Iot general data transmission method, device and storage medium

By using a data encapsulation format based on file concepts and mapping relationships, the problem of incompatibility in cross-physical layer transmission of IoT communication protocols is solved, enabling efficient data transmission and protocol decoupling between IoT devices, and supporting multiple data transmission methods.

CN119814773BActive Publication Date: 2026-01-27SHENZHEN POWEROAK NEWENER CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing IoT communication protocols are only applicable to the limited scope of each specific physical layer and cannot effectively support cross-physical layer data transmission, resulting in inconsistent and inefficient data transmission.

Method used

The system uses the concept of files to aggregate various types of data and establishes a mapping relationship between files and file indexes. It encapsulates files and file indexes into data blocks using different encapsulation formats, and then encapsulates the data blocks into data frames for transmission according to the currently used message transmission protocol, thereby achieving decoupling between the transmission protocol and the transmitted content.

Benefits of technology

It enables efficient collaboration between different IoT communication protocols on different physical layer media, supports breakpoint resume and multiple data transmissions, and adapts to the needs of different data sizes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814773B_ABST
    Figure CN119814773B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of Internet of Things communication, in particular to an Internet of Things general data transmission method, equipment and a storage medium. The Internet of Things general data transmission method comprises the following steps: an upper computer encapsulates target file indexes into file reading data blocks according to a preset first encapsulation format; the file reading data blocks are encapsulated into first index data frames based on a currently used message transmission protocol and then sent to a lower computer; a first content data frame sent by the lower computer is received, the first content data frame is parsed based on the message transmission protocol, and file content data blocks are obtained; and the file content data blocks are parsed based on a preset second encapsulation format, and target file content is obtained. The method of the application realizes decoupling of a transmission protocol and transmission content, so that different Internet of Things communication protocols can be efficiently cooperated 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] This application relates to the field of Internet of Things (IoT) communication technology, specifically to a general IoT data transmission method, device, and storage medium. Background Technology

[0002] In existing IoT communication networks, various physical transmission media are used, such as Ethernet (wired, wireless, Wi-Fi, 2G / 3G / 4G / 5G cellular networks), serial communication (UART / RS232 / RS485), and CAN (Controller Area Network). Equivalently unified under the OSI (Open System Interconnect) communication data model, different physical transmission media correspond to different application layer communication protocols. In current technologies, Ethernet and serial communication commonly use the standard Modbus communication protocol, while CAN bus commonly uses standard application layer protocols such as CANopen and SAE J1939. Each standard is only applicable to a limited range within a specific physical layer and lacks good compatibility for cross-physical layer data transmission.

[0003] Data between IoT devices typically includes real-time data, historical data, and configuration parameters. Conventional transmission methods are based on limited specific semaphore requirements, incrementally expanding the data point table (or register) as needed, thus endlessly increasing the table length. Because data content is associated with the data point table, the data cannot be well structured. Different data structures require different data point table addresses for differentiation, and the data length is limited by the protocol address length range (the maximum address length of the Modbus protocol is 65536). For historical data stored on the device side, a simple, immediate question-and-answer interaction protocol is generally used (i.e., the host computer sends a message to query a specified object, and the slave device immediately returns a valid content message based on the object index). This method cannot properly handle the actual latency of local data reading and the predetermined maximum response latency of protocol transmission.

[0004] In summary, each IoT communication protocol is only applicable to the limited scope of its specific physical layer and cannot effectively support cross-physical layer data transmission. To simplify and unify data communication in IoT embedded systems, a cross-physical layer data transmission method is urgently needed to enable efficient collaboration (e.g., reducing latency and throughput) between different IoT communication protocols based on the same data across different physical layer media and MCUs (Microcontroller Units). Summary of the Invention

[0005] This application provides a general data transmission method, device, and storage medium for the Internet of Things (IoT), which solves the problem that existing IoT communication protocols are only applicable to the limited scope of each specific physical layer and cannot be well compatible with cross-physical layer data transmission.

[0006] In a first aspect, embodiments of this application provide a general data transmission method for the Internet of Things, applied to a host computer, the method comprising:

[0007] The target file index is encapsulated into file read data blocks according to the preset first encapsulation format;

[0008] Based on the currently used message transmission protocol, the file read data block is encapsulated into a first index data frame and then sent to the lower-level machine;

[0009] The system receives a first content data frame sent by a lower-level device, parses the first content data frame based on the message transmission protocol, and obtains a file content data block.

[0010] The file content data blocks are parsed based on a preset second encapsulation format to obtain the target file content.

[0011] Optionally, the data block encapsulated using the first encapsulation format includes index information, data offset information, and a continuous write flag, while the data block encapsulated using the second encapsulation format includes data category, total number of data, current data transmission length, data offset information, and current load data.

[0012] Optionally, the method further includes:

[0013] The query directory index is encapsulated into file query data blocks according to the first encapsulation format;

[0014] 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-level machine.

[0015] The system receives a second content data frame sent by a lower-level device, parses the second content data frame based on the message transmission protocol, and obtains an index content data block.

[0016] The index content data block is parsed based on the second encapsulation format to obtain the target index content.

[0017] Optionally, the data parsed from the file content data blocks based on the second encapsulation format includes the total number of data, the current data transmission length, data offset information, and the current payload data. The method further includes:

