Method and device for acquiring and transmitting text file data of embedded system

By defining a character array in an embedded system to store text file data and using MD5 verification code, the complexity and cost problems of embedded systems when processing and transmitting text files are solved, and efficient data transmission and system stability are achieved. .

CN119066031APending Publication Date: 2024-12-03BEIJING INST OF SPACE LAUNCH TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411182304.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

When processing and transferring text file data, embedded systems require special file systems and storage media, which increases design complexity and cost.

Method used

By defining a character array with a length greater than the length of the text file, the text file data is converted into ASCII code and packaged and uploaded when receiving the host computer instruction. The MD5 verification code is used to ensure data integrity, avoiding file reading and writing operate.

Benefits of technology

It simplifies hardware design and applications, reduces costs, realizes efficient transmission of text file data in embedded systems, overcomes dependence on file management systems and storage media, and improves the stability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066031A_ABST
    Figure CN119066031A_ABST
Patent Text Reader

Abstract

The invention provides a method and a device for acquiring and transmitting text file data of an embedded system. The method comprises the following steps: determining the length of a text file used for storing embedded system data, and defining a character array of which the length is greater than that of the text file; converting character data of the text file into an ASCII (American Standard Code for Information Interchange) code, and assigning the ASCII code to the character array byte by byte; and when a data uploading instruction issued by an upper computer is received, packaging the character array and uploading the packaged character array to the upper computer. According to the method, the character array stored in the memory is defined to store the text file data, which is equivalent to storing a text file on the memory, so that the file reading operation is omitted, and the dependence of embedded software on a file management system and a storage medium is overcome; the method has the advantages of simple hardware system, small application program design scale, low cost and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of text data management, and in particular relates to a method and device for acquiring and transmitting text file data of an embedded system. Background Art

[0002] At present, embedded system devices based on ARM chips have been widely used in various fields. In some cases, the equipment needs to collect external sensor data, calculate measurement data, and send these measurement data to the host computer in the form of text file data. The embedded system connection diagram is shown in the attached figure. Figure 2 As shown. The creation, reading and writing of text files require a special file system for management, and a special storage medium is also required to save the files, which increases the complexity of application design, hardware design complexity and product cost. Therefore, in order to simplify the software and hardware design and reduce the cost, the present invention proposes a method and device for acquiring and transmitting text file data in an embedded system. Summary of the invention

[0003] In order to solve the above problems existing in the prior art, the present invention provides a method and device for acquiring and transmitting text file data of an embedded system.

[0004] In order to achieve the above object, the present invention adopts the following technical solutions.

[0005] In a first aspect, the present invention provides a method for acquiring and transmitting text file data of an embedded system, comprising the following steps:

[0006] Determine the length of a text file used to store embedded system data, and define a character array having a length greater than the length of the text file;

[0007] Convert the character data of the text file into ASCII code, and assign the ASCII code to the character array byte by byte;

[0008] When a data upload instruction is received from the host computer, the character array is packaged and uploaded to the host computer.

[0009] Furthermore, UltraEdit software is used to convert the character data of the text file into ASCII code.

[0010] Furthermore, the text file includes fixed data and variable data, the fixed data is fixed data, including name, meaning and comments; the variable data is frequently updated data, including test data and calculation results; the length of the text file is equal to the sum of the number of bytes of the fixed data and the number of bytes of the variable data.

[0011] Furthermore, the length of the character array is N+1 bytes, wherein N bytes are used to store the fixed data and the changing data of the text file, and the last byte is reserved.

[0012] Furthermore, the method for updating the value of the changed data of the text file in the character array includes:

[0013] Initialize the corresponding bytes of the character array storing the changed data to 0x00;

[0014] When the data update of the embedded system is completed, the updated data is converted into ASCII code, and the ASCII code is assigned byte by byte to the corresponding byte of the updated data;

[0015] The MD5 checksum of the N bytes of data in the character array after the data is updated is calculated, and the MD5 checksum before the data is updated is replaced by the MD5 checksum after the data is updated.

[0016] Furthermore, the method for the embedded system to upload the character array to the host computer includes:

[0017] Monitor in real time whether the data upload command issued by the host computer is received; if received, go to the next step;

[0018] Pack the character array and upload it to the host computer, and monitor in real time whether the MD5 checksum returned by the host computer is received; if received, go to the next step;

[0019] Compare the returned MD5 checksum with the MD5 checksum of the uploaded data to see if they are equal. If they are equal, send a file sending success message to the host computer; otherwise, send a file sending failure message to the host computer.

[0020] In a second aspect, the present invention provides a device for acquiring and transmitting text file data of an embedded system, comprising:

[0021] An array definition module, used to determine the length of a text file used to store embedded system data, and define a character array having a length greater than the length of the text file;

