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-2025 WPC Systems Ltd. All rights reserved.
12'''
13
14## WPC
15from wpcsys import pywpc
16
17
18def main():
19 ## Get Python driver version
20 print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
21
22 ## Create device handle
23 dev = pywpc.EDriveST()
24
25 ## Connect to device
26 try:
27 dev.connect("192.168.1.110") ## Depend on your device
28 except Exception as err:
29 pywpc.printGenericError(err)
30 ## Release device handle
31 dev.close()
32 return
33
34 try:
35 ## Parameters setting
36 port = 0 ## Depend on your device
37 timeout = 3 ## [sec]
38
39 ## Get firmware model & version
40 driver_info = dev.Sys_getDriverInfo(timeout)
41 print(f"Model name: {driver_info[0]}, Firmware version: {driver_info[-1]} ")
42
43 ## Motion open
44 err = dev.Motion_open(port, timeout)
45 print(f"Motion_open, status: {err}")
46
47 ## Motion servo on
48 err = dev.Motion_enableServoOn(port, timeout)
49 print(f"Motion_enableServoOn, status: {err}")
50
51 except Exception as err:
52 pywpc.printGenericError(err)
53 except KeyboardInterrupt:
54 print("Press keyboard")
55 finally:
56 ## Motion stop
57 err = dev.Motion_stopProcess(port, timeout)
58 print(f"Motion_stopProcess, status: {err}")
59
60 ## Motion Servo off
61 err = dev.Motion_enableServoOff(port, timeout)
62 print(f"Motion_enableServoOff, status: {err}")
63
64 ## Motion close
65 err = dev.Motion_close(port, timeout)
66 print(f"Motion_close, status: {err}")
67
68 ## Disconnect device
69 dev.disconnect()
70
71 ## Release device handle
72 dev.close()
73
74
75if __name__ == '__main__':
76 main()