[0018] Determine whether the target file has been completely transmitted based on the total number of data, the current data transmission length, and the data offset information;

[0019] If not, when the message transmission protocol is 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 device until all target file content is received; when the message transmission protocol is Modbus protocol, a new first index data frame is obtained based on the target file index and new data offset information, the new first index data frame is sent to the lower device, and then the lower device is received to send new first content data frames based on the new first index data frame until all target file content is received.

[0020] Optionally, 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, and the step of encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and sending it to the lower-level device includes:

[0021] The file read data block is encapsulated into a write data block start frame and at least one data payload frame according to the data frame format of the CAN protocol. The write data block start frame and the at least one data payload frame are sent to the lower-level machine in sequence. The data segment of the write data block start frame includes data block type, data start position, data length and payload data verification information. The data segment of the data payload frame includes data block type, data packet number and payload data.

[0022] Optionally, 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 sending it to the lower-level machine includes:

[0023] The file read data block is encapsulated into a first index data frame based on the first preset address space corresponding to the first encapsulation format according to the Modbus protocol multibyte write request frame format, and the first index data frame is sent to the lower-level machine.

[0024] The first content data frame received from the lower-level device includes:

[0025] After constructing a first content request frame based on the second preset address space corresponding to the second encapsulation format according to the Modbus protocol's multibyte read request frame format, it is sent to the lower-level machine.

[0026] Receive the first content data frame returned by the lower-level machine according to the multi-byte read response frame format of the Modbus protocol.

[0027] Secondly, embodiments of this application provide a general data transmission method for the Internet of Things, applied to a lower-level machine, the method comprising:

[0028] The system receives the first index data frame sent by the host computer, parses the first index data frame based on the currently used message transmission protocol, and obtains the file read data block.

[0029] The file read data blocks are parsed based on a preset first encapsulation format to obtain the target file index;

[0030] The target file corresponding to the target file index is determined, and the content of the target file is encapsulated into file content data blocks according to the preset second encapsulation format.

[0031] Based on the aforementioned message transmission protocol, the file content data block is encapsulated into a first content data frame and then sent to the host computer.

[0032] Optionally, the data block encapsulated using the first encapsulation format includes index information, data offset information, and a continuous write flag, while the data block encapsulated using the second encapsulation format includes data category, total number of data, current data transmission length, data offset information, and current load data.

[0033] Optionally, the method further includes:

[0034] The system receives a second index data frame sent by the host computer, parses the second index data frame based on the message transmission protocol, and obtains a file query data block.

[0035] The file query data block is parsed based on the first encapsulation format to obtain the query directory index;

[0036] Based on the query directory index, the corresponding target index is determined, and the target index content is encapsulated into an index content data block according to the second encapsulation format.

[0037] Based on the message transmission protocol, the index content data block is encapsulated into a second content data frame, and the second content data frame is sent to the host computer.

[0038] Optionally, 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, and the step of encapsulating the file content data block into a first content data frame based on the message transmission protocol and sending it to the host computer includes:

[0039] The file content data block is encapsulated 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 the write data block start frame and the at least one data payload frame are sent to the host computer in sequence; wherein, the data segment of the write data block start frame includes data block type, data start position, data length and payload data verification information, and the data segment of the data payload frame includes data block type, data packet number and payload data.

[0040] Optionally, the data parsed from 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 true, determining the corresponding target file based on the target file index and encapsulating the target file content into a file content data block according to a preset second encapsulation format includes:

[0041] The content of the target file is determined based on the target file index and the data offset information;

[0042] The target file content is encapsulated into one or more file content data blocks according to the second encapsulation format.

[0043] Optionally, 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 sending it to the host computer includes:

[0044] Receive a first content request frame constructed by the host computer according to the Modbus protocol multi-byte read request frame format based on the second preset address space corresponding to the second encapsulation format;

[0045] The file content data block is encapsulated into a first content data frame based on the second preset address space according to the Modbus protocol's multi-byte read response frame format and then sent to the host computer.

[0046] Thirdly, embodiments of this application provide an electronic device, including: 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 to enable the at least one processor to perform the method described above.

[0047] Fourthly, embodiments of this application provide a computer storage medium storing instructions or programs that, when executed by at least one processor, cause the at least one processor to perform any of the methods described above.

[0048] This application provides a general data transmission method for the Internet of Things (IoT). A host computer encapsulates a target file index into a file read data block according to a preset first encapsulation format. Based on the currently used message transmission protocol, the host computer encapsulates the file read data block into a first index write request frame and sends it to a slave computer. The host computer receives a first content data frame sent by the slave computer, parses the first content data frame according to the message transmission protocol to obtain a file content data block, and then parses the file content data block according to a preset second encapsulation format to obtain the target file content. This method uses the concept of a file to aggregate various types of data and establishes a mapping relationship between files and file indexes. During 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 according to the currently used message transmission protocol for transmission. This decouples the transmission protocol from the transmitted content, enabling different IoT communication protocols to efficiently collaborate across different physical layer media and MCUs based on the same data. Attached Figure Description

[0049] Figure 1a An exemplary bus topology diagram based on the Modbus protocol is shown.

