CN115379020B - Embedded multi-machine communication protocol design method - Google Patents

Embedded multi-machine communication protocol design method Download PDF

Info

Publication number
CN115379020B
CN115379020B CN202210942307.8A CN202210942307A CN115379020B CN 115379020 B CN115379020 B CN 115379020B CN 202210942307 A CN202210942307 A CN 202210942307A CN 115379020 B CN115379020 B CN 115379020B
Authority
CN
China
Prior art keywords
data
frame
receiving end
check
bits
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210942307.8A
Other languages
Chinese (zh)
Other versions
CN115379020A (en
Inventor
丁腾腾
周旺平
徐德邻
吴海波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University of Information Science and Technology
Original Assignee
Nanjing University of Information Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University of Information Science and Technology filed Critical Nanjing University of Information Science and Technology
Priority to CN202210942307.8A priority Critical patent/CN115379020B/en
Publication of CN115379020A publication Critical patent/CN115379020A/en
Application granted granted Critical
Publication of CN115379020B publication Critical patent/CN115379020B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/18Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)

Abstract

The invention discloses a design method of a multi-machine communication protocol based on an embedded type, wherein the communication protocol consists of a frame header, data bits, a check mode, check bits and a frame tail, wherein the frame header ID consists of a single byte, the data bits consist of the ID of a receiving end, the data length and the data content of specific transmission, and the check bits and the frame tail check mode can be defined by users. The communication protocol design method perfects the custom communication protocol commonly used among the embedded systems, adds data bits of a verification mode into the protocol aiming at the difference among different embedded devices, can select different verification modes to verify the received data, adopts a flexible verification mode, ensures the accuracy and reliability of the transmitted data, ensures that the communication protocol is more flexible and complete, and realizes the communication of one-to-many embedded devices.

Description

