GY-63_MS5611/libraries/SHEX
2021-12-28 11:19:54 +01:00
..
.github/workflows 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
examples 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
test 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
.arduino-ci.yml 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
keywords.txt 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
library.json 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
library.properties 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
LICENSE 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
README.md 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
SHEX.cpp 0.2.1 SHEX 2021-12-28 11:19:54 +01:00
SHEX.h 0.2.1 SHEX 2021-12-28 11:19:54 +01:00

Arduino CI Arduino-lint JSON check License: MIT GitHub release

SHEX

Arduino library to generate hex dump over Serial (any stream).

Description

SHEX is a simple library that wraps the Serial output side (by default) and generates an hex dump of all data that is printed. 16 bytes per row.

The default output format is

0xABCDABCD  xx xx xx xx  xx xx xx xx  xx xx xx xx  xx xx xx xx
0xABCDABCD  xx xx xx xx  xx xx xx xx  xx xx xx xx  xx xx xx xx
0xABCDABCD  xx xx xx xx  xx xx xx xx  xx xx xx xx  xx xx xx xx

0xABCDABCD  xx xx xx xx  xx xx xx xx  xx xx xx xx  xx xx xx xx 

with a separator line after each 8th line.

The constructor has a length parameter which can be used to have another number of bytes per row. This can be changed with setBytesPerLine().

One can toggle is HEX output or pass through by means of setHEX(bool). This makes it possible to switch between the modes e.g. between 'debugging' and 'release' mode.

One can toggle the character count at the start of the line.

Interface

Constructor + Core

  • SHEX(Print * stream = &Serial, uint8_t length = 16) Constructor, optional set the number of bytes per line. default 16 bytes per line, forced multiple of 4, max 32.
  • size_t write(uint8_t c) implements the Print interface.

Modifiers

  • void setHEX(bool hexOutput = true) switch between modi, HEX (true) or pass through (false).
  • bool getHEX() returns mode set above.
  • void setBytesPerLine(uint8_t length = 16) idem, default 16 bytes per line, forced multiple of 4, max 32.
  • uint8_t getBytesPerLine() returns number of bytes per line.
  • void setSeparator(char c = ' ') set the separator character, default a space. Some people like a dot '.', or a tab '\t'. Feel free to experiment.
  • char getSeparator() return the separator character set.
  • void setCountFlag(bool flag = true) show the character count at begin of every line.
  • bool getCountFlag() return flag set.

Operational

See examples.

Future

Although no follow up release is planned, some ideas are kept here so they won't get lost.

  • Optional ASCII column in the output format ( . if not printable) e.g.
        0xABCDABCD  xx xx xx xx xx xx xx xx xx    c.cc c..c

needs a line buffer to do that (double loop)

  • line buffering for faster output (e.g Ethernet and SD card)
  • header line: runtime configurable; optional combined with separator and after how many lines the header should repeat) header(str, lines); ???
  • HEX reader: converts dump format to a normal stream again.
  • better name for the class? - streamHex
  • showByteCount(bool) is a better name.