[0050] Figure 1b An exemplary topology diagram of a CAN bus is shown;

[0051] Figure 2a An exemplary diagram of a Modbus RTU message frame is shown.

[0052] Figure 2b An exemplary frame structure diagram of a CAN protocol data frame is shown;

[0053] Figure 3 An exemplary schematic diagram of the hardware structure of an electronic device is shown;

[0054] Figure 4 An exemplary flowchart illustrates a general data transmission method for the Internet of Things (IoT) applied to a host computer.

[0055] Figure 5 An exemplary flowchart illustrates a general data transmission method for the Internet of Things (IoT) applied to a lower-level machine;

[0056] Figure 6 An exemplary structural diagram of the first encapsulation format is shown;

[0057] Figure 7 An exemplary structural diagram of the second encapsulation format is shown;

[0058] Figure 8 An exemplary diagram illustrates the structure of the write data block start frame, data payload frame, and data response frame based on the CAN protocol.

[0059] Figure 9 The diagram illustrates the format of the Modbus protocol standard multibyte write request frame and multibyte write response frame.

[0060] Figure 10 The diagram illustrates the format of the Modbus protocol standard multibyte read request frame and multibyte read response frame.

[0061] Figure 11 An exemplary diagram illustrates the entire process of file transfer based on the CAN protocol;

[0062] Figure 12 An exemplary diagram illustrating the entire file transfer process based on the Modbus protocol is provided. Detailed Implementation

[0063] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0064] Please refer to Figure 1a , Figure 1a An exemplary bus topology diagram based on the Modbus protocol is shown. Figure 1a As shown, multiple devices are connected to the same bus. To avoid data conflicts, the Modbus protocol uses a master-slave communication method. A Modbus communication system includes a master device (such as...). Figure 1a (A) and multiple slave devices (such as...) Figure 1a (Device B, C, and D in the diagram). The Modbus protocol uses a request-response model and stipulates that Modbus requests can only be initiated by the master. That is, the master sends request data to the slave, and the slave can only receive requests from the master and respond accordingly, returning response data to the master. Slaves cannot initiate requests; they can only passively receive requests from the master. To avoid data conflicts, the master cannot send data in parallel. After sending the first piece of data, the master can only send the second piece of data after waiting for a response from the slave or after the response times out. Each slave has only one slave address in the system. When the master sends a data request, it includes the target slave's address in the request data. When the master sends data to the bus, every slave receives the data, but only the slave with the same target address as the one in the request data will respond; other slaves will ignore the request.

[0065] Please refer to Figure 2a, Figure 2a An exemplary diagram of a Modbus RTU message frame is shown. Figure 2a As shown, an RTU (Remote Terminal Unit) message frame consists of an address code, a function code, a data field, and a checksum. The address code, occupying one byte, identifies the destination address of the message; each slave device has a unique address. The function code, also occupying one byte, indicates the type of operation performed by the master on the slave device. The data field, occupying 0-252 bytes, has its length and content determined by the function code. The checksum, occupying two bytes, ensures correct message transmission.

[0066] Please refer to Figure 1b , Figure 1b An exemplary topology diagram of a CAN bus is shown. (For example...) Figure 1b As shown, the CAN bus includes two lines, CAN_H and CAN_L. Nodes 1 to N are connected to the CAN bus via the CAN controller and CAN transceiver, respectively. In the CAN protocol, frame types are mainly divided into data frames, remote frames, error frames, and overload frames. Data frames are used to send data, remote frames are used to request data, error frames indicate that an error has occurred, and overload frames indicate that a node cannot receive data.

[0067] Please refer to Figure 2b , Figure 2b An exemplary diagram of the CAN protocol data frame structure is shown. Data frames include standard frames and extended frames. Each data frame specifically includes seven parts: frame start, arbitration segment, control segment, data segment, CRC segment, ACK segment, and frame end segment. The arbitration segment determines the transmission priority and includes the data frame ID. The data segment contains the actual transmitted data, up to 8 bytes. When data frames are transmitted on the CAN bus, each CAN node uses an acceptance filter to compare the data frame ID on the bus with its own ID. If they match, the CAN controller allows the received information to be stored in the corresponding register. Through acceptance filtering technology, without dedicated scheduling, the CAN bus can achieve various data transmission methods such as one-to-one, one-to-many, and global broadcast.

[0068] Please refer to Figure 3 , Figure 3 An exemplary hardware structure diagram of an electronic device is shown. For example... Figure 3 As shown, the electronic device 100 includes a processor 10, a memory 20, and a communication interface 30. The processor 10, memory 20, and communication interface 30 are connected via lines. Figure 3 In the embodiment shown, the processor 10, memory 20, and communication interface 30 are connected to each other via a bus.

[0069] 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 the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the electronic device, etc.

[0070] The memory 20 can be a read-only memory (ROM), or other types of static storage devices that can store static information and instructions, or random access memory (RAM), or other types of dynamic storage devices that can store information and instructions, or electrically erasable programmable read-only memory (EEPROM). The specific type is not limited here.

[0071] For example, the aforementioned memory 20 can be Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM). This memory 20 can exist independently but is connected to the processor 10. Optionally, the memory 20 can also be integrated with the processor 10, for example, integrated within one or more chips.

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

