aboutsummaryrefslogtreecommitdiff
path: root/src/splitscreen_duo/serial.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/splitscreen_duo/serial.py')
-rw-r--r--src/splitscreen_duo/serial.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/splitscreen_duo/serial.py b/src/splitscreen_duo/serial.py
new file mode 100644
index 0000000..bc9caec
--- /dev/null
+++ b/src/splitscreen_duo/serial.py
@@ -0,0 +1,21 @@
+import serial
+
+
+class Serial:
+ def __init__(self, port, baudrate=115200):
+ self.port = port
+ self.baudrate = baudrate
+ self.serial = serial.Serial(port, baudrate, timeout=0.1)
+
+ def read(self):
+ return self.serial.read()
+
+ def write(self, data):
+ self.serial.write(data)
+
+ def readline(self):
+ return self.serial.readline()
+
+ def in_waiting(self):
+ return self.serial.in_waiting
+