Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

ISO 14229 (UDS) server and client for embedded systems

License

NotificationsYou must be signed in to change notification settings

driftregion/iso14229

Repository files navigation

Build Status

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

API status: Major version zero (0.y.z)(not yet stable). Anything MAY change at any time.

Using this library

  1. Downloadiso14229.zip from thereleases page, copyiso14229.c andiso14229.h into your project.
  2. Select a transport layer using the table below and enable it by defining thecopt in your project's build configuration.
Transport LayercoptSuitable for
ISO-TP sockets-DUDS_TP_ISOTP_SOCKLinux socketcan
isotp-c on socketcan-DUDS_TP_ISOTP_C_SOCKETCANLinux socketcan
isotp-c (bring your own CAN)-DUDS_TP_ISOTP_Cembedded systems, Windows, Linux non-socketcan, ...
  1. Refer to theexamples andtests for usage.

Compile-Time Features

The following features are configured with preprocessor defines:

DefineDescriptionValid values
-DUDS_TP_ISOTP_Cbuild the isotp-c transport layer (recommended for bare-metal systems)defined or not
-DUDS_TP_ISOTP_SOCKbuild the isotp socket transport layer (recommended for linux)defined or not
-DUDS_TP_ISOTP_C_SOCKETCANbuild the isotp-c transport layer with socketcan support (linux-only)defined or not
-DUDS_LOG_LEVEL=...Sets the logging level. Internal log messages are useful for bringup and unit tests. This defaults toUDS_LOG_LEVEL=UDS_LOG_NONE which completely disables logging, ensuring that no logging-related code goes in to the binary.UDS_LOG_NONE, UDS_LOG_ERROR, UDS_LOG_WARN, UDS_LOG_INFO, UDS_LOG_DEBUG, UDS_LOG_VERBOSE
-DUDS_SERVER_...server configuration optionsseesrc/config.h
-DUDS_CLIENT_...client configuration optionsseesrc/config.h
-DUDS_SYS=Selects target system. Seesrc/sys.hUDS_SYS_CUSTOM,UDS_SYS_UNIX,UDS_SYS_WINDOWS,UDS_SYS_ARDUINO,UDS_SYS_ESP32

Deprecated Compile-Time Features

DefineReason for deprecationmitigation
-DUDS_ENABLE_ASSERTredundantUse the standard-DNDEBUG to disable assertions.
-DUDS_ENABLE_DEBUG_PRINTreplaced byUDS_LOGUse-DUDS_LOG_LEVEL= to set or disable logging.

Features

  • entirely static memory allocation. (nomalloc,calloc, ...)
  • highly portable and tested
    • architectures: arm, x86-64, ppc, ppc64, risc
    • systems: linux, Windows, esp32, Arduino, NXP s32k
    • transports: isotp-c, linux isotp sockets

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

Documentation: Server

Server Events

seeenum UDSEvent insrc/uds.h

UDS_EVT_DiagSessCtrl (0x10)

Arguments

typedefstruct {constuint8_ttype;/**< requested session type */uint16_tp2_ms;/**< optional return value: p2 timing override */uint32_tp2_star_ms;/**< optional return value: p2* timing override */}UDSDiagSessCtrlArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest to change diagnostic level accepted.
0x12UDS_NRC_SubFunctionNotSupportedThe server doesn't support this diagnostic level
0x22UDS_NRC_ConditionsNotCorrectThe server can't/won't transition to the specified diagnostic level at this time

UDS_EVT_ECUReset (0x11)

Arguments

typedefstruct {constuint8_ttype;/**< reset type requested by client */uint8_tpowerDownTime;/**< Optional response: notify client of time until shutdown (0-254) 255                              indicates that a time is not available. */}UDSECUResetArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest to reset ECU accepted.
0x12UDS_NRC_SubFunctionNotSupportedThe server doesn't support the specified type of ECU reset
0x22UDS_NRC_ConditionsNotCorrectThe server can't reset now
0x33UDS_NRC_SecurityAccessDeniedThe current level of security access doesn't permit this type of ECU reset

UDS_EVT_ReadDataByIdent (0x22)

Arguments

typedefstruct {constuint16_tdataId;/*! data identifier *//*! function for copying to the server send buffer. Returns `UDS_PositiveResponse` on success and `UDS_NRC_ResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */constuint8_t (*copy)(UDSServer_t*srv,constvoid*src,uint16_tcount); }UDSRDBIArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest to read data accepted (be sure to callcopy(...))
0x14UDS_NRC_ResponseTooLongThe total length of the response message exceeds the transport buffer size
0x31UDS_NRC_RequestOutOfRangeThe requested data identifer isn't supported
0x33UDS_NRC_SecurityAccessDeniedThe current level of security access doesn't permit reading the requested data identifier

UDS_EVT_SecAccessRequestSeed,UDS_EVT_SecAccessValidateKey (0x27)

Arguments

typedefstruct {constuint8_tlevel;/*! requested security level */constuint8_t*constdataRecord;/*! pointer to request data */constuint16_tlen;/*! size of request data *//*! function for copying to the server send buffer. Returns `UDS_PositiveResponse` on success and `UDS_NRC_ResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */uint8_t (*copySeed)(UDSServer_t*srv,constvoid*src,uint16_tlen);}UDSSecAccessRequestSeedArgs_t;typedefstruct {constuint8_tlevel;/*! security level to be validated */constuint8_t*constkey;/*! key sent by client */constuint16_tlen;/*! length of key */}UDSSecAccessValidateKeyArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x12UDS_NRC_SubFunctionNotSupportedThe requested security level is not supported
0x22UDS_NRC_ConditionsNotCorrectThe server can't handle the request right now
0x31UDS_NRC_RequestOutOfRangeThedataRecord contains invalid data
0x35UDS_NRC_InvalidKeyThe key doesn't match
0x36UDS_NRC_ExceededNumberOfAttemptsFalse attempt limit reached
0x37UDS_NRC_RequiredTimeDelayNotExpiredRequestSeed request received and delay timer is still active

UDS_EVT_CommCtrl (0x28)

Arguments

typedefstruct {uint8_tctrlType;uint8_tcommType;}UDSCommCtrlArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x12UDS_NRC_SubFunctionNotSupportedThe requested control type is not supported
0x22UDS_NRC_ConditionsNotCorrectThe server can't enable/disable the selected communication type now
0x31UDS_NRC_RequestOutOfRangeThe requested control type or communication type is erroneous

UDS_EVT_WriteDataByIdent (0x2E)

Arguments

typedefstruct {constuint16_tdataId;/*! WDBI Data Identifier */constuint8_t*constdata;/*! pointer to data */constuint16_tlen;/*! length of data */}UDSWDBIArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest to write data accepted
0x22UDS_NRC_ConditionsNotCorrectThe server can't write this data now
0x31UDS_NRC_RequestOutOfRangeThe requested data identifer isn't supported or the data is invalid
0x33UDS_NRC_SecurityAccessDeniedThe current level of security access doesn't permit writing to the requested data identifier
0x72UDS_NRC_GeneralProgrammingFailureMemory write failed

UDS_EVT_RoutineCtrl (0x31)

Arguments

typedefstruct {constuint8_tctrlType;/*! routineControlType */constuint16_tid;/*! routineIdentifier */constuint8_t*optionRecord;/*! optional data */constuint16_tlen;/*! length of optional data *//*! function for copying to the server send buffer. Returns `UDS_PositiveResponse` on success and `UDS_NRC_ResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */uint8_t (*copyStatusRecord)(UDSServer_t*srv,constvoid*src,uint16_tlen);}UDSRoutineCtrlArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x22UDS_NRC_ConditionsNotCorrectThe server can't perform this operation now
0x24UDS_NRC_RequestSequenceErrorStop requested but routine hasn't started. Start requested but routine has already started (optional). Results are not available becuase routine has never started.
0x31UDS_NRC_RequestOutOfRangeThe requested routine identifer isn't supported or theoptionRecord is invalid
0x33UDS_NRC_SecurityAccessDeniedThe current level of security access doesn't permit this operation
0x72UDS_NRC_GeneralProgrammingFailureinternal memory operation failed (e.g. erasing flash)

UDS_EVT_RequestDownload (0x34)

Arguments

typedefstruct {constvoid*addr;/*! requested address */constsize_tsize;/*! requested download size */constuint8_tdataFormatIdentifier;/*! optional specifier for format of data */uint16_tmaxNumberOfBlockLength;/*! response: inform client how many data bytes to send in each                                        `TransferData` request */}UDSRequestDownloadArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x22UDS_NRC_ConditionsNotCorrectThe server can't perform this operation now
0x31UDS_NRC_RequestOutOfRangedataFormatIdentifier invalid,addr orsize invalid
0x33UDS_NRC_SecurityAccessDeniedThe current level of security access doesn't permit this operation
0x34UDS_NRC_AuthenticationRequiredClient rights insufficient
0x70UDS_NRC_UploadDownloadNotAccepteddownload cannot be accomplished due to fault

UDS_EVT_TransferData (0x36)

Arguments

typedefstruct {constuint8_t*constdata;/*! transfer data */constuint16_tlen;/*! transfer data length *//*! function for copying to the server send buffer. Returns `UDS_PositiveResponse` on success and `UDS_NRC_ResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */uint8_t (*copyResponse)(UDSServer_t*srv,constvoid*src,uint16_tlen);}UDSTransferDataArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x31UDS_NRC_RequestOutOfRangedata contents invalid, length incorrect
0x72UDS_NRC_GeneralProgrammingFailureMemory write failed
0x92UDS_NRC_VoltageTooHighCan't write flash: voltage too high
0x93UDS_NRC_VoltageTooLowCan't write flash: voltage too low

UDS_EVT_RequestTransferExit (0x37)

Arguments

typedefstruct {constuint8_t*constdata;/*! request data */constuint16_tlen;/*! request data length *//*! function for copying to the server send buffer. Returns `UDS_PositiveResponse` on success and `UDS_NRC_ResponseTooLong` if the length of the data to be copied exceeds that of the server send buffer */uint8_t (*copyResponse)(UDSServer_t*srv,constvoid*src,uint16_tlen);}UDSRequestTransferExitArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x31UDS_NRC_RequestOutOfRangedata contents invalid, length incorrect
0x72UDS_NRC_GeneralProgrammingFailurefinalizing the data transfer failed

UDS_SRV_EVT_RequestFileTransfer (0x38)

Arguments

typedefstruct {constuint8_tmodeOfOperation;/*! requested specifier for operation mode */constuint16_tfilePathLen;/*! request data length */constuint8_t*filePath;/*! requested file path and name */constuint8_tdataFormatIdentifier;/*! optional specifier for format of data */constsize_tfileSizeUnCompressed;/*! optional file size */constsize_tfileSizeCompressed;/*! optional file size */uint16_tmaxNumberOfBlockLength;/*! optional response: inform client how many data bytes to                                           send in each    `TransferData` request */}UDSRequestFileTransferArgs_t;

Supported Responses

ValueenumMeaning
0x00UDS_PositiveResponseRequest accepted
0x13UDS_NRC_IncorrectMessageLengthOrInvalidFormatLength of the message is wrong
0x22UDS_NRC_ConditionsNotCorrectDownloading or uploading data is ongoing or other conditions to be able to execute this service are not met
0x31UDS_NRC_RequestOutOfRangedata contents invalid, length incorrect
0x33UDS_NRC_SecurityAccessDeniedThe server is secure
0x70UDS_NRC_UploadDownloadNotAcceptedAn attempt to download to a server's memory cannot be accomplished due to some fault conditions

Documentation: Client

See the examples directory

Contributing

contributions are welcome

Reporting Issues

When reporting issues, please state what you expected to happen.

Running Tests

bazeltest //...

Seetest/README.md

Release

bazel build //:release

Release Checklist

  • be sure branch is rebased on main
  • run all tests locally (including vcan and examples) withbazel test //...
  • push branch, check all tests are passing in CI
  • update release notes in README.md
  • increment version insrc/version.h and commit changes
  • git tag with version, e.g.git tag v0.8.0 (the current implementation of.github/workflows/release.yml grabs the release triple from the git tag)

Acknowledgements

Changelog

0.9.0

  • breaking API changes:
    • converted subfunction enums to #defines with standard-consistent naming
    • simplified transport API

0.8.0

  • breaking API changes:
    • event enum consolidatedUDS_SRV_EVT_... ->UDS_EVT
    • UDSClient refactored into event-based API
    • negative server response now raises a client error by default.
    • server NRCs prefixed withUDS_NRC_
    • NRCs merged intoUDS_Err enum.
  • added more examples of client usage

0.7.2

  • runtime safety:
    1. turn off assertions by default, enable by-DUDS_ENABLE_ASSERT
    2. preferreturn UDS_ERR_INVALID_ARG; over assertion in public functions
  • use SimonCahill fork of isotp-c

0.7.1

  • amalgamated sources intoiso14229.c andiso14229.h to ease integration

0.7.0

  • test refactoring. theme: test invariance across different transports and processor architectures
  • breaking API changes:
    • overhauled transport layer implementation
    • simplified client and server init
    • UDS_ARCH_ renamed toUDS_SYS_

0.6.0

  • breaking API changes:
    • UDSClientErr_t merged intoUDSErr_t
    • TP_SEND_INPROGRESS renamed toUDS_TP_SEND_IN_PROGRESS
    • refactoredUDSTp_t to encourage struct inheritance
    • UDS_TP_LINUX_SOCKET renamed toUDS_TP_ISOTP_SOCKET
  • added server fuzz test and qemu tests
  • cleaned up example tests, added isotp-c on socketcan to examples
  • addedUDS_EVT_DoScheduledReset
  • improve client error handling

0.5.0

  • usability: refactored into a single .c/.h module
  • usability: default transport layer configs are now built-in
  • API cleanup: useUDS prefix on all exported functions
  • API cleanup: use a single callback function for all server events

0.4.0

  • refactor RDBIHandler to pass a function pointer that implements safe memmove rather than requiring the user to keep valid data around for an indefinite time or risking a buffer overflow.
  • Prefer fixed-width. Avoid usingenum types as return types and in structures.
  • Transport layer is now pluggable and supports the linux kernel ISO-TP driver in addition toisotp-c. Seeexamples.

0.3.0

  • addediso14229ClientRunSequenceBlocking(...)
  • added server and client examples
  • simplified test flow, deleted opaque macros and switch statements
  • flattened client and server main structs
  • simplified usage by moving isotp-c initialization parameters into server/client config structs
  • remove redundant buffers in server

0.2.0

  • removed all instances of__attribute__((packed))
  • refactored server download functional unit API to simplify testing
  • refactored tests
    • ordered by service
    • documented macros
  • removed middleware
  • simplified server routine control API
  • removed redundant functioniso14229ServerEnableService
  • updated example

0.1.0

  • Add client
  • Add server SID 0x27 SecurityAccess
  • API changes

0.0.0

  • initial release

[8]ページ先頭

©2009-2025 Movatter.jp