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