Set device alias

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