Serial echo hangs? I must be crazy...
Posted: Sun Jul 16, 2017 5:55 pm
I'm experience strange hangs with Pyboard v1.1 running
I'm working on a robot with a RasPi3 for ROS/Linux and a PyBoard for the hard realtime. I'm using serial to connect the two. Now first off the RasPi3 serial port is well known to be sub-standard, and I've stolen the Bluetooth UART from the RasPi to reroute it to the I/O header pins as that is supposed to be a better UART, at least it has a deeper buffer. In any case, that is one of the UART's that I'm using as the PyBoard's peer. I've also tried with an FTDI serial USB cable.
I've written a little loopback code shown below, just to see if I can get data from the RasPi to the PyBoard and back again without corruption. Strangely, the PyBoard seems to occasionally go out to lunch, drop off the USB console connection and block storage mount point, and require a hard reset. The symptoms are exactly that of some kind of lock race in the PyBoards serial driver allowing a buffer overflow to scribble everywhere in SRAM, at least that is where my suspicion would turn first. On the other hand, the PyBoard serial driver is very old, very well-exercised functionality, so I would expect it to be very robust by now. Anyway, my code is below. Am I missing something obvious? The code should just be a software implementation of a piece of wire....
Code: Select all
>>> sys.implementation
(name='micropython', version=(1, 9, 1))
I've written a little loopback code shown below, just to see if I can get data from the RasPi to the PyBoard and back again without corruption. Strangely, the PyBoard seems to occasionally go out to lunch, drop off the USB console connection and block storage mount point, and require a hard reset. The symptoms are exactly that of some kind of lock race in the PyBoards serial driver allowing a buffer overflow to scribble everywhere in SRAM, at least that is where my suspicion would turn first. On the other hand, the PyBoard serial driver is very old, very well-exercised functionality, so I would expect it to be very robust by now. Anyway, my code is below. Am I missing something obvious? The code should just be a software implementation of a piece of wire....
Code: Select all
from pyb import UART
def run(s=115200):
uart = UART(1, s)
while True:
ch = uart.readchar()
if ch < 0:
continue
uart.writechar(ch)