-
-
Save daedalus/bdaf36204ff1860fecd6fc53d19119db to your computer and use it in GitHub Desktop.
read 16-bit EEPROMs over I2C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# read 16-bit EEPROMs over I2C. tested with 24FC512 and 24LC515 | |
import sys | |
import smbus | |
bus = smbus.SMBus(1) # /dev/i2c-1 | |
if len(sys.argv) < 3: | |
sys.stderr.write("usage: %s device_address size > filename\n" % (sys.argv[0],)) | |
raise SystemExit | |
device_address = int(sys.argv[1], 16) | |
size = int(sys.argv[2]) | |
memory_address = 0 | |
bus.write_byte(device_address, memory_address >> 8) | |
bus.write_byte(device_address, memory_address & 0xff) | |
for i in range(0,size): | |
byte = bus.read_byte(device_address) | |
sys.stdout.write(chr(byte)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment