Movatterモバイル変換


[0]ホーム

URL:


CN119814774A - File transmission method, equipment and storage medium based on CAN protocol - Google Patents

File transmission method, equipment and storage medium based on CAN protocol
Download PDF

Info

Publication number
CN119814774A
CN119814774ACN202510286453.3ACN202510286453ACN119814774ACN 119814774 ACN119814774 ACN 119814774ACN 202510286453 ACN202510286453 ACN 202510286453ACN 119814774 ACN119814774 ACN 119814774A
Authority
CN
China
Prior art keywords
data
file
index
data block
content
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510286453.3A
Other languages
Chinese (zh)
Inventor
马辉
张勇波
温丹
杨嘉俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Delian Minghai New Energy Co ltd
Original Assignee
Shenzhen Delian Minghai New Energy Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Delian Minghai New Energy Co ltdfiledCriticalShenzhen Delian Minghai New Energy Co ltd
Priority to CN202510286453.3ApriorityCriticalpatent/CN119814774A/en
Publication of CN119814774ApublicationCriticalpatent/CN119814774A/en
Pendinglegal-statusCriticalCurrent

Links

Landscapes

Abstract

Translated fromChinese

本申请涉及CAN通信技术领域,具体涉及一种基于CAN协议的文件传输方法、设备及存储介质。基于CAN协议的文件传输方法包括:上位机将目标文件索引按照第一封装格式封装成文件读取数据块,并通过自定义的多字节写操作发送到下位机,再接收下位机通过多字节写操作发送的文件内容数据块,基于第二封装格式对文件内容数据块进行解析,得到目标文件内容。本申请的方法,不仅可支持文件断点续传,而且极大地提高了数据的传输效率,使得CAN协议可与其他物联网通信协议基于同一数据在不同物理层介质、MCU之间进行高效协同。

The present application relates to the field of CAN communication technology, and specifically to a file transfer method, device and storage medium based on the CAN protocol. The file transfer method based on the CAN protocol includes: the upper computer encapsulates the target file index into a file reading data block according to a first encapsulation format, and sends it to the lower computer through a customized multi-byte write operation, and then receives the file content data block sent by the lower computer through the multi-byte write operation, and parses the file content data block based on the second encapsulation format to obtain the target file content. The method of the present application can not only support file breakpoint continuation, but also greatly improve the data transmission efficiency, so that the CAN protocol can be efficiently coordinated with other Internet of Things communication protocols based on the same data between different physical layer media and MCUs.

Description

