CN109728879B - Synchronous error correction method for serial burst access application layer SLIP protocol message - Google Patents
Synchronous error correction method for serial burst access application layer SLIP protocol message Download PDFInfo
- Publication number
- CN109728879B CN109728879B CN201910044479.1A CN201910044479A CN109728879B CN 109728879 B CN109728879 B CN 109728879B CN 201910044479 A CN201910044479 A CN 201910044479A CN 109728879 B CN109728879 B CN 109728879B
- Authority
- CN
- China
- Prior art keywords
- message
- serial port
- byte
- pflag
- synchronous
- 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
Links
Images
Landscapes
- Communication Control (AREA)
Abstract
The invention discloses a synchronous error correction method for a serial burst access application layer SLIP protocol message, which comprises the steps of carrying out initial synchronous capture on a received byte according to the structural characteristics and the format characteristics of the SLIP protocol message, starting matching analysis from the first received byte, and directly discarding the received byte if the received byte is not a starting or ending identifier of a protocol; once the synchronization information is captured, due to the fact that the pseudo-synchronization condition exists in the synchronization information, the authenticity of the synchronization information needs to be further discriminated; and the first correct synchronization obtained after the discrimination is carried out, so that pseudo-synchronization errors before the pseudo-synchronization is skipped out, the message semantics can be recognized, and the normal two-way communication between the two parties can be recovered. The invention has the beneficial effects that: any serial port communication equipment based on the SLIP protocol can be accessed at any time, the method solves the pseudo-synchronization problem of the SLIP protocol, provides error correction guarantee for the application layer to identify message semantics, and improves the product user experience of serial port communication needing to use the SLIP protocol.
Description
Technical Field
The invention relates to the embedded field, in particular to a synchronous error correction method for a serial burst access application layer SLIP protocol message.
Background
In the embedded field, serial communication is a very common and widely used information transmission communication interface. The serial port is also called as a serial interface, is divided according to an electrical standard and a protocol, and comprises the following components: RS-232, RS-422 and RS 485. The RS-232, RS-422 and RS-485 standards only specify the electrical characteristics of the interface and do not relate to the connection of external programs, cables or protocols. The transmission is carried out according to 8 bits per single byte. After a certain device of the system operates, serial data needs to be continuously sent out through one serial standard of the three standards, for example: the received signal level value, scanning frequency value, etc. in the short-wave radio station are required to be continuously sent to the computer terminal. The serial port of the receiver is accessed in a burst mode, the first byte received by the receiver is the first byte which is not in the format of the agreed message protocol with high probability, so that the synchronization of the message is wrong, and the method is false pseudo-synchronization. Therefore, the access success of the serial application layer has randomness, and the access success rate is very low, so that the time problem of burst access exists. False synchronization errors occur, are accumulated continuously like domino effect, and the accumulated errors cannot be jumped out, so that the application layer can not identify message semantics permanently. Only when the equipment is used, the equipment must be opened strictly according to a certain sequence, the above conditions can be avoided, normal and effective communication is realized, and good use experience is brought.
Disclosure of Invention
Aiming at the problems in the related art, the invention provides a synchronous error correction method for a serial burst access application layer SLIP protocol message, and solves the problems that the application layer can not identify the message semantics permanently and can not carry out normal and effective communication finally due to the false synchronization of the existing SLIP protocol message.
In order to achieve the technical purpose, the technical scheme of the invention is as follows:
the synchronous error correction method for the serial burst access application layer SLIP protocol message specifically comprises the following steps:
step 1: the serial port burst access device carries out initial synchronous capture of the received bytes according to the structural characteristics and the format characteristics of the SLIP protocol message;
step 2: matching analysis is carried out from the captured first byte, if the first byte is not the start or end mark of the protocol, the first byte is directly discarded, and once the synchronous information is captured, the authenticity of the synchronous information is further screened;
and step 3: and judging that the current message is successfully synchronized and the serial application layer is normal after the first correct synchronization is obtained after screening.
Further, the specific steps of the serial port burst access device and the byte capture in step 1 are as follows:
s0: defining a complete SLIP protocol message identifier Pflag, and setting the complete SLIP protocol message identifier Pflag to be 0 during initialization;
s1: defining temporary buffer storage of message contents of a storage protocol, defining an array DATA one-dimensional variable with the size of n, initializing a serial port and waiting for the burst access of the serial port of equipment, wherein the size of the array DATA meets the maximum length of byte number of a specified message of a single SLIP;
s2: the serial port interrupt function starts to capture bytes, matching analysis is carried out when the bytes are received by the serial port interrupt, and otherwise, the serial port interrupt function continues to wait for the serial port interrupt.
Further, the size of the DATA group in S1 satisfies the maximum length of the byte number of the single SLIP specified message, including the maximum length after the escape.
Further, the specific steps of the byte matching analysis in step 2 are as follows:
s3: performing content matching detection on the received serial port bytes to determine whether the serial port bytes are 0xC0, if the serial port bytes are 0xC0, executing S4, and otherwise, executing S11;
s4: if the current byte content is 0xC0 and Pflag is equal to 0, then S5 is performed; if the current byte content is 0xC0 and Pflag is equal to 1, then S6 is performed;
s5: setting the identifier Pflag to be 1 (namely, the current identifier is a new SLIP protocol message), placing the identifier Pflag at the first storage position of the DATA array, and then executing S2;
s6: setting the identifier Pflag to be 2 (namely, a complete protocol message is captured to be synchronous), placing the identifier Pflag at the position m +2 of the DATA array, setting the identifier Pflag to be 0, and then executing S7;
s7: it is determined whether the flag Pflag is equal to 2, and if so, the next screening is performed, otherwise, S2 is performed.
Further, the specific steps of discrimination and determination in step 3 are as follows:
s8: carrying out authenticity synchronous identification, and judging whether the received DATA length of DATA is greater than 2; if greater than 2, executing S9, otherwise executing S10;
s9: judging that the current message is correctly synchronous, wherein a complete and correct SLIP protocol message is received by a serial port application layer;
s10: judging that the current message is pseudo-synchronous, wherein the current message belongs to a SLIP protocol pseudo-message, setting the identifier Pflag to be 1, removing 0xC0 at the second position in the DATA array, executing S2, and storing the subsequently received serial port DATA from the second position of the DATA;
s11: judging whether the flag Pflag device is 1, if not, executing S12, otherwise, executing S13;
s12: directly discarding the content of the current byte, not storing the content into a cache DATA array, and executing S2;
s13: the received byte content is placed in the m +1 position of the DATA array buffer, and S2 is performed.
Further, the criterion for determining that the current packet is pseudo-synchronous in S10 is: the SLIP protocol message is characterized by consisting of hexadecimal 0xC0 and 0xC0, and the size of the SLIP protocol message is 2 bytes.
Further, the size of m in the DATA array depends on the number of non-0 xC0 bytes received after Pflag equals 1.
The invention has the beneficial effects that: any serial port communication equipment based on the SLIP protocol can be accessed at any time, the method solves the pseudo-synchronization problem of the SLIP protocol, provides error correction guarantee for the application layer to identify message semantics, and improves the product user experience of serial port communication needing to use the SLIP protocol.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a flowchart of a synchronous error correction method for a serial burst access application layer SLIP protocol packet according to an embodiment of the present invention;
fig. 2 is a schematic diagram illustrating a standard SLIP protocol message format feature according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present invention.
The synchronous error correction method for the serial burst access application layer SLIP protocol message specifically comprises the following steps:
step 1: the serial port burst access device carries out initial synchronous capture of the received bytes according to the structural characteristics and the format characteristics of the SLIP protocol message;
step 2: matching analysis is carried out from the captured first byte, if the first byte is not the start or end mark of the protocol, the first byte is directly discarded, and once the synchronous information is captured, the authenticity of the synchronous information is further screened;
and step 3: and judging that the current message is successfully synchronized and the serial application layer is normal after the first correct synchronization is obtained after screening.
As shown in fig. 1, the real-time process includes the following steps:
s0: defining a complete SLIP protocol message identifier Pflag, and setting the complete SLIP protocol message identifier Pflag to be 0 during initialization;
s1: defining temporary buffer storage of message contents of a storage protocol, and defining an array DATA one-dimensional variable with the size of n, wherein the size of the array DATA meets the maximum length of byte number of a specified message of a single SLIP (Serial client side protocol), and the maximum length contains the maximum length after escape, initializing a serial port, and waiting for the burst access of a serial port of equipment;
s2: the serial port interrupt function starts to capture bytes, when the serial port interrupt receives the first byte, S3 is executed, otherwise, the serial port interrupt function continues to wait for the serial port receiving interrupt;
s3: performing content matching detection on the received serial port bytes to determine whether the serial port bytes are 0xC0, if the serial port bytes are 0xC0, executing S4, and otherwise, executing S11;
s4: if the current byte content is 0xC0 and Pflag is equal to 0, then S5 is performed; if the current byte content is 0xC0 and Pflag is equal to 1, then S6 is performed;
s5: setting the identifier Pflag to be 1 (namely, the current identifier is a new SLIP protocol message), placing the identifier Pflag at the first storage position of the DATA array, and then executing S2;
s6: setting the identifier Pflag to be 2 (namely, a complete protocol message synchronization is captured), placing the identifier Pflag at the position m +2 of the DATA array (the size of m depends on the number of bytes which are not 0xC0 and are received after the Pflag is equal to 1), setting the identifier Pflag to be 0, and then executing S7;
s7: determining whether the flag Pflag is equal to 2, if so, executing S8, otherwise, executing S2;
s8: carrying out authenticity synchronous identification, and judging whether the received DATA length of DATA is greater than 2; if greater than 2, executing S9, otherwise executing S10;
s9: judging that the current message is correctly synchronous, wherein a complete and correct SLIP protocol message is received by a serial port application layer;
s10: judging that the current message is pseudo-synchronous (the pseudo-synchronous SLIP protocol message is characterized in that the message consists of hexadecimal 0xC0 and 0xC0 and has the size of 2 bytes), wherein the current message belongs to the SLIP protocol pseudo-message, setting the identifier Pflag to be 1, removing 0xC0 at the second position in the DATA array, executing S2, and storing the subsequently received serial port DATA from the second position of the DATA;
s11: judging whether the flag Pflag device is 1, if not, executing S12, otherwise, executing S13;
s12: directly discarding the content of the current byte, not storing the content into a cache DATA array, and executing S2;
s13: s2 is performed by placing the received byte content in the m +1 position of the DATA array cache (m size depends on the number of non-0 xC0 bytes received after Pflag equals 1).
The specific design principle will now be briefly explained:
as shown in fig. 2, synchronous matching and capturing are performed according to the structural features and format features of the SLIP protocol message; because the serial port is accessed in a burst mode, the acquired synchronous information has a pseudo-synchronous condition, and the pseudo-synchronization is screened and removed by utilizing the characteristic that the whole byte length of the message is at least greater than 2 (because the complete synchronous information occupies 2 bytes); once the first legal synchronous command is captured, the pseudo-synchronization can be skipped out, the problem of synchronization error can be corrected, and the guarantee is provided for the semantic understanding of the normal message of the application layer, so that the two parties can recover normal and effective communication.
The present invention is not limited to the above preferred embodiments, and any modifications, equivalent substitutions, improvements, etc. within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (6)
1. The synchronous error correction method for the serial burst access application layer SLIP protocol message is characterized by comprising the following steps:
step 1: the serial port burst access device carries out initial synchronous capture of the received bytes according to the structural characteristics and the format characteristics of the SLIP protocol message;
step 2: matching analysis is carried out from the captured first byte, if the first byte is not the start or end mark of the protocol, the first byte is directly discarded, and once the synchronous information is captured, the authenticity of the synchronous information is further screened;
and step 3: carrying out authenticity synchronous identification, and judging whether the received DATA length of DATA is greater than 2; if the number of the received serial port DATA is larger than 2, judging that the current message is correctly synchronous, the serial port application layer already receives a complete and correct SLIP protocol message, otherwise, judging that the current message is pseudo-synchronous, the current message belongs to a SLIP protocol pseudo-message, setting an identifier Pflag to be 1, removing 0xC0 at the second position in the DATA array, starting to capture bytes by a serial port interrupt function, and starting to store the subsequently received serial port DATA from the second position of the DATA; judging whether the flag Pflag is set to be 1, if not, directly discarding the content of the current byte, not storing the content of the current byte in a cache DATA array, executing a serial port interrupt function to start to capture the byte, otherwise, placing the received byte content in an m +1 position of the DATA array cache, and executing the serial port interrupt function to start to capture the byte;
and 4, step 4: and judging that the current message is successfully synchronized and the serial application layer is normal after the first correct synchronization is obtained after screening.
2. The synchronous error correction method for the serial burst access application layer SLIP protocol message according to claim 1, characterized in that the specific steps of the serial burst access device and the byte capturing in step 1 are:
s0: defining a complete SLIP protocol message identifier Pflag, and setting the complete SLIP protocol message identifier Pflag to be 0 during initialization;
s1: defining temporary buffer storage of message contents of a storage protocol, defining an array DATA one-dimensional variable with the size of n, initializing a serial port and waiting for the burst access of the serial port of equipment, wherein the size of the array DATA meets the maximum length of byte number of a specified message of a single SLIP;
s2: the serial port interrupt function starts to capture bytes, matching analysis is carried out when the bytes are received by the serial port interrupt, and otherwise, the serial port interrupt function continues to wait for the serial port interrupt.
3. The synchronous error correction method for serial port burst access application layer SLIP protocol messages according to claim 2, characterized in that the size of the DATA group in S1 satisfies the maximum length of byte number of a single SLIP specified message, including the maximum length after escape.
4. The synchronous error correction method for the serial burst access application layer SLIP protocol message as claimed in claim 2, wherein the specific steps of byte matching analysis in step 2 are as follows:
s3: performing content matching detection on the received serial port bytes to determine whether the serial port bytes are 0xC0, if the serial port bytes are 0xC0, executing S4, and otherwise, executing S11;
s4: if the current byte content is 0xC0 and Pflag is equal to 0, then S5 is performed; if the current byte content is 0xC0 and Pflag is equal to 1, then S6 is performed;
s5: setting the identifier Pflag to be 1, indicating that the current message is a new SLIP protocol message, placing the message at the first storage position of the DATA array, and then executing S2;
s6: setting the identifier Pflag to be 2 to indicate that a complete protocol message is captured, placing the identifier Pflag at the position of m +2 of the DATA array, setting the identifier Pflag to be 0, and then executing S7;
s7: it is determined whether the flag Pflag is equal to 2, and if so, the next screening is performed, otherwise, S2 is performed.
5. The synchronous error correction method for serial burst access application layer SLIP protocol messages according to claim 1, wherein the standard for determining that the current message is pseudo-synchronous in S10 is as follows: the SLIP protocol message is characterized by consisting of hexadecimal 0xC0 and 0xC0, and the size of the SLIP protocol message is 2 bytes.
6. The method of any of claims 1 or 4, wherein the size of m in the DATA array is determined by the number of bytes received after Pflag equals 1, which is not 0xC0 bytes.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910044479.1A CN109728879B (en) | 2019-01-17 | 2019-01-17 | Synchronous error correction method for serial burst access application layer SLIP protocol message |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910044479.1A CN109728879B (en) | 2019-01-17 | 2019-01-17 | Synchronous error correction method for serial burst access application layer SLIP protocol message |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109728879A CN109728879A (en) | 2019-05-07 |
CN109728879B true CN109728879B (en) | 2022-02-11 |
Family
ID=66299721
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910044479.1A Active CN109728879B (en) | 2019-01-17 | 2019-01-17 | Synchronous error correction method for serial burst access application layer SLIP protocol message |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109728879B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112019319A (en) * | 2020-08-25 | 2020-12-01 | 杰华特微电子(杭州)有限公司 | Method and equipment for synchronous transmission of data signals |
CN112866389B (en) * | 2021-01-21 | 2022-09-16 | 同方电子科技有限公司 | Slip protocol-based file transmission method and device in short-wave radio station communication |
CN113726755B (en) * | 2021-08-23 | 2023-06-02 | 天津津航计算技术研究所 | SLIP protocol data processing method |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101141236A (en) * | 2007-03-20 | 2008-03-12 | 中兴通讯股份有限公司 | In-frame method for synchronous transmission system |
US8340005B1 (en) * | 2005-02-08 | 2012-12-25 | Cortina Systems, Inc. | High speed packet interface and method |
CN104486034A (en) * | 2014-12-08 | 2015-04-01 | 江西洪都航空工业集团有限责任公司 | RS422/485 serial port communication data packaging method |
CN105187420A (en) * | 2015-08-27 | 2015-12-23 | 哈尔滨工业大学 | Communication protocol matching method based on RS422 bus |
CN106533874A (en) * | 2016-11-22 | 2017-03-22 | 北京金自天正智能控制股份有限公司 | Permanent magnet synchronous motor (PMSM) data communication system and method based on Modbus RTU protocol |
CN107395565A (en) * | 2017-06-15 | 2017-11-24 | 北京机械设备研究所 | Serial ports receives preprocess method under a kind of fixed length single byte form message protocol |
-
2019
- 2019-01-17 CN CN201910044479.1A patent/CN109728879B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8340005B1 (en) * | 2005-02-08 | 2012-12-25 | Cortina Systems, Inc. | High speed packet interface and method |
CN101141236A (en) * | 2007-03-20 | 2008-03-12 | 中兴通讯股份有限公司 | In-frame method for synchronous transmission system |
CN104486034A (en) * | 2014-12-08 | 2015-04-01 | 江西洪都航空工业集团有限责任公司 | RS422/485 serial port communication data packaging method |
CN105187420A (en) * | 2015-08-27 | 2015-12-23 | 哈尔滨工业大学 | Communication protocol matching method based on RS422 bus |
CN106533874A (en) * | 2016-11-22 | 2017-03-22 | 北京金自天正智能控制股份有限公司 | Permanent magnet synchronous motor (PMSM) data communication system and method based on Modbus RTU protocol |
CN107395565A (en) * | 2017-06-15 | 2017-11-24 | 北京机械设备研究所 | Serial ports receives preprocess method under a kind of fixed length single byte form message protocol |
Also Published As
Publication number | Publication date |
---|---|
CN109728879A (en) | 2019-05-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109728879B (en) | Synchronous error correction method for serial burst access application layer SLIP protocol message | |
EP1811710A2 (en) | Apparatus and method for processing bursts in a wireless communication system | |
CN105281883B (en) | Multi-channel synchronization method, synchronizing device and system | |
EP3675398A1 (en) | Check code processing method, electronic device, and storage medium | |
JPH0673940U (en) | Data receiver | |
CN110704356A (en) | Universal serial port data analyzing method | |
CN112332951B (en) | Ethernet frame preemption method, device, equipment and storage medium | |
CN111130690A (en) | Processing method and device for multiple communication protocols of IR46 smart electric meter | |
CN115695576B (en) | Data frame conversion method and device compatible with TSN frame preemption protocol | |
JPH05160815A (en) | Error recovery processing method in consecutive transmission system | |
CN112565105A (en) | Method, device and equipment for reducing time-sensitive frame forwarding time delay | |
CN111770055A (en) | Multi-protocol communication frame rapid distinguishing method applied to electric energy meter | |
CN115297447B (en) | Long short message merging method, system, equipment and storage medium | |
US11435999B2 (en) | Method and apparatus for upgrading software | |
CN108111896B (en) | Subtitle synchronization method and device | |
CN112351049B (en) | Data transmission method, device, equipment and storage medium | |
CN112671721A (en) | Message analysis method of intelligent electric energy meter | |
KR100961905B1 (en) | Process for transmitting and receiving data | |
JP3495625B2 (en) | TS data filtering circuit in digital broadcast receiver | |
CN116192998B (en) | Method, device and equipment for decoding power transmission protocol information packet | |
CN116756076A (en) | Error detection method, detection system, terminal and medium for synchronous serial port communication | |
CN117041388B (en) | Data transmission method suitable for BMS (battery management system) products | |
EP2073423A1 (en) | Method and device for error detection and handling of received radio link control protocol data units in a mobile radio communication system | |
JP4072390B2 (en) | Protocol message detection method and method in audio signal | |
JPH0431214B2 (en) |
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 |