From 6af0c706c1dd1b0ae4cbc38adf1f056a8686aae4 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 23 Dec 2016 10:34:08 +0100 Subject: [PATCH] bus_pirate: fix i2c addr handling --- bus_pirate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bus_pirate.py b/bus_pirate.py index f64c8e3..4ef9c61 100644 --- a/bus_pirate.py +++ b/bus_pirate.py @@ -135,7 +135,7 @@ class BP: def i2c_write(self, addr, reg, s): # 1. Write # command (1) | number of write bytes (2) | number of read bytes (2) | bytes to write (0..) - msg = struct.pack(">BHHBB%ds" % len(s), 0x08, 2+len(s), 0, addr<<1, reg, s) + msg = struct.pack(">BHHBB%ds" % len(s), 0x08, 2+len(s), 0, addr, reg, s) ret = self.command(msg, 1) if ord(ret[0]) != 0x1: @@ -146,7 +146,7 @@ class BP: self.i2c_write(addr, reg, "") # command (1) | number of write bytes (2) | number of read bytes (2) | bytes to write (0..) - msg = struct.pack(">BHHB", 0x08, 1, num_read, (addr<<1) | 0x1) + msg = struct.pack(">BHHB", 0x08, 1, num_read, addr | 0x1) ret = self.command(msg, 1 + num_read) if ord(ret[0]) != 0x1: @@ -156,7 +156,7 @@ class BP: def i2c_search(self): for i in range(128): - msg = struct.pack(">BHHB", 0x08, 1, 1, i<<1) + msg = struct.pack(">BHHB", 0x08, 1, 1, i) ret = self.command(msg, 1) if ord(ret) == 0x1: print "Found I2C Addr: 0x%x" % (i & ~0x1) -- 2.39.5