DOBOT CR5 User Guide 6 Program Language
Issue V3.5.3.1 (2020-05-09) User Guide Copyright © Yuejiang Technology Co., Ltd
100
err:
0: Receiving data is successful
1: Receiving data is failed
Recbuf: Data buffer
Please refer to Program 6.3 and Program 6.4
Table 6.52 Send data command
UDPWrite(socket, buf, timeout)
The robot as a client sends data to a server
The robot as a server sends data to a client
socket: Socket object
buf: Data sent by the robot
timeout: Timeout. Unit: s. If timeout is 0 or not set, this command is a block reading. Namely,
the program will not continue to run until sending data is complete. If not, after exceeding the
timeout, the program will continue to run regardless of whether sending data is complete
0: Sending data is successful
1: Sending data is failed
Please refer to Program 6.3 and Program 6.4
NOTICE
Only a single UDP connection is supported. Please start the server before connecting a
client. Please shut down the client before disconnection, to avoid re-connection failure
since the server port is not released in time.
Program 6.3 UDP server demo
local ip="192.168.5.1" // IP address of the robot as a server
local port=6201 // Server port
local err=0
local socket=0
err, socket = UDPCreate(true, ip, port)
if err == 0 then
local RecBuf
while true do
UDPWrite(socket, "udp server test") // Server sends data to client