X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=examples%2Fpython%2Fcomplete.py;h=cf60d4d31e7fafd7e275df72fdd3b05ce54f269f;hp=2bab44d51173dd3f1b134a12e82057909dd3058e;hb=50280d45a136b6915dfdd06843f5f847a7ca468a;hpb=b3f439b157caa175b276d59c991354d90d88d7c6 diff --git a/examples/python/complete.py b/examples/python/complete.py index 2bab44d..cf60d4d 100644 --- a/examples/python/complete.py +++ b/examples/python/complete.py @@ -17,26 +17,24 @@ ftdic = ftdi.new() if ftdic == 0: print 'new failed: %d', ret os._exit( 1 ) - + + # list all devices -devlist = ftdi.new_device_listpp() -ret = ftdi.usb_find_all( ftdic, devlist, 0x0403, 0x6001 ) +ret, devlist = ftdi.usb_find_all( ftdic, 0x0403, 0x6001 ) if ret < 0: print 'ftdi_usb_find_all failed: %d (%s)' % ( ret, ftdi.get_error_string( ftdic ) ) os._exit( 1 ) print 'Number of FTDI devices found: %d\n' % ret -count = ret -curdev = devlist -for i in range( count ): - print 'Checking device: %d' % i - - curnode = ftdi.device_listpp_value( curdev ) - ret, manufacturer, description, serial = ftdi.usb_get_strings( ftdic, curnode.dev, 128, 128, 128 ) +curnode = devlist +i = 0 +while( curnode != None ): + ret, manufacturer, description, serial = ftdi.usb_get_strings( ftdic, curnode.dev ) if ret < 0: print 'ftdi_usb_get_strings failed: %d (%s)' % ( ret, ftdi.get_error_string( ftdic ) ) os._exit( 1 ) - print 'Manufacturer: %s, Description: %s, Serial: %s\n' % ( manufacturer, description, serial ) - ftdi.device_listpp_assign( curdev, curnode.next ) + print 'Device #%d: manufacturer="%s" description="%s" serial="%s"\n' % ( i, manufacturer, description, serial ) + curnode = curnode.next + i += 1 # open usb ret = ftdi.usb_open( ftdic, 0x0403, 0x6001 ) @@ -57,8 +55,8 @@ print 'turning everything off\n' ftdi.write_data( ftdic, chr(0x00), 1 ) time.sleep( 1 ) for i in range( 8 ): - print 'enabling bit', i val = 2**i + print 'enabling bit #%d (0x%02x)' % (i, val) ftdi.write_data( ftdic, chr(val), 1 ) time.sleep ( 1 ) ftdi.disable_bitbang( ftdic ) @@ -73,13 +71,19 @@ print 'FDTI chip id: %X\n' % chipid # read eeprom eeprom_addr = 1 ret, eeprom_val = ftdi.read_eeprom_location( ftdic, eeprom_addr ) -print 'eeprom @ %d: 0x%04x\n' % ( eeprom_addr, eeprom_val ) - -print 'eeprom:' -ret=ftdi.read_eeprom( ftdic ) -ret=ftdi.eeprom_decode( ftdic ,1) - - +if (ret==0): + print 'eeprom @ %d: 0x%04x\n' % ( eeprom_addr, eeprom_val ) + +print 'complete eeprom:' +ret = ftdi.read_eeprom( ftdic ) +ret, eeprom = ftdi.get_eeprom_buf ( ftdic ) +if ( ret == 0 ): + for i in range( 128 ): + print '%02x' % ord( eeprom[i] ), + if ( i % 8 == 7 ): + print '' + + # close usb ret = ftdi.usb_close( ftdic ) if ret < 0: