← index #5335Issue #1255
Related · high · value 2.201
QUERY · ISSUE

USB_VCP.readline() does not read whole line

openby shamlianopened 2019-11-15updated 2019-11-18
port-stm32

On a pyboard, I am having some trouble with USB_VCP.readline(); it seems to return whatever is in the buffer, even if it's not a full line. I would have expected the function to return None until a newline character is received, as if I were reading from a file. Is this expected? I noticed that the documentation text for USB_VCP's implementation of readline() is different than the text for UART and socket; I'm hoping this isn't a sign that they are supposed to work differently.

CANDIDATE · ISSUE

stmhal: sys.stdin and pyb.USB_VCP() don't have readinto

closedby dhylandsopened 2015-05-13updated 2015-05-13

sys.stdin seems to be missing readinto

>>> dir(sys.stdin)
['read', 'readall', 'readline', 'write', 'close', '__del__', '__enter__', '__exit__']

pyb.USB_VCP() also seems to be missing readinto

>>> dir(pyb.USB_VCP())
['setinterrupt', 'isconnected', 'any', 'send', 'recv', 'read', 'readall', 'readline', 'write', 'close', '__del__', '__enter__', '__exit__']

I'll use read in the meantime.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied