Internet of Things general data transmission method and device, and storage medium

By encapsulating and transmitting IoT data in file concepts, the problem that the Internet of Things communication protocol in the prior art is not compatible with data transmission across physical layers is solved, and efficient collaboration between different protocols and physical layers is achieved.

CN119814773AActive Publication Date: 2025-04-11SHENZHEN POWEROAK NEWENER CO LTD

Patent Information

Application Number
CN202510286452.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-12
Publication Date
2025-04-11
Estimated Expiration
2045-03-12

AI Technical Summary

Technical Problem

The existing Internet of Things communication protocol is only applicable to the limited scope of the specific physical layer and cannot be effectively compatible with data transmission across the physical layer, resulting in insufficient data transmission efficiency and scalability.

Method used

The data is summarized using the file concept, and the file and file index are encapsulated into data blocks through a preset encapsulation format. The data blocks are encapsulated into corresponding data frames according to the currently used message transmission protocol, so as to decouple the transmission protocol and the transmission content.

Benefits of technology

It realizes efficient coordination between different IoT communication protocols between different physical layer media and MCUs, improves the delay and throughput of data transmission, and solves the compatibility problem of data transmission across physical layer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814773A_ABST
    Figure CN119814773A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of Internet of Things communication, in particular to an Internet of Things general data transmission method and device and a storage medium. The universal data transmission method for the Internet of Things comprises the steps that an upper computer encapsulates a target file index into a file reading data block according to a preset first encapsulation format; packaging the file reading data block into a first index data frame based on a currently used message transmission protocol, and sending the first index data frame to a lower computer; receiving a first content data frame sent by the lower computer, and analyzing the first content data frame based on a message transmission protocol to obtain a file content data block; and analyzing the file content data block based on a preset second packaging format to obtain target file content. According to the method provided by the invention, decoupling of the transmission protocol and the transmission content is realized, so that different Internet of Things communication protocols can efficiently cooperate between different physical layer media and MCUs based on the same data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet of Things communication technology, and in particular to a universal data transmission method, device and storage medium for the Internet of Things. Background Art

[0002] In the existing IoT communication network, there are various physical transmission media, such as Ethernet (wired, wireless, WIFI, 2 / 3 / 4 / 5G cellular network), serial communication (UART / RS232 / RS485), CAN (Controller Area Network), etc. Equivalent to the OSI (Open System Interconnect) communication data model, different physical transmission media correspond to different application layer communication protocols. In the prior art, Ethernet and serial communication often use the standard Modbus communication protocol, and the standard application layer protocols commonly used by the CAN bus include CANopen, SAE J1939, etc. Each standard is only applicable to the limited range of each specific physical layer, and there is no good compatibility for cross-physical layer data transmission.

[0003] The data between IoT devices generally includes real-time data, historical data, configuration parameters, etc. Conventional transmission methods are based on limited specific signal quantity requirements. The data point table (or register) is gradually expanded based on the requirements in a toothpaste-squeezing manner, and the table length is infinitely increased by spreading out. Because the data content is associated with the data point table, the data cannot be well structured. Different data structures need to be distinguished by different data point table addresses, and the data length is limited by the protocol address length range (the maximum address length of the Modbus protocol is 65536). For historical record data stored on the device side, a simple and immediate question-and-answer interaction protocol is generally used (that is, the upper computer sends a message to query the specified object, and the lower computer immediately returns a valid content message based on the object index). This method cannot properly handle the actual delay of local data reading and the maximum response delay of protocol transmission.

[0004] In summary, each IoT communication protocol is only applicable to a limited range of each specific physical layer and cannot be well compatible with cross-physical layer data transmission. In order to simplify and unify data communication in IoT embedded systems, a cross-physical layer data transmission method is urgently needed to enable different IoT communication protocols to efficiently collaborate (such as latency and throughput) between different physical layer media and MCUs (Microcontroller Units) based on the same data. Summary of the invention

[0005] The embodiments of the present application provide a universal data transmission method, device and storage medium for the Internet of Things, which solve the problem that various Internet of Things communication protocols in the prior art are only applicable to the limited range of each specific physical layer and cannot be well compatible with cross-physical layer data transmission.

[0006] In a first aspect, an embodiment of the present application provides a general Internet of Things data transmission method, which is applied to a host computer, and the method includes: Encapsulating the target file index into a file reading data block according to a preset first encapsulation format; Based on the currently used message transmission protocol, the file reading data block is encapsulated into a first index data frame and then sent to the lower computer; Receiving a first content data frame sent by a lower computer, parsing the first content data frame based on the message transmission protocol to obtain a file content data block; The file content data block is parsed based on a preset second encapsulation format to obtain target file content.

[0007] Optionally, the data block encapsulated in the first encapsulation format includes index information, data offset information and a continuous write flag, and the data block encapsulated in the second encapsulation format includes data classification, total data, current data transmission length, data offset information and current load data.

[0008] Optionally, the method further includes: Encapsulating the query directory index into a file query data block according to the first encapsulation format; Based on the message transmission protocol, the file query data block is encapsulated into a second index data frame and then sent to the lower computer; receiving a second content data frame sent by the lower computer, parsing the second content data frame based on the message transmission protocol to obtain an index content data block; The index content data block is parsed based on the second encapsulation format to obtain target index content.

[0009] Optionally, the data after parsing the file content data block based on the second encapsulation format includes the total data amount, the current data transmission length, the data offset information and the current load data, and the method further includes: Determining whether the target file has been transferred according to the total amount of data, the current data transfer length and the data offset information; If not, when the message transmission protocol is the CAN protocol, if the continuous write flag carried by the file read data block is yes, continue to receive other first content data frames based on the target file sent by the lower computer until all target file contents are received; when the message transmission protocol is the Modbus protocol, obtain a new first index data frame based on the target file index and new data offset information, send the new first index data frame to the lower computer, and then receive a new first content data frame sent by the lower computer based on the new first index data frame until all target file contents are received.

