Example #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)
Example #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)
Example #3
0
def aa_close (aardvark):
    """usage: int return = aa_close(Aardvark aardvark)"""

    if not AA_LIBRARY_LOADED: return AA_INCOMPATIBLE_LIBRARY
    # Call API function
    return api.py_aa_close(aardvark)
Example #4
0
def aa_close (aardvark):
    """usage: int return = aa_close(Aardvark aardvark)"""

    if not AA_LIBRARY_LOADED: return AA_INCOMPATIBLE_LIBRARY
    # Call API function
    return api.py_aa_close(aardvark)
Example #5
0
 def close(self):
     '''close device
     '''
     api.py_aa_close(self.handle)
Example #6
0
 def close(self):
     '''close device
     '''
     api.py_aa_close(self.handle)