The timeout works for the readline().
I am also seeing some strange behaviour on the write().
I am sending commands to a Nextion display like this:
Code: Select all
def send(self, command):
write_buffer = bytearray(len(command) + 3)
write_buffer[0: len(command)] = bytes(command, 'ASCII')
write_buffer[-3:] = b'\xff\xff\xff'
self.uart.write(write_buffer)
Before this worked flawlessly but now starnge things happen on the display. This is extra weird because the display usually just ignores any command it doesn't understand.
I am repeatedly sending commands like this:
page1.gSpeed.val=9
on a loop with a sleep(0.1)
Every other second (more or less) the display apears to receive messages like:
page1.gSpeed.val=99
the same occurs for other fields. I have tried changing the timeouts but that doesn't change anything.
I can't get my head around how the numbers get duplicated At first I thought it was just the last digit that is repeated but that makes no sense since that is not the last character sent, there is always the appended b'\xff\xff\xff' to end the command.
Then I also noticed larger numbers getting doubled up occasionally.
page1.gDistance.val=812
occasionally results in the display showing 812812