[0022] An array assignment module, used for converting the character data of the text file into ASCII code, and assigning the ASCII code to the character array byte by byte;

[0023] The array uploading module is used to pack the character array and upload it to the host computer when receiving the data upload instruction issued by the host computer.

[0024] Furthermore, the text file includes fixed data and variable data, the fixed data is fixed data, including name, meaning and comments; the variable data is frequently updated data, including test data and calculation results; the length of the text file is equal to the sum of the number of bytes of the fixed data and the number of bytes of the variable data.

[0025] Furthermore, the length of the character array is N+1 bytes, wherein N bytes are used to store the fixed data and the changing data of the text file, and the last byte is reserved.

[0026] Furthermore, the method for updating the value of the changed data of the text file in the character array includes:

[0027] Initialize the corresponding bytes of the character array storing the changed data to 0x00;

[0028] When the data update of the embedded system is completed, the updated data is converted into ASCII code, and the ASCII code is assigned byte by byte to the corresponding byte of the updated data;

[0029] The MD5 checksum of the N bytes of data in the character array after the data is updated is calculated, and the MD5 checksum before the data is updated is replaced by the MD5 checksum after the data is updated.

[0030] Compared with the prior art, the present invention has the following beneficial effects.

[0031] The present invention determines the length of a text file for storing embedded system data, defines a character array whose length is greater than the length of the text file, converts the character data of the text file into ASCII code, and assigns the ASCII code to the character array byte by byte. When a data upload instruction issued by a host computer is received, the character array is packaged and uploaded to the host computer, thereby realizing the acquisition and transmission of text file data of the embedded system. The present invention stores text file data by defining a character array stored in a memory, which is equivalent to storing a text file on a memory, eliminating the file reading operation, and the change of the character array data is equivalent to the change writing operation of the file in the storage medium. The present invention overcomes the dependence of embedded software on a file management system and a storage medium. It has the advantages of simple hardware system, small application design scale, low cost, etc., and the overall operation of the system is efficient, stable and reliable. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 The present invention is a flowchart of a method for acquiring and transmitting text file data in an embedded system according to an embodiment of the present invention.

[0033] Figure 2 This is a connection diagram of an embedded system based on ARM chip.

[0034] Figure 3 FIG. 4 is a flow chart of another embodiment of the present invention.

[0035] Figure 4 The present invention is a block diagram of a device for acquiring and transmitting text file data of an embedded system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solution and advantages of the present invention clearer and more understandable, the present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0037] Figure 1 This is a flow chart of a method for acquiring and transmitting text file data of an embedded system according to an embodiment of the present invention, comprising the following steps:

[0038] Step 101, determining the length of a text file for storing embedded system data, and defining a character array whose length is greater than the length of the text file;

[0039] Step 102, converting the character data of the text file into ASCII codes, and assigning the ASCII codes byte by byte to the character array;

[0040] Step 103, when receiving a data upload instruction from the host computer, the character array is packaged and uploaded to the host computer.

[0041] In this embodiment, step 101 is mainly used to define a character array for storing text file data. The text file is used to store embedded system data. Figure 2 As shown. In some application scenarios, the external sensor data and measurement and calculation data collected when the embedded system is working need to be sent to the host computer in the form of text file data transmission. The creation, reading and writing of the text file require a special file system for management, and a special storage medium is also required to save the file, which increases the complexity of application design, hardware design complexity and product cost. To this end, this embodiment defines a character array stored in the memory to store the text file, which can avoid the file reading operation. At the same time, the change of the character combination data is equivalent to the change and write operation of the file in the storage medium, which can overcome the embedded software's dependence on the file management system and storage medium. This embodiment first determines the length of the text file, and then defines a character array whose length is greater than the length of the text file.

[0042] In this embodiment, step 102 is mainly used to assign the text file to the character array byte by byte. In this embodiment, the character data of the text file is first converted into ASCII code, and then the ASCII code is assigned to the character array byte by byte.

[0043] In this embodiment, step 103 is mainly used to upload the character array to the host computer. The embedded system monitors the instructions issued by the host computer in real time. When receiving the data upload instruction issued by the host computer, the character array is packaged and uploaded to the host computer. Array data packaging is usually a process of compressing it into a compressed package using compression software using the compression principle. This operation can significantly reduce the size of the data, thereby saving storage space and transmission time.

[0044] As an optional embodiment, UltraEdit software is used to convert the character data of the text file into ASCII code.

[0045] This embodiment provides a technical solution for quickly converting the character data of the text file into ASCII code. UltraEdit is a powerful text editor that can edit text, hexadecimal, and ASCII codes. It can completely replace Notepad, has built-in English word checking, C++ and VB command highlighting, can edit multiple files at the same time, and the speed will not be slow even if a large file is opened.

