Pyserial and some half-duplex woes.

Mark Barton mark at atldes.com
Thu Sep 3 15:05:02 EDT 2020


Hey All,

I am using Microchip's Python program to download 
code to a PIC32 microprocessor via Pyserial. There 
is also Microchip's bootloader code running on the 
PIC side. This works very well using the a 
standard serial hardware directly connected to a 
USB to serial adapter to one of the PIC's UARTs. 
However in our application the hardware is a 
single wire thus requiring a half-duplex 
communications. Fortunately Microchip's protocol 
lends itself to half-duplex communications, 
however the problem is that both the PIC and the 
Python program will receive an echo when one of 
the other transmits due to the hardware design. It 
other words the PIC will receive what it transmits 
and the same on the Python side. The PIC side is 
easily fixed by simply turning off receive during 
transmit. I don't think I can do this on the 
Python side at least there nothing in Pyserial's 
documentation that you can do that.

I have tried to do some flushing of the receive 
buffer, but I haven't been too successful. Perhaps 
that is due to timing.

I thought I would reach out to see if anyone may 
have had a similar experience.

Thanks for any help.

Mark




More information about the Python-list mailing list