Explorar el Código

catch serial exception on opening port

Thomas Buck hace 2 años
padre
commit
cff57b659e
Se han modificado 2 ficheros con 11 adiciones y 6 borrados
  1. 1
    1
      linux/PKGBUILD
  2. 10
    5
      linux/caselights

+ 1
- 1
linux/PKGBUILD Ver fichero

@@ -1,7 +1,7 @@
1 1
 # Maintainer: Thomas Buck <thomas@xythobuz.de>
2 2
 pkgname=CaseLights
3 3
 pkgver=0.2
4
-pkgrel=2
4
+pkgrel=3
5 5
 pkgdesc="RGB LED and UV strip controls"
6 6
 arch=('any')
7 7
 license=('unknown')

+ 10
- 5
linux/caselights Ver fichero

@@ -196,12 +196,17 @@ class CaseLights():
196 196
         self.serial = serial.Serial()
197 197
         self.serial.port = self.usedPort
198 198
         self.serial.baudrate = 115200
199
-        self.serial.open()
200
-        if self.serial.is_open:
201
-            print("connected to: " + self.usedPort)
202
-        else:
199
+
200
+        try:
201
+            self.serial.open()
202
+            if self.serial.is_open:
203
+                print("connected to: " + self.usedPort)
204
+            else:
205
+                print("error connecting to: " + self.usedPort)
206
+            return self.serial.is_open
207
+        except serial.serialutil.SerialException:
203 208
             print("error connecting to: " + self.usedPort)
204
-        return self.serial.is_open
209
+            return False
205 210
 
206 211
     def printRGBStrings(self, rs, gs, bs):
207 212
         if self.serial.is_open:

Loading…
Cancelar
Guardar