[0073] The processor 10 connects various parts of the electronic device 100 using various interfaces and lines. By running or executing software programs stored in the memory 20 and calling data stored in the memory 20, it performs various functions of the electronic device and processes data, such as implementing the methods described in any embodiment of this application.

[0074] The processor 10 can be a field-programmable gate array (FPGA), a digital signal processor (DSP), a central processing unit (CPU), or the like.

[0075] Processor 10 can be a single-core processor or a multi-core processor. For example, processor 10 can be composed of multiple FPGAs or multiple DSPs. Furthermore, processor 10 can refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions). Processor 10 can be a standalone semiconductor chip or integrated with other circuits into a single semiconductor chip. For example, it can form a system-on-a-chip (SoC) with other circuits (such as codec circuits, hardware acceleration circuits, or various bus and interface circuits), or it can be integrated as a built-in processor within an application-specific integrated circuit (ASIC). This ASIC with integrated processor can be packaged separately or together with other circuits.

[0076] The communication interface 30 can use a transceiver device, such as a transceiver, to enable communication between the electronic device and other devices or communication networks.

[0077] To address the issue that existing IoT communication protocols are only applicable to the limited scope of specific physical layers and cannot adequately support cross-physical layer data transmission, this application adopts the concept of files to aggregate various types of data and establishes a mapping relationship between files and file indexes. During file transmission, files and file indexes are encapsulated into data blocks using different encapsulation formats. Then, the data blocks are encapsulated into corresponding data frames according to the currently used message transmission protocol for transmission. This achieves decoupling of transmission protocol and transmission content, as well as efficient collaboration of the same data across different physical layer media and MCUs.

[0078] The documents in this application are formed by combining data with interrelated content in a preset format according to the requirements of the demand party. For example, in the field of energy storage systems, various types of record files can be formed according to the data content that different demand parties (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.

[0079] Files have attributes such as filename, folder, directory, file content, and file length. A directory can contain different folders and folder levels, and a folder can contain different files and subfolders. Directory and filename are used to distinguish the meaning of different files, and a file may have different file lengths and file contents depending on specific needs.

[0080] To accommodate data transmission of various sizes, this application adopts a data block-based transmission method. When the file to be transmitted is large, it can be split into multiple data blocks for transmission, and the data block to be transmitted each time can be specified by the data offset, thereby realizing the function of resuming interrupted transmission.

[0081] Furthermore, based on the use case of file transfer, data block types are divided into two categories: index type and content type. Index type data blocks mainly include the directory and filename, encapsulated using a first encapsulation format, and are used to indicate the directory to be queried or the target file to be read. Content type data blocks mainly include the target index content or target file content, encapsulated using a second encapsulation format, and are used to provide feedback to the requesting party regarding the queried target index content or read target file content. For example, the file read data block and file query data block in the following text are index type data blocks, while the index content data block and file content data block are content type data blocks.

[0082] The implementation process of the general data transmission method for the Internet of Things is described in detail from the perspectives of the requester (i.e., the host computer below) and the provider (i.e., the slave computer below).

[0083] Please refer to Figure 4 , Figure 4 An exemplary flowchart illustrates a general IoT data transmission method applied to a host computer, including:

[0084] Step S401: Encapsulate the target file index into a file reading data block according to a preset first encapsulation format.

[0085] Specifically, the target file index includes the target file's directory and filename. In one embodiment, the data block encapsulated using the first encapsulation format includes index information, data offset information, and a continuous write flag. The index information includes directory and filename information. In one embodiment, the directory and filename information is represented using ASCII strings.

[0086] Please refer to Figure 6 , Figure 6 An exemplary structural diagram of the first encapsulation format is shown. For example... Figure 6As shown, in the first encapsulation format, the index information field occupies 10 bytes. Bytes 1-2 represent the directory, and bytes 3-10 represent the filename. Assuming the first byte is ' / ' and the second byte is the second-level directory name, it can represent 61 types of second-level directories under the root directory: '1'~'9', 'A'~'Z', 'a'~'z'. For example, " / Z012345678" represents the file "012345678" under the second-level directory 'Z'. Directory and filenames are at most 10 bytes long; if the length is insufficient, it is padded with '\0'. When all 10 bytes are '\0', it indicates reading the root directory; when the second-level directory is not '\0' and the filename is all '\0', it indicates reading the file and folder information (i.e., the target index content) under the second-level directory; when the second-level directory is '\0' and the filename is not '\0', it indicates reading the target file (i.e., the target file content) under the root directory; when neither the second-level directory nor the filename is '\0', it indicates reading the target file (i.e., the target file content) under the second-level directory. The host computer notifies the slave computer to perform corresponding operations by filling different content into the index information field.

[0087] 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-level device can split the target file content or target index content into multiple data blocks for transmission. Since the standard Modbus protocol is a query-response protocol, the continuous write flag field is mainly used in the CAN protocol. When the continuous write flag is 1, it indicates that splitting the target file content or target index content into multiple data blocks for transmission is supported; when the continuous write flag is 0, it indicates that splitting the target file content or target index content into multiple data blocks for transmission is not supported. In some embodiments, by extending the Modbus protocol, a query-multiple-response function can be implemented. In this case, the continuous write flag can be used to indicate whether the lower-level device can split the target file content or target index content into multiple data blocks for transmission.

[0088] Step S402: Based on the currently used message transmission protocol, the file read data block is encapsulated into a first index write request frame and then sent to the lower-level machine.

[0089] The message transmission protocols based on the Internet of Things (IoT) mainly include the CAN protocol and the Modbus protocol. In the traditional CAN protocol, a single data frame can only transmit 8 bytes of payload data, which cannot accommodate data block transmission with variable data sizes. Therefore, this application defines a custom multi-byte write operation based on the CAN protocol to transmit data blocks. The standard Modbus protocol supports multi-byte writes and multi-byte reads; in this embodiment, the standard Modbus protocol is directly used to implement data block transmission, simplifying and unifying data communication in IoT embedded systems.

[0090] In one embodiment, sending a data block to a target device via 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, sequentially sending the write data block start frame and at least one data payload frame to the target device, and then receiving a data response frame encapsulated according to the CAN protocol data frame format returned by the target device.

[0091] Please refer to Figure 8 , Figure 8 An exemplary diagram illustrates the structure of the write data block start frame, data payload frame, and data response frame based on the CAN protocol. Figure 8 As shown, the write data block start frame, data payload frame, and data response frame each have different data frame IDs, and bytes Data0 to Data8 correspond to data segments in the CAN protocol data frame. The write data block start frame's data segment includes the data block type, data start position, data length, and payload data checksum information, 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 data block's checksum data. The data payload frame's data segment includes the data block type, data packet number, and payload data, used to carry the payload data. The data response frame's data segment includes the data block type, data start position, data length, and payload data checksum information, used to confirm whether the target device has accurately received the data block.

[0092] In one embodiment, when the message transmission protocol is CAN, 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. Encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and sending it to the lower-level device includes: encapsulating the file read 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 sequentially sending the write data block start frame and at least one data payload frame to the lower-level device. After receiving the first index data frame, the lower-level device returns a data response frame to the upper-level device based on the received data.

[0093] In another embodiment, when the message transmission protocol is Modbus, encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and sending it to the lower-level device 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 Modbus protocol's multi-byte write request frame format, and sending the first index data frame to the lower-level device. After receiving the first index data frame, the lower-level device returns a first index response frame to the upper-level device based on the received data according to the Modbus protocol's multi-byte write response frame format. For example, using... Figure 6As shown, the data block size after being encapsulated using the first encapsulation format is a total of 16 bytes, and its corresponding first preset address space is M~M+7, where M can be any specified value.

[0094] Please refer to Figure 9 , Figure 9 This example illustrates the format of a multibyte write request frame and a multibyte write response frame in the Modbus protocol standard. Specifically, the host computer fills the lower-level machine address into the device address field of the first index data frame, fills "0x10" into the function code field, fills the start address field of the data field with the start address of the first preset address space, and fills the register count field of the data field with the size of the first preset address space (e.g., ...). Figure 6 As shown in Figure 8), the total number of bytes of the file data block read is filled in the byte number field of the data field (e.g., ...). Figure 6 As shown in Figure 16), the register value field of the data field is filled with the contents of the file read data block in sequence, and the check field is filled with the CRC check value of all data in the data field. The host computer sends the filled first index data frame to the communication bus to initiate a multi-byte write request to the slave computer. The Modbus protocol supports communication buses including RS-232, RS-485, RS-422, and Ethernet.

