- Sometimes the read process ends at the 16 byte limit for no apparent reason
- Sometimes the 16th digit gets lost
It can do this no matter the UART settings I'm using regarding rxbuf size. I've tried it with 15, 16, 100 and 256 buffer limits and get the same random behaviour with all of them. I know the data is correct going in to the ESP8285 because i've watched it on the logic analyser. So clearly this is an issue within the UART implementation of Micropython.
The following code is called to setup the serial port.
Code: Select all
uos.dupterm(None,1)
uart = UART(0,115200)
uart.init(115200, bits=8, parity=None, stop=1, timeout=20, timeout_char=20, rxbuf=256)
Code: Select all
if (uart.any()):
cmd=""
serialline=uart.readline()
print("Received serial cmd: " + str(serialline))
if len(serialline)>1:
try:
cmd=serialline.decode("utf-8")
cmd=cmd.replace(chr(10),'').replace(chr(13),'')
except:
cmd=serialline
if (cmd[0]=='C' and mqttclient!=None):
payloaddict={"cardtoken": cmd[1:], "timestamp": utime.time()}
This behaviour is driving me nuts! How can I work around the issue, or is this simply broken in Micropython and I need to look elsewhere?