コード例 #1
0
    def query_fast_io_boards(self):
        """Query the NET processor to see if any FAST IO boards are connected.

        If so, queries the IO boards to log them and make sure they're the  proper firmware version.
        """
        self.writer.write('SA:\r'.encode())
        msg = ''
        while not msg.startswith('SA:'):
            msg = (yield from self.readuntil(b'\r')).decode()
            if not msg.startswith('SA:'):
                self.platform.debug_log(
                    "Got unexpected message from FAST: {}".format(msg))

        self.platform.process_received_message(msg)
        self.platform.debug_log('Querying FAST IO boards...')

        firmware_ok = True

        for board_id in range(128):
            self.writer.write('NN:{:02X}\r'.format(board_id).encode())
            msg = ''
            while not msg.startswith('NN:'):
                msg = (yield from self.readuntil(b'\r')).decode()
                if not msg.startswith('NN:'):
                    self.platform.debug_log(
                        "Got unexpected message from FAST: {}".format(msg))

            if msg == 'NN:F\r':
                break

            node_id, model, fw, dr, sw, _, _, _, _, _, _ = msg.split(',')
            node_id = node_id[3:]

            model = model.strip('\x00')

            # Iterate as many boards as possible
            if not model or model == '!Node Not Found!':
                break

            self.platform.register_io_board(
                FastIoBoard(int(node_id, 16), model, fw, int(sw, 16),
                            int(dr, 16)))

            self.platform.debug_log('Fast IO Board {0}: Model: {1}, '
                                    'Firmware: {2}, Switches: {3}, '
                                    'Drivers: {4}'.format(
                                        node_id, model, fw, int(sw, 16),
                                        int(dr, 16)))

            if StrictVersion(IO_MIN_FW) > str(fw):
                self.platform.log.critical(
                    "Firmware version mismatch. MPF "
                    "requires the IO boards to be firmware {0}, but "
                    "your Board {1} ({2}) is v{3}".format(
                        IO_MIN_FW, node_id, model, fw))
                firmware_ok = False

        if not firmware_ok:
            raise AssertionError("Exiting due to IO board firmware mismatch")
コード例 #2
0
    async def query_fast_io_boards(self):
        """Query the NET processor to see if any FAST IO boards are connected.

        If so, queries the IO boards to log them and make sure they're the  proper firmware version.
        """
        # reset CPU early
        try:
            await asyncio.wait_for(self.reset_net_cpu(),
                                   5,
                                   loop=self.machine.clock.loop)
        except asyncio.TimeoutError:
            self.platform.warning_log(
                "Reset of NET CPU failed. This might be a firmware bug in your version."
            )
        else:
            self.platform.debug_log("Reset successful")

        await asyncio.sleep(.5, loop=self.machine.clock.loop)

        self.platform.debug_log('Reading all switches.')
        self.writer.write('SA:\r'.encode())
        msg = ''
        while not msg.startswith('SA:'):
            msg = (await self.readuntil(b'\r')).decode()
            if not msg.startswith('SA:'):
                self.platform.log.warning(
                    "Got unexpected message from FAST: {}".format(msg))

        self.platform.process_received_message(msg, "NET")
        self.platform.debug_log('Querying FAST IO boards...')

        firmware_ok = True

        for board_id in range(128):
            self.writer.write('NN:{:02X}\r'.format(board_id).encode())
            msg = ''
            while not msg.startswith('NN:'):
                msg = (await self.readuntil(b'\r')).decode()
                if not msg.startswith('NN:'):
                    self.platform.debug_log(
                        "Got unexpected message from FAST: {}".format(msg))

            if msg == 'NN:F\r':
                break

            node_id, model, fw, dr, sw, _, _, _, _, _, _ = msg.split(',')
            node_id = node_id[3:]

            model = model.strip('\x00')

            # Iterate as many boards as possible
            if not model or model == '!Node Not Found!':
                break

            self.platform.register_io_board(
                FastIoBoard(int(node_id, 16), model, fw, int(sw, 16),
                            int(dr, 16)))

            self.platform.debug_log('Fast IO Board {0}: Model: {1}, '
                                    'Firmware: {2}, Switches: {3}, '
                                    'Drivers: {4}'.format(
                                        node_id, model, fw, int(sw, 16),
                                        int(dr, 16)))

            if StrictVersion(IO_MIN_FW) > str(fw):
                self.platform.log.critical(
                    "Firmware version mismatch. MPF "
                    "requires the IO boards to be firmware {0}, but "
                    "your Board {1} ({2}) is v{3}".format(
                        IO_MIN_FW, node_id, model, fw))
                firmware_ok = False

        if not firmware_ok:
            raise AssertionError("Exiting due to IO board firmware mismatch")