Embedded multi-machine communication protocol design method
Technical Field
The invention relates to the technical field of electronics, communication and information engineering, in particular to a multi-machine communication protocol design method based on embedded type.
Background
The communication protocol refers to a convention by which two parties communicate for data transfer control. The conventions include unified regulations for data format, data length, data verification mode, frame header and frame tail, and the like, and the two parties must follow the regulations together.
In the paper of 'STMZET 6 and S7-1200 custom communication protocol realize serial communication' published in journal of industrial control computer, STM32 singlechip and Siemens S7-1200 series PLC realize serial communication of remote custom communication protocol. Its communication protocol consists of a single byte of a start, an identifier, data, a check and an end.
The above is a common setting of one-to-one single machine communication protocol, and generally consists of a single fixed byte frame header and frame tail, data content and check bits.
The existing embedded custom communication protocol has simple structure definition, cannot carry out one-to-many communication modes and has lower efficiency. And secondly, the verification mode is single, and a proper verification mode is not used for different embedded devices and the transmitted data length.
Disclosure of Invention
The invention aims to provide a design method of an embedded-type-based multi-machine communication protocol, which is characterized in that data bits of a verification mode are added into a protocol according to the differences among different embedded-type devices, the received data can be verified in different verification modes, and the accuracy and reliability of the transmitted data are ensured by adopting a flexible verification mode, so that the communication protocol is more flexible and complete, and one-to-many embedded-type device communication is realized.
The aim of the invention can be achieved by the following technical scheme:
the communication protocol consists of a frame header, data bits, a check mode, check bits and a frame tail, wherein the frame header ID consists of a single byte, the data bits consist of the ID of a receiving end, the data length and the specifically transmitted data content, and the check bits and the frame tail check mode can be defined by a user.
Further, the frame header defines the IDs of the sender and the receiver by the user, the sender can only have one, the receiver can have a plurality of bytes @ which are fixed characters, hexadecimal corresponding to the ASCI code of the @ character is 0x40, the third byte is the number of the receiver, the number corresponds to the number of the following bytes, the number is the ID of the receiver from the fourth byte, and the number of the IDs of the receiver is consistent with the number of the receivers.
Further, the data bits may correspond to different data through different receiving ends, the first byte of the data bits corresponds to the receiving end ID1, the second byte and the third byte of the data bits are the number of data to be received by the receiving end ID1, and are formed by two bytes, the second byte is the upper octet of the data length, and the third byte is the lower octet of the data length.
The two bytes together form the data length of the receiving end ID1, and the fourth byte is the data specifically received by the receiving end ID1, and its number corresponds to the length formed by the second and third bytes, followed by the receiving end I D2, which is formed as the same as the receiving end ID 1.
Further, the check bit and the check mode are selected according to the embedded device. The verification mode is user-defined, such as sum verification, BBC verification, CRC verification and other verification modes. The check bit is check data finally calculated according to different check modes. The data to be checked is all the data from the frame head to the previous check bit, that is, the other data are all involved in the check except that the last two bits do not need to be checked. The end of the frame consists of a fixed character $whose hexadecimal corresponding to the ASCI code is 0x24.
Further, the method for receiving data by the communication protocol receiving end comprises the following steps:
s1: the receiving end receives the data
After receiving the data, the receiving end ensures that a frame of complete data is received according to the frame head, the frame tail, the fixed characters and the data length.
S2: judging data
After receiving a frame of complete data, judging whether the frame of complete data is a frame of complete data, if not, returning to the step S1, and if so, carrying out the next step.
S3: judging frame head
The receiving end judges whether the data sent to the receiving end is available according to whether the ID of the receiving end in the frame head contains the ID of the receiving end through a frame of complete data; if the self-ID is not contained, the description is not addressed to itself, and the frame data is discarded.
S4: verifying data
And S3, judging that if the frame head contains the ID of the frame head, checking the received data according to a checking mode, comparing the received data with the check bit of the received data, and if the two data are consistent, receiving the data sent to the receiving end by the frame head. If the check is inconsistent with the received data check bit, the frame data is discarded.
The invention has the beneficial effects that:
1. the communication protocol design method perfects the custom communication protocol commonly used among the embedded systems, and aiming at the difference among different embedded devices, the data bit of the verification mode is added in the protocol, so that the received data can be verified by selecting different verification modes;
2. the communication protocol design method adopts a flexible verification mode, ensures the accuracy and the reliability of the transmission data, and ensures that the communication protocol is more flexible and complete;
3. the communication protocol design method of the invention realizes one-to-many embedded equipment communication.
Drawings
The invention is further described below with reference to the accompanying drawings.
FIG. 1 is a flow chart of a communication protocol receiving end receiving data according to the present invention;
FIG. 2 is a diagram of a connection between a master and a slave according to the method of designing a communication protocol of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1 and 2, an embedded multi-machine communication protocol design method is disclosed, wherein the communication protocol consists of a frame header, data bits, a check mode, check bits and a frame tail, the frame header ID consists of a single byte, the data bits consist of an ID of a receiving end, a data length and a specific transmitted data content, and the check bits and the check mode can be defined by a user.
The frame header defines the IDs of the sender and the receiver by the user, as shown in the following table:
sender ID @ Number of receivers Receiver ID1 Receiver ID2 Receiver ID3 ......
The number of the receiving ends is equal to the number of the receiving ends, wherein the number of the receiving ends is equal to 0x40, the number of the receiving ends is equal to the number of the receiving ends, and the number of the receiving ends is equal to the number of the receiving ends.
The data bit can correspond to different data through different receiving ends, as shown in the following table:
receiver ID1 Data length Data 1 Data 2 ...... Receiver ID2 Data length Data 1 ......
Wherein the first byte corresponds to the receiving end ID1, the second byte and the third byte are the number of data to be received by the receiving end ID1, and are composed of two bytes, the second byte is the high octet of the data length, the third byte is the low octet of the data length, the two bytes together form the data length of the receiving end ID1, the fourth byte is the data to be specifically received by the receiving end ID1, and the number of the data corresponds to the length formed by the second byte and the third byte, and then the receiving end ID2 is formed as the same as the receiving end ID 1.
The check mode of the check bit and the frame tail is selected according to the embedded equipment, and the check mode is shown in the following diagram:
verification mode Check bit $
The verification mode is defined by users, such as sum verification, BBC verification, CRC verification and other verification modes. The check bit is check data finally calculated according to different check modes. The data to be checked is all the data from the frame head to the previous check bit, that is, the other data are all involved in the check except that the last two bits do not need to be checked. The end of the frame consists of a fixed character $whose hexadecimal corresponding to the ASCII code is 0x24.
The method for receiving data by the communication protocol receiving end comprises the following steps:
s1: the receiving end receives the data
After receiving the data, the receiving end ensures that a frame of complete data is received according to the frame head, the frame tail, the fixed characters and the data length.
S2: judging data
After receiving a frame of complete data, judging whether the frame of complete data is a frame of complete data, if not, returning to the step S1, and if so, carrying out the next step.
S3: judging frame head
And judging whether the data sent to the receiver is available or not by the receiver according to whether the ID of the receiver in the frame head contains the ID of the receiver through one frame of complete data. If the self-ID is not contained, the description is not addressed to itself, and the frame data is discarded.
S4: verifying data
And S3, judging that if the frame head contains the ID of the frame head, checking the received data according to a checking mode, comparing the received data with the check bit of the received data, and if the two data are consistent, receiving the data sent to the receiving end by the frame head. If the check is inconsistent with the received data check bit, the frame data is discarded.
As shown in fig. 2, the ID of the sender is an 'R' character, the hexadecimal corresponding to the ASCII code is 0x52, and there are a plurality of receivers, but the receivers are respectively an 'M' and an 'S', the hexadecimal corresponding to the ASCII code is 0x4D and 0x53, and the transmitted data are respectively 0x11, 0x22, 0x33 and 0x77, 0x88 and 0x99.
The BBC check is adopted for the check, and the check is that the last two bits of data are not involved in the check, and other data are all involved in the check, and the check mode is represented by 1, so that the data sent by a frame according to a protocol sender are as follows:
[0x52、0x40、0x02、0x4D、0x53、0x4D、0x00、0x03、0x11、0x22、0x33、 0x53、0x00、0x03、0x77、0x88、0x99,0x01,0x77,0x24]。
in the description of the present specification, the descriptions of the terms "one embodiment," "example," "specific example," and the like, mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
The foregoing has shown and described the basic principles, principal features and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, and that the above embodiments and descriptions are merely illustrative of the principles of the present invention, and various changes and modifications may be made without departing from the spirit and scope of the invention, which is defined in the appended claims.

