Commit | Line | Data |
---|---|---|
4b7a5e13 TJ |
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""" | |
4c5afeb9 | 12 | context = ftdi.new() |
4b7a5e13 | 13 | |
4c5afeb9 | 14 | version_info = ftdi.get_library_version() |
4b7a5e13 TJ |
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 | ||
4c5afeb9 MZ |
20 | print("ftdi.usb_open(): %d" % ftdi.usb_open(context, 0x0403, 0x6001)) |
21 | print("ftdi.set_baudrate(): %d" % ftdi.set_baudrate(context, 9600)) | |
4b7a5e13 | 22 | |
4c5afeb9 | 23 | ftdi.free(context) |
4b7a5e13 TJ |
24 | |
25 | main() |