[0046] As an optional embodiment, the text file includes fixed data and variable data, the fixed data is fixed data, including name, meaning and comments; the variable data is frequently updated data, including test data and calculation results; the length of the text file is equal to the sum of the number of bytes of the fixed data and the number of bytes of the variable data.

[0047] In this embodiment, the data of the text file is divided into fixed data and variable data. Fixed data refers to fixed data, such as name, meaning and comments, etc.; variable data refers to frequently updated data, such as observation data and calculation results output by sensors, etc. The text file can be edited by using UltraEdit software to determine the fixed data such as name and comments, and the variable data such as test data and calculation results.

[0048] As an optional embodiment, the length of the character array is N+1 bytes, wherein N bytes are used to store fixed data and changing data of the text file, and the last byte is backed up.

[0049] This embodiment provides a method for setting the length of the character array. In this embodiment, the character array is used not only to store the text file data, but also to store an MD5 checksum. If the length of the character array is recorded as N+1 bytes, then N bytes are used to store the text file data (including fixed data and variable data), and the last byte is reserved.

[0050] MD5 is the abbreviation of Message Digest Algorithm 5, which is a widely used hash algorithm for file verification and integrity check. By calculating the MD5 hash value of a file, a unique identifier can be generated, which can also be called the "digital fingerprint" of the file. When the file is modified or damaged during transmission or storage, the MD5 code will change. By comparing the MD5 values ​​before and after verification, the consistency of the file before and after transmission or storage can be verified to ensure that the file has not been accidentally tampered with or damaged.

[0051] As an optional embodiment, the method for updating the value of the changed data of the text file in the character array includes:

[0052] Initialize the corresponding bytes of the character array storing the changed data to 0x00;

[0053] When the data update of the embedded system is completed, the updated data is converted into ASCII code, and the ASCII code is assigned byte by byte to the corresponding byte of the updated data;

[0054] The MD5 checksum of the N bytes of data in the character array after the data is updated is calculated, and the MD5 checksum before the data is updated is replaced by the MD5 checksum after the data is updated.

[0055] This embodiment provides a technical solution for updating the assignment of changing data in the character array. As mentioned above, the text file includes both fixed data and changing data. Since the fixed data generally does not need to be modified, it is generally no longer necessary to pay attention to it after completing its assignment in the character array. Changing data is constantly changing data, especially data output by sensors. The values ​​at almost every data acquisition moment are different. Therefore, it is necessary to frequently update the bytes (position unchanged) storing the changing data in the character array. The specific updating method includes: first initializing, initializing the corresponding bytes of the character array storing the changing data to 0x00; if the data update of the embedded system has been completed, converting the updated data into ASCII code, and assigning the ASCII code byte by byte to the corresponding bytes of the updated data; since the data in the character array has changed, it is necessary to recalculate the MD5 checksum of the character array after the update, and replace the MD5 checksum before the data update with the MD5 checksum after the data update.

[0056] As an optional embodiment, the method for the embedded system to upload the character array to the host computer includes:

[0057] Monitor in real time whether the data upload command issued by the host computer is received; if received, go to the next step;

[0058] Pack the character array and upload it to the host computer, and monitor in real time whether the MD5 checksum returned by the host computer is received; if received, go to the next step;

[0059] Compare the returned MD5 checksum with the MD5 checksum of the uploaded data to see if they are equal. If they are equal, send a file sending success message to the host computer; otherwise, send a file sending failure message to the host computer.

[0060] This embodiment provides a technical solution for an embedded system to upload the character array to a host computer. In this embodiment, the embedded system monitors the instructions issued by the host computer in real time. If a data upload instruction issued by the host computer is received, the character array is packaged and uploaded to the host computer. After the host computer receives the uploaded data, it parses the data bytes in the character array, calculates the MD5 checksum of the received data, and then returns the MD5 checksum to the embedded system; the embedded system compares the MD5 checksum returned by the host computer with the MD5 checksum when the data is uploaded. If the two are equal, the file is considered to be sent successfully; otherwise, the file is considered to have failed to be sent; finally, the information on the success or failure of the file sending is sent to the host computer.

[0061] Figure 4 This is a schematic diagram of the composition of a device for acquiring and transmitting text file data of an embedded system according to an embodiment of the present invention, the device comprising:

[0062] An array definition module 11 is used to determine the length of a text file used to store embedded system data and define a character array whose length is greater than the length of the text file;

[0063] An array assignment module 12, used for converting the character data of the text file into ASCII code, and assigning the ASCII code to the character array byte by byte;

[0064] The array uploading module 13 is used for packaging the character array and uploading it to the host computer when receiving a data uploading instruction from the host computer.

