Any general utilities or libraries for converting hex dumps to human-readable form?

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:

# Field         Size        Byte Order  Output Format
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.

+5
source share
10
+2

, . hexedit. , , , , . , . , . HexEdit google ; .

+2

, emacs hexl-mode " ". , , ++.

+1

. , , , . , , , . , , . . , , . , , , , . , , . , , , . .

+1
+1

Tcl . . Tcl . , , , , .

bash$ tclsh
% binary scan [binary format H* 7eff007b00138604004142434456ef7e] \
  H2H2H2ccH4sa4h4H2 \
  flag1 addr ctl datatype lineidx polladdr datasize data crc flag2
10
% puts "$flag1 $addr $ctl $datatype $lineidx \
  $polladdr $datasize $data $crc $flag2"
7e ff 00 123 0 1386 4 ABCD 65fe 7e

-, , , , . , .

+1

hexworkshop

, . Viewer, a C/++, .

+1

, - CPAN. , .: -)

: , , Parse:: Binary:: FixedFormat

0

There is a BSD command line utility called hexdumpthat does this using format strings (which may be in an external file). See https://www.suse.com/communities/blog/making-sense-hexdump/ for input and, for example, https://www.freebsd.org/cgi/man.cgi?query=hexdump&sektion=1 for manual pages (with particular attention to the parameters -eand -fand under the heading Format ).

0
source

All Articles