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