IOT-WORKSHOP
DTU-H10X
Wi-Fi/Ethernet to RS485/RS232 Server User Manual
http://www.iotworkshop.com
22
3.2.2.
Agreement(Serial Command Mode)
In this mode, the user can send the serial data to a different server address, this mode can use
UDP or TCP client to send data to server.
Customer MCU send packets according to the following format. The device will parse the
received serial data and send only the data to ther destination address. When data is received
from server, the device will output it directly.
Table 7 Serial Command Mode
Frame
Header
Length
Function
Byte
Backup
Data Area
Destination
Port
Target
Address
Data
Check
Sum
Bytes
2
2(5+m+n)
1
2
2
m
n
1
Frame Header:
0x55 0xAA (Constant value)
Length:
Start from the function byte to check sum(does not contain the check sum). High byte first.
Function Byte:
Bit0:
(0-UDP, 1-TCP),
Bit1:
(0-Short Connection, 1-Long Connection), if it is a short connection, it sends data, and
then disconnected; if it is a long connection, it sends data and keep the connection until receive
new data to change the target address. Valid only in TCP communication.
Bit2:
(0-IP, 1-Domain Name), Indicate that the target address is IP or domain name. If it is
IP, the target address is 4 bytes. If it is domain name, the target address length includes the
entire domain name string length(the last byte address is '\0', the end of the string).
Backup Data Area:
Byte 1:
If it is a short connection, this position is TCP waits for the timeout time (1-255), if
the device do not receive a response data after the data has been sent, then it wait a few
seconds and the close the connection, e.g this byte is set as 5, then the device will wait from 5
seconds to receive data. If it receive data, then the connection is closed right away. If it is a long
connection, this byte should be 0.
Byte 2:
Reserved.
Destination Port:
Little endian, low byte first, e.g the destination port is 23, then the data flow should be
【
0x17 0x00
】
Target Address:
If it is IP, it is 4 bytes, e.g
【
192.168.0.7
】
should be
【
0x07 0x00 0xA8 0xC0
】
. If it is a
domain, then the address length should include the ending character '\0' .