DOBOT CR5 User Guide 6 Program Language
Issue V3.5.3.1 (2020-05-09) User Guide Copyright © Yuejiang Technology Co., Ltd
101
err, RecBuf = UDPRead(socket, 0) //Server receives the data from client
if err == 0 then
Go(P1) // Start to run motion commands after the server receives the data
Go(P2)
print(buf)
else
print("Read error ".. err)
break;
end
end
else
print("Create failed ".. err)
end
Program 6.4 UDP client demo
local ip="192.168.1.25" // IP address of the external equipment
as a server
local port=6200 // server port
local err=0
local socket=0
err, socket = UDPCreate(false, ip, port)
if err == 0 then
local RecBuf
while true do
UDPWrite(socket, "udp client test") // Client sends data to server
UDPWrite(socket, {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07})
err, RecBuf = UDPRead(socket, 0) // Client receives the data from server
if err == 0 then
Go(P1) // Start to run motion commands after the client receives the data
Go(P2)
print(buf)
else
print("Read error ".. err)
break
end