Home

Awesome

iso14229

<p align="center"> <a href="https://github.com/driftregion/iso14229/actions"><img src="https://github.com/driftregion/iso14229/actions/workflows/runtests.yml/badge.svg" alt="Build Status"></a> <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a> </p>

iso14229 is an implementation of UDS (ISO14229) targeting embedded systems. It is tested with isotp-c as well as linux kernel ISO15765-2 (ISO-TP) transport layer implementations.

API status: not yet stable.

Using this library

  1. Download iso14229.zip from the releases page, copy iso14229.c and iso14229.h into your source tree and build.
  2. Look at the examples

Build Systems

iso14229 is designed to build on any platform.

Preprocessor Defines

DefineDescriptionValid values
-DUDS_TP_ISOTP_Cbuild the isotp-c transport layer (recommended for bare-metal systems)on/off
-DUDS_TP_ISOTP_SOCKbuild the isotp socket transport layer (recommended for linux)on/off
-DUDS_TP_ISOTP_C_SOCKETCANbuild the isotp-c transport layer with socketcan support (linux-only)on/off
UDS_...Additional configuration optionssee src/config.h
UDS_SYSSelects target systemsee src/sys.h

Features

supported functions (server and client )

SIDnamesupported
0x10diagnostic session control
0x11ECU reset
0x14clear diagnostic information
0x19read DTC information
0x22read data by identifier
0x23read memory by address
0x24read scaling data by identifier
0x27security access
0x28communication control
0x2Aread periodic data by identifier
0x2Cdynamically define data identifier
0x2Ewrite data by identifier
0x2Finput control by identifier
0x31routine control
0x34request download
0x35request upload
0x36transfer data
0x37request transfer exit
0x38request file transfer
0x3Dwrite memory by address
0x3Etester present
0x83access timing parameter
0x84secured data transmission
0x85control DTC setting
0x86response on event

Running Tests

See test_all.sh and test/README.md

Documentation

Server Events

see enum UDSServerEvent in src/uds.h

UDS_SRV_EVT_DiagSessCtrl (0x10)

Arguments

typedef struct {
    const enum UDSDiagnosticSessionType type; /**< requested session type */
    uint16_t p2_ms;                           /**< optional return value: p2 timing override */
    uint32_t p2_star_ms;                      /**< optional return value: p2* timing override */
} UDSDiagSessCtrlArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest to change diagnostic level accepted.
0x12kSubFunctionNotSupportedThe server doesn't support this diagnostic level
0x22kConditionsNotCorrectThe server can't/won't transition to the specified diagnostic level at this time

UDS_SRV_EVT_ECUReset (0x11)

Arguments

typedef struct {
    const enum UDSECUResetType type; /**< reset type requested by client */
    uint8_t powerDownTime; /**< Optional response: notify client of time until shutdown (0-254) 255
                              indicates that a time is not available. */
} UDSECUResetArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest to reset ECU accepted.
0x12kSubFunctionNotSupportedThe server doesn't support the specified type of ECU reset
0x22kConditionsNotCorrectThe server can't reset now
0x33kSecurityAccessDeniedThe current level of security access doesn't permit this type of ECU reset

UDS_SRV_EVT_ReadDataByIdent (0x22)

Arguments

typedef struct {
    const uint16_t dataId; /*! data identifier */
    /*! function for copying to the server send buffer. Returns `kPositiveResponse` on success and `kResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */
    const uint8_t (*copy)(UDSServer_t *srv, const void *src,
                    uint16_t count); 
} UDSRDBIArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest to read data accepted (be sure to call copy(...))
0x14kResponseTooLongThe total length of the response message exceeds the transport buffer size
0x31kRequestOutOfRangeThe requested data identifer isn't supported
0x33kSecurityAccessDeniedThe current level of security access doesn't permit reading the requested data identifier

UDS_SRV_EVT_SecAccessRequestSeed, UDS_SRV_EVT_SecAccessValidateKey (0x27)

Arguments

typedef struct {
    const uint8_t level;             /*! requested security level */
    const uint8_t *const dataRecord; /*! pointer to request data */
    const uint16_t len;              /*! size of request data */
    /*! function for copying to the server send buffer. Returns `kPositiveResponse` on success and `kResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */
    uint8_t (*copySeed)(UDSServer_t *srv, const void *src,
                        uint16_t len);
} UDSSecAccessRequestSeedArgs_t;

typedef struct {
    const uint8_t level;      /*! security level to be validated */
    const uint8_t *const key; /*! key sent by client */
    const uint16_t len;       /*! length of key */
} UDSSecAccessValidateKeyArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x12kSubFunctionNotSupportedThe requested security level is not supported
0x22kConditionsNotCorrectThe server can't handle the request right now
0x31kRequestOutOfRangeThe dataRecord contains invalid data
0x35kInvalidKeyThe key doesn't match
0x36kExceededNumberOfAttemptsFalse attempt limit reached
0x37kRequiredTimeDelayNotExpiredRequestSeed request received and delay timer is still active

UDS_SRV_EVT_CommCtrl (0x28)

Arguments

typedef struct {
    enum UDSCommunicationControlType ctrlType; 
    enum UDSCommunicationType commType;
} UDSCommCtrlArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x12kSubFunctionNotSupportedThe requested control type is not supported
0x22kConditionsNotCorrectThe server can't enable/disable the selected communication type now
0x31kRequestOutOfRangeThe requested control type or communication type is erroneous

