Communication collection method, computer device, and computer readable storage medium

By introducing identification information and channel information into the data stream, efficient communication between the collector and the device is achieved, the problem of low communication efficiency in the prior art is solved, and the data acquisition rate is significantly improved.

CN115442394BActive Publication Date: 2025-02-07FOSHAN AKE ELECTRONICS ENG CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210908109.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2025-02-07
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

The serial communication between the existing collector and the instrument is inefficient, which results in too long communication when it is necessary to collect multiple instrument data in engineering projects.

Method used

The communication acquisition method based on data flow hand-in-hand data distribution is adopted. By introducing identification information and channel information into the data bytes, the first terminal can quickly filter and extract data information belonging to its own channel based on the channel information, thereby achieving efficient communication.

Benefits of technology

It realizes fast communication between the collector and the device, improves the data acquisition rate several times, reduces communication time, and improves communication efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115442394B_ABST
    Figure CN115442394B_ABST
Patent Text Reader

Abstract

The present invention discloses a communication acquisition method based on data stream hand-in-hand data distribution, a computer device and a computer-readable storage medium, and relates to the field of communication technology. The communication acquisition method based on data stream hand-in-hand data distribution includes: a first terminal sequentially receives data bytes sent by a second terminal, and the data bytes include identification information, channel information and data information; each time the first terminal receives a data byte, the data information of the current data string is extracted according to the identification information and channel information of the data byte; each time the first terminal extracts data information of two data bytes in the current data string, the data information of the two data bytes is combined into a reference byte, the first reference byte in the current data string is a feature byte, and the other reference bytes in the current data string are content bytes; the first terminal constructs a data frame according to the content byte, and operates according to the data frame. The present invention can realize efficient communication between a collector and a device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a communication collection method based on hand-in-hand data distribution of data streams, a computer device and a computer-readable storage medium. Background Art

[0002] like Figure 1 As shown, currently the collector and the instrument use serial communication. When the collector needs to collect data from the instrument, it can only collect data one by one in sequence, that is, the collector needs to collect data from device A first, then device B, and so on, until the collection of device F is completed; accordingly, if the project contains multiple instruments, each polling of the instrument will take a lot of time.

[0003] Therefore, it is necessary to develop a new communication collection method to achieve fast communication between the collector and the instrument and improve communication efficiency. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a communication collection method, a computer device and a computer-readable storage medium based on hand-in-hand data distribution of data streams, which can realize efficient communication between a collector and a device.

[0005] In order to solve the above technical problems, the present invention provides a communication collection method based on hand-in-hand data distribution of data streams, including: a first terminal receives data bytes sent by a second terminal in sequence, and the data bytes include identification information, channel information and data information; each time the first terminal receives one of the data bytes, the data information of the current data string is extracted according to the identification information and channel information of the data byte; each time the first terminal extracts data information of two of the data bytes in the current data string, the data information of the two data bytes is combined into a reference byte, the first reference byte in the current data string is a feature byte, and the other reference bytes in the current data string are content bytes; the first terminal constructs a data frame according to the content bytes, and operates according to the data frame.

[0006] As an improvement of the above scheme, the step of extracting data information of the current data string according to the identification information and channel information of the data byte includes: identifying the identification information and channel information in the data byte; wherein, if the identification information is a high-order identification and the channel information is a target channel, constructing a new data string and using the new data string as the current data string, extracting the data information of the data byte and using the data information as the data of the current data string; if the identification information is a low-order identification and the channel information is a target channel, extracting the data information of the data byte and using the data information as the data of the current data string; if the channel information is a non-target channel, discarding the data byte.

[0007] As an improvement of the above solution, the data byte includes 8 bits, wherein the first bit is used to record identification information, the second to fourth bits are used to record channel information, and the fifth to eighth bits are used to record data information.

[0008] As an improvement of the above solution, the characteristic byte includes 8 bits, wherein the 1st to 4th bits are used to record the baud rate, the 5th to 6th bits are used to record the check information, and the 7th bit is used to record the stop information.

