|
CAN CoreX 2.3.1
Table-driven CAN, CAN FD, ISO-TP, network simulation, and bus monitoring library
|
Allocation-free helpers for SLCAN text conversion, hex conversion, and linear signal scaling. More...
Macros | |
| #define | CCX_SLCAN_CLASSIC_MAX_LINE_LEN 28U |
| Maximum NUL-terminated classic SLCAN data-frame line length. | |
Enumerations | |
| enum | CCX_UTILS_Status_t { CCX_UTILS_OK = 0 , CCX_UTILS_NULL_PTR , CCX_UTILS_WRONG_ARG , CCX_UTILS_BUFFER_TOO_SMALL , CCX_UTILS_UNSUPPORTED } |
| Status values returned by CAN CoreX utility helpers. More... | |
Functions | |
| CCX_UTILS_Status_t | CCX_SLCAN_Parse (const char *line, CCX_message_t *msg) |
| Parse a classic SLCAN data-frame line into a CAN CoreX message. | |
| CCX_UTILS_Status_t | CCX_SLCAN_Format (const CCX_message_t *msg, char *out, size_t out_size) |
| Format a CAN CoreX classic CAN message as an SLCAN data-frame line. | |
| CCX_UTILS_Status_t | CCX_BytesToHex (const uint8_t *bytes, size_t byte_count, char *out, size_t out_size) |
| Convert bytes to an uppercase hex string. | |
| CCX_UTILS_Status_t | CCX_HexToBytes (const char *hex, size_t hex_len, uint8_t *out, size_t out_size, size_t *bytes_written) |
| Convert a hex string to bytes. | |
Allocation-free helpers for SLCAN text conversion, hex conversion, and linear signal scaling.
| #define CCX_SLCAN_CLASSIC_MAX_LINE_LEN 28U |
Maximum NUL-terminated classic SLCAN data-frame line length.
The longest supported line is an extended 29-bit data frame with 8 data bytes: T + 8 hex ID chars + 1 DLC char + 16 hex data chars + \r + \0.
| enum CCX_UTILS_Status_t |
Status values returned by CAN CoreX utility helpers.
| CCX_UTILS_Status_t CCX_BytesToHex | ( | const uint8_t * | bytes, |
| size_t | byte_count, | ||
| char * | out, | ||
| size_t | out_size ) |
Convert bytes to an uppercase hex string.
No separators are inserted. The output is NUL-terminated.
| bytes | Source bytes. |
| byte_count | Number of bytes to convert. |
| out | Caller-owned output buffer. |
| out_size | Size of out in chars. |
| CCX_UTILS_Status_t CCX_HexToBytes | ( | const char * | hex, |
| size_t | hex_len, | ||
| uint8_t * | out, | ||
| size_t | out_size, | ||
| size_t * | bytes_written ) |
Convert a hex string to bytes.
The input length must be even. Uppercase and lowercase hex digits are accepted.
| hex | Source hex characters. |
| hex_len | Number of hex characters to parse. |
| out | Caller-owned output byte buffer. |
| out_size | Capacity of out in bytes. |
| bytes_written | Optional destination for the number of bytes written. |
| CCX_UTILS_Status_t CCX_SLCAN_Format | ( | const CCX_message_t * | msg, |
| char * | out, | ||
| size_t | out_size ) |
Format a CAN CoreX classic CAN message as an SLCAN data-frame line.
The output is always terminated with \r and \0. Only classic CAN data frames are supported.
| msg | Source message. |
| out | Caller-owned output buffer. |
| out_size | Size of out in chars. |
| CCX_UTILS_Status_t CCX_SLCAN_Parse | ( | const char * | line, |
| CCX_message_t * | msg ) |
Parse a classic SLCAN data-frame line into a CAN CoreX message.
Supported input forms:
The parser accepts a trailing \r, \n, \r\n, or the end of the C string exactly after the last expected frame character. Remote frames (r/R) are not represented by CCX_message_t and are returned as CCX_UTILS_UNSUPPORTED.
| line | NUL-terminated SLCAN line. |
| msg | Destination message. |