Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UsbHostMAX3421E_Hello
parsetools.cpp
00001 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 00017 Contact information 00018 ------------------- 00019 00020 Circuits At Home, LTD 00021 Web : http://www.circuitsathome.com 00022 e-mail : support@circuitsathome.com 00023 */ 00024 #include "Usb.h" 00025 00026 bool MultiByteValueParser::Parse(uint8_t **pp, uint16_t *pcntdn) { 00027 if(!pBuf) { 00028 Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); 00029 return false; 00030 } 00031 for(; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) 00032 pBuf[valueSize - countDown] = (**pp); 00033 00034 if(countDown) 00035 return false; 00036 00037 countDown = valueSize; 00038 return true; 00039 } 00040 00041 bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { 00042 switch(nStage) { 00043 case 0: 00044 pBuf->valueSize = lenSize; 00045 theParser.Initialize(pBuf); 00046 nStage = 1; 00047 00048 case 1: 00049 if(!theParser.Parse(pp, pcntdn)) 00050 return false; 00051 00052 arLen = 0; 00053 arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); 00054 arLenCntdn = arLen; 00055 nStage = 2; 00056 00057 case 2: 00058 pBuf->valueSize = valSize; 00059 theParser.Initialize(pBuf); 00060 nStage = 3; 00061 00062 case 3: 00063 for(; arLenCntdn; arLenCntdn--) { 00064 if(!theParser.Parse(pp, pcntdn)) 00065 return false; 00066 00067 if(pf) 00068 pf(pBuf, (arLen - arLenCntdn), me); 00069 } 00070 00071 nStage = 0; 00072 } 00073 return true; 00074 }
Generated on Tue Jul 12 2022 18:12:04 by
1.7.2