Skip to content

Commit

Permalink
Fixed usb read loops not reading until timeout (#16827)
Browse files Browse the repository at this point in the history
* the size variable was redeclared (hiding the variable of the outside scope) and therefore the while check was always false, so the compiler just removed the do while loop, but it would be better to read all data and only exit the task, after this is done
  • Loading branch information
susch19 authored Apr 9, 2022
1 parent 4ce0203 commit bf67abb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tmk_core/protocol/chibios/usb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ void console_task(void) {
uint8_t buffer[CONSOLE_EPSIZE];
size_t size = 0;
do {
size_t size = chnReadTimeout(&drivers.console_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
size = chnReadTimeout(&drivers.console_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
if (size > 0) {
console_receive(buffer, size);
}
Expand Down Expand Up @@ -1102,7 +1102,7 @@ void raw_hid_task(void) {
uint8_t buffer[RAW_EPSIZE];
size_t size = 0;
do {
size_t size = chnReadTimeout(&drivers.raw_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
size = chnReadTimeout(&drivers.raw_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
if (size > 0) {
raw_hid_receive(buffer, size);
}
Expand All @@ -1125,7 +1125,7 @@ void midi_ep_task(void) {
uint8_t buffer[MIDI_STREAM_EPSIZE];
size_t size = 0;
do {
size_t size = chnReadTimeout(&drivers.midi_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
size = chnReadTimeout(&drivers.midi_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
if (size > 0) {
MIDI_EventPacket_t event;
recv_midi_packet(&event);
Expand Down

0 comments on commit bf67abb

Please sign in to comment.