[0009] As an improvement of the above-mentioned scheme, the communication collection method based on hand-in-hand data distribution of data streams also includes: the first terminal generates an original data string to be transmitted; each time the first terminal starts to read an original data string, it generates a first identification byte and a second identification byte, and sends the first identification byte and the second identification byte to the second terminal; the first terminal reads the original data bytes in the original data string in sequence; each time the first terminal reads an original data byte, it splits the original data byte into a first target data byte and a second target data byte, and sends the first target data byte and the second target data byte to the second terminal.

[0010] As an improvement of the above solution, the first identification byte includes a high-order identification, channel information and first baud information, and the second identification byte includes a low-order identification, channel information and second baud information.

[0011] As an improvement of the above scheme, the original data byte includes a first data item and a second data item, the first target data byte includes a low-order flag, channel information and the first data item, and the second target data byte includes a low-order flag, channel information and the second data item.

[0012] As an improvement of the above solution, the first terminal and the second terminal communicate via a serial port.

[0013] Correspondingly, the present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, wherein the processor implements the steps of the above-mentioned communication collection method based on hand-in-hand data distribution of data streams when executing the computer program.

[0014] Correspondingly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the above-mentioned communication collection method based on hand-in-hand data distribution of data streams are implemented.

[0015] The implementation of the present invention has the following beneficial effects:

[0016] When the second terminal sends data bytes, it sends the identification information, channel information and data information to the first terminal; when the first terminal receives the corresponding data bytes, it extracts the data information belonging to the channel number corresponding to itself; thereby, the second terminal can quickly communicate with multiple first terminals, increasing the data collection rate by several times.

[0017] In addition, the first terminal can also quickly feed back the collected data to the collector, thereby achieving efficient communication between the terminals. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a connection diagram between the collector and the device;

[0019] Figure 2 It is a flow chart of a first embodiment of a communication collection method based on hand-in-hand data distribution of data streams of the present invention;

[0020] Figure 3 It is a flow chart of a second embodiment of the communication collection method based on hand-in-hand data distribution of data streams of the present invention. DETAILED DESCRIPTION

[0021] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings.

[0022] See also Figure 2 , Figure 2 The first embodiment of the communication collection method based on hand-in-hand data distribution of data streams of the present invention is shown, which comprises:

[0023] S101, a first terminal sequentially receives data bytes sent by a second terminal.

[0024] Accordingly, the data byte includes identification information, channel information and data information;

[0025] like Figure 1As shown, the first terminal and the second terminal communicate via a serial port. It should be noted that the first terminal in the present invention can be a collector or a device, and the second terminal can also be a collector or a device; when the first terminal is a collector, the second terminal is a device; when the first terminal is a device, the second terminal is a collector; that is, the communication collection method of the present invention can be applied to both collectors and devices.

[0026] Different from the prior art, the present invention groups the devices under the serial port according to the channel number (can be divided into a maximum of 8 channels), and introduces channel information in the data byte, so that the first terminal can determine whether the data byte belongs to itself based on the channel information in the data byte, and thus extract the corresponding data information.

[0027] Furthermore, the data byte in the present invention includes 8 bits, wherein the first bit is used to record identification information, the second to fourth bits are used to record channel information, and the fifth to eighth bits are used to record data information. The specific data byte format is shown in Table 1:

[0028] Table 1

[0029]

[0030] S102, each time the first terminal receives a data byte, it extracts data information of the current data string according to identification information and channel information of the data byte;

[0031] Since the present invention groups the devices under the serial port according to the channel number, the first terminal can determine whether the data byte belongs to itself according to the channel information in the data byte, thereby extracting the data information belonging to itself.

[0032] Specifically, the step of extracting data information of the current data string according to the identification information and channel information of the data byte includes: identifying the identification information and channel information in the data byte; wherein,

[0033] (1) If the identification information is a high-order identification and the channel information is a target channel, a new data string is constructed and the new data string is used as the current data string, and the data information of the data byte is extracted and the data information is used as the data of the current data string;

[0034] (2) If the identification information is a low-order identification and the channel information is a target channel, extract the data information of the data byte and use the data information as the data of the current data string;

[0035] (3) If the channel information is not the target channel, the data byte is discarded.

