Ejemplo n.º 1
0
    def wait_for_serial(self):
        if self.scanTimer:
            self.scanTimer.cancel()
            self.scanTimer = None

        self.scanCount = 0
        self.scanTimer = add_timeout(self.scan_serial_device, 100, repeat = True)
Ejemplo n.º 2
0
    def scan_serial_device(self):
        self.scanCount = 0

        print "Checking if serial device is ready"
        ready = os.path.exists(SERIAL_RX_PREFIX + str(self.instanceId)) and os.path.exists(SERIAL_TX_PREFIX + str(self.instanceId))

        if ready:
            print "Serial device is ready"
            if self.scanTimer:
                self.scanTimer.cancel()
                self.scanTimer = None

            add_timeout(self.connected, 1)
            return False
        elif self.scanCount < 50:
            self.scanCount += 1
            return True
        else:
            print "Timed out waiting for device"
            self.scanTimer.cancel()
            self.scanTimer = None

            add_timeout(self.disconnectFromPebble, 1)
            return False