Detailed Description
Various aspects and features of the present application are described herein with reference to the accompanying drawings.
It should be understood that various modifications may be made to the embodiments of the application herein. Therefore, the above description should not be taken as limiting, but merely as exemplification of the embodiments. Other modifications within the scope and spirit of the application will occur to persons of ordinary skill in the art.
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the application and, together with a general description of the application given above, and the detailed description of the embodiments given below, serve to explain the principles of the application.
These and other characteristics of the application will become apparent from the following description of a preferred form of embodiment, given as a non-limiting example, with reference to the accompanying drawings.
It is also to be understood that, although the application has been described with reference to some specific examples, those skilled in the art can certainly realize many other equivalent forms of the application.
The above and other aspects, features and advantages of the present application will become more apparent in light of the following detailed description when taken in conjunction with the accompanying drawings.
Specific embodiments of the present application will be described hereinafter with reference to the accompanying drawings; however, it is to be understood that the disclosed embodiments are merely exemplary of the application, which can be embodied in various forms. Well-known and/or repeated functions and constructions are not described in detail to avoid obscuring the application in unnecessary or unnecessary detail. Therefore, specific structural and functional details disclosed herein are not intended to be limiting, but rather to teach one skilled in the art to variously employ the present application in virtually any appropriately detailed structure.
The specification may use the word "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," which may each refer to one or more of the same or different embodiments in accordance with the application.
The access method of the embodiment of the application can be applied to the process of accessing the HID associated with the electronic device by the electronic device, wherein the HID can be a USB-based HID, USB-HID is an abbreviation of Universal Serial Bus-Human INTERFACE DEVICE, and the HID is a device which can interact with Human, such as a keyboard, a mouse, a joystick and the like. The method can control the access process in the process that the body of the electronic equipment accesses the target equipment such as the HID equipment.
Fig. 1 is a flowchart of an access method according to an embodiment of the present application, as shown in fig. 1 and described in detail with reference to fig. 4, the method includes the following steps:
S100, at least one piece of access information for accessing the target device is acquired.
The target device is illustratively a device associated with the electronic device, such as the HID device described above that is connected to the body of the electronic device. The target device is the target of the access, e.g. the target of the body access of the electronic device is an HID device. The access information includes information about the access target device, and may include information about a specific target, access time, access content, and the like. The access information may be of various types and the purpose of different access information to access the target device may be different. For example, the multiple different threads generated by the electronic device all access the target device, but the access information corresponding to the different threads is not the same.
In this embodiment, when access information is acquired, the electronic device may acquire all the access information through a pre-built unified interface, so that unified processing can be performed on the acquired access information.
S200, sorting is carried out on the processing sequence of the access information based on a preset sorting mode.
The preset ordering mode may be configured according to actual requirements, for example, may be configured according to time when the access information is acquired, may be configured according to a priority corresponding to the access information, and may be configured according to an identifier of a target device corresponding to the access information.
The access information is ordered based on a preset ordering mode, for example, the access information can be arranged in a queue according to the acquired access information, then the access information is processed according to the sequence in the queue, the acquired access information is processed first, and then the acquired access information is processed later. The access information is processed according to the arranged sequence, so that accidents of conflict processing among different access information can be avoided.
For example, two different threads send access information to the first target device, if the access information corresponding to the two threads is sequenced (the corresponding request instruction sets are sequenced), the request instruction sets corresponding to the respective access information can be processed one by one according to the logic sequence formed after sequencing, so that the phenomenon of information disorder caused by processing conflict can be avoided.
S300, acquiring a request instruction set corresponding to the access information which is currently processed based on the processing sequence, and generating a first access request and a first acquisition request corresponding to the request instruction set, wherein the request instruction set is used for requesting to acquire target data from the target equipment.
Illustratively, after the processing sequences of the access information are ordered, a corresponding processing sequence is formed, and the electronic device may process the access information according to the processing sequence. The access information corresponds to a request instruction set, where the request instruction set is used to request to obtain target data from the target device, for example, the first access information includes a plurality of different request instructions (all the request instructions may be used as a request instruction set), so as to request to obtain a plurality of different feedback information of the target device.
In one embodiment, the request instruction set includes multiple types of request instructions, such as may include a get request instruction and a set request instruction. For example, the Get request instruction is a Get Report instruction, and the Set request instruction is a Set Report instruction. The Get Report instruction is used for acquiring information, and the Set Report instruction is used for setting target equipment. The Get Report instruction may be converted into a corresponding first access request and a first acquisition request, for example, into a Set Feature instruction and a Get Feature instruction, which form a first access request and a first acquisition request corresponding to the request instruction Set.
S400, acquiring the target data from the target equipment at least based on the first access request and the first acquisition request.
Illustratively, the fetch request instructions in the same request instruction Set correspond to a first access request (e.g., the Set Feature instruction described above) and a first fetch request (e.g., the Get Feature instruction described above). The first access request and the first acquisition request have relative logic processing sequences, the first access request can be sent to the target device first, so that the target device determines corresponding target data according to the first access request, then the first acquisition request can be sent to the target device, the target device can send the target data to a requester according to the first acquisition request, such as an entity of the electronic device, and therefore, loopholes can not occur in the processing process of the acquisition request instruction and the related instruction thereof, such as the phenomenon that the acquisition request instruction in the request instruction set is not executed all the time.
Further, the target device may be accessed based on a logical order among a first access request, a first fetch request, and other instructions in the request instruction set corresponding to the same request instruction set. The target device is accessed, for example, based on the first access request, the first acquisition request, and a set request instruction in the request instruction set. Such as accessing the target device in the following order: a first access request (e.g., the Set Feature instruction described above), a first fetch request (e.g., the Get Feature instruction described above), and a Set request instruction (e.g., the Set Report instruction described above). This allows individual instructions in the same request instruction set to not conflict.
Since different sets of requested instructions also have processing sequences, no conflict occurs for all instructions. And the target equipment processes different instructions respectively in sequence to realize that the target equipment feeds back correct target data, such as buffer data.
The access method can sort the acquired different access information, thereby realizing the sorting of the corresponding request instruction sets, avoiding the conflict among all the request instruction sets and avoiding the conflict of each instruction in the same request instruction set. And the target equipment processes different instructions respectively, so that the target equipment feeds back correct target data, and the success of the whole access process is ensured.
In one embodiment of the present application, as shown in fig. 2, the method further comprises the steps of:
s500, obtaining the information type of the access information.
Illustratively, the access information is of a variety of different types, such as an input report type, an output report type, and a feature report type. The type of the acquired access information can be determined by the identification of the access information, and the type of the access information can also be determined by the data structure of the access information.
For different information types, a processing mode matched with the information types can be adopted.
And S600, in the case that the information type is determined to be the first type, placing the corresponding access information in a sorting queue.
Illustratively, in connection with FIG. 4, the first type may be a feature report type, with access information of the feature report type placed in an ordering queue. So that the feature report type of access information can be processed in the order formed in the ordering queue (e.g., the first ordering queue).
Of course, the first type may be other types of access information, and other types of access information may be processed in other manners. For example, the method can be used for processing similar manner to the method for processing the access information of the feature report type, such as using a second sorting queue to place the access information of the input report type, and then uniformly processing the access information in the second sorting queue; and placing the access information of the output report type by using the third sorting queue, and further uniformly processing the access information in the third sorting queue.
Of course, the processing may be performed in a manner completely different from the processing of the access information of the feature report type, which is not limited herein. Thus, for the same type of access information arranged in the same ordering queue, the processing efficiency can be effectively improved during specific processing.
In one embodiment of the present application, the sorting the processing order of the access information based on the preset sorting manner, as shown in fig. 3, includes:
s210, based on the acquisition time of the access information, sequencing the processing sequence of the access information by using the constructed layer structure.
S220, adding the access information with the completed sequencing into the constructed sequencing queue.
The layer structure is illustratively a virtual structure that may be disposed between the requesting party and the target device, such as between the thread/process and the HDI device. The relatively independent hierarchy can receive access information sent by a plurality of different requesters in a unified and orderly mode, and then the received access information is ordered. Including ordering the access information by the acquisition time at which the access information can be acquired in accordance with the hierarchy. For example, access information acquired first adds it to the front of the ordering queue and access information acquired later adds it to the back of the ordering queue. Thereby gradually realizing the ordering of the whole access information.
When the access information in the sequencing queue is processed, the access information is obtained from the head of the sequencing queue to be used as current processing access information, and all the access information is further processed step by step in sequence.
In one embodiment of the present application, the request instruction set includes a set request instruction and an acquire request instruction, the acquiring the request instruction set corresponding to the access information currently processed, generating a first access request and a first acquire request corresponding to the request instruction set, including:
And converting the acquisition request instruction into a corresponding first access request and a first acquisition request by using an agent connected with the layer structure.
For example, the request instruction Set may include various request instructions, and in this embodiment, it is clear that the request instruction Set includes a Set request instruction and an acquire request instruction, where in a case where the target device is an HID device, the Set request instruction may be a Set Report instruction, and the acquire request instruction may be a Get Report instruction, where the Get Report instruction is used to acquire information, and the Set Report instruction is used to Set the target device.
The layer structure is connected with an Agent, the Agent can be arranged between the layer structure and the target equipment, after the layer structure determines a corresponding request instruction set according to the access information, the Agent can receive the request instruction set from the layer structure, further, the setting request instruction and the acquisition request instruction in the request instruction set are ordered, and then the acquisition request instruction in the request instruction set is converted into a corresponding first access request and a corresponding first acquisition request.
In one embodiment of the application, the method further comprises the steps of: and sequencing the first access request, the first acquisition request and the setting request instruction belonging to the same request instruction set according to a sequence order so as to interact with the target equipment based on the formed sequence order.
Illustratively, the first access request, the first fetch request, and the set request instruction in the same set of request instructions are ordered. So that no conflict occurs among the first access request, the first acquisition request and the setting request instruction.
For example, with reference to FIG. 5, the instructions in the first request instruction Set are ordered, the Get Report instruction is ordered first, and the Set Report instruction is ordered second. So that the Get Report instruction is processed in advance. The Set Feature instruction and the Get Feature instruction are converted into the Set Feature instruction and the Get Feature instruction, so that the Set Feature instruction can be sent to the target equipment first, and the Get Feature instruction can be sent to the target equipment after feedback is obtained. And then sending a Set Report instruction to the target equipment. Thereby avoiding collision between the respective instructions.
In one embodiment of the present application, the acquiring the target data from the target device based on at least the first access request and the first acquisition request, as shown in fig. 4, includes the following steps:
S410, the first access request is sent to the target device, so that the target device determines corresponding target data;
And S420, after receiving the feedback of the target equipment, sending the first acquisition request to the target equipment so as to acquire the target data.
Illustratively, the first access request is for a requestor to request target data that is required for a target device determination, such as determining relevant data for a sub-device in the target device. The target device determines the relevant data and feeds the relevant data back to the requesting party. The requester requests the related data of the sub-device to the target device again through the first acquisition request. And the target equipment feeds the target data back to the requester according to the first acquisition request. Therefore, the whole asking process is logical and is not confused.
For example, in one embodiment, the motherboard of the computer sends a Set feature instruction to the HID keyboard to ask the HID keyboard for the data of the lamp Set thereon, where the Set feature instruction may include target data such as position information, quantity information, and lighting state of the lamp, and the HID keyboard determines the target data to be fed back according to the Set feature instruction. And the main board of the computer sends a Get Feature instruction to the HID keyboard, and the HID keyboard feeds back target data about the lamp to the main board according to the Get Feature instruction. And then the main board sends a Set Report instruction to the HID keyboard, so that the state of the lamp can be Set.
In one embodiment of the present application, the layer structure is HID HELPER layers, a unified interface is provided in the HID HELPER layers, the unified interface is configured to receive the access information sent by at least one process, and the acquiring at least one access information for accessing a target device includes: and acquiring the access information through the unified interface.
For example, the HID HELPER layer may be disposed between a thread/process and an HID device, for example, the HID HELPER layer may be connected to a target device through an Agent (HID Agent), and the HID HELPER layer may be provided with a unified interface for receiving access information sent by one or more processes. The HID HELPER layer receives the access information and converts the access information into a corresponding request instruction set, the request instruction set is sent to the HID Agent, the HID Agent sequences a setting request instruction and an acquisition request instruction in the request instruction set into a sequencing queue, and then converts the acquisition request instruction into a corresponding first access request and a corresponding first acquisition request. And then interacting with the target device based on the instructions in the ordering queue.
In one embodiment of the present application, the target device is an HID device, and the acquiring the target data from the target device specifically includes: and acquiring partial or all data of the HID sub-device from the HID device.
For example, the HID device is a USB HID keyboard, and the target data obtained from the USB HID keyboard may be data related to some or all of the lamps on the USB HID keyboard. Such as the flashing status of the lamp.
The embodiment of the application also provides an electronic device, as shown in fig. 6, including:
An acquisition module configured to acquire at least one access information for accessing the target device.
The target device is illustratively a device associated with the electronic device, such as the HID device described above that is connected to the body of the electronic device. The target device is the target of the access, e.g. the target of the body access of the electronic device is an HID device. The access information includes information about the access target device, and may include information about a specific target, access time, access content, and the like. The access information may be of various types and the purpose of different access information to access the target device may be different. For example, the multiple different threads generated by the electronic device all access the target device, but the access information corresponding to the different threads is not the same.
In this embodiment, when the obtaining module obtains the access information, all the access information may be obtained through a pre-built unified interface, so that the obtained access information may be uniformly processed.
And the ordering module is configured to order the processing sequence of the access information based on a preset ordering mode.
The preset ordering mode may be configured according to actual requirements, for example, may be configured according to time when the access information is acquired, may be configured according to a priority corresponding to the access information, and may be configured according to an identifier of a target device corresponding to the access information.
The sorting module sorts the access information based on a preset sorting mode, for example, the access information can be arranged in a queue according to the acquired access information, and then the access information is processed according to the sequence in the queue, and the access information acquired first is processed and then the access information acquired later is processed. The access information is processed according to the arranged sequence, so that accidents of conflict processing among different access information can be avoided.
For example, two different threads send access information to the first target device, if the ordering module orders the access information corresponding to the two threads respectively (also orders the corresponding request instruction sets), the request instruction sets corresponding to the respective access information can be processed one by one according to the logic sequence formed after the ordering, so that the phenomenon of information disorder caused by conflict in processing can be avoided.
The processing module is configured to acquire a request instruction set corresponding to the access information currently processed based on the processing sequence, and generate a first access request and a first acquisition request corresponding to the request instruction set, wherein the request instruction set is used for requesting to acquire target data from the target equipment;
the target data is acquired from the target device based at least on the first access request and the first acquisition request.
Illustratively, after the ordering module performs ordering on the processing sequence of the access information, a corresponding processing sequence is formed, and the processing module may process the access information according to the processing sequence. The access information corresponds to a request instruction set, where the request instruction set is used to request to obtain target data from the target device, for example, the first access information includes a plurality of different request instructions (all the request instructions may be used as a request instruction set), so as to request to obtain a plurality of different feedback information of the target device.
In one embodiment, the request instruction set includes multiple types of request instructions, such as may include a get request instruction and a set request instruction. For example, the Get request instruction is a Get Report instruction, and the Set request instruction is a Set Report instruction. The Get Report instruction is used for acquiring information, and the Set Report instruction is used for setting target equipment. The processing module may convert the Get Report instruction into a corresponding first access request and a first acquisition request, for example, a Set Feature instruction and a Get Feature instruction, that is, a first access request and a first acquisition request corresponding to the request instruction Set are formed.
Illustratively, the fetch request instructions in the same request instruction Set correspond to a first access request (e.g., the Set Feature instruction described above) and a first fetch request (e.g., the Get Feature instruction described above). The first access request and the first acquisition request have relative logic processing sequences, and the processing module can firstly send the first access request to the target equipment, so that the target equipment can determine corresponding target data according to the first access request, and then can send the first acquisition request to the target equipment, so that the target equipment can send the target data to a requester according to the first acquisition request, such as an entity of the electronic equipment, thereby ensuring that loopholes can not occur in the processing process of the acquisition request instruction and the related instruction thereof, such as the phenomenon that the acquisition request instruction in the request instruction set is not executed all the time.
Further, the processing module may access the target device based on a logical order among a first access request, a first fetch request, and other instructions in the request instruction set corresponding to the same request instruction set. The target device is accessed, for example, based on the first access request, the first acquisition request, and a set request instruction in the request instruction set. Such as accessing the target device in the following order: a first access request (e.g., the Set Feature instruction described above), a first fetch request (e.g., the Get Feature instruction described above), and a Set request instruction (e.g., the Set Report instruction described above). This allows individual instructions in the same request instruction set to not conflict.
In one embodiment of the application, the ranking module is further configured to:
acquiring the information type of the access information;
And in the case that the information type is determined to be the first type, placing the corresponding access information in an ordering queue.
In one embodiment of the application, the ranking module is further configured to:
based on the acquisition time of the access information, sequencing the processing sequence of the access information by utilizing the constructed layer structure;
and adding the access information for completing the sorting into a constructed sorting queue.
In one embodiment of the application, the request instruction set includes a set request instruction and a get request instruction, and the processing module is further configured to:
And converting the acquisition request instruction into a corresponding first access request and a first acquisition request by using an agent connected with the layer structure.
In one embodiment of the application, the ranking module is further configured to:
And sequencing the first access request, the first acquisition request and the setting request instruction belonging to the same request instruction set according to a sequence order so as to interact with the target equipment based on the formed sequence order.
In one embodiment of the application, the processing module is further configured to:
transmitting the first access request to the target device so that the target device determines corresponding target data;
And after receiving the feedback of the target equipment, sending the first acquisition request to the target equipment so as to acquire the target data.
In one embodiment of the present application, the layer structure is HID HELPER layers, a unified interface is provided in the HID HELPER layers, the unified interface is used for receiving the access information sent by one or more processes, and the obtaining module is further configured to:
and acquiring the access information through the unified interface.
In one embodiment of the application, the target device is an HID device, and the processing module is further configured to:
and acquiring partial or all data of the HID sub-device from the HID device.
In one embodiment of the present application, in a case where the target device is an HID device, the setting request instruction is a Set Report instruction, and the acquisition request instruction is a Get Report instruction.
The embodiment of the application also provides an electronic device, as shown in fig. 7, which comprises a memory and a processor, wherein the memory stores an executable program, and the processor processes the executable program to execute the steps of the access method.
The above embodiments are only exemplary embodiments of the present application and are not intended to limit the present application, the scope of which is defined by the claims. Various modifications and equivalent arrangements of this application will occur to those skilled in the art, and are intended to be within the spirit and scope of the application.