File transmission method, equipment and storage medium based on CAN protocol
Technical Field
The application relates to the technical field of CAN communication, in particular to a file transmission method, device and storage medium based on CAN protocol.
Background
In the existing internet of things communication network, physical transmission media are various, such as ethernet (wired, wireless, WIFI, 2/3/4/5G cellular network), serial port communication (UART/RS 232/RS 485), CAN (Controller Area Network ) and the like. The equivalent unifies to different application layer communication protocols for different physical transmission media under the OSI (Open System Interconnect, open systems interconnect) communication data model. In the prior art, the Ethernet and serial port communication usually adopts a standard modbus communication protocol, and the standard application layer protocols which are usually adopted by a CAN bus are CANopen, SAE J1939 and the like. Each standard is only applicable to a limited range of each specific physical layer, and is not well compatible with cross-physical layer data transmission. In addition, for the history data stored in the device side, the CAN protocol generally adopts a simple and immediate question-answer interaction protocol (i.e. the upper computer sends a message for inquiring and formulating the object, and the lower computer returns an effective content message immediately based on the object index). This approach does not adequately address the local data read actual latency and protocol transmission longest response latency reservation.
In order to simplify and unify data communication in an embedded system of the internet of things, a data transmission method is needed to enable a CAN protocol and other internet of things communication protocols to perform efficient cooperation (such as time delay and throughput) between different physical layer media and MCUs (Microcontroller Unit and micro control units) based on the same data.
Disclosure of Invention
The embodiment of the application provides a file transmission method, equipment and storage medium based on a CAN protocol, which solve the problem that the traditional CAN protocol cannot be efficiently cooperated with other Internet of things communication protocols between different physical layer media and MCUs based on the same data.
In a first aspect, an embodiment of the present application provides a file transmission method based on a CAN protocol, which is applied to an upper computer, where the method includes:
Packaging the target file index into file read data blocks according to a preset first packaging format, and transmitting the file read data blocks to a lower computer through a user-defined multi-byte write operation;
Receiving a file content data block sent by the lower computer through the multi-byte write operation, and analyzing the file content data block based on a preset second encapsulation format to obtain target file content;
The sending the file read data block to the lower computer through the custom multi-byte write operation comprises:
And encapsulating the file read data block into a write data block start frame and at least one data load frame according to a CAN protocol data frame format, sequentially transmitting the write data block start frame and the at least one data load frame to a lower computer, and receiving a data response frame encapsulated according to the CAN protocol data frame format returned by the lower computer.
Optionally, the data segments of the write data block start frame and the data response frame include a data block type, a data start position, a data length and load data verification information, and the data segments of the data load frame include a data block type, a data packet number field and load data.
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 number of data, current data transmission length, data offset information and current load data.
Optionally, the method further comprises:
packaging the query directory index into a file query data block according to the first packaging format, and transmitting the file query data block to the lower computer through the multi-byte write operation;
And receiving an index content data block sent by the lower computer through the multi-byte writing operation, and analyzing the index content data block based on the second packaging format to obtain target index content.
In a second aspect, an embodiment of the present application provides a file transmission method based on a CAN protocol, which is applied to a lower computer, where the method includes:
Receiving a file reading data block sent by an upper computer through a user-defined multi-byte write operation, and analyzing the file reading data block based on a preset first encapsulation format to obtain a target file index;
determining target file content corresponding to the target file index according to the target file index, packaging the target file content into file content data blocks according to a preset second packaging format, and transmitting the file content data blocks to the upper computer through the multi-byte writing operation;
The sending the file content data block to the host computer by the multi-byte write operation includes:
And encapsulating the file content data block into a write data block starting frame and at least one data load frame according to a data frame format of a CAN protocol, sequentially transmitting the write data block starting frame and the at least one data load frame to the upper computer, and receiving a data response frame which is returned by the upper computer and encapsulated according to the data frame format of the CAN protocol.
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 number of data, current data transmission length, data offset information and current load data.
Optionally, the method further comprises:
Receiving a file inquiry data block sent by the upper computer through the multi-byte write operation, and analyzing the file inquiry data block based on the first encapsulation format to obtain an inquiry directory index;
And determining target index content corresponding to the index directory index according to the index directory index, packaging the target index content into an index content data block according to the second packaging format, and transmitting the index content data block to the upper computer through the multi-byte writing operation.
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 writing flag, when the continuous writing flag is yes, determining target file content corresponding to the target file index according to the target file index, encapsulating the target file content into a file content data block according to a preset second encapsulation format, and sending the file content data block to the upper computer through the multi-byte writing operation includes:
Determining the content of the target file according to the target file index and the data offset information;
and packaging the target file content into M file content data blocks according to a second packaging format, and sequentially sending each file content data block to the upper computer through M times of multi-byte write operation, wherein M is an integer greater than or equal to 1.
In a third aspect, an embodiment of the present application provides an electronic device comprising at least one processor and a memory communicatively coupled 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 any one of the methods described above.
In a fourth aspect, embodiments of the present application provide a computer storage medium storing instructions or a program which, when executed by at least one processor, cause the at least one processor to perform the method of any one of the preceding claims.
In the embodiment of the application, a file transmission method based on a CAN protocol is provided, an upper computer encapsulates a target file index into a file read data block according to a first encapsulation format, the file read data block is sent to a lower computer through a self-defined multi-byte write operation, then the file content data block sent by the lower computer through the multi-byte write operation is received, and the file content data block is analyzed based on a second encapsulation format to obtain target file content. According to the method, various data are summarized by adopting a file concept, the mapping relation between the file and the file index is established, the file and the file index are packaged into data blocks by adopting different packaging formats when the file is transmitted, and the data are transmitted by a self-defined multi-byte writing operation method, so that not only CAN the continuous transmission of file break points be supported, but also the data transmission efficiency is greatly improved, and the CAN protocol and other Internet of things communication protocols CAN be efficiently cooperated between different physical layer media and MCUs based on the same data.
Drawings
FIG. 1 illustrates a topology of a CAN bus;
FIG. 2 illustrates a frame structure diagram of a CAN protocol data frame;
FIG. 3 is a schematic diagram schematically showing a hardware structure of an electronic device;
FIG. 4 illustrates a flow chart of a CAN protocol based file transfer method applied to a host computer;
FIG. 5 illustrates a flow chart of a CAN protocol based file transfer method applied to a lower computer;
FIG. 6 illustrates a block diagram of a first package format;
FIG. 7 illustrates a block diagram of a second package format;
FIG. 8 illustrates a block diagram of a write data block start frame, a data payload frame, and a data reply frame;
Fig. 9 shows an exemplary overall process diagram of a file transfer based on the CAN protocol.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Referring to fig. 1, fig. 1 illustrates a topology of a CAN bus. As shown in fig. 1, the CAN bus includes two wires, can_h and can_l, and nodes 1 to N are connected to the CAN bus through a CAN controller and a CAN transceiver, respectively. In the CAN protocol, the types of frames are largely divided into data frames, remote frames, error frames, and overload frames. The remote frame is used for requesting the data, the error frame is used for indicating that an error occurs, and the overload frame is used for indicating that the node can not receive the data. The file transmission method based on the CAN protocol transmits the data blocks from the sending node to the receiving node through the data frames.
Referring to fig. 2, fig. 2 illustrates a frame structure diagram of a CAN protocol data frame. The data frames include standard frames and extended frames, and each data frame may specifically include seven parts of a frame start, an arbitration segment, a control segment, a data segment, a CRC segment, an ACK segment, and a frame end segment. The arbitration section is used for determining the sending priority, and comprises a data frame ID, wherein the data section contains data actually transmitted, and can transmit 8 bytes of data at most. When the data frame is transmitted on the CAN bus, each CAN node compares whether the data frame ID on the bus is consistent with the ID of the node through an acceptance filter, and if so, the CAN controller only allows the accepted information to be stored in the corresponding register. Through the acceptance filtering technology, the CAN bus CAN realize one-to-one, one-to-many, global broadcasting and other data transmission modes without special scheduling.
Referring to fig. 3, fig. 3 illustrates a hardware configuration diagram of an electronic device. The electronic device may be any of the node devices of fig. 1. As shown in fig. 3, the electronic device 100 includes a processor 10, a memory 20, and a communication interface 30, where the processor 10, the memory 20, and the communication interface 30 are connected by wires, and in the embodiment shown in fig. 3, the processor 10, the memory 20, and the communication interface 30 are communicatively connected to each other by a bus.
The memory 20 is used to store software programs, computer-executable program instructions, and the like. The memory 20 may include a storage program area that may store an operating system, application programs required for at least one function, and a storage data area that may store data created according to the use of the electronic device, etc.
The Memory 20 may be a Read-On1y Memory (ROM), other types of static storage devices capable of storing static information and instructions, a random access Memory (Random Access Memory, RAM), other types of dynamic storage devices capable of storing information and instructions, and an electrically erasable programmable Read-only Memory (E1 ectrica11y Erasab1E Programmab E Read-On1y Memory, EEPROM), which is not limited herein.
The aforementioned memory 20 may be, for example, a double rate synchronous dynamic random access memory DDR SDRAM (DDR for short). The memory 20 may exist separately but be connected to the processor 10. Alternatively, the memory 20 may be integral to the processor 10. For example, integrated within one or more chips.
In some embodiments, memory 20 may optionally include memory located remotely from processor 10, which 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.
The processor 10 connects the various parts of the overall electronic device 100 using various interfaces and lines, performs various functions of the electronic device and processes data, such as implementing the methods described in any of the embodiments of the present application, by running or executing software programs stored in the memory 20, and invoking data stored in the memory 20.
Processor 10 may be a field programmable gate array (Field Programmable GATE ARRAY, FPGA), a digital signal processor (Digita signal 1 Process, DSP), a Central Processing Unit (CPU), or the like.
The processor 10 may be a single-core processor or a multi-core processor, for example, the processor 10 may be composed of a plurality of FPGAs or a plurality of DSPs. Furthermore, processor 10 may refer to one or more devices, circuitry, and/or processing cores for processing data (e.g., computer program instructions). The processor 10 may be a single semiconductor Chip, or may be integrated with other circuits into a single semiconductor Chip, for example, may form a System-on-a-Chip (SoC) with other circuits (such as 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, where the ASIC with integrated processor may be packaged separately or may be packaged with other circuits.
The communication interface 30 may enable communication between the electronic device and other devices or communication networks using a transceiver device, such as a transceiver.
The data among the devices of the Internet of things generally comprise real-time data, historical data, configuration parameters and the like, the conventional transmission method is based on limited specific signal quantity requirements, a data point table (or a register) is gradually expanded based on the requirements by squeezing toothpaste, and the table length is infinitely increased in a pancake manner. The application layer data above different physical layers is merely the association of peer data point tables, and efficient coordination (such as delay and throughput) of the same data between different physical layer media and MCUs cannot be achieved. In order to solve the problems, the application adopts the file concept to summarize various data, establishes the mapping relation between the file and the file index, encapsulates the file and the file index into data blocks by adopting different encapsulation formats when transmitting the file, and transmits the data blocks by a self-defined multi-byte write operation method, thereby not only supporting the continuous transmission of file break points, but also greatly improving the data transmission efficiency, and enabling the CAN protocol and other internet of things communication protocols to efficiently cooperate between different physical layer media and MCUs based on the same data.
The file is formed by combining data with content meanings related to each other according to the requirement of a user and a preset format. For example, in the field of energy storage systems, various types of record files, such as fault records, operation records, historical power generation, equipment replacement records, and the like, can be formed according to data contents to be checked by different demand parties (such as clients, operation and maintenance engineers, research and development engineers).
Files have attributes such as file names, folders, file directories, file contents, file lengths, etc. Different folders and folder levels exist under one file directory, and different files and subordinate folders exist under one folder. The directory and file names are used to distinguish the meaning of different files, one file may have different file lengths and file contents based on specific needs.
In order to adapt to data transmission of various sizes, the application adopts a transmission method based on data blocks, when a file to be transmitted is large, the file can be split into a plurality of data blocks for transmission, and the data blocks transmitted for each time are designated through data offset, so that the breakpoint continuous transmission function is realized.
Further, the data block types are classified into two types, namely an index type and a content type, based on the usage scenario of file transfer. The index type data block mainly comprises a directory and a file name, and is packaged in a first packaging format and used for indicating the directory to be queried or the target file to be read. The content type data block mainly comprises target index content or target file content, and is packaged by adopting a second packaging format and used for feeding back the inquired target index content or the read target file content to a requestor. For example, the file read data block and the file query data block hereinafter are index type data blocks, and the index content data block and the file content data block are content type data blocks.
The implementation procedure of the CAN protocol-based file transfer method is specifically described below from the requestor (i.e., the upper computer below) and the provider (i.e., the lower computer below), respectively.
Referring to fig. 4, fig. 4 illustrates a flowchart of a file transmission method based on CAN protocol applied to a host computer, including:
step S401, packaging the target file index into file read data blocks according to a preset first packaging format, and sending the file read data blocks to a lower computer through a user-defined multi-byte write operation.
Specifically, the target file index includes a directory and a file name of the target file. In one embodiment, a data block encapsulated in a first encapsulation format includes index information, data offset information, and a continuous write flag. Wherein the index information includes directory and file name information. In one embodiment, the directory and filename information is represented by an ASCII string.
Referring to fig. 6, fig. 6 illustrates a block diagram of a first package format. As shown in fig. 6, in the first encapsulation format, out of 10 bytes occupied by the index information field, the 1 st to 2 nd bytes represent directories and the 3 rd to 10 th bytes represent file names. Assuming that the 1 st byte is '/', and the 2 nd byte is a secondary directory name, 61 secondary directories under the root directory can be represented by '1' to '9', 'A' to 'Z', 'a' to 'Z'. For example, "/Z012345678" represents the "012345678" file under the secondary directory 'Z'. The directory and file names are 10 bytes at maximum, and are complemented with '\0' when the length is insufficient. When 10 bytes are '0', the method indicates that the root directory is read, when the second-level directory is not '0', the file names are all '0', the method indicates that the files and the folder information (namely, target index contents) under the second-level directory are read, when the second-level directory is '0', the file names are not '0', the method indicates that the target files (namely, target file contents) under the root directory are read, and when the second-level directory and the file names are not '0', the method indicates that the target files (namely, target file contents) under the second-level directory are read. The upper computer fills different contents in the index information field to inform the lower computer of corresponding operation.
The data offset field occupies 4 bytes and contains the read offset location of the target file or target index. The continuous writing flag field occupies 2 bytes and is used for indicating whether the lower computer can split the target file content or the target index content into a plurality of data blocks for transmission. Specifically, when the continuous writing flag is 1, it indicates that the splitting of the target file content or the target index content into a plurality of data blocks is supported for transmission, and when the continuous writing flag is 0, it indicates that the splitting of the target file content or the target index content into a plurality of data blocks is not supported for transmission.
The message transmission protocol based on the Internet of things mainly comprises a CAN protocol and a Modbus protocol. In the conventional CAN protocol, only 8 bytes of payload data CAN be transmitted in one data frame, and the transmission of data blocks with variable data sizes cannot be adapted. Therefore, the application self-defines a multi-byte writing operation method to realize the transmission of the data blocks, and can simplify and unify the data communication in the embedded system of the Internet of things.
Specifically, the step of sending the data block to the target device through the custom multi-byte write operation includes the steps of packaging the data block into a write data block start frame and at least one data load frame according to a CAN protocol data frame format, sequentially sending the write data block start frame and the at least one data load frame to the target device, and then receiving a data response frame which is returned by the target device and packaged according to the CAN protocol data frame format.
Referring to fig. 8, fig. 8 illustrates a block diagram of a write data block start frame, a data payload frame, and a data response frame. As shown in fig. 8, the write Data block start frame, the Data load frame, and the Data response frame have different Data frame IDs, respectively, and Data0 to Data8 bytes correspond to Data segments in the Data frame of the CAN protocol. The data segment of the write data block start frame includes a data block type, a data start position, a data length, and load data verification information for informing the target device of the write position of the data block in the original file or content, the size of the data block, verification data of the data block, and the like. The data segment of the data payload frame includes a data block type, a data packet number, and payload data for carrying the payload data. The data segment of the data reply frame includes a data block type, a data start position, a data length, and payload data verification information for confirming whether the target device accurately received the data block.
Step S402, receiving a file content data block sent by the lower computer through multi-byte writing operation, and analyzing the file content data block based on a preset second encapsulation format to obtain target file content.
After receiving the file reading data block, the lower computer analyzes the target file index carried in the file reading data block based on the first encapsulation format, determines a target file corresponding to the target file index according to the target file index, encapsulates the target file content into a file content data block according to the second encapsulation format, and then sends the file content data block to the upper computer through multi-byte writing operation.
Referring to fig. 7, fig. 7 illustrates a block diagram of a second package format. In the second encapsulation format, as shown in fig. 7, the data sort field occupies 2 bytes for representing the data category of the current payload data. Wherein 0 represents that the current load data is the target index content, and 1 represents that the current load data is the target file content. The total data number field occupies 4 bytes, and represents the total number of bytes of the target index content when the data is classified as 0, and represents the total number of bytes of the target file content when the data is classified as 1. The current data transmission length field occupies 2 bytes, and represents the byte number of the target index content or the target file content of the current transmission. The data offset information field occupies 4 bytes and represents the data offset of the current load data in the target index content or the target file content. And the current load data field is used for representing the uploaded valid data. If the maximum length of a single payload is 128 bytes, when a 200-byte object file content is transmitted, the object file content can be split into two data blocks, wherein 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.
In one embodiment, the file content data block is parsed based on a preset second encapsulation format to obtain a data classification, a total number of data, a current data transmission length, data offset information, and current payload data. When the content of the target file to be transmitted is larger, the method supports the encapsulation of the content of the target file into a plurality of file content data blocks and then the file content data blocks are sequentially transmitted to an upper computer. Specifically, if the continuous writing flag carried by the file reading data block is yes, other first content data frames based on the target file sent by the lower computer are continuously received until the content of all the target files is received. And after the target file content is completely received, splicing the target file content received for multiple times into a complete file according to the data offset information. Further, the upper computer can analyze the corresponding signal information according to the content coding rule of the target file pre-agreed with the lower computer. For example, the target file is formed by sequentially sorting the current signal, the voltage signal, the electric quantity signal and the like, and then the upper computer can analyze the values of the current signal, the voltage signal and the electric quantity signal according to the rule.
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. The file transmission method based on the CAN protocol, which is applied to the upper computer, further comprises the steps of packaging the query directory index into a file query data block according to a first packaging format, sending the file query data block to the lower computer through multi-byte writing operation, receiving an index content data block sent by the lower computer through multi-byte writing operation, and analyzing the index content data block based on a second packaging format to obtain target index content. The query directory index includes query directory information (please refer to the foregoing description specifically), and the target index content includes file or folder information of a preset hierarchy under the query directory. For example, if the preset hierarchy is level 2, the target index content includes a file and a folder under the query directory, and a file and folder information under the query directory folder.
Referring to fig. 5, fig. 5 illustrates a flowchart of a file transmission method based on CAN protocol applied to a lower computer, including:
Step S501, receiving a file read data block sent by an upper computer through a user-defined multi-byte write operation, and analyzing the file read data block based on a preset first encapsulation format to obtain a target file index.
Step S502, determining target file content corresponding to the target file index according to the target file index, packaging the target file content into file content data blocks according to a preset second packaging format, and sending the file content data blocks to an upper computer through multi-byte writing operation.
In one embodiment, when the content of the target file to be transmitted is large, the method of the application supports the sequential transmission after the target file content is packaged into a plurality of file content data blocks. Specifically, the lower computer analyzes the file read data block based on the first package format, and can analyze the target file index, the data offset information and the continuous writing mark. When the continuous writing mark is yes, the lower computer determines the content of the target file according to the index of the target file and the data offset information, splits the content of the target file according to the size of the content of the target file, the maximum single transmission load length, the current network transmission environment, the processing capacity of current equipment and the like, encapsulates the content of the target file into M file content data blocks according to a second encapsulation format, and sequentially sends each file content data block to the upper computer through M multi-byte writing operations. Wherein M is an integer greater than or equal to 1. When the continuous writing mark is no, if the size of the target file content does not exceed the maximum load length of single transmission, packaging all the target file content into a data block and sending the data block to an upper computer, and if the size of the target file content exceeds the maximum load length of single transmission, packaging the target file content with the maximum load length of single transmission into a data block and sending the data block to an upper computer.
For example, after the lower computer analyzes the file read data block, the target file index is "/z123.Txt0", the offset information is 0, and the continuous writing flag is 1. According to the target file index, the target file can be determined to be a 123.Txt file under the folder of the secondary directory z. If the size of the "123.Txt" file is 200 bytes and the maximum payload length of a single transmission is 128 bytes, the "123.Txt" file can be split into two parts and then packaged into two file content data blocks. The current load data of the first file content data block starts from the initial data of the 123.Txt file and has a length of 128 bytes, and the current load data of the second file content data block starts from the 128 th byte of the 123.Txt file and has a length of 72 bytes. It is understood that the length of the current payload data in the first file content data block may be less than 128 bytes.
In one embodiment, the lower computer may 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. The file transmission method based on the CAN protocol, which is applied to the lower computer, further comprises the steps of receiving a file query data block sent by the upper computer through multi-byte writing operation, analyzing the file query data block based on a first encapsulation format to obtain a query directory index, determining target index content corresponding to the query directory index according to the query directory index, encapsulating the target index content into an index content data block according to a second encapsulation format, and sending the index content data block to the upper computer through multi-byte writing operation. It will be appreciated that when the target index content data is large, the target index content data may be split and packaged into a plurality of index content data blocks, and each index content data block is sequentially sent to the upper computer through a multi-byte write operation.
Referring to fig. 9, fig. 9 is a schematic diagram illustrating a whole file transfer process based on the CAN protocol. Specifically, the whole file transmission process comprises the following 4 steps:
in step 901, the upper computer sends the query directory index to the lower computer through a multi-byte write operation.
In step 902, the lower computer sends the target index content to the upper computer through a multi-byte write operation.
In step 903, the upper computer sends the target file index to the lower computer through a multi-byte write operation.
In step 904, the lower computer sends the content of the target file to the upper computer through a multi-byte write operation.
The data size transmitted in step 901 to step 903 is smaller, and all data transmission can be completed through one data block. The target file content transmitted in step 904 is split into a plurality of data blocks for transmission. The transmission of each data block is accomplished by a write data block start frame, at least one data payload frame, and a data reply frame.
According to the file transmission method based on the CAN protocol, the upper computer encapsulates the target file index into the file read data block according to the first encapsulation format, the file read data block is sent to the lower computer through the self-defined multi-byte write operation, then the file content data block sent by the lower computer through the multi-byte write operation is received, and the file content data block is analyzed based on the second encapsulation format, so that the target file content is obtained. According to the method, various data are summarized by adopting a file concept, the mapping relation between the file and the file index is established, the file and the file index are packaged into data blocks by adopting different packaging formats when the file is transmitted, and the data are transmitted by a self-defined multi-byte writing operation method, so that not only CAN the continuous transmission of file break points be supported, but also the data transmission efficiency is greatly improved, and the CAN protocol and other Internet of things communication protocols CAN be efficiently cooperated between different physical layer media and MCUs based on the same data.
According to an embodiment of the present application, there is provided a computer-readable storage medium of the type described above, the computer-readable storage medium storing a computer program which, when executed by a processor, performs the steps of the CAN protocol-based file transfer method described above.
It should finally be noted that the above embodiments are only intended to illustrate the technical solution of the present application and not to limit it, that the technical features of the above embodiments or of the different embodiments may be combined in any order, and that many other variations in the different aspects of the present application as described above exist, which are not provided in details for the sake of brevity, and that although the application has been described in the detailed description with reference to the foregoing embodiments, it should be understood by those skilled in the art that it may still make modifications to the technical solution described in the foregoing embodiments or equivalent to some of the technical features thereof, where these modifications or substitutions do not depart from the essence of the corresponding technical solution from the scope of the technical solution of the embodiments of the present application.

Claims (10)

CN202510286453.3A2025-03-122025-03-12File transmission method, equipment and storage medium based on CAN protocolPendingCN119814774A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202510286453.3ACN119814774A (en)2025-03-122025-03-12File transmission method, equipment and storage medium based on CAN protocol

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202510286453.3ACN119814774A (en)2025-03-122025-03-12File transmission method, equipment and storage medium based on CAN protocol

Publications (1)

Publication NumberPublication Date
CN119814774Atrue CN119814774A (en)2025-04-11

Family

ID=95257191

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202510286453.3APendingCN119814774A (en)2025-03-122025-03-12File transmission method, equipment and storage medium based on CAN protocol

Country Status (1)

CountryLink
CN (1)CN119814774A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109976767A (en)*2017-12-272019-07-05深圳市优必选科技有限公司 Software burning method and device
CN114422289A (en)*2022-01-112022-04-29国网电力科学研究院有限公司Transmission method and device for CAN (controller area network) message of electric vehicle
CN117221310A (en)*2023-09-052023-12-12佳源科技股份有限公司File transmission method and device based on multifunctional electric energy meter communication protocol
CN118642739A (en)*2024-06-142024-09-13江苏汇智高端工程机械创新中心有限公司 A method, system, medium and device for upgrading electro-hydraulic valve based on CAN network
CN118677970A (en)*2024-06-262024-09-20合众新能源汽车股份有限公司CAN protocol analysis method, system, equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109976767A (en)*2017-12-272019-07-05深圳市优必选科技有限公司 Software burning method and device
CN114422289A (en)*2022-01-112022-04-29国网电力科学研究院有限公司Transmission method and device for CAN (controller area network) message of electric vehicle
CN117221310A (en)*2023-09-052023-12-12佳源科技股份有限公司File transmission method and device based on multifunctional electric energy meter communication protocol
CN118642739A (en)*2024-06-142024-09-13江苏汇智高端工程机械创新中心有限公司 A method, system, medium and device for upgrading electro-hydraulic valve based on CAN network
CN118677970A (en)*2024-06-262024-09-20合众新能源汽车股份有限公司CAN protocol analysis method, system, equipment and medium

Similar Documents

PublicationPublication DateTitle
US11275530B2 (en)Method, system, and related device for NAS data access
WO2021052374A1 (en)Network congestion control method, node, system and storage medium
US20200250129A1 (en)Rdma data sending and receiving methods, electronic device, and readable storage medium
WO2014135038A1 (en)Packet transmission method and device based on pcie bus
CN114860437B (en)Data acquisition method, edge computing host and computer readable storage medium
CN112019440B (en)CAN bus multicast method based on identifier multiplexing
CN106484652A (en)A kind of many queue communication method and system based on NTB hardware
WO2022017454A1 (en)Message processing method, network device and related device
CN116828346A (en)Ammeter data proxy reading method and device, electronic equipment and storage medium
WO2021036189A1 (en)Rdma data sending and receiving methods, electronic device and readable storage medium
CN113163028B (en)Service data transmission method, device and system
CN119814774A (en)File transmission method, equipment and storage medium based on CAN protocol
CN106549845A (en)A kind of communication means and system based on NTB hardware
CN119814773A (en) Universal data transmission method, device and storage medium for Internet of Things
CN118714202A (en) A method, system, device and storage medium for communication protocol data conversion
CN119835266A (en) File transmission method, device and storage medium based on Modbus protocol
CN113993184A (en)Network selection method, network access method and related node equipment
CN117376300A (en)Message all-channel sending method and device, electronic equipment and storage medium
CN115865851A (en)Communication controller, vehicle, and communication control method
CN116418646A (en)Method, apparatus, device and computer readable storage medium for transmitting data
CN114390096A (en) A method, device and device for data transmission based on NB-IoT
CN103929404B (en)Method for analyzing HTTP chunked code data
CN116320079A (en)Message transmission method, device, electronic equipment and storage medium
CN115174311B (en)Method, system, equipment and medium for packaging virtual local area network data packet
CN119052179A (en)Data processing method, system and equipment for industrial Internet of things gateway

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp