I have a micro controller that sends data via serial. Regardless of the programming language that will be used to receive data. What's the best way to handle incoming serial data that does not care if you received the data or not.
This will be my 3rd attempt, the first attempt was using VB6 then I switched over to VB.NET and will again be using VB.NET.
This is how it works, I connect a CAN-BUS Transceiver to an Arduino UNO, The transceiver basically eaves drop on flyby data.
I.E
In modern cars you have a CAN-BUS and Device A (Engine ECU) sends data
Speed,
RPM,
Safety belt plugged in or not,
Tyre Pressure,
Distance traveled,
Lights on or off,
Current Gear Selection and a whole bunch more
Device B (Doors which has central locking)
Device B receives and ignore all the data being sent by the ECU because none of the messages are intended for it.
Device C (Instrument cluster)
Receives all data sent by Device A and because the data is meant for it it takes the information and displays it accordingly on the instrument cluster.
A typical CAN-BUS message looks like this.
000,000,000,000,000,000,000,000,000
each bit has a value between 0 and 255 except for the first bit which can range from 000 to 9999
The first bit is the ID of the message.
i.E
The rest of the data is structured in various ways, but for example purposes Device C is structured like this.
The biggest problem is to ensure I don't miss information.
when I monitor the bus with putty it will create a megabyte of text data in no time.
This is what I usually do, I output the serial data using the Arduino in CSV format with a leading < and trailing > like this.
<000,000,000,000,000,000,000,000,000> then send it over serial to my PC.
And I then receive it into a buffer string and by searching for "<" and ">" and at the same time keeping track of the cursor I'm able to track all messages that flew by, Sometimes the buffer fills up and the application crashes, So i discard all data before the cursor.
The problem with the above is its based on the clock speed of the PC CPU, and after adding a whole bunch of features like building a list of ignored IDs and ignoring complete but unwanted messages , updating a grid with incoming messages by first finding it in the grid then update or if it isnt in the list ad a new message, doing all that slows things downwhich also means that I sometimes have to sacrifice messages that flew by for CPU time.
How would you have done the above ?
This will be my 3rd attempt, the first attempt was using VB6 then I switched over to VB.NET and will again be using VB.NET.
This is how it works, I connect a CAN-BUS Transceiver to an Arduino UNO, The transceiver basically eaves drop on flyby data.
I.E
In modern cars you have a CAN-BUS and Device A (Engine ECU) sends data
Speed,
RPM,
Safety belt plugged in or not,
Tyre Pressure,
Distance traveled,
Lights on or off,
Current Gear Selection and a whole bunch more
Device B (Doors which has central locking)
Device B receives and ignore all the data being sent by the ECU because none of the messages are intended for it.
Device C (Instrument cluster)
Receives all data sent by Device A and because the data is meant for it it takes the information and displays it accordingly on the instrument cluster.
A typical CAN-BUS message looks like this.
000,000,000,000,000,000,000,000,000
each bit has a value between 0 and 255 except for the first bit which can range from 000 to 9999
The first bit is the ID of the message.
i.E
HTML:
Device A = 1034
Device B = 1021
Device C = 1044
The rest of the data is structured in various ways, but for example purposes Device C is structured like this.
HTML:
1044,10,0 = Lights OFF
1044,10,1 = Lights ON
1044,11,0 = Safety Belt Not plugged in
1044,11,1 = Safety Belt plugged in
104412,0 = RPM meter position 0
104412,1 = RPM meter position 1
104412,2 = RPM meter position 2
104412,3 = RPM meter position 3
104412,4 = RPM meter position 4 ...... ect ect
The biggest problem is to ensure I don't miss information.
when I monitor the bus with putty it will create a megabyte of text data in no time.
This is what I usually do, I output the serial data using the Arduino in CSV format with a leading < and trailing > like this.
<000,000,000,000,000,000,000,000,000> then send it over serial to my PC.
And I then receive it into a buffer string and by searching for "<" and ">" and at the same time keeping track of the cursor I'm able to track all messages that flew by, Sometimes the buffer fills up and the application crashes, So i discard all data before the cursor.
The problem with the above is its based on the clock speed of the PC CPU, and after adding a whole bunch of features like building a list of ignored IDs and ignoring complete but unwanted messages , updating a grid with incoming messages by first finding it in the grid then update or if it isnt in the list ad a new message, doing all that slows things downwhich also means that I sometimes have to sacrifice messages that flew by for CPU time.
How would you have done the above ?
Last edited:
