Skip to content

Commit eb274d7

Browse files
committed
usbd/cdc: Fix two bugs found by patfrench.
See https://github.com/orgs/micropython/discussions/13784#discussioncomment-8685049 Signed-off-by: Angus Gratton <[email protected]>
1 parent 61fb33e commit eb274d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

micropython/usbd/cdc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def read(self, size):
386386
b = bytearray(self._rb.readable())
387387

388388
n = self._readinto(b, start)
389-
if not b:
389+
if not n:
390390
return None
391391
if n < len(b):
392392
return b[:n]
@@ -420,7 +420,7 @@ def ioctl(self, req, arg):
420420
if req == _MP_STREAM_POLL:
421421
return (
422422
(_MP_STREAM_POLL_WR if (arg & _MP_STREAM_POLL_WR) and self._wb.writable() else 0)
423-
| (_MP_STREAM_POLL_RD if (arg & _MP_STREAM_POLL_RD) and self._rd.readable() else 0)
423+
| (_MP_STREAM_POLL_RD if (arg & _MP_STREAM_POLL_RD) and self._rb.readable() else 0)
424424
|
425425
# using the USB level "open" (i.e. connected to host) for !HUP, not !DTR (port is open)
426426
(_MP_STREAM_POLL_HUP if (arg & _MP_STREAM_POLL_HUP) and not self.is_open() else 0)

0 commit comments

Comments
 (0)