Skip to content

Commit 80f05c7

Browse files
authored
Merge pull request #4654 from dhalbert/6.2.x-merge-1
Port #4645 to main
2 parents 80e8b4a + 454e78f commit 80f05c7

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ jobs:
498498
id: idf-cache
499499
with:
500500
path: ${{ github.workspace }}/.idf_tools
501-
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210415
501+
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210422
502502
- name: Clone IDF submodules
503503
run: |
504504
(cd $IDF_PATH && git submodule update --init)

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
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,13 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
191191
mp_raise_ValueError(translate("No TX pin"));
192192
}
193193

194-
while (len > 0) {
195-
while (uart_is_writable(self->uart) && len > 0) {
194+
size_t left_to_write = len;
195+
while (left_to_write > 0) {
196+
while (uart_is_writable(self->uart) && left_to_write > 0) {
196197
// Write and advance.
197198
uart_get_hw(self->uart)->dr = *data++;
198199
// Decrease how many chars left to write.
199-
len--;
200+
left_to_write--;
200201
}
201202
RUN_BACKGROUND_TASKS;
202203
}

0 commit comments

Comments
 (0)