1
2'''
3SNTP - SNTP configure.py with synchronous mode.
4
5This example demonstrates how to configure SNTP from EthanA.
6
7-------------------------------------------------------------------------------------
8Please change correct serial number or IP and port number BEFORE you run example code.
9
10For other examples please check:
11 https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
12See README.md file to get detailed usage of this example.
13
14Copyright (c) 2022-2025 WPC Systems Ltd. All rights reserved.
15'''
16
17## WPC
18from wpcsys import pywpc
19
20## Python
21import sys
22sys.path.insert(0, 'src/')
23
24
25def main():
26 ## Get Python driver version
27 print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
28
29 ## Create device handle
30 dev = pywpc.EthanA()
31
32 ## Connect to device
33 try:
34 dev.connect("192.168.1.110") ## Depend on your device
35 except Exception as err:
36 pywpc.printGenericError(err)
37 ## Release device handle
38 dev.close()
39 return
40
41 try:
42 ## Parameters setting
43 ip_addr = "255.255.255.255" ## Automatic search
44 period = 5 ## [sec]
45 timeout = 3 ## [sec]
46
47 ## Get firmware model & version
48 driver_info = dev.Sys_getDriverInfo(timeout)
49 print(f"Model name: {driver_info[0]}, Firmware version: {driver_info[-1]} ")
50
51 ## Set SNTP server IP
52 err = dev.SNTP_setServerIP(ip_addr, timeout)
53 print(f"SNTP_setServerIP, status: {err}")
54
55 ## Set SNTP period
56 err = dev.SNTP_setPeriod(period, timeout)
57 print(f"SNTP_setPeriod, status: {err}")
58
59 ## Sync now
60 err = dev.SNTP_syncNow(timeout)
61 print(f"SNTP_syncNow, status: {err}")
62 except Exception as err:
63 pywpc.printGenericError(err)
64
65 finally:
66 ## Disconnect device
67 dev.disconnect()
68
69 ## Release device handle
70 dev.close()
71
72
73if __name__ == '__main__':
74 main()