Log info when not adding Interface/Endpoint because max is reached

This commit is contained in:
Daniel Gibson 2021-01-13 07:14:36 +01:00
parent 59af2be74f
commit 6d7984ade2
2 changed files with 30 additions and 6 deletions

View file

@ -306,8 +306,13 @@ void HIDComposite::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint
// Fill in interface structure in case of new interface
if(!piface) {
if(bNumIface >= maxHidInterfaces)
return; // don't overflow hidInterfaces[]
if(bNumIface >= maxHidInterfaces) {
// don't overflow hidInterfaces[]
Notify(PSTR("\r\n HIDComposite::EndpointXtract(): Not adding HID interface because we already have "), 0x80);
Notify(bNumIface, 0x80);
Notify(PSTR(" interfaces and can't hold more. "), 0x80);
return;
}
piface = hidInterfaces + bNumIface;
piface->bmInterface = iface;
piface->bmAltSet = alt;
@ -321,7 +326,14 @@ void HIDComposite::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint
if(!SelectInterface(iface, proto))
index = 0;
if(index && bNumEP < totalEndpoints) {
if(index) {
if(bNumEP >= totalEndpoints) {
// don't overflow epInfo[] either
Notify(PSTR("\r\n HIDComposite::EndpointXtract(): Not adding endpoint info because we already have "), 0x80);
Notify(bNumEP, 0x80);
Notify(PSTR(" endpoints and can't hold more. "), 0x80);
return;
}
// Fill in the endpoint info structure
epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F);
epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize;

View file

@ -308,8 +308,13 @@ void HIDUniversal::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint
// Fill in interface structure in case of new interface
if(!piface) {
if(bNumIface >= maxHidInterfaces)
return; // don't overflow hidInterfaces[]
if(bNumIface >= maxHidInterfaces) {
// don't overflow hidInterfaces[]
Notify(PSTR("\r\n HIDUniversal::EndpointXtract(): Not adding HID interface because we already have "), 0x80);
Notify(bNumIface, 0x80);
Notify(PSTR(" interfaces and can't hold more. "), 0x80);
return;
}
piface = hidInterfaces + bNumIface;
piface->bmInterface = iface;
piface->bmAltSet = alt;
@ -320,7 +325,14 @@ void HIDUniversal::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint
if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT)
index = (pep->bEndpointAddress & 0x80) == 0x80 ? epInterruptInIndex : epInterruptOutIndex;
if(index && bNumEP < totalEndpoints) {
if(index) {
if(bNumEP >= totalEndpoints) {
// don't overflow epInfo[] either
Notify(PSTR("\r\n HIDUniversal::EndpointXtract(): Not adding endpoint info because we already have "), 0x80);
Notify(bNumEP, 0x80);
Notify(PSTR(" endpoints and can't hold more. "), 0x80);
return;
}
// Fill in the endpoint info structure
epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F);
epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize;