Last active
February 16, 2022 03:50
-
-
Save rdandy/569532629e4d8477e4f9387b985e95a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# serial_read.py | |
import serial, time | |
SERIALPORT = "/dev/ttyS0" | |
ser = serial.Serial(SERIALPORT, baudrate=115200, bytesize=8, parity="N", stopbits=1, rtscts=False, xonxoff=False) | |
def read_data(): | |
while True: | |
if ser.in_waiting: | |
print (ser.read()) | |
else: | |
pass | |
time.sleep(0.3) | |
if __name__ == '__main__': | |
print(ser) | |
print("read data") | |
read_data() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment