EmSACAN_Write
Prototype
emsacan_result_t EmSACAN_Write(
emsacan_handle_t Handle,
uint8_t ChannelNumber,
emsacan_msg_t *pMessage );
Description
Transmits one CAN message on the specified port.
Parameters
| Parameter | Direction | Type | Description |
|---|---|---|---|
Handle | in | emsacan_handle_t | Session handle from EmSACAN_Connect. |
ChannelNumber | in | uint8_t | Zero-based port index (0 … NumberofChannels−1). |
pMessage | in | emsacan_msg_t | Frame to send. |
Return value
EMSACAN_OK on success, EMSACAN_ERR_INVALIDCHANNEL if ChannelNumber is out of range, or another emsacan_result_t code on failure.
Example
emsacan_msg_t msg = { 0 };
msg.id = 0x123;
msg.len = 4;
msg.type = EMSACAN_MSGTYPE_NONE;
msg.data[0] = 0xDE; msg.data[1] = 0xAD;
msg.data[2] = 0xBE; msg.data[3] = 0xEF;
emsacan_result_t rc = EmSACAN_Write(handle, 0, &msg);
if (rc == EMSACAN_ERR_TXOVERFLOW)
{ /* hardware TX queue full — back off and retry */ }
