1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4"""Python example program. 5 6Small program to demonstrate the usage 7of the swig generated python wrapper 8 9You need to build and install the wrapper first""" 10 11import ftdi1 as ftdi 12 13 14def main(): 15 """Main program""" 16 context = ftdi.new() 17 18 version_info = ftdi.get_library_version() 19 print("[FTDI version] major: %d, minor: %d, micro: %d" 20 ", version_str: %s, snapshot_str: %s" % 21 (version_info.major, version_info.minor, version_info.micro, 22 version_info.version_str, version_info.snapshot_str)) 23 24 # try to open an ftdi 0x6010 or 0x6001 25 ret = ftdi.usb_open(context, 0x0403, 0x6010) 26 if ret < 0: 27 ret = ftdi.usb_open(context, 0x0403, 0x6001) 28 29 print("ftdi.usb_open(): %d" % ret) 30 print("ftdi.set_baudrate(): %d" % ftdi.set_baudrate(context, 9600)) 31 32 ftdi.free(context) 33 34main() 35