Ejemplo n.º 1
0
def find_devices():
    """Return a dictionary of all devices attached to this system.

    The dictionary key is the unique ID of the adapter and the dictionary value is the port.
    """
    # find out how many devices are attached
    num_devices, ports, unique_ids = aardvark_py.aa_find_devices_ext(0, 0)
    # get all the available ports and their corresponding unique IDs
    num_devices, ports, unique_ids = aardvark_py.aa_find_devices_ext(num_devices, num_devices)
    devices = {}
    for i in range(len(ports)):
        devices[unique_ids[i]] = ports[i]
    return devices
Ejemplo n.º 2
0
def find_devices():
    """Return a dictionary of all devices attached to this system.

    The dictionary key is the unique ID of the adapter and the dictionary value is the port.
    """
    # find out how many devices are attached
    num_devices, ports, unique_ids = aardvark_py.aa_find_devices_ext(0, 0)
    # get all the available ports and their corresponding unique IDs
    num_devices, ports, unique_ids = aardvark_py.aa_find_devices_ext(
        num_devices, num_devices)
    devices = {}
    for i in range(len(ports)):
        devices[unique_ids[i]] = ports[i]
    return devices
Ejemplo n.º 3
0
	def __init__(self, uid = None):
		(num, ports, unique_ids) = aa_py.aa_find_devices_ext(16, 16)
		if num > 0:
			ix = 0
			if uid:
				if uid in unique_ids:
					ix = unique_ids.index(uid)
					port = ports[ix]
					if port & aa_py.AA_PORT_NOT_FREE:
						raise ValueError
				else:
					raise ValueError
			else:
				while ix < num:
					port = ports[ix]
					if port & aa_py.AA_PORT_NOT_FREE:
						ix += 1
						continue
					break
				if ix == num:
					print "No Free Device"
					raise IndexError
		else:
			print "No devices connected"
			raise IndexError

		self.aa = aa_py.aa_open(port)
		self.get_serial_number()
		aa_py.aa_configure(self.aa,  aa_py.AA_CONFIG_GPIO_I2C)
		aa_py.aa_configure(self.aa,  aa_py.AA_TARGET_POWER_NONE)
		aa_py.aa_configure(self.aa,  aa_py.AA_CONFIG_GPIO_I2C)
    def test_01_port_ready(self):
        """Tests that PORT_NUMBER is connected and available"""
        num, ports, unique_ids = aa_find_devices_ext(16, 16)

        self.assertGreater(num, 0)  # check that devices have been returned
        if num > 0:
            # dictionary of form = port : (unique_id, in_use_status)
            devices = {}
            for i in range(num):
                port, in_use_status = AardvarkConnection.get_status(ports[i])
                devices[port] = unique_ids, in_use_status
            # checks that the port is detected
            self.assertEqual(self.port_number in devices.keys(), True)
            # checks that it's available
            self.assertEqual(devices[self.port_number][1], False)
    def __init__(self, aadvark_index=None):
        _i2c_bus.__init__(self)
        self.bus_gpio_list = [1, 2]
        self._has_gpio = True
        self._handle = None
        self._bitrate = None

        if not aardvark_found:
            raise BusException('Aardvark libraries not found/installed.')

        (num, ports, unique_ids) = aa.aa_find_devices_ext(16, 16)
        if (num == 0):
            raise BusException('Aardvark i2c/spi host adapter not connected.')
        elif (num == -2):
            raise BusException(
                'Aardvark i2c/spi host adapter never connected.')
        else:
            self._ports = ports[0]
            if (num > 1):
                logger.warning(
                    'More that 1 Aardvark ports found. Selecting 1st one.')
Ejemplo n.º 6
0
def Open_Aardvark(number=0):
    global Aardvark_Handle
    (num, ports, unique_ids) = aardvark_py.aa_find_devices_ext(16, 16)
    port = None
    dongle_id = number
    if number == 0 and len(unique_ids) > 0:
        port = ports[0]
        dongle_id = unique_ids[0]
    else:
        for i in range(0, len(unique_ids)):
            if unique_ids[i] == number:
                port = ports[i]
                dongle_id = unique_ids[i]
                break

    if port is None:
        raise Exception('Failed to find dongle: ' + str(dongle_id))
    Aardvark_Handle = aardvark_py.aa_open(port)
    if (Aardvark_Handle <= 0):
        raise Exception('Failed to open dongle: ' + str(dongle_id))
    else:
        print('Using dongle with ID: ' + str(dongle_id) + "\n")
    def __init__(self):
        _spi_bus.__init__(self)
        self.bus_gpio_list = [1, 2]
        self._has_gpio = True
        self._handle = None
        self._bitrate = None

        if not aardvark_found:
            raise BusException('Aardvark libraries not found/installed.')

        (num, ports, unique_ids) = aa.aa_find_devices_ext(16, 16)
        if (num == 0):
            raise BusException('Aardvark i2c/spi host adapter not connected.')
        elif (num == -2):
            raise BusException(
                'Aardvark i2c/spi host adapter never connected.')
        else:
            self._ports = ports[0]
            if (num > 1):
                logger.warning(
                    'More that 1 Aardvark ports found. Selecting 1st one.')

        self.MASKR = int(evkit_config.get('spi', 'maskr'),
                         2)  # SPI's read address mask
Ejemplo n.º 8
0
def _find_aardvark():
    (num, ports, unique_ids) = api.aa_find_devices_ext(16, 16)
    for port in ports:
        if not (port & api.AA_PORT_NOT_FREE):
            return port
    raise Exception, 'Could not locate SMBus interface device'
Ejemplo n.º 9
0
def _find_aardvark():
  (num, ports, unique_ids) = api.aa_find_devices_ext(16, 16)
  for port in ports:
    if not (port & api.AA_PORT_NOT_FREE):
      return port
  raise Exception, 'Could not locate SMBus interface device'