[0095] After receiving the first index data frame from the communication bus, the lower-level device returns a first index response frame to the upper-level device based on the received data. In the first index response frame, the lower-level device fills the device address field with its own address, the function code field with "0x10", the start address field of the data field with the start address of the first preset address space, the register quantity field of the data field with the size of the first preset address space, and the checksum field with the CRC checksum value of the received data. The lower-level device then sends the filled-in first index response frame to the communication bus.

[0096] Step S403: Receive the first content data frame sent by the lower-level device, parse the first content data frame based on the message transmission protocol, and obtain the file content data block.

[0097] In one embodiment, when the message transmission protocol is CAN, the host computer receives a first content data frame from the slave computer, which encapsulates file content data blocks through multi-byte write operations. The first content data frame includes a write data block start frame and at least one data payload frame. After receiving the first content data frame, the host computer returns a data response frame to the slave computer based on the received data.

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

[0099] Please refer to Figure 7 , Figure 7 An exemplary structural diagram of the second encapsulation format is shown. For example... Figure 7 As shown, in the second encapsulation format, the data category field occupies 2 bytes and is used to indicate the data category of the current payload data. 0 indicates that the current payload data is target index content, and 1 indicates that the current payload data is target file content. The total data field occupies 4 bytes; when the data category is 0, it indicates the total number of bytes in the target index content; when the data category is 1, it indicates the total number of bytes in the target file content. The current data transmission length field occupies 2 bytes and indicates the number of bytes of the target index content or target file content being transmitted. The data offset information field occupies 4 bytes and indicates the data offset of the current payload data within the target index content or target file content. The current payload data field is used to indicate the valid data being uploaded. For example, if the maximum length of a single payload is 128 bytes, when transmitting a 200-byte target file content, 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 a 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 Modbus, the corresponding second preset address space size is N~N+70. It should be noted that the first and second preset address spaces do not overlap.

