lib/cansend: update documentation for CAN XL frame format
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/504/head
parent
7761d8bcf8
commit
740c0ba156
28
cansend.c
28
cansend.c
|
|
@ -64,11 +64,13 @@ static void print_usage(char *prg)
|
||||||
"Usage: %s <device> <can_frame>.\n"
|
"Usage: %s <device> <can_frame>.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"<can_frame>:\n"
|
"<can_frame>:\n"
|
||||||
" <can_id>#{data} for Classical CAN 2.0 data frames\n"
|
" <can_id>#{data} for CAN CC (Classical CAN 2.0B) data frames\n"
|
||||||
" <can_id>#R{len} for Classical CAN 2.0 data frames\n"
|
" <can_id>#R{len} for CAN CC (Classical CAN 2.0B) data frames\n"
|
||||||
" <can_id>#{data}_{dlc} for Classical CAN 2.0 data frames\n"
|
" <can_id>#{data}_{dlc} for CAN CC (Classical CAN 2.0B) data frames\n"
|
||||||
" <can_id>#R{len}_{dlc} for Classical CAN 2.0 data frames\n"
|
" <can_id>#R{len}_{dlc} for CAN CC (Classical CAN 2.0B) data frames\n"
|
||||||
" <can_id>##<flags>{data} for CAN FD frames\n\n"
|
" <can_id>##<flags>{data} for CAN FD frames\n"
|
||||||
|
" <vcid><prio>#<flags>:<sdt>:<af>#<data> for CAN XL frames\n"
|
||||||
|
"\n"
|
||||||
"<can_id>:\n"
|
"<can_id>:\n"
|
||||||
" 3 (SFF) or 8 (EFF) hex chars\n"
|
" 3 (SFF) or 8 (EFF) hex chars\n"
|
||||||
"{data}:\n"
|
"{data}:\n"
|
||||||
|
|
@ -80,9 +82,23 @@ static void print_usage(char *prg)
|
||||||
"<flags>:\n"
|
"<flags>:\n"
|
||||||
" a single ASCII Hex value (0 .. F) which defines canfd_frame.flags\n"
|
" a single ASCII Hex value (0 .. F) which defines canfd_frame.flags\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"<vcid>:\n"
|
||||||
|
" 2 hex chars - virtual CAN network identifier (00 .. FF)\n"
|
||||||
|
"<prio>:\n"
|
||||||
|
" 3 hex chars - 11 bit priority value (000 .. 7FF)\n"
|
||||||
|
"<flags>:\n"
|
||||||
|
" 2 hex chars values (00 .. FF) which defines canxl_frame.flags\n"
|
||||||
|
"<sdt>:\n"
|
||||||
|
" 2 hex chars values (00 .. FF) which defines canxl_frame.sdt\n"
|
||||||
|
"<af>:\n"
|
||||||
|
" 8 hex chars - 32 bit acceptance field (canxl_frame.af)\n"
|
||||||
|
"<data>:\n"
|
||||||
|
" 1..2048 ASCII hex-values (optionally separated by '.')\n"
|
||||||
|
"\n"
|
||||||
"Examples:\n"
|
"Examples:\n"
|
||||||
" 5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311223344 /\n"
|
" 5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311223344 /\n"
|
||||||
" 1F334455#1122334455667788_B / 123#R / 00000123#R3 / 333#R8_E\n"
|
" 1F334455#1122334455667788_B / 123#R / 00000123#R3 / 333#R8_E /\n"
|
||||||
|
" 45123#81:00:12345678#11223344.556677 / 00242#81:07:40000123#112233\n"
|
||||||
"\n",
|
"\n",
|
||||||
prg, prg);
|
prg, prg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
33
lib.h
33
lib.h
|
|
@ -110,9 +110,10 @@ int hexstring2data(char *arg, unsigned char *data, int maxdlen);
|
||||||
|
|
||||||
int parse_canframe(char *cs, cu_t *cu);
|
int parse_canframe(char *cs, cu_t *cu);
|
||||||
/*
|
/*
|
||||||
* Transfers a valid ASCII string describing a CAN frame into struct canfd_frame.
|
* Transfers a valid ASCII string describing a CAN frame into the CAN union
|
||||||
|
* containing CAN CC/FD/XL structs.
|
||||||
*
|
*
|
||||||
* CAN 2.0 frames (aka Classical CAN)
|
* CAN CC frames (aka Classical CAN, CAN 2.0B)
|
||||||
* - string layout <can_id>#{R{len}|data}{_len8_dlc}
|
* - string layout <can_id>#{R{len}|data}{_len8_dlc}
|
||||||
* - {data} has 0 to 8 hex-values that can (optionally) be separated by '.'
|
* - {data} has 0 to 8 hex-values that can (optionally) be separated by '.'
|
||||||
* - {len} can take values from 0 to 8 and can be omitted if zero
|
* - {len} can take values from 0 to 8 and can be omitted if zero
|
||||||
|
|
@ -125,6 +126,16 @@ int parse_canframe(char *cs, cu_t *cu);
|
||||||
* - {data} has 0 to 64 hex-values that can (optionally) be separated by '.'
|
* - {data} has 0 to 64 hex-values that can (optionally) be separated by '.'
|
||||||
* - return value on successful parsing: CANFD_MTU
|
* - return value on successful parsing: CANFD_MTU
|
||||||
*
|
*
|
||||||
|
* CAN XL frames
|
||||||
|
* - string layout <vcid><prio>#<flags>:<sdt>:<af>#{data}
|
||||||
|
* - <vcid> a two ASCII Hex value (00 .. FF) which defines the VCID
|
||||||
|
* - <prio> a three ASCII Hex value (000 .. 7FF) which defines the 11 bit PRIO
|
||||||
|
* - <flags> a two ASCII Hex value (00 .. FF) which defines canxl_frame.flags
|
||||||
|
* - <sdt> a two ASCII Hex value (00 .. FF) which defines canxl_frame.sdt
|
||||||
|
* - <af> a 8 digit ASCII Hex value which defines the 32 bit canxl_frame.af
|
||||||
|
* - {data} has 1 to 2048 hex-values that can (optionally) be separated by '.'
|
||||||
|
* - return value on successful parsing: CANXL_MTU
|
||||||
|
*
|
||||||
* Return value on detected problems: 0
|
* Return value on detected problems: 0
|
||||||
*
|
*
|
||||||
* <can_id> can have 3 (standard frame format) or 8 (extended frame format)
|
* <can_id> can have 3 (standard frame format) or 8 (extended frame format)
|
||||||
|
|
@ -155,6 +166,9 @@ int parse_canframe(char *cs, cu_t *cu);
|
||||||
* ^^
|
* ^^
|
||||||
* CAN FD extension to handle the canfd_frame.flags content
|
* CAN FD extension to handle the canfd_frame.flags content
|
||||||
*
|
*
|
||||||
|
* 45123#81:00:12345678#11223344.556677 -> CAN XL frame with len = 7,
|
||||||
|
* VCID = 0x45, PRIO = 0x123, flags = 0x81, sdt = 0x00, af = 0x12345678
|
||||||
|
*
|
||||||
* Simple facts on this compact ASCII CAN frame representation:
|
* Simple facts on this compact ASCII CAN frame representation:
|
||||||
*
|
*
|
||||||
* - 3 digits: standard frame format
|
* - 3 digits: standard frame format
|
||||||
|
|
@ -169,8 +183,9 @@ int sprint_canframe(char *buf , cu_t *cu, int sep);
|
||||||
* Creates a CAN frame hexadecimal output in compact format.
|
* Creates a CAN frame hexadecimal output in compact format.
|
||||||
* The CAN data[] is separated by '.' when sep != 0.
|
* The CAN data[] is separated by '.' when sep != 0.
|
||||||
*
|
*
|
||||||
* The type of the CAN frame (CAN CC / CAN FD) is specified by
|
* A CAN XL frame is detected when CANXL_XLF is set in the struct
|
||||||
* by the dual-use struct canfd_frame.flags element:
|
* cu.canxl_frame.flags. Otherwise the type of the CAN frame (CAN CC/FD)
|
||||||
|
* is specified by the dual-use struct cu.canfd_frame.flags element:
|
||||||
* w/o CAN FD flags (== 0) -> CAN CC frame (aka Classical CAN, CAN2.0B)
|
* w/o CAN FD flags (== 0) -> CAN CC frame (aka Classical CAN, CAN2.0B)
|
||||||
* with CAN FD flags (!= 0) -> CAN FD frame (with CANFD_[FDF/BRS/ESI])
|
* with CAN FD flags (!= 0) -> CAN FD frame (with CANFD_[FDF/BRS/ESI])
|
||||||
*
|
*
|
||||||
|
|
@ -182,6 +197,8 @@ int sprint_canframe(char *buf , cu_t *cu, int sep);
|
||||||
* 32345678#112233 -> error frame with CAN_ERR_FLAG (0x2000000) set
|
* 32345678#112233 -> error frame with CAN_ERR_FLAG (0x2000000) set
|
||||||
* 123##0112233 -> CAN FD frame standard CAN-Id = 0x123, flags = 0, len = 3
|
* 123##0112233 -> CAN FD frame standard CAN-Id = 0x123, flags = 0, len = 3
|
||||||
* 123##2112233 -> CAN FD frame, flags = CANFD_ESI, len = 3
|
* 123##2112233 -> CAN FD frame, flags = CANFD_ESI, len = 3
|
||||||
|
* 45123#81:00:12345678#11223344.556677 -> CAN XL frame with len = 7,
|
||||||
|
* VCID = 0x45, PRIO = 0x123, flags = 0x81, sdt = 0x00, af = 0x12345678
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -198,8 +215,9 @@ int sprint_long_canframe(char *buf , cu_t *cu, int view);
|
||||||
/*
|
/*
|
||||||
* Creates a CAN frame hexadecimal output in user readable format.
|
* Creates a CAN frame hexadecimal output in user readable format.
|
||||||
*
|
*
|
||||||
* The type of the CAN frame (CAN CC / CAN FD) is specified by
|
* A CAN XL frame is detected when CANXL_XLF is set in the struct
|
||||||
* by the dual-use struct canfd_frame.flags element:
|
* cu.canxl_frame.flags. Otherwise the type of the CAN frame (CAN CC/FD)
|
||||||
|
* is specified by the dual-use struct cu.canfd_frame.flags element:
|
||||||
* w/o CAN FD flags (== 0) -> CAN CC frame (aka Classical CAN, CAN2.0B)
|
* w/o CAN FD flags (== 0) -> CAN CC frame (aka Classical CAN, CAN2.0B)
|
||||||
* with CAN FD flags (!= 0) -> CAN FD frame (with CANFD_[FDF/BRS/ESI])
|
* with CAN FD flags (!= 0) -> CAN FD frame (with CANFD_[FDF/BRS/ESI])
|
||||||
*
|
*
|
||||||
|
|
@ -209,10 +227,13 @@ int sprint_long_canframe(char *buf , cu_t *cu, int view);
|
||||||
* 321 {B} 11 22 33 44 55 66 77 88 -> Classical CAN with raw '{DLC}' value B
|
* 321 {B} 11 22 33 44 55 66 77 88 -> Classical CAN with raw '{DLC}' value B
|
||||||
* 20001111 [7] C6 23 7B 32 69 98 3C ERRORFRAME -> (CAN_ERR_FLAG set)
|
* 20001111 [7] C6 23 7B 32 69 98 3C ERRORFRAME -> (CAN_ERR_FLAG set)
|
||||||
* 12345678 [03] 11 22 33 -> CAN FD with extended CAN-Id = 0x12345678, len = 3
|
* 12345678 [03] 11 22 33 -> CAN FD with extended CAN-Id = 0x12345678, len = 3
|
||||||
|
* 123 [0003] (45|81:00:12345678) 11 22 33 -> CAN XL frame with VCID 0x45
|
||||||
*
|
*
|
||||||
* 123 [3] 11 22 33 -> CANLIB_VIEW_INDENT_SFF == 0
|
* 123 [3] 11 22 33 -> CANLIB_VIEW_INDENT_SFF == 0
|
||||||
* 123 [3] 11 22 33 -> CANLIB_VIEW_INDENT_SFF == set
|
* 123 [3] 11 22 33 -> CANLIB_VIEW_INDENT_SFF == set
|
||||||
*
|
*
|
||||||
|
* There are no binary or ASCII view modes for CAN XL and the number of displayed
|
||||||
|
* data bytes is limited to 64 to fit terminal output use-cases.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *cf,
|
int snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *cf,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue