Extra character on UART
Posted: Sun Oct 09, 2016 10:44 am
I'm using the WiPy 1.0 with the Waveshare e-ink display. That display needs a specific command string over UART. In attempting to send that string format I seem to get extraneous characters inserted in the string. To test, I set up a loopback connecting pins 12 and 13 with a small code fragment:
[code]
from machine import UART
uart = UART(0, baudrate=115200, pins=('GP12', 'GP13'))
print("UART:",uart)
s1 = "test"
print(uart.write(s1))
print(uart.readall())
s2 = "\xA50900CC33C33CAC"
print(uart.write(s2))
print(uart.readall())
[/code]
On running this I get something odd:
[code]
UART: UART(0, baudrate=115200, bits=8, parity=None, stop=1)
4
b'test'
16
b'\xc2\xa50900CC33C33CAC'
[/code]
Where does that leading hex '\xc2' come from?
[code]
from machine import UART
uart = UART(0, baudrate=115200, pins=('GP12', 'GP13'))
print("UART:",uart)
s1 = "test"
print(uart.write(s1))
print(uart.readall())
s2 = "\xA50900CC33C33CAC"
print(uart.write(s2))
print(uart.readall())
[/code]
On running this I get something odd:
[code]
UART: UART(0, baudrate=115200, bits=8, parity=None, stop=1)
4
b'test'
16
b'\xc2\xa50900CC33C33CAC'
[/code]
Where does that leading hex '\xc2' come from?