I am using ST32 connected to the computer with USB cable. this micro-controller is already programmed and should give me two values
(it has worked on windows 10 I just replaced '/dev/ttyS1' with 'COM1').
the problem is that when i compile my program it doesn't show any Errors. I don't even know if I am communicating with the right port or not.
DO you have an Idea what can i do to solve this problem?
import serial
import re
serport = '/dev/ttyS1'
serbaudrate = 9600
ser = serial.Serial(port = serport, baudrate = serbaudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, timeout=2)
try:
ser.isOpen()
except:
print("Error")
exit()
if ser.isOpen():
try:
while 1:
if ser.inWaiting() > 0:
response = ser.readline()
needles = re.match("(\d+);(\d+)", response.decode("utf-8"))
if needles:
print("Got: {} {}".format(needles[1], needles[2]))
#print("Got: {}".format(needles[2]))
else:
ser.write(b"1")
except Exception as e:
print(e)
Bookmarks