Update main.py
This commit is contained in:
parent
33bad73206
commit
18b11a9503
17
main.py
17
main.py
@ -45,23 +45,6 @@ wdt.feed()
|
||||
print("Setting up UART")
|
||||
uart = machine.UART(0, 115200,invert=UART.INV_RX)
|
||||
|
||||
def readUntil(uartObject, termination, maxlen=-1, includeTermination=True):
|
||||
terminatedFlag=False
|
||||
result = ''
|
||||
while maxlen < 0 or len(result) < maxlen:
|
||||
if uartObject.any():
|
||||
result += chr(uartObject.read(1)[0])
|
||||
for terminal in termination:
|
||||
if result.endswith(terminal):
|
||||
terminatedFlag=True
|
||||
if not includeTermination:
|
||||
result = result[:-len(terminal)]
|
||||
break
|
||||
if(terminatedFlag==True):
|
||||
return result
|
||||
time.sleep_us(10)
|
||||
return result
|
||||
|
||||
def parse_han_protocol(data):
|
||||
data = data.replace("'b'", "")
|
||||
data_list = data.split("\\r\\n")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user