[0100] Please refer to Figure 10 , Figure 10 This example illustrates the format of a Modbus protocol standard multibyte read request frame and multibyte read response frame. Specifically, in the first content request frame, the host computer fills the slave device address into the device address field, "0x03" into the function code field, the start address field of the data field with the start address of the second preset address space, the register quantity field of the data field with the size of the second preset address space, and the checksum field with the CRC checksum value of all data in the data field. The host computer then sends the filled first content request frame to the communication bus to initiate a multibyte read request to the slave device.

[0101] After receiving the first content request frame from the communication bus, the lower-level device returns a first content data frame to the upper-level device according to the Modbus protocol multi-byte read response frame format based on the received data. Specifically, the lower-level device fills the lower-level device address field with its address, the function code field with "0x03", the byte number field of the data field with twice the size of the second preset address space, the register value field of the data field with the contents of the file content data blocks in sequence, and the checksum field with the CRC checksum values ​​of all data in the data field. The lower-level device then sends the filled first content data frame to the communication bus.

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

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

[0104] In one embodiment, the file content data block is parsed based on a preset second encapsulation format to obtain data classification, total data count, current data transmission length, data offset information, and current payload data. When the target file content to be transmitted is large, the method of this application supports encapsulating the target file content into several file content data blocks and transmitting them to the host computer sequentially. Specifically, when the message transmission protocol is CAN protocol, if the continuous write flag carried by the file read data block is true, then the system continues to receive other first content data frames based on the target file sent by the lower-level machine until all target file content has been received; when the message transmission protocol is Modbus protocol, a new first index data frame is first obtained based on the target file index and the new data offset information, and the new first index data frame is sent to the lower-level machine, and then the system receives the new first content data frame sent by the lower-level machine based on the new first index data frame, until all target file content has been received. The new data offset information can be determined based on the total data count, current data transmission length, and data offset information carried in the file content data block.

[0105] Once the entire target file content has been received, the host computer concatenates the multiple received target file contents into a single complete file according to the data offset information. Furthermore, the host computer can parse the corresponding signal information based on the target file content encoding rules pre-agreed with the slave computer. For example, if the target file is formed by sequentially sorting current signals, voltage signals, and electrical quantity signals, the host computer can parse the values ​​of the current signal, voltage signal, and electrical quantity signal according to this rule.

[0106] In one embodiment, the host computer can also send a query directory index to the slave computer to obtain file or folder information under the query directory index. Specifically, the general IoT data transmission method applied to the host computer further includes: encapsulating the query directory index into a file query data block according to a first encapsulation format; encapsulating the file query data block into a second index data frame based on a message transmission protocol, and sending the second index data frame to the slave computer; receiving the second content data frame sent by the slave computer, parsing the second content data frame based on the message transmission protocol to obtain an index content data block; and parsing the index content data block based on the second encapsulation format to obtain the target index content. The query directory index includes query directory information (see the previous description for details), and the target index content includes file or folder information at a preset level under the query directory. For example, if the preset level is 2, the target index content includes files and folders under the query directory, as well as file and folder information under the query directory folder.

[0107] It is understandable that the specific implementation method of the host computer sending the query directory index to the slave computer to obtain the target index content under the query directory is similar to the specific implementation method of the host computer sending the target file index to the slave computer to obtain the target file content, and will not be elaborated here.

[0108] Please refer to Figure 5 , Figure 5 An exemplary flowchart illustrates a general data transmission method for the Internet of Things (IoT) applied to a lower-level machine, including:

[0109] Step S501: Receive the first index data frame sent by the host computer, parse the first index data frame based on the currently used message transmission protocol, and obtain the file read data block.

[0110] In one embodiment, when the message transmission protocol is CAN, 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-level device returns a data acknowledgment frame.

[0111] In one embodiment, when the message transmission protocol is the Modbus protocol, step S501 specifically includes: receiving a first index data frame from the host computer, which encapsulates the file read data block based on the first preset address space according to the Modbus protocol's multi-byte write request frame format; and constructing a first index response frame based on the received data according to the Modbus protocol's multi-byte write response frame format and sending it to the host computer.

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

[0113] Step S503: Determine the corresponding target file based on the target file index, and encapsulate the target file content into file content data blocks according to the preset second encapsulation format.

[0114] Step S504: Based on the message transmission protocol, the file content data block is encapsulated into a first content data frame and then sent to the host computer.

[0115] 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. 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 sequentially sending the write data block start frame and at least one data payload frame to the host computer.

[0116] 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 it to the host computer.

[0117] Figure 5 The embodiment is with Figure 4 The corresponding implementation example provides a general IoT data transmission method for lower-level devices. Figure 5 The first encapsulation format, the second encapsulation format, and the method for transmitting data blocks of the first encapsulation format and the second encapsulation format based on the message transmission protocol in the embodiments are similar to those in the embodiments. Figure 4 The embodiments are the same, and in Figure 4 The examples have already been described accordingly, and will not be repeated here.

