8000 Merge pull request #4922 from dhalbert/usb-cdc-buffers · adafruit/circuitpython@6900513 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6900513

Browse files
authored
Merge pull request #4922 from dhalbert/usb-cdc-buffers
Failed to advance buffer ptrs in usb_cdc.Serial properly
2 parents 1d9eff1 + 62aca94 commit 6900513

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shared-module/usb_cdc/Serial.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data,
4040
uint32_t total_num_read = tud_cdc_n_read(self->idx, data, len);
4141

4242
if (wait_forever || wait_for_timeout) {
43+
// Continue filling the buffer past what we already read.
44+
len -= total_num_read;
45+
data += total_num_read;
46+
4347
// Read more if we have time.
4448
// Use special routine to avoid pulling in uint64-float-compatible math routines.
4549
uint64_t timeout_ms = float_to_uint64(self->timeout * 1000); // Junk value if timeout < 0.
@@ -78,6 +82,10 @@ size_t common_hal_usb_cdc_serial_write(usb_cdc_serial_obj_t *self, const uint8_t
7882
tud_cdc_n_write_flush(self->idx);
7983

8084
if (wait_forever || wait_for_timeout) {
85+
// Continue writing the rest of the buffer.
86+
len -= total_num_written;
87+
data += total_num_written;
88+
8189
// Write more if we have time.
8290
// Use special routine to avoid pulling in uint64-float-compatible math routines.
8391
uint64_t timeout_ms = float_to_uint64(self->write_timeout * 1000); // Junk value if write_timeout < 0.

0 commit comments

Comments
 (0)
0