Sat, 03 Dec 2011 09:26:20 +0100
added exception, started SlotCli class
slotUI/SlotCli.py | file | annotate | diff | comparison | revisions | |
slotUI/freeslot.py | file | annotate | diff | comparison | revisions |
--- 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
--- 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