[0010] Optionally, when the message transmission protocol is a CAN protocol, the first index data frame includes a write data block start frame and at least one data load frame, and the encapsulating the file read data block into the first index data frame based on the currently used message transmission protocol and sending it to the lower computer includes: The file read data block is encapsulated into a write data block start frame and at least one data load frame according to the data frame format of the CAN protocol, and the write data block start frame and the at least one data load frame are sent to the lower computer in sequence, wherein the data segment of the write data block start frame includes the data block type, the data start position, the data length and the load data verification information, and the data segment of the data load frame includes the data block type, the data packet number and the load data.

[0011] Optionally, when the message transmission protocol is the Modbus protocol, encapsulating the file reading data block into a first index data frame based on the currently used message transmission protocol and then sending it to the lower computer includes: Encapsulate the file read data block into a first index data frame based on the first preset address space corresponding to the first encapsulation format according to the multi-byte write request frame format of the Modbus protocol, and send the first index data frame to the lower computer; The receiving of the first content data frame sent by the lower computer comprises: Constructing a first content request frame based on a second preset address space corresponding to the second encapsulation format according to a multi-byte read request frame format of the Modbus protocol and sending the frame to the lower computer; The first content data frame returned by the lower computer according to the multi-byte read response frame format of the Modbus protocol is received.

[0012] In a second aspect, an embodiment of the present application provides a general Internet of Things data transmission method, which is applied to a lower computer, and the method includes: Receive a first index data frame sent by the host computer, and parse the first index data frame based on the currently used message transmission protocol to obtain a file reading data block; Parsing the file read data block based on a preset first encapsulation format to obtain a target file index; Determine a target file corresponding to the target file index according to the target file index, and encapsulate the target file content into a file content data block according to a preset second encapsulation format; The file content data block is encapsulated into a first content data frame based on the message transmission protocol and then sent to a host computer.

[0013] Optionally, the data block encapsulated in the first encapsulation format includes index information, data offset information and a continuous write flag, and the data block encapsulated in the second encapsulation format includes data classification, total data, current data transmission length, data offset information and current load data.

[0014] Optionally, the method further includes: Receiving a second index data frame sent by the host computer, parsing the second index data frame based on the message transmission protocol to obtain a file query data block; Parsing the file query data block based on the first encapsulation format to obtain a query directory index; Determine a target index corresponding to the query directory index according to the query directory index, and encapsulate the target index content into an index content data block according to the second encapsulation format; The index content data block is encapsulated into a second content data frame based on the message transmission protocol, and the second content data frame is sent to a host computer.

[0015] Optionally, when the message transmission protocol is a CAN protocol, the first content data frame includes a write data block start frame and at least one data payload frame, and the encapsulating the file content data block into the first content data frame based on the message transmission protocol and then sending it to the host computer includes: The file content data block is encapsulated into a write data block start frame and at least one data load frame according to the data frame format of the CAN protocol, and the write data block start frame and the at least one data load frame are sent to the host computer in sequence; wherein the data segment of the write data block start frame includes the data block type, the data start position, the data length and the load data verification information, and the data segment of the data load frame includes the data block type, the data packet number and the load data.

[0016] Optionally, the data after parsing the file read data block based on the first encapsulation format includes a target file index, data offset information and a continuous write flag, and when the continuous write flag is yes, determining a target file corresponding to the target file index according to the target file index, and encapsulating the target file content into a file content data block according to a preset second encapsulation format includes: Determine the target file content according to the target file index and the data offset information; The target file content is encapsulated into one or more file content data blocks according to a second encapsulation format.

[0017] Optionally, when the message transmission protocol is the Modbus protocol, encapsulating the file content data block into a first content data frame based on the message transmission protocol and then sending the frame to the host computer includes: Receiving a first content request frame constructed by a host computer according to a multi-byte read request frame format of the Modbus protocol based on a second preset address space corresponding to the second encapsulation format; The file content data block is encapsulated into a first content data frame based on the second preset address space according to the multi-byte read response frame format of the Modbus protocol and then sent to the host computer.

[0018] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor can execute any of the methods described above.

[0019] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores instructions or programs. When the instructions or programs are executed by at least one processor, the at least one processor executes any one of the methods described above.

[0020] In an embodiment of the present application, a general data transmission method for the Internet of Things is provided, wherein the upper computer encapsulates the target file index into a file read data block according to a preset first encapsulation format, and encapsulates the file read data block into a first index write request frame based on the currently used message transmission protocol and then sends it to the lower computer; receives the first content data frame sent by the lower computer, parses the first content data frame based on the message transmission protocol to obtain a file content data block, and parses the file content data block based on a preset second encapsulation format to obtain the target file content. The method of the present application uses the concept of file to summarize various types of data, and establishes a mapping relationship between files and file indexes. When performing file transmission, files and file indexes are encapsulated into data blocks using different encapsulation formats, and then the data blocks are encapsulated into corresponding data frames for transmission according to the currently used message transmission protocol, thereby realizing the decoupling of the transmission protocol and the transmission content, so that different Internet of Things communication protocols can be based on the same data and efficiently collaborate between different physical layer media and MCUs. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1aAn exemplary bus topology diagram based on the Modbus protocol is shown; Figure 1b A topological structure diagram of a CAN bus is shown as an example; Figure 2a The structure diagram of a Modbus RTU message frame is shown as an example; Figure 2b The following is an exemplary diagram showing a frame structure of a CAN protocol data frame; Figure 3 A schematic diagram of the hardware structure of an electronic device is exemplarily shown; Figure 4 The flowchart of the general data transmission method of the Internet of Things applied to the host computer is exemplified; Figure 5 The flowchart of the general data transmission method of the Internet of Things applied to the lower computer is exemplified; Figure 6 The structure diagram of the first packaging format is exemplarily shown; Figure 7 The structure diagram of the second packaging format is exemplarily shown; Figure 8 The structure diagram of the write data block start frame, data load frame and data response frame based on the CAN protocol is exemplarily shown; Fig. 9 The format diagram of the Modbus protocol standard multi-byte write request frame and multi-byte write response frame is exemplarily shown; Fig.10 The schematic diagram of the format of the Modbus protocol standard multi-byte read request frame and multi-byte read response frame is exemplarily shown; Fig.11 The following is a schematic diagram showing the whole process of file transmission based on CAN protocol; Fig.12 The schematic diagram of the whole process of file transmission based on Modbus protocol is shown as an example. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0023] Please refer to Figure 1a , Figure 1a The following is an example of a bus topology diagram based on the Modbus protocol. Figure 1a As shown in Figure 1, multiple devices are connected to the same bus. To avoid data conflicts, the Modbus protocol uses a master-slave communication method. In a Modbus communication system, there is a host device (such as Figure 1a device A) and multiple slave devices (such as Figure 1a Devices B, C and D in the middle). The Modbus protocol adopts a request-response mode and stipulates that Modbus requests can only be initiated by the host, that is, the host sends request data to the slave, and the slave can only receive requests from the host and make corresponding responses, returning response data to the host. The slave cannot actively initiate requests and can only passively receive requests from the host. In order to avoid data conflicts, the host cannot send data in parallel. After sending the first data, the second data can only be sent after the slave returns a response or the response times out. Each slave has only one slave address in a system. When the host sends a data request, it will carry the address of the target slave in the request data. When the host sends data to the bus, each slave will receive the data from the host, but only the slave with the same target address as the request data will respond, and other slaves will ignore this request.

