reboot and initial 19 characters on pyboard

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Posts: 4
Joined: Sun Feb 28, 2021 11:56 am

reboot and initial 19 characters on pyboard

Post by ghukill » Thu Apr 15, 2021 12:47 pm

Working with:

Code: Select all

MicroPython v1.13 on 2020-09-02; PYBv1.1
My code looks roughly as follows:

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...
I was having trouble with raw bytes -- only on hard reboot -- getting picked up in the loop where it checks the serial buffer. I suppose my questions are twofold:

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.

Post Reply