def scan_interface(self, address):
        """ Scan interface for Crazyflies """

        if self._radio_manager is None:
            try:
                self._radio_manager = _RadioManager(0)
            except Exception:
                return []

        with self._radio_manager as cradio:
            # FIXME: implements serial number in the Crazyradio driver!
            serial = 'N/A'

            logger.info('v%s dongle with serial %s found', cradio.version,
                        serial)
            found = []

            if address is not None:
                addr = '{:X}'.format(address)
                new_addr = struct.unpack('<BBBBB', binascii.unhexlify(addr))
                cradio.set_address(new_addr)

            cradio.set_arc(1)

            cradio.set_data_rate(cradio.DR_250KPS)

            if address is None or address == DEFAULT_ADDR:
                found += [['radio://0/{}/250K'.format(c), '']
                          for c in self._scan_radio_channels(cradio)]
                cradio.set_data_rate(cradio.DR_1MPS)
                found += [['radio://0/{}/1M'.format(c), '']
                          for c in self._scan_radio_channels(cradio)]
                cradio.set_data_rate(cradio.DR_2MPS)
                found += [['radio://0/{}/2M'.format(c), '']
                          for c in self._scan_radio_channels(cradio)]
            else:
                found += [['radio://0/{}/250K/{:X}'.format(c, address), '']
                          for c in self._scan_radio_channels(cradio)]
                cradio.set_data_rate(cradio.DR_1MPS)
                found += [['radio://0/{}/1M/{:X}'.format(c, address), '']
                          for c in self._scan_radio_channels(cradio)]
                cradio.set_data_rate(cradio.DR_2MPS)
                found += [['radio://0/{}/2M/{:X}'.format(c, address), '']
                          for c in self._scan_radio_channels(cradio)]

        self._radio_manager.close()
        self._radio_manager = None

        return found
def scan_interface ( self , address ) : if self . _radio_manager is None : try : self . _radio_manager = _RadioManager ( 0 ) except Exception : return [ ] with self . _radio_manager as cradio : serial = 'N/A' logger . info ( 'v%s dongle with serial %s found' , cradio . version , serial ) found = [ ] if address is not None : addr = '{:X}' . format ( address ) new_addr = struct . unpack ( '<BBBBB' , binascii . unhexlify ( addr ) ) cradio . set_address ( new_addr ) cradio . set_arc ( 1 ) cradio . set_data_rate ( cradio . DR_250KPS ) if address is None or address == DEFAULT_ADDR : found += [ [ 'radio://0/{}/250K' . format ( c ) , '' ] for c in self . _scan_radio_channels ( cradio ) ] cradio . set_data_rate ( cradio . DR_1MPS ) found += [ [ 'radio://0/{}/1M' . format ( c ) , '' ] for c in self . _scan_radio_channels ( cradio ) ] cradio . set_data_rate ( cradio . DR_2MPS ) found += [ [ 'radio://0/{}/2M' . format ( c ) , '' ] for c in self . _scan_radio_channels ( cradio ) ] else : found += [ [ 'radio://0/{}/250K/{:X}' . format ( c , address ) , '' ] for c in self . _scan_radio_channels ( cradio ) ] cradio . set_data_rate ( cradio . DR_1MPS ) found += [ [ 'radio://0/{}/1M/{:X}' . format ( c , address ) , '' ] for c in self . _scan_radio_channels ( cradio ) ] cradio . set_data_rate ( cradio . DR_2MPS ) found += [ [ 'radio://0/{}/2M/{:X}' . format ( c , address ) , '' ] for c in self . _scan_radio_channels ( cradio ) ] self . _radio_manager . close ( ) self . _radio_manager = None return found
Scan interface for Crazyflies