I work a lot with serial communication with various devices, so I often have to analyze hex dumps in the log files. I am currently doing this manually, looking at the dumps, looking at the protocol specification and recording the results. However, it is tedious and error prone, especially whem messages contain hundreds of bytes and contain mixtures of large and small numbers, ASCII, Unicode, compression, CRC.,.
I wrote some Python scripts to help with more common cases. But there are many protocols that you have to deal with, and it makes no sense to waste time creating a custom script if I don't know that I will have many dumps for analysis.
What I would like is some kind of utility that can automate this activity. So, for example, if I have a text hex dump, for example:
7e ff 00 7b 00 13 86 04
00 41 42 43 44 56 ef 7e
and some description of the message format, for example:
Flag 1 hex
Address 1 hex
Control 1 hex
DataType 1 decimal
LineIndex 1 decimal
PollAddress 2 msb hex
DataSize 2 lsb decimal
Data (DataSize) ascii
CRC 2 lsb hex
Flag 1 hex
I would get the output as follows:
Flag 0x7e
Address 0xff
Control 0x00
DataType 123
LineIndex 0
PollAddress 0x1386
DataSize 4
Data "ABCD"
CRC 0xef56
Flag 0x7e
Hardware protocol analyzers often have fancy features for these kinds of things, but I need to work with text log files.
Is there such a utility or library?
Some good answers have come about since I created generosity. I think generosity works!
Wireshark and HexEdit look promising; I will look at them and quickly reward generosity depending on what suits me. But I'm still open to other ideas.