DOBOT CR5 User Guide 6 Program Language
Issue V3.5.3.1 (2020-05-09) User Guide Copyright © Yuejiang Technology Co., Ltd
98
else
print("Read error ".. err)
break
end
end
else
print("Create failed ".. err)
end
TCPDestroy(socket)
else
print("Create failed ".. err)
end
Program 6.2 TCP client demo
local ip="192.168.5.25" // External equipment such as a camera is set as the server
local port=6001 // Server port
local err=0
local socket=0
err, socket = TCPCreate(false, ip, port)
if err == 0 then
err = TCPStart(socket, 0)
if err == 0 then
local RecBuf
while true do
TCPWrite(socket, "tcp client test") // Client sends data to server
TCPWrite(socket, {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07})
err, RecBuf = TCPRead(socket, 0) // Client receives 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
end