Looking for terminator in data drom UART
Posted: Thu Mar 23, 2017 9:08 pm
Hello,
I need to catch a terminator \r in data I receive from UART and I've got this code:
[code]
data = ""
while True:
bytes = uart.read()
if bytes is not None:
idx = str(bytes).find("'", 2)
data += str(bytes)[2:idx]
print(data[len(data)-2:])
if data.find("\r") != -1:
print("Here\r\n")
[/code]
But data.find("\r") always returns -1 even when data contains \r. How to solve this problem?
I need to catch a terminator \r in data I receive from UART and I've got this code:
[code]
data = ""
while True:
bytes = uart.read()
if bytes is not None:
idx = str(bytes).find("'", 2)
data += str(bytes)[2:idx]
print(data[len(data)-2:])
if data.find("\r") != -1:
print("Here\r\n")
[/code]
But data.find("\r") always returns -1 even when data contains \r. How to solve this problem?