A file downloading method based on single chip microcomputer, single chip microcomputer and file downloading system based on single chip microcomputer

By segmenting the file to be downloaded and re-downloading the failed file segment, the failure problem caused by the microcontroller due to network abnormalities when downloading the file is solved, which improves the download success rate and reduces cost and complexity.

CN119766803APending Publication Date: 2025-04-04JIANGXI XINGTAI TECH INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411927760.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In the Internet of Things environment, the microcontroller fails to download due to network abnormalities or signal instability when downloading files. The existing technology requires highly optimized network algorithms and high-performance hardware to improve download success rate, which increases cost and design complexity.

Method used

By segmenting the files to be downloaded and re-downloading when each file segment fails to download until all file segments are downloaded, the preset download start address and download completion address is avoided.

Benefits of technology

Without the need for highly optimized network algorithms and high-performance microcontroller hardware, the success rate of microcontroller file download is improved, and the cost and design complexity is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766803A_ABST
    Figure CN119766803A_ABST
Patent Text Reader

Abstract

The present invention discloses a file download method based on a single-chip microcomputer, a single-chip microcomputer and a file download system based on a single-chip microcomputer. The method comprises: first obtaining a file to be downloaded; then segmenting the file to be downloaded to obtain a plurality of file segments; finally, for each file segment, downloading the current file segment from a server to a corresponding download start address, and re-downloading when the current file segment fails to be downloaded, until all file segments are downloaded; wherein the download start address corresponding to the initial file segment is a preset download start address, and the download start address corresponding to the non-initial file segment is a download completion address of the previous file segment. By implementing the present invention, the success rate of downloading files by the single-chip microcomputer can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of signal acquisition, and in particular to a file downloading method based on a single-chip microcomputer, a single-chip microcomputer, and a file downloading system based on a single-chip microcomputer. Background Art

[0002] With the continuous development of the Internet of Things, there is an increasing demand for microcontroller devices to download files from servers. However, due to the complexity and uncertainty of the network environment, especially wireless networks, network anomalies or unstable signals often occur during the file download process, resulting in file download failures.

[0003] Existing technical solutions improve the success rate of MCU downloads by optimizing network algorithms, increasing network stability or adaptability, and automatically adjusting network parameters such as channel bandwidth, transmission power, and data transmission rate according to the actual environment. However, MCUs usually have low computing power and memory limitations. Therefore, the implementation of complex network algorithms may exceed the performance range of the MCU, resulting in the need to select higher performance hardware, which in turn increases the cost of the MCU and the complexity of the design. Summary of the invention

[0004] The invention provides a file downloading method based on a single-chip microcomputer, a single-chip microcomputer and a file downloading system based on a single-chip microcomputer, which can improve the success rate of downloading files by the single-chip microcomputer.

[0005] An embodiment of the present invention provides a file downloading method based on a single chip microcomputer, comprising:

[0006] Get the file to be downloaded;

[0007] Segment the file to be downloaded to obtain several file segments;

[0008] For each file segment, the current file segment is downloaded from the server to the corresponding download start address, and when the current file segment fails to be downloaded, it is downloaded again until all file segments are downloaded; among which, the download start address corresponding to the initial file segment is the preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment.

[0009] Furthermore, the above-mentioned obtaining of the file to be downloaded includes:

[0010] Obtain the storage path and file name of the file to be downloaded in the above server;

[0011] According to the storage path and the file name, the file to be downloaded is determined from the server.

[0012] Furthermore, before obtaining the file to be downloaded, the following steps are also included:

[0013] Get the server IP address and server port number of the server where the file to be downloaded is located;

[0014] A communication connection with the server is established based on the server IP address and the server port number.

[0015] Furthermore, the file to be downloaded is segmented to obtain several file segments, including:

[0016] The file to be downloaded is segmented according to a preset data length to obtain a plurality of file segments to be downloaded.

[0017] Furthermore, for each file segment, downloading the current file segment from the server to the corresponding download start address, and re-downloading the current file segment when downloading fails, includes:

[0018] Get the current download duration of the current file segment;

[0019] The current download duration is compared with the preset download duration. When the current download duration is greater than the preset download duration, it is determined that the download of the current file segment has failed, and the current file segment is downloaded again.

[0020] Furthermore, the above-mentioned determination that the download of the current file segment fails and re-downloading the current file segment includes:

[0021] Re-establishing the communication connection with the above server;

[0022] From the above server, the file segment that failed to be downloaded is re-downloaded to the corresponding download start address.

[0023] Furthermore, whether all file segments have been downloaded is determined by:

[0024] According to the storage path and file name, the total file data volume of the file to be downloaded is obtained;

[0025] After each file segment is downloaded, the amount of data currently downloaded of the file segment is obtained;

[0026] Calculate the sum of the current download data and the download data of all previously downloaded file segments to obtain the cumulative download data volume;

[0027] When the cumulative amount of downloaded data is not less than the total file data amount, it is determined that all file segments have been downloaded;

[0028] When the accumulated downloaded data volume is less than the total file data volume, the download of the next file segment continues.

[0029] Based on the above method embodiment, the present invention provides a single chip microcomputer;

[0030] The above-mentioned single chip microcomputer is used to execute the file downloading method based on single chip microcomputer mentioned above in any embodiment of the present invention.

[0031] Based on the above method embodiment, the present invention provides a corresponding device embodiment;

[0032] The present invention provides a file downloading system based on a single chip microcomputer, comprising:

[0033] MCU and server;

[0034] The server is used to determine the file to be downloaded and send a download instruction of the file to be downloaded to the microcontroller;

[0035] The above-mentioned single chip microcomputer is used to obtain the file to be downloaded after receiving the above-mentioned download instruction; segment the file to be downloaded to obtain a plurality of file segments; for each file segment, download the current file segment from the server to the corresponding download start address, and re-download when the current file segment fails to be downloaded until all file segments are downloaded; wherein, the download start address corresponding to the initial file segment is the preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment.

[0036] Furthermore, the above single chip microcomputer is also used for:

[0037] Get the server IP address and server port number of the server where the file to be downloaded is located;

[0038] A communication connection with the server is established based on the server IP address and the server port number.

[0039] The embodiments of the present invention have the following beneficial effects:

[0040] The present invention provides a file download method based on a single-chip microcomputer, a single-chip microcomputer, and a file download system based on a single-chip microcomputer. The above method includes: obtaining a file to be downloaded; segmenting the file to be downloaded to obtain a plurality of file segments; for each file segment, downloading the current file segment from a server to the corresponding download start address, and re-downloading when the current file segment fails to be downloaded, until all file segments are downloaded; wherein, the download start address corresponding to the initial file segment is a preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment. Therefore, the present invention uses a segmented download method to download files from a server, and records the download completion address after each file segment is downloaded as the download start address of the next file segment. Even if a certain file segment fails to be downloaded, the file segment that failed to be downloaded can be re-downloaded without re-downloading the entire file. Therefore, in the entire download process, without requiring a specific highly optimized network algorithm or specific high-performance single-chip microcomputer hardware, the success rate of single-chip microcomputer file download is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 The present invention is a flowchart of a method for downloading files based on a single chip microcomputer provided in accordance with an embodiment of the present invention.

[0042] Figure 2 The present invention is a schematic diagram of a file download system based on a single chip microcomputer according to an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the present invention. 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 creative work are within the scope of protection of the present invention.

[0044] like Figure 1 As shown, an embodiment of the present invention provides a file downloading method based on a single chip microcomputer, comprising:

[0045] Step S101: Obtain the file to be downloaded;

[0046] In a preferred embodiment, the above-mentioned obtaining the file to be downloaded includes:

[0047] Obtain the storage path and file name of the file to be downloaded in the above server;

[0048] According to the storage path and the file name, the file to be downloaded is determined from the server.

[0049] Specifically, the storage path and file name are sent to the single-chip microcomputer through the communication protocol by the server after the file to be downloaded is selected. After the single-chip microcomputer receives the storage path and file name, it determines the file to be downloaded.

[0050] In this preferred embodiment, the specific file to be downloaded is determined by the storage path and file name of the file to be downloaded.

[0051] In another preferred embodiment, before obtaining the file to be downloaded, the method further includes:

[0052] Get the server IP address and server port number of the server where the file to be downloaded is located;

[0053] A communication connection with the server is established based on the server IP address and the server port number.

[0054] Specifically, when the server and the single-chip microcomputer are working normally, the single-chip microcomputer first obtains the server IP address and the server port number, and then uses TCP to create a socket to connect to the server.

[0055] In this preferred embodiment, a connection is established with the corresponding server via the server IP address and the server port number.

[0056] Step S102: segment the file to be downloaded to obtain a number of file segments;

