3385 Scott Blvd., Santa Clara, CA 95054
Tel: +1/408.653.1260
Fax: +1/408.727.6622
Automation API
Reference Manual
for
Teledyne LeCroy USBTracer™, Advisor
T3™, USB Advisor™, Mercury T2, and
Voyager M3/M3i/M3x™
USB Protocol Suite Software Version 4.70 and above
Manual Version 4.71
September, 2013
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Document Disclaimer
The information contained in this document has been carefully checked and is believed to be
reliable. However, no responsibility can be assumed for inaccuracies that may not have been
detected.
Teledyne LeCroy reserves the right to revise the information presented in this document without
notice or penalty.
Trademarks and Servicemarks
CATC Trace, USBTracer, USBTrainer, USB Advisor, and Voyager are trademarks of Teledyne
LeCroy
Microsoft and Windows are registered trademarks of Microsoft Inc.
All other trademarks are property of their respective companies.
Appendix A. DCOM Configuration ................................................................. 130
Appendix B. How to Contact Teledyne LeCroy ............................................ 144
5
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
1 Introduction
USBTracer™, USB Advisor™, and Voyager™ USB Protocol Suite Automation is an Application Program
Interface (API) that allows users to create scripts or programs of commands and run these scripts or
programs locally or remotely over a network. The name Automation is derived from the goal of allowing
engineers to automate test procedures.
The USBTracer, USB Advisor, and Voyager USB Protocol Suite Automation API is composed of a
command set that duplicates most of the functionality of the USBTracer, USB Advisor, and Voyager
Graphical User Interfaces. Automation is implemented through the use of scripts or programs that the
user can write using late binding scripting languages such as VBScript and WSH or early binding
languages such as C++. Teledyne LeCroy provides examples of scripts written in WSH, VBScript, and
C++.
Once an Automation script or program has been created, it can be run on the PC attached to or
transmitted to the PC over a network from a remote location. Automation uses the
Distributed Component Object Model (DCOM) protocol to transmit automation commands over a
network. When run over a network, the Host Controller is configured as a DCOM server and the remote
PC is configured as a DCOM client.
Note:
If you are using any application that uses the Automation Interface to the USB Protocol Suite, and the
system prompts you that it cannot write a trace file to disk:
1. Make sure that the trace-file destination folder has write/create permissions. (For example, the target
directory might be the netwrok file system, which typically does not have write/create permissions.)
2. Make sure that the Windows (or other) Firewall Settings for USB Protocol Suite are set to Public.
1.1 System Requirements
Automation is supported with USBTracer/Trainer and USB Advisor software version 1.7 or higher and
Voyager USB Protocol Suite software version 3.0 or higher. If you have an older version of the software,
you must upgrade. You can get a new version of software from the Teledyne LeCroy web site,
www.teledynelecroy.com/support. You also need a copy of the USBTracer, USB Advisor, and
Voyager USB Protocol Suite Automation software package. This is available from Teledyne LeCroy.
IMPORTANT! To compile with the correct linkage to the USB Automation API code, you must move the
USBAutomation.tlb file from the application's installed directory into a directory from which your
compiler can access the file. For example, for Visual Studio, this typically is the directory that contains
your project file and sources.
1.2 Setting Up Automation for Local Use
If you intend to run Automation on the Analyzer Host Controller (the PC attached to the Analyzer), you
do not need to perform any special configuration. You can simply execute the scripts or programs you
have created, and they run the Analyzer.
6
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Objects
Interfaces
Description
UsbAnalyzer
IUsbAnalyzer
IUsbAnalyzer3
Primary Analyzer interface
_IAnalyzerEvents
Analyzer event source
UsbTrace
IUsbTrace
Trace file interfaces
IUsbTrace2
UsbRecOptions
IUsbRecOptions
Recording options interface
UsbDevice
IUsbDevice
USB device interface
AnalyzerErrors
IAnalyzerErrors
Error collection interface
UsbAnalyzer
UsbRecOptions
UsbTrace
UsbDevice
AnalyzerErrors
Suite
1.3 Setting Up Automation for Remote Use
If you intend to run automation remotely over a network, you must perform DCOM configuration. These
steps are described in the Appendix.
The USB Protocol Suite API exposes the following objects and interfaces:
Only the UsbAnalyzer object is creatable at the top level (that is, via the CoCreateInstance call),
instantiation of an object of other classes requires API calls. The following diagram represents the object
dependencies:
All interfaces are dual interfaces, which allow simple use from typeless languages as well as from C++.
All objects implement the ISupportErrorInfo interface for easy error handling from the client.
The examples of C++ code given in this document assume using the “import” technique of creating COM
clients, using the corresponding include statement:
#import "UsbAutomation.tlb" no_namespace named_guids
and creating appropriate wrapper classes in .tli and .tlh files by the compiler.
Samples of WSH, VBScript, and C++ client applications are provided.
7
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
IUsbAnalyzerinterface is the primary interface for theUsbAnalyzerobject. It derives from the
IAnalyzerinterface that implements the common functionality for all Teledyne LeCroy Analyzers.
Class ID: 136D64A4-3CD5-4b41-974A-C7039E3FC292
App ID: CATC.USBTracer
COM server: UsbSuite.exe
IUsbAnalyzer IID: C37E7603-E3E5-48b4-8F79-080DBB543F0C
2.1.1 IAnalyzer::GetVersion
Retrieves the current version of the specified subsystem.
Parameters
version_type Subsystem whose version is requested;
EAnalyzerVersionType enumerator has the following values:
ANALYZERVERSION_SOFTWARE ( 0 ) Software
ANALYZERVERSION_BUSENGINE ( 1 ) Bus engine
ANALYZERVERSION_FIRMWARE ( 2 ) Firmware
analyzer_version Current version of subsystem requested
Return values
ANALYZERCOMERROR_INVALIDVERSIONTYPE Specified version type is invalid.
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer device is not connected.
file_nameString providing the full pathname to the trace file traceAddress of a pointer to theUsbTraceobject primary interface
Return values
ANALYZERCOMERROR_UNABLEOPENFILEUnable to open file.
ANALYZERCOMERROR_WRONGCALL Error when trying to access the
opened trace when it is being
Remarks
UsbTraceobject is created via this method call, if call was successful.
In rare cases, the method may return ANALYZERCOMERROR_WRONGCALLerror. This may happen when
client code is trying to open an already opened trace file, while it is being released and destroyed.
Subsequent method calls will reopen the trace file.
released and destroyed.
11
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT StartGeneration (
[in] BSTR gen_file_name,
[in] long gen_mode,
[in] long loop_count );
Suite
2.1.4 IAnalyzer::StartGeneration
Starts USB 2.0 traffic generation from the file.
Parameters
gen_file_nameString providing the full pathname to the generation file.
If a valid name, the file is opened after any pre-existing
Generation File is closed in accordance with the behavior set
forth by Bit 31 in the gen_mode parameter.
If NULL string, it just closes any existing Generation File.
gen_modeGeneration mode:
Bit 0: 0 = bitstream; 1 = IntelliFrame
Bit 31: 0 = Load gen_file_name only if:
1. Different than pre-existing Generation Filename OR
2. The gen_file_name file is already loaded but has
been changed since the time it was loaded OR
3. The generation mode (bit 0) is different than the
previous invocation. Leaving this bit set to 0 allows
a file to be generated repeatedly without having to
be re-parsed or downloaded to the Analyzer
hardware, saving time.
loop_countNumber of times to repeat:
-1 = loop forever
1 through 16381 executes generation file that number of times.
Return values
ANALYZERCOMERROR_UNABLEOPENFILEUnable to open file
ANALYZERCOMERROR_UNABLESTARTGENERATIONUnable to start generation
E_INVALIDARG
Remarks
Used to load a .utg file and begin generating traffic.
Example
1 = Reload gen_file_name unconditionally.
(USB 3.0 generation is running,
invalid state, or other)
13
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT StopGeneration ( );
Suite
2.1.5 IAnalyzer::StopGeneration
Stops any current USB 2.0 generation in progress.
Return values
ANALYZERCOMERROR_UNABLESTARTGENERATIONUnable to stop generation
(invalid state, etc.).
Remarks
Stop any current traffic generation.
Example
14
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT StartRecording (
[in] BSTR ro_file_name );
Suite
2.1.6 IAnalyzer::StartRecording
Starts recording with specified recording options.
Parameters
ro_file_nameString providing the full pathname to recording options file.
If the parameter is omitted, then recording starts with the default
Return values
ANALYZERCOMERROR_EVENTSINKNOTINSTANTIATEDEvent sink was not instantiated.
ANALYZERCOMERROR_UNABLESTARTRECORDINGUnable to start recording.
Remarks
After recording starts, this function returns. The Analyzer continues recording until it is finished
or until a StopRecording method call is performed. During the recording, the events are sent to the
event sink (see the_IAnalyzerEventsinterface).
The recording options file is the file with extension .rec created by the USB Protocol Suite
application. You can create such a file by selecting Setup – Recording Options… from the
USB Protocol Suite application menu, changing the recording options in the dialog, and selecting the
Makes a recording with the specified recording options file.
Parameters
traceAddress of a pointer to theUsbTraceobject primary interface
Return values
Remarks
application. You can create such a file by selecting Setup – Recording Options… from the
USB Protocol Suite application menu, changing the recording options in the dialog, and selecting the
ro_file_nameString providing the full pathname to recording options file;
If the parameter is omitted, then recording starts with the
default recording options.
This method acts like StartRecording method but does not return until recording is completed.
UsbTraceobject is created via this method call, if call was successful.
The recording options file is the file with extension .rec created by the USB Protocol Suite
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Analyzer = WScript.CreateObject("CATC.USBTracer")
Set Trace = Analyzer.MakeRecording (CurrentDir & "Input\test_ro.rec")
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT LoadDisplayOptions (
[in] BSTR do_file_name );
Suite
2.1.9 IAnalyzer::LoadDisplayOptions
Loads display options that apply for traces opened or recorded later.
Parameters
do_file_nameString providing the full pathname to display options file
Return values
Remarks
method call apply only on trace files opened or recorded after this call.
You can create such a file by selecting Setup – Display Options… from the USB Protocol Suite
application menu, changing the display options in the dialog, and selecting the Save button.
Example
SeeITrace::ApplyDisplayOptions.
ANALYZERCOMERROR_UNABLELOADDOUnable to load display options file.
Use this method if you want to filter traffic of some type. The display options loaded by this
Display options file is the file with extension .opt created by the USB Protocol Suite application.
19
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT GetRecordingOptions (
[out, retval] IDispatch** recording_options );
Suite
2.1.10 IAnalyzer::GetRecordingOptions
Retrieves the primary interface for access to recording options.
Parameters
recording_optionsAddress of a pointer to theUsbRecOptionsobject
primary interface
Return values
Remarks
UsbRecOptionsobject is created via this method call, if call was successful.
Stops recording started by the StartRecording method and returns the pointer to the trace object
created.
Parameters
Return values
Remarks
This method stops recording started by the StartRecording method and does not return until the
recording is uploaded and a trace object related to this recording is created. In contrast, for
StopRecording, no event is issued when recording is stopped by this method.
In rare cases, the method may return ANALYZERCOMERROR_WRONGCALLerror. This may happen when
recording stopped by itself (for example, because buffer is full), and the method call occurs when the
recorded trace is being released and destroyed. Subsequent method calls will reopen the recorded
trace. To avoid this issue, use a recording-buffer size that is big enough, so that the method call will
occur when recording is still in progress and recording buffer is not full.
traceAddress of a pointer to theUsbTraceobject primary interface
ANALYZERCOMERROR_UNABLESTOPRECORDINGError when stopping recording
ANALYZERCOMERROR_WRONGCALL Error when trying to access
trace when it is being destroyed.
21
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Retrieves the full local path to the folder where the USB Protocol Suite application was installed and
registered as a COM server.
Parameters
Return values
Remarks
This property allows client applications to access some important files used by the USB Protocol Suite
application, such as recording options, display options, and trace files, in places relative to the USB
Protocol Suite application folder. If later the USB Protocol Suite application is re-installed to another
location, the client code does not have to be changed to reflect this event.
Example
WSH:
C++:
return;
app_folder Pointer to string variable indicating USB Protocol Suite application folder
Set Analyzer = WScript.CreateObject("CATC.UsbTracer")
' Open trace file 'some_trace.usb' in the USB Suite folder.
Set Trace = Analyzer.OpenFile( Analyzer.ApplicationFolder & "some_trace.usb" )
' Save opened trace as 'some_trace1.usb' in the USB Suite folder.
Trace.Save Analyzer.ApplicationFolder & "some_trace1.usb"
...
Retrieves the full local path to the folder for user-alterable data, such as scripts, traces, and default
options files.
Parameters
app_folder Pointer to string variable indicating the
Return values
Remarks
This property allows client applications to access some important files used by the USB Protocol Suite
application, such as recording options, display options, and trace files, in places relative to the USB
Protocol Suite application folder, Windows XP Documents and Settings\All Users folder, and
Windows Vista Users\Public folder. If later the USB Protocol Suite application is re-installed to another
location, the client code does not have to be changed to reflect this event.
Example
WSH:
Set Analyzer = WScript.CreateObject("CATC.UsbTracer")
' Open trace file 'some_trace.usb' in a user-modiable folder.
Set Trace = Analyzer.OpenFile(Analyzer. ApplicationDataFolder & "some_trace.usb")
' Save opened trace as 'some_trace1.usb' in a user-modiable folder.
Trace.Save Analyzer. ApplicationDataFolder & "some_trace1.usb"
...
gen_file_name USB 3.0 Exerciser script file name to execute.
If this parameter is an empty string, the last executed
Return values
ANALYZERCOMERROR_ANALYZERNOTCONNECTED No Analyzer connected
ANALYZERCOMERROR_UNABLESTARTGENERATION Analyzer cannot start for one of
the following reasons:
Remarks
This function returns after generation starts. Analyzer continues generating until it finishes or until the
StopUsb3Generation or PauseUsb3Generation method call is performed.
During generation, events are sent to the event sink (see the _IAnalyzerEvents interface section).
The script file should have the file extension “.usb3g”. It can be created by either the USB Protocol Suite
text editor or any plain-text editor.
script is repeated.
- Script has compiling error.
- Analyzer is currently running or paused.
- Analyzer is currently used by another client.
- License for trainer device was not purchased.
- USB 2.0 generation is running.
27
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
WSH (1):
See Automation\wsh\Usb3Exerciser.vbs
WSH(2):
Set Analyzer = WScript.CreateObject("CATC.UsbTracer", "Analyzer_")
' Tell the USB 3.0 Voyager Exerciser to start generation.
Analyzer. StartUsb3Generation CurrentDir & " \Input\Usb3ScriptExample.usb3g"
Dim doneGeneration
doneGeneration = 0
' Repeat Generation 49 more times.
For RepeatCount = 1 To 49
WScript.Sleep 100
Next
' Release the analyzer.
WScript.DisconnectObject Analyzer
' WScript.Echo "USBAnalyzer object has been disconnected."
Set Analyzer = Nothing
' WScript.Echo "Quitting WScript..."
WScript.Quit
' Handler of the event fired when recorded trace is created
' (after recording and uploading).
'
Sub Analyzer_OnStatusReport(ByVal subsystem, ByVal state, ByVal percent_done )
On Error Resume Next
if state = 400 Then
doneGeneration = 1
WScript.Echo "Generation finished"
End If
End Sub
VBScript:
On Error Resume Next
Analyzer.StartUsb3Generation PathToScript.value
If Err.Number <> 0 Then
MsgBox Err.Number & ":" & Err.Description
End If
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT StopUsb3Generation ();
Suite
2.1.15 IUsbAnalyzer::StopUsb3Generation
Stops USB 3.0 generation started by the StartUsb3Generation method.
Parameters
Return values
Remarks
Stops generation started by the StartUsb3Generation method. Generation stops if the analyzer is either
running or paused, and the analyzer then returns to the idle state.
Example
WSH:
Set Analyzer = WScript.CreateObject("CATC.UsbTracer", "Analyzer_")
' Tell the CATC USB analyzer to start generation.
Analyzer.StartUsb3Generation "example.usb3g"
WScript.Sleep 3000
' Tell the analyzer to stop recording.
Analyzer.StopUsb3Generation()
VBScript:
On Error Resume Next
Analyzer.StopUsb3Generation
If Err.Number <> 0 Then
MsgBox Err.Number & ":" & Err.Description
End If
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT PauseUsb3Generation ();
Suite
2.1.16 IUsbAnalyzer::PauseUsb3Generation
Pauses the currently running USB 3.0 generation.
Parameters
Return values
Remarks
Pauses the generation started by the StartUsb3Generation method. Generation pauses if the Exerciser
is running. However, the pause command cannot immediately pause traffic generation in all cases.
During execution of a generation script (.usb3g) file, some Send Packet instructions might be queued in
an output FIFO, and then pausing only takes effect after this buffer empties.
Example
WSH:
Set Analyzer = WScript.CreateObject("CATC.UsbTracer", "Analyzer_")
' Tell the CATC USB analyzer to start generation.
Analyzer.StartUsb3Generation "some_example.usb3g"
WScript.Sleep 3000
' Tell the analyzer to stop recording.
Analyzer.PauseUsb3Generation
VBScript:
On Error Resume Next
Analyzer.PauseUsb3Generation
If Err.Number <> 0 Then
MsgBox Err.Number & ":" & Err.Description
End If
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
ANALYZERCOMERROR_WRONGCALL Analyzer is not running
Calling this method causes the VBus power between the Host and the Device connected through the
Analyzer A and B USB ports to be broken for 1 second, simulating a unplug-plugin cycle. This is the
recommended method of creating plug-in scenarios.
Parameters
Return values
Remarks
Example
35
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT IssueManualTrig ();
Suite
2.2 IUsbAnalyzer3 interface
The IUsbAnalyzer3interface is the third interface for the UsbAnalyzer object. It inherits and extends
some analyzer-related functionality exposed via the IUsbAnalyzerinterface.
IID : 1D96A60E-AA3A-45e1-B6D5-C6AA27E65910
2.2.1 IUsbAnalyzer3:: IssueManualTrig
Issues manual trigger event to cause force trigger in analyzer engine.
Parameters
Return values
Remarks
Note that this method works with recording options that trigger mode is defined as manual
trigger.
36
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
The IUsbAnalyzer4interface is the forth interface for the UsbAnalyzer object. It inherits and extends
some analyzer-related functionality exposed via the IUsbAnalyzerinterface.
IID : D793E9EE-58EE-4237-9D2A-41DBB61DCDF8
2.3.1 IUsbAnalyzer4::GetRecordingStatus
This method could be used to poll recording state of analyzer after recording start. The method returns
useful running state information like happening trigger condition and recording finish. User may use this
method to poll status of recording and go to next step according to polling result.
Parameters
is_trigged Pointer to boolean variable indicating analyzer triggered or not.
is_done Pointer to boolean variable indicating recording process is finished or not
Return values
Remarks
A new method named as WaitForRecordingStatus is added to Anlyzer interface that could be used
instead of this method. The new method doesn’t block software normal operation and recommended to
use new method.
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
2.3.2 IUsbAnalyzer4::ResetUsb3Trainer
This method reset and initialize analyzer unit in “Host” trainer or “Device” trainer modes without runnig
any script.
Parameters
is_device_mode Specify desired mode.
“1” for “Device” mode, “0” for “Host” mode
Return values
Remarks
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
37
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
This method could be used to poll generation state after starting generation. The method returns status
of generation process. User may use this method to poll status of generation and go to next step
according to polling result.
Parameters
gen_idle Pointer to boolean variable indicating generation is done or not.
Return values
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
Remarks
A new method named as WaitForUsb3GenerationIdle is added to Anlyzer interface that could be
used instead of this method. The new method doesn’t block software normal operation and
recommended to use new method.
2.3.4 IUsbAnalyzer4::SwitchVBus
This method provides facilty to switch on/off VBus in USB3 trainer without running any script.
Parameters
switch_off if “1” switch off VBus, other switch on VBus.
Return values
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
Remarks
38
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
The IUsbAnalyzer5interface is the fifth interface for the UsbAnalyzer object. It inherits and extends
some analyzer-related functionality exposed via the IUsbAnalyzerinterface.
IID : 47CCA8A8-C4AC-4b90-ABD1-16DC2A5351FE
2.4.1 IUsbAnalyzer5::BindUnit
The method should be called when the API is used to control multiple anlayzer units. After creating any
analyzer object (for each unit), it is required to bind analyzer object to desired unit by calling this method.
Parameters
box_sn Specifies target UNIT serial number.
Return values
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
ANALYZERCOMERROR_UNABLESTARTRECORDING Multiple Unit Autopmation
License is not available
Remarks
Activation of this feature requires specific license.
2.4.2 IUsbAnalyzer5::MergeTraceFiles
The method is used for merging two trace file in one trace.
The IUsbAnalyzer6interface is the sixth interface for the UsbAnalyzer object. It inherits and extends
some analyzer-related functionality exposed via the IUsbAnalyzerinterface.
IID : 866DA1BD-9AD4-4627-A32A-C0F229684300
2.5.1 IUsbAnalyzer6::WaitForUsb3GenerationIdle
The method is introduced as replacement for legacy method “IsUsb3GenerationIdle”. The method polls
internally for generation running and returns when generation finishes. Method will return if specified
timeout is passed and generation is still running to prevent hangs/block conditions.
Parameters
wait_time_milisec Specifies time-out for waiting before return in milliseconds
spent_time_milisec Pointer to long value which returns spent time in this method
is_done Pointer to boolean value indicating Generation done or time-out
happened
Return values
Remarks
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
2.5.2 IUsbAnalyzer6::WaitForRecordingStatus
The method is introduced as replacement for legacy method “GetRecordingStatus”. The method polls
internally for analyzer running and returns when analyzer reaches to desired state(s). Method will return
if specified timeout is passed and analyzer has not reached to desired state(s).
40
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Parameters
wait_time_milisec Specifies time-out for waiting before return in milliseconds
desired_state Specify desired analyzer state(s) [see remarks] to return from
method
spent_time_milisec Pointer to long value which returns spent time in this method
is_done Pointer to boolean value indicating desired state has been
reached or time-out happened
Return values
ANALYZERCOMERROR_ANALYZERNOTCONNECTED Analyzer is not connected
Remarks
State value could be combination of following values:
RSTAT_DONE 0x4000
RSTAT_TRIGGERED 0x2000
RSTAT_WAITING_FOR_SYNC_REC 0x1000
41
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
3 Primary Dual Interface for Trace
3.1 IUsbTrace Dual Interface
IUsbTraceinterface is the primary interface for theUsbTraceobject. It derives from the ITrace
interface that implements the common functionality for all Teledyne LeCroy Analyzers.
42
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT ApplyDisplayOptions (
[in] BSTR do_file_name );
Suite
3.1.2 ITrace::ApplyDisplayOptions
Applies the specified display options to the trace.
Parameters
do_file_nameString providing the full pathname to display options file
Return values
Remarks
application. You can create such a file by selecting Setup – Display Options… from the USB Protocol
Suite application menu, changing the display options in the dialog, and selecting the Save button.
Example
WSH:
C++:
IUsbTrace* usb_trace;
. . .
{
ANALYZERCOMERROR_UNABLELOADDOUnable to load display options file.
Use this method if you want to filter traffic of some type in the recorded or opened trace.
The display options file is the file with extension .opt created by the USB Protocol Suite
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT Save (
[in] BSTR file_name,
[in, defaultvalue(-1)] long packet_from,
[in, defaultvalue(-1)] long packet_to );
Suite
3.1.3 ITrace::Save
Saves the trace into a file and allows you to save a range of packets.
Parameters
file_nameString providing the full pathname to file where trace is saved
packet_fromBeginning packet number when you are saving a range of packets.
Value –1 means that the first packet of saved trace would be the first packet of
this trace.
packet_toEnding packet number when you are saving a range of packets.
Value –1 means that the last packet of saved trace would be the last packet of
this trace.
Return values
ANALYZERCOMERROR_UNABLESAVEUnable to save trace file.
Remarks
Use this method if you want to save a recorded or opened trace into a file. If display options
apply to this trace (seeITrace::ApplyDisplayOptions or IAnalyzer::LoadDisplayOptions), then hidden
packets are not saved.
If packet range is specified and it is invalid (for example packet_to is more then last packet
number in the trace, or packet_from is less than first packet number in the trace, or packet_from is
more then packet_to), then packet range adjusts automatically.
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT ExportToText (
[in] BSTR file_name,
[in, defaultvalue(-1)] long packet_from,
[in, defaultvalue(-1)] long packet_to );
Suite
3.1.4 ITrace::ExportToText
Exports the trace into a text file and allows you to export a range of packets.
Parameters
Return values
Remarks
Use this method if you want to export a recorded or opened trace into a text file. If display
options apply to this trace (see ITrace::ApplyDisplayOptions or IAnalyzer::LoadDisplayOptions), then
hidden packets are not exported.
If packet range is specified and it is invalid (for example, packet_to is more than last packet
number in the trace, or packet_from is less than first packet number in the trace, or packet_from is
more than packet_to), then packet range adjusts automatically.
file_nameString providing the full pathname to file where trace is exported
packet_fromBeginning packet number when you are exporting a range of packets.
Value –1 means that the first packet of exported trace would be the first packet
of this trace.
packet_toEnding packet number when you are exporting a range of packets.
Value –1 means that the last packet of exported trace would be the last packet
of this trace.
ANALYZERCOMERROR_UNABLESAVEUnable to export trace file.
Here is a snippet of an export file for a Bluetooth Trace. A USB Trace file would look similar:
46
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
File E:\AnalyzerSw\Chief20\OfficialUTGFiles\SRP.usb.
From Packet #13 to Packet #24.
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT Close ( );
Suite
3.1.5 ITrace::Close
Closes the trace.
Parameters
Return values
Remarks
Closes current trace but does not releases interface pointer. Call the IUnknown::Release
method right after this method call. No ITrace method call succeeds after calling the ITrace::Close
method.
(Currently there is no need to call ITrace::Close directly since IUnknown::Release closes the
trace.)
Example
48
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT ReportFileInfo (
[in] BSTR file_name );
Suite
3.1.6 ITrace::ReportFileInfo
Saves trace information into the specified text file.
Parameters
Return values
ANALYZERCOMERROR_UNABLESAVEUnable to create trace information report.
Remarks
Creates trace information file if necessary. Stores trace information in specified file. Here is an
example of data stored using this method call:
File name : data.usb
Comment :
Recorded on Channel number : 0
Number of packets : 22514
Trigger packet number : 0
Recorded with application version 1.70 ( Build 102 )
Analyzer Serial Number 00213
Traffic Generation enabled
Firmware version 1.06 ( ROM 1.02 )
BusEngine version 1.90
BusEngine type 1
UPAS Slot 1 Part# US005MA PlugIn ID: 0x01 Version 0x4
UPAS Slot 2 Part# US005MG PlugIn ID: 0x04 Version 0x4
Number of markers : 1
Recording Options:
Options Name: Default
Recording Mode: Snapshot
Buffer Size: 2.000 MB
Post-trigger position: 50%
Base filename & path: E:\AnalyzerSw\Chief20\Debug_UPA\data.usb
Save External Signals No
Auto-Merge No
Truncate Data No
Devices setup for On-the-Go operation
2 DRD's: A device is named Camera, B device is named Printer
Assumes first trace data is captured when A-Device is Host
Channel 0 Trace Speed Recording Mode: Full Speed Only
Channel 0 Recording Events:
Channel 1 Trace Speed Recording Mode: Full Speed Only
Channel 1 Recording Events:
Channel 0 is Full Speed.
Recorded on product: USBTracer
License information for the USBTracer unit, Serial Number 00213, used to record this trace file
:
Software maintenance hasn't been enabled.
file_nameString with full pathname to file where trace information report is created
49
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
WSH:
C++:
IUsbTrace* usb_trace;
{
Set Analyzer = WScript.CreateObject("CATC.USBTracer")
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Trace = Analyzer.MakeRecording (CurrentDir & "Input\test_ro.rec")
Trace.ReportFileInfo CurrentDir & "Output\file_info.txt"
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT ReportErrorSummary (
[in] BSTR file_name );
Suite
3.1.7 ITrace::ReportErrorSummary
Saves trace error summary information into the specified text file.
Parameters
Return values
ANALYZERCOMERROR_UNABLESAVEUnable to create trace information report.
Remarks
Creates error summary file if necessary. Stores error summary in specified file. Here is an
example of data stored using this method call:
Error report for SRP.usb recording file.
_______|_______________________________________________________________________
Bad PID (0):
_______|_______________________________________________________________________
Bad CRC5 (0):
_______|_______________________________________________________________________
Bad CRC16 (0):
_______|_______________________________________________________________________
Bad Packet Length (0):
_______|_______________________________________________________________________
Bad Stuff Bits (0):
_______|_______________________________________________________________________
Bad EOP (0):
_______|_______________________________________________________________________
Babble Start (0):
_______|_______________________________________________________________________
Babble End (LOA) (0):
_______|_______________________________________________________________________
Bad Frame Length (0):
_______|_______________________________________________________________________
Bad Turnaround/Timeout (0):
_______|_______________________________________________________________________
Bad Data Toggle (1):
_______| 0.20;
_______|_______________________________________________________________________
Bad Frame/uFrame Number (0):
_______|_______________________________________________________________________
Analyzer Internal Error (0):
_______|_______________________________________________________________________
Last Byte Incomplete (0):
_______|_______________________________________________________________________
file_nameString providing the full pathname to file where error summary report is created
51
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
WSH:
C++:
IUsbTrace* usb_trace;
{
Set Analyzer = WScript.CreateObject("CATC.USBTracer")
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Trace = Analyzer.MakeRecording (CurrentDir & "Input\test_ro.rec")
Trace.ReportErrorSummary CurrentDir & "Output\error_summary.txt"
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT ReportTrafficSummary(
[in] BSTR file_name );
Suite
3.1.8 ITrace::ReportTrafficSummary
Saves trace traffic summary information into the specified text file.
Parameters
file_nameString providing the full pathname to file where traffic summary report is
Return values
ANALYZERCOMERROR_UNABLESAVEUnable to create or save traffic summary report.
Remarks
Creates traffic summary report file, if necessary. Stores traffic summary in the specified file. Here is an
example of data stored using this method call:
Example
WSH:
Set Analyzer = WScript.CreateObject("CATC.USBTracer")
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Trace = Analyzer.MakeRecording (CurrentDir & "Input\test_ro.rec")
Trace.ReportTrafficSummary CurrentDir & "Output\traffic_summary.txt"
packet_numberNumber of packet to retrieve
packetRaw packet representation
number_of_bits Number of bits in raw packet representation
Return values
ANALYZERCOMERROR_INVALIDPACKETNUMBERSpecified packet number is invalid
Remarks
The packet parameter has VT_ARRAY | VT_VARIANTactual automation type. Each element
of this array has VT_UI1 automation type. Since the last element of the array may contain extra data,
you need to use the number_of_bits parameter to determine the actual packet data.
54
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT AnalyzerErrors (
[in] long error_type,
[out, retval] IAnalyzerErrors** analyzer_errors );
Suite
3.1.12 ITrace::AnalyzerErrors
Retrieves trace file errors.
Parameters
long error_typeType of error collection you want to retrieve; the following values
are valid:
0x00000001 - Pid Error
0x00000002 - CRC5 Error
0x00000004 - CRC16 Error
0x00000008 - Packet Length Error
0x00000010 - Stuff Bit Error
0x00000020 – EOP Error
0x00000040 – Babble Start Error
0x00000080 – Babble End Error (LOA)
0x00000100 – Frame Length Error
0x00000200 – Handshake Timeout Error
0x00000400 – Analyzer Internal Error
0x00000800 – Data Toggle Error
0x00001000 – Microframe Error
analyzer_errorsAddress of a pointer to the AnalyzerErrors object primary
Return values
ANALYZERCOMERROR_INVALIDERROR Invalid error type specified
Remarks
AnalyzerErrors object is created via this method call, if call was successful.
0x00002000 – Short Byte Error (bits missing)
interface
59
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
3.2 IUsbTrace2 interface
The IUsbTrace2interface is the second interface for the UsbTrace object. It inherits and extends some
trace-related functionality exposed via the IUsbTraceinterface.
IID : 149B95E9-C17D-43b3-AC0D-30419A485058
60
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT GotoTime ( [in] double time );
Suite
3.2.1 IUsbTrace2::GotoTime
Instructs the trace view to jump to the specified timestamp.
Parameters
time Time (in nanoseconds) to jump
Example
WSH:
C++:
IUsbTrace2* Usb_trace;
. . .
{
double t = 1000000.0;
Set Analyzer = WScript.CreateObject("CATC.UsbTracer")
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Analyzer.StartRecording (CurrentDir & "test_ro.rec")
'... Do something.
Set Trace = Analyzer.StopRecordingAndWaitForTrace
Trace.GotoTime( 1000000 ) ' Go to 1 millisecond timestamp.
try
Usb_trace ->GotoTime( t );
}
catch (_com_error& er)
{
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT ExportToCsv(
[in] BSTR file_name,
[in] long level,
[in, defaultvalue(-1)] long unit_from,
[in, defaultvalue(-1)] long unit_to );
Suite
3.2.3 IUsbTrace2::ExportToCsv
Exports a trace into a text file in CSV format and allows exporting a range of packets.
Parameters
file_name String providing the full pathname of the trace export file
level Transaction level
0 – Packets
1 – USB Transactions
(Currently only these are supported.)
unit_from Beginning packet number when you are exporting a range of packets. Value –1
makes the first packet of the exported trace be the first packet of the trace.
unit_to Ending packet number when you are exporting a range of packets.
Value –1 makes the last packet of the exported trace be the last packet of the
Return values
ANALYZERCOMERROR_UNABLESAVE Unable to export trace file
Remarks
Use this method if you want to export a recorded or opened trace into a text file in CSV format. If display
options apply to this trace (see ITrace::ApplyDisplayOptions or
IAnalyzer::LoadDisplayOptions), then hidden units would not be exported.
If a unit range is specified and it is invalid (for example, unit_to is more than the last unit number in the
trace, or unit_from is less than first unit number in the trace, or unit_from is more then unit_to) then
unit range adjusts automatically.
trace.
63
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
WSH:
C++:
. . .
Set Analyzer = WScript.CreateObject("CATC.UsbTracer")
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
' Please specify the real path to the trace file instead of 'C:\test.usb'.
Set Trace = Analyzer.OpenFile ( "C:\test.usb" )
' Instructs the USB Protocol Suite application to locate packet # 15
' (transaction level 0) in the trace viewer.
Trace.GotoUnit 0, 15
' Instructs the USB Protocol Suite trace viewer to jump to the trace unit
' with the timestamp close to 6000 ns (6 microsecond).
Trace.GotoTime 6000
' Exports USB transactions (from #0 to #10 ) into CSV format.
' 1st parameter - file name of the export file
' 2nd parameter - transaction level ( 0 - packets, 1 - transactions )
' 3rd parameter - unit number to start with
' 4th parameter - unit number to end by
Trace.ExportToCsv CurrentDir & "Output\text_csv_export.csv", 1, 0, 10
The IUsbTrace3interface is the third interface for the UsbTrace object. It inherits and extends some
trace-related functionality exposed via the IUsbTrace3interface.
IID : 4DA2A987-47B3-4384-BFA8-2052326FBE0E
3.3.1 IUsbTrace3:: GetPowerInfoByTime
Returns voltage, current, and power values based on a time in nanoseconds.
Parameters
time timestamp in nanoseconds
voltage voltage in microvolts
current current in microamps
Return values
Remarks
power power in microwatts.
BOOL TRUE if power values were recorded at the time.
3.3.2 IUsbTrace3:: GetPowerInfoByPacket
Returns voltage, current, and power values based on a packet number..
Parameters
packet_number Packet number in the trace file
66
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
voltage voltage in microvolts
current current in microamps
power power in microwatts.
Return values
BOOL TRUE if power values were recorded at that packet_number.
Remarks
67
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
The IUsbTrace4interface is the forth interface for the UsbTrace object. It inherits and extends some
trace-related functionality exposed via the IUsbTrace3interface.
IID : C7D741F6-D425-417f-B7FC-4DB0FB01804B
3.4.1 IUsbTrace4:: GetFullName
Returns full path/name of trace file.
Parameters
trace_name Pointer to string to retrieve trace file full path
Return values
Remarks
68
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT GetUsbPacket(
[in] long packet_number,
[out, retval] IDispatch** usb_packet )
Suite
3.5 IUsbTrace5 interface
The IUsbTrace5interface is the fifth interface for the UsbTrace object. It inherits and extends some
trace-related functionality exposed via the IUsbTrace4 interface.
IID : CAC0F43F-322E-4165-9BB6-E0DBDD95B682
3.5.1 IUsbTrace5::GetUsbPacket
Retrieves a pointer to the specified packet.
Parameters
Packet_number Number of packet to retrieve.
Return values
Remarks
Usb_packet Address of a pointer to the UsbPacketobject primary interface.
69
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
3.6 IUsbVerificationScript Interface
The IUsbVerificationScript interface is the fourth interface for the UsbTrace object. It exposes the
trace functionality for running verification scripts. It derives from the IVerificationScript interface, which
implements the common functionality for running Teledyne LeCroy PSG verification scripts over
recorded traces. This interface is not dual, so scripting languages cannot use it directly, though some or
all of its methods are exposed to script languages through the primary UsbTrace automation interface.
IID : F1ED8DB5-2EC6-4fa0-8F8B-D645A1FA4A85Remarks
Verification scripts are special scripts written using Teledyne LeCroy PSG Script Language (CSL), which
can be “run” over the recorded trace to “verify” the trace for some verification conditions or to extract
more advanced information from the trace. Such scripts utilize a special feature of the USB Protocol
Suite application called the “Verification Script Engine”. This feature must be enabled for you to run
verification scripts.
(For more information, refer to the USB Protocol Suite User Manual and the USB Protocol Suite VSEngine Manual.)
70
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
verification_scriptName or full path of the verification script to run pResultAddress of a variable in which to keep the result of
verification
VS_RESULT is an enumeration type that can have these possible meanings:
enum VS_RESULT
{
SCRIPT_RUNNING = -2, // Verification script is running.
SCRIPT_NOT_FOUND = -1, // Verification script with the specified name was
// not found.
FAILED = 0, // Verification failed.
PASSED = 1, // Verification passed.
DONE = 2 // Verification is done, don’t care about result.
};
Return values
S_OK If the verification script executed successfully.
Remarks
The name of the verification script is the name of the verification script file (*.vse) without the file
extension. For example, for verification script file test.vse, the test name is test. Please refer to the
Teledyne LeCroy UWB Script Verification Engine Manual for details.
If a full path is specified (such as C:\test.vse), VSE uses it, instead of searching for the script by name in
the \Scripts\VFScripts application subfolder.
71
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
C++:
// In this example, use wrapper functions provided by #import directive.
script_nameName or full path of the verification script to initialize the script
verification engine
pVSEngineAddress of a pointer to the VScriptEngine object primary interface
Return values
S_OK If verification script engine object was successfully retrieved.
Remarks
The name of the verification script is the name of the verification script file (*.vse) without the file
extension. See remark to RunVerificationScript(…) for details.
Example
C++:
// In this example, use wrapper functions provided by #import directive.
Retrieves the values of all available fields. It returns three arrays that contain name, value and size of
fields.
Parameters
fields_namesArray of strings containing fields names.
fields_valuesArray of DWORDs or bytes arrays containing fields values. If
size of field value is less than or equal to 4 bytes it is DWORD
otherwise bytes array.
fields_values_bit_sizeArray of integers containing size of fields in bit. fields_countPointer to integer variable containing count of fields.
Return values
Remarks
The bit order and byte order are little-Endian for all fields always.
4.1.8 IUsbPacket::GetMarker
Retrieves the marker text of current packet.
Parameters
markerPointer to string variable where marker text is retrieved.
Return values
Remarks
4.1.9 IUsbPacket::GetErrorsBitmap
Retrieves the errors of packet.
Parameters
78
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
errors_bitmapPointer to unsigned 64 bits integer variable where errors are retrieved.
Return values
Remarks
Format of returned errors bitmap is as below:
Bit 0 : Reserved
Bit 1 : USB2 PID Error
Bit 2 : USB2 CRC5 Error
Bit 3 : USB2 CRC16 Error
Bit 4 : USB2 Packet Length Error
Bit 5 : USB2 Bit Stuff Error
Bit 6 : USB2 EOP Error
Bit 7 : USB2 Babble Start Error
Bit 8 : USB2 Babble End Error
Bit 9 : USB2 Frame Length Error
Bit 10 : USB2 Turnaround/Timeout Error
Bit 11 : USB2 Analyzer Internal Error
Bit 12 : USB2 Data Toggle Error
Bit 13 : USB2 Frame/uFrame Number Error
Bit 14 : USB2 Last Byte Incomplete Error
Bit 15 : USB2 OTG Signal Error
Bit 16 : USB3 CRC5 Error
Bit 17 : USB3 CRC16 Error
Bit 18 : USB3 CRC32 Error
Bit 19 : USB3 Disparity Error
Bit 20 : USB3 10 Bit Symbol Error
Bit 21 : USB3 Unknown Packet(IPS) Error
Bit 22 : USB3 Framing Symbol Error
Bit 23 : USB3 LC Data Symbol Error
Bit 24 : USB3 Bad Header Packet Length Error
Bit 25 : USB3 Bad Data Length Field Error
Bit 26 : USB3 SKP Symbol Error
Bit 27 : USB3 Control Endpoint Direction Error
Bit 28 : USB3 Missed DPH Error
Bit 29 : USB3 Missed DPP Error
Bit 30 : USB3 Setup DP Error
Bit 31 : USB3 Sequence Number Error
Bit 32 – 44 : Reserved
Bit 45 : USB3 TP Non-Zero Reserved Error
Bit 46 : USB3 Missed ITP Error
Bit 47 : USB3 Late/Early ITP Error
Bit 48 – 63 : Reserved
Note that below errors bits are valid after transaction level decoding:
Bit 4 : USB2 Packet Length Error
Bit 10 : USB2 Turnaround/Timeout Error
Bit 12 : USB2 Data Toggle Error
Bit 27 : USB3 Control Endpoint Direction Error
Bit 46 : USB3 Missed ITP Error
79
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Retrieves the ten bit symbols of USB3 packets.
Parameters
symbles_array Array of DWORDs containing returned symbols. array_size Pointer to integer variable containing count of returned symbols.
Return values
Remarks
Format of returned symbols are as below:
81
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
5 Primary Dual Interface for USB Verification Script
Engine
5.1 IVScriptEngine interface
The IVScriptEngine interface is the primary dual interface for the UsbVScriptEngine object. It
implements the common functionality for the Teledyne LeCroy PSG verification script engine (VSE). The
main advantage of the IVScriptEngine interface is that it allows clients to implement the
_IVScriptEngineEvents callback interface to receive notifications when a verification script is running.
IID : 67FC41C6-0FEE-4b95-8EE0-A5724661FE98
82
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Property putting and getting current verification script name.
Parameters
*pValAddress of variable in which to store current verification script name newValName of the verification script to initialize script verification engine
Return values
Remarks
The name of the verification script is the name of the verification script file (*.vse) without the file
extension.
Example
C++:
// In this example, use wrapper functions provided by #import directive.
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
[propget] HRESULT Tag([out, retval] int* pVal);
[propput] HRESULT Tag([in] int newVal);
Suite
5.1.2 IVScriptEngine::Tag
Property assigning and getting a tag to the VSE object. This tag is used in event notifications, allowing a
client event handler to determine which VSE object sent the event.
Parameters
*pValAddress of variable in which to store current VSE tag newValNew tag for VSE
Return values
Remarks
Example
C++:
// In this example, use wrapper functions provided by #import directive.
Changes the current verification script name and runs verification script.
Parameters
script_nameName of the verification script to initialize script verification engine. PResult Address of variable in which to store the result of verification.
Return values
Remarks
This method makes a “synchronous” call, so this method does not return until the script stops running.
Example
C++:
// In this example, use wrapper functions provided by #import directive.
VS_RESULT result = usb_vsengine ->LaunchVScript();
// You can go further without waiting for the result from the VSE object.
// If you are interested in the result, implement the client event handler for
// OnVScriptFinished() notification.
. . .
(either it is already running or verification script was not found).
87
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
HRESULT Stop();
Suite
5.1.6 IVScriptEngine::Stop
Stops verification script previously launched by the IVScriptEngine::LaunchVScript method.
Parameters
Return values
Remarks
Example
C++:
// In this example, use wrapper functions provided by #import directive.
Returns the value of some verification script variable before/after executing the script. The resulting
value may contain an integer, a string, or an array of VARIANTs (if the requested script variable is a list
object – see the CSL Manual for more details about list objects).
Parameters
var_name String providing the name of the global variable or constant
var_value Address of a VARIANT variable in which result will be stored.
Return values
E_PENDING If this method is called when script running is in progress
Remarks
If there is no such global variable or constant with the name 'var_name', the resulting value contains an
empty VARIANT.
used in the running verification script.
89
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
C++:
// In this example, use wrapper functions provided by #import directive.
Allows you to set the value of some verification script variable before/after executing the script. Only
integers, strings, or arrays of VARIANTs are allowed. Arrays of VARIANTs are converted into list values
inside of scripts – see the CSL Manual for more details about list objects.
Parameters
var_name String providing the name of the global variable used in the
var_value VARIANT value containing new variable value.
Return values
E_PENDING If this method is called when script running is in progress.
Remarks
This function allows you to set internal script variables before/after script run, so you can make run-time
customizations from COM/Automation client applications.
If there is no such global variable with the name 'var_name', a new variable with that name is created.
running verification script.
91
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
Example
C++:
// In this example, use wrapper functions provided by #import directive.
IUsbTrace* usb_trace;
. . .
IUsbVerificationScript* usb_vscript = NULL;
assert( usb_vscript != NULL );
. . .
WSH:
. . .
Set Trace = Analyzer.OpenFile( TraceName ) ' Open the trace.
// Set internal script variable 'MyVar' to 100.
usb_vsengine->SetScriptVar( _bstr_t("MyVar"), my_var );
VS_RESULT result = usb_vsengine ->RunVScript();
Set VSEngine = Trace.GetVScriptEngine( VScript ) ' Get VS Engine object.
92
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
6 Verification Script Engine Events Callback
Interface
6.1 _IVScriptEngineEvents dispinterface
To retrieve the event notifications from the UsbAnalyzer application when a verification script engine
object is running a script, you must implement the _IVScriptEngineEvents callback interface.
Because this interface is a default source interface for the IVScriptEngine object, there is a very simple
implementation from such languages as Visual Basic, VBA, VBScript, and WSH.
Remarks
Some script engines impose restrictions on handling events from “indirect” automation objects in
typeless script languages (when the automation interface to the object is obtained from a call of some
method, rather than from a creation function – like CreateObject() in VBScript). Teledyne LeCroy PSG
USB Protocol Suite™ provides a special COM class that allows receiving and handling notifications from
VSE objects, even in script languages not supporting event handling from "indirect" objects.
(Please refer to CATCAnalyzerAdapter for details.)
Example
The C++ implementation used in the examples below implements an event sink object by deriving from
IDispEventImplbut not specifying the type library as a template argument. Instead, the type library and
default source interface for the object are determined using AtlGetObjectSourceInterface(). A
SINK_ENTRY()macro is used for each event from each source interface to be handled:
93
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
C++:
class CVSEngineSink : public IDispEventImpl<IDC_SRCOBJ_VSE, CVSEngineSink >
{
public:
. . .
BEGIN_SINK_MAP(CVSEngineSink)
// Make sure the Event Handlers have __stdcall calling convention.
SINK_ENTRY( IDC_SRCOBJ_VSE, 1, OnVScriptReportUpdated )
SINK_ENTRY( IDC_SRCOBJ_VSE, 2, OnVScriptFinished )
END_SINK_MAP()
HRESULT __stdcall OnVScriptReportUpdated ( BSTR newLine, int TAG ); HRESULT __stdcall OnVScriptFinished( BSTR script_name, VS_RESULT result, int TAG ); HRESULT __stdcall OnNotifyClient ( int eventId, VARIANT eventBody, int TAG );
CVSEngineSink vse_sink;
HRESULT hr = vse_sink . Advise( vscript_engine ); // “Subscribe” for receiving events
...
VS_RESULT res = SCRIPT_NOT_FOUND;
try
{
res = (VS_RESULT)vscript_engine ->RunVScript();
}
catch ( _com_error& er)
{ SetStatusError( er ); }
// Tear connection with the test case.
vse_sink. Unadvise( vscript_engine );
...
94
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
VBA: ( MS Excel )
Public USBTracer As UsbAnalyzer
Public Trace As UsbTrace
Public GVSEngine As VScriptEngine
'
' VSEngineEventsModule is a special class implementing VSE event handlers.
' It should have, in global declaration section, a line like this:
' Public WithEvents VSEEvents As VScriptEngine
'
Dim X As New VSEngineEventsModule
Private Sub RunVScritButton_Click()
Dim VSEngine As VScriptEngine
Dim IVScript As IUsbVerificationScript
Dim ScriptName, fileToOpen As String
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
[id(3)] HRESULT OnNotifyClient( [in] int eventId,
[in] VARIANT eventBody,
[in] int TAG );
Suite
6.1.3 _IVScriptEngineEvents::OnNotifyClient
Fires when running verification script calls NotifyClient() function.
Parameters
EventId Event Id
eventBody Body of event packed in a VARIANT object
Return values
Remarks
The information packed in the event body is opaque for VSE, which only packs the information given to
NotifyClient() function inside of a verification script into a VARIANT object and sends it to client
applications.
(See Teledyne LeCroy PSG USB Verification Script Engine Manual for details about the NotifyClient()
script function.)
For Each Item In eventBody
ThisWorkbook.Sheets("Sheet1").Cells(LineIndex, Col) = Item
Col = Col + 1
Next
Else
ThisWorkbook.Sheets("Sheet1").Cells(LineIndex, 2) = eventBody
End If
LineIndex = LineIndex + 1
End Sub
99
Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite
7 Primary Dual Interface for Recording
Options
7.1 IUsbRecOptions Dual Interface
The IUsbRecOptionsinterface is the primary interface for theIBRecOption object. It derives from the
IRecOptionsinterface that implements the common functionality for all Teledyne LeCroy Analyzers.
100
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.