if __name__ == '__main__': # initialize ftdic = ftdi.new() if ftdic == 0: print 'new failed: %d', ret os._exit( 1 ) version_info = ftdi.get_library_version() print("\nlibFTDI version = major: %d, minor: %d, micro: %d" \ ", version_str: %s, snapshot_str: %s\n" % (version_info.major, version_info.minor, version_info.micro, version_info.version_str, version_info.snapshot_str)) # list all devices ret, devlist = ftdi.usb_find_all( ftdic, DEVICE_VID, DEVICE_PID ) 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 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 'Device #%d: manufacturer="%s" description="%s" serial="%s"\n' % ( i, manufacturer, description, serial ) curnode = curnode.next i += 1
if __name__ == '__main__': # initialize ftdic = ftdi.new() if ftdic == 0: print 'new failed: %d', ret os._exit(1) version_info = ftdi.get_library_version() print("\nlibFTDI version = major: %d, minor: %d, micro: %d" \ ", version_str: %s, snapshot_str: %s\n" % (version_info.major, version_info.minor, version_info.micro, version_info.version_str, version_info.snapshot_str)) # list all devices ret, devlist = ftdi.usb_find_all(ftdic, DEVICE_VID, DEVICE_PID) 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 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 'Device #%d: manufacturer="%s" description="%s" serial="%s"\n' % (
of the swig generated python wrapper You need to build and install the wrapper first""" import os import ftdi import time # initialize ftdic = ftdi.new() if ftdic == 0: print 'new failed: %d', ret os._exit(1) # list all devices 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 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 'Device #%d: manufacturer="%s" description="%s" serial="%s"\n' % (
You need to build and install the wrapper first""" import os import ftdi import time # initialize ftdic = ftdi.new() if ftdic == 0: print 'new failed: %d', ret os._exit( 1 ) # list all devices 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 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 'Device #%d: manufacturer="%s" description="%s" serial="%s"\n' % ( i, manufacturer, description, serial ) curnode = curnode.next i += 1