CDX Model CAN API

Foreground-only access to the model’s sole logical IPC bus.

IPC maps to CM7’s Model IPC/CAN3 port, not a physical CM4 CAN controller. Call from model callbacks, not interrupts or concurrent threads.

Contents

Typedefs

Typedef Description
CDX_DATA_64 Aligned eight-byte payload chunk with unsigned access views.
CDX_CAN_FRAME_FLAGS CDX flags; these values are not the Model IPC wire flag encoding.
CDX_CAN_FRAME Received frame; the frame and data are valid only during RX callback.
CDX_CAN_TX_PARAMS TX request copied during enqueue; zero-initialize before filling it.

Functions

Function Description
CDX_can_frame_flags_is_std Test for a classic standard-ID frame.
CDX_can_frame_flags_is_ext Test for a classic extended-ID frame.
CDX_can_frame_flags_is_fd_std Test for a CAN-FD standard-ID frame.
CDX_can_frame_flags_is_fd_ext Test for a CAN-FD extended-ID frame.
CDX_can_tx_enqueue_copy Copy a TX request and payload into the nonblocking Model IPC queue.
CDX_can_is_timed_out_ms Test elapsed local milliseconds using unsigned wrap-safe subtraction.
CDX_can_read_signal_u32_le Read an unsigned, little-endian signal of up to 32 bits.
CDX_can_read_signal_u64_le Read an unsigned, little-endian signal of up to 64 bits.
CDX_can_read_signal_u32_be Read an unsigned, big-endian signal of up to 32 bits.
CDX_can_read_signal_u64_be Read an unsigned, big-endian signal of up to 64 bits.

Macros

Macro Description
CDX_CAN_FRAME_FLAG_NONE Classic frame with a standard 11-bit identifier.
CDX_CAN_FRAME_FLAG_IDE Extended 29-bit identifier.
CDX_CAN_FRAME_FLAG_EDL CAN-FD payload, up to 64 bytes instead of the classic 8-byte limit.
CDX_CAN_FRAME_FLAG_BRS CAN-FD bit-rate switch; valid only with EDL.
CDX_CAN_FRAME_FLAG_DISABLE_DEADLINE Ignore deadline_ticks when enqueueing and publishing this TX frame.

Typedefs

CDX_DATA_64

Aligned eight-byte payload chunk with unsigned access views.

1typedef union CDX_DATA_64_UNION CDX_DATA_64

CDX_CAN_FRAME_FLAGS

CDX flags; these values are not the Model IPC wire flag encoding.

1typedef uint16_t CDX_CAN_FRAME_FLAGS

CDX_CAN_FRAME

Received frame; the frame and data are valid only during RX callback.

1typedef struct CDX_CAN_FRAME_STRUCT CDX_CAN_FRAME

CDX_CAN_TX_PARAMS

TX request copied during enqueue; zero-initialize before filling it.

1typedef struct CDX_CAN_TX_PARAMS_STRUCT CDX_CAN_TX_PARAMS

Functions

CDX_can_frame_flags_is_std

Test for a classic standard-ID frame.

1int CDX_can_frame_flags_is_std(CDX_CAN_FRAME_FLAGS flags)

Returns

Nonzero if both IDE and EDL are clear.

Parameters

Location: cdx_can.h:101

CDX_can_frame_flags_is_ext

Test for a classic extended-ID frame.

1int CDX_can_frame_flags_is_ext(CDX_CAN_FRAME_FLAGS flags)

Returns

Nonzero if IDE is set and EDL is clear.

Parameters

Location: cdx_can.h:109

CDX_can_frame_flags_is_fd_std

Test for a CAN-FD standard-ID frame.

1int CDX_can_frame_flags_is_fd_std(CDX_CAN_FRAME_FLAGS flags)

Returns

Nonzero if EDL is set and IDE is clear.

Parameters

Location: cdx_can.h:117

CDX_can_frame_flags_is_fd_ext

Test for a CAN-FD extended-ID frame.

1int CDX_can_frame_flags_is_fd_ext(CDX_CAN_FRAME_FLAGS flags)

Returns

Nonzero if both IDE and EDL are set.

Parameters

Location: cdx_can.h:125

CDX_can_tx_enqueue_copy

Copy a TX request and payload into the nonblocking Model IPC queue.

1CDX_STATUS CDX_can_tx_enqueue_copy(CDX_CAN_BUS_ID bus, CDX_CAN_TX_PARAMS const *params, CDX_DATA_64 const *data)

retval

  • CDX_STATUS_OK: Copied and accepted; not yet delivered to the peer.
  • CDX_STATUS_BAD_PARAM: Invalid bus, pointer, flags, ID or length.
  • CDX_STATUS_IPC_OFFLINE: No bound RUNNING runtime or IPC session lost.
  • CDX_STATUS_TIMEOUT: Nonzero, enabled deadline has already expired.
  • CDX_STATUS_QUEUE_FULL: Newest frame rejected; runtime drop count rises.

