Пример #1
0
    def open(self, portnum=None, serialnumber=None):
        '''
        find ports, and open the port with portnum or sn,
        config the aardvark tool params like bitrate, slave address etc,
        '''
        ports = self.find_devices()
        logging.debug("find ports: " + str(ports))
        self.port = None
        if(serialnumber):
            for port in ports:
                handle = api.py_aa_open(port)
                if(api.py_aa_unique_id(handle) == serialnumber):
                    logging.debug("SN: " + str(api.py_aa_unique_id(handle)))
                    self.port = port
                    api.py_aa_close(handle)
                    break
                api.py_aa_close(handle)
            if(self.port is None):
                raise_aa_ex(-601)
        elif(portnum):
            self.port = portnum
        else:
            self.port = 0

        logging.debug("open: " + str(self.port))
        self.handle = api.py_aa_open(self.port)

        if(self.handle <= 0):
            raise_aa_ex(self.handle)
        # Ensure that the I2C subsystem is enabled
        api.py_aa_configure(self.handle,  I2CConfig.AA_CONFIG_SPI_I2C)
        api.py_aa_i2c_pullup(self.handle, I2CConfig.AA_I2C_PULLUP_BOTH)
        api.py_aa_target_power(self.handle, I2CConfig.AA_TARGET_POWER_NONE)
        # Set the bitrate, in khz
        self.bitrate = api.py_aa_i2c_bitrate(self.handle, self.bitrate)
        # Set the bus lock timeout, in ms
        api.py_aa_i2c_bus_timeout(self.handle, self.bus_timeout)
        # Free bus
        api.py_aa_i2c_free_bus(self.handle)
Пример #2
0
    def open(self, portnum=None, serialnumber=None):
        '''
        find ports, and open the port with portnum or sn,
        config the aardvark tool params like bitrate, slave address etc,
        '''
        ports = self.find_devices()
        logging.debug("find ports: " + str(ports))
        self.port = None
        if (serialnumber):
            for port in ports:
                handle = api.py_aa_open(port)
                if (api.py_aa_unique_id(handle) == serialnumber):
                    logging.debug("SN: " + str(api.py_aa_unique_id(handle)))
                    self.port = port
                    api.py_aa_close(handle)
                    break
                api.py_aa_close(handle)
            if (self.port is None):
                raise_aa_ex(-601)
        elif (portnum):
            self.port = portnum
        else:
            self.port = 0

        logging.debug("open: " + str(self.port))
        self.handle = api.py_aa_open(self.port)

        if (self.handle <= 0):
            raise_aa_ex(self.handle)
        # Ensure that the I2C subsystem is enabled
        api.py_aa_configure(self.handle, I2CConfig.AA_CONFIG_SPI_I2C)
        api.py_aa_i2c_pullup(self.handle, I2CConfig.AA_I2C_PULLUP_BOTH)
        api.py_aa_target_power(self.handle, I2CConfig.AA_TARGET_POWER_NONE)
        # Set the bitrate, in khz
        self.bitrate = api.py_aa_i2c_bitrate(self.handle, self.bitrate)
        # Set the bus lock timeout, in ms
        api.py_aa_i2c_bus_timeout(self.handle, self.bus_timeout)
        # Free bus
        api.py_aa_i2c_free_bus(self.handle)
Пример #3
0
def aa_unique_id (aardvark):
    """usage: u32 return = aa_unique_id(Aardvark aardvark)"""

    if not AA_LIBRARY_LOADED: return AA_INCOMPATIBLE_LIBRARY
    # Call API function
    return api.py_aa_unique_id(aardvark)
Пример #4
0
def aa_unique_id (aardvark):
    """usage: u32 return = aa_unique_id(Aardvark aardvark)"""

    if not AA_LIBRARY_LOADED: return AA_INCOMPATIBLE_LIBRARY
    # Call API function
    return api.py_aa_unique_id(aardvark)
Пример #5
0
 def unique_id(self):
     """Return the unique identifier of the device. The identifier is the
     serial number you can find on the aapter without the ash. Eg. the
     serial number 0012-345678 would be 12345678.
     """
     return api.py_aa_unique_id(self.handle)
Пример #6
0
 def unique_id(self):
     """Return the unique identifier of the device. The identifier is the
     serial number you can find on the aapter without the ash. Eg. the
     serial number 0012-345678 would be 12345678.
     """
     return api.py_aa_unique_id(self.handle)