UDS_SRV_EVT_WriteDataByIdent (0x2E)

Arguments

typedef struct {
    const uint16_t dataId;     /*! WDBI Data Identifier */
    const uint8_t *const data; /*! pointer to data */
    const uint16_t len;        /*! length of data */
} UDSWDBIArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest to write data accepted
0x22kConditionsNotCorrectThe server can't write this data now
0x31kRequestOutOfRangeThe requested data identifer isn't supported or the data is invalid
0x33kSecurityAccessDeniedThe current level of security access doesn't permit writing to the requested data identifier
0x72kGeneralProgrammingFailureMemory write failed

UDS_SRV_EVT_RoutineCtrl (0x31)

Arguments

typedef struct {
    const uint8_t ctrlType;      /*! routineControlType */
    const uint16_t id;           /*! routineIdentifier */
    const uint8_t *optionRecord; /*! optional data */
    const uint16_t len;          /*! length of optional data */
    /*! function for copying to the server send buffer. Returns `kPositiveResponse` on success and `kResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */
    uint8_t (*copyStatusRecord)(UDSServer_t *srv, const void *src,
                                uint16_t len);
} UDSRoutineCtrlArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x22kConditionsNotCorrectThe server can't perform this operation now
0x24kRequestSequenceErrorStop requested but routine hasn't started. Start requested but routine has already started (optional). Results are not available becuase routine has never started.
0x31kRequestOutOfRangeThe requested routine identifer isn't supported or the optionRecord is invalid
0x33kSecurityAccessDeniedThe current level of security access doesn't permit this operation
0x72kGeneralProgrammingFailureinternal memory operation failed (e.g. erasing flash)

UDS_SRV_EVT_RequestDownload (0x34)

Arguments

typedef struct {
    const void *addr;                   /*! requested address */
    const size_t size;                  /*! requested download size */
    const uint8_t dataFormatIdentifier; /*! optional specifier for format of data */
    uint16_t maxNumberOfBlockLength; /*! response: inform client how many data bytes to send in each
                                        `TransferData` request */
} UDSRequestDownloadArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x22kConditionsNotCorrectThe server can't perform this operation now
0x31kRequestOutOfRangedataFormatIdentifier invalid, addr or size invalid
0x33kSecurityAccessDeniedThe current level of security access doesn't permit this operation
0x34kAuthenticationRequiredClient rights insufficient
0x70kUploadDownloadNotAccepteddownload cannot be accomplished due to fault

UDS_SRV_EVT_TransferData (0x36)

Arguments

typedef struct {
    const uint8_t *const data; /*! transfer data */
    const uint16_t len;        /*! transfer data length */
    /*! function for copying to the server send buffer. Returns `kPositiveResponse` on success and `kResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */
    uint8_t (*copyResponse)(
        UDSServer_t *srv, const void *src,
        uint16_t len);
} UDSTransferDataArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x31kRequestOutOfRangedata contents invalid, length incorrect
0x72kGeneralProgrammingFailureMemory write failed
0x92kVoltageTooHighCan't write flash: voltage too high
0x93kVoltageTooLowCan't write flash: voltage too low

UDS_SRV_EVT_RequestTransferExit (0x37)

Arguments

typedef struct {
    const uint8_t *const data; /*! request data */
    const uint16_t len;        /*! request data length */
    /*! function for copying to the server send buffer. Returns `kPositiveResponse` on success and `kResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */
    uint8_t (*copyResponse)(UDSServer_t *srv, const void *src,
                            uint16_t len);
} UDSRequestTransferExitArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x31kRequestOutOfRangedata contents invalid, length incorrect
0x72kGeneralProgrammingFailurefinalizing the data transfer failed

UDS_SRV_EVT_RequestFileTransfer (0x38)

Arguments

typedef struct {
    const uint8_t modeOfOperation;      /*! requested specifier for operation mode */
    const uint16_t filePathLen;         /*! request data length */
    const uint8_t *filePath;            /*! requested file path and name */
    const uint8_t dataFormatIdentifier; /*! optional specifier for format of data */
    const size_t fileSizeUnCompressed;  /*! optional file size */
    const size_t fileSizeCompressed;    /*! optional file size */
    uint16_t maxNumberOfBlockLength;    /*! optional response: inform client how many data bytes to
                                           send in each    `TransferData` request */
} UDSRequestFileTransferArgs_t;

Supported Responses

ValueenumMeaning
0x00kPositiveResponseRequest accepted
0x13kIncorrectMessageLengthOrInvalidFormatLength of the message is wrong
0x22kConditionsNotCorrectDownloading or uploading data is ongoing or other conditions to be able to execute this service are not met
0x31kRequestOutOfRangedata contents invalid, length incorrect
0x33kSecurityAccessDeniedThe server is secure
0x70kUploadDownloadNotAcceptedAn attempt to download to a server's memory cannot be accomplished due to some fault conditions

Examples

examples/README.md

Running Tests

make test

Contributing

contributions are welcome

Acknowledgements

Changelog

0.7.1

0.7.0

0.6.0

0.5.0

0.4.0

0.3.0

0.2.0

0.1.0

0.0.0