Tool to dump contents of a data buffer in traditional terminal format. Some VT100 color commands used.
Revision 4:c3c8b072f80f, committed 2016-04-27
- Comitter:
- loopsva
- Date:
- Wed Apr 27 22:21:21 2016 +0000
- Parent:
- 3:4a6123f2a4c9
- Commit message:
- added function to display a full 32 bit address
Changed in this revision
PrintBuffer.cpp | Show annotated file Show diff for this revision Revisions of this file |
PrintBuffer.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4a6123f2a4c9 -r c3c8b072f80f PrintBuffer.cpp --- a/PrintBuffer.cpp Thu May 14 16:40:04 2015 +0000 +++ b/PrintBuffer.cpp Wed Apr 27 22:21:21 2016 +0000 @@ -58,6 +58,43 @@ //--------------------------------------------------------------------------------------------------------------------------------------// // Used for doing a hex and ascii dump of the buffer. BufferLines tells PrintBuffer how +// many 16 byte lines to print. Added external ability to add to the buffer base address for display purposes + +int PrintBuffer::dump_a(const char* title, int BufferLines, int BufferOffset, const char buffer[], int addr) { + pc.printf("\n%s%s - lines: %d starting at: 0x%04x%s\r\n", DOMAGENTA, title, BufferLines, BufferOffset + addr, DONONE); + for(int i = BufferOffset; i < BufferLines * 16 + BufferOffset; i = i + 16) { + pc.printf("%04x_%04x ", (i + addr) >> 16, (i + addr) & 0xffff); + for(int s = 0; s < 8; s++) { + pc.printf("%02x ", buffer [s + i]); + } + pc.printf(" "); + for(int s = 0; s < 8; s++) { + pc.printf("%02x ", buffer[s + i + 8]); + } + pc.printf(" "); + for(int s = 0; s < 8; s++) { + if((buffer[s + i] < 0x20) || (buffer[s + i] > 0x7f)) { + pc.printf("%s.%s", DOCYAN, DONONE); + } else { + pc.printf("%c", buffer[s + i]); + } + } + pc.printf(" "); + for(int s = 0; s < 8; s++) { + if((buffer[s + i + 8] < 0x20) || (buffer[s + i + 8] > 0x7f)) { + pc.printf("%s.%s", DOCYAN, DONONE); + } else { + pc.printf("%c", buffer[s + i + 8]); + } + } + pc.printf("\r\n"); + } + pc.printf("\r\n"); + return(0); +} + +//--------------------------------------------------------------------------------------------------------------------------------------// +// Used for doing a hex and ascii dump of the buffer. BufferLines tells PrintBuffer how // many 16 byte lines to print. int PrintBuffer::dump_t(const char* title, int BufferLines, int BufferOffset, const uint8_t buffer[]) {
diff -r 4a6123f2a4c9 -r c3c8b072f80f PrintBuffer.h --- a/PrintBuffer.h Thu May 14 16:40:04 2015 +0000 +++ b/PrintBuffer.h Wed Apr 27 22:21:21 2016 +0000 @@ -61,27 +61,37 @@ class PrintBuffer { public: + /** Create a PrintBuffer object with a name attached * * @param constructor, - for PrintBuffer */ PrintBuffer(const char* name); - /** Print out hex / ascii data using pc.printf using format above + + /** Print out hex / ascii data using pc.printf using format below * * @param three, (int # of lines to print), (int starting address), (c c name of buffer to print) */ int dump(const char* title, int BufferLines, int BufferOffset, const char buffer[]); - /** Print out hex / ascii data using pc.printf using format above + + /** Print out hex / ascii data using pc.printf using format below * * @param three, (int # of lines to print), (int starting address), (c u8_t name of buffer to print) */ int dump_t(const char* title, int BufferLines, int BufferOffset, const uint8_t buffer[]); - /** Print out hex / ascii data using pc.printf using format above + + /** Print out hex / ascii data using pc.printf using format below * * @param three, (int # of lines to print), (int starting address), (c unsigned char name of buffer to print) */ int dump_uc(const char* title, int BufferLines, int BufferOffset, const unsigned char buffer[]); + /** Print out hex / ascii data using pc.printf using format below + * + * @param four, (int # of lines to print), (int starting address), (c unsigned char name of buffer to print), (int starting address) + */ + int dump_a(const char* title, int BufferLines, int BufferOffset, const char buffer[], int addr); + private: int BufferLines;