Files
mixly3-server/mixly/boards/default/micropython/build/lib/uart_com.py

28 lines
561 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
UART Communication
MicroPython library for the UART_COMBoard to board communication
=======================================================
#Preliminary composition 20220903
dahanzimin From the Mixly Team
"""
_sdata=None
def send(uart,data,repeat=True):
global _sdata
if data != _sdata:
uart.write((str(data)+'\n'))
if not repeat:
_sdata=data
def recv(uart):
data = uart.readline()
if data:
data_str = data.strip()
try:
data_str=data_str.decode()
return eval(data_str)
except:
return data_str