Skip to content

Commit f1b5249

Browse files
committed
Fix esp32s2 uart.write() return value
1 parent b3ffb3a commit f1b5249

File tree

1 file changed

+4
-3
lines changed
  • ports/esp32s2/common-hal/busio

1 file changed

+4
-3
lines changed

ports/esp32s2/common-hal/busio/UART.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,14 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
291291
mp_raise_ValueError(translate("No TX pin"));
292292
}
293293

294-
while (len > 0) {
295-
int count = uart_tx_chars(self->uart_num, (const char *)data, len);
294+
size_t left_to_write = len;
295+
while (left_to_write > 0) {
296+
int count = uart_tx_chars(self->uart_num, (const char *)data, left_to_write);
296297
if (count < 0) {
297298
*errcode = MP_EAGAIN;
298299
return MP_STREAM_ERROR;
299300
}
300-
len -= count;
301+
left_to_write -= count;
301302
data += count;
302303
RUN_BACKGROUND_TASKS;
303304
}

0 commit comments

Comments
 (0)