[0118] In one embodiment, when the message transmission protocol is the CAN protocol, the data parsed from the file read data block based on the first encapsulation format includes the target file index, data offset information, and a continuous write flag. Step S503 specifically includes: when the continuous write flag is true, determining the target file content based on the target file index and data offset information, and encapsulating the target file content into one or more file content data blocks according to the second encapsulation format. In one embodiment, the lower-level machine determines the target file content based on the total number of data in the target file and the maximum payload length for a single transmission (e.g., ...). Figure 7The target file content (128 bytes in length) is split and encapsulated into multiple file content data blocks according to the second encapsulation format. For example, after parsing the file reading data block, the lower-level machine obtains the target file index as " / z123.txt0", the offset information is 0, and the continuous write flag is 1. Based on this target file index, the target file can be determined to be the "123.txt" file under the second-level directory "z". If the size of the "123.txt" file is 200 bytes, and the maximum payload length for a single transmission is 128 bytes, then the "123.txt" file can be split into two parts and encapsulated into two file content data blocks. The current payload data of the first file content data block starts from the beginning of the "123.txt" file and has a length of 128 bytes; the current payload 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 payload data in the first file content data block can be less than 128 bytes.

[0119] In one embodiment, the lower-level device can also obtain a query directory index sent by the upper-level device and return file or folder information under the query directory index to the upper-level device. Specifically, the general IoT data transmission method applied to the lower-level device further includes: receiving a second index data frame sent by the upper-level device; parsing the second index data frame based on a message transmission protocol to obtain a file query data block; parsing the file query data block based on a first encapsulation format to obtain a query directory index; determining the corresponding target index based on 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-level device. It is understood that when the target index content data is large, the method of this application also supports encapsulating the target index content into several index content data blocks and transmitting them to the upper-level device sequentially.

[0120] Please refer to Figure 11 , Figure 11 This example illustrates a complete file transfer process based on the CAN protocol. Specifically, the entire file transfer process includes the following four steps:

[0121] Step 1101: The host computer sends the query directory index to the slave computer through a multi-byte write operation.

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

[0123] Step 1103: The host computer sends the target file index to the slave computer through a multi-byte write operation.

[0124] Step 1104: The lower-level machine sends the target file content to the upper-level machine through a multi-byte write operation.

[0125] In steps 1101-1103, the amount of data transmitted is relatively small, and all data transmission can be completed through a single data block. In step 1104, the target file content is split 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 payload frame, and a data acknowledgment frame.

[0126] Please refer to Figure 12 , Figure 12 This example illustrates a complete file transfer process based on the Modbus protocol. Specifically, the entire file transfer process includes the following four steps:

[0127] Step 1201: The host computer sends the query directory index to the slave computer by writing a multi-byte message to the first preset address space, and the slave computer returns a write success response.

[0128] Specifically, the host computer sends the query directory index by writing a multi-byte address in the range [M~M+7]. For example, if the query directory index is the root directory, then the index information field in 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.

[0129] Step 1202: The host computer queries the target index content of the slave computer by reading the second preset address space through multi-byte read, and the slave computer returns a response containing the target index content.

[0130] Specifically, the host computer obtains the target index content through a multi-byte read method [address N~N+69]. The slave computer responds to the host computer's directory query by constructing a response frame containing a data block of index content and returning it to the host computer. If there is only one file named "alarm" in the queried directory, the data category 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 payload data is "alarm" + 123 "0"s (a total of 128 bytes).

[0131] Step 1203: The host computer sends the target file index to the slave computer by writing multiple bytes to the first preset address space, and the slave computer returns a write success response.

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

[0133] Step 1204: The host computer queries the target file content of the slave computer by reading the second preset address space via multi-byte read, and the slave computer returns a response containing the target file content.

[0134] Specifically, the host computer obtains the target file content using the multi-byte read method [address N~N+69]. The slave computer responds to the host computer's file query by constructing a response frame containing a block of file content data and returning it to the host computer. For example, if the total number of "alarm" data is 64 bytes, then the constructed file content data block is classified as 1, the total number of bytes in the target file content is 64, the current data transmission length is 64, the data offset is 0, and the current payload data is 64 bytes of "alarm" file content plus 64 zeros.

[0135] The implementation methods for steps 1203 and 1204 are similar to those for steps 1201 and 1202. When the content of the target file exceeds the maximum load length for a single transmission, steps 1203 and 1204 can be repeated multiple times until all target file content has been transmitted; when the content of the target index exceeds the maximum load length for a single transmission, steps 1201 and 1202 can be repeated multiple times until all target index content has been transmitted.

[0136] The IoT general data transmission method provided in this application uses the concept of files to summarize various types of data and establishes a mapping relationship between files and file indexes. When transmitting files, files and file indexes are encapsulated into data blocks using different encapsulation formats. Then, the data blocks are encapsulated into corresponding data frames according to the currently used message transmission protocol for transmission. This achieves decoupling of transmission protocol and transmission content, enabling different IoT communication protocols to efficiently collaborate between different physical layer media and MCUs based on the same data.

[0137] According to an embodiment of this application, a computer-readable storage medium of the type described above is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor performs the steps of the general data transmission method for the Internet of Things described above.

