1'''
2AHRS - AHRS_getAcceleration.py with synchronous mode.
3
4This example demonstrates the process of getting AHRS three axis acceleration data from WifiDAQE3AH.
5
6To begin with, it demonstrates the steps to open the AHRS and configure the AHRS parameters.
7Next, it outlines the procedure for the AHRS acceleration data.
8Finally, it concludes by explaining how to close the AHRS.
9
10-------------------------------------------------------------------------------------
11Please change correct serial number or IP and port number BEFORE you run example code.
12
13For other examples please check:
14 https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
15See README.md file to get detailed usage of this example.
16
17Copyright (c) 2022-2025 WPC Systems Ltd. All rights reserved.
18'''
19
20## WPC
21from wpcsys import pywpc
22
23
24def main():
25 ## Get Python driver version
26 print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
27
28 ## Create device handle
29 dev = pywpc.WifiDAQE3AH()
30
31 ## Connect to device
32 try:
33 dev.connect("192.168.5.38") ## Depend on your device
34 except Exception as err:
35 pywpc.printGenericError(err)
36 ## Release device handle
37 dev.close()
38 return
39
40 try:
41 ## Parameters setting
42 port = 0 ## Depend on your device
43 timeout = 3 ## [sec]
44
45 ## Get firmware model & version
46 driver_info = dev.Sys_getDriverInfo(timeout)
47 print(f"Model name: {driver_info[0]}, Firmware version: {driver_info[-1]} ")
48
49 ## Open AHRS and update rate is 333 HZ
50 err = dev.AHRS_open(port, timeout)
51 print(f"AHRS_open in port {port}, status: {err}")
52
53 ## Start AHRS
54 err = dev.AHRS_start(port, timeout)
55 print(f"AHRS_start in port {port}, status: {err}")
56
57 ## Get three axis acceleration
58 while True:
59 data = dev.AHRS_getAcceleration(port, timeout)
60 print(data)
61 except KeyboardInterrupt:
62 print("Press keyboard")
63
64 except Exception as err:
65 pywpc.printGenericError(err)
66
67 finally:
68 ## Stop AHRS
69 err = dev.AHRS_stop(port, timeout)
70 print(f"AHRS_stop in port {port}, status: {err}")
71
72 ## Close AHRS
73 err = dev.AHRS_close(port, timeout)
74 print(f"AHRS_close in port {port}, status: {err}")
75
76 ## Disconnect device
77 dev.disconnect()
78
79 ## Release device handle
80 dev.close()
81
82
83if __name__ == '__main__':
84 main()