3385 Scott Blvd.
Santa Clara, CA 95054
Tel: +1/408.727.6600
Fax: +1/408.727.6622
Automation API
for
LeCroy SAS/SATA Tracer/Trainer
Reference Manual
Manual Version 1.11
For SAS/SATA Tracer/Trainer Software Version 2.60/4.60
May 2010
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
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.
LeCroy reserves the right to revise the information presented in this document without
notice or penalty.
Trademarks and Servicemarks
LeCroy, CATC, SASTracer, SATracer, SASTrainer, SATrainer Automation are trademarks
of LeCroy Corporation.
Microsoft and Windows are registered trademarks of Microsoft Inc.
All other trademarks are property of their respective companies.
This document may be printed and reproduced without additional permission, but all copies
should contain this copyright notice.
Version
This is version 1.11 of the SASTracer/SATracer Automation API Reference Manual. This
manual applies to SASTracer/SATracer software version 2.60/4.60 and higher.
ii
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
LeCroy’s SASTracer/SATracer software provides a rich, functional COM/Automation API to
the most important functionalities of the LeCroy SASTracer/SATracer Protocol Analyzer and
LeCroy SASTrainer/SATrainer Exerciser. This makes it a great tool for implementation of
automated programs for complicated testing, development and debugging. The "dual" nature of
the interfaces provided makes it easy to use the SASTracer/SATracer COM API in different
Integrated Development Environments (IDE) supporting the COM architecture.
Special support for typeless script languages (such as VB and JavaScript), while overri ding
some restrictions imposed by script engines (remote access, dynamic object creation, and
handling events), allows you to write client applications quickly and easily. You do not need
significant programming skills. or installation of expensive and powerful programming language
systems. All these features, along with the ability to set up all necessary DCOM permissions
during the installation process, make the LeCroy SASTracer/SATracer an attractive tool for
automating and speeding many engineering processes.
1.1 System Requirements
The Automation API was introduced with the following release: SASTracer/SATracer
software 2.60/4.60.
This document covers the functionality available in SASTracer/SATracer 2.60/4.60.
1.2 Support Resources
As new functionalities are added to the API, not all of them are supported by older versions
of the analyzer's software. For newer releases of analyzer software, please refer to the LeCroy
web site: www.lecroy.com
1.3 Setting Up Automation for Local Use
To run Automation on the SASTracer/SATracer's Host Controller (the PC attached to the
SASTracer/SATracer), you do not need to perform any special configuration. You can simply
execute the scripts or programs that you have created and they will run the analyzer. In order to
use the SASTracer/SATracer COM API, during the installation process the application should be
registered as a COM server in a system registry.
1.4 Setting Up Automation for Remote Use
To access SASTracer/SATracer remotely over a network, install the SASTracer/SATracer
application on both server and client systems and accept the Enabling Remote Access option
during installation. You can also perform a manual DCOM configuration.
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
2 SASTracer/SATracer Object Model
LeCroy’s SASTracer/SATracer API programmatically exposes its functionality through
objects. You work with an object by using its properties and methods. Objects are named
according to the portion of an application they represent, and they are ordered in a hierarchy.
A single object occupies the topmost tier of LeCroy SASTracer/SATracer object hierarchy:
SASAnalyzer.
The following object model diagram shows how the objects in an object model fit together:
Only the SASAnalyzer object is creatable at the top level (for instance, via the
CoCreateInstance call from a C/C++ client). Instantiation of an object of other classes requires
API calls.
The Class ID and App ID for the SASAnalyzer object are the following.
Class ID: SASAnalyzer 12A4B62B-107A-42AE-9C56-08C5EC3C26E2
AppID: SASAnalyzer Lecroy.SASAnalyzer
All interfaces are dual interfaces that allow simple use from typeless languages (like
VBScript), as well as from C/C++.
All objects implement the ISupportErrorInfo interface for easy error handling from the client.
6
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
Objects Interfaces Description
SASAnalyzer ISASAnalyzer
_ISASAnalyzerEvents
SASTrace ITrace
ISASTrace*
ISASVerificationScript*
SASRecOptions IRecOptions
ISASRecOptions
SASPacket IPacket
ISASPacket*
SASTraceErrors ISASAnalyzerErrors*
* Primary interfaces
The examples of C++ code given in this document assume using the “import” technique of
creating COM clients. That means the corresponding include is used:
Appropriate wrapper classes are created in .tli and .tlh files by the compiler.
Examples of WSH, VBScript, and C++ client applications are provided.
Represents the SASTracer application.
Represents recorded trace.
Represents recording options.
Represents single packet of the recorded
trace.
Represents the collection of errors that
occurred in the recorded trace.
7
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
3 SASAnalyzer Object
The SASAnalyzer object is the top-level object of the SASTracer API. The SASAnalyzer
object allows you to control recording and traffic generation, open trace files, and access
recording and generation options. The SASAnalyzer object supports the following interfaces:
Interfaces Description
ISASAnalyzer
_ISASAnalyzerEvents
The ISASAnalyzer interface is the primary interface for the SASAnalyzer object.
The Class ID and App ID for the SASAnalyzer object are the following:
Class ID SASAnalyzer 12A4B62B-107A-42AE-9C56-08C5EC3C26E2
App ID SASAnalyzer Lecroy.SASAnalyzer
Example
WSH:
Set Analyzer = WScript.CreateObject( “Lecroy.SASAnalyzer” )
C++:
ISASAnalyzer* poSASAnalyzer;
// create SASAnalyzer object
if ( FAILED( CoCreateInstance(
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
3.1.5 ISASAnalyzer::StartRecording
HRESULT StartRecording (
Starts recording with specified recording options.
Parameters
ro_file_name String providing the full pathname to the recording options file;
Return values
ANALYZERCOMERROR_UNABLESTARTRECORDING -
Remarks
After recording starts, this function will return. The Analyzer continues recording until it is
finished or until the StopRecording method call is performed. During recording, events are sent to
the event sink (see _ISASAnalyzerEvents
The recording options file is the file with extension .rec created by the SASTracer
application. You can create this file when you select “Setup –> Recording Options…” from the
SASTracer application menu, change the recording options in the “Recording Options” dialog,
and select the “Save…” button.
Example
VBScript:
<OBJECT
>
</OBJECT>
<INPUT TYPE=TEXT VALUE="" NAME="TextRecOptions">
<SCRIPT LANGUAGE="VBScript">
<!--
Sub BtnStartRecording_OnClick
On Error Resume Next
Analyzer.StartRecording TextRecOptions.value
If Err.Number <> 0 Then
MsgBox Err.Number & ":" & Err.Description
End If
-->
</SCRIPT>
[in] BSTR ro_file_name );
If the parameter is omitted, then recording starts with default recording
options.
unable to start recording
interface).
RUNAT=Server
ID = Analyzer
CLASSID = " clsid: 297CD804-08F5-4A4F-B3BA-779B2654B27C "
End Sub
16
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
3.1.7 ISASAnalyzer::MakeRecording
HRESULT MakeRecording (
Makes recording with the specified recording options file.
Parameters
ro_file_name String providing the full pathname to a recording options file;
trace Address of a pointer to the SASTrace object interface
Return values
ANALYZERCOMERROR_UNABLESTARTRECORDING -
Remarks
This method acts like the StartRecording method but will not return until recording is
completed. The SASTrace object is created via this method call, if the call was
successful.
The recording options file is the file with extension .rec created by the SASTracer
application. You can create this file when you select “Setup –> Recording Options…”
from the SASTracer application menu, change the recording options in the
“Recording Options” dialog, and select the “Save…” button.
Example
WSH:
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Analyzer = WScript.CreateObject("Lecroy.SASAnalyzer")
Set Trace = Analyzer.MakeRecording (CurrentDir & "Input\test_ro.rec")
Attaches the SASAnalyzer object to the board and lets it work with connected boards.
Parameters
yDefaultPort An enumeration indicates a TCP or USB connection.
bstrDeviceId A BSTR object specifies the Board ID as a string.
bstrSystemPath Specifies the path of the system folder in which the software has been
installed.
pnErrorCode A pointer to an integer which contains an error code about the situation
Return values
Remarks
This function is used to connect to a board. This function will not connect to the specified board if
any other objects have been already connected to the same board.
[out, retval] int* pnErrorCode)
in which one or more error(s) has occurred.
23
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
3.1.12 ISASAnalyzer::Detach
HRESULT Detach (
[out, retval] int* pnErrorCode)
Detaches the object from the board.
Parameters
pnErrorCode A pointer to an integer which contains an error code about the
situation in which one or more error(s) has occurred.
Return values
Remarks
This method detaches the object from the board.
24
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4 SASTrace Object
The SASTrace object represents the recorded trace file.
The SASTrace object allows users to:
o Get trace information.
o Access trace packets.
o Access trace errors.
o Save/export the trace or a portion of the trace.
The SASTrace object can be created by:
o Using the ISASAnalyzer::OpenFile
o Using the ISASAnalyzer::MakeRecording
o Handling the _ISASAnalyzerEvents::OnTraceCreated
The SASTrace object supports the following interfaces:
Interfaces Description
Itrace
ISASTrace
ISASVerificationScript
The ISASTrace interface is a primary interface for the SASTrace object.
Implements trace packets and trace errors access,
different report types, export, and saving.
Extends ITrace interface:
Adds functionality for accessing the SASTracePacket
object.
Exposes functionality for running verification scripts.
method
method
event
25
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1 ITrace Interface
The ITrace interface is a dual interface for the SASTrace object.
It implements the following methods:
GetName
ApplyDisplayOptions
Save
ExportToText
Close
ReportFileInfo
ReportErrorSummary
GetPacket
GetPacketsCount
GetTriggerPacketNum
AnalyzerErrors
Note: All methods of the ITrace interface are also available in ISASTrace
interface.
26
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1.1 ITrace::GetName
HRESULT GetName (
Retrieves the trace name.
Parameters
trace_name Name of the trace
Return values
Remarks
This name can be used for presentation purposes.
Do not forget to free the string returned by this method call.
Example
WSH:
Set Analyzer = WScript.CreateObject("Lecroy.SASAnalyzer ")
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1.2 ITrace::ApplyDisplayOptions
HRESULT ApplyDisplayOptions (
Applies the specified display options to the trace.
Parameters
do_file_name String providing the full pathname to the display options file
Return values
ANALYZERCOMERROR_UNABLELOADDO -
Remarks
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 SASTrainer
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1.3 ITrace::Save
HRESULT Save (
Saves trace into a file while allowing you to specify a range of packets.
Parameters
file_name
packet_from Beginning packet number when you are saving a range of packets,
packet_to Ending packet number when you are saving a range of packets,
Return values
ANALYZERCOMERROR_UNABLESAVE – unable to save the trace file
ANALYZERCOMERROR_INVALIDPACKETNUMBER - bad packet range
Remarks
Use this method if you want to save a recorded or opened trace into a file. If the display
options apply to this trace (see ITrace::ApplyDisplayOptions
ISASAnalyzer::LoadDisplayOptions
If the packet range specified is invalid (for example, packet_to is more than the last packet
number in the trace, or packet_from is less than the first packet number in the trace, or
packet_from is more than packet_to) then the packet range will be adjusted automatically.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1.4 ITrace::ExportToText
HRESULT ExportToText (
Exports the trace into a text file while allowing you to specify a range of packets.
Parameters
file_name String providing the full file pathname for the exported trace
packet_from
packet_to
Return value
ANALYZERCOMERROR_UNABLESAVE –
Remarks
Use this method if you want to export a recorded or opened trace into a text file. If the
display options apply to this trace (see ITrace::ApplyDisplayOptions
ISASAnalyzer::LoadDisplayOptions
If the packet range specified is invalid (for example packet_to is more than the last packet
number in the trace, or packet_from is less than the first packet number in the trace, or
packet_from is more than packet_to) then the packet range will be adjusted automatically.
[in] BSTR file_name,
[in, defaultvalue(-1)] long packet_from,
[in, defaultvalue(-1)] long packet_to );
Beginning packet number when you are exporting a range of packets,
Value –1 means that the first packet of the exported trace is the first
packet of this trace.
Ending packet number when you are exporting a range of packets,
Value –1 means that the last packet of the exported trace is the last
packet of this trace.
unable to export trace file
or
), then hidden packets would not be exported.
30
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
Here is a snippet of an exported text file:
File c:\analyzersw\traces\sas\allsata.sas.
From Frame #1 to Frame #20.
Frame#
_______|_______________________________________________________________________T2
Frame(1) 1.5(G) SATA RCV Time Stamp(29.196 501 432)
_______|_______________________________________________________________________T2
Frame(2) 1.5(G) SATA XMT SATA_SOF FIS Type(DMA Activate) Port(0x0)
_______| Data(4 bytes) CRC(0x8FA86FC5) SATA_EOF Time Stamp(29.196 513 752)
_______|_______________________________________________________________________I2
Frame(3) 1.5(G) SATA RCV Time Stamp(29.196 514 177)
_______|_______________________________________________________________________I2
Frame(4) 1.5(G) SATA XMT SATA_SOF FIS Type(Data) Port(0x0)
_______| Data(8196 bytes) CRC(0x7BFAA709) SATA_EOF Time Stamp(29.196 518 682)
_______|_______________________________________________________________________T2
Frame(5) 1.5(G) SATA RCV Time Stamp(29.196 518 952)
_______|_______________________________________________________________________T2
Frame(6) 1.5(G) SATA XMT SATA_SOF FIS Type(DMA Activate) Port(0x0)
_______| Data(4 bytes) CRC(0x8FA86FC5) SATA_EOF Time Stamp(29.196 632 872)
_______|_______________________________________________________________________I2
Frame(7) 1.5(G) SATA RCV Time Stamp(29.196 633 167)
_______|_______________________________________________________________________I2
Frame(8) 1.5(G) SATA XMT SATA_SOF FIS Type(Data) Port(0x0)
_______| Data(8196 bytes) CRC(0x7919EFB6) SATA_EOF Time Stamp(29.196 634 687)
_______|_______________________________________________________________________T2
Frame(9) 1.5(G) SATA RCV Time Stamp(29.196 634 950)
_______|_______________________________________________________________________T2
Frame(10) 1.5(G) SATA XMT SATA_SOF FIS Type(DMA Activate) Port(0x0)
_______| Data(4 bytes) CRC(0x8FA86FC5) SATA_EOF Time Stamp(29.196 748 927)
_______|_______________________________________________________________________I2
Frame(11) 1.5(G) SATA RCV Time Stamp(29.196 749 220)
_______|_______________________________________________________________________I2
Frame(12) 1.5(G) SATA XMT SATA_SOF FIS Type(Data) Port(0x0)
_______| Data(8196 bytes) CRC(0x38CA16DA) SATA_EOF Time Stamp(29.196 750 740)
_______|_______________________________________________________________________T2
Frame(14) 1.5(G) SATA XMT SATA_SOF FIS Type(DMA Activate) Port(0x0)
_______| Data(4 bytes) CRC(0x8FA86FC5) SATA_EOF Time Stamp(29.196 864 980)
_______|_______________________________________________________________________I2
Frame(15) 1.5(G) SATA RCV Time Stamp(29.196 865 272)
_______|_______________________________________________________________________I2
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1.5 ITrace::Close
HRESULT Close ( );
Closes the trace.
Parameters
Return values
Remarks
Closes the current trace but does not release the interface pointer. Call the
IUnknown::Release method right after this method call. No ITrace method call will succeed
after calling the ITrace::Close
Note: Currently there is no need to call ITrace::Close directly, since IUnknown::Release will
close the
trace.
Example
method.
32
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.1.6 ITrace::ReportFileInfo
HRESULT ReportFileInfo (
Saves trace information into a specified text file
Parameters
file_name String providing the full pathname to file where the trace information
Return values
ANALYZERCOMERROR_UNABLESAVE -
Remarks
Creates a new trace information file if the file specified in the file_name parameter does
not exist.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.2 ISASTrace Interface
The ISASTrace interface is a primary dual interface for the SASTrace object.
This interface is derived from the ITrace interface.
The ISASTrace interface implements all methods from the ITrace interface plus the
following: GetBusPacket
4.2.1 ISASTrace::GetBusPacket
HRESULT GetBusPacket (
Retrieves the interface for a packet within a trace.
Parameters
packet_number Zero based number of packet to retrieve
packet Address of a pointer to the SASPacket
Return values
Remarks
The SASPacket object is created by this method call, if the call was successful.
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
4.3 ISASVerificationScript Interface
The ISASVerificationScript interface is an interface for the SASTrace object. It exposes the
trace functionality for running verification scripts. This interface is not dual—which means
that scripting languages cannot use it directly, though all of its methods described below are
exposed to script languages through the primary automation interface of the
SASTrace object.
Remarks
Verification scripts are scripts written in a special manner using the CATC Script Language
(CSL). These scripts can be “run” over a 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 SASTracer application, its Verification Script Engine.
Please refer to the SASTracer Manual, SASTracer Verification Script Engine Manual, and
SASTracer File Based Decoding Manual for more details.
Attention
The functions of this interface may be legally called either for regular traces or
multi-segmented traces. The VSE will open segments of the multi-segmented trace during
script execution when it is needed.
44
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
Runs a verification script over the recorded trace.
Parameters
verification_script
result Address of a variable in which to keep the verification 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 (*.pevs). If
only the name of the script, without file extension, is specified, SASTracer’s server
searches for the named script among the scripts loaded from the \Scripts\VFScripts
folder under the SASTracer installation folder. If the full path to the script is specified,
then the server attempts to load the script from the specified path prior to running it.
Example
For a verification script file named test.pevs, the test name is “test”. Please refer to the
SASTracer Verification Script Engine Manual for more details.
VS_RESULT is an enumeration type that can have five meanings:
SCRIPT_RUNNING (-2) - verification script is running
SCRIPT_NOT_FOUND (-1) - verification script with the specified name not found
FAILED ( 0) - verification failed
PASSED ( 1) - verification passed
DONE ( 2) - verification is done, do not care about result
45
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
ISASTrace* trace;
. . .
ISASVerificationScript* vscript = NULL;
if ( SUCCEEDED ( trace->QueryInterface( IID_ISASVerificationScript,
(void**)&vscript ) )
{
}
else
{
}
. . .
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASTracer")
Set Trace = Analyzer.OpenFile( "C:\Some trace files\some_trace.sas" )
Dim Result
Result = Trace.RunVerificationScript( "Test1" )
If Result = 1 Then
Else
End If
MsgBox( "Done" )
try
{
VS_RESULT result = vscript ->RunVerificationScript("Test1");
if( result == PASSED )
{
::MessageBox( NULL, "Test verification 1 is passed !!!", "SASTracer
client", MB_OK );
Set Analyzer = WScript.CreateObject("LeCroy.SASTracer")
Set Trace = Analyzer.OpenFile( "C:\Some trace files\some_trace.sas" )
Dim Result
Set VSEngine = Trace.GetVScriptEngine( "Test1" )
Result = VSEngine.RunVScript
If Result = 1 Then
Msgbox "PASSED"
Else
Msgbox "FAILED"
End If
MsgBox( "Done" )
[in] BSTR script_name,
[out, retval] IVScriptEngine** vs_engine )
Name of the verification script to initialize the verification script engine
for details.
47
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5 SASRecOptions Object
The SASRecOptions object represents the options for the SASTracer hardware and is used
to specify the recording parameters.
The SASRecOptions object allows you to:
o Load/save the recording options from/to the file.
o Set up recording mode and recording buffer size.
o Set up custom recording parameters, such as ChannelSettings,
DataTruncate, MultiSegment mode, and SpoolMode.
The SASRecOptions object can be created by using the
ISASAnalyzer::GetRec
The SASRecOptions object supports the following interfaces:
Interfaces Description
IRecOptions
ISASRecOptions
The ISASRecOptions interface is a primary interface for the SASRecOptions object.
ordingOptions method.
Allows you to load/save recording options from/to the file,
reset recording options, set up recording mode, recording
buffer size, trigger position, and the trace file name.
Identical to IRecOptions interface
48
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1 IRecOptions Interface
The IRecOptions interface is a dual interface for the SASRecOptions object.
IRecOptions implements the following methods:
Load
Save
SetRecMode
SetBufferSize
SetPostTriggerPercentage
SetTriggerBeep
SetSaveExternalSignals
SetTraceFileName
Reset
Note: All methods of the IRecOptions interface are also available in the ISASRecOptions
Interface.
49
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.1 IRecOptions::Load
HRESULT Load (
Loads recording options from the specified file.
Parameters
ro_file_name String that provides the full pathname to the recording options file
Return values
ANALYZERCOMERROR_UNABLEOPENFILE
Remarks
Example
WSH:
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
RecOptions.Load( CurrentDir & "Input\rec_options.rec" )
C++:
[in] BSTR ro_file_name );
– unable to open file
50
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.2 IRecOptions::Save
HRESULT Save (
Saves recording options into the specified file.
Parameters
ro_file_name String that provides the full pathname to the recording options file
Return values
ANALYZERCOMERROR_UNABLEOPENFILE –
Remarks
If the specified file does not exist, it will be created. If it exists, it will be overwritten.
Example
WSH:
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
' do the changes of recording options here
RecOptions.Save( CurrentDir & "Input\rec_options.rec" )
C++:
[in] BSTR ro_file_name );
unable to open file
51
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.3 IRecOptions::SetRecMode
HRESULT SetRecMode (
Sets the recording mode.
Parameters
rec_mode Enumerated value providing the mode to set;
Return values
E_INVALIDARG –
Remarks
The default setting of recording options is "snapshot" recording mode.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
RecOptions.SetRecMode 2 ' Event trigger
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.4 IRecOptions::SetBufferSize
HRESULT SetBufferSize (
Sets the size of the recording buffer.
Parameters
buffer_size Size of the recording buffer in bytes
Return values
E_INVALIDARG –
Remarks
The default setting is 16 MB for Conventional Recording mode and 120 GB or 12.5 hours
for Spooled Recording Mode.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
RecOptions.SetBufferSize 2*1024*1024 ' 2 MB
C++:
[in] long buffer_size );
invalid buffer size was specified
53
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.5 IRecOptions::SetPostTriggerPercentage
HRESULT SetPostTriggerPercentage (
Sets the post-trigger buffer size.
Parameters
posttrigger_percentage Size of the post-trigger buffer in percent of the whole
recording buffer (see IRecOptions::SetBufferSize
Return values
E_INVALIDARG –
Remarks
This method call has no effect if recording mode is set to
(see IRecOptions::SetRecMode
The default setting is 50%.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
RecOptions.SetPostTriggerPercentage 60 ' 60%
C++:
[in] short posttrigger_percentage );
invalid percentage was specified
RMODE_SNAPSHOT
).
).
54
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.6 IRecOptions::SetTriggerBeep
HRESULT SetTriggerBeep (
Sets a flag to make a sound when a trigger occurs.
Parameters
beep TRUE – Beep when trigger occurs.
Return values
Remarks
The default state of the beeper is FALSE.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
RecOptions.SetTriggerBeep TRUE
C++:
[in] BOOL beep );
FALSE – Do not beep when trigger occurs.
55
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.7 IRecOptions::SetSaveExternalSignals
HRESULT SetSaveExternalSignals (
Sets a flag to save external signals.
Parameters
save TRUE – Save external signals.
Return values
Remarks
By default, external signals are not saved.
Example
WSH:
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
RecOptions.SetSaveExternalSignals TRUE
C++:
[in] BOOL save );
FALSE – Do not save external signals.
56
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.8 IRecOptions::SetTraceFileName
HRESULT SetTraceFileName (
Sets the file path to where the trace will be stored after recording.
Parameters
file_name String that provides the full file pathname to where the recording
Return values
Remarks
If the specified file does not exist, it will be created. If it exists, it will be overwritten.
Example
WSH:
CurrentDir = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))
Set Analyzer = WScript.CreateObject("LeCroy.SASAnalyzer")
Set RecOptions = Analyzer.GetRecordingOptions
' do the changes of recording options here
RecOptions.Save( CurrentDir & "Input\trace.sat" )
C++:
[in] BSTR file_name );
will be stored
57
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.1.9 IRecOptions::Reset
HRESULT Reset ( )
Resets the recording options to the initial state.
Parameters
Return values
Remarks
For default values of recording options, see the remarks sections of all IRecOptions
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
5.2 ISASRecOptions Interface
This interface is identical to the IRecOptions interface
.
59
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
6 SASPacket Object
The SASPacket object represents a single packet of the recorded trace file.
The SASPacket object allows you to retrieve packet content and packet properties, such as
timestamp, link width, packet start lane, packet direction, and packet errors.
The SASPacket object can be created by calling ISASTrace::GetBusPacket
The SASPacket object supports the following interfaces:
Interfaces Description
IPacket
ISASPacket
The ISASPacket interface is a primary interface for the SASPacket object.
Allows retrieval of the packet’s
timestamp.
Extends the IPacket interface.
.
60
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
6.1 IPacket Interface
The IPacket interface is a dual interface for the SASPacket object.
IPacket implements the following method:
GetTimestamp
Note: All methods of the IPacket interface are also available in theISASPacket interface
timestamp Timestamp of the beginning symbol of the packet, from the start of
recording
Return values
Remarks
Example
WSH:
Set Analyzer = WScript.CreateObject( “LeCroy.SASTracer” )
Set Trace = Analyzer.MakeRecording( CurrentDir & "Input\test_ro.rec" )
TriggerPacket = Trace. GetTriggerPacketNum
Set Packet = Trace.GetBusPacket(TriggerPacket)
MsgBox "Trigger packet at " & Packet.GetTimestamp & " ns"
C++:
.
61
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
6.2 ISASPacket Interface
The ISASPacket interface is a primary dual interface for the SASPacket object.
This interface is derived from the IPacket interface.
The ISASPacket interface implements all methods from the IPacket interface plus the
Returns an array of errors present in this packet.
Parameters
error_array Array of error IDs present in this packet.
See ITrace::AnalyserErrors
number_of_errors Total number of errors in this packet
Return values
Remarks
Example
WSH:
C++:
for error ID values.
66
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
7 SASTraceErrors Object
The SASTraceErrors object represents the collection of errors that occurred in the recorded trace
file.
The SASTraceErrors object can be created by calling ITrace::AnalyzerErrors
The ISASAnalyzerErrors interface is a primary interface for the SASTraceErrors object.
7.1 ISASAnalyzerErrors Dispinterface
This is a standard collection interface for collection of packet numbers with errors of a
specified type (see ITrace::AnalyzerErrors
It has the following methods, which are standard for collection interfaces:
get_Item
get_Count
).
.
67
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
7.1.1 ISASAnalyzerErrors::get_Item
HRESULT get_Item(
Parameters
index Index of the error in the collection
packet_number
[in] long index,
[out, retval] long* packet_number );
Error packet number
68
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
7.1.2 ISASAnalyzerErrors::get_Count
HRESULT get_Count(
Returns the number of errors in the trace.
Parameters
number_of_errors Number of elements in the collection
Remarks
Example
WSH:
' Makes recording and saves the portions of the recorded trace
' where "Running Disparity" errors occured.
CurrentDir = Left(WScript.ScriptFullName, InstrRev( WScript.ScriptFullName, “\” ))
Set Analyzer = WScript.CreateObject( “LeCroy.SASTracer” )
Set Trace = Analyzer.MakeRecording( CurrentDir & "Input\test_ro.rec" )
Set Errors = Trace.AnalyzerErrors( 32 ) ' Running Disparity Error
For Each ErrorPacketNumber In Errors
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
8 SASVScriptEngine Object
The SASVScriptEngine object allows you to run verification scripts over the recorded trace.
It extends the functionality of the ISASVerificationScript interface of a SASTrace object. The
main advantage of a SASVScriptEngine object is that it allows clients implementing
_IVScriptEngineEvents a callback interface to receive notifications when a verification script
is running.
The SASVScriptEngine object can be created by calling
ISASVerificationScript:: GetVScriptEngine
The SASVScriptEngine object supports the following interfaces:
Interfaces Description
IVScriptEngine
_ISASAnalyzerEvents
The IVScriptEngine interface is a primary interface for the SASVScriptEngine object.
Remarks
Verification scripts are scripts written in a special manner using the CATC Script Language
(CSL). These scripts can be “run” over a 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 SASTracer application, its Verification Script Engine.
Please refer to the SASTracer Manual, SASTracer Verification Script Engine Manual, and
SASTracer File Based Decoding Manual for more details.
Provides advanced control over the verification script and
allows you to execute the script asynchronously.
Events from SASVScriptEngine object
.
8.1 IVScriptEngine Interface
The IVScriptEngine interface is the primary dual interface for the SASVScriptEngine object.
It implements the following properties and methods:
VscriptName
Tag
RunVScript
RunVScriptEx
LaunchVScript
Stop
GetScriptVar
SetScriptVar
71
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
Property puts and gets current verification script name.
Parameters
pVal Address of the variable where current verification script name is kept
newVal Name of the verification script to initialize verification script engine
Return values
Remarks
only the name of the script, without a file extension, is specified, the SASTracer server
searches for the named script among the scripts loaded from the \Scripts\VFScripts folder
under the SASTracer installation folder. If the full path to the script is specified, then the
server attempts to load the script from the specified path prior to running it.
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
The name of the verification script is the name of the verification script file (*.pevs). If
72
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
8.1.2 IVScriptEngine::Tag
[propget] HRESULT Tag ( [out, retval] int* pVal )
[propget] HRESULT Tag ( [in] int newVal )
Property assigns and gets a tag to the VSE object. This tag will be used in event
notifications, allowing a client event handler to determine which VSE object sent the event.
Parameters
pVal Address of the variable where the current VSE tag is kept
newVal New tag for VSE
Return values
Remarks
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
8.1.3 IVScriptEngine::RunVScript
HRESULT RunVScript ( [out, retval] int* pResult )
Runs the verification script currently specified for this engine.
Parameters
pResult Address of the variable where the results of the verification are kept
Return values
Remarks
The name of the verification script is the name of the verification script file (*.pevs). If
only the name of the script, without a file extension, is specified, the SASTracer server
searches for the named script among the scripts loaded from the \Scripts\VFScripts folder
under the SASTracer installation folder. If the full path to the script is specified, then the
server attempts to load the script from the specified path prior to running it.
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
Changes the current verification script name and runs the verification script.
Parameters
script_name Name of the verification script to initialize the script verification engine
pResult Address of the variable where the results of the verification are kept
Return values
Remarks
This method makes a “synchronous” call, which means that this method does not
return until the script stops running.
The name of the verification script is the name of the verification script file (*.pevs). If
only the name of the script, without a file extension, is specified, the SASTracer server
searches for the named script among the scripts loaded from the \Scripts\VFScripts folder
under the SASTracer installation folder. If the full path to the script is specified, then the
server attempts to load the script from the specified path prior to running it.
See ISASVerificationScript:: RunVerificationScript
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
8.1.5 IVScriptEngine::LaunchVScript
HRESULT LaunchVScript ( )
Launches the current verification script.
Parameters
Return values
S_FALSE – if VS Engine was not successfully launched
(Either it is already running, or the verification script was not found.)
Remarks
This method makes an “asynchronous” call, which means that this method
immediately returns after the script starts running.
When the verification script stops running, the VSE object sends a special event
notification _ IVScriptEngineEvents:: OnVScriptFinished
can also terminate the running script using the method IVScriptEngine:: Stop
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
VS_RESULT result = sas_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.
. . .
to the client event handler. You
.
76
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
8.1.6 IVScriptEngine::Stop
HRESULT Stop ( )
Stops the verification script previously launched by IVScriptEngine:: LaunchVScript.
Parameters
Return values
Remarks
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
Allows you to set the value of some verification script global variable before/after executing
the script (refer to the SASTracer Verification Script Engine Manual and the File Based Decoding Manual for information on how a script can declare, set, and use global
variables).
Only integers, strings, or arrays of VARIANTs are allowed as correct values. Arrays of
VARIANTs are converted into list values inside of scripts. See the SASTracer File Based Decoding Manual for more details about list objects.
Parameters
var_name String providing the name of the global variable used in the
running verification script
var_value VARIANT variable containing the new variable value
Return values
E_PENDING – if this method is called when the script is already running
Remarks
This function allows you to set internal script variables before running a script, giving
you the opportunity to make run-time customization from COM/Automation client
applications.
In order for this operation to take effect during execution of the script, a global variable
with the name specified by var_name should be declared by the script.
Example
C++:
// In this example, we use wrapper functions provided by the #import directive.
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
9 SASVScriptEngine Object Events
9.1 _IVScriptEngineEvents Interface
In order to retrieve event notifications from the SASTracer application when a
verification script engine object is running the script, you must implement the
_IVScriptEngineEvents callback interface. Since this interface is a default source interface
for the SASVScriptEngine object, there is a very simple implementation from languages like
Visual Basic, VBA, VBScript, and WSH.
Some script engines impose restrictions on handling events from “in direct” automation
objects in typeless script languages (when an automation interface to the object is obtained
from a call of some method, rather than from creation function, such as CreateObject() in
VBScript). The SASTracer application provides a special COM class, allowing receiving and
handling of notifications from a VSE object even in script languages not supporting event
handling from "indirect" objects.
Example
C++ implementation used in the examples below implements an event sink object by
deriving it from IdispEventImpl, but 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 that is to
be handled:
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 )
SINK_ENTRY( IDC_SRCOBJ_VSE, 3, OnNotifyClient )
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 );
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
VBA: ( MS Excel )
Public SASTracer As SASAnalyzer
Public Trace As SASTrace
Public GVSEngine As VScriptEngine
' VSEngineEventsModule is a special class implementing VSE event handlers.
' It should have, in the global declaration section, the line like this:
' Public WithEvents VSEEvents As VScriptEngine
Dim X As New VSEngineEventsModule
Private Sub RunVScritButton_Click()
End Sub
Dim VSEngine As VScriptEngine
Dim IVScript As ISASVerificationScript
Dim ScriptName, fileToOpen As String
HRESULT OnVScriptReportUpdated (
[in] BSTR newline,
[in] int tag )
Fires when running a verification script. Calls the ReportText( newLine ) function (please
refer to the SASTracer Verification Script Engine Manual for details on the ReportText
function).
Parameters
newline New portion of text reported by the verification script
tag VSE object's tag
Return values
Remarks
Make sure that C++ event handlers have __stdcall calling convention.
Example
C++:
HRESULT __stdcall OnVScriptReportUpdated (BSTR newLine, int TAG )
{
}
VBA (MS Excel):
Public WithEvents VSEEvents As VScriptEngine
Public LineIndex As Integer
. . .
Private Sub VSEEvents_OnVScriptReportUpdated(ByVal newLine As String,
ByVal Tag As Long)
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
9.1.2 IVScriptEngineEvents::OnVScriptFinished
HRESULT OnVScriptFinished (
[in] BSTR script_name,
[in] VS_RESULT result,
[in] int TAG )
Fires when running a verification script. Calls the ReportText( newLine ) function (please
refer to the SASTracer Verification Script Engine Manual for details on the ReportText
function).
Parameters
script_name Name of the verification script
result Result of "verification"
See ISASVerificationScript::RunVerificationScript
TAG VSE object's tag
Return values
Remarks
Make sure that C++ event handlers have __stdcall calling convention.
Example
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
9.1.3 IVScriptEngineEvents::OnNotifyCount
HRESULT OnNotifyCount (
[in] int eventId,
[in] VARIANT eventBody,
[in] int TAG )
Fired when running a verification script. Calls the NotifyClient() function.
Parameters
eventID Event ID
eventBody Body of event packed in a VARIANT object
TAG VSE object's tag
Return values
Remarks
The information packed in the event body is opaque for VSE. It only packs the
information given to the NotifyClient() function inside of a verification script into a VARIANT
object and sends it to client applications.
See the SASTracer Verification Script Engine Manual for details about the
NotifyClient() script function.
LeCroy Corporation Automation API for SAS/SATATracer/Trainer Manual Version 1.11
10 SASAnalyzer Object Events
10.1 _ISASAnalyzerEvents Dispinterface
In order to retrieve the events from a SASAnalyzer object, you must implement the
_ISASAnalyzerEvents interface. Since this interface is the default source interface for the
SASAnalyzer object, there is a very simple implementation from languages, such as Visual
Basic, VBA, VBScript, and WSH.
Some script engines impose restrictions on handling events from “in direct” 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, such as CreateObject() in
VBScript). The SASTracer application provides a special COM class, allowing receiving and
handling notifications from the VSE object even in script languages not supporting event
handling from "indirect" objects.
C++ implementation used in the examples below utilizes a sink object by deriving it
from IdispEventImpl, but 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 that is to
be handled:
class CAnalyzerSink : public IDispEventImpl<IDC_SRCOBJ, CAnalyzerSink>
{
BEGIN_SINK_MAP(CAnalyzerSink)
END_SINK_MAP()
. . .
}
Then, after you establish a connection with the server, you need to advise as to your
implementation of the event interface:
hr = CoCreateInstance( CLSID_SASAnalyzer, NULL,
poAnalyzerSink = new CAnalyzerSink();
// Make sure the COM object corresponding to pUnk implements IProvideClassInfo2 or
// IPersist*. Call this method to extract info about source type library, if you
// specified only two parameters to IDispEventImpl.
hr = AtlGetObjectSourceInterface(m_poSASAnalyzer, &poAnalyzerSink->m_libid,
if ( FAILED(hr) )
return 1;
// Connect the sink and source. m_poSASAnalyzer is the source COM object.
hr = poAnalyzerSink->DispEventAdvise(m_poSASAnalyzer, &poAnalyzerSink->m_iid);
if ( FAILED(hr) )
return 1;
// Make sure the Event Handlers have __stdcall calling convention.
SINK_ENTRY(IDC_SRCOBJ, 1, OnTraceCreated)
SINK_ENTRY(IDC_SRCOBJ, 2, OnStatusReport)