Data export methods, devices, equipment and storage media
By using global memory variables in devices such as microcontrollers to copy and convert data sectors, the problem of high disk storage space requirements in existing technologies is solved, achieving fast data export and cost savings.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAMEN MILESIGHT IOT CO LTD
- Filing Date
- 2023-10-30
- Publication Date
- 2026-06-30
AI Technical Summary
In existing technologies, data export methods require a large amount of disk storage space from storage devices such as microcontrollers, which increases hardware costs.
It establishes a connection with the target device via USB interface, uses global memory variables to copy the storage information of the first N sectors of the disk, converts the data sectors into document data, and dynamically exports them to the target device without the need for additional disk storage space expansion.
It enables the rapid export of data in document form without increasing disk storage space, saving hardware costs.
Smart Images

Figure CN117591010B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a data export method, apparatus, device and storage medium. Background Technology
[0002] In some industrial or commercial applications, data is collected and stored in real time using devices such as microcontrollers, and then exported after a certain period of time.
[0003] The common method for exporting data is for the microcontroller to pre-convert the data into a document format and store it. Then, it is connected to another device via a USB interface, and a USB flash drive is created on that device. By opening the USB flash drive in the file manager of the other device, the generated document can be directly copied to the other device.
[0004] Because documents take up a lot of space and their specifications and reading requirements are not fixed, current data export methods require a lot of disk storage space from storage devices such as microcontrollers, which leads to a corresponding increase in the hardware cost of related products. Summary of the Invention
[0005] To achieve the above objectives, this application provides a data export method, apparatus, device, and storage medium that can quickly export data from a storage device in document form to a target device without requiring additional disk storage space expansion, thus greatly saving hardware costs.
[0006] Firstly, this application provides a data export method, which includes:
[0007] S1. Establish a connection with the target device via USB interface, and sequentially copy the file system-related storage information in the first N sectors of the disk to the target device through a global memory variable, where N is a positive integer determined according to the type of the file system;
[0008] S2. In response to the completion of copying the stored information in the Nth sector, convert the data in the first data sector after the Nth sector into document data, and store the document data in the global memory variable;
[0009] S3. In response to a read request for the target document, copy the document data of the first data sector from the global memory variable to the target device, convert the data in the next data sector into document data, and then copy it to the target device through the global memory variable until the target document is exported.
[0010] In one possible implementation, step S1 includes:
[0011] S11. In response to the target device's request to read the disk, copy the storage information in the boot sector of the disk to the global memory variable;
[0012] S12. In response to copying the currently stored storage information in the global memory variable to the target device, copy the storage information in the next sector of the disk to the global memory variable, until the storage information in the first N sectors is copied.
[0013] In one possible implementation, step S2 includes:
[0014] S21. In response to the completion of copying the stored information in the Nth sector, disable USB interrupts;
[0015] S22. After converting the data in the first data sector into document data and storing it in the global memory variable, enable the USB interrupt.
[0016] In one possible implementation, step S3 includes:
[0017] S31. In response to a read request for the target document, after copying the document data of the first data sector from the global memory variable to the target device, the USB interrupt is turned off;
[0018] S32. After converting the data in the second data sector into document data and storing it in the global memory variable, enable the USB interrupt;
[0019] S33. After copying the document data of the second data sector from the global memory variable to the target device, disable the USB interrupt;
[0020] S34. Perform steps S32 and S33 sequentially on the data sectors after the second data sector until the document data of the Mth data sector is copied to the target device. Then, turn off the USB interrupt, and the export of the target document is complete. M is the number of data sectors occupied by the target document.
[0021] In one possible implementation, the global memory variable is located in memory, and the capacity of the global memory variable is greater than or equal to the capacity of the sector.
[0022] In one possible implementation, the data export method is applied to an electronic device, the electronic device including a USB interface, a processor, and a memory, the memory including the disk and RAM.
[0023] In one possible implementation, where the electronic device uses the FAT32 file system, N is 4.
[0024] In a second aspect, a data export apparatus is provided, which includes multiple functional modules for performing corresponding steps in the data export method provided in the first aspect.
[0025] Thirdly, a computing device is provided, comprising a memory and a processor, the memory storing at least one program that is executed by the processor to implement the data export method as provided in the first aspect.
[0026] Fourthly, a computer-readable storage medium is provided, wherein at least one program is stored therein, the at least one program being executed by a processor to implement the data export method as provided in the first aspect.
[0027] The technical solution provided in this application includes at least the following technical effects:
[0028] This application utilizes global memory variables to dynamically export documents according to the file system specifications. It eliminates the need for additional disk storage space to store the generated documents, enabling the rapid export of data from storage devices to target devices in document form, thus significantly reducing hardware costs. Attached Figure Description
[0029] Figure 1 This is a schematic diagram of the implementation environment of a data export method provided in an embodiment of this application;
[0030] Figure 2 This is a flowchart illustrating a data export method provided in an embodiment of this application;
[0031] Figure 3 This is a flowchart illustrating another data export method provided in an embodiment of this application;
[0032] Figure 4 This is a schematic diagram of a data export device provided in an embodiment of this application;
[0033] Figure 5 This is a schematic diagram of the hardware structure of a computing device provided in an embodiment of this application. Detailed Implementation
[0034] To further illustrate the various embodiments, this application provides accompanying drawings. These drawings are part of the disclosure of this application and are mainly used to illustrate the embodiments, and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementations and the advantages of this application. Components in the drawings are not drawn to scale, and similar component symbols are generally used to represent similar components. In this application, the term "at least one" means one or more, and the term "multiple" means two or more; for example, multiple sectors refer to two or more sectors.
[0035] This application will now be further described in conjunction with the accompanying drawings and specific embodiments.
[0036] The implementation environment involved in this application will be introduced below.
[0037] Figure 1 A schematic diagram illustrating the implementation environment of a data export method provided in this application. See also... Figure 1 Storage device 1 connects to target device 3 via Universal Serial Bus (USB) interface 2. Storage device 1 is used to store data and can be a microcontroller, a single-chip microcomputer, or other type of electronic device. Target device 3, such as a personal computer or tablet, is used to read data from storage device 1. Both storage device 1 and target device 3 have USB interfaces. In target device 3, storage device 1 is recognized as a USB mass storage device (or simply a USB flash drive).
[0038] USB is a serial bus standard and an input / output interface technology specification that is widely used in information and communication products such as personal computers and mobile devices.
[0039] The data export method provided in this application can be executed by the aforementioned storage device 1. The following is in conjunction with the above... Figure 1 The implementation environment shown will be used to provide a detailed description of the technical solution of this application. Figure 2 This is a flowchart illustrating a data export method provided in an embodiment of this application. (Refer to...) Figure 2 The technical solution provided in this application includes the following steps S1 to S3, which are executed by the storage device.
[0040] S1. Establish a connection with the target device via the USB interface, and sequentially copy the storage information in the first N sectors of the disk to the target device through a global memory variable. N is a positive integer determined according to the file system type of the storage device.
[0041] Global memory variables reside in memory, and their capacity is greater than or equal to the capacity of a sector.
[0042] In one possible implementation, step S1 includes:
[0043] S11. In response to a request from the target device to read the disk, copy the storage information in the boot sector of the disk to a global memory variable.
[0044] In this embodiment, the storage device employs USB mass storage technology, which by default reads data from the disk. The storage device uses a 32-bit File Allocation Table (FAT) file system to organize the data on the disk. The FAT32 system supports periodic fetching of data sector by sector. In this example, the global memory variable is denoted as ramdisk, and its capacity is set to the size of one sector; for example, the capacity of the global memory variable is 4 kilobytes (KB).
[0045] In this embodiment of the application, the FAT32 file system used stores file-related storage information in the boot sector and the next three sectors; therefore, N is set to 4. That is, the actual document-related data is stored starting from the fifth sector.
[0046] In this embodiment, when the storage device is connected to the target device via a USB interface, it is recognized as a mass storage device by the target device. The target device first requests to read the storage information in the 0th sector of the storage device's read / write head (i.e., the boot sector). The storage information in the boot sector includes information such as disk sector size, number of sectors, and file system type. At this time, the storage device writes the storage information in the boot sector to the global memory variable ramdisk. When the target device requests to read the storage information in the 0th sector, it simply copies all the data from ramdisk.
[0047] S12. In response to copying the currently stored information in the global memory variable to the target device, copy the storage information in the next sector of the disk to the global memory variable, until the storage information of the first N sectors is copied.
[0048] In this embodiment, the FAT32 system supports periodic sector-by-sector data retrieval. After reading the storage information in the boot sector, the target device can determine the period for sector-by-sector document retrieval based on relevant information from the file system.
[0049] For example, when the first cycle time arrives, the target device requests the storage information in sector 1 (that is, the next sector after the boot sector). For example, sector 1 stores FAT table 1. The storage device copies FAT table 1 to the global memory variable ramdisk and directly copies all the data in ramdisk to the target device.
[0050] Similarly, when the second cycle arrives, the target device requests the storage information in sector 2 (that is, the next sector after sector 1). For example, sector 2 stores FAT table 2. The storage device copies FAT table 2 to the global memory variable ramdisk and directly copies all the data in ramdisk to the target device.
[0051] When the third cycle arrives, the target device requests the storage information in sector 3 (that is, the sector following sector 2). For example, sector 3 stores the root directory information. The storage device copies the root directory information to the global memory variable ramdisk, and then directly copies all the data in ramdisk to the target device. This process continues until the storage information in the first N sectors has been copied to the target device through the global memory variable ramdisk.
[0052] S2. In response to the completion of the copying of the stored information in the Nth sector, convert the data in the first data sector into document data and store it in the global memory variable.
[0053] In this embodiment of the application, N is set to 4, so the first data sector is actually the first sector after sector 0 (boot sector), sector 1, sector 2, and sector 3, and is exemplarily referred to as sector 4.
[0054] In one possible implementation, step S2 includes:
[0055] S21. In response to the completion of the copying of the stored information in the Nth sector, disable the USB interrupt of the storage device.
[0056] USB interrupt is a data scheduling and transmission method defined by the USB protocol, which is used in situations involving small-batch, high-real-time data transmission.
[0057] By disabling USB interrupts, requests from the target device can be prevented from interfering with the process of generating document data on the storage device.
[0058] S22. After converting the data in the first data sector into document data and storing it in a global memory variable, enable the USB interrupt.
[0059] In this embodiment, it is first determined whether the target device has read the storage information in the first N sectors. If the copying is complete, the document generation process is executed in advance to generate document data of one sector size and store it in the global memory variable ramdisk. Specifically, a document generation function can be used to convert the data into document data. For example, the document can be in PDF or TXT format; this application does not limit the document format.
[0060] S3. In response to a read request for the target document, copy the document data of the first data sector from the global memory variable to the target device, convert the data in the next data sector into document data, and then copy it to the target device through the global memory variable until the target document is exported.
[0061] In one possible implementation, step S3 includes:
[0062] S31. In response to a read request for the target document, after copying the document data of the first data sector from the global memory variable to the target device, disable the USB interrupt of the storage device.
[0063] In this embodiment, if a user opens a target document on the target device, a sector-by-sector read request for the target document is triggered. In response to the read request, the storage device starts its main loop program and begins pushing the target document sector-by-sector to the target device via USB interrupt.
[0064] S32. After converting the data in the second data sector into document data and storing it in a global memory variable, enable the USB interrupt.
[0065] S33. After copying the document data of the second data sector from the global memory variable to the target device, disable the USB interrupt;
[0066] S34. Perform steps S32 and S33 sequentially on the data sectors after the second data sector until the document data of the Mth data sector is copied from the global memory variable to the target device. Then, disable the USB interrupt, and the target document export is complete. M is the number of data sectors occupied by the target document.
[0067] For example, after the target device copies the document data corresponding to the first data sector, i.e., the N+1th sector (sector 4), from the global memory variable via a USB interrupt, the storage device then generates the document data for the second data sector and stores it in the ramdisk global memory variable. This process continues until all data in all data sectors has been exported as document data, at which point the process ends.
[0068] The above technical solution, based on the concept of virtual storage, uses a global memory variable of one sector size as an intermediate variable for data copying. It can generate document data of one sector size while copying data from the global memory variable to the target device. This allows for flexible and dynamic export of documents according to the specifications of the storage device, without the need for additional disk storage space to store the generated documents, thus greatly saving hardware costs.
[0069] To facilitate understanding of the process principles of the specific implementation methods described above, this application provides a flowchart of another data export method based on an exemplary embodiment. See also... Figure 3 Taking a PDF document as the generated document and a PC as the target device as an example, after the storage device starts the data export process, it first checks whether the PDF generation process has been closed. If not, the process ends. If so, it means that no data is currently being exported, and it checks whether a USB connection has been established with the PC. If a USB connection has been established, the storage information in the first four sectors is copied to the global memory variable ramdisk via a USB interrupt. After the USB interrupt has completed transmitting the storage information in the first four sectors, it closes the USB interrupt. After generating the PDF document data corresponding to the first data sector and storing it in the global memory variable, the USB interrupt is enabled. When the PC starts reading the PDF document, the USB interrupt retrieves the PDF document data of the first data sector from the global memory variable and uploads it to the PC. After the USB interrupt upload is complete, it closes the USB interrupt again. After generating the PDF document data of the next data sector and storing it in the global memory variable, the USB interrupt is enabled. When the PC continues to read the PDF document data of the next data sector, the USB interrupt retrieves the PDF document data of the next data sector from the global memory variable and uploads it to the PC, then closes the USB interrupt again. This process repeats until the entire PDF document is exported.
[0070] This application also provides a schematic diagram of a data export device, see reference. Figure 4 The device includes: a transmission module 401 and a processing module 402;
[0071] The transmission module 401 is used to establish a connection with the target device via a USB interface, and sequentially copy the file system-related data in the first N sectors of the disk to the target device through a global memory variable, where N is a positive integer determined according to the type of the file system;
[0072] The processing module 402 is configured to, in response to the completion of copying the stored information in the Nth sector, convert the data in the first data sector after the Nth sector into document data, and store the document data in the global memory variable;
[0073] The transmission module 401 is configured to copy the document data of the first data sector from the global memory variable to the target device in response to a read request for the target document.
[0074] The processing module 402 is used to convert the data in the next data sector into document data;
[0075] The transmission module 401 is used to copy the document data obtained by converting the data in the next data sector to the target device through the global memory variable until the target document is exported.
[0076] It should be noted that the data export device provided in the above embodiments is only illustrated by the division of the above functional modules when implementing the corresponding steps. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the data export device provided in the above embodiments and the data export method described above belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0077] This application provides a computing device that can be implemented as the aforementioned storage device and execute the data export method provided in this application. Figure 5 This is a schematic diagram of the hardware structure of a computing device provided in an embodiment of this application, such as... Figure 5 As shown, the computing device includes a processor 501, a memory 502, a bus 503, and a computer program stored in the memory 502 and executable on the processor 501. The processor 501 includes one or more processing cores. The memory 502 is connected to the processor 501 via the bus 503 and is used to store program instructions. When the processor executes the computer program, it implements all or part of the steps in the above-described method embodiments provided in this application.
[0078] Furthermore, as an executable solution, the aforementioned computing device can be a computer unit, which may be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer unit may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above-described computer unit structure is merely an example and does not constitute a limitation on the computer unit. It may include more or fewer components, or combine certain components, or different components. For example, the computer unit may also include input / output devices, network access devices, buses, etc., which are not limited in this application embodiment.
[0079] Furthermore, as an executable solution, the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The processor is the control center of the computer unit, connecting various parts of the entire computer unit via various interfaces and lines.
[0080] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the computer unit by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0081] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the methods described in the embodiments of this application.
[0082] If the modules / units integrated in the computer unit are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution media, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0083] Although this application has been specifically shown and described in conjunction with preferred embodiments, those skilled in the art should understand that various changes in form and detail may be made to this application without departing from the spirit and scope of this application as defined by the appended claims, and all such changes shall be within the scope of protection of this application.
Claims
1. A data export method, characterized in that, Applied to electronic devices, the method includes: S1. Establish a connection with the target device via USB interface, and sequentially copy the file system-related storage information in the first N sectors of the disk to the target device through a global memory variable. N is a positive integer determined according to the type of the file system, and the global memory variable is located in the memory of the electronic device. S2. In response to the completion of copying the storage information in the Nth sector, disable the USB interrupt, convert the data in the first data sector after the Nth sector into document data, store the document data in the global memory variable, and then enable the USB interrupt. S3. In response to a read request for the target document, copy the document data of the first data sector from the global memory variable to the target device, convert the data in the next data sector into document data, and then copy it to the target device through the global memory variable until the target document is exported. Step S3 includes: S31. In response to a read request for the target document, after copying the document data of the first data sector from the global memory variable to the target device, the USB interrupt is turned off; S32. After converting the data in the second data sector into document data and storing it in the global memory variable, enable the USB interrupt; S33. After copying the document data of the second data sector from the global memory variable to the target device, disable the USB interrupt; S34. Perform steps S32 and S33 sequentially on the data sectors after the second data sector until the document data of the Mth data sector is copied to the target device. Then, turn off the USB interrupt, and the export of the target document is complete. M is the number of data sectors occupied by the target document.
2. The data export method according to claim 1, characterized in that, Step S1 includes: S11. In response to the target device's request to read the disk, copy the storage information in the boot sector of the disk to the global memory variable; S12. In response to copying the currently stored storage information in the global memory variable to the target device, copy the storage information in the next sector of the disk to the global memory variable, until the storage information in the first N sectors is copied.
3. The data export method according to any one of claims 1 to 2, characterized in that, The capacity of the global memory variable is greater than or equal to the capacity of the sector.
4. The data export method according to claim 1, characterized in that, The electronic device includes a USB interface, a processor, and a memory, the memory including the disk and RAM.
5. The data export method according to claim 4, characterized in that, When the electronic device uses the FAT32 file system, N is 4.
6. A data export device, characterized in that, Applied to electronic devices, the device includes: a transmission module and a processing module; The transmission module is used to establish a connection with the target device via a USB interface, and sequentially copy the file system-related data in the first N sectors of the disk to the target device through a global memory variable, where N is a positive integer determined according to the type of the file system, and the global memory variable is located in the memory of the electronic device. The processing module is configured to, in response to the completion of copying the stored information in the Nth sector, disable the USB interrupt, convert the data in the first data sector after the Nth sector into document data, store the document data in the global memory variable, and then enable the USB interrupt; The transmission module is configured to, in response to a read request for a target document, copy the document data of the first data sector from the global memory variable to the target device and disable USB interrupts; The processing module is used to convert the data in the next data sector into document data; The transmission module is used to copy the document data obtained by converting the data in the next data sector to the target device through the global memory variable until the target document is exported. Converting the data in the next data sector into document data includes: S32. After converting the data in the second data sector into document data and storing it in the global memory variable, enable the USB interrupt; Specifically, copying the document data obtained by converting the data in the next data sector to the target device via the global memory variable until the target document export is complete includes: S33. After copying the document data of the second data sector from the global memory variable to the target device, disable the USB interrupt; S34. Perform steps S32 and S33 sequentially on the data sectors after the second data sector until the document data of the Mth data sector is copied to the target device. Then, turn off the USB interrupt, and the export of the target document is complete. M is the number of data sectors occupied by the target document.
7. An electronic device, characterized in that, It includes a memory and a processor, the memory storing at least one program, the at least one program being executed by the processor to implement the data export method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The storage medium stores at least one program segment, which is executed by a processor to implement the data export method as described in any one of claims 1 to 5.