[0024] Please refer to Figure 2a , Figure 2a The structure diagram of the Modbus RTU message frame is shown as an example. Figure 2a As shown in the figure, the RTU (Remote Terminal Unit) message frame consists of an address code, a function code, a data field, and a check code. The address code occupies one byte and is used to identify the destination address of the message. Each slave has a unique address. The function code occupies one byte and is used to indicate the type of operation the host has on the slave. The data field occupies 0 to 252 bytes, and its length and content are determined by the function code. The check code occupies two bytes and is used to ensure the correct transmission of the message.

[0025] Please refer to Figure 1b , Figure 1b The topological structure diagram of a CAN bus is shown as an example. Figure 1b As shown in the figure, the CAN bus includes two lines, CAN_H and CAN_L. Nodes 1 to N are connected to the CAN bus through the CAN controller and the CAN transceiver respectively. In the CAN protocol, the types of frames are mainly divided into data frames, remote frames, error frames and overload frames. Among them, data frames are used to send data, remote frames are used to request data, error frames are used to indicate that an error has occurred, and overload frames are used to indicate that the node cannot receive data.

[0026] Please refer to Figure 2b , Figure 2bThe frame structure diagram of the CAN protocol data frame is shown as an example. The data frame includes a standard frame and an extended frame. Each data frame may specifically include seven parts: frame start, arbitration segment, control segment, data segment, CRC segment, ACK segment and frame end segment. Among them, the arbitration segment is used to determine the transmission priority, including the data frame ID. The data segment contains the actual transmitted data, and a maximum of 8 bytes of data can be transmitted. When the data frame is transmitted on the CAN bus, each CAN node uses an acceptance filter to compare whether the data frame ID on the bus is consistent with the ID of the node. If they are consistent, the CAN controller allows the received information to be stored in the corresponding register. Through acceptance filtering technology, without the need for special scheduling, the CAN bus can realize data transmission in various ways such as one-to-one, one-to-many and global broadcast.

[0027] Please refer to Figure 3 , Figure 3 The hardware structure diagram of the electronic device is shown as an example. Figure 3 As shown, the electronic device 100 includes a processor 10, a memory 20 and a communication interface 30, and the processor 10, the memory 20 and the communication interface 30 are connected through a line. Figure 3 In the illustrated embodiment, the processor 10, the memory 20 and the communication interface 30 are communicatively connected to each other via a bus.

[0028] The memory 20 is used to store software programs, computer executable program instructions, etc. The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created according to the use of the electronic device, etc.

[0029] The memory 20 may be a read-only memory (ROM), or other types of static storage devices that can store static information and instructions, or a random access memory (RAM), or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), and the specifics are not limited here.

[0030] Exemplarily, the aforementioned memory 20 may be a double data rate synchronous dynamic random access memory DDR SDRAM (DDR for short). The memory 20 may exist independently but be connected to the processor 10. Optionally, the memory 20 may also be integrated with the processor 10. For example, integrated into one or more chips.

[0031] In some embodiments, the memory 20 may include a memory remotely located relative to the processor 10, and the remote memory may be connected to the electronic device via a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0032] The processor 10 uses various interfaces and lines to connect various parts of the entire electronic device 100, and performs various functions of the electronic device and processes data by running or executing software programs stored in the memory 20 and calling data stored in the memory 20, such as implementing the method described in any embodiment of the present application.

[0033] The processor 10 may be a Field Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), a Central Processing Unit (CPU), or the like.

[0034] The processor 10 may be a single-core processor or a multi-core processor. For example, the processor 10 may be composed of multiple FPGAs or multiple DSPs. In addition, the processor 10 may refer to one or more devices, circuits and / or processing cores for processing data (e.g., computer program instructions). The processor 10 may be a separate semiconductor chip or may be integrated into a semiconductor chip together with other circuits. For example, the processor 10 may form a system-on-a-chip (SoC) with other circuits (e.g., codec circuits, hardware acceleration circuits, or various buses and interface circuits), or may be integrated into an application-specific integrated circuit (ASIC) as a built-in processor of the ASIC. The ASIC with the integrated processor may be packaged separately or may be packaged together with other circuits.

[0035] The communication interface 30 may use a transceiver or other transceiver to implement communication between the electronic device and other devices or a communication network.

