Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have a block of data that came into a memory buffer from a serial port connected data acquisition device. The data consists of mixed types of data (Characters, HEX data, DECIMAL data, FLAGS, etc. all codded as hex or ASCII hex values) and the only control I have is to ask the device to send over it's data. Or take a configuration I send it.

I am reverse engineering the data fields and don't have them all figured out yet, but it looks like it came from a small micro-controller because there is no memory alignment padding, a data field may start in the high half of byte 341 and go for 6 nibbles (4 bit chunks) and then a new data element starts.

memory address-->
43683031313233343536436832373836323234EF.......

Meaning?
Channel: CH01
value: 123456
Channel: CH02
value: 786224
flag: 0xEF
etc.

Looks like they just dumped a data struct starting at the beginning to the end with no padding (in the devices struct) to align the data.

Is there an easy way to overlay my own struct and get it correctly aligned? Then, I could read the elements from the struct.

I started writing a parser that read the right number of bytes, split them into nibbles as needed and loaded the result into local variables, but there are a lot of them. And, as I said, I don't know what they all represent. I can also change the configuration of the device by writing the data back (with changes) if I have it in exactly the same format and aligned exactly the same. I'll start with just using the values and channel numbers and add to it as I figure out more.

Ideas?

mcb
Posted
Comments
Sergey Alexandrovich Kryukov 17-Mar-12 0:09am    
It's really hard to advise something without seeing how you already do it. Basically, the parsing looks pretty simple (split by lines, split each line into ket-data by delimiters, etc.). The problem is that reverse engineering is something which cannot 100% guarantee the success.
—SA
Philippe Mori 23-Apr-15 20:22pm    
1) You don't tell the language. Assuming that you are using C/C++, then solution 1 might be appropriate if the data has a fixed length and the alignment is at least on a byte boundary.
2) In any case, I would recommand that have a translation layer so that details would be abstracted.
Richard MacCutchan 21-Aug-15 4:05am    
If you do not know the structure of the data that is being presented to you, then there is no way you can write a parser for it. I suggest you contact the manufacturer of the device and ask for their documentation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900