AxsunOCTControl_LW 2.0.0
A light-weight & cross-platform alternative to the .NET-based AxsunOCTControl.dll.
Loading...
Searching...
No Matches
AxsunOCTControl_LW_Python_example.py

This example source code and the aoclw_wrapper.py wrapper file show how to integrate the AxsunOCTControl_LW API in a Python client application via the ctypes library (https://docs.python.org/3/library/ctypes.html).

1
2import sys, time
3from ctypes import cast, py_object
4from aoclw_wrapper import AOCLW_wrapper_class, AxErr
5
6
7def ConnectCallbackFunction(userdata):
8 obj = cast(userdata, py_object).value
9 count = obj.CountDevices()
10 print("Devices connected: " + str(count))
11 for i in range(0, count):
12 print(str(i) + ") "
13 + obj.GetDeviceType(i) + "\t"
14 + obj.GetSerialNum(i) + "\tFW: "
15 + obj.GetFirmwareVersion(i) + "\tvia "
16 + obj.GetConnectionType(i))
17
18
19try:
20 axsun_control = AOCLW_wrapper_class()
21 print("Loaded AxsunOCTControl_LW version: " + axsun_control.LWLibVersion() + ", " + axsun_control.axLWBuildDateTime())
22
23 axsun_control.RegisterCallback(ConnectCallbackFunction, axsun_control)
24
25 axsun_control.OpenUSBInterface(1)
26 axsun_control.OpenNetworkInterface(1)
27
28 time.sleep(1)
29 print("\nWhen DAQ is connected, press ENTER to continue... \n")
30 input() # wait for user input
31
32 axsun_control.SetFPGARegister(60, 42, 0) # set a register (60) to a value (42)
33 print(str(axsun_control.GetFPGARegister(60, 0))) # read back register (60) and print to verify value was written
34 axsun_control.SetFPGARegister(60, 0, 0) # set a register (60) to a value (0)
35 print(str(axsun_control.GetFPGARegister(60, 0))) # read back register (60) and print to verify value was written
36
37 # add as many register reads/writes as needed here
38 # ...
39 # ...
40
41except AxErr as error:
42 print(error)
43