[0036] In order to solve the problem that various IoT communication protocols in the prior art are only applicable to the limited scope of each specific physical layer and cannot be well compatible with cross-physical layer data transmission, the present application adopts the concept of file to summarize various types of data, and establishes a mapping relationship between files and file indexes. When performing file transmission, files and file indexes are encapsulated into data blocks using different encapsulation formats, and then the data blocks are encapsulated into corresponding data frames for transmission according to the currently used message transmission protocol, thereby realizing the decoupling of transmission protocol and transmission content, and efficient collaboration of the same data between different physical layer media and MCUs.

[0037] The files in this application are formed by combining some data with interrelated contents and meanings in a preset format according to the requirements of the demander. For example, in the field of energy storage systems, various types of record files can be formed according to the data content that different demanders (such as customers, operation and maintenance engineers, and R&D engineers) need to view, such as fault records, operation records, historical power generation, equipment replacement records, etc.

[0038] Files have attributes such as file name, folder, file directory, file content, and file length. A file directory has different folders and folder levels, and a folder can have different files and subordinate folders. Directories and file names are used to distinguish the meanings of different files. A file may have different file lengths and file contents based on specific needs.

[0039] In order to adapt to data transmission of various sizes, this application adopts a data block-based transmission method. When the file to be transmitted is large, the file can be split into multiple data blocks for transmission, and the data offset is used to specify the data block to be transmitted each time, thereby realizing the breakpoint resume function.

[0040] Furthermore, based on the usage scenario of file transfer, the data block types are divided into two types: index type and content type. Among them, the index type data block mainly includes the directory and the file name, and is encapsulated in the first encapsulation format to indicate the directory to be queried or the target file to be read. The content type data block mainly includes the target index content or the target file content, and is encapsulated in the second encapsulation format to feedback the queried target index content or the read target file content to the requesting party. For example, the file reading data block and the file query data block below are index type data blocks, and the index content data block and the file content data block are content type data blocks.

[0041] The following describes the implementation process of the general data transmission method of the Internet of Things from the perspectives of the requester (i.e., the upper computer below) and the provider (i.e., the lower computer below).

[0042] Please refer to Figure 4 , Figure 4The flowchart of the general data transmission method of the Internet of Things applied to the host computer is exemplified, including: Step S401: encapsulate the target file index into a file reading data block according to a preset first encapsulation format.

[0043] Specifically, the target file index includes the directory and file name of the target file. In one embodiment, the data block encapsulated in the first encapsulation format includes index information, data offset information and a continuous write flag. The index information includes directory and file name information. In one embodiment, the directory and file name information are represented by an ASCII string.

[0044] Please refer to Figure 6 , Figure 6 The structure diagram of the first packaging format is exemplarily shown. Figure 6 As shown, in the first encapsulation format, the index information field occupies 10 bytes, of which the 1st to 2nd bytes represent the directory, and the 3rd to 10th bytes represent the file name. Assuming that the 1st byte is ' / ' and the 2nd byte is the secondary directory name, 61 secondary directories under the root directory can be represented: '1'~'9', 'A'~'Z', 'a'~'z'. For example, " / Z012345678" represents the "012345678" file under the secondary directory 'Z'. The directory and file name are up to 10 bytes long, and if the length is insufficient, it is supplemented with '\0'. When all 10 bytes are '\0', it means reading the root directory; when the secondary directory is not '\0' and the file name is all '\0', it means reading the file and folder information under the secondary directory (i.e. the target index content); when the secondary directory is '\0' and the file name is not '\0', it means reading the target file under the root directory (i.e. the target file content); when both the secondary directory and the file name are not '\0', it means reading the target file under the secondary directory (i.e. the target file content). The upper computer notifies the lower computer to perform corresponding operations by filling different contents in the index information field.

[0045] The data offset information field occupies 4 bytes and contains the read offset position of the target file or target index. The continuous write flag field occupies 2 bytes and is used to indicate whether the lower computer can split the target file content or target index content into multiple data blocks for transmission. Since the standard Modbus protocol is a question-and-answer type, the continuous write flag field is mainly used for the CAN protocol. When the continuous write flag is 1, it means that the target file content or target index content is supported to be split into multiple data blocks for transmission. When the continuous write flag is 0, it means that the target file content or target index content is not supported to be split into multiple data blocks for transmission. In some embodiments, by extending the Modbus protocol, a one-question-multiple-answer function can be realized. At this time, the continuous write flag can be used to indicate whether the lower computer can split the target file content or target index content into multiple data blocks for transmission.

[0046] Step S402: encapsulate the file read data block into a first index write request frame based on the currently used message transmission protocol and send it to the lower computer.

[0047] The message transmission protocols based on the Internet of Things mainly include the CAN protocol and the Modbus protocol. In the traditional CAN protocol, a data frame can only transmit 8 bytes of payload data, which cannot adapt to the transmission of data blocks with variable data size. Hereby, the present application customizes a multi-byte write operation based on the CAN protocol to transmit data blocks. The standard Modbus protocol supports multi-byte write and multi-byte read. In the embodiment of the present application, the standard Modbus protocol is directly used to realize the transmission of data blocks, so as to simplify and unify the data communication in the embedded system of the Internet of Things.

[0048] In one embodiment, sending a data block to a target device through a multi-byte write operation based on the CAN protocol includes: encapsulating the data block into a write data block start frame and at least one data payload frame according to the CAN protocol data frame format, and sending the write data block start frame and at least one data payload frame to the target device in sequence, and then receiving a data response frame encapsulated in the CAN protocol data frame format returned by the target device.

[0049] Please refer to Figure 8 , Figure 8 The structure diagram of the write data block start frame, data load frame and data response frame based on the CAN protocol is shown as an example. Figure 8As shown in the figure, the write data block start frame, data load frame and data response frame have different data frame IDs respectively, and the Data0~Data8 bytes correspond to the data segment in the data frame of the CAN protocol. The data segment of the write data block start frame includes the data block type, data start position, data length and load data verification information, which is used to inform the target device of the write position of the data block in the original file or content, the size of the data block and the verification data of the data block. The data segment of the data load frame includes the data block type, data packet number and load data, which is used to carry the load data. The data segment of the data response frame includes the data block type, data start position, data length and load data verification information, which is used to confirm whether the target device has accurately received the data block.

