Skip to main content

Ethernet Motion Server Sample Codes

Sending multiple ASCII commands to motor drives

import socket

def main():
host = '10.1.10.65'
port = 5000
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))
commands = [
's r0x70 2 0',
's r0xc8 256',
's r0xca 200000',
's r0xcb 1000000',
's r0xcc 2000000',
's r0xcd 2000000',
's r0x24 31',
't 1'
]
for command in commands:
sock.send(bytes('{0}\r'.format(command), encoding="utf-8"))
data = sock.recv(1024)
print('{}: {}'.format(command, data.decode('ascii')))

sock.close()

main()