[0036] Referring to Table 1, when the second terminal sends data bytes, the upper 4 bits of each data byte are feature bits for recording identification information and channel information, and the lower 4 bits are data bits for recording data information; therefore, if the data byte carries a high-bit identification, the data byte is judged to be the first valid content, and when the first terminal receives this data byte, it starts to parse the subsequent data bytes; accordingly, when the first terminal performs parsing, it is necessary to perform channel judgment on each data byte, and if this data byte is the corresponding channel content, it is retained; otherwise, it is discarded.

[0037] S103, whenever the first terminal extracts data information of two data bytes in the current data string, it combines the data information of the two data bytes into a reference byte.

[0038] Among them, the first reference byte in the current data string is the feature byte, and the other reference bytes in the current data string are content bytes.

[0039] Accordingly, the feature byte includes 8 bits, of which the 1st to 4th bits are used to record the baud rate, the 5th to 6th bits are used to record the check information, and the 7th bit is used to record the stop information. The specific feature byte format is shown in Table 2:

[0040] Table 2

[0041]

[0042] S104: The first terminal constructs a data frame according to the content bytes, and operates according to the data frame.

[0043] It should be noted that, after each receiving two data bytes, the first terminal extracts the corresponding data information and synthesizes a complete reference byte; if the synthesized reference byte is the first byte in the current data string, the baud rate of the corresponding data is parsed according to the format of Table 2; accordingly, in the current data string, the second byte synthesized by the first terminal starts to be the formal data information, which can be judged according to the preset protocol content, and the data frame is composed according to the corresponding rules, and the corresponding data is returned.

[0044] The present invention will be further described below in conjunction with specific embodiments:

[0045] When the first terminal is device A and corresponds to channel 6, and the second terminal is a collector.

[0046] (1) The collector sends the data "E2 61 6D 6B 6D 6B 6D 6B 60 61 60 61 60 60 6060 65 66 6C 69" to device A;

[0047] (2) Device A receives the data bytes sent by the collector in sequence;

[0048] (3) Each time device A receives a data byte, it extracts the data information of the current data string based on the identification information and channel information of the data byte;

[0049] When device A receives the data byte "E2", it can identify that the binary representation of "E2" is "1110 0010". Since Bit7 in the binary representation is "1", it is a high-order identifier; Bit6-Bit4 are "110", which is channel 6; Bit3-Bit0 are "0010", which is data information; therefore, it can be determined that the identification information in the data byte "E2" is a high-order identifier and the channel information is the target channel. At this time, a new data string is constructed and the new data string is used as the current data string, and the data information "0010" is extracted and the data information "0010" is used as the data of the current data string;

[0050] When device A receives the data byte "61", it can identify that the binary representation of "61" is "0110 0001". Since Bit7 in the binary representation is "0", it is a low-order identifier; Bit6-Bit4 are "110", which is channel 6; Bit3-Bit0 are "0001", which is data information; therefore, it can be determined that the identification information in the data byte "61" is a low-order identifier and the channel information is the target channel. At this time, the data information "0001" can be directly extracted and used as the data of the current data string;

[0051] By analogy, the subsequent data bytes "6D", "6B", "6D", "6B", "6D", "6B", "60", "61", "60", "61", "60", "60", "60", "60", "65", "66", "6C", "69" can be identified respectively to extract the data information of the data string "1101", "1011", "1101", "1011", "1101", "1011", "0000", "0001", "0000", "0000", "0000", "0000", "0101", "0110", "1100", "1001".

[0052] (4) Whenever device A extracts data information of two data bytes in the current data string, it combines the data information of the two data bytes into a reference byte, the first reference byte in the current data string is the feature byte, and the other reference bytes in the current data string are content bytes;

[0053] When device A extracts the data information "0010" and "0001", it can be synthesized into a reference byte "21"; and so on, the reference bytes "DB", "DB", "DB", "01", "01", "00", "00", "56", and "C9" can be synthesized according to the subsequent data information "1101", "1011", "1101", "1011", "1101", "1011", "0000", "0001", "0000", "0000", "0000", "0000", "0101", "0110", "1100", and "1001".

[0054] Among them, the first reference byte "21" in the current data string is a feature byte; other reference bytes "DB", "DB", "DB", "01", "01", "00", "00", "56", and "C9" in the current data string are content bytes.

[0055] Accordingly, according to Table 2, it can be interpreted from the characteristic byte "21" that is "0010 0001" that the baud rate of this data string is "4800"; at the same time, it can also judge "DB DB DB 01 01 00 00 56 C9" according to the preset protocol content, and form a data frame according to the corresponding rules, and return the corresponding data.

[0056] (5) Device A constructs a data frame based on the content bytes and operates according to the data frame.

[0057] Therefore, when the second terminal sends data bytes, it will send identification information, channel information and data information to the first terminal. When the first terminal receives the corresponding data bytes, it determines whether the data bytes belong to itself. If so, it processes and returns, otherwise it does not process. In this way, the second terminal can quickly collect data from multiple first terminals, increasing the collection data rate by 8 times.

[0058] See also Figure 3 , Figure 3 A second embodiment of the communication collection method based on hand-in-hand data distribution of data streams of the present invention is shown, which comprises:

[0059] S201, the first terminal sequentially receives data bytes sent by the second terminal.

[0060] The data bytes include identification information, channel information and data information.

[0061] S202: Whenever the first terminal receives a data byte, it extracts data information of the current data string according to identification information and channel information of the data byte.

[0062] S203, whenever the first terminal extracts data information of two data bytes in the current data string, it combines the data information of the two data bytes into a reference byte.

[0063] Among them, the first reference byte in the current data string is the feature byte, and the other reference bytes in the current data string are content bytes.

[0064] S204: The first terminal constructs a data frame according to the content bytes, and operates according to the data frame.

[0065] S205: The first terminal generates an original data string to be transmitted.

[0066] When the first terminal is a device and the second terminal is a collector, the device can generate an original data string based on the data frame and feed the original data string back to the collector; when the first terminal is a collector and the second terminal is a device, the collector can generate an original data string based on user needs and send the original data string to the collector.

[0067] S206, each time the first terminal starts to read an original data string, it generates a first identification byte and a second identification byte, and sends the first identification byte and the second identification byte to the second terminal;

[0068] The first identification byte includes a high-order identification, channel information and first baud information, and the second identification byte includes a low-order identification, channel information and second baud information.

[0069] It should be noted that before the first terminal transmits the original data string, it needs to convert the original data string; specifically, each time the first terminal starts to read an original data string, it generates a first identification byte and a second identification byte; wherein the first identification byte is used to identify the start of the original data string (i.e., the high-order identification), the channel number (i.e., the channel information) and the baud rate (i.e., the first baud information).

[0070] S207, the first terminal reads the original data bytes in the original data string in sequence;

[0071] The original data bytes include a first data item and a second data item,

[0072] S208, each time the first terminal reads an original data byte, the original data byte is split into a first target data byte and a second target data byte, and the first target data byte and the second target data byte are sent to the second terminal.

[0073] The first target data byte includes a low-order mark, channel information and a first data item, and the second target data byte includes a low-order mark, channel information and a second data item.

[0074] For example, if the original data is "DB", the corresponding first data item is "D" and the second data item is "B"; then, split it into the first target data byte "0110 1101" and the second target data byte "0110 1011", among which, the first target data byte and Bit7 in the first target data byte are "0", which is the low-order mark, and Bit6-Bit4 are "110", which is channel 6; Bit3-Bit0 of the first target data byte are "1101", which is the first data item "D", and Bit3-Bit0 of the second target data byte are "1011", which is the first data item "B".

[0075] The present invention will be further described below in conjunction with specific embodiments:

[0076] The first terminal is a collector, when the second terminal is device A and corresponds to channel 6.

[0077] (1) The collector generates the original data string “DB DB DB 01 01” to be transmitted according to user requirements.

[0078] (2) Every time the collector starts to read the original data string "DB DB DB 01 01", it generates the first identification byte "E2" and the second identification byte "61", and sends "E2" and "61" to device A;

