From 6d7984ade21f34d30c484ee4cc34ff1bc8951829 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Wed, 13 Jan 2021 07:14:36 +0100 Subject: [PATCH] Log info when not adding Interface/Endpoint because max is reached --- hidcomposite.cpp | 18 +++++++++++++++--- hiduniversal.cpp | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/hidcomposite.cpp b/hidcomposite.cpp index 62cc9d0a..6cb866d3 100644 --- a/hidcomposite.cpp +++ b/hidcomposite.cpp @@ -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; diff --git a/hiduniversal.cpp b/hiduniversal.cpp index 4ced3b14..bbd06af7 100644 --- a/hiduniversal.cpp +++ b/hiduniversal.cpp @@ -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;