by DarrenR on Tue Mar 17, 2020 4:56 pm
The Tx buffer is 32 messages long per CAN bus.
The 32 messages is regardless of the number of handles you use.
As soon as the TxMessage function is called the message is put on the queue to transmit as soon as the bus is idle.
So if you were to queue up say 40 messages in one script, with a 1Mbit bus and no competing traffic, you'll see about 38 of the 40 messages as the time it takes to load 38 messages, 6 messages have already been transmitted. But you can't rely on this because traffic from other nodes may keep the bus busy while the M1 is trying to empty it's queue.
If you have a bunch of scripts writing messages at different rates, say 100Hz, 50Hz and 10Hz, remember on the cycle when the 10Hz runs, the 50 and 100Hz has also queued up messages before it so the total number of messages on all cycles will be queued on the slowest event. But it is generally safe to go over the 32 message limit in this case and a lot of other code has had to run between the first queued and the last so often the queue clears enough to have 40 - 50 messages in this case. But it's never guaranteed.
Or the correct way to increase the output is to stagger the messages, so run a script at 200Hz, Tx half of the set on one cycle and the other half on the next cycle. This method could Tx 6400 messages/s without risk of overflowing the buffer, provided the bus is not saturated.
Darren Reynolds
MoTeC Research Centre - Melbourne, Australia.