| 1 |
|
| 2 |
|
| 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 |
|
| 14 |
def 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 |
|
| 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 |
|
| 34 |
main() |