[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A universal data transmission method for the Internet of Things, characterized in that, Applied to a host computer, the method includes: The target file index is encapsulated into file read data blocks according to the preset first encapsulation format; Based on the currently used message transmission protocol, the file read data block is encapsulated into a first index data frame and then sent to the lower-level machine; The system receives a first content data frame sent by a lower-level device, parses the first content data frame based on the message transmission protocol, and obtains a file content data block. The file content data blocks are parsed based on a preset second encapsulation format to obtain the target file content; The data block encapsulated using the first encapsulation format includes index information, data offset information, and a continuous write flag. The data block encapsulated using the second encapsulation format includes data classification, total data count, current data transmission length, data offset information, and current load data. The first index data frame and the first content data frame include one or more data frames. 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 the file read data block. The step of encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and sending it to the lower-level device includes: The file read data block is encapsulated into a write data block start frame and at least one data payload frame according to the data frame format of the CAN protocol. The write data block start frame and the at least one data payload frame are sent to the lower-level machine in sequence. The data segment of the write data block start frame includes data block type, data start position, data length and payload data verification information. The data segment of the data payload frame includes data block type, data packet number and payload data.

2. The method according to claim 1, characterized in that, The method further includes: The query directory index is encapsulated into file query data blocks 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-level machine. The system receives a second content data frame sent by a lower-level device, parses the second content data frame based on the message transmission protocol, and obtains an index content data block. The index content data block is parsed based on the second encapsulation format to obtain the target index content.

3. The method according to claim 1, characterized in that, The data parsed from the file content data blocks based on the second encapsulation format includes the total number of data, the current data transmission length, data offset information, and the current payload data. The method further includes: Determine whether the target file has been completely transmitted based on the total number of data, the current data transmission length, and the data offset information; If not, when the message transmission protocol is 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 device until all target file content is received; when the message transmission protocol is Modbus protocol, a new first index data frame is obtained based on the target file index and new data offset information, the new first index data frame is sent to the lower device, and then the lower device is received to send new first content data frames based on the new first index data frame until all target file content is received.

4. The method according to any one of claims 1 to 3, characterized in that, When the message transmission protocol is Modbus, the step of encapsulating the file read data block into a first index data frame based on the currently used message transmission protocol and sending it to the lower-level machine includes: The file read data block is encapsulated into a first index data frame based on the first preset address space corresponding to the first encapsulation format according to the Modbus protocol multibyte write request frame format, and the first index data frame is sent to the lower-level machine. The first content data frame received from the lower-level device includes: After constructing a first content request frame based on the second preset address space corresponding to the second encapsulation format according to the Modbus protocol's multibyte read request frame format, it is sent to the lower-level machine. Receive the first content data frame returned by the lower-level machine according to the multi-byte read response frame format of the Modbus protocol.

5. A universal data transmission method for the Internet of Things, characterized in that, Applied to a lower-level machine, the method includes: The system receives the first index data frame sent by the host computer, parses the first index data frame based on the currently used message transmission protocol, and obtains the file read data block. The file read data blocks are parsed based on a preset first encapsulation format to obtain the target file index; The target file corresponding to the target file index is determined, and the content of the target file is encapsulated into file content data blocks according to the preset second encapsulation format. Based on the message transmission protocol, the file content data block is encapsulated into a first content data frame and then sent to the host computer. The data block encapsulated using the first encapsulation format includes index information, data offset information, and a continuous write flag. The data block encapsulated using the second encapsulation format includes data classification, total data count, current data transmission length, data offset information, and current load data. The first index data frame and the first content data frame include one or more data frames. 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. The step of encapsulating the file content data block into a first content data frame based on the message transmission protocol and 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 payload frame according to the data frame format of the CAN protocol, and the write data block start frame and the at least one data payload frame are sent to the host computer in sequence; wherein, the data segment of the write data block start frame includes data block type, data start position, data length and payload data verification information, and the data segment of the data payload frame includes data block type, data packet number and payload data.

6. The method according to claim 5, characterized in that, The method further includes: The system receives a second index data frame sent by the host computer, parses the second index data frame based on the message transmission protocol, and obtains a file query data block. The file query data block is parsed based on the first encapsulation format to obtain the query directory index; Based on the query directory index, the corresponding target index is determined, and the target index content is encapsulated into an index content data block according to the second encapsulation format. Based on the message transmission protocol, the index content data block is encapsulated into a second content data frame, and the second content data frame is sent to the host computer.

7. The method according to claim 5 or 6, characterized in that, The data parsed from 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 true, determining the corresponding target file based on the target file index and encapsulating the target file content into a file content data block according to the preset second encapsulation format includes: The content of the target file is determined based on 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 the second encapsulation format.

8. The method according to claim 5 or 6, characterized in that, When the message transmission protocol is Modbus, the step of encapsulating the file content data block into a first content data frame based on the message transmission protocol and sending it to the host computer includes: Receive a first content request frame constructed by the host computer according to the Modbus protocol multi-byte read request frame format based on the 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 Modbus protocol's multi-byte read response frame format and then sent to the host computer.

9. 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 to enable the at least one processor to perform the method as described in any one of claims 1 to 8.

10. A computer storage medium, characterized in that, The computer storage medium stores instructions or programs that, when executed by at least one processor, cause the at least one processor to perform the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

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

    CN117221310A