Scan to FollowLearn Embedded Together, learn and grow together
Current Topic
Some embedded devices need to communicate with other devices for data transmission. To ensure reliable data transfer, it is often necessary to establish a fixed format for the communication data frame. Both parties need to organize and parse data according to the established format.
So, how do we establish such a data communication interface protocol?
Let’s discuss
Today, we will briefly discuss several aspects of formulating data communication interface protocols.
(1) Communication parameter configuration. Common physical interfaces for communication between devices include serial ports and network ports, which explain the configuration information of the communication interface, such as serial port parameters, network data transmission protocols, network port numbers, etc.
(2) Format of communication data frames. Agree on the frame format of the data packet, such as data frame header, data field length, data content, frame check, and data frame tail. The data sender and receiver parse and encode according to the frame format.
(3) Choose a suitable data frame check algorithm, such as CRC-16 check, BCC check, CS checksum, etc.
(4) Specify the communication method. If it is TCP communication over a network port, it needs to specify whether the device is a server or a client.
(5) Formulate control commands. Based on the device control situation, formulate specific control command values and indicate the purpose of the commands. For example, initialization commands, heartbeat commands, command responses, etc.
(6) Provide detailed content of the command data field. This part is used to give detailed control command contents, including control command values and parameters carried by the commands. Each part of the data field needs to be explained specifically to facilitate both parties in writing corresponding processing function codes.
(7) Command control flow. To facilitate understanding of the device control flow, sometimes a simple command send/receive flow diagram is drawn, which is more intuitive.
(8) Other requirements. If there are other considerations or special requirements for the communication protocol, clear textual explanations need to be provided to avoid misunderstandings between both parties.
Alright, that’s about it. Thank you for reading, keep it up~
If you find the article good, click “Share”, “Like”, “Read”!