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