Merge remote-tracking branch 'origin/master'
99
config/instruction_images/st-ten-5/5802815400.svg
Normal file
|
After Width: | Height: | Size: 445 KiB |
93
config/instruction_images/st-ten-5/5803025107.svg
Normal file
|
After Width: | Height: | Size: 634 KiB |
88
config/instruction_images/st-ten-5/5803025111.svg
Normal file
|
After Width: | Height: | Size: 605 KiB |
86
config/instruction_images/st-ten-5/5803025113.svg
Normal file
|
After Width: | Height: | Size: 420 KiB |
86
config/instruction_images/st-ten-5/5803025114.svg
Normal file
|
After Width: | Height: | Size: 375 KiB |
86
config/instruction_images/st-ten-5/5803025116.svg
Normal file
|
After Width: | Height: | Size: 308 KiB |
86
config/instruction_images/st-ten-5/5803025117.svg
Normal file
|
After Width: | Height: | Size: 444 KiB |
87
config/instruction_images/st-ten-5/5803025127.svg
Normal file
|
After Width: | Height: | Size: 418 KiB |
64
config/instruction_images/st-ten-5/5803025131.svg
Normal file
|
After Width: | Height: | Size: 141 KiB |
64
config/instruction_images/st-ten-5/5803025134.svg
Normal file
|
After Width: | Height: | Size: 155 KiB |
64
config/instruction_images/st-ten-5/5803025135.svg
Normal file
|
After Width: | Height: | Size: 187 KiB |
87
config/instruction_images/st-ten-5/5803034025.svg
Normal file
|
After Width: | Height: | Size: 396 KiB |
71
config/instruction_images/st-ten-5/5803034774.svg
Normal file
|
After Width: | Height: | Size: 165 KiB |
89
config/instruction_images/st-ten-5/5803036737.svg
Normal file
|
After Width: | Height: | Size: 203 KiB |
80
config/instruction_images/st-ten-5/5803036739.svg
Normal file
|
After Width: | Height: | Size: 263 KiB |
80
config/instruction_images/st-ten-5/5803036740.svg
Normal file
|
After Width: | Height: | Size: 385 KiB |
78
config/instruction_images/st-ten-5/5803041432.svg
Normal file
|
After Width: | Height: | Size: 321 KiB |
80
config/instruction_images/st-ten-5/5803041433.svg
Normal file
|
After Width: | Height: | Size: 254 KiB |
80
config/instruction_images/st-ten-5/5803047099.svg
Normal file
|
After Width: | Height: | Size: 229 KiB |
49
src/test/serial_test.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
import platform
|
||||||
|
|
||||||
|
import serial
|
||||||
|
import time
|
||||||
|
|
||||||
|
def invia_e_leggi_frase(porta_seriale):
|
||||||
|
try:
|
||||||
|
porta_seriale.write(b'Connection OK')
|
||||||
|
time.sleep(1)
|
||||||
|
received_data = porta_seriale.read(15)
|
||||||
|
if not received_data:
|
||||||
|
print("Nessun dato ricevuto")
|
||||||
|
else:
|
||||||
|
print(f'Frase ricevuta: {received_data.decode("utf-8")}')
|
||||||
|
|
||||||
|
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(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')
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
invia_e_leggi_frase(ser)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
finally:
|
||||||
|
ser.close()
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f'Impossibile aprire la porta COM5')
|
||||||
|
|
||||||
|
except OSError as e:
|
||||||
|
print(f"Errore nell'apertura della porta COM5: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Errore generico: {e}")
|
||||||