USB Host Shield 2.0
Loading...
Searching...
No Matches
hexdump.h
Go to the documentation of this file.
1
/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; either version 2 of the License, or
6
(at your option) any later version.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17
Contact information
18
-------------------
19
20
Circuits At Home, LTD
21
Web : http://www.circuitsathome.com
22
e-mail : support@circuitsathome.com
23
*/
24
25
#if !defined(_usb_h_) || defined(__HEXDUMP_H__)
26
#error "Never include hexdump.h directly; include Usb.h instead"
27
#else
28
#define __HEXDUMP_H__
29
30
extern
int
UsbDEBUGlvl
;
31
32
template
<
class
BASE_CLASS,
class
LEN_TYPE,
class
OFFSET_TYPE>
33
class
HexDumper
:
public
BASE_CLASS {
34
uint8_t
byteCount;
35
OFFSET_TYPE
byteTotal;
36
37
public
:
38
39
HexDumper
() : byteCount(0), byteTotal(0) {
40
};
41
42
void
Initialize
() {
43
byteCount = 0;
44
byteTotal = 0;
45
};
46
47
void
Parse
(
const
LEN_TYPE
len
,
const
uint8_t
*
pbuf
,
const
OFFSET_TYPE
&
offset
);
48
};
49
50
template
<
class
BASE_CLASS,
class
LEN_TYPE,
class
OFFSET_TYPE>
51
void
HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse
(
const
LEN_TYPE
len
,
const
uint8_t
*
pbuf
,
const
OFFSET_TYPE
&
offset
__attribute__
((unused))) {
52
if
(
UsbDEBUGlvl
>= 0x80) {
// Fully bypass this block of code if we do not debug.
53
for
(
LEN_TYPE
j
= 0;
j
<
len
;
j
++, byteCount++, byteTotal++) {
54
if
(!byteCount) {
55
PrintHex<OFFSET_TYPE >
(byteTotal, 0x80);
56
E_Notify
(
PSTR
(
": "
), 0x80);
57
}
58
PrintHex<uint8_t >
(
pbuf
[
j
], 0x80);
59
E_Notify
(
PSTR
(
" "
), 0x80);
60
61
if
(byteCount == 15) {
62
E_Notify
(
PSTR
(
"\r\n"
), 0x80);
63
byteCount = 0xFF;
64
}
65
}
66
}
67
}
68
69
#endif
// __HEXDUMP_H__
ConfigDescParser
Definition
confdescparser.h:47
HexDumper
Definition
hexdump.h:33
HexDumper::HexDumper
HexDumper()
Definition
hexdump.h:39
HexDumper::Parse
void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset)
Definition
hexdump.h:51
HexDumper::Initialize
void Initialize()
Definition
hexdump.h:42
UsbDEBUGlvl
int UsbDEBUGlvl
Definition
message.cpp:29
E_Notify
void E_Notify(char const *msg, int lvl)
Definition
message.cpp:41
PSTR
#define PSTR(str)
Definition
version_helper.h:54
Generated by
1.9.8