Claims (3)

1. The method is characterized in that the communication protocol consists of a frame header, data bits, a check mode, check bits and a frame tail, wherein the frame header ID consists of a single byte, the data bits consist of the ID of a receiving end, the data length and the specifically transmitted data content, and the check bits, the frame tail and the check mode can be defined by users;
the frame header defines the IDs of a sender and a receiver by a user, the sender can only have one, the receiver can have a plurality of bytes @ which are fixed characters, hexadecimal corresponding to an ASCII code of the @ character is 0x40, the third byte is the number of the receiver, the number corresponds to the number of the following bytes, the number of the bytes is the ID of the receiver from the fourth byte, and the number of the IDs of the receiver is consistent with the number of the receiver;
the data bit corresponds to different data through different receiving ends, the first byte of the data bit corresponds to the receiving end ID1, the second byte and the third byte of the data bit are the number of the data to be received by the receiving end ID1 and are composed of two bytes, the second byte is the high-order eight bits of the data length, and the third byte is the low-order eight bits of the data length;
the two bytes together form the data length of the receiving end ID1, the fourth byte is the data to be specifically received by the receiving end ID1, the number of which corresponds to the length formed by the second and third bytes, and then the receiving end ID2, which is formed as the same as the receiving end ID 1.
2. The method for designing a multi-machine communication protocol based on embedded type according to claim 1, wherein the check bit and the check mode are selected according to the embedded type device; the verification mode is user-defined, and the verification bits are verification data finally calculated according to different verification modes; the data to be checked is all data from the frame head to the front of the check bit, namely, other data are all involved in the check except that the last two bits do not need to be checked; the end of the frame consists of a fixed character $whose hexadecimal corresponding to the ASCII code is 0x24.
3. The method for designing a multi-machine communication protocol based on the embedded system according to claim 2, wherein the method for receiving data by the communication protocol receiving end comprises the following steps:
s1: the receiving end receives the data
After receiving the data, the receiving end ensures that a frame of complete data is received according to the frame head, the frame tail, the fixed characters and the data length;
s2: judging data
After receiving a frame of complete data, judging whether the frame of complete data is the frame of complete data, if not, returning to the step S1, and if so, carrying out the next step;
s3: judging frame head
The receiving end judges whether the data sent to the receiving end is available according to whether the ID of the receiving end in the frame head contains the ID of the receiving end through a frame of complete data; if the frame data does not contain the ID of the frame, the description is not sent to the frame data, and the frame data is discarded;
s4: verifying data
S3, judging that if the frame head contains the ID of the frame head, checking the received data according to a checking mode, comparing the received data with the check bit of the received data, and if the two data are consistent, receiving the data sent to the receiving end by the frame head; if the check is inconsistent with the received data check bit, the frame data is discarded.
CN202210942307.8A 2022-08-08 2022-08-08 Embedded multi-machine communication protocol design method Active CN115379020B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210942307.8A CN115379020B (en) 2022-08-08 2022-08-08 Embedded multi-machine communication protocol design method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210942307.8A CN115379020B (en) 2022-08-08 2022-08-08 Embedded multi-machine communication protocol design method

