source: rtos_arduino/trunk/arduino_lib/libraries/USBHost/src/parsetools.cpp@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.6 KB
Line 
1/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3This software may be distributed and modified under the terms of the GNU
4General Public License version 2 (GPL2) as published by the Free Software
5Foundation and appearing in the file GPL2.TXT included in the packaging of
6this file. Please note that GPL2 Section 2[b] requires that all works based
7on this software must also be made publicly available under the terms of
8the GPL2 ("Copyleft").
9
10Contact information
11-------------------
12
13Circuits At Home, LTD
14Web : http://www.circuitsathome.com
15e-mail : support@circuitsathome.com
16*/
17
18#include "parsetools.h"
19
20bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn)
21{
22 if (!pBuf)
23 {
24 //Notify(PSTR("Buffer pointer is NULL!\r\n"));
25 return false;
26 }
27 for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++)
28 pBuf[valueSize-countDown] = (**pp);
29
30 if (countDown)
31 return false;
32
33 countDown = valueSize;
34 return true;
35}
36
37bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me)
38{
39 switch (nStage)
40 {
41 case 0:
42 pBuf->valueSize = lenSize;
43 theParser.Initialize(pBuf);
44 nStage = 1;
45
46 case 1:
47 if (!theParser.Parse(pp, pcntdn))
48 return false;
49
50 arLen = 0;
51 arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue));
52 arLenCntdn = arLen;
53 nStage = 2;
54
55 case 2:
56 pBuf->valueSize = valSize;
57 theParser.Initialize(pBuf);
58 nStage = 3;
59
60 case 3:
61 for (; arLenCntdn; arLenCntdn--)
62 {
63 if (!theParser.Parse(pp, pcntdn))
64 return false;
65
66 if (pf)
67 pf(pBuf, (arLen - arLenCntdn), me);
68 }
69
70 nStage = 0;
71 }
72 return true;
73}
Note: See TracBrowser for help on using the repository browser.