System get network info

 1'''
 2System_ETH - get_network_info.py with synchronous mode.
 3
 4This example demonstrates how to get hardware & network information from EthanA.
 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-2024 WPC Systems Ltd. All rights reserved.
17'''
18
19## Python
20import time
21
22## WPC
23
24from wpcsys import pywpc
25
26def main():
27    ## Get Python driver version
28    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
29
30    ## Create device handle
31    dev = pywpc.EthanA()
32
33    ## Connect to device
34    try:
35        dev.connect("192.168.1.110") ## Depend on your device
36    except Exception as err:
37        pywpc.printGenericError(err)
38        ## Release device handle
39        dev.close()
40        return
41
42    try:
43        ## Parameters setting
44        timeout = 3 ## second
45
46        ## Get firmware model & version
47        driver_info = dev.Sys_getDriverInfo(timeout)
48        print("Model name: " + driver_info[0])
49        print("Firmware version: " + driver_info[-1])
50
51        ## Get IP & submask
52        ip_addr, submask = dev.Net_getIPAddrAndSubmask(timeout)
53        print(f"IP: {ip_addr}")
54        print(f"Submask: {submask}")
55
56        ## Get MAC
57        mac = dev.Net_getMACAddr(timeout)
58        print(f"MAC: {mac}")
59    except Exception as err:
60        pywpc.printGenericError(err)
61
62    ## Disconnect network device
63    dev.disconnect()
64
65    ## Release device handle
66    dev.close()
67
68    return
69
70if __name__ == '__main__':
71    main()