Publications (2)

Publication Number Publication Date
CN115379020A CN115379020A (en) 2022-11-22
CN115379020B true CN115379020B (en) 2023-06-09

Family

ID=84063825

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210942307.8A Active CN115379020B (en) 2022-08-08 2022-08-08 Embedded multi-machine communication protocol design method

Country Status (1)

Country Link
CN (1) CN115379020B (en)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1527561A (en) * 2003-09-22 2004-09-08 中兴通讯股份有限公司 RS-485 multipoint communication method
CN103188252A (en) * 2011-12-31 2013-07-03 中国科学院微电子研究所 Method for communication between central machine and test terminal of distributed test system
CN104009982A (en) * 2014-05-15 2014-08-27 北京航天发射技术研究所 File grouping and mass texting device based on ultra-short wave radio station and file grouping and mass texting method
CN104780619A (en) * 2015-04-08 2015-07-15 西北工业大学 Method for designing WLAN (wireless local area network) MAC (medium access control) layer protocol based on cooperative communication
CN105282101A (en) * 2014-06-28 2016-01-27 王金鹤 Data transmission protocol new algorithm
CN107147657A (en) * 2017-05-31 2017-09-08 飞智控(天津)科技有限公司 Suitable for the communication protocol of multimachine reliable communication, decoding method and communication apparatus
CN109211300A (en) * 2018-09-12 2019-01-15 山东省计算中心(国家超级计算济南中心) A kind of Hall sensor batch quickly detection and calibration system and its means of communication and application
CN110995686A (en) * 2019-11-26 2020-04-10 珠海泰芯半导体有限公司 Software communication protocol checking method
CN111711609A (en) * 2020-05-21 2020-09-25 重庆川仪自动化股份有限公司 Protocol design method in serial port communication
CN112015584A (en) * 2020-10-22 2020-12-01 中国人民解放军国防科技大学 Multi-hand fusion satellite-borne receiver single particle resistance method
CN113392060A (en) * 2021-06-16 2021-09-14 天津津航计算技术研究所 Universal serial port data receiving and processing method
CN114500652A (en) * 2022-04-18 2022-05-13 中国人民解放军国防科技大学 Method and device for designing high-reliability transmission protocol of internal data interface of satellite
CN114584483A (en) * 2021-12-30 2022-06-03 无锡兆勤自动化科技有限公司 Workshop field data real-time monitoring and anomaly detection method based on stream processing

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1527561A (en) * 2003-09-22 2004-09-08 中兴通讯股份有限公司 RS-485 multipoint communication method
CN103188252A (en) * 2011-12-31 2013-07-03 中国科学院微电子研究所 Method for communication between central machine and test terminal of distributed test system
CN104009982A (en) * 2014-05-15 2014-08-27 北京航天发射技术研究所 File grouping and mass texting device based on ultra-short wave radio station and file grouping and mass texting method
CN105282101A (en) * 2014-06-28 2016-01-27 王金鹤 Data transmission protocol new algorithm
CN104780619A (en) * 2015-04-08 2015-07-15 西北工业大学 Method for designing WLAN (wireless local area network) MAC (medium access control) layer protocol based on cooperative communication
CN107147657A (en) * 2017-05-31 2017-09-08 飞智控(天津)科技有限公司 Suitable for the communication protocol of multimachine reliable communication, decoding method and communication apparatus
CN109211300A (en) * 2018-09-12 2019-01-15 山东省计算中心(国家超级计算济南中心) A kind of Hall sensor batch quickly detection and calibration system and its means of communication and application
CN110995686A (en) * 2019-11-26 2020-04-10 珠海泰芯半导体有限公司 Software communication protocol checking method
CN111711609A (en) * 2020-05-21 2020-09-25 重庆川仪自动化股份有限公司 Protocol design method in serial port communication
CN112015584A (en) * 2020-10-22 2020-12-01 中国人民解放军国防科技大学 Multi-hand fusion satellite-borne receiver single particle resistance method
CN113392060A (en) * 2021-06-16 2021-09-14 天津津航计算技术研究所 Universal serial port data receiving and processing method
CN114584483A (en) * 2021-12-30 2022-06-03 无锡兆勤自动化科技有限公司 Workshop field data real-time monitoring and anomaly detection method based on stream processing
CN114500652A (en) * 2022-04-18 2022-05-13 中国人民解放军国防科技大学 Method and device for designing high-reliability transmission protocol of internal data interface of satellite

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"Modeling and verification of custom TCP using SDL";Kai Hu等;《2013 IEEE 4th International Conference on Software Engineering and Service Science》;全文 *
串行通信协议的研究与实现;张雷;梁建武;陈英;;现代计算机(第09期);全文 *

