Summary of the invention
In order to solve above-mentioned problems of the prior art, the invention provides and a kind of USB interface equipment is carried out method of operating and device, the technical solution used in the present invention is to increase control module in existing apparatus, upper layer software (applications) in the main frame uses certain communication protocol to communicate by letter with control module by interface function, specifies Extended Capabilities Port by control module.
One aspect of the present invention provides a kind of device that USB interface equipment is operated, this device comprises main frame, control module, switch module, the Extended Capabilities Port module, main frame is used for sending opening specifies the Extended Capabilities Port order, USB device that Extended Capabilities Port connects to appointment is operated, control module is used for resolve command and the address of the port module that is expanded, the gauge tap module, switch module is used for switch and has path between the Extended Capabilities Port module of this address and the main frame USB interface, the Extended Capabilities Port module is used to connect USB device, main frame is by the USB interface link control module and the switch module of main frame, control module is connected with switch module, and switch module is connected with the Extended Capabilities Port module.
Control module comprises the state that is used to detect the USB device that Extended Capabilities Port connects with this address, and reports to the detection sub-module of main frame.
Extended Capabilities Port modular power source line, D+ line and D-line are connected the main frame USB interface by switch module.
Extended Capabilities Port module ground wire directly is connected with the main frame USB interface.
When switch module was open mode, USB device power supply, three connecting lines of D+ and D-that switch module is communicated with on the Extended Capabilities Port were connected with the main frame USB interface.
When switch module was closed condition, USB device power supply, three connecting lines of D+ and D-that switch module is isolated on the Extended Capabilities Port were connected with the main frame USB interface.
Switch module comprises analog switch chip, address selection chip and on-off circuit, the address selection chip connects described control module, analog switch chip and on-off circuit, Extended Capabilities Port modular power source line connects the main frame USB interface by on-off circuit, and Extended Capabilities Port module D+ line, D-line connect the main frame USB interface by the analog switch chip.
Extended Capabilities Port module ground wire connects the main frame USB interface by switch module.
When switch module was open mode, the USB device on the Extended Capabilities Port was connected with the main frame USB interface by power supply, four connecting lines of D+, D-and ground.
When switch module was closed condition, USB device power supply, four connecting lines of D+, D-and ground that switch module is isolated on the Extended Capabilities Port were connected with the main frame USB interface.
Switch module comprises analog switch chip, address selection chip and on-off circuit, address selection chip link control module, analog switch chip and on-off circuit, Extended Capabilities Port modular power source line is connected the main frame USB interface with ground wire by on-off circuit, and Extended Capabilities Port module D+ line, D-line connect the main frame USB interface by the analog switch chip.
Main frame is by the USB interface link control module and the switch module of USB HUB module.The Extended Capabilities Port module comprises a plurality of expansion interfaces.
The Extended Capabilities Port module comprises a plurality of expansion interfaces.
The present invention provides a kind of on the other hand and USB interface equipment is carried out method of operating comprises the steps:
Steps A: main frame sends to control module and opens the Extended Capabilities Port order;
Step B: the control module resolve command and the port address that is expanded;
Step C: control module gauge tap module device is opened path between Extended Capabilities Port with address and the main frame;
Step D: USB device that Extended Capabilities Port connects is operated.
Step C comprises:
Step C1: control module is selected the Extended Capabilities Port of address by the address selection chip of switch module inside;
Step C2: control module is opened the Extended Capabilities Port of address and the connecting line between the main frame by the control analog switch chip and the transistor switching circuit of switch module inside.
Step D is specially: whether the state to USB device that Extended Capabilities Port connects with address normally carries out detecting operation, and gives main frame with test results report.
Step D is specially: USB device that Extended Capabilities Port connects is carried out business operation.
Step D is specially: the USB device that Extended Capabilities Port connects with address is carried out business operation.
Comprise also between step C and step D whether the state to USB device that Extended Capabilities Port connects with address normally carries out detecting operation, and the result is reported to the step of main frame.
Be specially when detecting step: when the state that detects Extended Capabilities Port institute connection device is normal, and when reporting to main frame, corresponding, step D is specially: main frame carries out business operation to USB device that Extended Capabilities Port connects.
Be specially when detecting step: undesired when the state that detects USB device that Extended Capabilities Port connects, and when reporting to main frame, re-execute main frame and open the step of the order of Extended Capabilities Port to the control module transmission.
Be specially when detecting step: when the state that detects USB device that Extended Capabilities Port connects undesired, and when reporting to main frame, re-execute main frame sends step from the order of opening Extended Capabilities Port to control module, accordingly, step D is specially: main frame carries out business operation to USB device that Extended Capabilities Port connects.
Be specially when detecting step: to connect the USB device state undesired when detecting Extended Capabilities Port, and when reporting to main frame, re-execute the step that main frame sends the order of opening other Extended Capabilities Port, accordingly, step D is specially: main frame carries out business operation to USB device that other Extended Capabilities Port connect.
Undesired being specially of state of USB device that Extended Capabilities Port connects: USB device that Extended Capabilities Port connects exists, and USB device is a malfunction.
Undesired being specially of state of USB device that Extended Capabilities Port connects: USB device that Extended Capabilities Port connects does not exist.
After the step D another is expanded salty new operation steps A-D.
Beneficial effect:
1. upper application software can optionally be controlled the downstream USB Extended Capabilities Port of appointment.
2. can detect and specify on the Extended Capabilities Port whether USB device is arranged, and whether detect USB device normal, which USB device fault the user can know.
3. the quantity that inserts the USB device of Extended Capabilities Port can not influence the usb bus bandwidth.
4. improved production efficiency.
Embodiment
Further specify the present invention below in conjunction with drawings and Examples, but not as a limitation of the invention.
Apparatus of the present invention are dimerous by software unit and hardware cell.Software section mainly refers to upper application software, and api function that upper application software can carry by system and respective protocol and control module communicate.
Control module is gone the physical connection of gauge tap module (this switch module comprises address selection chip 74HC138, on-off circuit and bidirectional high speed analog switch chip MAX4638) and Extended Capabilities Port as requested after the order of receiving upper application software.Each Extended Capabilities Port all has an absolute port numbers, and these port numbers have been assigned with different addresses.Control module is determined the designated port that upper application software need be controlled by the address selection chip in the switch module.
Switch module inside comprises analog switch chip, address selection chip and the on-off circuit that is made of transistor.Because USB device on the Extended Capabilities Port and main-machine communication need four connecting lines (power supply, D+, D-, ground).So we use these elements of switch module inside that these four connecting lines of the USB device on the Extended Capabilities Port are isolated respectively.Just can control communicating by letter of USB device on the Extended Capabilities Port of appointment and main frame so physically.
When sending to control module, upper application software orders, when requiring the USB device on a certain Extended Capabilities Port of visit.The address selection chip of control module by switch module inside selected the Extended Capabilities Port of assigned address, and controls analog switch chip and transistor switching circuit simultaneously, and four connecting lines of USB and the main frame USB interface of the Extended Capabilities Port of assigned address are connected.Specify the USB device of Extended Capabilities Port just can communicate by letter normally like this with main frame.Can see on Extended Capabilities Port, having only an equipment to communicate by implementation method, when this equipment and main frame communicate, be disconnected by physics between other Extended Capabilities Port and the main frame USB interface with main frame.Such benefit is no matter what USB device are Extended Capabilities Port connect, and system can not produce usb bus bandwidth deficiency, and upper application software can arbitrarily be controlled the Extended Capabilities Port of appointment.
Embodiment 1
As shown in Figure 1, device provided by the invention comprises the main frame 12 that includes upper-layer user's software unit, USB HUB module 13 (comprising a USB HUB chip AU9254A21), control module 14 (be control module, this unit comprises a microcontroller Motorola 68HC908JB8), switch module 15 and Extended Capabilities Port module 16.Use direct data connected mode between these several modules, concrete annexation is that main frame 12 is distinguished link control module 14 and switch module 15 by two USB interface of the USB HUB module 13 of main frame, control module 14 is connected with switch module 15, and switch module 15 is connected with Extended Capabilities Port module 16.
Wherein upper-layer user's software unit is made up of api function and the corresponding interface order and user software.The user can operate by api function and the corresponding interface order, controls Extended Capabilities Port module 16.
USB HUB module 13 is made of single-chip, has mainly realized the function of usb hub.Guarantee that control module 14 and Extended Capabilities Port module 16 can communicate with main frame.
Control module 14 comprises microprocessor, this module is used for being responsible for the order of response upper-layer user software unit, and real-time come gauge tap module 15 according to specific instructions, reach the function of management 16 Extended Capabilities Port modules, control module 14 also comprises the state that is used to detect the USB device that Extended Capabilities Port connects with described address, and reports to the detection sub-module 17 of main frame.
Extended Capabilities Port modular power source line, D+ line, D-line and ground wire are connected the main frame USB interface by switch module, when switch module is open mode, USB device on the Extended Capabilities Port is connected with the main frame USB interface by power supply, four connecting lines of D+, D-and ground, when switch module was closed condition, USB device power supply, four connecting lines of D+, D-and ground that switch module is isolated on the Extended Capabilities Port were connected with the main frame USB interface.Certainly the Extended Capabilities Port ground wire also can directly be connected with the main frame USB interface always, and switch module also can be realized identical technical purpose by opening the powered-down line separately.
Specifically describe and be exactly, 15 switch modules comprise analog switch chip, address selection chip and on-off circuit, address selection chip link control module, analog switch chip and on-off circuit, on-off circuit connects Extended Capabilities Port module and main frame USB interface by power lead, ground wire, and the analog switch chip connects Extended Capabilities Port module and main frame USB interface by D+, D-line.When on-off circuit, when the analog switch chip is open mode, promptly when on-off circuit, analog switch chip were opened between Extended Capabilities Port with this address and the main frame path, the USB device on the Extended Capabilities Port was connected with the main frame USB interface by power supply, four connecting lines of D+, D-and ground.When on-off circuit, when the analog switch chip is closed condition, promptly when on-off circuit, analog switch chip were closed between Extended Capabilities Port with this address and the main frame USB interface path, USB device power supply, four connecting lines of D+, D-and ground that on-off circuit, analog switch chip are isolated on the Extended Capabilities Port were connected with the main frame USB interface.Switch module 15 is made of 10 switch submodules, and the control of controlled module 14 is communicated with on the physical channel or disconnects being connected of Extended Capabilities Port module 16 and USB HUB module 13.And Extended Capabilities Port module 16 has only an Extended Capabilities Port to keep physically being connected with USB HUB module 13 at one time.
Extended Capabilities Port module 16 provides 10 Extended Capabilities Port, it is external connection interface section, the connecting interface of USB flash disk can be provided for the user, owing on Extended Capabilities Port, have only a USB flash disk to communicate with main frame, when this USB flash disk and main frame communicate, disconnected by physics between other Extended Capabilities Port and the main frame, so no matter what USB device are Extended Capabilities Port connect, system can not produce the problem of usb bus bandwidth deficiency, and therefore Extended Capabilities Port module 16 can provide any a plurality of Extended Capabilities Port in theory.
Embodiment 2
As shown in Figure 2, apparatus of the present invention comprise that the main frame 12, control module 14 (control module comprises a microcontroller Motorola68HC908JB8), switch module 15 (switch module comprises addressing chip 74HC138, on-off circuit and bidirectional high speed analog switch chip MAX4638) and the 15 Extended Capabilities Port modules that include upper-layer user's software unit are the Extended Capabilities Port module.Use direct data connected mode between these several modules, concrete annexation is USB interface link control module 14 and the switch module 15 of main frame 12 by main frame, control module 14 is connected with switch module 15, and switch module 15 is connected with Extended Capabilities Port module 16.
Wherein upper-layer user's software unit is made up of api function and the corresponding interface order and user software.The user can operate by api function and the corresponding interface order, controls Extended Capabilities Port module 16.
Control module 14 comprises microprocessor, and this module is responsible for responding the order of upper-layer user's software unit, and real-time comes gauge tap module 15 according to specific instructions, reaches the function of administration extensions port module 16.
Switch module 15 comprises analog switch chip, address selection chip and on-off circuit, address selection chip link control module, analog switch chip and on-off circuit, on-off circuit connects Extended Capabilities Port module and main frame USB interface by power lead, ground wire, and the analog switch chip connects this Extended Capabilities Port module and main frame USB interface by D+, D-line.When on-off circuit, analog switch chip were opened between Extended Capabilities Port with this address and the main frame USB interface path, the USB device on the Extended Capabilities Port was connected with the main frame USB interface by power supply, four connecting lines of D+, D-and ground.When on-off circuit, analog switch chip were closed between Extended Capabilities Port with this address and the main frame USB interface path, USB device power supply, four connecting lines of D+, D-and ground that on-off circuit, analog switch chip are isolated on the Extended Capabilities Port were connected with the main frame USB interface.Certainly the Extended Capabilities Port ground wire also can directly be connected with the main frame USB interface always, and on-off circuit closes the border power lead and also can realize identical technical purpose by opening separately.The control of switch module 15 controlled modules 14 is communicated with on the physical channel or disconnects being connected of Extended Capabilities Port module 16 and main frame 12.And have only an Extended Capabilities Port in the Extended Capabilities Port module 16 to keep physically being connected at one time with main frame 12.
Extended Capabilities Port module 16 provides external connection interface section, and the connecting interface of USB device can be provided for the user.
Embodiment 3
Operating personnel are carrying out detecting operation to the 1st USB flash disk that Extended Capabilities Port connects, and the method 1 of present embodiment employing comprises that step is as follows as shown in Figure 3:
Step 101: operating personnel assign the 1st order that USB flash disk that Extended Capabilities Port connects detects main frame, and the main frame upper application software sends the order of opening the 1st Extended Capabilities Port by api function and corresponding protocol to control module.
Step 102: control module receives the order that main frame is sent out, and according to the respective protocol resolve command.
Step 103: control module determines that according to the data that resolve command obtains the address of the 1st Extended Capabilities Port that upper application software need be controlled is 001.
Step 104: control module gauge tap module, only the path that 001 Extended Capabilities Port is connected main frame or USB HUB is opened, guarantee that 001 Extended Capabilities Port and main frame or USB HUB are communicated with physically, and other Extended Capabilities Port and main frame or USB HUB are disconnected physically.
Step 105: control module is carried out detecting operation to the USB flash disk that 001 Extended Capabilities Port is connected, and judges that USB flash disk exists and state is normal, and control module is returned USB flash disk to main frame and existed and the normal information of state, afterwards to the 2nd Extended Capabilities Port operation steps 101.Operating personnel just can be by showing that USB flash disk exists and the normal information of state learns that this USB flash disk exists and state is normal like this.
When a fault USB flash disk inserts, adopt this method can detect its malfunction equally, adopting this method can detect this port when an expansion mouth does not insert USB flash disk does not have USB flash disk to insert yet yet.
Embodiment 4
Operating personnel are by method 1 detected 8 normal USB flash disks of state of the present invention, these 8 normal USB flash disks of state are inserted in the 1-8 mouth of expansion mouth respectively, and adopt method 2 of the present invention to carry out format manipulation respectively, the method 2 of present embodiment employing comprises that step is as follows as shown in Figure 4:
Step 201: operating personnel assign main frame the 1st Extended Capabilities Port are connected the USB flash disk formatting command, and the main frame upper application software sends the order of opening the 1st Extended Capabilities Port by api function and corresponding protocol to control module.
Step 202: control module receives the order that main frame is sent out, and according to the respective protocol resolve command.
Step 203: control module determines that according to the data that resolve command obtains the address of the 1st Extended Capabilities Port that upper application software need be controlled is 001.
Step 204: control module gauge tap module, only the path that 001 Extended Capabilities Port is connected main frame or USB HUB is opened, guarantee that 001 Extended Capabilities Port and main frame or USB HUB are communicated with physically, and other Extended Capabilities Port and main frame or USB HUB are disconnected physically.
Step 205: host application software carries out format manipulation to the USB flash disk that 001 Extended Capabilities Port is connected, and this USB flash disk format of success back demonstration successful information notifying operation personnel is finished.
Re-execute step 201 afterwards, different is, and operating personnel assign main frame again that the 2nd Extended Capabilities Port connected the USB flash disk formatting command, also can not finish automatically by computer software if do not issue an order by operating personnel certainly.Finish format manipulation by that analogy to these 8 USB flash disks, when using this method that USB flash disk is carried out format manipulation, need not confirm the USB flash disk state, also can be to 8 not after testing USB flash disk directly carry out format manipulation, or directly each port is assigned the order of format manipulation respectively, and do not consider whether to have USB flash disk to insert.
Embodiment 5
Certainly operating personnel also can survey judgement limit format manipulation by frontier inspection when the 1st USB flash disk that Extended Capabilities Port connects carried out format manipulation, and the method 3 of present embodiment employing comprises that step is as follows as shown in Figure 5:
Step 301: operating personnel assign main frame the 1st USB flash disk that Extended Capabilities Port connects are detected and formatting command, and the main frame upper application software sends the order of opening the 1st Extended Capabilities Port by api function and corresponding protocol to control module.
Step 302: control module receives the order that main frame is sent out, and according to the respective protocol resolve command.
Step 303: control module determines that according to the data that resolve command obtains the address of the 1st Extended Capabilities Port that upper application software need be controlled is 001.
Step 304: control module gauge tap module, only the path that 001 Extended Capabilities Port is connected main frame or USB HUB is opened, guarantee that 001 Extended Capabilities Port and main frame or USB HUB are communicated with physically, and other Extended Capabilities Port and main frame or USB HUB are disconnected physically.
Step 305: control module detects the USB flash disk that 001 Extended Capabilities Port is connected, and judge the USB flash disk state, when state normally promptly this USB flash disk insert and during non-fault, directly carry out 306 steps, when Extended Capabilities Port has USB flash disk to insert but this equipment when being a fault USB flash disk, carry out follow-up 307 steps.
Step 306: control module is returned USB flash disk to main frame and is existed and the normal information of state, direct control step 308 afterwards.
Step 307: control module is returned the USB flash disk existence to main frame but is the information of malfunction, and the USB flash disk that more renews re-executes similar step to the 1st Extended Capabilities Port afterwards.
Step 308: receive return message aft engine application software the USB flash disk that 001 Extended Capabilities Port is connected is carried out format manipulation, this USB flash disk format of success back demonstration successful information notifying operation personnel is finished.
Embodiment 6
Different with embodiment 5, when Extended Capabilities Port did not have USB flash disk to insert, as shown in Figure 6, the method 4 that adopts at present embodiment comprised that step is as follows:
Step 401: operating personnel assign main frame the 1st USB flash disk that Extended Capabilities Port connects are detected and formatting command, and the main frame upper application software sends the order of opening the 1st Extended Capabilities Port by api function and corresponding protocol to control module.
Step 402: control module receives the order that main frame is sent out, and according to the respective protocol resolve command.
Step 403: control module determines that according to the data that resolve command obtains the address of the 1st Extended Capabilities Port that upper application software need be controlled is 001.
Step 404: control module gauge tap module, only the path that 001 Extended Capabilities Port is connected main frame or USB HUB is opened, guarantee that 001 Extended Capabilities Port and main frame or USB HUB are communicated with physically, and other Extended Capabilities Port and main frame or USB HUB are disconnected physically.
Step 405: control module detects the USB flash disk that 001 Extended Capabilities Port is connected, and judges the USB flash disk state, when state just often, directly carry out 406 steps, when Extended Capabilities Port does not have USB flash disk to insert, carry out follow-up 407 steps.
Step 406: control module is returned USB flash disk to main frame and is existed and the normal information of state, direct control step 408 afterwards.
Step 407: control module is returned the information that Extended Capabilities Port does not have USB flash disk to insert to main frame, and the USB flash disk that more renews re-executes similar step to the 1st Extended Capabilities Port afterwards.
Step 408: receive return message aft engine application software the USB flash disk that 001 Extended Capabilities Port is connected is carried out format manipulation, this USB flash disk format of success back demonstration successful information notifying operation personnel is finished.
Embodiment 7
As when the USB flash disk fault, also can not change the USB flash disk of the 1st Extended Capabilities Port immediately, but the 2nd Extended Capabilities Port operated, as shown in Figure 7, the method 5 that adopts at present embodiment comprises that step is as follows:
Step 501: operating personnel assign main frame the 1st USB flash disk that Extended Capabilities Port connects are detected and formatting command, and the main frame upper application software sends the order of opening the 1st Extended Capabilities Port by api function and corresponding protocol to control module.
Step 502: control module receives the order that main frame is sent out, and according to the respective protocol resolve command.
Step 503: control module determines that according to the data that resolve command obtains the address of the 1st Extended Capabilities Port that upper application software need be controlled is 001.
Step 504: control module gauge tap module, only the path that 001 Extended Capabilities Port is connected main frame or USB HUB is opened, guarantee that 001 Extended Capabilities Port and main frame or USB HUB are communicated with physically, and other Extended Capabilities Port and main frame or USB HUB are disconnected physically.
Step 505: control module detects the USB flash disk that 001 Extended Capabilities Port is connected, and judges the USB flash disk state, when state just often, directly carry out 506 steps, when Extended Capabilities Port has USB flash disk to insert but this equipment when being a fault USB flash disk, carry out follow-up 507 steps.
Step 506: control module is returned USB flash disk to main frame and is existed and the normal information of state, direct control step 508 afterwards.
Step 507: control module is returned the USB flash disk existence to main frame but is the information of malfunction, and the USB flash disk that more renews re-executes similar step to the 2nd Extended Capabilities Port afterwards.
Step 508: receive return message aft engine application software the USB flash disk that 001 Extended Capabilities Port is connected is carried out format manipulation, this USB flash disk format of success back demonstration successful information notifying operation personnel is finished.
Embodiment 8
When Extended Capabilities Port does not have USB flash disk to insert, can not insert USB flash disk the 1st Extended Capabilities Port again immediately yet, but the 2nd Extended Capabilities Port operated, as shown in Figure 8, the method 6 that adopts at present embodiment comprises that step is as follows:
Step 601: operating personnel assign main frame the 1st USB flash disk that Extended Capabilities Port connects are detected and formatting command, and the main frame upper application software sends the order of opening the 1st Extended Capabilities Port by api function and corresponding protocol to control module.
Step 602: control module receives the order that main frame is sent out, and according to the respective protocol resolve command.
Step 603: control module determines that according to the data that resolve command obtains the address of the 1st Extended Capabilities Port that upper application software need be controlled is 001.
Step 604: control module gauge tap module, only the path that 001 Extended Capabilities Port is connected main frame or USB HUB is opened, guarantee that 001 Extended Capabilities Port and main frame or USB HUB are communicated with physically, and other Extended Capabilities Port and main frame or USB HUB are disconnected physically.
Step 605: control module detects the USB flash disk that 001 Extended Capabilities Port is connected, and judges the USB flash disk state, when state just often, directly carry out 606 steps, when Extended Capabilities Port does not have USB flash disk to insert, carry out follow-up 607 steps.
Step 606: control module is returned USB flash disk to main frame and is existed and the normal information of state, direct control step 608 afterwards.
Step 607: control module is returned the information that Extended Capabilities Port does not have USB flash disk to insert to main frame, and the USB flash disk that more renews re-executes similar step to the 2nd Extended Capabilities Port afterwards.
Step 608: receive return message aft engine application software the USB flash disk that 001 Extended Capabilities Port is connected is carried out format manipulation, this USB flash disk format of success back demonstration successful information notifying operation personnel is finished.
In the above-described embodiments, just enumerate USB flash disk is carried out formative operation, can certainly operate other USB interface equipment, and wherein business operation is not limited to just carry out format manipulation, also can reads and writes or the like other business operations USB interface equipment.In embodiment 5-8, can continue operation to next Extended Capabilities Port after the complete operation, begin to carry out in initial step again.
More than to a kind of method provided by the present invention and device, be described in detail, used specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and realizing thought; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.