ndStartPeriodicTesterPresent
- Updated2025-10-07
- 2 minute(s) read
Purpose
Starts a background thread for the current diagnostic session that periodically transmits a TesterPresent message. Format
long ndStartPeriodicTesterPresent(
TD1 *diagRef,
uint32_t messageType,
double periodSec,
int32_t responseRequired,
uint8_t userMessage[],
int32_t len);
Input
diagRef
Specifies the diagnostic session handle, obtained from ndOpenDiagnosticOnCANFD and passed to subsequent diagnostic functions. Typically, it is not necessary to manipulate the elements of this struct manually.
messageType
Defines the periodic message to be transmitted. Choices are:
| KWP2000 TesterPresent | 0 | A TesterPresent message according to the KWP2000 protocol as defined in ISO 14230-3. The responseRequired parameter determines whether the message is configured to have a response. |
| UDS TesterPresent | 1 | A TesterPresent message according to the UDS protocol as defined in ISO 14229-1. The responseRequired parameter determines whether the message is configured to have a response. |
| User Defined | 2 | Any user defined message can be transmitted periodically. Specify the message in the userMessage parameter. The message must be configured according to the setting of the responseRequired parameter. If the responseRequired parameter does not match the behavior of the message given, the behavior is undefined. |
periodSec
Specifies the transmit period of the periodic message in floating point seconds.
responseRequired
Indicates whether the periodic message will have a response.
| 0 | Indicates no response is expected and handled. |
| !=0 | Indicates a response is processed but ignored. |
userMessage
Specifies a byte array that contains the message to be transmitted periodically for the User Defined messageType.
len
Specifies the length of the userMessage. This parameter should be set to 0 if no userMessage is specified. Output
Return Value
The return value indicates the function call status as a signed 32-bit integer.
Zero means the function executed successfully.
A negative value indicates an error, which means the function did not perform the expected behavior.
A positive value indicates a warning, which means the function performed as expected, but a condition arose that may require attention.
Use the ndStatusToString function to obtain a descriptive string for the return value.
DescriptionOften it is necessary to transmit a TesterPresent service to keep a diagnostic session alive in the ECU. This function automatically transmits a periodic TesterPresent message in the context of the current diagnostic session, as long as no other communication takes place. The automatic transmissions do not interfere with the regular diagnostic communication the user initiates.