-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuart.py
More file actions
32 lines (29 loc) · 942 Bytes
/
uart.py
File metadata and controls
32 lines (29 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import serial.tools.list_ports
def getPort():
# ports = serial.tools.list_ports.comports()
# N = len(ports)
# commPort = "None"
# for i in range(0, N):
# port = ports[i]
# strPort = str(port)
# if "USB Serial Device" in strPort:
# splitPort = strPort.split(" ")
# commPort = (splitPort[0])
#return commPort
return "COM6"
def writeData(ser, data):
ser.write(str(data).encode())
# mess = ""
# def readSerial(client):
# bytesToRead = ser.inWaiting()
# if (bytesToRead > 0):
# global mess
# mess = mess + ser.read(bytesToRead).decode("UTF-8")
# while ("#" in mess) and ("!" in mess):
# start = mess.find("!")
# end = mess.find("#")
# processData(client, mess[start:end + 1])
# if (end == len(mess)):
# mess = ""
# else:
# mess = mess[end+1:]