From 2e883d3eaab92c6e4e104eedde72dbe63b31b8cd Mon Sep 17 00:00:00 2001 From: Raghav <62105787+MythicalCow@users.noreply.github.com> Date: Sun, 18 Jul 2021 16:04:48 -0400 Subject: [PATCH] Create RaspberryPiSerialReader.py --- .../usbserial/RaspberryPiSerialReader.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 serial communication test code/usbserial/RaspberryPiSerialReader.py diff --git a/serial communication test code/usbserial/RaspberryPiSerialReader.py b/serial communication test code/usbserial/RaspberryPiSerialReader.py new file mode 100644 index 0000000..e2bef24 --- /dev/null +++ b/serial communication test code/usbserial/RaspberryPiSerialReader.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +import serial +if __name__ == '__main__': + ser = serial.Serial('/dev/tty.usbserial-01BE27D0', 115200, timeout=1) #Declaring Serial Object. First parameter is the usb port. Second is Baud Rate. + ser.flush() + while True: + if ser.in_waiting > 0: + line = ser.readline().decode('utf-8').rstrip() #Stores serial data in utf 8 format. + print(line)