CN110737483B - Signaling and data transmission method based on Windows USB MassStorage class - Google Patents
Signaling and data transmission method based on Windows USB MassStorage class Download PDFInfo
- Publication number
- CN110737483B CN110737483B CN201910970692.5A CN201910970692A CN110737483B CN 110737483 B CN110737483 B CN 110737483B CN 201910970692 A CN201910970692 A CN 201910970692A CN 110737483 B CN110737483 B CN 110737483B
- Authority
- CN
- China
- Prior art keywords
- command
- data
- area
- packet
- response
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4411—Configuring for operating with peripheral devices; Loading of device drivers
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to a signaling data transmission method based on Windows USB MassStorage, which belongs to the field of data transmission and consists of an upper computer software part running at a PC side and a lower computer which is connected with the upper computer software part through a USB port and enumerated to the PC by MassStorage, wherein a specific command interaction area A and a specific data interaction area B are arranged in a U disk, and all commands sent to the lower computer by the upper computer are sent to the area A by using a standard USB write command data packet; the USB equipment writes the received data packet containing the command into the designated address of the area A, inquires the data of the area A at regular time, analyzes and executes the command if the command exists in the area A, and rewrites the command in the area A into a command response after the command is completed. The invention ensures the reliability of MassStorage type lower computer to execute various commands, and is suitable for occasions with high data operation requirement, large transmission quantity and unreliable USB connection.
Description
Technical Field
The invention belongs to the field of data transmission, and relates to a signaling and data transmission method based on Windows USB MassStorage class.
Background
The traditional USB Mass Storage type equipment is commonly called a U disk, is a plug-and-play device, uses the existing 'standard' equipment driving program, and can be used for all system lines without installing any equipment driving program. When the operating system checks that a USB device (here, a USB flash disk) is inserted, the relevant parameters of the device are automatically inquired to know the capability and the requirement of the device, and an appropriate driver is automatically loaded into the operating system, so that a user can normally use the equipment. By the time the device is unplugged from the USB interface, the operating system will automatically stop the use of the device and uninstall its drivers. The USB device is sold together with software (firmware) stored in the USB device, and is used to control the operation of the USB device (i.e. the lower computer), and generally adopts a general standard driver, and only responds to related standard commands such as read, write, erase, and the like issued by the PC (upper computer).
The USB interface has high popularity in the fields of PC, consumer electronics and the like, so the application range of the transmission mode is wide. However, the following disadvantages also exist: the traditional USB Mass Storage class can only meet the requirement of simple data transmission and can not support the functions of other extended command (such as a commonly used debugging command of embedded debugging equipment) transmission and the like; if unexpected interruption (such as unexpected reset of the U disk, power failure and the like) occurs in the data transmission process, the data transmission command cannot be continuously executed after the U disk is reconnected.
The Lawrens Hamimed and Mark Carlo in Ontario, canada proposed a patent of "a method and protocol for transmitting extended commands via USB device" (application No.: 200680006799.9 application date: 2006-02-28), which proposed a method for packaging command packets and data packets executed corresponding to the commands into common USB read-write data and transmitting the data packets to a lower computer such as a U disk, and the lower computer unpacks the data packets according to a convention mode after receiving the data packets, takes out the command packets and data information in the data packets for execution, and writes a read command into the lower computer, and the lower computer returns the result of the last command execution, i.e. the data packets responded to the upper computer, thereby realizing the whole command execution process.
The method for transmitting the extended command by the command transmission mode provided by the patent realizes the function of transmitting the extended command by the standard USB equipment, but no matter the command data is issued and the execution result is obtained, the lower computer actively responds, the lower computer responds correspondingly, the interactive relation of the response of the upper computer and the lower computer cannot be correctly executed and completed under the conditions of dialing out of the lower computer and accidental power failure, the whole command execution process can be interrupted, and the reliability of command execution is not facilitated. The USB interface device itself supports hot plug, and there is a possibility that a user does not delete a USB Mass Storage class device in the operating system according to a normal operation procedure, but makes hardware dial-out, and there are many key commands, such as: if the operations of formatting, deleting user confidential data in the USB flash disk, upgrading the firmware of the USB flash disk and the like are not correctly executed, the USB flash disk is accidentally powered off by a user, the USB device of the user is damaged if the operations are not correctly executed, and the situation that confidential information is accidentally lost if the operations are not correctly executed is generated.
Disclosure of Invention
In view of this, the present invention provides a scheme for ensuring that the lower computer can continue to execute the unfinished operation after the lower computer is powered down without executing the command of the upper computer.
In order to achieve the purpose, the invention provides the following technical scheme:
a signaling and data transmission method based on Windows USB MassStorage class, set up order interaction district A and data interaction district B in USB apparatus, all orders that the upper computer sends to USB apparatus use the standard USB to write the order data packet to send to district A, and capsulate the actual order as the data in the standard USB writes the order data packet; the USB equipment writes the received data packet containing the command into the designated address of the area A, periodically inquires the data of the area A, analyzes and executes the command if the command exists in the area A, and rewrites the command in the area A into a command response after the command is inquired; and after the USB equipment is electrified and enumerated successfully, the upper computer reads the data in the area A, and sends a new command if the data is a response packet, or waits for the USB equipment to execute the command in the area A if the data is not the response packet.
Further, the setting of the area A and the area B of the USB device comprises a basic type and an extended mode, wherein the area A of the basic type is set by the address offset length X of the USB device 0, the area B is set by the address offset length Y of the USB device 0, and the area A and the area B of the extended mode are combined and are both set by the address offset length X of the USB device 0.
Further, the command packet format of the command write-in area A of the USB equipment, which is written into the area A by the upper computer, is sequentially a command head valid mark-a reserved interval 1-a command execution code-a reserved interval 2-a command execution starting address-a reserved interval 3-a command execution length-a reserved interval 4-a command tail valid mark;
when the command is executed, the response packet format written into the area A by the lower computer is a response head valid mark-a reserved interval 1-a command execution response code-a reserved interval 2-a response starting address-a reserved interval 3-a response length-a reserved interval 4-a response tail valid mark in sequence;
each reserved interval is used for data protection and function expansion in the future, and the data area format sequentially comprises a data area effective mark 1, a data area effective mark 2;
also included are derivatives extended in the manner described above:
a plurality of command packet combination writing mode: the method comprises the steps of marking a command head valid mark-a reserved area 1-a command execution code 1-a command execution starting address 1-a reserved area 2-a command execution code 2-a command execution starting address 2-a command execution length 2- \ 8230 \\ 8230; -a command execution code n-a command execution starting address n-a command execution length n-a reserved area n-a command tail valid mark;
a plurality of response packets are combined in a writing mode: the method comprises the steps of responding to a header valid mark, reserving a region 1, responding to a starting address 1, responding to a length 1, reserving a region 2, responding to a command execution response code 2, responding to a starting address 2, responding to a length 2, 8230, responding to a starting address n, responding to a length n, reserving a region n, responding to a tail valid mark, wherein the response address n is a response address n, the response length n is a response length n, and the response tail valid mark is a response length n;
data area format for multiple command/response packets: data area valid flag 1-command execution code 1 data portion-command execution code 2 data portion- \8230; -command execution code n data portion-data area valid flag 2.
Further, an upper computer function support module is arranged in the upper computer to realize the following functions:
(1) Interface display and user operation response unit: responding to various operations executed by a user, displaying command execution progress and results, and providing input interfaces for various setting options;
(2) A user operation command or command set conversion unit: for various operations issued by a user, when a single command cannot complete the whole function, the command is converted into a corresponding command or a command set supported by the USB equipment, and meanwhile, the operation objects (generally various data) of the user are unpacked and subjected to segmentation pretreatment;
(3) A command packet and data packet packaging and assembling unit: packing the command execution code, the command execution starting address, the command execution length and the data file into an effective command packet and an effective data packet respectively in a specified mode;
(4) The response packet and response data analysis processing unit: unpacking and analyzing the acquired response information according to a specified mode, judging a response result executed by a command, extracting response data, repacking the response data under the condition of need, recovering the response data into a super-large data packet and transmitting the super-large data packet back to the upper computer;
(5) Command data caching and execution result recording unit: recording the USB ID number of the current USB equipment and caching the command packet and data packet information of the command when the command is executed, and recording the execution condition of the command at any time, so that when the command is failed to be executed, the upper computer can resend the command or complete the response data acquisition work which is not finished by the last operation;
(6) A/B area data read-write unit: completing the read-write function of the A/B area data of the specified offset address;
(7) A command execution flow maintenance unit: and judging and maintaining the function execution conditions of the units, judging whether the current command fails to be executed or not, whether the current command is re-executed or not, whether a user needs to be prompted to intervene operation or not, and judging whether the current USB equipment has the operation which is not completed last time or not through the USB ID.
Further, a lower computer function support module is arranged in the USB device to realize the following functions:
(1) A/B area data read-write unit: finishing the read (obtaining command packet) and write (writing response packet) functions of the A/B area data of the designated offset address, particularly polling the A area data at fixed time intervals so as to obtain the command issued by the upper computer at any time;
(2) The command packet and data packet analysis and validity judgment unit: analyzing the command packet and the data packet in a specified mode, and judging the validity of the command packet and whether the command is supported;
(3) A command execution unit: converting the command execution code in the command packet into a series of corresponding operation processes of the lower computer, and specifically executing the operation by using the data in the data packet;
(4) Response packet and response data assembling unit: the result of the execution by the command execution unit is packed into a command execution response packet and a response data packet for writing to the A/B area in a manner of executing the response code and the response data, respectively.
Further, before the upper computer issues a new command, the upper computer judges whether the current USB equipment has the operation which is not executed last time through the USB ID number,
A. if not, the following operations are carried out:
(1) Generating command execution codes and corresponding data according to the operation condition of a user, assembling into a command packet and a data packet according to the specification, caching and recording the command packet and the data packet by an upper computer, and writing the command packet and the data packet into corresponding A/B areas respectively, namely finishing the issuing process of the command;
(2) After the command is issued, the upper computer continuously inquires the data in the area A to judge whether a response packet which is executed and completed by the lower computer is written back, after the response packet and the response data are obtained within a specified time, the upper computer carries out unpacking and command execution result judging work to complete the command interaction flow, and the upper computer enters the issuing interaction flow of the next command;
(3) If any one of the flows fails to execute or the lower computer write-back response packet is overtime, the command is marked as failed to execute, and the command is re-issued according to the setting condition, the command execution flow is suspended or user intervention is required;
B. if the last command of the current USB equipment is not executed, the upper computer reads the data in the area A of the lower computer and judges whether the data is a normal response packet of the last command or not, if so, the response packet and the response data are acquired back so as to complete the last legacy command interaction process, and then the issuing operation of a new command is carried out; if the A area of the USB equipment is not a response packet but a command packet, the response packet of the previous command is not written by the lower computer, under the condition that the A/B area data is judged to be consistent with the cache data, the upper computer waits for the lower computer to finish the command execution and writes the response packet and the response data packet, then obtains the response data so as to finish the previous unfinished command, then sends a new command, and if the upper computer finds that the A/B area data is inconsistent with the cache data, rewrites the A/B area so that the previous command can be correctly executed, and then carries out the operation;
the USB equipment polls the information of the areas A and B at a certain time interval so as to judge whether a new command is issued by the upper computer in time, loads data to execute the corresponding operation of the command execution code under the condition of confirming that the command packet and the data packet are effective after acquiring the command packet written by the upper computer, and writes the execution result, namely the response packet and the response data, into the specified address, thereby completing the execution process of the command code;
if the USB device detects that the data in the A/B area is an illegal command/data packet, including a normal response packet written after the last command is executed or a damaged command/data packet, the USB device does not execute any operation, waits for a certain time and inquires the data in the A/B area, so that the upper computer can read the response data or re-issue a correct command and data packet and then continue the command execution process.
The invention has the beneficial effects that: the system can ensure the reliability of the MassStorage lower computer in executing various commands, can continue to execute unfinished commands on next power-on even after power failure or interruption command execution due to abnormal interference, and is particularly suitable for occasions with high data operation requirement, large transmission quantity and unreliable USB connection.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims thereof.
Drawings
For the purposes of promoting a better understanding of the objects, aspects and advantages of the invention, reference will now be made to the following detailed description taken in conjunction with the accompanying drawings in which:
FIG. 1 is a schematic diagram of a command interaction area (area A) and a data interaction area (area B) according to the basic embodiment of the present invention;
FIG. 2 is a schematic diagram of a command interaction area (area A) and a data interaction area (area B) in the extended mode according to the present invention;
FIG. 3 is a diagram (basic type) of the command packet format of the command interaction area (area A) according to the present invention;
FIG. 4 is a diagram (basic type) of a format of a response packet of the command interaction area (area A) according to the present invention;
FIG. 5 is a format diagram (basic type) of the data area according to the present invention;
FIG. 6 is a diagram (expanded type) of the command packet format of the command interaction area (area A) according to the present invention;
FIG. 7 is a diagram (expanded type) of the format of the response packet of the command interaction area (area A) according to the present invention;
FIG. 8 is a data area format diagram (expanded type) according to the present invention;
fig. 9 is a block diagram of the upper and lower computers to which the function support module of the present invention is added;
fig. 10 is a block diagram of internal sub-modules of the upper and lower computer function support modules according to the present invention;
FIG. 11 is a flow chart of command execution issued by the upper computer according to the present invention;
FIG. 12 is a flow chart of the lower computer receiving and executing commands according to the present invention.
Detailed Description
The following embodiments of the present invention are provided by way of specific examples, and other advantages and effects of the present invention will be readily apparent to those skilled in the art from the disclosure herein. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention in a schematic way, and the features in the following embodiments and embodiments may be combined with each other without conflict.
Wherein the showings are for the purpose of illustration only and not for the purpose of limiting the invention, shown in the drawings are schematic representations and not in the form of actual drawings; to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of an actual product; it will be understood by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The same or similar reference numerals in the drawings of the embodiments of the present invention correspond to the same or similar components; in the description of the present invention, it should be understood that if there is an orientation or positional relationship indicated by the terms "upper", "lower", "left", "right", "front", "rear", etc., based on the orientation or positional relationship shown in the drawings, it is only for convenience of description and simplification of description, but it is not intended to indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore the terms describing the positional relationship in the drawings are only used for illustrative purposes and are not to be construed as limiting the present invention, and the specific meaning of the terms described above will be understood by those skilled in the art according to the specific circumstances.
The invention aims to provide a scheme for ensuring that a lower computer can still continue to execute unfinished operation after the lower computer is powered down without executing an upper computer command.
The main idea of the scheme is to store commands (containing data required by the commands) and then execute the commands, the specific implementation scheme is composed of an upper computer software part running on a PC side and a lower mechanism which is connected with the upper computer software part through a USB port and enumerated to the PC in a Mass Storage class manner, specific commands and data interaction areas (an area A and an area B) are set in a U disk as shown in a basic type and an expansion mode in a figure 1, and all commands (including standard USB read-write commands and expansion commands) sent to a lower computer by the upper computer are sent to the area A by using a standard USB write command data packet (actual commands are packaged into a USB standard data packet as data); the USB equipment writes the received data packet containing the command into the designated address of the area A, inquires the data of the area A at regular time, analyzes and executes the command if the command exists in the area A, and rewrites the command in the area A into a command response after the command is completed.
And after the USB equipment is electrified and enumerated successfully, the upper computer reads the data in the area A, and sends a new command if the data is a response packet, or waits for the USB equipment to execute the command in the area A if the data is not the response packet. The format (command packet format) of the command write-in command interaction area (area a) of the upper computer to the lower computer is as shown in fig. 3 (basic type), while the format (response packet format) of the command write-in command interaction area (area a) of the lower computer is as shown in fig. 4 (basic type) after the command execution is completed (each 'reserved area' is used for data protection and future function extension), and the format of the data area is as shown in fig. 5. Or derivatives extended in this way: the combination of the command/response packets, the response mode (see fig. 6 and 7), and the data area format corresponding to the command/response packets are shown in fig. 8.
The basic model of the method is explained below, because a common Mass Storage device can only perform corresponding command response on operation commands such as reading, writing, erasing and the like of an upper computer (PC) and cannot meet the read/write operation requirements of a command interaction area (area A comprises parameters such as command execution response codes, response initial addresses and the like as shown in the figure) and data of a data interaction area (area B) for appointing an offset address of a U disk, the lower computer needs an additional function support module (in a software or hardware mode) of the method to realize the functions; also the upper computer needs to run an additional software or software/hardware module to support this function. Fig. 9 is a block diagram of the upper and lower computers to which the upper and lower computer function support modules are added.
The structural block diagram of each internal functional unit of the newly added module is shown in fig. 10, which is introduced below:
host computer function support module: (1) interface display and user operation response unit: responding to various operations executed by a user, displaying command execution progress and results, and providing input interfaces for various setting options; (2) a user operation command or command set conversion unit: converting various operations issued by a user into corresponding commands or command sets supported by a lower computer (when a single command cannot complete the whole function), and simultaneously performing preprocessing operations such as unpacking, segmenting and the like on operation objects (generally various data) of the user; (3) a command packet and data packet packaging and assembling unit: packing the command execution code, the command execution starting address, the command execution length and the data file into an effective command packet and an effective data packet respectively in a specified mode; (4) response packet and response data analysis processing unit: unpacking and analyzing the acquired response information according to a specified mode, judging a response result executed by a command, extracting response data, repacking the response data under the condition of need, recovering the response data into a super-large data packet and transmitting the super-large data packet back to the upper computer; (5) the command data caching and execution result recording unit: recording the USB ID number of the current USB equipment, caching the command packet and data packet information of the command when the command is executed, and recording the execution condition of the command at any time, so that when the command fails to be executed, the upper computer can resend the command or complete the response data acquisition work which is not finished by the last operation; (6) A/B area data read-write unit: completing the read-write function of the A/B area data of the appointed offset address; (7) a command execution flow maintenance unit: and judging and maintaining the function execution conditions of the units, judging whether the current command fails to be executed or not, whether the current command is re-executed or not, whether a user needs to be prompted to intervene operation or not, judging whether the current USB equipment has last unfinished operation or not through the USB ID, and the like.
The lower computer function support module: (1) A/B area data read-write unit: finishing the read (obtaining command packet) and write (writing response packet) functions of the A/B area data of the designated offset address, particularly polling the A area data at fixed time intervals so as to obtain the command issued by the upper computer at any time; (2) The command packet and data packet analysis and validity judgment unit: analyzing the command packet and the data packet in a specified mode, and judging the validity, whether the command is supported, and the like; (3) a command execution unit: converting the command execution code in the command packet into a series of corresponding operation processes of the lower computer, and specifically executing the operation by using the data in the data packet; (4) response packet and response data assembling unit: the result of the execution by the command execution unit is packed into a command execution response packet and a response data packet for writing to the A/B area in a manner of executing the response code and the response data, respectively.
The execution process of the upper computer software/module on the basic type command of the scheme is shown in a flow chart 11, and the whole execution process is explained in detail as follows:
A. before the upper computer issues a new command, whether the USB equipment has operation which is not executed last time (such as unexpected power failure of the lower computer) is judged through the USB ID number, and if not, the normal process is followed
(1) Generating command execution codes and corresponding data according to the operation condition of a user, assembling into a command packet and a data packet according to the specification, caching and recording the command packet and the data packet by an upper computer, and writing the command packet and the data packet into corresponding A/B areas respectively, namely finishing the issuing process of the command;
(2) After the command is issued, the upper computer continuously queries the data in the area A to judge whether a response packet executed and completed by the lower computer is written back, and after the response packet and the response data are obtained within a specified time, the upper computer performs the work of unpacking, judging the command execution result and the like, so that the command interaction process is completed, and the upper computer can enter the issuing interaction process of the next command.
(3) If any one of the processes fails to be executed or the lower computer write-back response packet is overtime, the command is marked as failed to be executed, and the command can be re-issued, the command execution process can be suspended or user intervention can be required according to the setting condition.
B. If the last command of the current USB equipment is not finished, the upper computer reads the data in the area A of the lower computer and judges whether the data is a normal response packet of the last command or not, if so, the response packet and the response data are acquired back so as to finish the last legacy command interaction process, and then the issuing operation of a new command is carried out; if the A area of the USB device is not a response packet but a command packet, the response packet of the previous command is not written by the lower computer, under the condition that the A/B area data is judged to be consistent with the cache data, the upper computer waits for the lower computer to finish the command execution and writes the response packet and the response data packet, then obtains the response data so as to finish the previous unfinished command, then sends a new command, and if the upper computer finds that the A/B area data is inconsistent with the cache data, rewrites the A/B area so that the previous command can be correctly executed, and then carries out the operation.
The execution process of the lower computer module for the basic type command of the present solution is shown in the flowchart 12, and the whole execution process is described as follows:
the lower computer polls the information of the areas A and B at a certain time interval so as to judge whether a new command is issued by the upper computer in time, loads data to execute the corresponding operation of the command execution code under the condition of confirming that the command packet and the data packet are effective after acquiring the command packet written by the upper computer, and writes the execution result (response packet and response data) into the designated address, thereby completing the execution process of the command code.
If the lower computer detects that the data in the A/B area is not a legal command/data packet (possibly a normal response packet written after the execution of the previous command or a damaged command/data packet), no operation is executed, and the lower computer waits for a certain time to inquire the data in the A/B area so as to enable the upper computer to read the response data or continue the command execution process after the upper computer re-issues a correct command or data packet.
According to the mode, even if the lower computer is reset due to abnormal power failure, interference and the like, after the lower computer is electrified and finishes enumeration identification in the PC, whether the area A has a valid command packet or not is checked, if the valid command packet exists, the command is not executed and completed before the last power failure, the lower computer executes the command again, and the executed response packet and data are written in the corresponding area A and the corresponding area B in an overlaid mode to mark the completion of the command execution. Therefore, the mechanism is still applicable to the power-on state after abnormal power failure.
The above-described flow is illustrated below by way of example:
and deleting the user data: when the lower computer receives the deleting command and is executing, if the command is accidentally dialed out and power off, the deleting operation is terminated, the user data is still not completely deleted, and the possibility of disclosure exists; however, if the usb disk is powered on again, the usb disk controller with the functional module of this embodiment will first check whether the command packet in the area a is valid, and if so, will parse the command packet and re-execute the corresponding delete command, and after the command is executed correctly, will rewrite the information in the area a to the format of the response packet (this operation does not need to return response data).
Data write operation of large file: when a user writes a 6G-sized file into an 8G usb disk, if the user directly performs the writing operation through the resource manager of Windows, the user inadvertently dials out the usb disk when the previous 5G is copied, the file is not correctly written into the usb disk (even the file is lost), and the next time the user writes the file into the usb disk correctly, the user needs to copy the 6G-sized file again, which is time-consuming and labor-consuming. By adopting the scheme, the problem can be solved more conveniently, the recording condition of the command packet is fully utilized to avoid the condition of repeated copy operation, and the specific execution process is as follows:
when a large file is written into the U disk through the upper computer software, the upper computer software splits the one-time large file writing operation into a plurality of FLASH data writing command operations which are not larger than the size of the B area according to the size of the B area of the lower computer.
In the normal process: writing the first block of data to be written into the area B, assembling a command execution code corresponding to the FLASH writing operation, the initial address written this time and the length into a command packet, and writing the command packet into the area A. After the lower computer checks the writing of the command packet in the area A in the polling process, the data in the area B is written into a specified initial address in a specified length after the command packet is analyzed. Finally, the execution result of the write command is written back to the area A in a response packet mode (no response data of the operation), thereby completing the data command. And after detecting that the current data block is successfully written, the upper computer writes the next data block to be written into the area B, packs the information of the write address, the length and the like corresponding to the data block into a command packet again and writes the command packet into the area A, and continues writing the next data block. The above operations are continued until the entire command set is successfully executed, i.e. all the large files are successfully written into the lower computer.
When the current block write command is failed to be executed during an abnormal flow, for example, when the U disk is accidentally pulled out, the upper computer caches the command and data according to the ID number of the USB device and gives a warning message (or prompts the user to intervene), if the insertion of the USB ID device is checked again and the copying operation which is not finished is judged to be executed, and if the user is set to automatically execute the last unfinished operation according to the setting condition of the user (the user can cancel the operation conveniently), the upper computer software continues to transmit the residual data without re-transmitting the 6G file. The specific implementation process is divided into the following cases:
A. judging the areas A and B as normal commands and data packets, and reading the data check response information written in the area A after a period of time if the command written in the area A and the area B is effective, so that the lower computer can complete the last unfinished data block writing command after being electrified, and then perform the writing command and data issuing operation of the new data card after the command is completed, so as to continue the whole writing operation flow of the remaining data;
B. judging that the areas A and B are normal response packets and response data packets, wherein response addresses and response length information carried by the response packets correspond to a previous data writing command direction, and the previous command is just executed and completed before power failure, and the whole operation residual flow is directly continued;
C. and judging that the areas A and B are other conditions, namely, the command, the response packet or the read-write process of the command and the response packet are damaged in the power failure, and the upper computer rewrites the areas A and B of the lower computer according to the last command and data information cached corresponding to the ID number of the USB equipment so that the lower computer can re-execute the write-in command of the damaged power failure data block, and the whole operation residual flow is continued after the command is completed.
Data reading operation of large files: reading process corresponding to the large file, similar to the above writing process, is not repeated here, except that the upper computer software has a plurality of processes of splicing and assembling each data block again according to the data block address and length information sent back by the lower computer so as to recover the large file; in addition, after the lower computer is powered off abnormally and then powered on again, the conditions that the areas A and B are normal response data, the response address and the length information are matched with the previous command, but the upper computer does not successfully read the completed response data before the power failure exist, at the moment, the upper computer needs to judge through the USB ID number and the record information of the command execution failure, and the previous command execution response information is read again, so that the rest process can be continued.
Because the data packet/response data packet is written before the command packet/response packet in each operation, the data packet is ensured to be matched and reliable when the lower computer acquires a new command packet, and the corresponding response data acquired by the upper computer is also ensured to be matched and reliable with the response packet when the upper computer reads a new command execution response packet.
The extended command execution process of the scheme is consistent with the basic principle, but the upper computer can issue a plurality of commands and corresponding data at one time, while the lower computer can execute the corresponding commands in sequence (or according to a certain rule) and write back the command execution response packet and the response data packet execution result of the corresponding commands (according to the actual use requirement, the execution result of the step can be written back after each step is completed, or the response of each step is uniformly written into the corresponding position after the whole command set is completed), thereby ensuring the execution effectiveness of the command set which can execute and complete a certain function only by a plurality of command operations under the conditions of power failure, abnormal restart and the like.
For a standard command, the whole standard command packet containing information such as command, data, verification and the like is sent to a zone B as a data packet, then an extended command is sent to the zone A, the data of the zone B is marked as the standard command packet, and after the USB equipment analyzes the extended command, the standard command packet can be completely taken out from the zone B, and then the command is executed according to the original standard command execution function.
Finally, the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the present invention, and although the present invention has been described in detail with reference to the preferred embodiments, it will be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions, and all of them should be covered by the claims of the present invention.
Claims (3)
1. A signaling and data transmission method based on Windows USBMassStorage class is characterized in that: setting a command interaction area A and a data interaction area B in the USB equipment, sending all commands sent to the USB equipment by an upper computer to the area A by using a standard USB write command data packet, and packaging the actual commands serving as data into the standard USB write command data packet; the USB equipment writes a received data packet containing a command into a specified address of the area A, regularly inquires data of the area A, analyzes and executes the command if the command exists in the area A, and rewrites the command in the area A into a command response after the command is inquired; after the USB device is successfully electrified and enumerated, the upper computer reads the data in the area A, if the data is a response packet, a new command is sent, and if the data is not the response packet, the USB device waits for the USB device to execute the command in the area A;
an upper computer function support module is arranged in the upper computer to realize the following functions:
(1) Interface display and user operation response unit: responding to various operations executed by a user, displaying command execution progress and results, and providing input interfaces for various setting options;
(2) A user operation command or command set conversion unit: for various operations issued by a user, when a single command cannot complete the whole function, the command is converted into a corresponding command or a command set supported by the USB equipment, and meanwhile, unpacking and segmentation preprocessing operations are carried out on an operation object of the user;
(3) A command packet and data packet packaging and assembling unit: packing the command execution code, the command execution starting address, the command execution length and the data file into an effective command packet and an effective data packet respectively in a specified mode;
(4) The response packet and response data analysis processing unit: unpacking and analyzing the acquired response information according to a specified mode, judging a response result of command execution, extracting response data, repackaging the response data under the condition of need, recovering the response data into a super-large data package, and transmitting the super-large data package back to the upper computer;
(5) A command data caching and execution result recording unit: recording the USBID number of the current USB equipment and caching the command packet and data packet information of the current command when the command is executed, and recording the execution condition of the command at any time, so that when the command is failed to be executed, the upper computer can resend the command or complete the response data acquisition work of which the last operation is not finished;
(6) A/B area data read-write unit: completing the read-write function of the A/B area data of the specified offset address;
(7) A command execution flow maintenance unit: judging and maintaining the function execution conditions of the units, judging whether the current command fails to be executed or not, whether the current command is re-executed or not, whether a user needs to be prompted to intervene operation or not, and judging whether the current USB equipment has the operation which is not completed last time or not through the USBID;
the lower computer function supporting module is arranged in the USB device to realize the following functions:
(1) A/B area data read-write unit: finishing the read-write function of the A/B area data of the specified offset address, and polling the A area data at fixed time intervals so as to conveniently acquire a command issued by an upper computer at any time;
(2) The command packet and data packet analysis and validity judgment unit comprises: analyzing the command packet and the data packet in a specified mode, and judging the validity of the command packet and whether the command is supported;
(3) A command execution unit: converting the command execution code in the command packet into a series of corresponding operation processes of the lower computer, and specifically executing the operation by using the data in the data packet;
(4) Response packet and response data assembling unit: packing the result of the command executing unit into command executing response packet and response data packet for writing into A/B area;
before the upper computer issues a new command, whether the current USB equipment has the operation which is not executed last time is judged through the USBID number,
A. if not, the following operations are carried out:
(1) Generating command execution codes and corresponding data according to the operation condition of a user, assembling into a command packet and a data packet according to the specification, caching and recording the command packet and the data packet by an upper computer, and writing the command packet and the data packet into corresponding A/B areas respectively, namely finishing the issuing process of the command;
(2) After the command is issued, the upper computer continuously inquires the data in the area A to judge whether a response packet executed and completed by the lower computer is written back, after the response packet and the response data are obtained within a specified time, the upper computer performs unpacking and command execution result judgment work to complete the command interaction flow, and the upper computer enters the issuing interaction flow of the next command;
(3) If any one of the flows fails to execute or the lower computer write-back response packet is overtime, the command is marked as failed to execute, and the command is re-issued according to the setting condition, the command execution flow is suspended or user intervention is required;
B. if the last command of the current USB equipment is not executed, the upper computer reads the data in the area A of the lower computer and judges whether the data is a normal response packet of the last command or not, if so, the response packet and the response data are acquired back so as to complete the last legacy command interaction process, and then the issuing operation of a new command is carried out; if the A area of the USB equipment is not a response packet but a command packet, the response packet of the previous command is not written by the lower computer, under the condition that the A/B area data is judged to be consistent with the cache data, the upper computer waits for the lower computer to finish the command execution and writes the response packet and the response data packet, then obtains the response data so as to finish the previous unfinished command, then sends a new command, and if the upper computer finds that the A/B area data is inconsistent with the cache data, rewrites the A/B area so that the previous command can be correctly executed, and then carries out the operation;
the USB equipment polls the information of the areas A and B at a certain time interval so as to judge whether a new command is issued by the upper computer in time, loads data to execute the corresponding operation of the command execution code under the condition of confirming that the command packet and the data packet are effective after acquiring the command packet written by the upper computer, and writes the execution result, namely the response packet and the response data, into the designated address, thereby completing the execution process of the command code;
if the USB device detects that the data in the A/B area is an illegal command/data packet, including a normal response packet written after the last command is executed or a damaged command/data packet, the USB device does not execute any operation, waits for a certain time and inquires the data in the A/B area, so that the upper computer can read the response data or re-issue a correct command and data packet and then continue the command execution process.
2. The method for signaling and data transmission based on windows usb class storage class of claim 1, wherein: the setting of the area A and the area B of the USB equipment comprises a basic type and an extended mode, wherein the area A of the basic type is set by the address offset length X of the USB equipment 0, the area B is set by the address offset length Y of the USB equipment 0, and the area A and the area B of the extended mode are combined and are both set by the address offset length X of the USB equipment 0.
3. The method for signaling and data transmission based on windows usb class storage as claimed in claim 1, wherein: the command packet format of the command write-in area A of the USB equipment, which is written by the upper computer, is sequentially a command head valid mark, a reserved interval 1, a command execution code, a reserved interval 2, a command execution starting address, a reserved interval 3, a command execution length, a reserved interval 4 and a command tail valid mark;
when the command is executed, the response packet format written into the area A by the lower computer is a response head valid mark-a reserved interval 1-a command execution response code-a reserved interval 2-a response starting address-a reserved interval 3-a response length-a reserved interval 4-a response tail valid mark in sequence;
each reserved interval is used for data protection and future function expansion, and the data area format sequentially comprises a data area effective mark 1, a data area effective mark 2;
also included are derivatives extended in the manner described above:
a plurality of command packet combination writing mode: the method comprises the steps of marking a command head valid mark-a reserved area 1-a command execution code 1-a command execution starting address 1-a reserved area 2-a command execution code 2-a command execution starting address 2-a command execution length 2- \8230; marking a command execution code n-a command execution starting address n-a command execution length n-a reserved area n-a command tail valid mark;
multiple response packet combination write mode: the method comprises the steps of responding to a header valid mark, reserving a region 1, responding to a starting address 1, responding to a length 1, reserving a region 2, responding to a command execution response code 2, responding to a starting address 2, responding to a length 2, 8230, responding to a starting address n, responding to a length n, reserving a region n, responding to a tail valid mark, wherein the response address n is a response address n, the response length n is a response length n, and the response tail valid mark is a response length n;
data area format for multiple command/response packets: data area valid flag 1-command execution code 1 data portion-command execution code 2 data portion \8230; -command execution code n data portion-data area valid flag 2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910970692.5A CN110737483B (en) | 2019-10-12 | 2019-10-12 | Signaling and data transmission method based on Windows USB MassStorage class |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910970692.5A CN110737483B (en) | 2019-10-12 | 2019-10-12 | Signaling and data transmission method based on Windows USB MassStorage class |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110737483A CN110737483A (en) | 2020-01-31 |
CN110737483B true CN110737483B (en) | 2023-02-24 |
Family
ID=69268823
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910970692.5A Active CN110737483B (en) | 2019-10-12 | 2019-10-12 | Signaling and data transmission method based on Windows USB MassStorage class |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110737483B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114003176B (en) * | 2021-11-03 | 2024-07-02 | 杭州海康存储科技有限公司 | Data writing method and device and hard disk device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1869855A (en) * | 2005-05-23 | 2006-11-29 | 深圳市江波龙电子有限公司 | Method for command interaction and two-way data transmission on USB mass storage equipment by program and USB mass storage equipment |
CN101789019A (en) * | 2010-02-11 | 2010-07-28 | 株洲南车时代电气股份有限公司 | Method for controlling removable disk under Windows |
CN103034561A (en) * | 2011-09-29 | 2013-04-10 | 重庆重邮信科通信技术有限公司 | Command transmission method and relevant device for universal serial bus (USB) |
CN103731510A (en) * | 2014-01-24 | 2014-04-16 | 重庆邮电大学 | Data interaction method for application layer of wireless sensor network based on IPv6 (internal protocol version 6) |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6978339B2 (en) * | 2002-02-22 | 2005-12-20 | Canon Kabushiki Kaisha | Communication system and method of controlling same |
JP5107833B2 (en) * | 2008-08-29 | 2012-12-26 | 株式会社日立製作所 | Storage system and storage system control method |
US20140095822A1 (en) * | 2012-10-01 | 2014-04-03 | Trend Micro Incorporated | Secure removable mass storage devices |
-
2019
- 2019-10-12 CN CN201910970692.5A patent/CN110737483B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1869855A (en) * | 2005-05-23 | 2006-11-29 | 深圳市江波龙电子有限公司 | Method for command interaction and two-way data transmission on USB mass storage equipment by program and USB mass storage equipment |
CN101789019A (en) * | 2010-02-11 | 2010-07-28 | 株洲南车时代电气股份有限公司 | Method for controlling removable disk under Windows |
CN103034561A (en) * | 2011-09-29 | 2013-04-10 | 重庆重邮信科通信技术有限公司 | Command transmission method and relevant device for universal serial bus (USB) |
CN103731510A (en) * | 2014-01-24 | 2014-04-16 | 重庆邮电大学 | Data interaction method for application layer of wireless sensor network based on IPv6 (internal protocol version 6) |
Non-Patent Citations (6)
Title |
---|
A Secure Data Transfer Algorithm for USB Mass Storage Devices to Protect Documents;MAN Magdum,YM Patil;《International Journal of Emerging Engineering Research and Technology》;20170701;第4卷(第2期);第78-84页 * |
Comparision of Data Transfer Protocols over USB;Megha Dey;《International Journal of Engineering Research & Technology》;20121129;第9卷(第1期);第1-6页 * |
USB Host在嵌入式系统中的应用研究;孙飞;《中国优秀硕士学位论文全文数据库 (信息科技辑)》;20050815(第8期);I137-20 * |
USB Mass Storage类的设备端固件开发;卞廷波等;《实验科学与技术》;20051230(第04期);第49-52页 * |
USB Mass Storage类设备的设计与实现;韩杰等;《可编程控制器与工厂自动化》;20090315(第03期);第100-103页 * |
USB1.1 Mass Storage类设备的研究与实现;迟玉强等;《电子器件》;20071215(第06期);第2088-2090页 * |
Also Published As
Publication number | Publication date |
---|---|
CN110737483A (en) | 2020-01-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101593083B (en) | device, computer and method for protecting and restoring computer configuration information | |
JP2006286001A (en) | Usage of usb memory device for recovery of operating system | |
CN102289418A (en) | Built-in device programming system and method | |
CN103838537A (en) | Control device and information processing apparatus | |
CN112947978A (en) | Method for upgrading firmware based on chip usbhid, terminal device and computer readable storage medium | |
CN105760191A (en) | Embedded system equipment programming mass production method | |
US20100049961A1 (en) | Update method for basic input/output system and update system thereof | |
CN103150188A (en) | Quick initialization method for x86 compatible display card of non-x86 instruction set computer | |
CN107315607B (en) | Drive self-adaptation loading system | |
US8176309B2 (en) | Boot system has BIOS that reads rescue operating system from memory device via input/output chip based on detecting a temperature of a hard disk | |
CN103034561B (en) | Command transfer method and the relevant apparatus of USB | |
CN110737483B (en) | Signaling and data transmission method based on Windows USB MassStorage class | |
CN117687664A (en) | Online upgrade configuration method and device for DSP | |
CN103455288B (en) | Information processor and control method | |
CN110457058A (en) | Control node online upgrading method, apparatus, host computer, system and electronic equipment | |
CN113900693A (en) | Firmware upgrading method, device and system, electronic equipment and storage medium | |
CN110888656B (en) | Multifunctional programming device and programming method | |
JP3028055B2 (en) | PC card system and program rewriting method | |
CN102929647B (en) | Mainboard method of upgrading integrated with front panel and device in digital hard disc video recorder | |
CN107908418B (en) | Method for upgrading logic program of fiber channel node card and fiber channel bus equipment | |
US9058264B2 (en) | Method for repairing communication abnormality between data card and host and data card | |
CN113590143B (en) | MCU program downloading method based on USB, electronic equipment and storage medium | |
JP2001209527A (en) | Method for recovering preinstalled software | |
TWI480799B (en) | Method and equipment for upadating firmware of embedded system | |
CN103312728B (en) | Method of data synchronization between a kind of storage system, system and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |