Description
set_send_interval() – sets the CAN send interval [ms] of the CAN2SER instance. Senders on a CAN bus have to limit their occupation of the can bus (aka ‘babbling idiots’). This is necessary so that the can-bus won’t get blocked in case larger amounts of data should be transferred. By default the min. time between two messages (the send interval) is 1ms.
Syntax
myExampleSerial.set_send_interval( u8_interval );
Parameters
uint8_t u8_interval– minimum time interval between CAN messages while sending in [ms]
Returns
nothing
Example Code
The following example constantly changes the send-interval while sending text to the can2ser monitor.
void setup()
{
// Wait for the PC can2ser-monitor to send handshakes
while(!Serial) {;}
Serial.println("Welcome to the set_send_interval() example");
}
uint8_t u8_interval = 0;
void loop ()
{
for(int i=0; i < 100; i++)
Serial.println("send interval "+String(u8_interval));
delay(1000);
u8_interval = u8_interval + 8;
Serial.set_send_interval(u8_interval);
}
The time between the messages can be observed on the CAN bus (e.g. peak can monitor) and by the time that it takes to transfer the text.
Notes and Warnings
The send-interval ensures sufficient time on the bus for all devices on the CAN to send their data.