CN106126446A - A kind of USB device and the method identifying MacOS system thereof - Google Patents

A kind of USB device and the method identifying MacOS system thereof Download PDF

Info

Publication number
CN106126446A
CN106126446A CN201610457589.7A CN201610457589A CN106126446A CN 106126446 A CN106126446 A CN 106126446A CN 201610457589 A CN201610457589 A CN 201610457589A CN 106126446 A CN106126446 A CN 106126446A
Authority
CN
China
Prior art keywords
main frame
descriptor
operating system
order
usb device
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.)
Granted
Application number
CN201610457589.7A
Other languages
Chinese (zh)
Other versions
CN106126446B (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201610457589.7A priority Critical patent/CN106126446B/en
Priority to CN201811305607.5A priority patent/CN109446120B/en
Publication of CN106126446A publication Critical patent/CN106126446A/en
Application granted granted Critical
Publication of CN106126446B publication Critical patent/CN106126446B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/102Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention discloses a kind of USB device and the method identifying MacOS system thereof, belong to USB device field.The method of the USB device identification MacOS system that the present invention provides includes: USB device powers on, receive and respond the order that main frame issues, before USB device receives APDU order, if receiving acquisition configuration descriptor order after first receiving acquisition character string descriptor order, then the type identifying host operating system is MacOS system;If receiving acquisition character string descriptor order after first receiving acquisition configuration descriptor order, then the type identifying host operating system is non-MacOS system.The USB device that the present invention provides includes: receiver module, sending module, the first mark module and the second mark module.The beneficial effects of the present invention is: using the technical scheme that the present invention provides, USB device can identify MacOS system exactly.

Description

A kind of USB device and the method identifying MacOS system thereof
Technical field
The present invention relates to USB device, particularly relate to a kind of USB device and the method identifying MacOS system thereof.
Background technology
Usb protocol technology is the serial bus standard that main frame is connected with external equipment, main frame (such as, personal computer, Personal digital assistant and removable computer etc.) upper use quite varied, support hot plug and plug and play, and supporting bus supplies Electricity, the almost institute such as mouse, keyboard, game paddle, scanner, digital camera, printer, hard disk, safety equipment, CD-ROM drive and network interface card Some ancillary equipment can be connected with main frame by running USB interface and communicate, and USB interface has become as the most mostly The default interface that number host peripheral is connected with computer.
In terms of operating system platform support, MacOS system and non-MacOS system (Windows, Linux etc.) all provide Support to USB interface.USB device, when main frame communicates, needs to accurately distinguish the type of host operating system.
Inventor, during realizing the present invention, finds at least to exist in prior art following defect:
Along with the appearance of redaction operating system, the method for existing USB device identification host operating system can not be accurate Really identify MacOS system.
Summary of the invention
It is an object of the invention to overcome the defect of prior art, it is provided that a kind of USB device and the side of identification MacOS system thereof Method.
The present invention is achieved through the following technical solutions:
On the one hand, the present invention provides a kind of method of USB device identification MacOS system, including:
Step A1, USB device power on;
Step A2, described USB device wait the order that Receiving Host issues;
When receiving the acquisition character string descriptor order that main frame issues, send corresponding character string to main frame and describe Symbol;
When receiving the acquisition configuration descriptor order that main frame issues, send corresponding configuration descriptor to main frame and connect Mouth descriptor;
Described method is additionally included in before described USB device receives APDU order:
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive main frame and issue Acquisition configuration descriptor order, then the type identifying host operating system is MacOS system;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive what main frame issued Obtain character string descriptor order, then the type identifying host operating system is non-MacOS system.
And a kind of USB device corresponding with said method, including:
Receiver module, after described USB device powers on, the order that Receiving Host issues;
Sending module, is used for when described receiver module receives the acquisition character string descriptor order that main frame issues, to Main frame sends corresponding character string descriptor, when described receiver module receives the acquisition configuration descriptor order that main frame issues Time, send corresponding configuration descriptor and interface descriptor to main frame;
First mark module, for before described receiver module receives APDU order, first receives what main frame issued Obtain character string descriptor order, after when receiving the acquisition configuration descriptor order that main frame issues, identify host operating system Type be MacOS system;
Second mark module, for before described receiver module receives APDU order, first receives what main frame issued Obtain configuration descriptor order, after when receiving the acquisition character string descriptor order that main frame issues, identify host operating system Type be non-MacOS system.
On the other hand, the present invention provides again the method for another kind of USB device identification MacOS system, including:
Step B1, USB device power on;
Step B2, described USB device wait the order that Receiving Host issues;
When receiving the acquisition character string descriptor order that main frame issues, send corresponding character string to main frame and describe Symbol;
Described method also includes: when receiving acquisition character string descriptor order after described USB device powers on first, if The a length of predetermined word joint number of acquisition in described acquisition character string descriptor order then identifies the type of host operating system MacOS system, the type otherwise identifying host operating system is non-MacOS system.
And a kind of USB device corresponding with said method, including:
Receiver module, after described USB device powers on, the acquisition character string descriptor order that Receiving Host issues;
Sending module, after described receiver module receives the acquisition character string descriptor order that main frame issues, to master Machine sends corresponding character string descriptor;
First mark module, for receiving acquisition character first when described receiver module after described USB device powers on During string descriptor order, if the acquisition a length of predetermined word joint number in described acquisition character string descriptor order, identify main frame behaviour The type making system is MacOS system, and the type otherwise identifying host operating system is non-MacOS system.
The beneficial effects of the present invention is: using the technical scheme that the present invention provides, USB device can identify exactly MacOS system.
Accompanying drawing explanation
For the clearer explanation embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing In having technology to describe, the required accompanying drawing used is briefly described, it should be apparent that, the accompanying drawing in describing below is only this Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, it is also possible to Other accompanying drawing is obtained according to these accompanying drawings.
The method flow diagram of a kind of USB device identification MacOS system that Fig. 1 provides for the embodiment of the present invention 2;
The structural representation of a kind of USB device that Fig. 2 provides for the embodiment of the present invention 3;
The method flow diagram of a kind of USB device identification MacOS system that Fig. 3 provides for the embodiment of the present invention 5;
The structural representation of a kind of USB device that Fig. 4 provides for the embodiment of the present invention 6.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Describe, it is clear that described embodiment is only a part of embodiment of the present invention rather than whole embodiments wholely.Based on Embodiment in the present invention, the every other enforcement that those skilled in the art are obtained under not making creative work premise Example, broadly falls into the scope of protection of the invention.
Embodiment 1
The present embodiment provides a kind of method of USB device identification MacOS system, including:
Step A1, USB device power on;
Step A2, described USB device wait the order that Receiving Host issues;
When receiving the acquisition character string descriptor order that main frame issues, send corresponding character string to main frame and describe Symbol;
When receiving the acquisition configuration descriptor order that main frame issues, send corresponding configuration descriptor to main frame and connect Mouth descriptor;
Described method is additionally included in before described USB device receives APDU order:
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive main frame and issue Acquisition configuration descriptor order, then the type identifying host operating system is MacOS system;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive what main frame issued Obtain character string descriptor order, then the type identifying host operating system is non-MacOS system.
Further, in the present embodiment:
Described step A1 also includes: the type of described USB device mark host operating system is the unknown;
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive main frame The acquisition configuration descriptor order issued, then the type identifying host operating system is MacOS system, specifically includes: when described When USB device receives the acquisition character string descriptor order that main frame issues, it is judged that whether the type of host operating system is not Knowing, be, the type identifying host operating system is MacOS system, to main frame send corresponding character string descriptor, otherwise to Main frame sends corresponding character string descriptor;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive under main frame The acquisition character string descriptor order sent out, then the type identifying host operating system is non-MacOS system, specifically includes: work as institute State USB device when receiving the acquisition configuration descriptor order that main frame issues, check whether the type of host operating system is not Knowing, be, the type identifying host operating system is non-MacOS system, sends corresponding configuration descriptor to main frame and interface is retouched State symbol, otherwise send corresponding configuration descriptor and interface descriptor to main frame.
Or, described step A1 also includes: described USB device reset the first reception mark and second receives and indicates;
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive main frame The acquisition configuration descriptor order issued, then the type identifying host operating system is MacOS system, specifically includes: when described When USB device receives the acquisition character string descriptor order that main frame issues, described in set, first receives mark, it is judged that described the Two receive whether mark is set, and are then to send corresponding character string descriptor to main frame, otherwise identify host operating system Type is MacOS system, sends corresponding character string descriptor to main frame;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive under main frame The acquisition character string descriptor order sent out, then the type identifying host operating system is non-MacOS system, specifically includes: work as institute Stating USB device when receiving the acquisition configuration descriptor order that main frame issues, described in set, second receives mark, it is judged that described the Whether one mark is set, and is then to send corresponding configuration descriptor and interface descriptor to main frame, otherwise identifies host service function The type of system is non-MacOS system, sends corresponding configuration descriptor and interface descriptor to main frame.
Further, in the present embodiment, the type of mark host operating system is also to include after MacOS system: if institute State and receive first command that main frame issues after USB device powers on for arranging address command, then mark host operating system Version is first to preset version, if described USB device receives the first command that main frame issues after powering on be that acquisition equipment is retouched State symbol order, then identifying the version of host operating system is second to preset version.
Preferably, of the present invention first to preset version be MacOS x10.11, and of the present invention second presets version This is the version of the MacOS issued before MacOS x10.11, including: MacOS x10.6, MacOS x10.7, MacOS X10.8, MacOS x10.9, MacOS x10.10 etc..
Embodiment 2
The present embodiment provides a kind of method of USB device identification MacOS system, as it is shown in figure 1, include:
Step 101, USB device power on;
The type of step 102, USB device mark host operating system is unknown;
Specifically, USB device can identify the type of host operating system by arranging default flag, when pre-bidding When the value of knowledge position is the first preset value, represent that the type of host operating system is unknown;Such as, the first preset value can be 0.
The order that step 103, USB device Receiving Host issue;
Step 104, USB device judge the type of the order received, and then perform if obtaining character string descriptor order Step 105, if obtaining configuration descriptor order then perform step 108, otherwise performs step 111;
Specifically, obtain character string descriptor order and acquisition configuration descriptor order is that main frame is in USB device enumeration mistake Journey uses and controls the order that transmission means issues to USB device.
USB device is with specific reference to the bmRequestType territory (the 1st byte of order) in order and bRequest territory (the 2nd byte of order) judge order type, when bmRequestType territory be 0x80, bRequest territory be GET_ During the encoded radio 0x06 of DESCRIPTOR, USB device judges to order and (includes that obtaining USB device describes as obtaining descriptor order Symbol is ordered, acquisition configures descriptor order, obtain character string descriptor order, obtain interface descriptor order, acquisition end points is retouched State symbol order, obtain hub class descriptor order, acquisition man-machine interface class descriptor order etc.).
According to the wValue territory in order, (a length of 2 bytes are specially the 3rd, the 4th of order to USB device further Byte) high byte judge obtain descriptor order particular type, when the high byte (the 3rd byte of order) in wValue territory During for 0x03, USB device judges that obtaining descriptor order is specially acquisition character string descriptor order, when the high word in wValue territory When joint is for 0x02, USB device judges that obtaining descriptor order specially obtains configuration descriptor order.
Step 105, USB device judge whether the type of host operating system is unknown, is then to perform step 106, otherwise Perform step 107;
Specifically, USB device can identify the type of host operating system by arranging default flag, when pre-bidding When the value of knowledge position is the first preset value, represent that the type of host operating system is unknown;Correspondingly, USB device judges main frame Whether the type of operating system is unknown, can be particularly as follows: whether USB device judges to preset the value of flag is first to preset Value, is that the type of then host operating system is the unknown, and otherwise the type of host operating system is not unknown;Such as, first preset Value can be 0.
The type of step 106, USB device mark host operating system is MacOS system, performs step 107;
Specifically, USB device can identify the type of host operating system by arranging default flag, when pre-bidding When the value of knowledge position is the second preset value, represent that the type of host operating system is MacOS system;Such as second preset value is permissible For MacOS.
Step 107, USB device send corresponding character string descriptor to main frame, return step 103;
Specifically, main frame is by obtaining wValue territory (a length of 2 bytes, the acquisition character in character string descriptor order The 3rd of string descriptor order, the 4th byte) low byte the 3rd byte of character string descriptor order (obtain) designated word Symbol string descriptor index;Step 107 is particularly as follows: USB device is according to the character string descriptor obtained in character string descriptor order Index and send corresponding character string descriptor to main frame.
Further, USB device sends to main frame according to obtaining character string descriptor index in character string descriptor order Corresponding character string descriptor, specifically includes:
When character string descriptor index is for 0x00, USB device sends the character string descriptor of representation language ID to main frame;
When character string descriptor index is not 0x00, USB device sends the character string representing string encoding to main frame Descriptor;Such as, when character string descriptor index is for 0x01, USB device sends the character string representing trade name to main frame Descriptor;When character string descriptor index is for 0x02, USB device sends to main frame and represents that the character string of USB device title is retouched State symbol etc..
Specifically, the form of character string descriptor is+bStrings territory ,+bDescriptorType territory, bLength territory, its In:
The size in bLength territory is 1 byte, is worth for numeral, the length of expression descriptor;
The size in bDescriptorType territory is 1 byte, is worth for 0x03, represents that the type of descriptor is that character string is retouched State symbol;
The size in bStrings territory is N number of byte, is worth for numeral, is used for describing information;The character of representation language ID describes The bStrings territory of string is specially the array of double byte language ID: wLANGID [0]~wLANGID [x], representation language identification code 0 ~language identification code x, for describing the language that equipment is supported;Represent the bStrings territory of the character string descriptor of string encoding It is specially the character string of UNICODE coding, is used for describing the information such as trade name, device name or serial number.
Step 108, USB device judge whether the type of host operating system is unknown, is then to perform step 109, otherwise Perform step 110;
Specifically, USB device can identify the type of host operating system by arranging default flag, when pre-bidding When the value of knowledge position is the first preset value, represent that the type of host operating system is unknown;Correspondingly, USB device judges main frame Whether the type of operating system is unknown, can be particularly as follows: whether USB device judges to preset the value of flag is first to preset Value, is that the type of then host operating system is the unknown, and otherwise the type of host operating system is not unknown;Such as, first preset Value can be 0.
The type of step 109, USB device mark host operating system is non-MacOS system, performs step 110;
Specifically, USB device can identify the type of host operating system by arranging default flag, when pre-bidding When the value of knowledge position is three preset value, represent that the type of host operating system is non-MacOS system;Such as the 3rd preset value can Think else.
Step 110, USB device send corresponding configuration descriptor and interface descriptor to main frame, return step 103;
In the present embodiment, USB device sends corresponding configuration descriptor to main frame and interface descriptor can specifically include:
Step 1-1, USB device judge the type of host operating system, if MacOS system then performs step 1-2, if Non-MacOS system then performs step 1-3;
Further, if the type of host operating system is unknown, then performs step 1-2 or perform step 1-3;
Step 1-2, USB device judge that whether the acquisition length obtaining in configuration descriptor order is more than configuration descriptor Length, is then to send preset configuration descriptor and the first preset interface descriptor to main frame, otherwise sends preset configuration to main frame The top n byte of descriptor, N is equal to described acquisition length;
Preferably, a length of 9 bytes of descriptor are configured;
Such as, obtain a length of 4 bytes, then front 4 bytes of preset configuration descriptor are returned to main frame.
Step 1-3, USB device judge that whether the acquisition length obtaining in configuration descriptor order is more than configuration descriptor Length, is then to send preset configuration descriptor and the second preset interface descriptor to main frame, otherwise sends preset configuration to main frame The top n byte of descriptor, N is equal to described acquisition length;
Such as, obtain a length of 9 bytes, then preset configuration descriptor is returned to main frame.
Specifically, the first preset interface descriptor is different from the second preset interface descriptor;
Preferably, the first preset interface descriptor is smart card class interface descriptor, the i.e. first preset interface descriptor BInterfaceClass territory is 0x0B;Second preset interface descriptor is that big data store class interface descriptor, and i.e. second presets The bInterfaceClass territory of interface descriptor is 0x08.
Further, when the type of host operating system is MacOS system, step 110 can also include USB device CCID class descriptor is sent to main frame;
Further, when the type of host operating system is MacOS system, if the first preset interface descriptor is retouched The end points that the interface stated uses is not only end points 0, then also include in step 110 that USB device is to host sending end point descriptor;When USB device judges when the type of host operating system is non-MacOS system, if the interface described by the second preset interface descriptor The end points used is not only end points 0, then also include in step 110 that USB device is to host sending end point descriptor.
Such as, when the type of host operating system is MacOS system, USB device returns to main frame:
0x 09 02 56 00 01 01 00 80 19//configuration descriptor
0x 09 04 00 00 02 0B 00 00 00//interface descriptor
0x 36 21 10 01 00 01 02 00 00 00 FC 0D 00 00 FC 0D 00 00 00 80 25 00 00 80 25 00 00 00 20 10 00 00 00 00 00 00 00 00 00 00 40 08 04 00 20 10 00 00 FF FF 00 00 00 01//CCID class descriptor
0x 07 05 81 02 40 00 00//endpoint descriptor
0x 07 05 02 02 40 00 00//endpoint descriptor
When the type of host operating system is non-MacOS system, USB device returns to main frame:
0x 09 02 20 00 01 01 00 80 19//configuration descriptor
0x 09 04 00 00 02 08 06 50 00//interface descriptor
0x 07 05 81 02 40 00 00//endpoint descriptor
0x 07 05 02 02 40 00 00//endpoint descriptor
Step 111, USB device perform corresponding operating according to the order received, and return step 103.
Preferably, USB device can perform grasp corresponding with the order received according to the type of host operating system Make.
In the present embodiment, USB device sends corresponding configuration descriptor to main frame and interface descriptor can also specifically be wrapped Include: USB device sends preset configuration descriptor and the 3rd preset interface descriptor to main frame;Preferably, the 3rd preset interface is retouched Stating symbol is smart card class interface descriptor, and the bInterfaceClass territory of the i.e. the 3rd preset interface descriptor is 0x0B, further Ground, can also include in step 110 that USB device sends CCID class descriptor to main frame;Further, when the 3rd preset interface When the end points that interface described by descriptor uses is not only end points 0, step 110 also including, USB device is to host sending end Point descriptor;
Correspondingly, step 104 also includes: if USB device judges that the order received is APDU order, then perform described APDU order, according to performing result tissue reply data, it is judged that whether the length of reply data exceedes and host operating system The default maximum packet length that type is corresponding, is that according to described default maximum packet length subpackage, reply data is sent to main frame, Otherwise reply data is sent to main frame;Specifically, when the type of host operating system is MacOS system, preset maximum bag A length of preset length, such as 261 bytes, when the type of host operating system is non-MacOS system, preset maximum bag long Degree is equal to the size of the preset buffer memory of USB device, such as 1024 bytes.
In the technical scheme of the present embodiment, the order that main frame is issued by USB device resolves, and current to USB device Judging the mark of the type of host operating system, type and the USB device of the order issued according to main frame are the most right The mark of host operating system type, determines the type of host operating system.
Further, the method described in the present embodiment can also include:
When the first command that the main frame received after USB device powers on issues is for arranging address command, version is set It is designated the first preset value;
When the first command that the main frame received after USB device powers on issues is for obtaining device descriptor order, if Putting version identifier is the second preset value;
Correspondingly, also include after step 106: USB device checks version identifier, if the first preset value then identifies main frame The version of operating system is first to preset version, if it is second to preset that the second preset value then identifies the version of host operating system Version;
Wherein, other values outside the initial value of version identifier is the first preset value and the second preset value;
In the present embodiment, such as, arranging address instruction is 0x 00 05 XX XX 00 00 00 00;Acquisition equipment describes Symbol order is 0x 80 06 00 01 00 00 XX XX.
Embodiment 3
The present embodiment provides a kind of USB device, as in figure 2 it is shown, include:
Receiver module 301, after USB device powers on, the order that Receiving Host issues;
Sending module 302, is used for when receiver module 301 receives the acquisition character string descriptor order that main frame issues, Corresponding character string descriptor is sent, when receiver module 301 receives the acquisition configuration descriptor order that main frame issues to main frame Time, send corresponding configuration descriptor and interface descriptor to main frame;
First mark module 303, for before receiver module 301 receives APDU order, first receives main frame and issues Acquisition character string descriptor order, after when receiving the acquisition configuration descriptor order that main frame issues, identify host service function system The type of system is MacOS system;
Second mark module 304, for obtaining of first receiving before receiver module 301 receives APDU order that main frame issues Take configuration descriptor order, after when receiving the acquisition character string descriptor order that main frame issues, mark host operating system Type is non-MacOS system.
Further, the USB device described in the present embodiment can also include:
3rd mark module 305, is MacOS system for identifying the type of host operating system in the first mark module 303 After system, if the first command that the main frame that receiver module 301 receives after USB device powers on issues is for arranging address life Order, then identifying the version of host operating system is first to preset version;
4th mark module 306, is MacOS system for identifying the type of host operating system in the first mark module 303 After system, describe if the first command that the main frame that receiver module 301 receives after USB device powers on issues is acquisition equipment Symbol order, then identifying the version of host operating system is second to preset version.
Specifically, the USB device described in the present embodiment, also include: the 5th mark module, after USB device powers on, mark The type knowing host operating system is unknown;Correspondingly:
First mark module 303 specifically includes:
First judging unit, is used for when receiver module 301 receives the acquisition character string descriptor order that main frame issues, Whether the type judging host operating system is unknown;
First mark unit, for judging that when the first judging unit the type of host operating system, as time unknown, identifies main The type of machine operating system is MacOS system;
Second mark module 304 specifically includes:
Second judging unit, for when receiver module 301 receives the acquisition configuration descriptor order that main frame issues, sentencing Whether the type of disconnected host operating system is unknown;
Second mark unit, for judging that when the second judging unit the type of host operating system, as time unknown, identifies main The type of machine operating system is non-MacOS system.
Further, USB device also includes: module is set, for being followed by when receiver module 301 powers at USB device When the first command that the main frame received issues is for arranging address command, arranging version identifier is the first preset value;When receiving mould When the first command that the main frame that block 301 receives after USB device powers on issues is for obtaining device descriptor order, version is set Originally the second preset value it is designated;Correspondingly, the first mark unit is additionally operable to: check version identifier, if version identifier is first pre- If value, then identifying the version of host operating system is first to preset version, if version identifier is the second preset value, then identifies main frame The version of operating system is second to preset version.
Or, the USB device described in the present embodiment, also include: reseting module, after USB device powers on, reset first Receive mark and second and receive mark;Correspondingly:
First mark module 303 specifically includes:
First judging unit, is used for when receiver module 301 receives the acquisition character string descriptor order that main frame issues, Set first receives mark, it is judged that second receives whether mark is set;
First mark unit, for when the first judging unit judges that the second reception mark is not set, mark main frame is grasped The type making system is MacOS system;
Second mark module 304 specifically includes:
Second judging unit, for when receiver module 301 receives the acquisition configuration descriptor order that main frame issues, putting Position second receives mark, it is judged that first receives whether mark is set;
Second mark unit, for when the second judging unit judges that the first reception mark is not set, mark main frame is grasped The type making system is non-MacOS system.
Specifically, in the present embodiment, sending module 302 can be specifically for: issues when receiver module 301 receives main frame Acquisition configuration descriptor order time, it is judged that the type of host operating system, if MacOS system then to main frame send pre-establishing Put descriptor and the first preset interface descriptor, if non-MacOS system then sends preset configuration descriptor and difference to main frame In the first the second preset interface descriptor presetting descriptor.
Or, sending module 302 specifically for: when receiver module 301 receives the acquisition configuration descriptor that main frame issues During order, send preset configuration descriptor and the 3rd preset interface descriptor to main frame;
Further, receiver module 301 is additionally operable to: the APDU order that Receiving Host issues;USB device also includes: hold Row module, for when receiver module 301 receives the APDU order that main frame issues, performs what receiver module 301 received APDU order, according to performing result tissue reply data, it is judged that whether the length of reply data exceedes and host operating system The default maximum packet length that type is corresponding, is that according to described default maximum packet length subpackage, reply data is sent to main frame, Otherwise reply data is sent to main frame.
Embodiment 4
The present embodiment provides a kind of method of USB device identification MacOS system, including:
Step B1, USB device power on;
Step B2, described USB device wait the order that Receiving Host issues;
When receiving the acquisition character string descriptor order that main frame issues, send corresponding character string to main frame and describe Symbol;
Described method also includes: when receiving acquisition character string descriptor order after described USB device powers on first, if The a length of predetermined word joint number of acquisition in described acquisition character string descriptor order then identifies the type of host operating system MacOS system, the type otherwise identifying host operating system is non-MacOS system.
Further, in the present embodiment:
Described step B1 also includes: the type of described USB device mark host operating system is the unknown;
Described when receiving acquisition character string descriptor order after described USB device powers on first, if described acquisition word It is MacOS system that a length of predetermined word joint number of acquisition in symbol string descriptor order then identifies the type of host operating system, no The type then identifying host operating system is non-MacOS system, specifically includes:
Step 1-1, when described USB device receives the acquisition character string descriptor order that main frame issues, check main frame Whether the type of operating system is unknown, is then to perform step 1-2, otherwise sends corresponding character string descriptor to main frame;
Step 1-2, described USB device judge whether the acquisition length obtaining in character string descriptor order is to preset byte Number, is that the type identifying host operating system is MacOS system, and the type otherwise identifying host operating system is non-MacOS System.
Or, described step B1 also includes: described USB device resets and receives mark;
Described when receiving acquisition character string descriptor order after described USB device powers on first, if described acquisition word It is MacOS system that a length of predetermined word joint number of acquisition in symbol string descriptor order then identifies the type of host operating system, no The type then identifying host operating system is non-MacOS system, specifically includes:
Step 2-1, when described USB device receives the acquisition character string descriptor order that main frame issues, check described Receive mark, if described reception mark is not set, receives mark described in set, perform step 2-2;
Step 2-2, described USB device judge whether the acquisition length obtaining in character string descriptor order is to preset byte Number, is that the type identifying host operating system is MacOS system, and the type otherwise identifying host operating system is non-MacOS System.
Further, in the present embodiment, the type of mark host operating system is also to include after MacOS system: if institute State and receive first command that main frame issues after USB device powers on for arranging address command, then mark host operating system Version is first to preset version, if described USB device receives the first command that main frame issues after powering on be that acquisition equipment is retouched State symbol order, then identifying the version of host operating system is second to preset version.
Embodiment 5
The present embodiment provides a kind of method of USB device identification MacOS system, as it is shown on figure 3, include:
Step 201, USB device power on;
The type of step 202, USB device mark host operating system is unknown;
The order that step 203, USB device Receiving Host issue;
Step 204, USB device judge the type of the order received, and then perform if obtaining character string descriptor order Step 206, otherwise performs step 205;
Step 205, USB device perform corresponding operating according to the order received, and return step 203;
Preferably, USB device can perform grasp corresponding with the order received according to the type of host operating system Make.
Step 206, USB device judge whether the type of host operating system is unknown, is then to perform step 207, otherwise Perform step 210;
Step 207, USB device judge whether the acquisition length obtained in character string descriptor order is predetermined word joint number, It is then to perform step 208, otherwise performs step 209;
Specifically, the 7th byte obtaining character string descriptor order is acquisition length, and predetermined word joint number is 2 bytes.
The type of step 208, USB device mark host operating system is MacOS system, performs step 210;
The type of step 209, USB device mark host operating system is non-MacOS system, performs step 210;
Step 210, USB device send corresponding character string descriptor to main frame, return step 203.
Further, step 204 can also include: if USB device judges that the order received describes as obtaining configuration Symbol order, then send corresponding configuration descriptor and interface descriptor to main frame, return step 203.
In the present embodiment, USB device sends corresponding configuration descriptor to main frame and interface descriptor can specifically include:
Step a, USB device judge the type of host operating system, if MacOS system then performs step b, if non- MacOS system then performs step c;
Further, if the type of host operating system is unknown, then performs step b or perform step c;
Step b, USB device judge that whether the acquisition length obtaining in configuration descriptor order is more than the length configuring descriptor Degree, is then to send preset configuration descriptor and the first preset interface descriptor to main frame, otherwise sends preset configuration to main frame and retouch Stating the top n byte of symbol, N is equal to described acquisition length;
Preferably, a length of 9 bytes of descriptor are configured;
Such as, obtain a length of 4 bytes, then front 4 bytes of preset configuration descriptor are returned to main frame.
Step c, USB device judge that whether the acquisition length obtaining in configuration descriptor order is more than the length configuring descriptor Degree, is then to send preset configuration descriptor and the second preset interface descriptor to main frame, otherwise sends preset configuration to main frame and retouch Stating the top n byte of symbol, N is equal to described acquisition length;
Such as, obtain a length of 9 bytes, then preset configuration descriptor is returned to main frame.
Specifically, the first preset interface descriptor is different from the second preset interface descriptor;
Preferably, the first preset interface descriptor is smart card class interface descriptor, the i.e. first preset interface descriptor BInterfaceClass territory is 0x0B;Second preset interface descriptor is that big data store class interface descriptor, and i.e. second presets The bInterfaceClass territory of interface descriptor is 0x08.
Further, when the type of host operating system is MacOS system, USB device sends to main frame joins accordingly Can also include when putting descriptor and interface descriptor that USB device sends CCID class descriptor to main frame;
Further, when the type of host operating system is MacOS system, if the first preset interface descriptor is retouched The end points that the interface stated uses is not only end points 0, then USB device sends corresponding configuration descriptor and interface descriptor to main frame Time also include that USB device is to host sending end point descriptor;When USB device judges that the type of host operating system is non-MacOS During system, if the end points that interface described by the second preset interface descriptor uses is not only end points 0, then step USB device to Main frame also includes that USB device is to host sending end point descriptor when sending corresponding configuration descriptor and interface descriptor.
Or USB device sends corresponding configuration descriptor to main frame and interface descriptor specifically includes: USB device is to master Machine sends preset configuration descriptor and the 3rd preset interface descriptor;Preferably, the 3rd preset interface descriptor is smart card class Interface descriptor, the bInterfaceClass territory of the i.e. the 3rd preset interface descriptor is 0x0B, and further, USB device is to master Machine can also include that USB device sends CCID class descriptor to main frame when sending corresponding configuration descriptor and interface descriptor; Further, when described by the 3rd preset interface descriptor interface use end points not be only end points 0 time, USB device to Main frame also includes that USB device is to host sending end point descriptor when sending corresponding configuration descriptor and interface descriptor;;
Correspondingly, step 204 also includes: if USB device judges that the order received is APDU order, then perform described APDU order, according to performing result tissue reply data, it is judged that whether the length of reply data exceedes and host operating system The default maximum packet length that type is corresponding, is that according to described default maximum packet length subpackage, reply data is sent to main frame, Otherwise reply data is sent to main frame;Specifically, when the type of host operating system is MacOS system, preset maximum bag A length of preset length, such as 261 bytes, when the type of host operating system is non-MacOS system, preset maximum bag long Degree is equal to the size of the preset buffer memory of USB device, such as 1024 bytes.
In the technical scheme of the present embodiment, the order that main frame is issued by USB device resolves, and current to USB device The mark of the type of host operating system is judged, the acquisition length in the type of the order issued according to main frame, order And USB device currently mark to host operating system type, determine the type of host operating system.
Further, the method described in the present embodiment can also include:
When the first command that the main frame received after USB device powers on issues is for arranging address command, version is set It is designated the first preset value;
When the first command that the main frame received after USB device powers on issues is for obtaining device descriptor order, if Putting version identifier is the second preset value;
Correspondingly, also include after step 208: USB device checks version identifier, if the first preset value then identifies main frame The version of operating system is first to preset version, if it is second to preset that the second preset value then identifies the version of host operating system Version;
Wherein, other values outside the initial value of version identifier is the first preset value and the second preset value;
In the present embodiment, such as, arranging address instruction is 0x 00 05 XX XX 00 00 00 00;Acquisition equipment describes Symbol order is 0x 80 06 00 01 00 00 XX XX.
Embodiment 6
A kind of USB device of the present embodiment offer, as shown in Figure 4, including:
Receiver module 401, after USB device powers on, the acquisition character string descriptor order that Receiving Host issues;
Sending module 402, is used for after receiver module 401 receives the acquisition character string descriptor order that main frame issues, Corresponding character string descriptor is sent to main frame;
First mark module 403, for receiving acquisition character string first when receiver module 401 after USB device powers on During descriptor order, if the acquisition a length of predetermined word joint number obtained in character string descriptor order, identify host operating system Type be MacOS system, the type otherwise identifying host operating system is non-MacOS system.
Further, the USB device described in the present embodiment can also include:
Second mark module 404, is MacOS system for identifying the type of host operating system in the first mark module 403 After system, if the first command that the main frame that receiver module 401 receives after USB device powers on issues is for arranging address life Order, then identifying the version of host operating system is first to preset version;
3rd mark module 405, the type identifying host operating system for the first mark module 403 is MacOS system Afterwards, if the first command that the main frame that receiver module 401 receives after USB device powers on issues is acquisition device descriptor Order, then identifying the version of host operating system is second to preset version.
Specifically, the USB device described in the present embodiment, also include: the 4th mark module, be used for after USB device powers on, The type of mark host operating system is unknown;Correspondingly, the first mark module 403 specifically includes:
Judging unit, for when receiver module 401 receives the acquisition character string descriptor order that main frame issues, it is judged that Whether the type of host operating system is unknown;
Mark unit, for judging that when judging unit the type of host operating system is as time unknown, it is judged that receiver module 401 Whether the acquisition length obtained in character string descriptor order received is predetermined word joint number, is to identify host operating system Type be MacOS system, the type otherwise identifying host operating system is non-MacOS system.
Further, USB device also includes: module is set, for being followed by when receiver module 401 powers at USB device When the first command that the main frame received issues is for arranging address command, arranging version identifier is the first preset value;When receiving mould When the first command that the main frame that block 401 receives after USB device powers on issues is for obtaining device descriptor order, version is set Originally the second preset value it is designated;Correspondingly, mark unit is additionally operable to: check version identifier, if version identifier is the first preset value, Then identifying the version of host operating system is first to preset version, if version identifier is the second preset value, then identifies host service function The version of system is second to preset version.
Or, the USB device described in the present embodiment, also include: reseting module, after USB device powers on, reset and receive Mark;Correspondingly, the first mark module 403 specifically includes:
Judging unit, for when receiver module 401 receives the acquisition character string descriptor order that main frame issues, it is judged that Receive whether mark is set;
Mark unit, for when judging unit judges that receiving mark is not set, it is judged that receiver module 401 receives Whether the acquisition length obtained in character string descriptor order is predetermined word joint number, is that the type identifying host operating system is MacOS system, the type otherwise identifying host operating system is non-MacOS system.
In the present embodiment, receiver module 401 is additionally operable to: the acquisition configuration descriptor order that Receiving Host issues;Correspondingly, Sending module 402 is additionally operable to: when receiver module 401 receives the acquisition configuration descriptor order that main frame issues, send out to main frame Send corresponding configuration descriptor and interface descriptor;
Further, sending module 402 specifically for: retouch when receiver module 401 receives the acquisition configuration that main frame issues When stating symbol order, it is judged that the type of host operating system, if MacOS system then sends preset configuration descriptor and the to main frame One preset interface descriptor, if non-MacOS system then sends preset configuration descriptor to main frame and is different from described first pre- If the second preset interface descriptor of descriptor;
Or, sending module 402 specifically for: when receiver module 401 receives the acquisition configuration descriptor that main frame issues During order, send preset configuration descriptor and the 3rd preset interface descriptor to main frame;Correspondingly, receiver module 401 is additionally operable to: The APDU order that Receiving Host issues;USB device also includes: perform module, for issuing when receiver module 401 receives main frame APDU order time, perform the APDU order that receives of receiver module 401, according to performing result tissue reply data, it is judged that answer Whether the length of answer evidence exceedes the default maximum packet length corresponding with the type of host operating system, be then by reply data by It is sent to main frame according to default maximum packet length subpackage, otherwise reply data is sent to main frame.
Embodiment described above is the present invention more preferably detailed description of the invention, and those skilled in the art is at this The usual variations and alternatives carried out in the range of bright technical scheme all should comprise within the scope of the present invention.

Claims (34)

1. the method for a USB device identification MacOS system, it is characterised in that including:
Step A1, USB device power on;
Step A2, described USB device wait the order that Receiving Host issues;
When receiving the acquisition character string descriptor order that main frame issues, send corresponding character string descriptor to main frame;
When receiving the acquisition configuration descriptor order that main frame issues, send corresponding configuration descriptor to main frame and interface is retouched State symbol;
Described method is additionally included in before described USB device receives APDU order:
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive that main frame issues obtain Take configuration descriptor order, then the type identifying host operating system is MacOS system;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive the acquisition that main frame issues Character string descriptor order, then the type identifying host operating system is non-MacOS system.
2. the method for claim 1, it is characterised in that also include: the type of described mark host operating system is After MacOS system, if described USB device receives first command that main frame issues for arranging address command after powering on, then The version of mark host operating system is first to preset version, if described USB device receives first that main frame issues after powering on Bar order is for obtaining device descriptor order, then identifying the version of host operating system is second to preset version.
3. the method for claim 1, it is characterised in that:
Described step A1 also includes: the type of described USB device mark host operating system is the unknown;
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive main frame and issue Acquisition configuration descriptor order, then the type identifying host operating system is MacOS system, specifically includes: when described USB sets Standby when receiving the acquisition character string descriptor order that main frame issues, it is judged that whether the type of host operating system is unknown, is The type then identifying host operating system is MacOS system, sends corresponding character string descriptor to main frame, otherwise sends out to main frame Send corresponding character string descriptor;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive what main frame issued Obtain character string descriptor order, then the type identifying host operating system is non-MacOS system, specifically includes: as described USB When equipment receives the acquisition configuration descriptor order that main frame issues, check whether the type of host operating system is unknown, be The type then identifying host operating system is non-MacOS system, sends corresponding configuration descriptor and interface descriptor to main frame, Otherwise send corresponding configuration descriptor and interface descriptor to main frame.
4. method as claimed in claim 3, it is characterised in that also include:
When the first command that the main frame received after described USB device powers on issues is for arranging address command, version is set It is designated the first preset value;
When the first command that the main frame received after described USB device powers on issues is for obtaining device descriptor order, if Putting version identifier is the second preset value;
The type of described mark host operating system is also to include after MacOS system: described USB device checks described version mark Knowing, if described version identifier is described first preset value, identifying the version of host operating system is first to preset version, if institute Stating version identifier is that then to identify the version of host operating system be second to preset version to described second preset value.
5. the method for claim 1, it is characterised in that:
Described step A1 also includes: described USB device reset the first reception mark and second receives and indicates;
If described USB device first receives the acquisition character string descriptor order that main frame issues, after receive main frame and issue Acquisition configuration descriptor order, then the type identifying host operating system is MacOS system, specifically includes: when described USB sets Standby when receiving the acquisition character string descriptor order that main frame issues, described in set, first receives mark, it is judged that described second connects Receive whether mark is set, be then to send corresponding character string descriptor to main frame, otherwise identify the type of host operating system For MacOS system, send corresponding character string descriptor to main frame;
If described USB device first receives the acquisition configuration descriptor order that main frame issues, after receive what main frame issued Obtain character string descriptor order, then the type identifying host operating system is non-MacOS system, specifically includes: as described USB When equipment receives the acquisition configuration descriptor order that main frame issues, described in set, second receives mark, it is judged that described first connects Receive whether mark is set, be then to send corresponding configuration descriptor and interface descriptor to main frame, otherwise identify host service function The type of system is non-MacOS system, sends corresponding configuration descriptor and interface descriptor to main frame.
6. the method for claim 1, it is characterised in that described send corresponding configuration descriptor to main frame and interface is retouched State symbol, specifically include: judge the type of host operating system, if MacOS system then sends preset configuration descriptor to main frame With the first preset interface descriptor, if non-MacOS system then sends preset configuration descriptor and the second preset interface to main frame Descriptor, described first preset interface descriptor is different from described second interface descriptor.
7. the method for claim 1, it is characterised in that described send corresponding configuration descriptor to main frame and interface is retouched State symbol, specifically include: described USB device sends preset configuration descriptor and the 3rd preset interface descriptor to main frame.
8. method as claimed in claim 7, it is characterised in that described step A2 also includes: when described USB device Receiving Host During the APDU order issued, perform described APDU order, and according to performing result tissue reply data, it is judged that described reply data Length whether exceed the default maximum packet length corresponding with the type of host operating system, be then by described reply data according to Described default maximum packet length subpackage is sent to main frame, otherwise described reply data is sent to main frame.
9. a USB device, it is characterised in that including:
Receiver module, after described USB device powers on, the order that Receiving Host issues;
Sending module, for when described receiver module receives the acquisition character string descriptor order that main frame issues, to main frame Send corresponding character string descriptor, when described receiver module receives the acquisition configuration descriptor order that main frame issues, to Main frame sends corresponding configuration descriptor and interface descriptor;
First mark module, for before described receiver module receives APDU order, first receives the acquisition that main frame issues Character string descriptor order, after when receiving the acquisition configuration descriptor order that main frame issues, the class of mark host operating system Type is MacOS system;
Second mark module, for before described receiver module receives APDU order, first receives the acquisition that main frame issues Configuration descriptor order, after when receiving the acquisition character string descriptor order that main frame issues, the class of mark host operating system Type is non-MacOS system.
10. USB device as claimed in claim 9, it is characterised in that also include:
3rd mark module, after the type of described first mark module id host operating system is MacOS system, if The first command that the main frame that described receiver module receives after described USB device powers on issues is for arranging address command, then The version of mark host operating system is first to preset version;
4th mark module, after the type of described first mark module id host operating system is MacOS system, if The first command that the main frame that described receiver module receives after described USB device powers on issues is for obtaining device descriptor life Order, then identifying the version of host operating system is second to preset version.
11. USB devices as claimed in claim 9, it is characterised in that also include: the 5th mark module, set for described USB After powering on, the type of mark host operating system is unknown;
Described first mark module specifically includes:
First judging unit, for when described receiver module receives the acquisition character string descriptor order that main frame issues, sentences Whether the type of disconnected host operating system is unknown;
First mark unit, for judging that when described first judging unit the type of host operating system, as time unknown, identifies main The type of machine operating system is MacOS system;
Described second mark module specifically includes:
Second judging unit, for when described receiver module receives the acquisition configuration descriptor order that main frame issues, it is judged that Whether the type of host operating system is unknown;
Second mark unit, for judging that when described second judging unit the type of host operating system, as time unknown, identifies main The type of machine operating system is non-MacOS system.
12. USB devices as claimed in claim 11, it is characterised in that also include:
Module is set, the Article 1 life that the main frame for receiving after described USB device powers on when described receiver module issues When order is for arranging address command, arranging version identifier is the first preset value;When described receiver module is after described USB device powers on When the first command that the main frame received issues is for obtaining device descriptor order, arranging version identifier is the second preset value;
Described first mark unit is additionally operable to: checks version identifier, if described version identifier is described first preset value, then identifies The version of host operating system is first to preset version, if described version identifier is described second preset value, then and mark main frame behaviour Making the version of system is second to preset version.
13. USB devices as claimed in claim 9, it is characterised in that also include: reseting module, for described USB device After electricity, the first reception mark and second that resets receives mark;
Described first mark module specifically includes:
First judging unit, for when described receiver module receives the acquisition character string descriptor order that main frame issues, puts Position described first receives mark, it is judged that described second receives whether mark is set;
First mark unit, for when described first judging unit judges that described second reception mark is not set, mark is main The type of machine operating system is MacOS system;
Described second mark module specifically includes:
Second judging unit, is used for when described receiver module receives the acquisition configuration descriptor order that main frame issues, set Described second receives mark, it is judged that described first receives whether mark is set;
Second mark unit, for when described second judging unit judges that described first reception mark is not set, mark is main The type of machine operating system is non-MacOS system.
14. USB devices as claimed in claim 9, it is characterised in that described sending module specifically for: when described reception mould When block receives the acquisition configuration descriptor order that main frame issues, it is judged that the type of host operating system, if MacOS system is then Send preset configuration descriptor and the first preset interface descriptor to main frame, preset if non-MacOS system then sends to main frame Configure descriptor and be different from the described first the second preset interface descriptor presetting descriptor.
15. USB devices as claimed in claim 9, it is characterised in that described sending module specifically for: when described reception mould When block receives the acquisition configuration descriptor order that main frame issues, send preset configuration descriptor and the 3rd preset interface to main frame Descriptor.
16. USB devices as claimed in claim 15, it is characterised in that:
Described receiver module is additionally operable to: the APDU order that Receiving Host issues;
Described USB device also includes: perform module, is used for when described receiver module receives the APDU order that main frame issues, Perform the APDU order that described receiver module receives, according to performing result tissue reply data, it is judged that described reply data Whether length exceedes the default maximum packet length corresponding with the type of host operating system, be then by described reply data according to institute State default maximum packet length subpackage and be sent to main frame, otherwise described reply data is sent to main frame.
The method of 17. 1 kinds of USB device identification MacOS systems, it is characterised in that including:
Step B1, USB device power on;
Step B2, described USB device wait the order that Receiving Host issues;
When receiving the acquisition character string descriptor order that main frame issues, send corresponding character string descriptor to main frame;
Described method also includes: when receiving acquisition character string descriptor order after described USB device powers on first, if described It is MacOS system that a length of predetermined word joint number of acquisition in acquisition character string descriptor order then identifies the type of host operating system System, the type otherwise identifying host operating system is non-MacOS system.
18. methods as claimed in claim 17, it is characterised in that also include: the type of described mark host operating system is After MacOS system, if described USB device receives first command that main frame issues for arranging address command after powering on, then The version of mark host operating system is first to preset version, if described USB device receives first that main frame issues after powering on Bar order is for obtaining device descriptor order, then identifying the version of host operating system is second to preset version.
19. methods as claimed in claim 17, it is characterised in that:
Described step B1 also includes: the type of described USB device mark host operating system is the unknown;
Described when receiving acquisition character string descriptor order after described USB device powers on first, if described acquisition character string It is MacOS system that a length of predetermined word joint number of acquisition in descriptor order then identifies the type of host operating system, otherwise marks The type knowing host operating system is non-MacOS system, specifically includes:
Step 1-1, when described USB device receives the acquisition character string descriptor order that main frame issues, check host service function Whether the type of system is unknown, is then to perform step 1-2, otherwise sends corresponding character string descriptor to main frame;
Step 1-2, described USB device judge whether the acquisition length obtained in character string descriptor order is predetermined word joint number, Being that the type identifying host operating system is MacOS system, the type otherwise identifying host operating system is non-MacOS system System.
20. methods as claimed in claim 19, it is characterised in that also include:
When the first command that the main frame received after described USB device powers on issues is for arranging address command, version is set It is designated the first preset value;
When the first command that the main frame received after described USB device powers on issues is for obtaining device descriptor order, if Putting version identifier is the second preset value;
The type of described mark host operating system is also to include after MacOS system: described USB device checks described version mark Knowing, if described version identifier is described first preset value, identifying the version of host operating system is first to preset version, if institute Stating version identifier is that then to identify the version of host operating system be second to preset version to described second preset value.
21. methods as claimed in claim 17, it is characterised in that:
Described step B1 also includes: described USB device resets and receives mark;
Described when receiving acquisition character string descriptor order after described USB device powers on first, if described acquisition character string It is MacOS system that a length of predetermined word joint number of acquisition in descriptor order then identifies the type of host operating system, otherwise marks The type knowing host operating system is non-MacOS system, specifically includes:
Step 2-1, when described USB device receives the acquisition character string descriptor order that main frame issues, check described reception Mark is set the most, is then to send corresponding character string descriptor to main frame, otherwise performs step 2-2;
Step 2-2, described USB device judge whether the acquisition length obtained in character string descriptor order is predetermined word joint number, It is that mark host operating system is MacOS system, and the type otherwise identifying host operating system is non-MacOS system.
22. methods as claimed in claim 17, it is characterised in that also include in described step B2: when described USB device receives During the acquisition configuration descriptor order issued to main frame, send corresponding configuration descriptor and interface descriptor to main frame.
23. methods as claimed in claim 22, it is characterised in that described transmission to main frame configures descriptor and interface accordingly Descriptor, specifically includes: judge the type of host operating system, describes if MacOS system then sends preset configuration to main frame Symbol and the first preset interface descriptor, connect if non-MacOS system is then preset to main frame transmission preset configuration descriptor and second Mouth descriptor;Described first preset interface descriptor is different from described second preset interface descriptor.
24. methods as claimed in claim 22, it is characterised in that described return to main frame configures descriptor and interface accordingly Descriptor, specifically includes: send preset configuration descriptor and the 3rd preset interface descriptor to main frame.
25. methods as claimed in claim 24, it is characterised in that also include in described step B2: when described USB device receives During the APDU order issued to main frame, perform described APDU order, according to performing result tissue reply data, it is judged that described response Whether the length of data exceedes the default maximum packet length corresponding with the type of host operating system, is then by described reply data It is sent to main frame according to described default maximum packet length subpackage, otherwise described reply data is sent to main frame.
26. 1 kinds of USB devices, it is characterised in that including:
Receiver module, after described USB device powers on, the acquisition character string descriptor order that Receiving Host issues;
Sending module, after described receiver module receives the acquisition character string descriptor order that main frame issues, sends out to main frame Send corresponding character string descriptor;
First mark module, for retouching when described receiver module receives acquisition character string after described USB device powers on first When stating symbol order, if the acquisition a length of predetermined word joint number in described acquisition character string descriptor order, identify host service function system The type of system is MacOS system, and the type otherwise identifying host operating system is non-MacOS system.
27. USB devices as claimed in claim 26, it is characterised in that also include:
Second mark module, after the type of described first mark module id host operating system is MacOS system, if The first command that the main frame that described receiver module receives after described USB device powers on issues is for arranging address command, then The version of mark host operating system is first to preset version;
3rd mark module, after the type of described first mark module id host operating system is MacOS system, if The first command that the main frame that described receiver module receives after described USB device powers on issues is for obtaining device descriptor life Order, then identifying the version of host operating system is second to preset version.
28. USB devices as claimed in claim 26, it is characterised in that also include: the 4th mark module, set for described USB After powering on, the type of mark host operating system is unknown;
Described first mark module specifically includes:
Judging unit, for when described receiver module receives the acquisition character string descriptor order that main frame issues, it is judged that main Whether the type of machine operating system is unknown;
Mark unit, for judging that when described judging unit the type of host operating system is as time unknown, it is judged that described reception mould Whether the acquisition length obtained in character string descriptor order that block receives is predetermined word joint number, is then to identify host service function system The type of system is MacOS system, and the type otherwise identifying host operating system is non-MacOS system.
29. USB devices as claimed in claim 28, it is characterised in that also include:
Module is set, the Article 1 life that the main frame for receiving after described USB device powers on when described receiver module issues When order is for arranging address command, arranging version identifier is the first preset value;When described receiver module is after described USB device powers on When the first command that the main frame received issues is for obtaining device descriptor order, arranging version identifier is the second preset value;
Described mark unit is additionally operable to: checks version identifier, if described version identifier is described first preset value, then identifies main frame The version of operating system is first to preset version, if described version identifier is described second preset value, then and mark host service function system The version of system is second to preset version.
30. USB devices as claimed in claim 26, it is characterised in that also include: reseting module, for described USB device After electricity, reset and receive mark;
Described first mark module specifically includes:
Judging unit, for when described receiver module receives the acquisition character string descriptor order that main frame issues, it is judged that institute State whether reception mark is set;
Mark unit, for when described judging unit judges that described reception mark is not set, it is judged that described receiver module connects Whether the acquisition length obtained in character string descriptor order received is predetermined word joint number, is then to identify host operating system Type is MacOS system, and the type otherwise identifying host operating system is non-MacOS system.
31. USB devices as claimed in claim 26, it is characterised in that:
Described receiver module is additionally operable to: the acquisition configuration descriptor order that Receiving Host issues;
Described sending module is additionally operable to: when described receiver module receives the acquisition configuration descriptor order that main frame issues, to Main frame sends corresponding configuration descriptor and interface descriptor.
32. USB devices as claimed in claim 31, it is characterised in that described sending module specifically for: when described reception mould When block receives the acquisition configuration descriptor order that main frame issues, it is judged that the type of host operating system, if MacOS system is then Send preset configuration descriptor and the first preset interface descriptor to main frame, preset if non-MacOS system then sends to main frame Configure descriptor and be different from the described first the second preset interface descriptor presetting descriptor.
33. USB devices as claimed in claim 31, it is characterised in that described sending module specifically for: when described reception mould When block receives the acquisition configuration descriptor order that main frame issues, send preset configuration descriptor and the 3rd preset interface to main frame Descriptor.
34. USB devices as claimed in claim 33, it is characterised in that:
Described receiver module is additionally operable to: the APDU order that Receiving Host issues;
Described USB device also includes: perform module, is used for when described receiver module receives the APDU order that main frame issues, Perform the APDU order that described receiver module receives, according to performing result tissue reply data, it is judged that described reply data Whether length exceedes the default maximum packet length corresponding with the type of host operating system, be then by described reply data according to institute State default maximum packet length subpackage and be sent to main frame, otherwise described reply data is sent to main frame.
CN201610457589.7A 2016-06-22 2016-06-22 A kind of USB device and its method for identifying MacOS system Active CN106126446B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201610457589.7A CN106126446B (en) 2016-06-22 2016-06-22 A kind of USB device and its method for identifying MacOS system
CN201811305607.5A CN109446120B (en) 2016-06-22 2016-06-22 USB device and method for identifying MacOS system by USB device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610457589.7A CN106126446B (en) 2016-06-22 2016-06-22 A kind of USB device and its method for identifying MacOS system

Related Child Applications (1)

Application Number Title Priority Date Filing Date
CN201811305607.5A Division CN109446120B (en) 2016-06-22 2016-06-22 USB device and method for identifying MacOS system by USB device

Publications (2)

Publication Number Publication Date
CN106126446A true CN106126446A (en) 2016-11-16
CN106126446B CN106126446B (en) 2019-01-04

Family

ID=57269148

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201610457589.7A Active CN106126446B (en) 2016-06-22 2016-06-22 A kind of USB device and its method for identifying MacOS system
CN201811305607.5A Active CN109446120B (en) 2016-06-22 2016-06-22 USB device and method for identifying MacOS system by USB device

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN201811305607.5A Active CN109446120B (en) 2016-06-22 2016-06-22 USB device and method for identifying MacOS system by USB device

Country Status (1)

Country Link
CN (2) CN106126446B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109173239A (en) * 2018-08-29 2019-01-11 深圳市七熊科技有限公司 Game host recognition methods, device, computer equipment and storage medium
WO2019218547A1 (en) * 2018-05-14 2019-11-21 深圳市江波龙电子有限公司 Usb mass storage device access control method and access control apparatus
CN115061732A (en) * 2022-05-05 2022-09-16 科大讯飞股份有限公司 Operating system identification method, device, equipment and storage medium

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112068893B (en) * 2020-11-12 2021-03-16 飞天诚信科技股份有限公司 USB device and method for distinguishing mobile device operating systems
CN112100103B (en) * 2020-11-19 2021-03-16 飞天诚信科技股份有限公司 Communication method and system based on apple operating system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004046942A1 (en) * 2002-11-15 2004-06-03 Globespanvirata Incorporated Method and system for attaching a usb network adapter supporting both rndis and non-rndis capable operating systems
CN101957807A (en) * 2010-09-16 2011-01-26 北京飞天诚信科技有限公司 Method for USB device to recognize version type of Windows operating system
CN102375786A (en) * 2011-10-18 2012-03-14 中兴通讯股份有限公司 Automatic operating system identifying method and system for USB (Universal Serial Bus) equipment
CN102890662A (en) * 2012-10-19 2013-01-23 无锡海森诺科技有限公司 Method for identifying host operating system by executing enumeration twice on USB (Universal Serial Bus) HID (Human Interface Device)
CN104516842A (en) * 2013-09-29 2015-04-15 中兴通讯股份有限公司 Method for universal serial bus (USB) equipment quick adaptation operating system and USB equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101916238B (en) * 2010-08-26 2012-01-25 华为终端有限公司 Method and device for data card to identify operating system and communication system
CN102253904A (en) * 2011-06-08 2011-11-23 广州视睿电子科技有限公司 Method and device for identifying computer operating system by USB equipment
CN103092799B (en) * 2012-12-28 2015-07-22 飞天诚信科技股份有限公司 Universal serial bus (USB) device and method for recognition of host operating system
CN105279110B (en) * 2014-07-25 2018-07-27 南京中兴软件有限责任公司 A kind of method and USB device of USB device identification host system
US20180060260A1 (en) * 2016-08-24 2018-03-01 Prolific Technology Inc. Method and device capable of automatically identifying host operating systems

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004046942A1 (en) * 2002-11-15 2004-06-03 Globespanvirata Incorporated Method and system for attaching a usb network adapter supporting both rndis and non-rndis capable operating systems
CN101957807A (en) * 2010-09-16 2011-01-26 北京飞天诚信科技有限公司 Method for USB device to recognize version type of Windows operating system
CN102375786A (en) * 2011-10-18 2012-03-14 中兴通讯股份有限公司 Automatic operating system identifying method and system for USB (Universal Serial Bus) equipment
CN102890662A (en) * 2012-10-19 2013-01-23 无锡海森诺科技有限公司 Method for identifying host operating system by executing enumeration twice on USB (Universal Serial Bus) HID (Human Interface Device)
CN104516842A (en) * 2013-09-29 2015-04-15 中兴通讯股份有限公司 Method for universal serial bus (USB) equipment quick adaptation operating system and USB equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019218547A1 (en) * 2018-05-14 2019-11-21 深圳市江波龙电子有限公司 Usb mass storage device access control method and access control apparatus
US11762976B2 (en) 2018-05-14 2023-09-19 Shenzhen Longsys Electronics Co., Ltd. USB mass storage device access control method and access control apparatus
CN109173239A (en) * 2018-08-29 2019-01-11 深圳市七熊科技有限公司 Game host recognition methods, device, computer equipment and storage medium
CN115061732A (en) * 2022-05-05 2022-09-16 科大讯飞股份有限公司 Operating system identification method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN109446120B (en) 2020-05-15
CN109446120A (en) 2019-03-08
CN106126446B (en) 2019-01-04

Similar Documents

Publication Publication Date Title
CN106126446A (en) A kind of USB device and the method identifying MacOS system thereof
CN101957807B (en) Method for USB device to recognize version type of Windows operating system
CN106462528A (en) Power-saving mode for USB power delivery sourcing device
CN101438258A (en) Adapter to convert USB device into WUSB device
CN103248420B (en) Methods, systems and devices for detecting and identifying fiber connection
CN103092799A (en) Universal serial bus (USB) device and method for recognition of host operating system
CN101625670A (en) Serial bus device, serial bus transmission system and method
CN102624429A (en) Method and device for managing information exchange between for example a nfc controller and a set of at least two secure elements
CN104793544B (en) Bidirectional power supply system in a kind of Ethernet POE
CN108564776A (en) Equipment debugging system, apparatus debugging method and computer storage media
CN109451457B (en) Automatic uploading system for test data of power equipment
CN104731737A (en) Hub, operating system and control method
CN108054794A (en) Charging and discharging method and device for intelligent terminal, terminal and storage medium
CN103873256A (en) Working method of NFC token
CN207283558U (en) A kind of optical fiber Routing identification high in the clouds management system
CN106532863B (en) Method and system for stopping charging of charging pile in off-grid mode
CN108280037A (en) A kind of method and apparatus that preemptive type multiplexing serial port automatically switches
CN207218309U (en) A kind of mobile phone shares the power-supply system of charging equipment
CN107154182A (en) A kind of word-forming main frame, character module, word spelling system and word-forming method
CN103036753B (en) Send method and the Broadband Remote Access Server of message
CN109246668A (en) A kind of communication equipment and a kind of substation equipment detection system using it
CN106294237A (en) A kind of multiplexing functions method and device of communication interface
CN103209105A (en) Communication device and method for rail transit vehicles
CN102355460A (en) Communication device for rail transportation vehicle and method
CN202261382U (en) Communication equipment for rail transit vehicle

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
OL01 Intention to license declared
OL01 Intention to license declared