Skip to content

Commit 4ad94f6

Browse files
committed
limit retries
1 parent b525e95 commit 4ad94f6

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

stm32-modules/heater-shaker/firmware/host_comms_task/freertos_comms_task.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,14 @@ void run(void *param) { // NOLINT(misc-unused-parameters)
158158
vTaskDelay(1);
159159
tx_result = USBD_CDC_TransmitPacket(&_local_task.usb_handle);
160160
}
161-
162-
while (((USBD_CDC_HandleTypeDef *)_local_task.usb_handle.pClassData)
163-
->TxState == 1) {
164-
vTaskDelay(1);
161+
if (tx_result != USBD_FAIL) {
162+
uint8_t retries = 0;
163+
while ((((USBD_CDC_HandleTypeDef *)
164+
_local_task.usb_handle.pClassData)
165+
->TxState == 1) &&
166+
retries++ < 10) {
167+
vTaskDelay(1);
168+
}
165169
}
166170
if (UartReady) {
167171
UartReady = false;

stm32-modules/include/thermocycler-gen2/thermocycler-gen2/gcodes.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct GetResetReason {
162162
int res = 0;
163163
// print a hexadecimal representation of the reset flags
164164
res = snprintf(&*buf, (limit - buf),
165-
"M114 Last Reset Reason: %X h OK\n", reason);
165+
"M114 Last Reset Reason: %X OK\n", reason);
166166
if (res <= 0) {
167167
return buf;
168168
}

stm32-modules/thermocycler-gen2/firmware/host_comms_task/usb_hardware.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,12 @@ void usb_hw_send(uint8_t *buf, uint16_t len) {
220220
vTaskDelay(1);
221221
tx_result = USBD_CDC_TransmitPacket(&_local_config.usb_handle);
222222
}
223+
if (tx_result == USBD_FAIL) {
224+
return;
225+
}
226+
uint8_t retries = 0;
223227

224-
while (((USBD_CDC_HandleTypeDef*)_local_config.usb_handle.pClassData)->TxState == 1) {
228+
while ((((USBD_CDC_HandleTypeDef*)_local_config.usb_handle.pClassData)->TxState == 1) && retries++ < 10) {
225229
vTaskDelay(1);
226230
}
227231
}

0 commit comments

Comments
 (0)