Recommendations for developing advanced compatible communications protocols?

I am working on a communication protocol between embedded devices. The protocol will certainly require new teams and fields in the future. What do I need to do so that I do not paint myself in the corner?

+3
source share
4 answers

This is a widely open question. Here are some random thoughts about this:

  • Leave stock.
  • Use a very simple header with the "number of bytes for later" field.
  • If message types are listed, make sure the type field can be placed growth.
  • If you use bit flags, leave spare parts.
  • , " ", .

, .

+6

, , . , ( Enter-mark Enter), , , , - , , :

__DATE__ ": " __TIME__

, .

, , . HTTP - - , , . , :

  • , . . .
  • CR + LF ( -).
  • , , .

. , ? - , Netstring?

+1

. , , :

? ? ? ?

, , , , . , , , / . ( ) .

0

HDLC. . , , , , .

HDLC . . 802.11

U8 cmd;
U8 len;
u8 payload[len];

len +2

#define TRIGGER_SENSOR 0x01
#define SENSOR_RESPONSE 0x02

, , undefined, .

, , .

 // total packet length minus flags len+4
 U8 sflag;   //0x7e start of packet end of packet flag from HDLC
 U8 cmd;     //tells the other side what to do.
 U8 len;     // payload length
 U8 payload[len];  // could be zero len
 U16 crc;
 U8 eflag;   //end of frame flag

0x7e, , , , pklen >= 4 pklen = len + 4, crc . . crc , , . crc reset crc . , . reset crc .

cmd len, . , , , .

So, for example, the touch device may have a timer or respond to a command to read. Then he formatted the packet and sent it to the PC, and the PC will reply that he received the packet. If not, the touch device can resend the wait time.

Also, when you are performing a network transfer, you must create it as a network stack, such as the OSI modle . HDLC is the data link layer , while RPC and command processing are the application layer .

0
source

Source: https://habr.com/ru/post/1751441/


All Articles