serial test linux
This commit is contained in:
parent
6810b9c63f
commit
dea95e6d76
@ -1,3 +1,5 @@
|
||||
import platform
|
||||
|
||||
import serial
|
||||
import time
|
||||
|
||||
@ -13,8 +15,17 @@ def invia_e_leggi_frase(porta_seriale):
|
||||
|
||||
except Exception as e:
|
||||
print(f"Errore: {e}")
|
||||
|
||||
|
||||
is_win = platform.system().lower() == "windows"
|
||||
|
||||
if is_win:
|
||||
dev="COM5"
|
||||
else:
|
||||
dev = '/dev/ttyUSB0'
|
||||
|
||||
try:
|
||||
ser = serial.Serial('COM5', 9600, timeout=1, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)
|
||||
ser = serial.Serial(dev, 9600, timeout=1, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)
|
||||
if ser.is_open:
|
||||
print(f'Connesso alla porta COM5')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user