I previously have blogged about the TkbmMWBinaryParser which use special defined definition files for parsing binary data. (Check this blog)

This is a short blog about a new feature, included in kbmMW Enterprise Edition which makes it simple to visualizing the definition file and the data to be parsed.

You will find the demos in kbmMW to have been updated, to include the binary parser visualizer, and showing how to step thru data, while visualizing what fails and what succeeds during the parse.

A picture is worth many words… so here goes. This is a screenshot of the included demo:

The visualizer is in the center. It shows optionally the data being parsed (in magenta) followed by the definition (everything else).

Specific bit definitions are shown in blue, tags and subtags are in green, and constant bitmasks/values are in black.

When parsing non matching data, it is showing failed parts as red. This way its easy to see what match and what doesn’t according to the given definition.

The definition for the above visualization is shown in the end of this blog for the curious.

kbmMW also includes a couple of readers which makes reading files and streams easy. For example TkbmMWBPFileReader.

The simple setup is:

The Options property of the visualizer controls what you want to see:

TkbmMWBPVisalizerOption = (mwbpvoShowData,mwbpvoShowOnlyTouched,mwbpvoShowOnlyTouchedData);

  • mwbpvoShowData – Hexdump of the data is visualized.
  • mwbpvoShowOnlyTouched – Only show parts of the definition which was “touched”. As the parser is a short circuit parser, it will immediately give up parsing the moment something does not match the definition file. Everything matching until that point is “touched”.
  • mwbpvoShowOnlyTouchedData – Only show data which was valid or “touched”.

 

The definition for the above visualization is typically stored in YAML format, but could just as well be stored in JSON, XML or one of the binary formats supported by kbmMW’s object notation framework. YAML just makes it a cleaner read for humans imo.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *