DPOT write all channels

 1'''
 2DPOT - DPOT_writeAllChannels.py with asynchronous mode.
 3
 4This example demonstrates how to write digital potentiometer resistance to all channel from EthanP.
 5-------------------------------------------------------------------------------------
 6Please change correct serial number or IP and port number BEFORE you run example code.
 7
 8For other examples please check:
 9    https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
10See README.md file to get detailed usage of this example.
11
12Copyright (c) 2022-2025 WPC Systems Ltd. All rights reserved.
13'''
14
15## WPC
16from wpcsys import pywpc
17
18
19def main():
20    ## Get Python driver version
21    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
22
23    ## Create device handle
24    dev = pywpc.EthanP()
25
26    ## Connect to device
27    try:
28        dev.connect("192.168.1.110")  ## Depend on your device
29    except Exception as err:
30        pywpc.printGenericError(err)
31        ## Release device handle
32        dev.close()
33        return
34
35    try:
36        ## Parameters setting
37        port = 0  ## Depend on your device
38        resistance_ratio = [0.5, 0.2, 0.8, 0.7]
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        ## Open DPOT
46        err = dev.DPOT_open(port, timeout)
47        print(f"DPOT_open in port {port}, status: {err}")
48
49        ## Write all channels
50        err = dev.DPOT_writeAllChannel(port, resistance_ratio, timeout)
51        print(f"DPOT_writeAllChannel in port {port}, status: {err}")
52
53        ## Close DPOT
54        err = dev.DPOT_close(port, timeout)
55        print(f"DPOT_close in port {port}, status: {err}")
56    except Exception as err:
57        pywpc.printGenericError(err)
58
59    finally:
60        ## Disconnect device
61        dev.disconnect()
62
63        ## Release device handle
64        dev.close()
65
66
67if __name__ == '__main__':
68    main()