Exemple #1
0
def main():
    """Main program"""
    context = ftdi.new()

    version_info = ftdi.get_library_version()
    print("[FTDI version] major: %d, minor: %d, micro: %d" \
               ", version_str: %s, snapshot_str: %s" %
               (version_info.major, version_info.minor, version_info.micro,
               version_info.version_str, version_info.snapshot_str))

    print("ftdi.usb_open(): %d" % ftdi.usb_open(context, 0x0403, 0x6010))
    print("ftdi.set_baudrate(): %d" % ftdi.set_baudrate(context, 9600))

    ftdi.free(context)
Exemple #2
0







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 )
Exemple #3
0
        for i in range(ret):
            st += '0x%02X,' % ord(data[i])
        print "Received:", st, "ret=", ret, "\n"
    if (DEBUG_LEVEL > 0):
        print "Data written to address 0x%04X" % address, "= 0x%02X" % int(
            databyte), "\n"


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):