Understanding the Library Interface

Initialize/release API

Initialize and release the API before you use it. Use the following functions to initialize and release the API.

Note: The API can only be initialized/released once per process. Performing multiple initialization/release cycles within a single process is not supported.

Declarations and Prototypes

TLNetAPI.h

APIInitialize()

Prototype

C
APIInitialize()

Description

This function initializes the API. It must be called before any other API function calls.

Parameters

None.

Return value

It always returns zero.

APIUninitialize()

Prototype

Python
APIUninitialize()

Description

This function releases the API. It must be called after the last API function call. If any API function is called after this, it returns an error code that means API has not been initialized.

Parameters

None.

Return value

It always returns zero.

Enumerations

All API enumerations are located in: SDK/Includes/APIEnumerations.h

Version/Info Methods

APIGetVersion ()

Prototype

C
APIGetVersion()

Description

This function gets the version of the software.

Parameters

major

major software version

minor

minor software version

build_no

build number of software

API Error Codes

Value

Description

API_EXCEPTION

1

An exception occurred.

APIGetHardwareInfo()

Prototype

Python
APIGetHardwareInfo()

Description

It gets product ID of a device.

Parameters

serial_number

serial number of the board

product_id

product id of the board

If no board with the input serial number exists, the return value is 33. (API_ERROR_INVALID_ARGUMENT). It is possible to get the complete description of the error code by calling APIError_GetLastError() and APIError_GetDescription() functions.

Product id: Can be one of the following values:

Value

Product ID

0x3102

M408

0x3502

M168

0x4002

T328

0x4012

M328

0x4602

M648

0x4d02

M1288

API Error Codes

Value

Description

API_EXCEPTION

1

An exception occurred.

Error handling

All API functions return an integer value in code from the API ErrorCode enumeration. If any error occurs, a proper error code is returned. (If no code is returned, then that means that no error occurred.) In some cases, more details are available about the error. APIError_GetLastError() can be called to return the internal error code. The description of an internal error code, returned by APIError_GetLastError(), can be collected by calling APIError_GetDescription().

Declarations and Prototypes

C
TLNetAPI.h

APIError_GetLastError()

Prototype

C
APIError_GetLastError(): int

Description

If any error occurs during an API function call, the function returns an error in code from the EAPIErrorCode enumeration. In some cases, more details are available about the error. This function returns the last occuring internal error code. The Return value is an integer. To collect a complete description, call APIError_GetDescription().

Parameters

None.

Return value

It returns the last internal API Error Codes.

APIError_GetDescription()

Prototype

C
APIError_GetDescription(int error_code, char *error_description,
int max_length_error_description): void

Description

It returns a description of an error code.

Parameters

error_code

An integer value as error code.

error_description

An allocated buffer that is passed to collect the description of the error.

max_length_error_description

Maximum length of error description buffer.

Return value

None.

Project methods

Declarations and Prototypes

C
APIProject.h

APIProject_create ()

Prototype

C
APIProject_create(APIProject* *api_project)

Description

It creates a new object of project type.

Parameters

api_project

A pointer reference to a created project object.

API Error Codes

Value

Description

API_ERROR_INSUFFICIENT_MEMORY

3

There is insufficient memory to create a new API object.

APIProject_destroy()

Prototype

C
APIProject_destroy(APIProject* *api_project)

Description

This function tries to destroy the input project object. First, it tries to save and close the project. If it cannot save or close, or if the project is in use, this function cannot destroy the input object, and it will return an error. If the project is in use, and API cannot destroy it, nothing happens.

Parameters

api_project

Pointer to the project object created by APIProject_create().

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

APIProject_Open()

Prototype

C
APIProject_Open(APIProject *api_project, const char *file_name)

Description

It opens a project.

Parameters

api_project

Pointer of the project object created by APIProject_create().

file_name

Null-terminated project file name.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_OPEN_PROJECT

25

It cannot open the project.

APIProject_Close()

Prototype

C
APIProject_Close(APIProject *api_project)

Description

It disconnects from all boards and closes the opened project by calling APIProject_open().

Parameters


api_project

Pointer of the project object opened by APIProject_Open().

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_CLOSE_PROJECT

23

It cannot close project.

API_ERROR_CAN_NOT_SAVE_PROJECT

24

It cannot save project.

