Code: Select all
MicroPython v1.13 on 2020-09-02; PYBv1.1
Code: Select all
vcp = pyb.USB_VCP()
# warmup: clear serial buffer
t0 = pyb.millis()
r = vcp.recv(19, timeout=10000) # what are these 19 characters? 10s timeout is a safeguard, usually more like 5-6s...
# main loop
while True:
# if anything in serial buffer, parse
if vcp.any() > 0:
raw_input = vcp.readline()
# do work here...
1. Is there a more elegant way to handle clearing the serial buffer before entering into the main loop and consuming as data comes in?
2. What are those 19 characters? I'm having trouble capturing them in a way I could copy/paste here, but they quite obviously bytes and don't readily decode to anything meaningful that I've been able to capture.
Any insight would be appreciated. I'm also interested in the best way to reboot the main loop via serial commands, but that might be better as a separate post.