예제 #1
0
    def run(self):
        # detect USB Switchable charger port
        port = DeviceCharger.detect_charger_port()
        if port is None:
            msg = 'None of the ports contains a USB Switchable charger, exiting'
            logger.error(msg)
            return

        # connect to the charger device using its serial interface
        try:
            self.charger = Serial(port, 9600, 8, 'N', 1, timeout=0.5)
        except (OSError, IOError) as e:
            logger.error(e)
            return

        # start charger status watcher
        charger_watcher = self.start_watcher(self.charger)

        # command handler
        command_handler = subscribe(DeviceCharger.COMMAND_CHANNEL,
                                    self.on_command)
        try:
            while True:
                time.sleep(0.1)
        except (SystemExit, KeyboardInterrupt):
            command_handler.stop()
            charger_watcher.stop()
            self.enable_charging(False)
예제 #2
0
    def run(self):
        # detect USB Switchable charger port
        port = DeviceCharger.detect_charger_port()
        if port is None:
            msg = 'None of the ports contains a USB Switchable charger, exiting'
            logger.error(msg)
            return

        # connect to the charger device using its serial interface
        try:
            self.charger = Serial(port, 9600, 8, 'N', 1, timeout=0.5)
        except (OSError, IOError) as e:
            logger.error(e)
            return

        # start charger status watcher
        charger_watcher = self.start_watcher(self.charger)

        # command handler
        command_handler = subscribe(DeviceCharger.COMMAND_CHANNEL,
                                    self.on_command)
        try:
            while True:
                time.sleep(0.1)
        except (SystemExit, KeyboardInterrupt):
            command_handler.stop()
            charger_watcher.stop()
            self.enable_charging(False)
예제 #3
0
    def run(self):
        try:
            # message handler
            handler = subscribe(ReceiptManagerApp.COMMAND_CHANNEL,
                                self.on_message)

            # main loop
            while True:
                time.sleep(0.1)
        except (SystemExit, KeyboardInterrupt):
            handler.stop()
예제 #4
0
    def run(self):
        try:
            # message handler
            handler = subscribe(
                ReceiptManagerApp.COMMAND_CHANNEL, self.on_message
            )

            # main loop
            while True:
                time.sleep(0.1)
        except (SystemExit, KeyboardInterrupt):
            handler.stop()
예제 #5
0
    def run(self):
        # message handler
        handler = subscribe(CardReaderApp.COMMAND_CHANNEL, self.on_message)

        # detect where the magnetic reader is connected
        device = MSReader.detect_reader()
        if device is None:
            return
        self.reader = MSReader(device)

        # main loop
        try:
            while True:
                time.sleep(0.1)
        except (SystemExit, KeyboardInterrupt):
            handler.stop()
            self.reader.close()
예제 #6
0
    def run(self):
        # message handler
        handler = subscribe(CardReaderApp.COMMAND_CHANNEL, self.on_message)

        # detect where the magnetic reader is connected
        device = MSReader.detect_reader()
        if device is None:
            return
        self.reader = MSReader(device)

        # main loop
        try:
            while True:
                time.sleep(0.1)
        except (SystemExit, KeyboardInterrupt):
            handler.stop()
            self.reader.close()