From d32a09168c349af58406087b2142be2b3ff7de52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Fri, 26 Feb 2016 22:14:21 +0100 Subject: [PATCH] mejor forma de detectar el puerto de arduino --- arduino-daemon.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arduino-daemon.py b/arduino-daemon.py index 67a7257..038c1d9 100755 --- a/arduino-daemon.py +++ b/arduino-daemon.py @@ -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