Beidou message error code detection method based on GBK format and storage medium
By splicing BeiDou short message sub-packets using first frame identifiers and subsequent frame identifiers, and performing GBK format validity checks byte by byte, the problem of insufficient error identification in existing technologies for BeiDou short messages encoded in GBK format is solved, achieving effective interception of garbled characters and reliable display of message content.
Patent Information
- Application Number
- CN202610959271.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2046-06-30
AI Technical Summary
The existing BeiDou short message communication system has difficulty identifying abnormalities in GBK format encoded Chinese messages under the condition of bit errors, resulting in garbled characters or semantic errors. The existing verification methods are insufficient to identify bit errors in a timely manner.
By concatenating short message sub-packets using the first frame identifier and subsequent frame identifier, GBK format validity is checked byte by byte. A preset set of valid GBK combinations is used to determine the range of single-byte and double-byte characters, and bytes or byte combinations that do not conform to the rules are identified as errors.
It effectively identifies and intercepts garbled messages caused by packet loss, misspelling, or multiple spelling, improving the display reliability of BeiDou short message messages and ensuring the legality of message content encoding.
Smart Images

Figure CN122496863B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of satellite navigation and communication technology, specifically to a method and storage medium for detecting BeiDou message errors based on GBK format. Background Technology
[0002] BeiDou short message communication features wide coverage and flexible use, and is commonly used in scenarios such as field operations, emergency rescue, ship communication, and vehicle monitoring. In practical applications, terminal devices typically encapsulate the content to be sent into one or more short message sub-packets and transmit them through the BeiDou short message link. After receiving multiple short message sub-packets, the receiving end splices them together according to information such as frame sequence number, first frame identifier, and continuation frame identifier to recover the complete message content.
[0003] Because the transmission environment of BeiDou short messages is easily affected by factors such as obstruction, multipath propagation, weather, electromagnetic interference, and terminal mobility, problems such as bit flipping, byte loss, byte insertion, or sub-packet splicing anomalies may occur during transmission. Existing short message systems generally use checksums, cyclic redundancy checks, or frame structure checks to determine the integrity of the message at the transmission layer. However, these checks primarily assess the overall frame data or communication protocol format. If some errors are not detected by the check mechanism, or if errors still pass protocol layer checks after they occur, the receiver may still treat abnormal messages as normal messages. For Chinese messages encoded in GBK format, errors may turn originally valid combinations of Chinese character bytes into invalid combinations, or cause garbled text or semantic errors in the displayed content. Existing processing methods typically focus on reception, packet splicing, and display, paying insufficient attention to the encoding validity of the message content itself, making it difficult to identify abnormal messages in a timely manner. Summary of the Invention
[0004] The purpose of this application is to provide a method and storage medium for detecting BeiDou message errors based on GBK format.
[0005] To achieve the above objectives, the first aspect of this application provides a method for detecting BeiDou message errors based on the GBK format, comprising: The first frame sub-packet is determined from multiple short message sub-packets based on the first frame identifier carried by each short message sub-packet; The first frame sub-packet is used as the starting sub-packet for splicing, and the short message sub-packets received after the first frame sub-packet are spliced sequentially according to the receiving order of multiple short message sub-packets; When splicing the data to a short message sub-packet that indicates no continuation frame, the BeiDou message to be detected is obtained.
[0006] In this embodiment of the application, the preset range of double-byte characters is determined by a preset set of legal GBK combinations. The preset set of legal GBK combinations includes multiple legal combination items, and each legal combination item includes a first byte value, a second byte lower limit value, and a second byte upper limit value.
[0007] In this embodiment of the application, the preset range of single-byte characters is the range in which the byte value is less than or equal to the hexadecimal number 0x80.
[0008] In this embodiment of the application, the first byte range of the preset double-byte character is the range where the byte value is greater than or equal to the hexadecimal number 0x81 and less than or equal to the hexadecimal number 0xFE.
[0009] In this embodiment of the application, the second byte range of the preset double-byte character is the range where the byte value is greater than or equal to the hexadecimal number 0x40 and less than or equal to the hexadecimal number 0xFE.
[0010] In this embodiment of the application, determining whether the byte combination formed by the current byte and the next byte is within a preset double-byte character range includes: Match the current byte with the first byte value of each legal combination item in the preset set of legal GBK combinations; If the current byte matches the first byte value of any valid combination item, determine the lower limit value of the second byte and the upper limit value of the second byte corresponding to the valid combination item; If the next byte is greater than or equal to the lower limit of the second byte and less than or equal to the upper limit of the second byte, the byte combination formed by the current byte and the next byte is determined to be within the preset double-byte character range.
[0011] In this embodiment of the application, if the first byte value of the current byte does not match any of the first byte values of any legal combination item in the preset set of legal GBK combinations, or if the next byte is not located between the lower limit value of the second byte and the upper limit value of the second byte corresponding to the first byte value that was successfully matched, it is determined that the byte combination formed by the current byte and the next byte is not within the preset range of double-byte characters.
[0012] In this embodiment of the application, the method further includes: If the message content of the BeiDou message to be tested conforms to the GBK format, the BeiDou message to be tested is output.
[0013] A second aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform a GBK-formatted BeiDou message error detection method.
[0014] This application proposes a method for detecting errors in BeiDou messages based on the GBK format. The method assembles the BeiDou message to be detected based on the first frame identifier and subsequent frame identifier carried in the short message sub-packets. Then, it performs a byte-by-byte legality check on the message content according to the GBK encoding rules. This ensures that bytes and byte combinations that do not conform to the preset single-byte character range, the preset first byte range of double-byte characters, or the preset double-byte character range can be identified as errors. This intercepts garbled messages caused by packet loss, mis-spelling, or multiple spellings before output, solving the problem that existing BeiDou short message assembly methods struggle to detect message content anomalies solely through sub-packet identifiers and routine checks, leading to the output and display of erroneous messages.
[0015] Other features and advantages of the embodiments of this application will be described in detail in the following detailed description section. Attached Figure Description
[0016] The accompanying drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the following detailed description to explain the embodiments of this application, but do not constitute a limitation on the embodiments of this application. In the drawings: Figure 1 The schematic diagram illustrates a flowchart of a BeiDou message error detection method based on GBK format according to an embodiment of this application; Figure 2 The illustration shows a schematic flowchart of a message legality detection process based on GBK format according to an embodiment of this application; Figure 3 The diagram illustrates the internal structure of a computer device according to an embodiment of this application. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for illustration and explanation of the embodiments of this application and are not intended to limit the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0018] Figure 1 The illustration shows a schematic flowchart of a BeiDou message error detection method based on GBK format according to an embodiment of this application. Figure 1 As shown in one embodiment of this application, a method for detecting BeiDou message errors based on GBK format is provided, including the following steps: Step 102: Obtain multiple short message sub-packets, each short message sub-packet carrying a first frame identifier and a continuation frame identifier; Step 104: Concatenate the short message sub-packets sequentially according to the first frame identifier and the continuation frame identifier carried by each short message sub-packet to obtain the BeiDou message to be detected. Step 106: Perform GBK format legality checks on the message content of the Beidou message to be tested byte by byte; Step 108: If the current byte read is within the preset single-byte character range, determine that the current byte conforms to the GBK format, and continue reading the next byte; Step 110: If the current byte is within the range of the first byte of the preset double-byte character, read the next byte after the current byte. If the byte combination formed by the current byte and the next byte is within the range of the preset double-byte character, determine that the byte combination conforms to the GBK format, and continue reading the next byte after the byte combination. Step 112: If the current byte is not within the preset single-byte character range and is not within the first byte range of the preset double-byte character range, or if the byte combination is not within the preset double-byte character range, it is determined that the BeiDou message to be detected has a bit error.
[0019] In one embodiment, this application provides a method for detecting errors in BeiDou messages based on GBK format. This method is applicable to BeiDou short messages whose content is encoded in GBK format. During transmission, the BeiDou short message is split into multiple short message sub-packets. Each sub-packet carries a first frame identifier and a continuation frame identifier. The first frame identifier indicates whether the sub-packet is the starting sub-packet of a BeiDou short message, and the continuation frame identifier indicates whether there are any subsequent sub-packets that need to be concatenated. After acquiring multiple sub-packets, they are sequentially concatenated according to the first frame identifier and continuation frame identifier carried by each sub-packet to obtain the BeiDou message to be detected. Specifically, the starting sub-packet can be determined first based on the first frame identifier, and then subsequent sub-packets can be concatenated according to the receiving order of the sub-packets until a sub-packet with a continuation frame identifier indicating no continuation frame is reached, thus obtaining a complete BeiDou message to be detected. Since the receiving end typically cannot know the total number of sub-packets in a BeiDou short message before splicing, splicing using the first frame identifier and subsequent frame identifier can adapt to the packetized transmission mode of BeiDou short messages. Each sub-packet of a BeiDou short message can also carry a CRC check result. The CRC check result of the entire BeiDou short message packet is usually determined by the CRC check results of each sub-packet. If the CRC check of each sub-packet passes, the spliced BeiDou short message packet may also be considered to have passed the check. However, because the receiving end cannot know the total number of sub-packets in a BeiDou short message before splicing, if an intermediate sub-packet is lost, the remaining sub-packets may still be spliced into a message according to the first frame identifier and subsequent frame identifier, and the CRC check of each remaining sub-packet may still pass, leading to the risk of incomplete content or garbled characters in the spliced BeiDou short message packet. Therefore, after splicing together the BeiDou message to be tested, it is necessary to further perform error detection based on the legality of the GBK format of the message content.
[0020] After receiving the BeiDou message to be tested, the message content is checked byte by byte for GBK format validity. During the check, reading begins from the first byte of the message content, and the byte being read is taken as the current byte. If the current byte is within a preset single-byte character range, it means that the current byte can constitute a valid character in GBK format on its own, confirming that the current byte conforms to GBK format, and the next byte is read. If the current byte is not within the preset single-byte character range but is within the preset first byte range of double-byte characters, it means that the current byte may be the first byte of a GBK double-byte character. In this case, the next byte after the current byte is read, and the current byte and the next byte are combined into a byte combination. If this byte combination is within the preset double-byte character range, it means that the byte combination conforms to GBK format, and the next byte after this byte combination is read. If the current byte is neither within the preset single-byte character range nor within the preset first byte range of double-byte characters, it means that the current byte cannot be a valid single-byte character or the first byte of a valid double-byte character, and the BeiDou message to be tested is determined to have errors. If the current byte is within the first byte range of a preset double-byte character, but the byte combination formed by the current byte and the next byte is not within the preset double-byte character range, the BeiDou message to be detected is also determined to have a bit error. After determining that a bit error exists, the current GBK format validity check can be stopped, and the output of the BeiDou message to be detected to the host computer can be stopped. In this embodiment, if the current byte is within the preset single-byte character range, then the current byte is determined to be a single-byte character in GBK encoding, which can correspond to an ASCII character.
[0021] In this embodiment, the message content of the BeiDou message to be detected is encoded in GBK format at the sending end. Therefore, under normal circumstances, the message content spliced by the receiving end should conform to the GBK character encoding rules. When short message sub-packets are lost, mis-spelled, or multi-spelled during transmission, the byte order or adjacent byte combinations after splicing are easily disrupted. Even if conventional verification fails to detect abnormalities, bytes or byte combinations that do not conform to the GBK format may appear. By performing GBK format legality checks on each byte of the BeiDou message to be detected, abnormal messages can be identified by utilizing the encoding legality of the message content itself, thereby improving the BeiDou message error detection capability and avoiding the display of error messages by the host computer.
[0022] For example, if the BeiDou short message to be transmitted is "BeiDou 3", the machine code converted according to GBK format can be B1 B1 B6 B7 33 BAC5. If some bytes are lost during transmission, and the receiving end receives B1 B1 B6 33 BAC5, then B1 B1 can conform to the GBK format, but the second byte 33 in B6 33 is less than 0x40, which does not conform to the range of the second byte of a GBK double-byte character. Therefore, it can be determined that there is a code error in the BeiDou message to be tested, and the output of the BeiDou message to be tested will be stopped.
[0023] In one embodiment, short message sub-packets are sequentially concatenated according to the first frame identifier and the continuation frame identifier carried by each short message sub-packet to obtain the BeiDou message to be detected. This includes: determining the first frame sub-packet from multiple short message sub-packets based on the first frame identifier carried by each short message sub-packet; using the first frame sub-packet as the starting sub-packet for concatenation, and sequentially concatenating the short message sub-packets received after the first frame sub-packet according to the receiving order of the multiple short message sub-packets; and obtaining the BeiDou message to be detected when concatenating to a short message sub-packet where the continuation frame identifier indicates no continuation frame. In this embodiment, the first frame sub-packet is used to determine the starting point for concatenating a BeiDou short message, and short message sub-packets without continuation frames are used to determine the ending point for concatenating a BeiDou short message. Short message sub-packets received between the first frame sub-packet and the short message sub-packets without continuation frames are concatenated sequentially according to the receiving order. Therefore, even if the receiving end cannot know the total number of short message sub-packets before concatenation, it can complete the concatenation of the entire packet based on the first frame identifier and the continuation frame identifier. For example, the receiving end receives short message sub-packets A, B, C, and D sequentially. Sub-packet A carries a first frame identifier and a continuation frame identifier, so it is identified as the first frame sub-packet. Sub-packets B and C both carry non-first frame identifiers and continuation frame identifiers, so sub-packet B is concatenated after sub-packet A according to the receiving order, and sub-packet C is concatenated after sub-packet B. Sub-packet D carries a non-first frame identifier and a no-continuation-frame identifier, so it is concatenated after sub-packet C, and the concatenation operation ends. This results in a BeiDou message to be detected, consisting of sub-packets A, B, C, and D. If short message sub-packet B or short message sub-packet C is lost during transmission, the receiving end may concatenate short message sub-packets A, C, and D into a BeiDou message to be detected, or concatenate short message sub-packets A, B, and D into a BeiDou message to be detected. Since the receiving end cannot directly determine whether intermediate short message sub-packets are lost based on the first frame identifier and subsequent frame identifier, and the CRC check of the remaining short message sub-packets may still pass, the concatenated BeiDou message to be detected may become garbled after being output to the host computer. This embodiment identifies abnormal messages caused by the loss of intermediate short message sub-packets by continuing to perform GBK format validity checks after packet concatenation. This concatenation method, used in conjunction with GBK format validity checks, ensures that byte misalignment caused by the loss of intermediate short message sub-packets can be detected in subsequent checks.
[0024] In one embodiment, the preset range of two-byte characters is determined by a preset set of legal GBK combinations. This set includes multiple legal combination items, each comprising a first byte value, a lower limit of the second byte, and an upper limit of the second byte. In this embodiment, the preset set of legal GBK combinations can be pre-configured as a multi-row, three-column data structure according to GBK encoding rules. For example, the preset set A can be a 43×3 data structure, with each row in set A corresponding to a legal combination item. Each legal combination item includes a first byte value, a lower limit of the second byte, and an upper limit of the second byte. During detection, the current byte Byte1 is matched with the first byte values of each row in set A. If Byte1 matches the first byte value of a row, and the next byte Byte2 is located between the lower and upper limits of the second byte in that row, then the byte combination consisting of Byte1 and Byte2 is determined to be a legal GBK combination. If Byte1 does not match any first byte value in set A, or Byte2 does not fall between the corresponding lower and upper limits of the second byte, then the byte combination consisting of Byte1 and Byte2 does not conform to the GBK format.
[0025] Set A is as follows: A={{0xA1,0x40,0xA0},{0xA2,0x40,0xA0},{0xA2,0xAB,0xB0},{0xA2,0xE3,0xE4},{0xA2,0xEF,0xF0},{0x A2,0xFD,0xFF},{0xA3,0x40,0xA0}{0xA4,0x40,0xA0},{0xA4,0xF4,0xFF},{0xA5,0x40,0xA0},{0xA5,0xF7, 0xFF},{0xA6,0x40,0xA0},{0xA6,0xB9,0xC0},{0xA6,0xD9,0xDF},{0xA6,0xEC,0xED},{0xA6,0xF3,0xF3},{ 0xA6,0xF6,0xFF},{0xA7,0x40,0xA0},{0xA7,0xC2,0xD0},{0xA7,0xF2,0xFF},{0xA8,0x95,0xA0},{0xA8,0x BC,0xBC},{0xA8,0xBF,0xBF},{0xA8,0xC1,0xC4},{0xA8,0xEA,0xFF},{0xA9,0x58,0x58},{0xA9,0x5D,0x5 F}, {0xA9,0x89,0x95},{0xA9,0x97,0xA3},{0xA9,0xF0,0xFF},{0xAA,0xA1,0xFF},{0xAB,0xA1,0xFF},{0xA C,0xA1,0xFF},{0xAD,0xA1,0xFF},{0xAE,0xA1,0xFF},{0xAF,0xA1,0xFF},{0xF8,0xA1,0xFF},{0xF9,0xA1, 0xFF},{0xFA,0xA1,0xFF},{0xFB,0xA1,0xFF},{0xFC,0xA1,0xFF},{0xFD,0xA1,0xFF},{0xFE,0x50,0xFF}}.
[0026] Each row represents a valid combination. The first column is the value of the first byte, the second column is the lower limit of the second byte corresponding to that first byte value, and the third column is the upper limit of the second byte corresponding to that first byte value. For example, the valid combination {0xA1, 0x40, 0xA0} means that when the first byte value is 0xA1, any combination of bytes with a second byte value between 0x40 and 0xA0 is a valid combination. This data structure transforms the valid combination range of GBK double-byte characters into a first-byte matching and second-byte range judgment, facilitating rapid validity checks in software.
[0027] In one embodiment, the preset range of single-byte characters is the range where the byte value is less than or equal to the hexadecimal number 0x80. In this embodiment, when the byte value of the current byte is less than or equal to 0x80, the current byte can be treated as a single-byte character in the GBK format. Since this type of character does not need to be combined with the next byte to represent a valid character, it can be directly determined that the current byte conforms to the GBK format and the next byte can be read. This avoids misjudging a single-byte character as the first byte of a double-byte character and also reduces unnecessary combination judgments.
[0028] In one embodiment, the preset range for the first byte of a double-byte character is a range where the byte value is greater than or equal to hexadecimal 0x81 and less than or equal to hexadecimal 0xFE. In this embodiment, when the byte value of the current byte is greater than or equal to 0x81 and less than or equal to 0xFE, the current byte can be used as the first byte of a GBK double-byte character. If the current byte is greater than 0x80 but does not fall within the range of 0x81 to 0xFE, then the current byte belongs neither to the range of single-byte characters nor can it be used as the first byte of a double-byte character; therefore, it can be determined that the message content does not conform to the GBK format. By using this range judgment, obviously illegal first bytes can be excluded first, improving the efficiency of error detection.
[0029] In one embodiment, the preset range for the second byte of a double-byte character is a range where the byte value is greater than or equal to hexadecimal 0x40 and less than or equal to hexadecimal 0xFE. In this embodiment, after the current byte is determined to be the first byte of a possible GBK double-byte character, the next byte following the current byte is read, and it is first determined whether the next byte is within the range of 0x40 to 0xFE. If the next byte is not within this range, then the next byte cannot be used as the second byte of a GBK double-byte character, and it can be directly determined that the byte combination formed by the current byte and the next byte does not conform to the GBK format. By first determining the range of the second byte, anomalies in the second byte caused by packet loss or misspelling can be quickly detected.
[0030] In one embodiment, determining whether the byte combination formed by the current byte and the next byte is within a preset double-byte character range includes: matching the current byte with the first byte value of each legal combination item in a preset set of legal GBK combinations; if the current byte successfully matches the first byte value of any legal combination item, determining the lower limit value and the upper limit value of the second byte corresponding to that legal combination item; if the next byte is greater than or equal to the lower limit value of the second byte and less than or equal to the upper limit value of the second byte, determining that the byte combination formed by the current byte and the next byte is within the preset double-byte character range. In this embodiment, the current byte is Byte1, and the next byte, i.e., the second byte, is Byte2. During detection, Byte1 is first matched with the first byte value of each legal combination item in the preset set of legal GBK combinations. If the match is successful, the lower limit value and the upper limit value of the second byte in the successfully matched legal combination item are read, and it is determined whether Byte2 is between the lower limit value and the upper limit value. If Byte2 is within the corresponding interval, it indicates that the byte combination formed by Byte1 and Byte2 belongs to a legal GBK combination, and the next byte after this byte combination can be read. Therefore, the judgment of double-byte characters can not only satisfy the overall value range of the first and second bytes, but also the specific combination range of the corresponding first byte in the GBK encoding table, thereby reducing missed detections.
[0031] In one embodiment, if the first byte value of the current byte does not match any of the first byte values in the preset set of valid GBK combinations, or if the next byte is not located between the lower and upper limits of the second byte corresponding to the matched first byte value, it is determined that the byte combination formed by the current byte and the next byte is not within the preset range of double-byte characters. In this embodiment, if the current byte cannot match any first byte value in the preset set of valid GBK combinations, it indicates that although the current byte may fall within the overall range of the first byte of a double-byte character, it does not correspond to a valid first byte in the set of valid combinations, and the byte combination can be determined to be invalid. If the current byte can match a certain first byte value, but the next byte is less than the corresponding lower limit of the second byte or greater than the corresponding upper limit of the second byte, it also indicates that the next byte cannot form a valid GBK double-byte character with the current byte. Through the above reverse judgment, the error determination conditions can be clearly defined, facilitating timely termination of detection and prevention of garbled message output when an illegal combination is detected.
[0032] In one embodiment, the method further includes: outputting the BeiDou message to be detected if the message content of the BeiDou message to be detected conforms to the GBK format. In this embodiment, if, starting from the first byte of the message content of the BeiDou message to be detected, all single-byte characters are within a preset single-byte character range, and all double-byte characters satisfy the first byte range, the second byte range, and the preset set of valid GBK combinations, then it can be determined that the message content of the BeiDou message to be detected conforms to the GBK format. At this time, the BeiDou message to be detected is output to the host computer for display. In this way, only BeiDou messages that pass the GBK format validity check will be output, and BeiDou messages with the risk of errors will be intercepted, thereby improving the reliability of BeiDou short message display.
[0033] In one embodiment, this application proposes a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform a GBK-formatted BeiDou message error detection method.
[0034] like Figure 2 As shown, in one embodiment, after receiving multiple BeiDou short message sub-packets, the terminal device first concatenates the multiple short message sub-packets according to the first frame identifier and subsequent frame identifier carried by each short message sub-packet, following the sending order. After concatenation, a BeiDou short message to be detected is obtained. The BeiDou short message to be detected includes message content, which is represented in byte sequence form. After obtaining the BeiDou short message to be detected, GBK validity detection begins. The byte reading position is set as the starting position of the message content, and the current byte Byte1 in the message content is read byte by byte. If the current byte Byte1 is within a preset single-byte character range, it is determined that the current byte Byte1 conforms to the GBK format requirements, and the byte reading position is moved forward by one byte. The preset single-byte character range is the range where the byte value is less than or equal to the hexadecimal number 0x80.
[0035] If the current byte Byte1 is not within the preset single-byte character range, then it is determined whether the current byte Byte1 is within the first byte range of GBK double-byte characters. If the current byte is within the first byte range of GBK double-byte characters, then the next byte after the current byte is read, and it is determined whether the next byte, that is, the second byte Byte2, is within the second byte range of GBK double-byte characters. The range of the first byte can be 0x81 to 0xFE, and the range of the second byte can be 0x40 to 0xFE.
[0036] If the current byte Byte1 is within the first byte range and the next byte Byte2 is within the second byte range, then the current byte Byte1 and the next byte Byte2 are treated as a valid GBK double-byte character, and the byte reading position is shifted two bytes to the right. If the current byte is not within the first byte range, or the current byte is within the first byte range but the next byte does not exist, or the next byte is not within the second byte range, then an illegal GBK byte combination is determined to exist in the BeiDou short message to be detected, and the position of the illegal byte combination is recorded.
[0037] During the byte-by-byte inspection process, if all bytes conform to the single-byte character rule or the double-byte character rule, the message content of the BeiDou short message to be inspected is determined to have passed the GBK format validity check. If at least one illegal byte or illegal byte combination is detected, it is determined that the BeiDou short message to be inspected has a risk of bit error, and an error message can be output, the BeiDou short message to be inspected can be discarded, or a request can be made to re-receive the corresponding short message sub-packet. After each byte is read and the GBK validity check is performed, it is determined whether the sub-node has been extracted. If all bytes have been extracted and all have passed the GBK validity check, the process ends, confirming that there are no garbled characters in this message.
[0038] Compared with existing technologies, this application proposes a method for detecting BeiDou message errors based on GBK format. The method assembles the BeiDou message to be detected based on the first frame identifier and subsequent frame identifier carried in the short message sub-packets. Then, it performs a byte-by-byte legality check on the message content according to GBK encoding rules. This ensures that bytes and byte combinations that do not conform to the preset single-byte character range, the preset first byte range of double-byte characters, or the preset double-byte character range can be identified as errors. This intercepts garbled messages caused by packet loss, mis-spelling, or multiple spellings before output, solving the problem that existing BeiDou short message assembly methods struggle to detect message content anomalies solely through sub-packet identifiers and routine checks, leading to the output and display of erroneous messages.
[0039] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3As shown in the figure, the computer device includes a processor A01, a network interface A02, and a memory (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A04. The network interface A02 is used for communication with external terminals via a network connection. When executed by the processor A01, the computer program B02 implements a BeiDou message error detection method based on the GBK format.
[0040] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0041] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0042] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0043] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0044] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0045] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0046] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0047] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0048] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for detecting errors in BeiDou messages based on GBK format, characterized in that, The method is applicable to BeiDou short messages whose content is encoded in GBK format. The method includes: Acquire multiple short message sub-packets, each of which carries a first frame identifier and a continuation frame identifier; The short message sub-packets are sequentially spliced together according to the first frame identifier and the subsequent frame identifier carried by each short message sub-packet to obtain the BeiDou message to be detected. The message content of the BeiDou message to be detected is checked byte by byte for GBK format legality. If the current byte read is within a preset single-byte character range, determine that the current byte conforms to the GBK format, and continue reading the next byte; If the current byte read is within the first byte range of a preset double-byte character, then read the next byte after the current byte. The preset double-byte character range is determined by a preset set of legal GBK combinations. The preset set of legal GBK combinations includes multiple legal combination items, and each legal combination item includes a first byte value, a second byte lower limit value, and a second byte upper limit value. Match the current byte with the first byte value of each legal combination item in the preset set of legal GBK combinations; If the current byte successfully matches the first byte value of any of the legal combination items, determine the lower limit value of the second byte and the upper limit value of the second byte corresponding to the legal combination item; If the next byte is greater than or equal to the lower limit of the second byte and less than or equal to the upper limit of the second byte, it is determined that the byte combination formed by the current byte and the next byte is within the preset double-byte character range, and it is determined that the byte group conforms to the GBK format, and the next byte after the byte combination is exclusively controlled. If the current byte is not within the range of the preset single-byte character and not within the range of the first byte of the preset double-byte character, or if the byte combination is not within the range of the preset double-byte character, the BeiDou message to be detected is determined to have a bit error.
2. The method for detecting BeiDou message errors based on GBK format according to claim 1, characterized in that, The short message sub-packets are sequentially concatenated based on the first frame identifier and the continuation frame identifier carried by each short message sub-packet to obtain the BeiDou message to be detected, including: The first frame sub-packet is determined from the plurality of short message sub-packets based on the first frame identifier carried by each of the short message sub-packets; The first frame sub-packet is used as the starting sub-packet for splicing, and the short message sub-packets received after the first frame sub-packet are spliced sequentially according to the receiving order of the multiple short message sub-packets; When splicing the data to a short message sub-packet that indicates no continuation frame, the BeiDou message to be detected is obtained.
3. The method for detecting BeiDou message errors based on GBK format according to claim 1, characterized in that, The preset single-byte character range is the range where the byte value is less than or equal to the hexadecimal number 0x80.
4. The method for detecting BeiDou message errors based on GBK format according to claim 1, characterized in that, The first byte range of the preset double-byte character is the range where the byte value is greater than or equal to the hexadecimal number 0x81 and less than or equal to the hexadecimal number 0xFE.
5. The method for detecting BeiDou message errors based on GBK format according to claim 1, characterized in that, The second byte range of the preset double-byte character is the range where the byte value is greater than or equal to the hexadecimal number 0x40 and less than or equal to the hexadecimal number 0xFE.
6. The method for detecting BeiDou message errors based on GBK format according to claim 1, characterized in that, If the first byte value of the current byte does not match any of the first byte values of the legal combination items in the preset set of legal GBK combinations, or if the next byte is not located between the lower limit value and the upper limit value of the second byte corresponding to the first byte value that was successfully matched, it is determined that the byte combination formed by the current byte and the next byte is not within the preset range of double-byte characters.
7. The method for detecting BeiDou message errors based on GBK format according to claim 1, characterized in that, The method further includes: If the message content of the BeiDou message to be detected conforms to the GBK format, the BeiDou message to be detected is output.
8. A machine-readable storage medium storing instructions thereon, characterized in that, When executed by the processor, this instruction causes the processor to be configured to perform the BeiDou message error detection method based on GBK format according to any one of claims 1 to 7.
Citation Information
Patent Citations
UTF-8 (8-bit Unicode transformation format) and ANSI (American national standards institute) code identification method and device
CN103970913A
Data transmission method and system based on Beidou short message
CN114499765A
