| Description | | The CAN_set function sets the DATA FRAME message to be sent automatically by the CAN controller hardware (specified by ctrl) in response to a REMOTE FRAME request. If the CAN controller hardware supports REMOTE FRAME requests, this function sets the DATA FRAME message from msg. If the hardware is busy it will retry every timer tick. The timeout specifies how long to wait for the hardware to become available. | timeout | Description |
|---|
| 0 | Return immediately. | | 0x0001-0xFFFE | Wait the specified number of RTX Kernel ticks. | | 0xFFFF | Wait infinitely. |
If the message is not set by the specified time, an error is returned. The CAN_set function executes quickly because the CAN controller hardware is rarely busy for long periods of time. The CAN_set function is part of RL-CAN. The prototype is defined in rtx_can.h. |
| Example | |
#include <rtx_can.h>
void task_send_CAN (void) __task
{
unsined int i = 0;
CAN_msg msg_buf =
{
33, // ID
{ 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 }, // Data
1, // Length
1, // Channel
STANDARD_FORMAT, // Format
DATA_FRAME // Type
};
while (1)
{
// Put data (i) into the transmit buffer
// Set DATA FRAME message on controller 1
msg_buf.data[0] = ++i;
CAN_set (1, &msg_buf, 0x0F00);
// Wait 100ms
os_dly_wait (10);
}
}
|