Drive servo on

 1'''
 2Drive - Drive_servo_on.py with synchronous mode.
 3
 4-------------------------------------------------------------------------------------
 5Please change correct serial number or IP and port number BEFORE you run example code.
 6
 7For other examples please check:
 8    https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
 9See README.md file to get detailed usage of this example.
10
11Copyright (c) 2022-2024 WPC Systems Ltd. All rights reserved.
12'''
13
14## Python
15import time
16
17## WPC
18
19from wpcsys import pywpc
20
21def main():
22    ## Get Python driver version
23    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
24
25    ## Create device handle
26    dev = pywpc.EDriveST()
27
28    ## Connect to device
29    try:
30        dev.connect("192.168.1.110") ## Depend on your device
31    except Exception as err:
32        pywpc.printGenericError(err)
33        ## Release device handle
34        dev.close()
35        return
36
37    try:
38        ## Parameters setting
39        port = 0 ## Depend on your device
40        timeout = 3 ## second
41
42        ## Get firmware model & version
43        driver_info = dev.Sys_getDriverInfo(timeout)
44        print("Model name: " + driver_info[0])
45        print("Firmware version: " + driver_info[-1])
46
47        ## Motion open
48        err = dev.Motion_open(port, timeout)
49        print(f"Motion_open, status: {err}")
50
51        ## Motion servo on
52        err = dev.Motion_enableServoOn(port, timeout)
53        print(f"Motion_enableServoOn, status: {err}")
54
55    except Exception as err:
56        pywpc.printGenericError(err)
57    except KeyboardInterrupt:
58        print("Press keyboard")
59    finally:
60        ## Motion stop
61        err = dev.Motion_stopProcess(port, timeout)
62        print(f"Motion_stopProcess, status: {err}")
63
64        ## Motion Servo off
65        err = dev.Motion_enableServoOff(port, timeout)
66        print(f"Motion_enableServoOff, status: {err}")
67
68        ## Motion close
69        err = dev.Motion_close(port, timeout)
70        print(f"Motion_close, status: {err}")
71
72    ## Disconnect device
73    dev.disconnect()
74
75    ## Release device handle
76    dev.close()
77
78if __name__ == '__main__':
79    main()