diff options
-rwxr-xr-x | daemon.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -21,6 +21,7 @@ class Daemon: def __init__(self): self.ser = serial.Serial(sys.argv[1], 9600, timeout=1) + logger.debug("connected. waiting for client greeting") # raise timeout to let arduino start up self.ser.timeout = 15 @@ -29,13 +30,14 @@ class Daemon: # arduino sometimes has a dirty buffer # and sends junk before the ready message if not incoming.endswith("ready"): - sys.stderr.write("Got unexpected reply: "+incoming) - raise Exception("Wrong client greeting") + log.error("Got reply: '"+incoming+"'") + raise Exception("Wrong or no client greeting") self.ser.timeout = 1 + logger.debug("got client greeting") self.client = mpd.MPDClient() self.client.connect("localhost", 6600) - logger.debug("connected") + logger.debug("connected to mpd") def readline(self): return self.ser.readline().decode("ascii").strip() |