Reading form the bus: threads, buffers?
Posted: Sat 22. Feb 2014, 06:11
I'm trying to figure out the best way to read messages from the bus using PCAN-Basic with a PCAN-USB from C#.
My main concern with the 1-thread event model is loosing messages if my thread is busy with one message when another arrives.
Does the driver have an incoming message queue, and how big is it? Does the event fire to read the next message in the queue when there is one, or just when they actually arrive, regardless of where they might be in the buffer? Or is there just the buffers provided by the CAN Controller (the 64-bit receive FIFO)?
One solution is having many threads, the other is to NOT use events and make sure my read loop is fast enough to not let the buffer fill up.
This may be somewhat academic, as I don't know yet how much time my threads will spend on a message, or even how fast the data could be coming in on the bus, but planning for maximum throughput, that's several thousands of messages per second to process ... Of course I plan on simply interpreting and displaying the data ... skipping the odd message here and there might be OK ...
Thoughts?
Thx
J.F.
My main concern with the 1-thread event model is loosing messages if my thread is busy with one message when another arrives.
Does the driver have an incoming message queue, and how big is it? Does the event fire to read the next message in the queue when there is one, or just when they actually arrive, regardless of where they might be in the buffer? Or is there just the buffers provided by the CAN Controller (the 64-bit receive FIFO)?
One solution is having many threads, the other is to NOT use events and make sure my read loop is fast enough to not let the buffer fill up.
This may be somewhat academic, as I don't know yet how much time my threads will spend on a message, or even how fast the data could be coming in on the bus, but planning for maximum throughput, that's several thousands of messages per second to process ... Of course I plan on simply interpreting and displaying the data ... skipping the odd message here and there might be OK ...
Thoughts?
Thx
J.F.