Also Published As

Publication number Publication date
CN115379020A (en) 2022-11-22

Similar Documents

Publication Publication Date Title
KR100615806B1 (en) Data receiving method for data link layer
US7984117B2 (en) Networking method and apparatus
WO2004107090A2 (en) Home network system
US20060248228A1 (en) Home network system
CN105187420A (en) Communication protocol matching method based on RS422 bus
CN112929367A (en) Protocol conversion method for Profinet network and industrial IPv6 backbone network
CN115379020B (en) Embedded multi-machine communication protocol design method
CN106027686B (en) Enhanced MODBUS communication method based on MPEG-2
US7844680B2 (en) Home network system
CN111628920B (en) Intercommunication method between multiple serial interface devices
AU2002303114A1 (en) Simultaneous serial transmission of messages with bit-arbitrated selection of the numerically largest or smallest value in the messages' data fields
CN106059715B (en) Multi-connected air conditioning unit and data transmission method and device thereof
CN112583676B (en) Information transmission method
CN111614612B (en) Communication protocol implementation method, device, network management server and storage medium
WO2022087795A1 (en) Resource mapping method and apparatus, device, and storage medium
WO2005094192A2 (en) Home network system
CN103368915A (en) CAN bus based communication method
CN109412868A (en) A kind of flight simulator network communication method based on dynamic socket
CN101174929A (en) Data compression method, device and automatic repeat request feedback system
CN116886800B (en) Communication method and storage medium based on HBES (heterojunction bipolar transistor) extension communication protocol
CN114189315B (en) Civil aircraft-mounted digital audio transmission system and method based on point-to-point Ethernet
CN113452646B (en) Method and device for transmitting data by user datagram protocol and electric automobile
CN111756607B (en) Message transmission method and device
CN101916512A (en) Intelligent traffic signal lamp
CN111365830A (en) Fan networking system based on RS-485 enhanced Modbus communication protocol

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant