1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
17 #if !defined(_usb_h_) || defined(__HEXDUMP_H__)
18 #error "Never include hexdump.h directly; include Usb.h instead"
22 extern int UsbDEBUGlvl;
24 template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
25 class HexDumper : public BASE_CLASS {
27 OFFSET_TYPE byteTotal;
31 HexDumper() : byteCount(0), byteTotal(0) {
39 void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset);
42 template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
43 void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
44 if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
45 for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
47 PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
48 E_Notify(PSTR(": "), 0x80);
50 PrintHex<uint8_t > (pbuf[j], 0x80);
51 E_Notify(PSTR(" "), 0x80);
54 E_Notify(PSTR("\r\n"), 0x80);
61 #endif // __HEXDUMP_H__