fix tab/space mixtures -- whitespace only change
This commit is contained in:
parent
00dd2e0097
commit
a2801a1602
4 changed files with 121 additions and 123 deletions
|
|
@ -19,6 +19,8 @@ e-mail : support@circuitsathome.com
|
|||
#error "Never include confdescparser.h directly; include Usb.h instead"
|
||||
#else
|
||||
|
||||
|
||||
|
||||
#pragma GCC diagnostic push // Available since GCC 4.6.4
|
||||
/*
|
||||
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
|
||||
|
|
@ -70,15 +72,15 @@ class ConfigDescParser : public USBReadParser {
|
|||
uint32_t ifaceNumber; // Interface number
|
||||
uint32_t ifaceAltSet; // Interface alternate settings
|
||||
|
||||
bool UseOr;
|
||||
bool UseOr;
|
||||
bool ParseDescriptor(uint8_t **pp, uint32_t *pcntdn);
|
||||
void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc);
|
||||
|
||||
public:
|
||||
|
||||
void SetOR(void) {
|
||||
UseOr = true;
|
||||
}
|
||||
void SetOR(void) {
|
||||
UseOr = true;
|
||||
}
|
||||
ConfigDescParser(UsbConfigXtracter *xtractor);
|
||||
virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset);
|
||||
};
|
||||
|
|
@ -109,8 +111,8 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::Parse(const uin
|
|||
compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */
|
||||
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
|
||||
bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) {
|
||||
USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
|
||||
USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
|
||||
USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
|
||||
USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
|
||||
switch(stateParseDescr) {
|
||||
case 0:
|
||||
theBuffer.valueSize = 2;
|
||||
|
|
@ -123,7 +125,7 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
|||
dscrType = *((uint8_t*)theBuffer.pValue + 1);
|
||||
stateParseDescr = 2;
|
||||
case 2:
|
||||
// This is a sort of hack. Assuming that two bytes are all ready in the buffer
|
||||
// This is a sort of hack. Assuming that two bytes are all ready in the buffer
|
||||
// the pointer is positioned two bytes ahead in order for the rest of descriptor
|
||||
// to be read right after the size and the type fields.
|
||||
// This should be used carefully. varBuffer should be used directly to handle data
|
||||
|
|
@ -131,14 +133,14 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
|||
theBuffer.pValue = varBuffer + 2;
|
||||
stateParseDescr = 3;
|
||||
case 3:
|
||||
switch(dscrType) {
|
||||
case USB_DESCRIPTOR_INTERFACE:
|
||||
isGoodInterface = false;
|
||||
case USB_DESCRIPTOR_CONFIGURATION:
|
||||
theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2;
|
||||
break;
|
||||
case USB_DESCRIPTOR_ENDPOINT:
|
||||
theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2;
|
||||
switch(dscrType) {
|
||||
case USB_DESCRIPTOR_INTERFACE:
|
||||
isGoodInterface = false;
|
||||
case USB_DESCRIPTOR_CONFIGURATION:
|
||||
theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2;
|
||||
break;
|
||||
case USB_DESCRIPTOR_ENDPOINT:
|
||||
theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2;
|
||||
break;
|
||||
case HID_DESCRIPTOR_HID:
|
||||
theBuffer.valueSize = dscrLen - 2;
|
||||
|
|
@ -147,37 +149,37 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
|||
valParser.Initialize(&theBuffer);
|
||||
stateParseDescr = 4;
|
||||
case 4:
|
||||
switch(dscrType) {
|
||||
switch(dscrType) {
|
||||
case USB_DESCRIPTOR_CONFIGURATION:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
confValue = ucd->bConfigurationValue;
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
confValue = ucd->bConfigurationValue;
|
||||
break;
|
||||
case USB_DESCRIPTOR_INTERFACE:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID)
|
||||
break;
|
||||
if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID)
|
||||
break;
|
||||
if(UseOr) {
|
||||
if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol)))
|
||||
break;
|
||||
} else {
|
||||
if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID)
|
||||
break;
|
||||
}
|
||||
isGoodInterface = true;
|
||||
ifaceNumber = uid->bInterfaceNumber;
|
||||
ifaceAltSet = uid->bAlternateSetting;
|
||||
protoValue = uid->bInterfaceProtocol;
|
||||
break;
|
||||
case USB_DESCRIPTOR_ENDPOINT:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
if(isGoodInterface)
|
||||
if(theXtractor)
|
||||
theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID)
|
||||
break;
|
||||
if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID)
|
||||
break;
|
||||
if(UseOr) {
|
||||
if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol)))
|
||||
break;
|
||||
} else {
|
||||
if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID)
|
||||
break;
|
||||
}
|
||||
isGoodInterface = true;
|
||||
ifaceNumber = uid->bInterfaceNumber;
|
||||
ifaceAltSet = uid->bAlternateSetting;
|
||||
protoValue = uid->bInterfaceProtocol;
|
||||
break;
|
||||
case USB_DESCRIPTOR_ENDPOINT:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
if(isGoodInterface)
|
||||
if(theXtractor)
|
||||
theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
|
||||
break;
|
||||
//case HID_DESCRIPTOR_HID:
|
||||
// if (!valParser.Parse(pp, pcntdn))
|
||||
|
|
@ -196,38 +198,38 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
|||
|
||||
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
|
||||
void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
|
||||
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
|
||||
Notify(PSTR("bDescLength:\t\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bLength, 0x80);
|
||||
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
|
||||
Notify(PSTR("bDescLength:\t\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bLength, 0x80);
|
||||
|
||||
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
|
||||
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
|
||||
|
||||
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
|
||||
PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
|
||||
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
|
||||
PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
|
||||
|
||||
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
|
||||
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
|
||||
|
||||
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
||||
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
||||
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
||||
|
||||
//Notify(PSTR("\r\nbDescrType:\t\t"));
|
||||
//PrintHex<uint8_t>(pDesc->bDescrType);
|
||||
//
|
||||
//Notify(PSTR("\r\nwDescriptorLength:\t"));
|
||||
//PrintHex<uint16_t>(pDesc->wDescriptorLength);
|
||||
//Notify(PSTR("\r\nbDescrType:\t\t"));
|
||||
//PrintHex<uint8_t>(pDesc->bDescrType);
|
||||
//
|
||||
//Notify(PSTR("\r\nwDescriptorLength:\t"));
|
||||
//PrintHex<uint16_t>(pDesc->wDescriptorLength);
|
||||
|
||||
for (uint32_t i = 0; i < pDesc->bNumDescriptors; i++) {
|
||||
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
|
||||
|
||||
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
|
||||
PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
|
||||
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
|
||||
PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
|
||||
|
||||
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
|
||||
PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
|
||||
}
|
||||
Notify(PSTR("\r\n"), 0x80);
|
||||
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
|
||||
PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
|
||||
}
|
||||
Notify(PSTR("\r\n"), 0x80);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -994,7 +994,6 @@ void ReportDescParserBase::Parse(const uint32_t len, const uint8_t *pbuf, const
|
|||
uint32_t cntdn = (uint32_t)len;
|
||||
uint8_t *p = (uint8_t*)pbuf;
|
||||
|
||||
|
||||
totalSize = 0;
|
||||
|
||||
while(cntdn) {
|
||||
|
|
@ -1246,18 +1245,18 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) {
|
|||
if(VALUE_BETWEEN(page, 0x00, 0x11))
|
||||
pfUsage = (usagePageFunctions[page - 1]);
|
||||
|
||||
// Dead code...
|
||||
//
|
||||
// pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]);
|
||||
//else if (page > 0x7f && page < 0x84)
|
||||
// E_Notify(pstrUsagePageMonitor);
|
||||
//else if (page > 0x83 && page < 0x8c)
|
||||
// E_Notify(pstrUsagePagePower);
|
||||
//else if (page > 0x8b && page < 0x92)
|
||||
// E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]));
|
||||
//else if (page > 0xfeff && page <= 0xffff)
|
||||
// E_Notify(pstrUsagePageVendorDefined);
|
||||
//
|
||||
// Dead code...
|
||||
//
|
||||
// pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]);
|
||||
//else if (page > 0x7f && page < 0x84)
|
||||
// E_Notify(pstrUsagePageMonitor);
|
||||
//else if (page > 0x83 && page < 0x8c)
|
||||
// E_Notify(pstrUsagePagePower);
|
||||
//else if (page > 0x8b && page < 0x92)
|
||||
// E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]));
|
||||
//else if (page > 0xfeff && page <= 0xffff)
|
||||
// E_Notify(pstrUsagePageVendorDefined);
|
||||
//
|
||||
else
|
||||
switch(page) {
|
||||
case 0x14:
|
||||
|
|
@ -1578,8 +1577,7 @@ void ReportDescParser2::OnInputItem(uint8_t itm) {
|
|||
// bits_to_copy - number of bits to copy to result buffer
|
||||
|
||||
// for each bit in a field
|
||||
for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left;
|
||||
bits_left -= bits_to_copy) {
|
||||
for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; bits_left -= bits_to_copy) {
|
||||
bits_to_copy = (bits_left > bits_of_byte) ? bits_of_byte : bits_left;
|
||||
|
||||
result.dwResult <<= bits_to_copy; // Result buffer is shifted by the number of bits to be copied into it
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ e-mail : support@circuitsathome.com
|
|||
#include "Usb.h"
|
||||
|
||||
bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) {
|
||||
if(!pBuf) {
|
||||
Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
|
||||
if(!pBuf) {
|
||||
Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
|
||||
return false;
|
||||
}
|
||||
for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++)
|
||||
pBuf[valueSize - countDown] = (**pp);
|
||||
|
||||
if(countDown)
|
||||
if(countDown)
|
||||
return false;
|
||||
|
||||
countDown = valueSize;
|
||||
|
|
@ -41,35 +41,34 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) {
|
|||
*/
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||||
bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) {
|
||||
switch(nStage) {
|
||||
case 0:
|
||||
pBuf->valueSize = lenSize;
|
||||
theParser.Initialize(pBuf);
|
||||
nStage = 1;
|
||||
switch(nStage) {
|
||||
case 0:
|
||||
pBuf->valueSize = lenSize;
|
||||
theParser.Initialize(pBuf);
|
||||
nStage = 1;
|
||||
|
||||
case 1:
|
||||
if(!theParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
|
||||
arLen = 0;
|
||||
arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue));
|
||||
arLenCntdn = arLen;
|
||||
nStage = 2;
|
||||
|
||||
case 2:
|
||||
pBuf->valueSize = valSize;
|
||||
theParser.Initialize(pBuf);
|
||||
nStage = 3;
|
||||
|
||||
case 3:
|
||||
for(; arLenCntdn; arLenCntdn--) {
|
||||
case 1:
|
||||
if(!theParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
|
||||
arLen = 0;
|
||||
arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue));
|
||||
arLenCntdn = arLen;
|
||||
nStage = 2;
|
||||
|
||||
case 2:
|
||||
pBuf->valueSize = valSize;
|
||||
theParser.Initialize(pBuf);
|
||||
nStage = 3;
|
||||
|
||||
case 3:
|
||||
for(; arLenCntdn; arLenCntdn--) {
|
||||
if(!theParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
|
||||
if(pf)
|
||||
pf(pBuf, (arLen - arLenCntdn), me);
|
||||
}
|
||||
|
||||
nStage = 0;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ class MultiByteValueParser {
|
|||
|
||||
public:
|
||||
|
||||
MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) {
|
||||
};
|
||||
MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) {
|
||||
};
|
||||
|
||||
const uint8_t* GetBuffer() {
|
||||
return pBuf;
|
||||
};
|
||||
const uint8_t* GetBuffer() {
|
||||
return pBuf;
|
||||
};
|
||||
|
||||
void Initialize(MultiValueBuffer * const pbuf) {
|
||||
pBuf = (uint8_t*)pbuf->pValue;
|
||||
|
|
@ -71,7 +71,7 @@ class ByteSkipper {
|
|||
public:
|
||||
|
||||
ByteSkipper() : pBuf(NULL), nStage(0), countDown(0) {
|
||||
};
|
||||
};
|
||||
|
||||
void Initialize(MultiValueBuffer *pbuf) {
|
||||
pBuf = (uint8_t*)pbuf->pValue;
|
||||
|
|
@ -79,15 +79,14 @@ public:
|
|||
};
|
||||
|
||||
bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) {
|
||||
switch(nStage) {
|
||||
case 0:
|
||||
countDown = bytes_to_skip;
|
||||
nStage++;
|
||||
case 1:
|
||||
for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--);
|
||||
|
||||
if(!countDown)
|
||||
nStage = 0;
|
||||
switch(nStage) {
|
||||
case 0:
|
||||
countDown = bytes_to_skip;
|
||||
nStage++;
|
||||
case 1:
|
||||
for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--);
|
||||
if(!countDown)
|
||||
nStage = 0;
|
||||
};
|
||||
return (!countDown);
|
||||
};
|
||||
|
|
@ -99,9 +98,9 @@ typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t cou
|
|||
class PTPListParser {
|
||||
public:
|
||||
|
||||
enum ParseMode {
|
||||
modeArray, modeRange/*, modeEnum*/
|
||||
};
|
||||
enum ParseMode {
|
||||
modeArray, modeRange/*, modeEnum*/
|
||||
};
|
||||
|
||||
private:
|
||||
uint32_t nStage;
|
||||
|
|
|
|||
Loading…
Reference in a new issue