[0050] In one embodiment, when the message transmission protocol is the CAN protocol, the first index data frame includes a write data block start frame and at least one data load frame carrying a file read data block, and encapsulating the file read data block into the first index data frame based on the currently used message transmission protocol and then sending it to the lower computer includes: encapsulating the file read data block into a write data block start frame and at least one data load frame according to the CAN protocol data frame format, and sending the write data block start frame and the at least one data load frame to the lower computer in sequence. After receiving the first index data frame, the lower computer returns a data response frame to the upper computer based on the received data.

[0051] In another embodiment, when the message transmission protocol is the Modbus protocol, encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and then sending it to the lower computer includes: encapsulating the file read data block into a first index data frame based on the first preset address space corresponding to the first encapsulation format according to the multi-byte write request frame format of the Modbus protocol, and sending the first index data frame to the lower computer. After the lower computer receives the first index data frame, it returns a first index response frame to the upper computer according to the multi-byte write response frame format of the Modbus protocol based on the received data. If using Figure 6 As shown, the size of the data block encapsulated by the first encapsulation format is 16 bytes in total, and the corresponding first preset address space is M~M+7, where M can be any specified value.

[0052] Please refer to Fig. 9 , Fig. 9 The format diagram of the Modbus protocol standard multi-byte write request frame and multi-byte write response frame is shown as an example. Specifically, the host computer fills the device address field of the first index data frame with the address of the slave computer, fills "0x10" in the function code field, fills the starting address of the first preset address space in the starting address field of the data field, and fills the size of the first preset address space in the register number field of the data field (such as Figure 68), fill in the total number of bytes of the file read data block in the byte number field of the data domain (such as Figure 6 As shown in 16, the register value field of the data domain is filled with the contents of the file read data block in sequence, and the CRC check value of all the data in the data domain is filled in the check field. The upper computer sends the filled first index data frame to the communication bus to initiate a multi-byte write request to the lower computer. Among them, the communication buses supported by the Modbus protocol include RS-232, RS-485, RS-422 and Ethernet.

[0053] After receiving the first index data frame from the communication bus, the lower computer returns the first index response frame to the upper computer based on the received data. The lower computer fills the lower computer address in the device address field of the first index response frame, fills "0x10" in the function code field, fills the start address of the first preset address space in the start address field of the data field, fills the size of the first preset address space in the register quantity field of the data field, and fills the CRC check value of the received data in the check field. The lower computer sends the filled first index response frame to the communication bus.

[0054] Step S403: receiving a first content data frame sent by the lower computer, parsing the first content data frame based on a message transmission protocol to obtain a file content data block.

[0055] In one embodiment, when the message transmission protocol is the CAN protocol, the upper computer receives the first content data frame encapsulated by the lower computer through a multi-byte write operation of the file content data block. The first content data frame includes a write data block start frame and at least one data load frame. After receiving the first content data frame, the upper computer returns a data response frame to the lower computer based on the received data.

[0056] In another embodiment, when the message transmission protocol is the Modbus protocol, the host computer reads the first content data frame from the slave computer based on a multi-byte read request of the Modbus protocol standard. Specifically, the host computer constructs the first content request frame based on the second preset address space corresponding to the preset second encapsulation format according to the multi-byte read request frame format of the Modbus protocol and sends it to the slave computer.

[0057] Please refer to Figure 7 , Figure 7 The structure diagram of the second packaging format is exemplarily shown. Figure 7As shown, in the second encapsulation format, the data classification field occupies 2 bytes, which is used to indicate the data category of the current load data. Among them, 0 indicates that the current load data is the target index content, and 1 indicates that the current load data is the target file content. The total number of data field occupies 4 bytes. When the data classification is 0, it indicates the total number of bytes of the target index content, and when the data classification is 1, it indicates the total number of bytes of the target file content. The current data transmission length field occupies 2 bytes, indicating the number of bytes of the target index content or target file content transmitted this time. The data offset information field occupies 4 bytes, indicating the data offset of the current load data in the target index content or target file content. The current load data field is used to indicate the valid data uploaded. If the maximum length of a single load is 128 bytes, when a 200-byte target file content is transmitted, the target file content can be split into two data blocks, the data offset information field corresponding to the first data block is 0, and the data offset information field corresponding to the second data block is 128. Taking the current data transmission length of 128 bytes as an example, the total size of the data block encapsulated using the second encapsulation format is 140 bytes. When the message transmission protocol is the Modbus protocol, the size of the corresponding second preset address space is N to N + 70. It should be noted that the first preset address space and the second preset address space do not overlap with each other.

[0058] Please refer to Fig.10 , Fig.10 The format diagram of the Modbus protocol standard multi-byte read request frame and multi-byte read response frame is exemplarily shown. Specifically, the upper computer fills the lower computer address in the device address field of the first content request frame, fills "0x03" in the function code field, fills the starting address of the second preset address space in the starting address field of the data field, fills the size of the second preset address space in the register number field of the data field, and fills the CRC check value of all data in the data field in the check field. The upper computer sends the filled first content request frame to the communication bus to initiate a multi-byte read request to the lower computer.

[0059] After receiving the first content request frame from the communication bus, the lower computer returns the first content data frame to the upper computer based on the received data in the format of the multi-byte read response frame of the Modbus protocol. Specifically, the lower computer fills the lower computer address in the device address field of the first content data frame, fills "0x03" in the function code field, fills twice the size of the second preset address space in the byte number field of the data field, fills the content of the file content data block in order in the register value field of the data field, and fills the CRC check value of all data in the data field in the check field. The lower computer sends the filled first content data frame to the communication bus.

[0060] The host computer receives the first content data frame, and parses the first content data frame based on the message transmission protocol (ie, the CAN protocol or the Modbus protocol) to obtain a file content data block.

[0061] Step S404: parsing the file content data block based on the preset second encapsulation format to obtain the target file content.

[0062] In one embodiment, the file content data block is parsed based on the preset second encapsulation format to obtain data classification, total data, current data transmission length, data offset information and current load data. When the target file content to be transmitted is large, the method of the present application supports encapsulating the target file content into several file content data blocks and then transmitting them to the host computer in sequence. Specifically, when the message transmission protocol is the CAN protocol, if the continuous write flag carried by the file read data block is yes, then continue to receive other first content data frames based on the target file sent by the lower computer until all target file contents are received; when the message transmission protocol is the Modbus protocol, first obtain a new first index data frame based on the target file index and the new data offset information, send the new first index data frame to the lower computer, and then receive the new first content data frame sent by the lower computer based on the new first index data frame, until all target file contents are received. Among them, the new data offset information can be determined according to the total data carried in the file content data block, the current data transmission length and the data offset information.

[0063] When all the target file contents are received, the host computer will splice the target file contents received multiple times into a complete file according to the data offset information. Furthermore, the host computer can parse the corresponding signal information according to the target file content encoding rules agreed upon in advance with the lower computer. For example, if the target file is formed in the order of current signal, voltage signal, power signal, etc., the host computer can parse the value of the current signal, the value of the voltage signal, and the value of the power signal according to the rule.

[0064] In one embodiment, the upper computer may also send a query directory index to the lower computer to obtain the file or folder information under the query directory index. Specifically, the general data transmission method of the Internet of Things applied to the upper computer also includes: encapsulating the query directory index into a file query data block according to the first encapsulation format; encapsulating the file query data block into a second index data frame based on the message transmission protocol, and sending the second index data frame to the lower computer; receiving the second content data frame sent by the lower computer, parsing the second content data frame based on the message transmission protocol to obtain the index content data block; parsing the index content data block based on the second encapsulation format to obtain the target index content. Among them, the query directory index includes the query directory information (please refer to the previous description for details), and the target index content includes the file or folder information of the preset level under the query directory. For example, if the preset level is level 2, the target index content includes the files and folders under the query directory, and the file and folder information under the query directory folder.

[0065] It can be understood that the specific implementation method of the upper computer sending the query directory index to the lower computer to obtain the target index content under the query directory is similar to the specific implementation method of the upper computer sending the target file index to the lower computer to obtain the target file content, which will not be repeated here.

[0066] Please refer to Figure 5 , Figure 5 The flowchart of the general data transmission method of the Internet of Things applied to the lower computer is exemplarily shown, including: Step S501: receiving a first index data frame sent by a host computer, parsing the first index data frame based on a currently used message transmission protocol to obtain a file reading data block.

[0067] In one embodiment, when the message transmission protocol is the CAN protocol, the first index data frame includes a write data block start frame and at least one data payload frame carrying a file read data block. After receiving the first index data frame, the lower computer returns a data response frame.

[0068] In one embodiment, when the message transmission protocol is the Modbus protocol, step S501 specifically includes: receiving a first index data frame encapsulated by a host computer from a file read data block based on a first preset address space in accordance with a multi-byte write request frame format of the Modbus protocol; constructing a first index response frame based on the received data in accordance with a multi-byte write response frame format of the Modbus protocol and sending it to the host computer.

[0069] Step S502: parsing the file read data block based on a preset first encapsulation format to obtain a target file index.

[0070] Step S503: determine the target file corresponding to the target file index, and encapsulate the target file content into a file content data block according to a preset second encapsulation format.

[0071] Step S504: encapsulate the file content data block into a first content data frame based on the message transmission protocol and send it to the host computer.

[0072] In one embodiment, when the message transmission protocol is the CAN protocol, the first content data frame includes a write data block start frame and at least one data payload frame carrying the file content data block, and step S504 specifically includes: encapsulating the file content data block into a write data block start frame and at least one data payload frame according to the data frame format of the CAN protocol, and sending the write data block start frame and the at least one data payload frame to the host computer in sequence.

[0073] In one embodiment, when the message transmission protocol is the Modbus protocol, step S504 specifically includes: receiving a first content request frame constructed by the host computer based on the second preset address space according to the multi-byte read request frame format of the Modbus protocol; encapsulating the file content data block into a first content data frame based on the second preset address space according to the multi-byte read response frame format of the Modbus protocol and sending the first content data frame to the host computer.

[0074] Figure 5 The embodiment is with Figure 4 The general Internet of Things data transmission method applied to the lower computer corresponding to the embodiment is Figure 5 The first encapsulation format, the second encapsulation format and the method for transmitting the data block of the first encapsulation format and the data block of the second encapsulation format based on the message transmission protocol in the embodiment Figure 4 The same as in the embodiment and Figure 4 The corresponding description has been made in the embodiments and will not be repeated here.

[0075] In one embodiment, when the message transmission protocol is the CAN protocol, the data after parsing the file read data block based on the first encapsulation format includes the target file index, data offset information and the continuous write flag, and step S503 specifically includes: when the continuous write flag is yes, determine the target file content according to the target file index and the data offset information, and encapsulate the target file content into one or more file content data blocks according to the second encapsulation format. In one embodiment, the lower computer determines the target file content according to the total number of data in the target file and the maximum load length of a single transmission (such as Figure 7128 bytes in the target file) to split the target file content, and encapsulate the target file content into multiple file content data blocks according to the second encapsulation format. For example, after the lower computer parses the file read data block, it is obtained that the target file index is " / z123.txt0", the offset information is 0, and the continuous write flag is 1. According to the target file index, it can be determined that the target file is the "123.txt" file in the secondary directory "z" folder. If the size of the "123.txt" file is 200 bytes and the maximum load length of a single transmission is 128 bytes, the "123.txt" file can be split into two parts and then encapsulated into two file content data blocks. Among them, the current load data of the first file content data block starts from the starting data of the "123.txt" file and has a length of 128 bytes; the current load data of the second file content data block starts from the 128th byte of the "123.txt" file and has a length of 72 bytes. It can be understood that the length of the current load data in the first file content data block can be less than 128 bytes.

[0076] In one embodiment, the lower computer can also obtain the query directory index sent by the upper computer, and return the file or folder information under the query directory index to the upper computer. Specifically, the general data transmission method of the Internet of Things applied to the lower computer also includes: receiving the second index data frame sent by the upper computer, parsing the second index data frame based on the message transmission protocol to obtain the file query data block; parsing the file query data block based on the first encapsulation format to obtain the query directory index; determining the corresponding target index according to the query directory index, encapsulating the target index content into an index content data block according to the second encapsulation format; encapsulating the index content data block into a second content data frame based on the message transmission protocol, and sending the second content data frame to the upper computer. It can be understood that when the target index content data is large, the method of the present application also supports encapsulating the target index content into several index content data blocks and transmitting them to the upper computer in sequence.

[0077] Please refer to Fig.11 , Fig.11 The following is a schematic diagram of the entire process of file transmission based on the CAN protocol. Specifically, the entire process of file transmission includes the following four steps: Step 1101: The upper computer sends the query directory index to the lower computer through a multi-byte write operation.

[0078] Step 1102: The lower computer sends the target index content to the upper computer through a multi-byte write operation.

[0079] Step 1103: the upper computer sends the target file index to the lower computer through a multi-byte write operation.

[0080] Step 1104, the lower computer sends the target file content to the upper computer through a multi-byte write operation.

[0081] Among them, the amount of data transmitted in step 1101 to step 1103 is relatively small, and all data transmission can be completed through one data block. In step 1104, the target file content transmitted is divided into multiple data blocks for transmission. The transmission of each data block can be achieved through a write data block start frame, at least one data load frame and a data response frame.

[0082] Please refer to Fig.12 , Fig.12 The following is a schematic diagram of the entire file transfer process based on the Modbus protocol. Specifically, the entire file transfer process includes the following four steps: Step 1201, the upper computer sends the query directory index to the lower computer by writing a first preset address space with multiple bytes, and the lower computer returns a normal write response.

[0083] Specifically, the host computer sends the query directory index through the multi-byte write [M~M+7] address method. For example, if the query directory index is the root directory, the index information field of the [M~M+7] address space is filled with "0000000000", the data offset information field is filled with 0, and the continuous write flag field is filled with 0.

[0084] Step 1202: The upper computer queries the target index content of the lower computer by reading the second preset address space by multi-bytes, and the lower computer returns a response including the target index content.

[0085] Specifically, the host computer obtains the target index content through the multi-byte read [address N~N+69] method, and the lower computer responds to the directory query of the host computer and constructs a response frame containing the index content data block and returns it to the host computer. If there is only one file named "alarm" in the query directory, the data classification of the constructed index content data block is 0, the total number of bytes of the target index content is 5, the current data transmission length is 5, the data offset is 0, and the current load data is "alarm" + 123 "0" (a total of 128 bytes).

[0086] Step 1203, the upper computer sends the target file index to the lower computer by writing a first preset address space with multiple bytes, and the lower computer returns a normal write response.

[0087] Specifically, the host computer sends the target file index through the multi-byte write [M~M+7] address method. For example, if the target file index is the "alarm" file in the root directory, then fill "00alarm000" in the index information field of the [M~M+7] address space, fill 0 in the data offset information field, and fill 0 in the continuous write flag field.

[0088] Step 1204, the upper computer queries the lower computer for the target file content by reading the second preset address space by multi-bytes, and the lower computer returns a response including the target file content.

[0089] Specifically, the host computer obtains the target file content through the multi-byte read [address N~N+69] method, and the lower computer responds to the file query of the host computer, constructs a response frame containing the file content data block and returns it to the host computer. If the total number of "alarm" data is 64 bytes, the data classification of the constructed file content data block is 1, the total number of bytes of the target file content is 64, the current data transmission length is 64, the data offset is 0, and the current load data is 64 bytes of "alarm" file content + 64 "0".

[0090] The implementation method of step 1203 and step 1204 is similar to step 1201 and step 1202. When the target file content exceeds the maximum payload length of a single transmission, step 1203 and step 1204 may be repeated multiple times until all target file content is transmitted; when the target index content exceeds the maximum payload length of a single transmission, step 1201 and step 1202 may be repeated multiple times until all target index content is transmitted.

[0091] The universal data transmission method for the Internet of Things provided in the embodiment of the present application adopts the concept of files to summarize various types of data and establishes a mapping relationship between files and file indexes. When performing file transmission, the files and file indexes are encapsulated into data blocks using different encapsulation formats, and then the data blocks are encapsulated into corresponding data frames for transmission according to the currently used message transmission protocol, thereby realizing the decoupling of the transmission protocol and the transmission content, so that different Internet of Things communication protocols can be efficiently coordinated between different physical layer media and MCUs based on the same data.

[0092] According to an embodiment of the present application, a computer-readable storage medium is provided, the type of which is as described above, and the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned general Internet of Things data transmission method.

[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as described above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A universal data transmission method for the Internet of Things, characterized in that: Applied to a host computer, the method includes: Encapsulating the target file index into a file reading data block according to a preset first encapsulation format; Based on the currently used message transmission protocol, the file reading data block is encapsulated into a first index data frame and then sent to the lower computer; Receiving a first content data frame sent by a lower computer, parsing the first content data frame based on the message transmission protocol to obtain a file content data block; The file content data block is parsed based on a preset second encapsulation format to obtain target file content.

2. The method according to claim 1, characterized in that: The data block encapsulated in the first encapsulation format includes index information, data offset information and a continuous write flag, and the data block encapsulated in the second encapsulation format includes data classification, total data, current data transmission length, data offset information and current load data.

3. The method according to claim 1, characterized in that The method further comprises: Encapsulating the query directory index into a file query data block according to the first encapsulation format; Based on the message transmission protocol, the file query data block is encapsulated into a second index data frame and then sent to the lower computer; receiving a second content data frame sent by the lower computer, parsing the second content data frame based on the message transmission protocol to obtain an index content data block; The index content data block is parsed based on the second encapsulation format to obtain target index content.

4. The method according to claim 2, characterized in that: The data after parsing the file content data block based on the second encapsulation format includes the total data amount, the current data transmission length and data offset information and the current load data, the method further includes: Determining whether the target file has been transferred according to the total amount of data, the current data transfer length and the data offset information; If not, when the message transmission protocol is the CAN protocol, if the continuous write flag carried by the file read data block is yes, continue to receive other first content data frames based on the target file sent by the lower computer until all target file contents are received; when the message transmission protocol is the Modbus protocol, obtain a new first index data frame based on the target file index and new data offset information, send the new first index data frame to the lower computer, and then receive a new first content data frame sent by the lower computer based on the new first index data frame until all target file contents are received.

5. The method according to any one of claims 1 to 4, characterized in that: When the message transmission protocol is the CAN protocol, the first index data frame includes a write data block start frame and at least one data load frame carrying the file read data block, and the encapsulating the file read data block into the first index data frame based on the currently used message transmission protocol and sending it to the lower computer includes: The file read data block is encapsulated into a write data block start frame and at least one data load frame according to the data frame format of the CAN protocol, and the write data block start frame and the at least one data load frame are sent to the lower computer in sequence, wherein the data segment of the write data block start frame includes the data block type, the data start position, the data length and the load data verification information, and the data segment of the data load frame includes the data block type, the data packet number and the load data.

6. The method according to any one of claims 1 to 4, characterized in that: When the message transmission protocol is the Modbus protocol, the step of encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and then sending the frame to the lower computer comprises: Encapsulate the file read data block into a first index data frame based on the first preset address space corresponding to the first encapsulation format according to the multi-byte write request frame format of the Modbus protocol, and send the first index data frame to the lower computer; The receiving of the first content data frame sent by the lower computer comprises: Constructing a first content request frame based on a second preset address space corresponding to the second encapsulation format according to a multi-byte read request frame format of the Modbus protocol and sending the frame to the lower computer; The first content data frame returned by the lower computer according to the multi-byte read response frame format of the Modbus protocol is received.

7. A universal data transmission method for the Internet of Things, characterized in that: Applied to a lower computer, the method includes: Receive a first index data frame sent by the host computer, and parse the first index data frame based on the currently used message transmission protocol to obtain a file reading data block; Parsing the file read data block based on a preset first encapsulation format to obtain a target file index; Determine a target file corresponding to the target file index according to the target file index, and encapsulate the target file content into a file content data block according to a preset second encapsulation format; The file content data block is encapsulated into a first content data frame based on the message transmission protocol and then sent to a host computer.

8. The method according to claim 7, characterized in that The data block encapsulated in the first encapsulation format includes index information, data offset information and a continuous write flag, and the data block encapsulated in the second encapsulation format includes data classification, total data, current data transmission length, data offset information and current load data.

9. The method according to claim 7, characterized in that: The method further comprises: Receiving a second index data frame sent by the host computer, parsing the second index data frame based on the message transmission protocol to obtain a file query data block; Parsing the file query data block based on the first encapsulation format to obtain a query directory index; Determine a target index corresponding to the query directory index according to the query directory index, and encapsulate the target index content into an index content data block according to the second encapsulation format; The index content data block is encapsulated into a second content data frame based on the message transmission protocol, and the second content data frame is sent to a host computer.

10. The method according to any one of claims 7 to 9, characterized in that: When the message transmission protocol is the CAN protocol, the first content data frame includes a write data block start frame and at least one data payload frame carrying the file content data block, and the step of encapsulating the file content data block into the first content data frame based on the message transmission protocol and then sending the frame to the host computer includes: The file content data block is encapsulated into a write data block start frame and at least one data load frame according to the data frame format of the CAN protocol, and the write data block start frame and the at least one data load frame are sent to the host computer in sequence; wherein the data segment of the write data block start frame includes the data block type, the data start position, the data length and the load data verification information, and the data segment of the data load frame includes the data block type, the data packet number and the load data.

11. The method according to claim 10, characterized in that The data after parsing the file read data block based on the first encapsulation format includes a target file index, data offset information, and a continuous write flag. When the continuous write flag is yes, determining a target file corresponding to the target file index according to the target file index, and encapsulating the target file content into a file content data block according to a preset second encapsulation format includes: Determine the target file content according to the target file index and the data offset information; The target file content is encapsulated into one or more file content data blocks according to a second encapsulation format.

12. The method according to any one of claims 7 to 9, characterized in that: When the message transmission protocol is the Modbus protocol, the step of encapsulating the file content data block into a first content data frame based on the message transmission protocol and then sending the frame to the host computer comprises: Receiving a first content request frame constructed by a host computer according to a multi-byte read request frame format of the Modbus protocol based on a second preset address space corresponding to the second encapsulation format; The file content data block is encapsulated into a first content data frame based on the second preset address space according to the multi-byte read response frame format of the Modbus protocol and then sent to the host computer.

13. An electronic device, characterized in that: The electronic device includes at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor can execute the method described in any one of claims 1 to 12.

14. A computer storage medium, characterized in that: The computer storage medium stores instructions or programs, and when the instructions or programs are executed by at least one processor, the at least one processor is caused to perform the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Equipment upgrading method and device, storage medium, electronic equipment and server

    CN115756530A

  • File transmission method and device based on communication protocol of multifunctional electric energy meter

    CN117221310A

  • Energy storage management system updating method and device and storage medium

    CN118585499A

  • File processing method and device, electronic equipment and storage medium

    CN119211389A

  • Method of Using Protocol CRC to Implement End to End Protection of a CAN Message

    US20210173961A1

Cited By

  • Compatible data transmission method and system based on dynamic text structure definition

    CN121503430A