Transmit a frame
Informative
How upper-layer software sends a CAN L-PDU. Binding rules: CHI-CAN-MUST-08 to CHI-CAN-MUST-12 in Can — Requirements; signature: API Reference.
Goal
Queue a frame for transmission on a STARTED channel and learn when it completes.
Send
uint8 payload[8] = { 0 };
Can_PduInfoType pdu = {
.pduId = 7u, /* your handle; echoed back in the confirmation */
.frameId = 0x123u, /* MSBs select standard/extended and FD/classic */
.sduLength = 8u,
.sduDataPtr = payload,
};
Std_ReturnType r = Can_Transmit(0u /* mailboxId */, &pdu);
Handle the return value:
Value |
Do |
|---|---|
|
Frame accepted. Keep |
|
Mailbox is busy with another frame; retry later. The in-flight frame is untouched. |
|
A development error was detected (see Errors); fix the call. |
Confirmation
Transmission completes asynchronously. The driver calls back:
void CanIf_OnTransmission(PduIdType pduId)
{
/* pduId == 7u here — the value you put in pdu.pduId. */
}
Classic vs. CAN FD, and length
The frame is sent as CAN FD only when the channel is in FD mode and the FD bit is set in
frameId; otherwise it is sent as a classic frame.If
sduLengthis not a valid DLC, the driver rounds up to the next valid DLC and pads the extra bytes with the configuredfd_padding_value(CHI-CAN-MUST-12).
Note
Buffer ownership. The driver copies your data, but you must keep sduDataPtr valid until
the operation completes. Do not free or overwrite it before CanIf_OnTransmission fires.
See also
Concepts — the Event handling sequence traces the full transmit-then-confirm flow for both interrupt and polling modes.