canSend - Send CAN message

Send a CAN data frame. If no payload bytes are given, a zero-length data frame is sent for the msgId.

Usage:

- command: canSend <port> <msgId> [<b> <b> ...] [nofd]
  [extractKey: <key>]
  [retry: <retryCount>]
  [with:
    [- flags <flags>]
    [- dlc <dlc>]]

Argument

Description

port

CAN port name: CAN0, CAN1, CAN2, etc.

msgId

CAN Message Arbitration ID (11-bit standard or 29-bit extended). Can be specified as a decimal, hex, or binary number, depending on prefix. Use 0x for hex and 0b for binary. If no prefix is specified, the value will be interpreted as decimal.

b

Payload bytes, in order, starting at byte 0. Up to 8 bytes on Classic CAN, or up to 64 bytes on a port configured for CAN-FD (see canCfg - Configure CAN interface). Each byte can be specified as a decimal, hex, or binary number, depending on prefix. Use 0x for hex and 0b for binary. If no prefix is specified, the value will be interpreted as decimal.

nofd

Send a Classic CAN frame on a port configured for CAN-FD, instead of a CAN-FD frame. Has no effect on a port that isn’t configured for CAN-FD. Must be the last token on the command line, after all payload bytes.

key

Key in which to store the transmitted payload, as a hex string (optional)

retryCount

Number of times to retry the test step (optional)

flags

Optional: raw CAN-FD flags byte (0…15) to send with the frame.

dlc

Optional: DLC value to send when no payload bytes (b) are given, for example to send an empty frame that still advertises a non-zero data length code. Ignored if any payload bytes are supplied — in that case the DLC is derived from the payload length.

Note

The built-in CAN0 port does not support CAN-FD. CAN-FD frames (64-byte payloads, with: flags, nofd) are only available on externally-attached USB CAN-FD dongles that have been configured with FD via canCfg - Configure CAN interface.

Examples