rogerclarkmelbourne / Arduino_STM32

Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards
Other
2.49k stars 1.25k forks source link

usb_hid.c doesn't receive outgoing reports correctly #897

Open davidgiven opened 1 year ago

davidgiven commented 1 year ago

In usb_hid.c:hidUSBDataSetup(), there's this code:

[code] usb_generic_control_rx_setup(buffer->buffer, buffer->bufferSize, &(buffer->state)); buffer->state = HID_BUFFER_UNREAD; [/code]

As far as I can tell, that assignment to buffer->state shouldn't be there. usb_generic_control_rx_setup() will set the state itself if the retrieval completes, and sometimes it doesn't. If it doesn't, hidUSBDataSetup() will be called again. However, if the assignment above is present, then the buffer will be marked as unread twice (and so picked up by the application twice).

It seems that just removing the assignment fixes things.

stevstrong commented 8 months ago

Hi, can you please post a pull request?