« Close

Datasheets and User Guides

App Notes

Software & Driver

 

3.1 - Timeout Configs

Timeout Configs Overview

LJM can be configured to set separate timeouts when connecting to a device and when sending / receiving packets to / from a device. Both of these timeout types can be configured separately for USB, Ethernet, and WiFi.

The open timeouts are:

LJM_OPEN_TCP_DEVICE_TIMEOUT_MS may be used to set both open timeout configs at the same time.
The send / receive (command-response) timeouts are:

LJM_SEND_RECEIVE_TIMEOUT_MS may be used to set all three send / receive timeouts at the same time.

All timeouts are in units of milliseconds.

Details

One command-response operation (as performed by a function like LJM_eReadName, for example) may take longer than the timeout for that connection type. This is because there are multiple timeout periods -- one to send the command and another to receive the response.

Setting a new timeout value will not affect pending timeouts.

Setting a timeout value to 0 sets an infinite timeout.

Relevant Functions

To read a timeout config, use LJM_ReadLibraryConfigS.

To write a timeout config, use LJM_WriteLibraryConfigS or LJM_LoadConfigurationFile.

Example

[C/C++] Read LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS, set LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS, then read it again

char ErrorString[LJM_MAX_NAME_SIZE];
double Value = 0;
int LJMError = LJM_ReadLibraryConfigS(LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS, &Value);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_ReadLibraryConfigS error: %s\n", ErrorString);
}
printf("The default for LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS is %.00f milliseconds\n", Value);

Value = 3000;
printf("Setting LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS to %.00f milliseconds\n", Value);
LJMError = LJM_WriteLibraryConfigS(LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS, Value);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_WriteLibraryConfigS error: %s\n", ErrorString);
}

LJMError = LJM_ReadLibraryConfigS(LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS, &Value);
if (LJMError != 0) {
    LJM_ErrorToString(LJMError, ErrorString);
    printf("LJM_ReadLibraryConfigS error: %s\n", ErrorString);
}
printf("LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS is now %.00f milliseconds\n", Value);

Possible output:

The default for LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS is 2000 milliseconds
Setting LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS to 3000 milliseconds
LJM_ETHERNET_SEND_RECEIVE_TIMEOUT_MS is now 3000 milliseconds

For more LJM configurations, see Library Configuration Functions.