[0079] (3) The collector reads the original data bytes "DB", "DB", "DB", "01", "01" in the original data string in sequence;

[0080] (4) Each time the collector reads an original data byte, it splits the original data byte into a first target data byte and a second target data byte, and sends the first target data byte and the second target data byte to device A.

[0081] When the collector reads the original data byte "DB", it can split "DB" into the first target data byte "01101101" and the second target data byte "0110 1011" or "6D", and send "0110 1101" and "0110 1011" or "6B" to device A.

[0082] By analogy, the subsequent data bytes "DB", "DB", "01", "01" can be split to generate "6D", "6B", "6D", "6B", "60", "61", "60", "61" and sent to device A.

[0083] Finally, the data bytes received by device A are “E2 61 6D 6B 6D 6B 6D 6B 60 61 60 61”.

[0084] Therefore, in the present invention, the collector can quickly collect data from multiple devices, increasing the collection data rate by 8 times; at the same time, the devices can also quickly feed back the collected data to the collector, thereby achieving efficient communication between the collector and the devices.

[0085] Correspondingly, the present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, wherein the processor implements the steps of the communication collection method based on hand-in-hand data distribution of data streams when executing the computer program. At the same time, the present invention also discloses a computer-readable storage medium, which stores a computer program, wherein the computer program implements the steps of the communication collection method based on hand-in-hand data distribution of data streams when executed by the processor.

[0086] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A communication collection method based on hand-in-hand data distribution of data streams, characterized in that: include: The first terminal sequentially receives data bytes sent by the second terminal, wherein the data bytes include identification information, channel information and data information; Each time the first terminal receives one of the data bytes, it extracts data information of the current data string according to the identification information and channel information of the data byte; Each time the first terminal extracts data information of two data bytes in the current data string, the data information of the two data bytes are combined into a reference byte, the first reference byte in the current data string is a feature byte, and the other reference bytes in the current data string are content bytes; The first terminal constructs a data frame according to the content bytes and operates according to the data frame; The first terminal generates an original data string to be transmitted; Each time the first terminal starts to read an original data string, it generates a first identification byte and a second identification byte, and sends the first identification byte and the second identification byte to the second terminal; the first identification byte includes a high-order identification, channel information and first baud information, and the second identification byte includes a low-order identification, channel information and second baud information; The first terminal sequentially reads original data bytes in the original data string; Each time the first terminal reads an original data byte, the original data byte is split into a first target data byte and a second target data byte, and the first target data byte and the second target data byte are sent to the second terminal.

2. The communication collection method based on hand-in-hand data distribution of data streams as claimed in claim 1 is characterized in that: The step of extracting data information of the current data string according to the identification information and channel information of the data byte comprises: Identify the identification information and channel information in the data bytes; wherein, If the identification information is a high-order identification and the channel information is a target channel, a new data string is constructed and the new data string is used as the current data string, data information of the data byte is extracted and the data information is used as data of the current data string; If the identification information is a low-order identification and the channel information is a target channel, extracting data information of the data byte and using the data information as data of the current data string; If the channel information is a non-target channel, the data byte is discarded.

3. The communication collection method based on hand-in-hand data distribution of data streams as claimed in claim 1 is characterized in that: The data byte includes 8 bits, wherein the first bit is used to record identification information, the second to fourth bits are used to record channel information, and the fifth to eighth bits are used to record data information.

4. The communication collection method based on hand-in-hand data distribution of data streams as claimed in claim 1, characterized in that: The characteristic byte includes 8 bits, wherein the 1st to 4th bits are used to record the baud rate, the 5th to 6th bits are used to record the check information, and the 7th bit is used to record the stop information.

5. The communication collection method based on hand-in-hand data distribution of data streams as claimed in claim 1, characterized in that: The original data byte includes a first data item and a second data item, the first target data byte includes a low-order mark, channel information and the first data item, and the second target data byte includes a low-order mark, channel information and the second data item.

6. The communication collection method based on hand-in-hand data distribution of data streams as claimed in claim 1, characterized in that: The first terminal communicates with the second terminal via a serial port.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Multi-channel serial port communication method and system based on software simulation

    CN114253879A