コード例 #1
0
    def verify_protocol_version(self, major_version, minor_version):
        # check that FW has correct version

        self.protocol_major_version = major_version
        self.protocol_minor_version = minor_version

        if major_version != proto.EVKIT_PROTOCOL_VERSION_MAJOR or \
           minor_version != proto.EVKIT_PROTOCOL_VERSION_MINOR:
            # raise proto.ProtocolException('Wrong protocol version received from Firmware. Expected %d.%d, received %d.%d' %
                                    # (proto.EVKIT_PROTOCOL_VERSION_MAJOR, proto.EVKIT_PROTOCOL_VERSION_MINOR,
                                     # major_version, minor_version))
            logger.critical('Wrong protocol version received from Firmware. Expected %d.%d, received %d.%d' %
                            (proto.EVKIT_PROTOCOL_VERSION_MAJOR, proto.EVKIT_PROTOCOL_VERSION_MINOR,
                             major_version, minor_version))
コード例 #2
0
    def _configure_interrupts(self):
        # add all defined GPIO pins
        self.bus_gpio_list = []
        self._gpio_pin_index = []
        for t in range(1,4):
            if not evkit_config.has_option(self.config_section,'pin%d_index' % t):
                break
            self._has_gpio = True
            self.bus_gpio_list.append(t)
            self._gpio_pin_index.append(evkit_config.getint(self.config_section,'pin%d_index' % t))

        drdy_op = evkit_config.get('generic', 'drdy_operation') # Warn user if using interrupts and interrupt pin list is empty
        if self.bus_gpio_list == [] and drdy_op.startswith('ADAPTER_GPIO') :
            logger.critical('No interrupt pins configured in setting.cfg!')
コード例 #3
0
    def get_dev_darwin(self):
        """Search from /dev for iot node, arduino or nrf-dk depending which config_section is in use

        Returns path to the device
        """

        import glob

        if self.config_section == 'serial_com_kx_iot': #IoT node
            logger.info("Searching for Kx IoT node...")
            dev = glob.glob("/dev/tty.usbserial*")

        elif self.config_section.startswith('serial_com_nrf51dk'): #nrf-dk
            logger.info("Searching for NRF5x-dk...")
            dev = glob.glob("/dev/tty.usbmodem*")

        elif self.config_section.startswith('serial_com_arduino'): #Arduino
            logger.info("Searching for Arduino...")
            dev = glob.glob("/dev/tty.usbmodem*")

        else:
            print("Autofinder does not yet support {}",self.config_section )

        if len(dev) == 0:
            logger.critical("Autofinder found no {} devices".format(self.config_section))
            logger.critical("Please define port manually in settings.cfg")
            logger.critical("Example: com_port = /dev/tty.usbserial-DM00336G")
            exit()

        logger.info("Found {} devices:\n{}".format(len(dev), '\n'.join(dev)))
        logger.info("Using first device found:\n{}".format(dev[0]))
        return dev[0]
コード例 #4
0
    def check_com_port(self, wql):
        try:
            import wmi
        except ImportError:
            logger.critical("Autofinder found no {} devices".format(self.config_section))
            logger.critical("\nPlease run \'pip install wmi\'\nand \'pip install pypiwin32\'\n")
            logger.critical("Alternatively define port in settings.cfg\n")
            logger.critical("Example for windows OS : com_port = COM10\n")
            exit()

        c = wmi.WMI()
        result = None

        for foundPort in c.query(wql):
            result = foundPort.Name.partition('(')[2].partition(')')[0]
        return result