[0065] The device of this embodiment can be used to perform Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be described in detail here. The same is true for the following embodiments, which will not be described in detail.

[0066] As an optional embodiment, the text file includes fixed data and variable data, the fixed data is fixed data, including name, meaning and comments; the variable data is frequently updated data, including test data and calculation results; the length of the text file is equal to the sum of the number of bytes of the fixed data and the number of bytes of the variable data.

[0067] As an optional embodiment, the length of the character array is N+1 bytes, wherein N bytes are used to store fixed data and variable data of the text file, and the last byte is reserved.

[0068] As an optional embodiment, the method for updating the value of the changed data of the text file in the character array includes:

[0069] Initialize the corresponding bytes of the character array storing the changed data to 0x00;

[0070] When the data update of the embedded system is completed, the updated data is converted into ASCII code, and the ASCII code is assigned byte by byte to the corresponding byte of the updated data;

[0071] The MD5 checksum of the N bytes of data in the character array after the data is updated is calculated, and the MD5 checksum before the data is updated is replaced by the MD5 checksum after the data is updated.

[0072] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A method for acquiring and transmitting text file data of an embedded system, characterized in that: The following steps are involved: Determine the length of a text file used to store embedded system data, and define a character array having a length greater than the length of the text file; Convert the character data of the text file into ASCII code, and assign the ASCII code to the character array byte by byte; When a data upload instruction is received from the host computer, the character array is packaged and uploaded to the host computer.

2. The method for acquiring and transmitting text file data of an embedded system according to claim 1, characterized in that: The character data of the text file is converted into ASCII code using UltraEdit software.

3. The method for acquiring and transmitting text file data of an embedded system according to claim 1, characterized in that: The text file includes fixed data and variable data. The fixed data is fixed data, including name, meaning and comments; the variable data is frequently updated data, including test data and calculation results; the length of the text file is equal to the sum of the number of bytes of the fixed data and the number of bytes of the variable data.

4. The method for acquiring and transmitting text file data of an embedded system according to claim 3, characterized in that: The length of the character array is N+1 bytes, wherein N bytes are used to store the fixed data and the changing data of the text file, and the last byte is reserved.

5. The method for acquiring and transmitting text file data of an embedded system according to claim 4, characterized in that: The method for updating the assignment of the changed data of the text file in the character array comprises: Initialize the corresponding bytes of the character array storing the changed data to 0x00; When the data update of the embedded system is completed, the updated data is converted into ASCII code, and the ASCII code is assigned byte by byte to the corresponding byte of the updated data; The MD5 checksum of the N bytes of data in the character array after the data is updated is calculated, and the MD5 checksum before the data is updated is replaced by the MD5 checksum after the data is updated.

6. The method for acquiring and transmitting text file data of an embedded system according to claim 5, characterized in that: The method for the embedded system to upload the character array to the host computer includes: Monitor in real time whether the data upload command issued by the host computer is received; if received, go to the next step; Pack the character array and upload it to the host computer, and monitor in real time whether the MD5 checksum returned by the host computer is received; if received, go to the next step; Compare the returned MD5 checksum with the MD5 checksum of the uploaded data to see if they are equal. If they are equal, send a file sending success message to the host computer; otherwise, send a file sending failure message to the host computer.

7. A device for acquiring and transmitting text file data of an embedded system, characterized in that: include: An array definition module, used to determine the length of a text file used to store embedded system data, and define a character array having a length greater than the length of the text file; An array assignment module, used for converting the character data of the text file into ASCII code, and assigning the ASCII code to the character array byte by byte; The array uploading module is used to pack the character array and upload it to the host computer when receiving the data upload instruction issued by the host computer.

8. The device for acquiring and transmitting text file data of an embedded system according to claim 7, characterized in that: The text file includes fixed data and variable data. The fixed data is fixed data, including name, meaning and comments; the variable data is frequently updated data, including test data and calculation results; the length of the text file is equal to the sum of the number of bytes of the fixed data and the number of bytes of the variable data.

9. The device for acquiring and transmitting text file data of an embedded system according to claim 8, characterized in that: The length of the character array is N+1 bytes, wherein N bytes are used to store the fixed data and the changing data of the text file, and the last byte is reserved.

10. The device for acquiring and transmitting text file data of an embedded system according to claim 9, characterized in that: The method for updating the assignment of the changed data of the text file in the character array comprises: Initialize the corresponding bytes of the character array storing the changed data to 0x00; When the data update of the embedded system is completed, the updated data is converted into ASCII code, and the ASCII code is assigned byte by byte to the corresponding byte of the updated data; The MD5 checksum of the N bytes of data in the character array after the data is updated is calculated, and the MD5 checksum before the data is updated is replaced by the MD5 checksum after the data is updated.