@@ -13,16 +13,18 @@ Arduino library to generate hex dump over Serial (any stream).
1313
1414## Description
1515
16- SHEX is a simple library that wraps the Serial output side (by default) and
16+ ### SHEX
17+
18+ ** SHEX** is a simple library that wraps the Serial output side (by default) and
1719generates an hex dump of all data that is printed. 16 bytes per row.
1820
19- The default output format is
21+ The default output format is (changed since 0.3.0)
2022```
21- 0xABCDABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
22- 0xABCDABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
23- 0xABCDABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
23+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
24+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
25+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
2426
25- 0xABCDABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
27+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
2628```
2729with a separator line after each 8th line.
2830
@@ -35,38 +37,92 @@ This makes it possible to switch between the modes e.g. between 'debugging' and
3537One can toggle the character count at the start of the line.
3638
3739
40+ ### SHEXA
41+
42+ ** SHEXA** (Serial HEX Ascii) is a derived class from ** SHEX** that also
43+ displays a column with printable characters.
44+
45+
46+ The default output format is
47+ ```
48+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx abcdefgh ijklmnop
49+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx abcdefgh ijklmnop
50+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx abcdefgh ijklmnop
51+
52+ ABCD xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
53+ ```
54+
55+ To print this ASCII column extra RAM and code is used.
56+ Therefore this is made a derived class from ** SHEX** .
57+
58+ Furthermore ** SHEXA** has a function ** flushASCII()** to flush the ASCII column to output.
59+ This is might be needed when HEX output is restarted.
60+
61+
3862## Interface
3963
64+ The ** SHEX** and ** SHEXA** share most of their interface.
65+
4066### Defines
4167
4268To be adjusted via command line (or in SHEX.h file)
4369
44- - ** SHEX_DEFAULT_LENGTH 16**
45- - ** SHEX_MAX_LENGTH 32**
70+ - ** SHEX_DEFAULT_LENGTH 16**
71+ - ** SHEX_MAX_LENGTH 32**
72+ - ** SHEX_MIN_LENGTH 4**
73+ - ** SHEX_COUNTER_DIGITS 4**
74+ - ** SHEX_DEFAULT_VTAB 8**
4675
4776
4877### Constructor + Core
4978
50- - ** SHEX(Print \* stream = &Serial, uint8_t length = SHEX_DEFAULT_LENGTH)** Constructor, optional set the number of bytes per line.
79+ - ** SHEX(Print \* stream = &Serial, uint8_t length = SHEX_DEFAULT_LENGTH)** Constructor,
80+ optional set the number of bytes per line.
5181default 16 bytes per line, forced multiple of 4, max SHEX_MAX_LENGTH = 32.
5282- ** size_t write(uint8_t c)** implements the Print interface.
5383
5484
55- ### Modifiers
85+ ### Output Modifiers
5686
5787- ** void setHEX(bool hexOutput = true)** switch between modi, HEX (true) or pass through (false).
5888- ** bool getHEX()** returns mode set above.
59- - ** void setBytesPerLine(uint8_t length = SHEX_DEFAULT_LENGTH)** idem, default 16 bytes per line, forced multiple of 4, max SHEX_MAX_LENGTH = 32.
89+ - ** void setBytesPerLine(uint8_t length = SHEX_DEFAULT_LENGTH)** idem, default 16 bytes per line,
90+ forced multiple of 4, max SHEX_MAX_LENGTH = 32.
6091- ** uint8_t getBytesPerLine()** returns number of bytes per line.
92+
93+
94+ ### Separator
95+
6196- ** void setSeparator(char c = ' ')** set the separator character, default a space.
6297Some people like a dot '.', or a tab '\t'. Feel free to experiment.
6398- ** char getSeparator()** return the separator character set.
64- - ** void setCountFlag(bool flag = true)** show the character count at begin of every line.
65- - ** bool getCountFlag()** return flag set.
99+
100+
101+ ### Counter
102+
103+ - ** void setCountDigits(uint8_t digits)** set the length of the counter, 8 or 6 or 4 (default).
104+ Other numbers will be rounded up to 4, 6 or 8.
105+ - ** uint8_t getCountDigits()** returns idem.
106+ - ** void restartOutput()** restarts the counter from 0 and a new line.
107+ Is automatically called if a setting is modified like ** bytesPerLine**
108+ ** setVTAB** or ** setCountDigits**
109+ - ** uint32_t getCounter()** return internal counter.
110+
111+
112+ ### VTAB
113+
66114- ** void setVTAB(uint8_t vtab = SHEX_DEFAULT_VTAB)** set the vertical separator line.
67115- ** uint8_t getVTAB()** return the current vertical separator line.
68116
69117
118+ ### SHEXA specific
119+
120+ - ** void flushASCII()** allows the user to flush the ASCII column to output.
121+ This is typically used after a setting is changed, which causes a restart of
122+ the HEX output. Best if followed by a ** restartOutput()** .
123+ _ Note: it is not ideal but workable. This might change in the future._
124+
125+
70126## Operational
71127
72128See examples.
@@ -77,19 +133,29 @@ See examples.
77133Although no follow up release is planned, some ideas are kept here
78134so they won't get lost.
79135
80- - Optional ASCII column in the output format ( . if not printable) e.g.
81- ```
82- 0xABCDABCD xx xx xx xx xx xx xx xx xx c.cc c..c
83- ```
84- needs a line buffer to do that (double loop)
136+ ### Must
85137
86- - line buffering for faster output (e.g Ethernet and SD card)
87- could it support ** write(array, length) ** call ?
88- - header line: runtime configurable; optional combined with separator
89- and after how many lines the header should repeat)
90- ** header(str, lines) ** ; ???
91- - HEX reader: converts dump format to a normal stream again.
92- - better name for the class? - streamHex
93- - ** showByteCount(bool) ** is a better name than ** setCountFlag() **
138+ - optimize code
139+ - print vs write
140+ - more testing
141+ - performance measurement
142+ - different platforms.
143+ - different streams incl SW Serial
144+
145+ ### Could
94146
147+ - investigate ** flushASCII()** for better solutions.
148+ - HEX reader: ** RHEX** converts dump format to a normal stream again.
149+ - separate library.
95150
151+ ### Wont
152+
153+ - line buffering for faster output (e.g Ethernet and SD card)
154+ could it support ** write(array, length)** call.
155+ needs quite a rewrite..
156+ Needs a big buffer: ~ 150 bytes. (counter 8 + hex 96 + printable 32 + extra sep)
157+ - header line: runtime configurable;
158+ optional combined with separator
159+ and after how many lines the header should repeat
160+ ** header(str, lines)** ?
161+ Can also be done by just calling Serial.print.
0 commit comments