CAN Bus data array processing

Firstly, I apologise about the long winded query here.

I’ve tried to explain as clearly as possible, in as much detail as possible, to try to help anyone understand the problem I’m stuck on. I should add I’ve tried to dig for ages for a suitable function to help me in 'C' but without resorting to parsing by looping on iterations of arrays, it seems no function(s) exist in ‘C’ to get the job done more elegantly?

Anyway, I have a script which, when complete, will allow me to send specific integer value data, via a serial signal, to a dot matrix display.

I’m able to send the raw HEX data from an array/buffer to a dot matrix display using the script as it is. I also have the dot matrix script working well too so it displays the whole array of HEX data well. However, I want to ‘refine’ the data by not only changing the data types in an array or buffer (named ‘tempBuffer’) from HEX to INT (or whatever is appropriate) but to also specifically select three items of data from their respective index positions in that eight item array/buffer (tempBuffer).

The problem looks like this:-

tempBuffer {0x4 0x41 0xC 0xB 0x90 0x0 0x0 0x0} // Raw hex data in array (buffer) - index positions 0 through 7.

I would like to select index positions [2], [3] and [4] in the above 'tempBuffer' array and then place them consecutively into another array pending further processing (i.e. eventually adding item [3] and [4] together to produce one INT value representing a temperature, for example).

For example:

tempBuffer index item [2] would then be placed as Index item [0] in a new array, ‘newArray’ . tempBuffer Items [3] & [4] would obviously become items [1] & [2] in ‘newArray’.

I plan to use 'newArray' index item [0] as a condition check, for example, an ‘if’ or ‘case’ statement etc. The outcome of the clause would determine what happens next to the subsequent index items in [1] & [2]. It won’t always be necessary to use item [2] for data checking of a certain condition if item [0] is not met.

I could use a messy ‘C’ loop/parsing iteration to extract the values I need from 'tempBuffer' and place them in 'newArray'. However, I wondered if there is a more elegant or existing function set existing in ‘C’ which will allow me to get the job done more efficiently?

My query also applies I guess to possible function solutions in ‘C’ to add the index values [1] and [2] together in 'newArray' but if anyone can point me to a pre-existing function or an efficient means to iterate the arrays from above I should be grateful for any guidance, advice or pointers to further reading. Else, (excuse the pun) its back to using unwieldy looping and iteration in ‘C’ statements to achieve the same outcome.

Thank you, Ryme

In the unlikely event anyone is following my original posting . . .

I've managed to resolve my query and now have an adapted script running the way I want it to.

My adapted and integrated script now achieves the following:-

  1. Read and *display (static, scroll, reverse & invert) Ford **ECU PID data (500Kb/11bit) relating to Vehicle Speed and RPM to a 10 x (8x8) LED Matrix display strip.

  2. ***Parse NEMA sentences to display on said matrix altitude and time-of-day data.

• I plan to change to Mikal Hart's TinyGPS++ libraries soon and adapt the script further to make it more efficient.

• I also plan to present a YouTube tutorial about my project.

*Thank you to Marco Colli (MajicDesigns) Parola libraries.
**Thank you to Seeed Studio's example script, OBDII_PIDs, as a base starting point.
*** Thank you to "ludektalian" for further inspiration.

Thank you,

Ryme.