Note: There are no TX completion callbacks. Acceptance does not guarantee publication, physical CAN delivery or model execution. Queued frames may expire or be discarded on IPC fault. Published batches remain owned by the peer until acknowledgement; they cannot be cancelled by expiry.

Parameters

  • CDX_CAN_BUS_ID bus: Sole logical bus: CDX_CAN_BUS_ID_IPC (legacy CAN1 is an alias).
  • CDX_CAN_TX_PARAMS const * params: Nonnull request, with supported flags, ID and byte length.
  • CDX_DATA_64 const * data: Aligned payload chunks containing length_bytes bytes; may be NULL only for an empty payload. Storage may be reused after this call.

Location: cdx_can.h:150

CDX_can_is_timed_out_ms

Test elapsed local milliseconds using unsigned wrap-safe subtraction.

1int CDX_can_is_timed_out_ms(CDX_MILLISEC_32 received_ms, CDX_MILLISEC_32 timeout_ms)

Returns

Nonzero if elapsed milliseconds are at least timeout_ms.

Note: The timestamp must be less than one millisecond-counter wrap old.

Parameters

  • CDX_MILLISEC_32 received_ms: Recent past timestamp from the local millisecond clock.
  • CDX_MILLISEC_32 timeout_ms: Timeout interval; zero always times out.

Location: cdx_can.h:159

CDX_can_read_signal_u32_le

Read an unsigned, little-endian signal of up to 32 bits.

1uint32_t CDX_can_read_signal_u32_le(void const *buffer, uint32_t size, uint16_t offset, uint8_t bits)

Returns

Raw value, or zero for an invalid pointer, width or range.

Note: Invalid input is indistinguishable from a valid zero-valued signal.

Parameters

  • void const * buffer: Nonnull source buffer; never modified.
  • uint32_t size: Source size in bytes, including CAN-FD data if present.
  • uint16_t offset: Least significant bit position in internal DBC numbering.
  • uint8_t bits: Signal width, 1 through 32; the entire signal must fit.

Location: cdx_can.h:163

CDX_can_read_signal_u64_le

Read an unsigned, little-endian signal of up to 64 bits.

1uint64_t CDX_can_read_signal_u64_le(void const *buffer, uint32_t size, uint16_t offset, uint8_t bits)

Returns

Raw value, or zero for an invalid pointer, width or range.

Parameters

  • void const * buffer: Nonnull source buffer; never modified.
  • uint32_t size: Source size in bytes.
  • uint16_t offset: Least significant bit position in internal DBC numbering.
  • uint8_t bits: Signal width, 1 through 64; the entire signal must fit.

Location: cdx_can.h:167

CDX_can_read_signal_u32_be

Read an unsigned, big-endian signal of up to 32 bits.

1uint32_t CDX_can_read_signal_u32_be(void const *buffer, uint32_t size, uint16_t offset, uint8_t bits)

Returns

Raw value, or zero for an invalid pointer, width or range.

Parameters

  • void const * buffer: Nonnull source buffer; never modified.
  • uint32_t size: Source size in bytes.
  • uint16_t offset: Internal start-LSB position, not external Motorola start-MSB.
  • uint8_t bits: Signal width, 1 through 32; the entire signal must fit.

Location: cdx_can.h:171

CDX_can_read_signal_u64_be

Read an unsigned, big-endian signal of up to 64 bits.

1uint64_t CDX_can_read_signal_u64_be(void const *buffer, uint32_t size, uint16_t offset, uint8_t bits)

Returns

Raw value, or zero for an invalid pointer, width or range.

Parameters

  • void const * buffer: Nonnull source buffer; never modified.
  • uint32_t size: Source size in bytes.
  • uint16_t offset: Internal start-LSB position, not external Motorola start-MSB.
  • uint8_t bits: Signal width, 1 through 64; the entire signal must fit.

Location: cdx_can.h:175

Macros

CDX_CAN_FRAME_FLAG_NONE

1#define CDX_CAN_FRAME_FLAG_NONE 0u

Classic frame with a standard 11-bit identifier.

CDX_CAN_FRAME_FLAG_IDE

1#define CDX_CAN_FRAME_FLAG_IDE 0x0001u

Extended 29-bit identifier.

CDX_CAN_FRAME_FLAG_EDL

1#define CDX_CAN_FRAME_FLAG_EDL 0x0008u

CAN-FD payload, up to 64 bytes instead of the classic 8-byte limit.

CDX_CAN_FRAME_FLAG_BRS

1#define CDX_CAN_FRAME_FLAG_BRS 0x0010u

CAN-FD bit-rate switch; valid only with EDL.

CDX_CAN_FRAME_FLAG_DISABLE_DEADLINE

1#define CDX_CAN_FRAME_FLAG_DISABLE_DEADLINE 0x0100u

Ignore deadline_ticks when enqueueing and publishing this TX frame.