|
iso14229 0.10.0
ISO14229-1 (UDS) C Library
|
The UDS server API provides functionality for implementing diagnostic services that respond to UDS client requests. The server is event-driven. Incoming client requests are processed by your service handler function (called fn by convention).
The service handler function server.fn is called by UDSServerPoll when an event occurs. A listing of all events is available in UDSEvent_t.
The handler structure has five parts:
Example Handler:
The UDSServer_t structure contains:
| Identifier | Description | How to Use |
|---|---|---|
| tp | Pointer to ISO-TP transport layer | Set during initialization: server.tp = transport; |
| fn | Event handler callback function | Set during initialization: server.fn = fn; |
| fn_data | User data bound to server, accessible in fn | Optional: server.fn_data = &my_data; |
| p2_ms | P2 timeout in milliseconds | Internal use only; Set default with UDS_SERVER_DEFAULT_P2_MS |
| p2_star_ms | P2* timeout in milliseconds | Internal use only; Set default with UDS_SERVER_DEFAULT_P2_STAR_MS |
| s3_ms | S3 session timeout in milliseconds | Internal use only; Set default with UDS_SERVER_DEFAULT_S3_MS |
| sessionType | Current diagnostic session | Read: if (server.sessionType == UDS_LEV_DS_EXTDS) |
| securityLevel | Current security level | Read/write: server.securityLevel = args->level; |
| xferIsActive | Transfer operation active flag | Read: if (server.xferIsActive) |
| xferBlockSequenceCounter | Transfer block sequence counter | Read only |
| r | Current request/response buffers | Internal use only |
See UDSEvent_t for the mapping from event to argument type.
Return UDS_OK or use the copy function to send data:
Return a Negative Response Code (NRC):
Return UDS_NRC_RequestCorrectlyReceived_ResponsePending (0x78) to indicate that processing is taking longer than P2:
This is used to prevent the client from timing out during long-running server actions such as writing to flash memory.
To control long-running tasks asynchronously, consider using UDSSendRoutineCtrl .
The server tracks the current diagnostic session:
Sessions automatically timeout after S3 time of inactivity, returning to the default session.
Some configuration options are set at compile-time. See : Compile-Time Configuration.