[0057] In a preferred embodiment, the file to be downloaded is segmented to obtain several file segments, including:

[0058] The file to be downloaded is segmented according to a preset data length to obtain a plurality of file segments to be downloaded.

[0059] Specifically, the preset data length is the data length agreed upon by the single chip microcomputer and the server (eg, 4K bytes).

[0060] In this preferred embodiment, the file to be downloaded is divided into data segments according to the data length agreed upon with the server, thereby obtaining a plurality of file segments.

[0061] Step S103: For each file segment, the current file segment is downloaded from the server to the corresponding download start address, and when the current file segment fails to be downloaded, it is downloaded again until all file segments are downloaded; wherein, the download start address corresponding to the initial file segment is the preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment.

[0062] Specifically, when the file data volume of the file to be downloaded is relatively large, the download time is longer. If the network is unstable during the download, the file download will fail.

[0063] Specifically, the current file segment is downloaded from the server to the corresponding download start address through the acquired storage path and file name. The download start address of each non-initial file segment is located at the position where the previous file segment was successfully downloaded.

[0064] In a preferred embodiment, for each file segment, downloading the current file segment from the server to the corresponding download start address, and re-downloading the current file segment when the download fails, includes:

[0065] Get the current download duration of the current file segment;

[0066] The current download duration is compared with the preset download duration. When the current download duration is greater than the preset download duration, it is determined that the download of the current file segment has failed, and the current file segment is downloaded again.

[0067] Specifically, each time a file segment is downloaded, the download duration of the current file segment is recorded, and the current download duration is compared with the preset download duration. If the preset download duration is exceeded, it proves that the download of the current file segment has timed out and the file segment download has failed, and then the current file segment is downloaded again.

[0068] In this preferred embodiment, whether the download of the current file segment fails is determined by comparing the download duration of the current file segment with the preset download duration.

[0069] In another preferred embodiment, the above-mentioned determination that the download of the current file segment fails and re-downloading the current file segment includes:

[0070] Re-establishing the communication connection with the above server;

[0071] From the above server, the file segment that failed to be downloaded is re-downloaded to the corresponding download start address.

[0072] Specifically, a socket is created using TCP according to the server IP address and the server port number, a connection with the server is established, and the failed file segment is downloaded from the server again to the download start address corresponding to the file segment.

[0073] In this preferred embodiment, after determining that the current file segment fails to be downloaded, the communication connection with the server is re-established, and then the file segment that failed to be downloaded is re-downloaded from the server to the corresponding download start address.

[0074] In another preferred embodiment, whether all file segments have been downloaded is determined in the following manner:

[0075] According to the storage path and file name, the total file data volume of the file to be downloaded is obtained;

[0076] After each file segment is downloaded, the amount of data currently downloaded of the file segment is obtained;

[0077] Calculate the sum of the current download data and the download data of all previously downloaded file segments to obtain the cumulative download data volume;

[0078] When the cumulative amount of downloaded data is not less than the total file data amount, it is determined that all file segments have been downloaded;

[0079] When the accumulated downloaded data volume is less than the total file data volume, the download of the next file segment continues.

[0080] Specifically, first determine the total file data size of the file to be downloaded based on the storage path and file name. After each file segment is successfully downloaded, record the data size of the current successfully downloaded file segment. Then add the current data size to all previously recorded successfully downloaded data sizes to get the current cumulative downloaded data size. Then compare the current cumulative downloaded data size with the total file data size. When the current cumulative downloaded data size is not less than the total file data size, it indicates that the download of the file to be downloaded is complete, and close the connection between the single-chip microcomputer and the server. When the current cumulative downloaded data size is less than the total file data size, it indicates that the download of the file to be downloaded is not complete, and continue to download.

[0081] In this preferred embodiment, by comparing the current cumulative download data volume with the total file data volume, it is determined whether the download of the file to be downloaded is complete.

[0082] Based on the above method embodiment, the present invention provides a corresponding single chip microcomputer.

[0083] The above-mentioned single chip microcomputer is used to execute the file downloading method based on single chip microcomputer mentioned above in any embodiment of the present invention.

[0084] Based on the above method embodiment, the present invention provides a corresponding device embodiment.

[0085] like Figure 2 As shown, an embodiment of the present invention provides a file download system based on a single chip microcomputer, comprising:

[0086] MCU and server;

[0087] The server is used to determine the file to be downloaded and send a download instruction of the file to be downloaded to the microcontroller;

[0088] The above-mentioned single chip microcomputer is used to obtain the file to be downloaded after receiving the above-mentioned download instruction; segment the file to be downloaded to obtain a plurality of file segments; for each file segment, download the current file segment from the server to the corresponding download start address, and re-download when the current file segment fails to be downloaded until all file segments are downloaded; wherein, the download start address corresponding to the initial file segment is the preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment.

[0089] In a preferred embodiment, the above-mentioned single chip microcomputer is also used for:

[0090] Get the server IP address and server port number of the server where the file to be downloaded is located;

[0091] A communication connection with the server is established based on the server IP address and the server port number.

[0092] It should be noted that the device embodiments described above are merely schematic, wherein the modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without creative work. The above schematic diagram is merely an example of a file download system based on a single-chip microcomputer, and does not constitute a limitation on a file download system based on a single-chip microcomputer, and may include more or fewer components than shown in the figure, or a combination of certain components, or different components.

[0093] Compared with the prior art, by implementing the above-mentioned embodiments of the present invention, the success rate of downloading files by a single chip microcomputer can be improved.

[0094] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A file downloading method based on a single chip microcomputer, characterized in that: include: Get the file to be downloaded; Segment the file to be downloaded to obtain several file segments; For each file segment, the current file segment is downloaded from the server to the corresponding download start address, and when the current file segment fails to be downloaded, it is downloaded again until all file segments are downloaded; among which, the download start address corresponding to the initial file segment is the preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment.

2. A file downloading method based on a single chip microcomputer according to claim 1, characterized in that: The step of obtaining the file to be downloaded includes: Obtain the storage path and file name of the file to be downloaded in the server; According to the storage path and the file name, a file to be downloaded is determined from the server.

3. A file downloading method based on a single chip microcomputer according to claim 2, characterized in that: Before getting the file to be downloaded, it also includes: Get the server IP address and server port number of the server where the file to be downloaded is located; A communication connection with the server is established according to the server IP address and the server port number.

4. A file downloading method based on a single chip microcomputer according to claim 3, characterized in that: The file to be downloaded is segmented to obtain a number of file segments, including: The file to be downloaded is segmented according to a preset data length to obtain a plurality of file segments to be downloaded.

5. A file downloading method based on single chip microcomputer according to claim 4, characterized in that: For each file segment, downloading the current file segment from the server to the corresponding download start address, and re-downloading the current file segment when downloading fails, including: Get the current download duration of the current file segment; The current download duration is compared with the preset download duration. When the current download duration is greater than the preset download duration, it is determined that the download of the current file segment has failed, and the current file segment is downloaded again.

6. A file downloading method based on a single chip microcomputer according to claim 5, characterized in that: The step of determining that the download of the current file segment fails and re-downloading the current file segment includes: re-establishing a communication connection with the server; The file segment that has failed to be downloaded is re-downloaded from the server to the corresponding download start address.

7. A file downloading method based on a single chip microcomputer according to claim 6, characterized in that: Determine whether all file segments have been downloaded by: According to the storage path and the file name, the total file data volume of the file to be downloaded is obtained; After each file segment is downloaded, the amount of data currently downloaded of the file segment is obtained; Calculate the sum of the current download data and the download data of all previously downloaded file segments to obtain the cumulative download data volume; When the accumulated downloaded data volume is not less than the total file data volume, determining that all file segments have been downloaded; When the accumulated downloaded data volume is less than the total file data volume, the downloading of the next file segment continues.

8. A single chip microcomputer, characterized in that: The single chip microcomputer is used to execute the single chip microcomputer-based file downloading method as described in claims 1-7.

9. A file download system based on a single chip microcomputer, characterized in that: include: MCU and server; The server is used to determine the file to be downloaded and send a download instruction of the file to be downloaded to the single chip microcomputer; The single chip microcomputer is used to obtain the file to be downloaded after receiving the download instruction; segment the file to be downloaded to obtain a plurality of file segments; for each file segment, download the current file segment from the server to the corresponding download start address, and re-download when the download of the current file segment fails until all file segments are downloaded; wherein the download start address corresponding to the initial file segment is a preset download start address, and the download start address corresponding to the non-initial file segment is the download completion address of the previous file segment.

10. A file download system based on a single chip microcomputer according to claim 9, characterized in that: The single chip microcomputer is also used for: Get the server IP address and server port number of the server where the file to be downloaded is located; A communication connection with the server is established according to the server IP address and the server port number.