Teledyne LeCroy USB Analyzer Automation Manual User Manual

Page 23

Advertising
background image

Teledyne LeCroy Automation API Reference Manual for USBTracer, USB Advisor, and Voyager USB Protocol
Suite

23

C++: (Raw code without using type library. All error handling is omitted for simplicity)

IUsbAnalyzer* pAnalyzer = NULL;

// Create UsbAnalyzer object.
if ( FAILED( CoCreateInstance( CLSID_UsbAdvisor, NULL, CLSCTX_SERVER,

IID_IUsbAnalyzer, (LPVOID *)&pAnalyzer ) )

return;


BSTR ro_file_name = SysAllocString( L"test_ro.rec" );
BSTR bstr_trace_name;

IDispatch* trace = NULL;

for( int i = 0; i < 4; i++ )
{

if( FAILED( pAnalyzer ->StartRecording( ro_file_name ) )

return; // Error handling and resources releasing should be done.


// Fake generation.
Sleep(3000);

if( FAILED( Analyzer->StopRecordingAndWaitForTrace( &trace ) ) )

return; // Error handling and resources releasing should be done.

IUsbTrace2* usbTrace = NULL;


// Query for IUsbTrace2 interface.
if( FAILED( trace->QueryInterface( IID_IUsbTrace2, (LPVOID*)usbTrace ) ) )

return; // Error handling and resources releasing should be done.



OLECHAR trace_name[_MAX_PATH];
swprintf ( trace_name, "test_data%u.usb", i );
SysAllocString( bstr_trace_name );


// Save the trace recorded to the current folder
usbTrace->Save( bstr_trace_name );

// Release the trace object.
trace->Release();
usbTrace->Release();

SysFreeString( bstr_trace_name ); // Free BSTR.
}

pAnalyzer->Release(); // Release the analyzer object.
SysFreeString( ro_file_name ); // Free BSTR.

Advertising