def read_chipid(myargs): """read the chip id""" ret, chipid = ftdi.read_chipid(myargs.ctx) if ret == 0: output("chip id: {:x}".format(chipid))
#print( 'enabling bit #%d (0x%02x)' % (i, val) ) #ftdi.write_data( ftdic, chr(val), 1 ) #time.sleep ( 1 ) #ftdi.disable_bitbang( ftdic ) #print( '' ) # read pins # FIXME: read_pins fails with python3, so I disabled it for now # tested on ubuntu 12.04 ( python3.2.3 / swig 2.0.4 ) if (sys.version_info[0] < 3): ret, pins = ftdi.read_pins(ftdic) if (ret == 0): print('pins: %02x' % ord(pins[0])) # read chip id ret, chipid = ftdi.read_chipid(ftdic) if (ret == 0): print('chip id: %X\n' % chipid) # read eeprom eeprom_addr = 1 ret, eeprom_val = ftdi.read_eeprom_location(ftdic, eeprom_addr) if (ret == 0): print('eeprom @ %d: 0x%04x\n' % (eeprom_addr, eeprom_val)) print('eeprom:') ret = ftdi.read_eeprom(ftdic) size = 128 ret, eeprom = ftdi.get_eeprom_buf(ftdic, size) if (ret == 0): for i in range(size):
ftdi.disable_bitbang(ftdic) print('') # read pins ret, pins = ftdi.read_pins(ftdic) if (ret == 0): if sys.version_info[0] < 3: # python 2 pins = ord(pins) else: pins = pins[0] print('pins: 0x%x' % pins) # read chip id ret, chipid = ftdi.read_chipid(ftdic) if (ret == 0): print('chip id: %x\n' % chipid) # read eeprom eeprom_addr = 1 ret, eeprom_val = ftdi.read_eeprom_location(ftdic, eeprom_addr) if (ret == 0): print('eeprom @ %d: 0x%04x\n' % (eeprom_addr, eeprom_val)) print('eeprom:') ret = ftdi.read_eeprom(ftdic) size = 128 ret, eeprom = ftdi.get_eeprom_buf(ftdic, size) if (ret == 0):