Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
#ifndef __DEVPROPPARSER_H__
2
#define __DEVPROPPARSER_H__
3
 
4
#include <inttypes.h>
5
#include <avr/pgmspace.h>
6
#include <../ptp/ptpconst.h>
7
#include <../ptp/ptp.h>
8
 
9
// Device properties
10
const char msgUndefined                                 [] PROGMEM = "Undefined";                      
11
const char msgBatteryLevel                              [] PROGMEM = "BatteryLevel";                           
12
const char msgFunctionalMode                    [] PROGMEM = "FunctionalMode";                         
13
const char msgImageSize                                 [] PROGMEM = "ImageSize";                                      
14
const char msgCompressionSetting                [] PROGMEM = "CompressionSetting";                     
15
const char msgWhiteBalance                              [] PROGMEM = "WhiteBalance";                           
16
const char msgRGBGain                                   [] PROGMEM = "RGBGain";                                        
17
const char msgFNumber                                   [] PROGMEM = "FNumber";                                        
18
const char msgFocalLength                               [] PROGMEM = "FocalLength";                                    
19
const char msgFocusDistance                             [] PROGMEM = "FocusDistance";                          
20
const char msgFocusMode                                 [] PROGMEM = "FocusMode";                                      
21
const char msgExposureMeteringMode              [] PROGMEM = "ExposureMeteringMode";           
22
const char msgFlashMode                                 [] PROGMEM = "FlashMode";                                      
23
const char msgExposureTime                              [] PROGMEM = "ExposureTime";                           
24
const char msgExposureProgramMode               [] PROGMEM = "ExposureProgramMode";                    
25
const char msgExposureIndex                             [] PROGMEM = "ExposureIndex";                          
26
const char msgExposureBiasCompensation  [] PROGMEM = "ExposureBiasCompensation";       
27
const char msgDateTime                                  [] PROGMEM = "DateTime";                                       
28
const char msgCaptureDelay                              [] PROGMEM = "CaptureDelay";                           
29
const char msgStillCaptureMode                  [] PROGMEM = "StillCaptureMode";                       
30
const char msgContrast                                  [] PROGMEM = "Contrast";                                       
31
const char msgSharpness                                 [] PROGMEM = "Sharpness";                                      
32
const char msgDigitalZoom                               [] PROGMEM = "DigitalZoom";                                    
33
const char msgEffectMode                                [] PROGMEM = "EffectMode";                                     
34
const char msgBurstNumber                               [] PROGMEM = "BurstNumber";                                    
35
const char msgBurstInterval                             [] PROGMEM = "BurstInterval";                          
36
const char msgTimelapseNumber                   [] PROGMEM = "TimelapseNumber";                        
37
const char msgTimelapseInterval                 [] PROGMEM = "TimelapseInterval";                      
38
const char msgFocusMeteringMode                 [] PROGMEM = "FocusMeteringMode";                      
39
const char msgUploadURL                                 [] PROGMEM = "UploadURL";                                      
40
const char msgArtist                                    [] PROGMEM = "Artist";                                 
41
const char msgCopyrightInfo                             [] PROGMEM = "CopyrightInfo";                          
42
 
43
// Data Types
44
const char msgUNDEF             [] PROGMEM = "UNDEF";
45
const char msgINT8              [] PROGMEM = "INT8";
46
const char msgUINT8             [] PROGMEM = "UINT8";
47
const char msgINT16             [] PROGMEM = "INT16";
48
const char msgUINT16    [] PROGMEM = "UINT16";
49
const char msgINT32             [] PROGMEM = "INT32";
50
const char msgUINT32    [] PROGMEM = "UINT32";
51
const char msgINT64             [] PROGMEM = "INT64";
52
const char msgUINT64    [] PROGMEM = "UINT64";
53
const char msgINT128    [] PROGMEM = "INT128";
54
const char msgUINT128   [] PROGMEM = "UINT128";
55
const char msgAINT8             [] PROGMEM = "AINT8";
56
const char msgAUINT8    [] PROGMEM = "AUINT8";
57
const char msgAINT16    [] PROGMEM = "AINT16";
58
const char msgAUINT16   [] PROGMEM = "AUINT16";
59
const char msgAINT32    [] PROGMEM = "AINT32";
60
const char msgAUINT32   [] PROGMEM = "AUINT32";
61
const char msgAINT64    [] PROGMEM = "AINT64";
62
const char msgAUINT64   [] PROGMEM = "AUINT64";
63
const char msgAINT128   [] PROGMEM = "AINT128";
64
const char msgAUINT128  [] PROGMEM = "AUINT128";
65
const char msgSTR       [] PROGMEM = "STR";
66
 
67
 
68
class DevPropParser : public PTPReadParser
69
{
70
        static const char* dtNames1[];
71
        static const char* dtNames2[];
72
        static const char* prNames[];
73
 
74
        uint8_t                         nStage;
75
        uint8_t                         enStage;
76
        uint16_t                        dataType;
77
        uint8_t                         formFlag;
78
        uint8_t                         bytesSize;
79
        MultiValueBuffer                theBuffer;
80
        uint8_t                         varBuffer[16];
81
        uint16_t                        enLen;
82
        uint16_t                        enLenCntdn;
83
 
84
        MultiByteValueParser            valParser;
85
 
86
        void PrintDevProp       (uint8_t **pp, uint16_t *pcntdn);
87
        void PrintDataType      (uint8_t **pp, uint16_t *pcntdn);
88
        void PrintGetSet        (uint8_t **pp, uint16_t *pcntdn);
89
        bool PrintValue         (uint8_t **pp, uint16_t *pcntdn);      
90
        bool PrintEnum          (uint8_t **pp, uint16_t *pcntdn);      
91
        bool ParseEnum          (uint8_t **pp, uint16_t *pcntdn);      
92
        bool ParseEnumSingle    (uint8_t **pp, uint16_t *pcntdn);      
93
        bool ParseEnumArray     (uint8_t **pp, uint16_t *pcntdn);      
94
 
95
        static void PrintChar(const MultiValueBuffer * const p, uint32_t count, const void *me)
96
        {
97
                if (((unsigned char*)p->pValue)[0])
98
                        Serial.print(((unsigned char*)p->pValue)[0]);
99
        };
100
        static void PrintByte(const MultiValueBuffer * const p, uint32_t count, const void *me)
101
        {
102
                if (count)
103
                        Notify(PSTR(","));
104
                PrintHex<uint8_t>(((uint8_t*)p->pValue)[0]);
105
        };
106
        static void PrintTwoBytes(const MultiValueBuffer * const p, uint32_t count, const void *me)
107
        {
108
                if (count)
109
                        Notify(PSTR(","));
110
                PrintHex<uint16_t>(((uint16_t*)p->pValue)[0]);
111
        };
112
        static void PrintFourBytes(const MultiValueBuffer * const p, uint32_t count, const void *me)
113
        {
114
                if (count)
115
                        Notify(PSTR(","));
116
                PrintHex<uint32_t>(((uint32_t*)p->pValue)[0]);
117
        };
118
        static void PrintEightBytes(const MultiValueBuffer * const p, uint32_t count, const void *me)
119
        {
120
                if (count)
121
                        Notify(PSTR(","));
122
                for (uint8_t i=p->valueSize; i; i--)
123
                    PrintHex<uint8_t>(((uint8_t*)p->pValue)[i-1]);
124
        };
125
        static void PrintEnumValue(const MultiValueBuffer * const p, uint32_t count, const void *me)
126
        {
127
            if (count)
128
                Serial.print(", ");
129
 
130
            switch (((MultiValueBuffer*)p)->valueSize)
131
            {
132
            case 1:
133
                PrintHex<uint8_t>(*((uint8_t*)p->pValue));
134
                break;
135
            case 2:  
136
                PrintHex<uint16_t>(*((uint16_t*)p->pValue));
137
                break;
138
            case 4:  
139
                PrintHex<uint32_t>(*((uint32_t*)p->pValue));
140
                break;
141
            default:
142
                for (uint8_t i=p->valueSize; i; i--)
143
                    PrintHex<uint8_t>(((uint8_t*)p->pValue)[i-1]);
144
            }
145
            count++;
146
        };
147
 
148
        PTPListParser      enumParser;
149
 
150
        uint8_t GetDataSize();
151
 
152
public:
153
        DevPropParser() :
154
                nStage(0),
155
                enStage(0),
156
                dataType(0),
157
                formFlag(0),
158
                bytesSize(0),
159
                enLen(0),
160
                enLenCntdn(0)
161
        {
162
                theBuffer.pValue = varBuffer;
163
        }
164
        virtual void Parse(const uint16_t len, const uint8_t * const pbuf, const uint32_t &offset);
165
};
166
 
167
#endif // __DEVPROPPARSER_H__