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