slotUI/freeslot.py

changeset 27
3e617fcf999a
parent 26
4af697fa5ea9
child 35
00166228a419
--- 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
 

mercurial