print "***ReadI2C() failed with error: ", str(Error(qusb.LastError())) else: print "ReadI2C OK" # Test CachedWriteI2C c_data = CreateByteBuffer(64) (ok, ) = qusb.CachedWriteI2C(0x60, c_data, 64) if (not ok): print "***CachedWriteI2C() failed with error: ", str( Error(qusb.LastError())) else: print "CachedWriteI2C OK" # Test WriteI2C c_data = CreateByteBuffer(64) (ok, ) = qusb.WriteI2C(0x60, c_data, 64) if (not ok): print "***WriteI2C() failed with error: ", str(Error(qusb.LastError())) else: print "WriteI2C OK" if "storage" in test: # Test WriteStorage c_data = CreateByteBuffer(64) (ok, ) = qusb.WriteStorage(0, c_data, 64) if (not ok): print "***WriteStorage() failed with error: ", str( Error(qusb.LastError())) else: print "WriteStorage OK"
devName = modules[0] # Print out the name of each module found for x in modules: print "Found", x # Open the first device qusb = QuickUsb(devName) qusb.Open() # Write the starting address (0x0000) write_len = 2 i2c_write_data = CreateByteBuffer(write_len) i2c_write_data[0] = 0 i2c_write_data[1] = 0 (result, ) = qusb.WriteI2C(0x51, i2c_write_data, write_len) if (result == 0): print "Cannot write data to %s" % (devName) qusb.Close() sys.exit() print "Set starting I2C memory read address to 0x0000" # Read I2C bytes read_len = 8 i2c_read_data = CreateByteBuffer(read_len) (result, num_read) = qusb.ReadI2C(0x51, i2c_read_data, read_len) if (result == 0): print "Cannot read data from %s" % (devName) qusb.Close() sys.exit() print "Read {0} bytes of I2C data starting at 0x0000".format(read_len)