def testMultiByteRead(self): data = [0x10, 0x01] self.readTestHelper(data) self.mox.ReplayAll() self.bbi2c = bbi2c.BBi2c({'bus_num': 2}) result = self.bbi2c.wr_rd(SLAVE_ADDRESS, [DATA_ADDRESS], len(data)) self.assertEquals(result, data)
def testWriteAndRead(self): wr_data = [DATA_ADDRESS, 0x8, 0x9] rd_data = [0x10, 0x01] self.singleWriteTestHelper(wr_data) self.readTestHelper(rd_data, send_address=False) self.mox.ReplayAll() self.bbi2c = bbi2c.BBi2c({'bus_num': 2}) result = self.bbi2c.wr_rd(SLAVE_ADDRESS, wr_data, len(rd_data)) self.assertEquals(result, rd_data)
def testBlockWriteFailure(self): data = [0x7, 0x8, 0x9, 0x10, 0x11, 0x12, 0x13] self.mox.ReplayAll() self.bbi2c = bbi2c.BBi2c({'bus_num': 2}) with self.assertRaises(bbi2c.BBi2cError): self.bbi2c.wr_rd(SLAVE_ADDRESS, data, 0)
def testThreeByteWrite(self): data = [0x7, 0x8, 0x9] self.singleWriteTestHelper(data) self.mox.ReplayAll() self.bbi2c = bbi2c.BBi2c({'bus_num': 2}) self.bbi2c.wr_rd(SLAVE_ADDRESS, data, 0)
def _init_bb_i2c(self, interface): """Initalize beaglebone i2c interface.""" return bbi2c.BBi2c(interface)