mejor forma de detectar el puerto de arduino
This commit is contained in:
parent
ed6e8d9d75
commit
d32a09168c
|
@ -8,16 +8,17 @@
|
|||
import serial
|
||||
import influxdb
|
||||
import time
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
while True:
|
||||
try:
|
||||
influx = influxdb.InfluxDBClient("localhost", 8086, "root", "root", "hometv")
|
||||
|
||||
ser = serial.Serial(sys.argv[1] or "/dev/ttyACM0", 9600) # 9600 bauds
|
||||
ser = serial.Serial("/dev/ttyACM0" if os.path.exists("/dev/ttyACM0") else "/dev/ttyACM1", 9600) # 9600 bauds
|
||||
while True:
|
||||
line = ser.readline()
|
||||
parts = line.decode('ascii').strip().split(" ")
|
||||
print(time.ctime(), line, parts)
|
||||
|
||||
if parts[0] != "D":
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue