[riot-notifications] [RIOT-OS/RIOT] pyterm: try to reconnect on SerialException during connect (#10482)

Alexandre Abadie notifications at github.com
Wed Sep 11 08:38:49 CEST 2019


aabadie requested changes on this pull request.

I just tested this one and it doesn't work in the current state. See my comment below.

>              self.logger.info("Connect to serial port %s" % self.port)
-            try:
-                self.serial_connect()
-            except OSError as e:
-                self.logger.error("Cannot connect to serial port {}: {}"
-                                  .format(self.port, e.strerror))
-                sys.exit(1)
-            except serial.SerialException as e:
-                self.logger.error("%s", e.strerror)
-                sys.exit(1)
+            while not connected:
+                try:
+                    self.serial_connect()
+                except OSError as e:

This doesn't work on my machine: OSError is catched before serial.SerialException. The following works:
```suggestion
                except serial.SerialException as e:
                    self.logger.error("%s", e.strerror)
                    if not self.reconnect:
                        sys.exit(1)
                    self.logger.info("Trying to reconnect to {} in 10 sec"
                                     .format(self.port))
                    time.sleep(10)
                except OSError as e:
                    self.logger.error("Cannot connect to serial port {}: {}"
                                      .format(self.port, e.strerror))
                    sys.exit(1)
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10482#pullrequestreview-286580487
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190910/6f44b0de/attachment.htm>


More information about the notifications mailing list