# HG changeset patch # User Malte Bayer # Date 1322900780 -3600 # Node ID 3e617fcf999a61283db0449a9bc39a958d936c3d # Parent 4af697fa5ea938b1264be7007a988d9f7267ff6a added exception, started SlotCli class diff -r 4af697fa5ea9 -r 3e617fcf999a slotUI/SlotCli.py --- a/slotUI/SlotCli.py Sat Dec 03 09:16:39 2011 +0100 +++ b/slotUI/SlotCli.py Sat Dec 03 09:26:20 2011 +0100 @@ -3,3 +3,20 @@ Freeslot project Command line interface """ + +from freeslot import Blackbox + +class SlotCli(): + def __init__(self): + self.box = Blackbox() + self.box.connect() + + def run(self): + """ + Keyboard loop to control it??? + """ + return None + +if __name__ == "__main__": + app = SlotCli() + app.run() \ No newline at end of file diff -r 4af697fa5ea9 -r 3e617fcf999a slotUI/freeslot.py --- a/slotUI/freeslot.py Sat Dec 03 09:16:39 2011 +0100 +++ b/slotUI/freeslot.py Sat Dec 03 09:26:20 2011 +0100 @@ -3,7 +3,8 @@ Blackbox communication library """ -from serial import Serial +import serial +import sys class SerialCommunicator(): def __init__(self, device, speed): @@ -15,7 +16,11 @@ def connect(self): if self.connected: return True - self.com = Serial(self.device, baudrate=self.speed, xonxoff=0, timeout=1) + try: + self.com = serial.Serial(self.device, baudrate=self.speed, xonxoff=0, timeout=1) + except serial.SerialException, err: + print err + sys.exit(1) self.connected = True return True