Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
2
 
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
8
the GPL2 ("Copyleft").
9
 
10
Contact information
11
-------------------
12
 
13
Circuits At Home, LTD
14
Web      :  http://www.circuitsathome.com
15
e-mail   :  support@circuitsathome.com
16
*/
17
#ifndef __PTPDEBUG_H__
18
#define __PTPDEBUG_H__
19
 
20
#include <inttypes.h>
21
#include <avr/pgmspace.h>
22
#include "ptpcallback.h"
23
 
24
void Notify(const char* msg);
25
void Message(const char* msg, uint16_t rcode);
26
 
27
template <class T>
28
void PrintHex(T val)
29
{
30
    T    mask = (((T)1) << (((sizeof(T) << 1) - 1) << 2));
31
 
32
    while (mask > 1)
33
    {
34
                if (val < mask)
35
                  Serial.print("0");
36
 
37
                mask >>= 4;
38
    }
39
    Serial.print((T)val, HEX);
40
}
41
 
42
template <class T>
43
void PrintHex2(Print *prn, T val)
44
{
45
    T    mask = (((T)1) << (((sizeof(T) << 1) - 1) << 2));
46
 
47
    while (mask > 1)
48
    {
49
                if (val < mask)
50
                  prn->print("0");
51
 
52
                mask >>= 4;
53
    }
54
    prn->print((T)val, HEX);
55
}
56
 
57
class HexDump : public PTPReadParser
58
{
59
        uint8_t         byteCount;
60
        uint16_t    byteTotal;
61
 
62
public:
63
        HexDump() : byteCount(0), byteTotal(0) {};
64
        void Initialize() { byteCount = 0; byteTotal = 0; };
65
        virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset);
66
};
67
 
68
#include "ptpcallback.h"
69
 
70
class EOSEventDump : public PTPReadParser
71
{
72
        uint32_t        ptppktSize;
73
        uint16_t        recordSize;
74
        uint8_t         parseStage;
75
        uint8_t         parseSubstage;
76
 
77
        MultiByteValueParser    valueParser;
78
        MultiValueBuffer                valueBuffer;
79
        uint32_t                                theBuffer;
80
public:
81
        EOSEventDump() : ptppktSize(0), recordSize(0), parseStage(0), parseSubstage(0)
82
                { valueBuffer.valueSize = 4; valueBuffer.pValue = &theBuffer; };
83
        void Initialize() { ptppktSize = 0; recordSize = 0; parseStage = 0; valueParser.Initialize(&valueBuffer); };
84
        virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset);
85
};
86
#endif // __PTPDEBUG_H__