API_ERROR_CAN_NOT_DISCONNECT_FROM_DEVICE

26

It cannot disconnect from a device.

APIProject_Save()

Prototype

C
APIProject_Save(APIProject *api_project)

Description

It saves the project.

Parameters

api_project

Pointer of the opened project object by APIProject_create().

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_SAVE_PROJECT

24

It cannot save the project.

APIProject_GetChainCount()

Prototype

C
APIProject_GetChainCount(APIProject *api_project, int *chain_count)

Description

It returns the number of included chains in the project.

Parameters

api_project

Pointer of the project object opened by APIProject_create().

chain_count

The number of chains in the project.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIProject_GetDeviceCount()

Prototype

C
APIProject_GetDeviceCount(APIProject *api_project, int chain_index,
int *device_count)

Description

It returns the number of devices in project’s chain.

Parameters

api_project

Pointer of the project object opened by APIProject_create().

chain_index

Index of the chain. It is a zero-based index.

device_count

Number of devices in index(th) chain of the project.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIProject_GetPairPortCount()

Prototype

C
APIProject_GetPairPortCount(APIProject *api_project, int chain_index,
int device_index, int *pair_port_count

Description

It returns the number of pair ports supported by a device in a project’s chain.

Parameters

api_project

Pointer of the project object opened by APIProject_create().

chain_index

Index of the chain. It is a zero-based index.

device_index

Index of the device. It is zero-based index.

pair_port_count

Number of the device’s pair-port in the project.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIProject_GetAnalyzerSettings()

Prototype

C
APIProject_GetAnalyzerSettings(APIProject *api_project, int chain_index,
APIAnalyzerSettings *api_analyzer_settings)

Description

It returns the analyzer settings of a specific chain in the opened project.

Parameters

api_project

Pointer of the project object opened by APIProject_create().

chain_index

Index of the chain. It is a zero-based index.

api_analyzer_settings

Refers to the pointer of the analyzer settings of the project’s chain_index.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

APIProject_GetPortConfiguration()

Prototype

C
APIProject_GetPortConfiguration(APIProject *api_project, int chain_index,
int device_index,ELinkConfiguration *port_config)

Description

It returns the port configuration of a device in a chain.

Parameters

api_project

Pointer of the project object opened by APIProject_create().

chain_index

Index of the chain. It is a zero-based index.

device_index

Index of the device. It is a zero-based index.

port_config

Port configuration of the chain’s device.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

APIProject_Assign()

Prototype

C
APIProject_Assign(APIProject *api_project, unsigned short serial_number,
EConnectionType connection_type, int chain_index, int device_index)

Description

It connects to a board and assigns it to a device of a chain in the project. If any board needs to be updated, it returns error codes.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

serial_number

The board’s serial number.

connect_type

The board’s connection type. It can be USB or TCP.

chain_index

Index of the chain. It is a zero-based index.

device_index

Index of the device. It is a zero-based index.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_SELECTED_DEVICE_IS_NOT_UPDATED

27

The selected device is not updated.

API_ERROR_CAN_NOT_ASSIGN_TO_DEVICE

31

It cannot assign to the selected device.

APIProject_StartRecording()

Prototype

C
APIProject_StartRecording(APIProject *api_project, int chain_index, int
trigger_settings_count, const char
**trigger_settings_names, OnTraceCreatedProc
OnTraceCreated, OnReportRecordingStatusProc
OnReportRecordingStatus, OnAnalyzerErrorProc
OnError, int time_out)

Description

It starts the recording process.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

Index of the chain. It is a zero-based index.

trigger_settings_count

Number of trigger setting names.

trigger_setting_names

Null-terminated Trigger/Filter setting name in the current opened project. If it is Null, the default is used.

event_handler

Refers to a callback function to handle event notifications from the APIs. If it is NULL, then events will not be sent to the client. If the user wants to follow or perform any process during a different recoding status, the OnReportRecordingStatus callback function can be used to report changes in the status of the recording process. The OnError callback function is called to report any errors that occur during the recording or uploading processes. When a trace is created, the OnTraceCreated callback function reports that a trace files has been created.

time_out

If greater than 0, a timer will begin counting down from the timeout value. If the recording is still in progress when the timer expires, the recording will automatically stop. If the timeout is less then or equal to zero, the recording will continue until stopped by other means.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_START_RECORDING

30

It cannot start recording process.

API_ERROR_SELECTED_DEVICE_IS_NOT_UPDATED

27

The selected device is not updated.

API_ERROR_INVALID_TRIGGER_NAME

7

Invalid trigger name.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

The following errors are returned by thecallback function:

API Error Codes

Value

Description

API_ERROR_RECORDING

16

An error occurred during recording process.

API_ERROR_UPLOADING

17

An error occurred during uploading process.

APIProject_StopRecording()

Prototype

C
APIProject_StopRecording(APIProject *api_project, int chain_index,
bool do_not_upload)

Description

It stops any recording or uploading process.



api_project

Pointer of the opened project object by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

Do_not_upload

If it is true, it does not upload any trace file, or stop uploading if the uploading was started automatically.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_CAN_NOT_STOP_RECORDING

29


The following errors are returned by the callback function:

API Error Codes

Value

Description

API_ERROR_RECORDING

16

An error occurred during recording process.

API_ERROR_UPLOADING

17

An error occurred during uploading process.

APIProject_StartJammer()

Prototype

C
APIProject_StartJammer(APIProject *api_project, int chain_index, int
device_index, int pair_port_index, const char
*scenario_name, OnReportMonitoringStatusProc
OnReportMonitoringStatus, OnReportJammerStatusProc
OnReportJammerStatus, OnJammerErrorProc OnError);

Description

It starts the jammer process.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

device_index

The device’s index. It is a zero-based index.

pair_port_index

The pair port’s index. It is a zero-based index.

scenario_name

Null-terminated Scenario name. If it is Null, then the project default is used.

event_handler

It refers to a callback function to handle the events. If it is NULL, the events will not be sent to the client.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_START_JAMMER

13

It cannot start jammer process.

API_ERROR_SELECTED_DEVICE_IS_NOT_UPDATED

27

The selected device is not updated.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_INVALID_PAIR_PORT_INDEX

6

Invalid pair port index.

API_ERROR_INVALID_SCENARIO_NAME

28

Invalid scenario name.

The following errors are returned by the callback function:

API Error Codes

Value

Description

API_ERROR_JAMMER

18

An error occurred during jammer process.

APIProject_StartJammers()

Prototype

C
APIProject_StartJammers(APIProject *api_project, int chain_index, int
device_index, int count, int pair_port_indexes[],
const char *scenario_names[],
OnReportMonitoringStatusProc
OnReportMonitoringStatus[], OnReportJammerStatusProc
OnReportJammerStatus[], OnJammerErrorProc
OnError[]);

Description

It starts the jammer process on a set of ports. If any port has a problem, it does not stop; it starts to jam another port. It returns the last error code if any exists; otherwise, it returns zero.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

device_index

The device’s index. It is a zero-based index.

count

Jammer count.

pair_port_indexes[]

Array of indexes of pair ports. It is a zero-based index.

scenario_names[]

Array of indexes of scenario names. Null terminated Scenario name. If it is Null, project default is used.

event_handler[]

It refers to a callback function to handle the events. If it is NULL, the events will not be sent to the client.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_START_JAMMER

13

It cannot start jammer process.

API_ERROR_SELECTED_DEVICE_IS_NOT_UPDATED

27

The selected device is not updated.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_INVALID_PAIR_PORT_INDEX

6

Invalid pair port index.

API_ERROR_INVALID_SCENARIO_NAME

28

Invalid scenario name.

The following errors are returned by the callback function:

API Error Codes

Value

Description

API_ERROR_JAMMER

18

An error occurred during jammer process.

APIProject_StopJammer()

Prototype

C
APIProject_StopJammer(APIProject *api_project, int chain_index,
int device_index, int pair_port_index)

Description

It stops the jammer process.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

device_index

The device’s index. It is a zero-based index.

pair_port_index

The pair port’s index. It is a zero-based index.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_INVALID_PAIR_PORT_INDEX

6

Invalid pair port index.

API_ERROR_CAN_NOT_STOP_JAMMER

12

It cannot stop jammer process.

The following errors are returned by the callback function:

API Error Codes

Value

Description

API_ERROR_JAMMER

18

An error occurred during jammer process.

APIProject_StopJammers()

Prototype

C
APIProject_StopJammers(APIProject *api_project, int chain_index,
int device_index, int count, int pair_port_indexes[])

Description

It stops the jammer process on a set of ports. If any port has a problem, it does not stop and continues to stop jamming other ports. It returns the last error code if any exists. Otherwise it returns zero.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

device_index

The device’s index. It is a zero-based index.

count

Jammer count.

pair_port_indexes[]

Array of indexes of pair ports. It is a zero-based index.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_INVALID_PAIR_PORT_INDEX

6

Invalid pair port index.

API_ERROR_CAN_NOT_STOP_JAMMER

12

It cannot stop jammer process.

The following errors are returned by the callback function:

API Error Codes

Value

Description

API_ERROR_JAMMER

18

An error occurred during jammer process.

APIProject_StartRTS()

Prototype

C
APIProject_StartRTS(APIProject *api_project, int chain_index, int
device_index, const char *log_file_name);

Description

It starts the RTS process.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

device_index

The device’s index. It is a zero-based index.

log_file_name

User specified CSV file for the RTS log output.

API Error Codes

Value

Description

IDE_PROJECT_NEW_DEVICE_SELECTED_ NOT_UPDATED

27

The selected device is not updated.

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_CAN_NOT_START_RTS

37

Cannot start RTS process

API_ERROR_CAN_NOT_OPEN_LOG_RTS

38

Unable to open user specified log file. Possible file is in use.

APIProject_StopRTS()

Prototype

C
APIProject_StopRTS(APIProject api_project, int chain_index, int
device_index);

Description

It stops the RTS process.

Parameters

api_project

Pointer of the project object opened by APIProject_Open().

chain_index

The chain’s index. It is a zero-based index.

device_index

The device’s index. It is a zero-based index.

API Error Codes

Value

Description

API_ERROR_INVALID_CHAIN_INDEX

4

Invalid chain index.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

API_ERROR_CAN_NOT_STOP_RTS

36

Cannot start RTS process

APIJammerManager_GetLibraryTree ()

Prototype

C
APIJammerManager_GetLibraryTree (APIJammerManager *api_jammer_manager,
JammerLibraryNode* library_tree);

Description

It returns the Jammer library in the form of a tree.

Parameter

Type

Description

api_jammer_manager

APIJammerManager*

Pointer to the APIJammerManager object

library_tree

JammerLibraryNode*

Pointer to a JammerLibraryNode object.

This is a structure that would be filled up on return.

The definition of the JammerLibraryNode which can be found in APIEnumeration.h is as below

C
struct JammerLibraryNode
{
  char*	Name;
  bool	IsGroup;
  int	ChildrenCount;
  JammerLibraryNode*	Children;
};

The definition of the parameters is as follows

Node Member Name

Description

Name

The name of the node. It can be either a name of scenario/Group. An empty name indicates the root node.

IsGroup

It indicates whether the node is a Group. The value is false if it's a scenario.

ChildrenCount

It indicates the number of child, in case the node is a group. The value is 0 if the node is a scenario.

Children

This is a pointer to its children.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

Example: A C++ example of getting the list of scenario names, and run of your choice.

C++
void ReturnScenerioNames(JammerLibraryNode* node, std::vector<std::string>& scenerio_names)
{
  for (int index = 0; index < node->ChildrenCount; ++index)
  {
    auto child = &node->Children[index]; if (child->IsGroup)
    {
      ReturnScenerioNames(child, scenerio_names);
    }
    else
    {
      scenerio_names.emplace_back(child->Name);
    }
  }
}
// Get all the scenario-names
JammerLibraryNode library_tree; APIJammerManager_GetLibraryTree(jammer_manager, &library_tree); ReturnScenerioNames(&library_tree, scenerio_names);
// Run the desired scenario
for (auto scenerio_name: scenerio_names)
{
  if (scenerio_name == "MyScenerioPort1")
{
APIProject_StartJammer( Project, 0, 0, 0, scenerio_name.c_str(), nullptr, nullptr, nullptr);
// More logic goes here
}
}

Analyzer settings

Declarations and Prototypes

C
APIAnalyzerSettings.h

APIAnalyzerSettings_create()

Prototype

C
APIAnalyzerSettings_create(APIAnalyzerSettings* *api_analyzer_settings)

Description

It creates a new analyzer settings object.

Parameters

api_analyzer_settings

A pointer reference to a created analyzer settings object.

API Error Codes

Value

Description

API_ERROR_INSUFFICIENT_MEMORY

3

Insufficient memory to create a new API object.

APIAnalyzerSettings _destroy()

Prototype

C
APIAnalyzerSettings_destroy(APIAnalyzerSettings* *api_analyzer_settings)

Description

It destroys the created APIAnalyzerSettings object.

Parameters

api_analyzer_setting

Pointer to the APIAnalyzerSettings object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

APIAnalyzerSettings_GetSegmentBufferSize()

Prototype

C
APIAnalyzerSettings_GetSegmentBufferSize(APIAnalyzerSettings
*api_analyzer_settings,
int device_index,
int *segment_buffer_size)

Description

It returns the size of the segment buffer.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

device_index

Zero-based index of the device.

Segment_buffer_size

Segment buffer size (specified in KB).

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

APIAnalyzerSettings_SetSegmentBufferSize()

Prototype

C
APIAnalyzerSettings_SetSegmentBufferSize(APIAnalyzerSettings
*api_analyzer_settings,
int device_index, int segment_size)

Description

It sets the size of a segment buffer.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

device_index

Zero-based index of the device.

segment_size

New segment size in Kbytes.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_SEGMENT_SIZE

9

Invalid segment size.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

APIAnalyzerSettings_SetTraceFileName()

Prototype

C
APIAnalyzerSettings_SetTraceFileName(APIAnalyzerSettings
*api_analyzer_settings,
const char* file_name)

Description

It sets the file name of the analyzer settings.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

file_name

A null terminate file name of analyzer settings object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIAnalyzerSettings_GetTraceFileName()

Prototype

C
APIAnalyzerSettings_GetTraceFileName(APIAnalyzerSettings
*api_analyzer_settings,
char **trace_file_name)

Description

It returns the trace file name of the analyzer settings object.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

file_name

Returned trace file name. This pointer must not be deleted or destroyed by the user.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIAnalyzerSettings_SetNumberOfSegment()

Prototype

C
APIAnalyzerSettings_SetNumberOfSegment(APIAnalyzerSettings
*api_analyzer_settings,
int segment_number)

Description

It sets the number of segments. If the segment buffer size is not valid according to the device property and new segment number, it will change to the valid maximum segment buffer size, depending on the quantity of current segments.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

segment_number

Number of segments.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_NUMBER_OF_SEGMENT

10

Invalid number of segments.

APIAnalyzerSettings_GetNumberOfSegment()

Prototype

C
APIAnalyzerSettings_GetNumberOfSegment(APIAnalyzerSettings
*api_analyzer_settings,
int *number_of_segment)

Description

It returns the number of segments.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

segment_number

Number of segments.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIAnalyzerSettings_SetTrigMode()

Prototype

C
APIAnalyzerSettings_SetTrigMode(APIAnalyzerSettings *api_analyzer_settings,
ETriggerMode trig_mode)

Description

It sets trigger mode.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

trig_mode

Trigger mode. Can be one of these values:

SNAPSHOT: 0

PATTERN: 1

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_TRIG_MODE

11

Invalid trigger mode.

APIAnalyzerSettings_GetTrigMode()

Prototype

C
APIAnalyzerSettings_GetTrigMode(APIAnalyzerSettings *api_analyzer_settings,
ETriggerMode *trig_mode)

Description

It returns trigger mode.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

trig_mode

Returns trigger mode. Can be one of these values:

SNAPSHOT: 0

PATTERN: 1

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APIAnalyzerSettings_SetTrigFilterSetting()

Prototype

C
APIAnalyzerSettings_SetTrigFilterSetting(APIAnalyzerSettings
*api_analyzer_settings,
int device_index,
const char *trig_setting_name)

Description

It sets trigger filter setting.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

trig_setting_name

Null-terminated Trigger/Filter setting name in the currently open project.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_TRIGGER_NAME

7

Invalid trigger name.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

APIAnalyzerSettings_SetTrigPosition()

Prototype

C
APIAnalyzerSettings_SetTrigPosition(APIAnalyzerSettings
*api_analyzer_settings,
int device_index, int trig_position)

Description

It sets the trigger position.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

device_index

Zero-based index of the device.

trig_position

Project trigger’s position. It can be 1 to 99.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_TRIGGER_POSITION

8

Invalid trigger position. It must be between 1 and 99.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

APIAnalyzerSettings_GetTrigPosition()

Prototype

C
APIAnalyzerSettings_GetTrigPosition(APIAnalyzerSettings
*api_analyzer_settings,
int device_index, int *trig_position)

Description

It returns the trigger position.

Parameters

api_analyzer_settings

Pointer of the analyzer settings.

device_index

Zero-based index of the device.

trig_position

Project trigger’s position. It can be 1 to 99.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_DEVICE_INDEX

5

Invalid device index.

Trace methods

Declarations and prototypes

C
APITrace.h

APITrace_create()

Prototype

C
APITrace_create(APITrace* *api_trace)

Description

It creates a new trace object.

Parameters

api_trace

Pointer to the trace object.

API Error Codes

Value

Description

API_ERROR_INSUFFICIENT_MEMORY

3

There is insufficient memory to create a new API object.

APITrace_destroy()

Prototype

C
APITrace_destroy(APITrace* *api_trace)

Description

It destroys the created trace object. It does not close the trace file. It calls APITrace_Close() function before destroying the api_trace object.

Parameters

api_trace

Pointer to the trace object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_SAVE_TRACE

21

It cannot save the trace.

API_ERROR_CAN_NOT_CLOSE_TRACE

22

It cannot close the trace.

APITrace_Open()

Prototype

C
APITrace_Open(APITrace *api_trace, const char *file_name)

Description

It opens a trace. If trace file needs to be updated, it will be updated and then opened. The update process updates the trace file without creating any backup from the updated trace file.

Parameters

api_trace

Pointer to the trace object.

file_name

Null-terminated string providing the full pathname to the trace file.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_UPDATE_TRACE

20

It cannot update the trace.

API_ERROR_CAN_NOT_OPEN_TRACE

19

It cannot open the trace.

APITrace_Close()

Prototype

C
APITrace_Close(APITrace *api_trace)

Description

It closes the opened trace object. If the trace has any modification, it is saved and then closed.

Parameters

api_trace

Pointer to the trace object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_CAN_NOT_SAVE_TRACE

21

It cannot save the trace.

API_ERROR_CAN_NOT_CLOSE_TRACE

22

It cannot close the trace.

APITrace_GetStartDateTime()

Prototype

C
APITrace_GetStartDateTime(APITrace *api_trace, time_t *start_date_time)

Description

It returns the start date-time of the trace object.

Parameters

api_trace

Pointer to the trace object.

start_date_time

Start date-time of the trace.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITrace_GetEndDateTime()

Prototype

C
APITrace_GetEndDateTime(APITrace *api_trace, time_t *end_date_time)

Description

It returns the end date-time of the trace object.

Parameters

api_trace

Pointer to the trace object.

end_date_time

End date-time of the trace.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITrace_GetTriggerDateTime()

Prototype

C
APITrace_GetTriggerDateTime(APITrace *api_trace, time_t *trig_date_time)

Description

It returns the trigger date-time of the trace object.

Parameters

api_trace

Pointer to the trace object.

trig_date_time

Trigger date-time of the trace.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITrace_ExportToCSV()

Prototype

C
APITrace_ExportToCSV(APITrace *api_trace, const char *csv_file_name,
OnExportProc OnExport)

Description

This function export an opened trace file to CSV file.

Parameters

api_trace

Pointer to the trace object.

Csv_file_name

csv file name

OnExport

Callback function, used to report percentage of exporting process.

void OnExport( int progress );

This callback function is called to provide status updates on the progress of an export operation. progress is an integer from 0 to 100 that indicates the percentage of completion of the export.

API Error Codes

Value

Description

API_EXCEPTION

1

An exception occurred.

APITrace_ExportToWireshark()

Prototype

C
APITrace_ExportToWireshark(APITrace *api_trace, const char
*wireshark_file_name, EAPILinkProtocol api_link_protocol, OnExportProc
OnExport)

Description

This function exports an opened trace file to wireshark.

Parameters

api_trace

Pointer to the trace object.

Wireshark_file_name

Output file name.

api_link_protocol

Specifies whether you want to export Ethernet frames or Fibre channel frames. It can be one of below values:

API_LINK_PROTOCOL_ETHERNET = 0;

API_LINK_PROTOCOL_FC = 1;

OnExport

Callback function, used to report percentage of exporting process.

void OnExport( int progress );

This callback function is called to provide status updates on the progress of an export operation. progress is an integer from 0 to 100 that indicates the percentage of completion of the export.

API Error Codes

Value

Description

API_EXCEPTION

1

An exception occurred.

Packet methods

Declarations and prototypes

C
APITracePacket.h

APITracePacket_create()

Prototype

C
APITracePacket_create(APITracePacket* *api_trace_packet)

Description

It creates a new trace object.

Parameters

api_trace_packet

Pointer to the trace packet object.

API Error Codes

Value

Description

API_ERROR_INSUFFICIENT_MEMORY

3

There is insufficient memory to create a new API object.

APITracePacket_destroy()

Prototype

C
APITracePacket_destroy(APITracePacket* *api_trace_packet)

Description

It destroys the created packet object.

Parameters

api_trace_packet

Pointer to the trace packet object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

APITracePacket_GetTimeStamp()

Prototype

C
APITracePacket_GetTimeStamp(APITracePacket *api_trace_packet,
__int64 *timestamp)

Description

It returns time stamp of the packet in picosecconds. One picosecond is equal to 1/1000 nanosecond.

Parameters

api_trace_packet

Pointer to the trace packet object.

timestamp

Timestamp of the packet in picoseconds.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITracePacket_GetChannel()

Prototype

C
APITracePacket_GetChannel(APITracePacket *api_trace_packet, int *channel)

Description

It returns the packet’s channel.

Parameters

api_trace_packet

Pointer to the trace packet object.

channel

Channel of the packet.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITracePacket_GetSpeed()

Prototype

C
APITracePacket_GetSpeed(APITracePacket *api_trace_packet,
EAnalyzerSpeed *speed)

Description

It returns the packet’s speed.

Parameters

api_trace_packet

Pointer to the trace packet object.

speed

Speed of the packet.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITracePacket_GetType()

Prototype

C
APITracePacket_GetType(APITracePacket *api_trace_packet, EDataType *type)

Description

It returns the packet’s protocol.

Parameters

api_trace_packet

Pointer to the trace packet object.

type

The type of the packet. The Packet Type enumeration is given below:

ConnectDisconnect

0

EthernetFrame

1

FCFrame

2

EthernetOrderedSet

3

FCOrderedSet

4

AutoNegotiation

5

TrainingSequence

6

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITracePacket_GetData()

Prototype

C
APITracePacket_GetData(APITracePacket *api_trace_packet,
unsigned char* *data, int *data_length)

Description

The raw_data parameter will be set to the address of the raw data buffer of the packet. The return value shows the size of the buffer in bytes.

The packet object manages the raw data buffer. Do not attempt to manually delete the buffer. The buffer is valid as long as the packet object is alive and the trace is open.

Parameters

api_trace_packet

Pointer to the trace packet object.

data

It will be set to the address of the packet’s data buffer.

data_length

Data size in bytes.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

The format for each packet type is as follows. Unless otherwise specified, the byte ordering is little-endian.

DWord

Description

Connect/Disconnect

0

Connect: 1/Disconnect: 0

Ethernet Frame

0

Ethernet Frame

1

Ethernet Frame

2

Ethernet Frame

...

...

N

Ethernet Frame

FC Frame

0

SOF

1

FC Frame

2

FC Frame

...

...

N

EOF

Ethernet Ordered Set

0

Order Set Data (64 bits)

1

2

Order Set Count

FC Frame

0

Order Set Data (32 bits)

1

Order Set Count

Auto Negotiation (Packed Format)

9

Count

Training Sequence

0

Control Field + Status Fields

1

Count

APITracePacket_GetBookmark()

Prototype

C
APITracePacket_GetBookmark(APITracePacket *api_trace_packet,
char* *bookmark)

Description

It returns the packet’s bookmark.

Parameters

api_trace_packet

Pointer to the trace packet object.

bookmark

Current bookmark of the packet.

Return value

It returns packet bookmark strings (only the bookmark title). The packet object manages the returned buffers. Do not attempt to manually delete the buffers. The buffers are valid as long as the packet object is alive and the trace is open.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITracePacket_SetBookmark()

Prototype

C
APITracePacket_SetBookmark(APITracePacket *api_trace_packet,
const char *bookmark)

Description

It places a new bookmark on the packet. If the packet already has an existing bookmark, it is replaced with the new one.

Parameters

api_trace_packet

Pointer to the trace packet object.

bookmark

Name of the bookmark.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

Trace iterator methods

Declarations and Prototypes

C
APITraceIterator.h

APITraceIterator_create()

Prototype

C
APITraceIterator_create(APITrace *api_trace, APITraceIterator*
*api_trace_iterator)

Description

It creates a new trace iterator object. The iterator will be initialized to the beginning of the trace.

Parameters

api_trace

Trace object

api_trace_iterator

Reference pointer of created iterator object.

API Error Codes

Value

Description

API_ERROR_INVALID_TRACE

14

Invalid API trace object.

API_ERROR_INSUFFICIENT_MEMORY

3

There is insufficient memory to create a new API object.

APITraceIterator_destroy()

Prototype

C
APITraceIterator_destroy(APITraceIterator* *api_trace_iterator)

Description

It destroys the created trace iterator object.

Parameters

api_trace_iterator

Reference pointer of created iterator object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

APITraceIterator_HasNext()

Prototype

C
APITraceIterator_HasNext(APITraceIterator *api_trace_iterator,
bool *has_next)

Description

It returns true if iteration has more packets when traversing in forward direction; otherwise, returns false.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

has_next

If there is a next packet, it will be true; otherwise it will be false.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_HasPrevious()

Prototype

C
APITraceIterator_HasPrevious(APITraceIterator *api_trace_iterator,
bool *has_previous)

Description

It returns true if iteration has more packets when traversing in backward direction; otherwise, returns false.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

has_previous

If there is any previous packet, it will be true; otherwise it will be false.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_GetNext()

Prototype

C
APITraceIterator_GetNext(APITraceIterator *api_trace_iterator,
APITracePacket *api_trace_packet)

Description

It returns the iterator packet and moves the iterator forward.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

api_trace_packet

Next packet container.

Return value

It returns next packet of iterator and moves the iterator forward.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_GetPrevious()

Prototype

C
APITraceIterator_GetPrevious(APITraceIterator *api_trace_iterator,
APITracePacket *api_trace_packet)

Description

It returns previous packet of iterator and moves the iterator backward.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

api_trace_packet

Previous packet container.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_PeekNext()

Prototype

C
APITraceIterator_PeekNext(APITraceIterator *api_trace_iterator,
APITracePacket *api_trace_packet)

Description

It returns next packet of iterator without moving the iterator forward.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

api_trace_packet

Next packet container.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_PeekPrevious()

Prototype

C
APITraceIterator_PeekPrevious(APITraceIterator *api_trace_iterator,
APITracePacket *api_trace_packet)

Description

It returns previous packet of iterator without moving the iterator backward.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

api_trace_packet

Previous packet container.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_GetAt()

Prototype

C
APITraceIterator_GetAt(APITraceIterator *api_trace_iterator, int index,
APITracePacket *api_trace_packet)

Description

It returns packet in the input index.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

index

Index of record. It is a zero-based index.

api_trace_packet

Packet container.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

API_ERROR_INVALID_INDEX_OF_PACKET

15

Invalid index of packet.

APITraceIterator_GetCount()

Prototype

C
APITraceIterator_GetCount(APITraceIterator *api_trace_iterator, int *count)

Description

It returns the number of packets.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

count

Packet count.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_ToBack()

Prototype

C
APITraceIterator_ToBack(APITraceIterator *api_trace_iterator)

Description

It moves the iterator pointer to the last packet.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

APITraceIterator_ToFront()

Prototype

C
APITraceIterator_ToFront(APITraceIterator *api_trace_iterator): void

Description

It moves the iterator pointer to the first packet.

Parameters

api_trace_iterator

Pointer to the trace iterator object.

API Error Codes

Value

Description

API_ERROR_INVALID_OBJECT

2

The API object is not valid.

API_EXCEPTION

1

An exception occurred.

Examples

The following is a simple example for using the API to iterate through all the packets in a trace file.

For complete examples, please refer to the API examples named "Trace" and "Project" which are provided with the Net Protocol Suite installer. This example is located in the directory.

"...\API\Examples\Project" and "...\API\Examples\Trace"