CN111104075B - USB equipment simulation device and method - Google Patents
USB equipment simulation device and method Download PDFInfo
- Publication number
- CN111104075B CN111104075B CN201911314876.2A CN201911314876A CN111104075B CN 111104075 B CN111104075 B CN 111104075B CN 201911314876 A CN201911314876 A CN 201911314876A CN 111104075 B CN111104075 B CN 111104075B
- Authority
- CN
- China
- Prior art keywords
- usb
- usb device
- information
- upper computer
- enumeration
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/12—Digital output to print unit, e.g. line printer, chain printer
- G06F3/1201—Dedicated interfaces to print systems
- G06F3/1202—Dedicated interfaces to print systems specifically adapted to achieve a particular effect
- G06F3/1203—Improving or facilitating administration, e.g. print management
- G06F3/1205—Improving or facilitating administration, e.g. print management resulting in increased flexibility in print job configuration, e.g. job settings, print requirements, job tickets
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/12—Digital output to print unit, e.g. line printer, chain printer
- G06F3/1201—Dedicated interfaces to print systems
- G06F3/1223—Dedicated interfaces to print systems specifically adapted to use a particular technique
- G06F3/1224—Client or server resources management
- G06F3/1228—Printing driverless or using generic drivers
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/12—Digital output to print unit, e.g. line printer, chain printer
- G06F3/1201—Dedicated interfaces to print systems
- G06F3/1223—Dedicated interfaces to print systems specifically adapted to use a particular technique
- G06F3/1236—Connection management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/12—Digital output to print unit, e.g. line printer, chain printer
- G06F3/1201—Dedicated interfaces to print systems
- G06F3/1278—Dedicated interfaces to print systems specifically adapted to adopt a particular infrastructure
- G06F3/1279—Controller construction, e.g. aspects of the interface hardware
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4406—Loading of operating system
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Software Systems (AREA)
- Computer Security & Cryptography (AREA)
- Information Transfer Systems (AREA)
Abstract
The invention provides a USB equipment simulation device and a method, wherein the device comprises a controller and a USB interface connected with the controller; the controller is connected with the upper computer through the USB interface; an embedded Linux system is operated in the controller, a USB Device driver is preloaded in the embedded Linux system, and enumeration information of the simulated USB Device is preset in the USB Device driver; the controller is used for sending the enumeration information to the upper computer through the USB Device driver when receiving an inquiry signal of the upper computer so as to be recognized as the simulated USB Device by the upper computer. According to the invention, the enumeration information of the simulated USB device is acquired, and when the upper computer enumerates the USB device, the controller based on the embedded Linux system sends the enumeration information to the upper computer, so that the upper computer can identify the enumeration information as the simulated USB device.
Description
Technical Field
The present invention relates to the field of interface technologies, and in particular, to a device and a method for simulating a USB device.
Background
The USB printer is favored by more and more office users by virtue of the advantages of flexible plugging, convenient operation and the like. In some scenarios, a large number of USB printers are required to perform the job, and the types of USB printers that may be actually put into production use are different. Thus, in the process of maintaining printers, once a certain printer is damaged, it is necessary to replace the printer with a new one and to restore the print job in time.
Currently, in the above application scenario, if a printer of the same model as the damaged printer is absent or not, a new print driver needs to be reinstalled on a host computer connected to the printer after a printer of a different model is replaced. This printing apparatus replacement method takes much time and is cumbersome to operate.
Disclosure of Invention
Therefore, the invention aims to provide a USB equipment simulation device and a method, which can simulate the information of the original USB printing equipment without reinstalling a printing driver, can quickly replace the original USB printing equipment, and has simpler operation.
In a first aspect, an embodiment of the present invention provides a USB device simulation apparatus, including: a controller and a USB interface connected with the controller; the controller is connected with the upper computer through the USB interface; the controller is internally provided with an embedded Linux system, a USB Device driver is preloaded in the embedded Linux system, and enumeration information of the simulated USB Device is preset in the USB Device driver; the controller is used for sending the enumeration information to the upper computer through the USB Device driver when receiving the query signal of the upper computer so as to be recognized as the simulated USB Device by the upper computer.
In a preferred embodiment of the present invention, the emulated USB device is a USB printer.
In a preferred embodiment of the present invention, the above-mentioned USB device simulation apparatus further includes a print module, and the print module is connected to the controller.
In a preferred embodiment of the present invention, the USB interface is a USB Type B interface.
In a preferred embodiment of the present invention, the above-mentioned USB device simulation apparatus further includes an USB Type a interface, where the USB Type a interface is connected to the controller, and the USB Type a interface is used for externally connecting the simulated USB device.
In a second aspect, the embodiment of the present invention further provides a USB Device simulation method, which is applied to an embedded Linux system, where a USB Device driver is preloaded in the embedded Linux system, and enumeration information of a simulated USB Device is preset in the USB Device driver; the method comprises the following steps: when an inquiry signal of the upper computer is received, the enumeration information is sent to the upper computer through the USB Device driver, so that the upper computer is identified as the simulated USB Device.
In a preferred embodiment of the present invention, the enumeration information of the emulated USB device is obtained by: monitoring a device management event of the embedded Linux system; when the fact that the designated USB interface is plugged in by the USB equipment is monitored, interface event information of the USB equipment is obtained; generating a file path of a sysfs file system of the USB equipment according to the interface event information; and acquiring enumeration information of the USB device from the USB device through the file path.
In a preferred embodiment of the present invention, the step of generating the file path of the sysfs file system of the USB device according to the interface event information includes: obtaining a devpath character string in the interface event information; and splicing the devpath character string with the/sys/character string to obtain a file path of the sysfs file system of the USB equipment.
In a preferred embodiment of the present invention, the step of monitoring the device management event of the embedded Linux system includes: acquiring system kernel information of the embedded Linux system; and monitoring the device management event in the system kernel information.
In a preferred embodiment of the present invention, the enumeration information of the emulated USB Device is set to the USB Device driver in the following manner: when the USB Device driver is loaded, the enumeration information of the emulated USB Device is transferred to the USB Device driver by means of parameter transfer, so as to set the enumeration information into a corresponding data structure in the USB Device driver.
The embodiment of the invention has the following beneficial effects:
the embodiment of the invention provides a USB equipment simulation device and a method, wherein the device comprises a controller and a USB interface connected with the controller; the controller is connected with the upper computer through the USB interface; the controller is internally provided with an embedded Linux system, a USB Device driver is preloaded in the embedded Linux system, and enumeration information of the simulated USB Device is preset in the USB Device driver; the controller is used for sending the enumeration information to the upper computer through the USB Device driver when receiving the query signal of the upper computer so as to be recognized as the simulated USB Device by the upper computer. In the method, enumeration information of the simulated USB device is acquired, and when the host computer enumerates the USB device, the controller based on the embedded Linux system sends the enumeration information to the host computer, so that the host computer can recognize the enumeration information as the simulated USB device. And when the simulated USB equipment is USB printing equipment, the device can simulate the information of the original USB printing equipment, does not need to reinstall a printing driver, quickly replaces the original USB printing equipment, and is simpler and more convenient to operate.
Additional features and advantages of the disclosure will be set forth in the description which follows, or in part will be obvious from the description, or may be learned by practice of the techniques of the disclosure.
The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic structural diagram of a USB device simulation apparatus according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of another USB device simulation apparatus according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of a USB device simulation method according to an embodiment of the present invention;
fig. 4 is a flowchart of another method for simulating a USB device according to an embodiment of the present invention.
Icon: 100-USB equipment simulation device; 11-a controller; a 12-USB interface; 200-an upper computer; 21-USB Type a interface; 22-USB Type B interface; a 23-print module; 300-USB printer.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Considering that in some application scenarios, if a printer of the same type as a damaged printer is absent or not, after a printer of a different type is replaced, a new print driver needs to be reinstalled on a host connected to the printer, and this type of replacement of the print device needs to take more time and is complicated to operate. For the sake of understanding the present embodiment, first, a USB device simulation apparatus disclosed in the present embodiment will be described in detail.
Referring to fig. 1, a schematic structural diagram of a USB device simulation apparatus according to an embodiment of the present invention is shown, and as can be seen from fig. 1, the USB device simulation apparatus 100 includes a controller 11 and a USB interface 12 connected to the controller 11, wherein the controller 11 is connected to an upper computer 200 through the USB interface 12. In one possible implementation, the USB interface 12 is a USB Type B interface 22.
In the above-mentioned USB Device simulation apparatus 100, an embedded Linux system is run in the controller 11, and a USB Device driver is preloaded in the embedded Linux system, and enumeration information of a simulated USB Device is preset in the USB Device driver. The embedded Linux system is an operating system which is used for cutting and modifying the increasingly popular Linux operating system so as to enable the Linux operating system to run on the embedded computer system. Embedded Linux inherits unlimited open source code resources on the Internet and has the characteristics of an embedded operating system.
In addition, the USB Device driver is a USB Device driver installer, which is source code provided by the Linux kernel in this embodiment. In the USB Device driver, enumeration information of the emulated USB Device is preset. The simulated USB device can be USB devices such as a USB printer, a USB flash disk and the like.
Here, the USB device is one piece of hardware at the end of the USB cable, and may be divided into three parts, i.e., a USB bus interface, a USB logic device, and a functional device. Also, USB devices typically contain device descriptors that indicate the attributes and characteristics of a given device. These USB devices provide host software with a range of USB device features and capabilities for configuring devices and locating USB drivers. In addition, the USB device driver may also use the device descriptor to determine the additional information needed to ensure that the device is accessed in the correct form.
In actual operation, when the controller 11 receives an inquiry signal from the host computer 200, the controller 11 sends the enumeration information to the host computer 200 through the USB Device driver, so that the host computer 200 recognizes the enumeration information as the emulated USB Device. Here, when the USB interface 12 of the Device is connected to the host computer 200, the host computer 200 will initiate an inquiry to the USB Device to enumerate the connected Device, and at this time, the USB Device driver loaded in the controller 11 will initialize and send the enumeration information to the host computer 200, so as to be recognized as a simulated USB Device by the host computer 200.
Here, it is assumed that the emulated USB Device is a USB printer, so by acquiring enumeration information of the USB printer in advance, and setting the enumeration information into a USB Device driver loaded on the controller 11 of the USB Device emulation apparatus 100; when the USB device simulation apparatus 100 is connected to the host computer 200 through the USB interface 12, the host computer 200 initiates an inquiry to the apparatus; when the controller 11 receives the inquiry information of the host computer 200, the above enumeration information is transmitted to the host computer 200 through the USB Device driver, and at this time, the host computer 200 acquires the enumeration information of the USB printer, so that the USB Device emulation apparatus 100 is identified as the USB printer.
In this way, communication is established between the host computer 200 and the USB device simulation apparatus 100, the USB device simulation apparatus 100 simulates that a USB printer interacts with the host computer 200, the host computer 200 can send print data to the USB device simulation apparatus 100, and the USB device simulation apparatus 100 can send print status information to the host computer 200, thereby simulating the operation of the printer. In at least one possible embodiment, the USB device simulation apparatus 100 further includes a printing module, so that when the USB device simulation apparatus 100 receives print data from the host computer 200, a printing operation can be performed through the printing module, thereby completely replacing the USB printer.
In this way, in some application scenarios, if a USB printer of the same type as the damaged printer is absent or not, the USB printer that needs to be replaced can be simulated by the above-mentioned USB device simulation apparatus 100 provided by the present invention, and the host computer 200 that is originally connected can be identified as a "replaced USB printer" without reinstalling a driver, thereby implementing printing and quickly recovering a print job. Compared with the mode of replacing printers with different models and reinstalling a printing drive in the prior art, the USB equipment simulation device 100 provided by the invention can provide a solution which is simpler and more convenient to operate and more efficient to replace.
In other possible embodiments, when the Device to be emulated is a USB disk, correspondingly, by presetting enumeration information of the USB disk in the USB Device driver, when the host computer 200 inquires about the Device, the controller 11 of the USB Device emulation apparatus 100 sends the enumeration information to the host computer 200, and the enumeration information returned to the host computer 200 when the USB disk is connected to the host computer 200 is the same, so that the Device to be emulated is recognized as the USB disk by the host computer 200. Similarly, the USB device simulation apparatus 100 may simulate other USB devices.
The embodiment of the invention provides a USB equipment simulation device, which comprises a controller and a USB interface connected with the controller; the controller is connected with the upper computer through the USB interface; the controller is internally provided with an embedded Linux system, a USB Device driver is preloaded in the embedded Linux system, and enumeration information of the simulated USB Device is preset in the USB Device driver; the controller is used for sending the enumeration information to the upper computer through the USB Device driver when receiving the query signal of the upper computer so as to be recognized as the simulated USB Device by the upper computer. In the device, enumeration information of the simulated USB equipment is acquired, and when the upper computer enumerates the USB equipment, the controller based on the embedded Linux system sends the enumeration information to the upper computer, so that the upper computer is identified as the simulated USB equipment. And when the simulated USB equipment is USB printing equipment, the device can simulate the information of the original USB printing equipment, does not need to reinstall a printing driver, quickly replaces the original USB printing equipment, and is simpler and more convenient to operate.
On the basis of the USB device simulation apparatus shown in fig. 1, this embodiment also provides another USB device simulation apparatus, see fig. 2, which is a schematic structural diagram of the USB device simulation apparatus.
As can be seen from fig. 2, the USB device simulation apparatus 100 includes a controller 11, and a USB Type a interface 21, a USB Type B interface 22, and a print module 23, which are respectively connected to the controller 11. The controller 11 is connected to the host computer 200 through the USB Type B interface 22, and is connected to the USB printer 300 through the USB Type a interface 21.
In this embodiment, the USB printer 300 is a simulated USB device, and the USB device simulator 100 is configured to simulate the USB printer 300, so that the host computer 200 recognizes the simulated USB printer 300 and performs printing by the USB device simulator 100.
In the USB Device simulation apparatus 100 shown in fig. 2, the controller 11 runs an embedded Linux system, in which a USB Device driver is preloaded, in which enumeration information of a simulated USB Device is preset, that is, in which enumeration information of the USB printer 300 is preset. Thus, when the controller 11 receives an inquiry signal from the host computer 200, the controller 11 transmits the enumeration information to the host computer 200 through the USB Device driver, so as to be recognized as the USB printer 300 by the host computer 200.
Here, the print module 23 is a hardware module having a print function, and the controller 11 transmits print data acquired from the host computer 200 to the print module 23, and the print module 23 performs a print operation. In at least one possible embodiment, the USB device simulation apparatus 100 may further include a power module for providing power to the apparatus; the apparatus may further comprise a storage module for storing data. In other possible embodiments, the USB device simulation apparatus 100 may further extend other modules as needed, for example: the network connection module, serial port, etc. may be set as required by the specific expansion component, which is not limited herein.
The USB equipment simulation device provided by the embodiment can simulate the information of the USB printing equipment, does not need to reinstall a printing driver, realizes quick replacement of the USB printing equipment, and is simpler and more convenient to operate.
Corresponding to the above-mentioned USB Device simulation apparatus, this embodiment also provides a USB Device simulation method, referring to fig. 3, which is a schematic flow chart of a USB Device simulation method, where the method is applied to an embedded Linux system, and a USB Device driver is preloaded in the embedded Linux system, and enumeration information of a simulated USB Device is preset in the USB Device driver. As can be seen from fig. 3, the method comprises the steps of:
step S302: when an inquiry signal of the upper computer is received, the enumeration information is sent to the upper computer through the USB Device driver, so that the upper computer is identified as the simulated USB Device.
In the USB device simulation method, enumeration information of the simulated USB device is acquired, and when the host computer enumerates the USB device, the controller based on the embedded Linux system sends the enumeration information to the host computer, so that the host computer can recognize the enumeration information as the simulated USB device. And when the simulated USB equipment is USB printing equipment, the device can simulate the information of the original USB printing equipment, does not need to reinstall a printing driver, quickly replaces the original USB printing equipment, and is simpler and more convenient to operate.
The implementation principle and the generated technical effects of the method for simulating the USB equipment provided by the embodiment of the invention are the same as those of the embodiment of the device for simulating the USB equipment, and for the sake of brief description, the corresponding contents in the embodiment of the device for simulating the USB equipment can be referred to for the parts, which are not mentioned in the embodiment of the method for simulating the USB equipment.
In another embodiment, referring to fig. 4, a flowchart of another method for simulating a USB Device is shown, wherein the method is applied to an embedded Linux system, and a USB Device driver is preloaded in the embedded Linux system, and the method includes the following steps:
s402: and monitoring the device management event of the embedded Linux system.
In one possible implementation manner, first, system kernel information of the embedded Linux system is acquired; then, monitoring the device management event in the system kernel information.
S404: when the fact that the USB equipment is inserted into the appointed USB interface is monitored, interface event information of the USB equipment is obtained.
S406: and generating a file path of the sysfs file system of the USB equipment according to the interface event information.
In one possible implementation manner, the step of generating the file path of the sysfs file system of the USB device according to the interface event information may be implemented through the following steps 21-22:
(21) Obtaining a devpath character string in the interface event information;
(22) And splicing the devpath character string with the/sys/character string to obtain a file path of the sysfs file system of the USB equipment.
S408: and acquiring enumeration information of the USB device from the USB device through the file path.
Taking the simulated device as a USB printer as an example, the enumeration information obtained from the sysfs file system of the USB printer through the obtained file path includes: vendorID, productID bcdDevice, mangafacter, serial, ieee1284_id, bInterfaceClass, bInterfaceSub Class, bInterface Protocol.
S410: when the USB Device driver is loaded, the enumeration information of the emulated USB Device is transferred to the USB Device driver by means of parameter transfer, so as to set the enumeration information into a corresponding data structure in the USB Device driver.
S412: when an inquiry signal of the upper computer is received, the enumeration information is sent to the upper computer through the USB Device driver, so that the upper computer is identified as the simulated USB Device.
The USB equipment simulation method provided by the embodiment of the invention has the same technical characteristics as the USB equipment simulation device provided by the embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
In order to more clearly understand the above-mentioned USB device simulation method, this embodiment also introduces an application example of simulating a USB printer by using the USB device simulation method, where the USB device simulation apparatus simulating a USB printer refers to fig. 2, and the specific steps are as follows.
Step 1: the USB device simulation device is powered on, the embedded Linux system is started, the system udev is initialized, operating system kernel (hereinafter referred to as kernel) information is obtained through netlink, and a kernel device management event (namely udev event) is monitored. Here udev is a Linux kernel 2.6 family of device managers whose main function is to manage/dev the device nodes under the directory.
Step 2: and receiving the acquired device insertion or extraction event sent by the kernel, and judging whether the device is a USB device if the device insertion or extraction event is the insertion event.
Step 3: and connecting the USB printer needing simulation to the USB Type A interface of the USB device simulation device.
Step 4: the bus and interface event related information of the device is acquired through udev, and the method comprises the following steps: busnum, devname, devnum, devpath, devtype, major, minor, product, seqnum and subsystem.
Step 5: and splicing the devpath character string and/sys/character string in the interface event into the relevant file path of the sysfs file system of the USB printer. The enumeration information of the USB printer is acquired through the file under the path, and the enumeration information acquired from the sysfs file system comprises: vendorID, productID bcdDevice, mangafacter, serial, ieee1284_id, bInterfaceClass, bInterfaceSubClass and bInterfaceProtocol. And, the type of the inserted USB device is judged by the information.
Step 6: and recording the enumeration information of the USB equipment acquired in the sysfs into a database.
Step 7: judging whether a USB Device driver of the USB equipment simulation Device is added into the system or not, and if the USB Device driver is loaded, unloading the USB Device driver.
Step 8: and when the USB Device driver is reloaded, the acquired enumeration information of the USB printer is transmitted in a parameter transmission mode. The USB Device driver sets the enumeration information of the incoming USB printer into a corresponding data structure.
Step 9: and the USB Type B port of the USB equipment simulation device is connected to the upper computer through a connecting wire.
Step 10: after connection, the upper computer enumerates the accessed USB equipment, at the moment, the USB Device driver of the USB equipment simulation Device is initialized, and after initialization, the Device returns enumeration information to the upper computer, so that the effect of simulating the USB printer is achieved.
The relative steps, numerical expressions and numerical values of the components and steps set forth in these embodiments do not limit the scope of the present invention unless it is specifically stated otherwise.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, in the description of embodiments of the present invention, unless explicitly stated and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
In the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or positional relationships shown in the drawings, are merely for convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
The computer program product for performing the USB device simulation method according to the embodiment of the present invention includes a computer readable storage medium storing a non-volatile program code executable by a processor, where the program code includes instructions for executing the USB device simulation method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment and will not be described herein.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the above examples are only specific embodiments of the present invention, and are not intended to limit the scope of the present invention, but it should be understood by those skilled in the art that the present invention is not limited thereto, and that the present invention is described in detail with reference to the foregoing examples: any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or perform equivalent substitution of some of the technical features, while remaining within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (4)
1. The USB Device simulation method is characterized by being applied to an embedded Linux system, wherein a USB Device driver is preloaded in the embedded Linux system, and enumeration information of a simulated USB Device is preset in the USB Device driver; the method comprises the following steps:
when an inquiry signal of an upper computer is received, the enumeration information is sent to the upper computer through the USB Device driver so as to be identified as the simulated USB Device by the upper computer;
the enumeration information of the simulated USB device is obtained by the following method:
monitoring a device management event of the embedded Linux system;
when the fact that a designated USB interface is plugged in by a USB device is monitored, interface event information of the USB device is obtained;
generating a file path of a sysfs file system of the USB equipment according to the interface event information;
and acquiring enumeration information of the USB equipment from the USB equipment through the file path.
2. The USB device emulation method of claim 1, wherein the step of generating a file path of a sysfs file system of the USB device according to the interface event information comprises:
acquiring a devpath character string in the interface event information;
and splicing the devpath character string with the sys/character string to obtain a file path of the sysfs file system of the USB equipment.
3. The USB device emulation method of claim 1, wherein the step of listening for device management events of the embedded Linux system comprises:
acquiring system kernel information of the embedded Linux system;
and monitoring equipment management events in the system kernel information.
4. The USB Device emulation method of claim 1, wherein the enumeration information of the emulated USB Device is set into the USB Device driver by:
when the USB Device driver is loaded, the enumeration information of the emulated USB Device is transferred to the USB Device driver in a parameter transfer mode, so that the enumeration information is set in a corresponding data structure in the USB Device driver.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911314876.2A CN111104075B (en) | 2019-12-18 | 2019-12-18 | USB equipment simulation device and method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911314876.2A CN111104075B (en) | 2019-12-18 | 2019-12-18 | USB equipment simulation device and method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111104075A CN111104075A (en) | 2020-05-05 |
| CN111104075B true CN111104075B (en) | 2023-11-07 |
Family
ID=70422318
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201911314876.2A Active CN111104075B (en) | 2019-12-18 | 2019-12-18 | USB equipment simulation device and method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111104075B (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115905095A (en) * | 2022-10-31 | 2023-04-04 | 深圳市广和通无线股份有限公司 | USB drive-free communication method, device, electronic equipment and storage medium |
| CN117991999A (en) * | 2024-01-02 | 2024-05-07 | 深圳市链科网络科技有限公司 | A cloud printing method based on ARM architecture |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6813669B1 (en) * | 2000-02-24 | 2004-11-02 | International Business Machines Corporation | Agent provided by USB device for executing USB device dependent program in USB host |
| CN105488000A (en) * | 2015-12-23 | 2016-04-13 | 广东数字证书认证中心有限公司 | Method and system for achieving rapid accessing of USB devices |
-
2019
- 2019-12-18 CN CN201911314876.2A patent/CN111104075B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6813669B1 (en) * | 2000-02-24 | 2004-11-02 | International Business Machines Corporation | Agent provided by USB device for executing USB device dependent program in USB host |
| CN105488000A (en) * | 2015-12-23 | 2016-04-13 | 广东数字证书认证中心有限公司 | Method and system for achieving rapid accessing of USB devices |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111104075A (en) | 2020-05-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11151225B2 (en) | License management in pre-boot environments | |
| US10467388B2 (en) | Managing heterogeneous product features using a unified license manager | |
| CN102880532B (en) | Cloud technology-based test system and method | |
| CN105281937B (en) | Server, service management system, and service management method | |
| CN111104075B (en) | USB equipment simulation device and method | |
| CN108170457A (en) | Firmware upgrade method, device and VR head-mounted displays | |
| WO2017036330A1 (en) | Service configuration method and device for network cutover | |
| CN107844305A (en) | The method for upgrading software and embedded device of embedded device | |
| CN114615527B (en) | Hot plug equipment information transmission method, computer equipment and readable medium | |
| CN114489701A (en) | A configuration method, device and electronic device for an artificial intelligence software deployment environment | |
| CN104081369A (en) | Establishing connectivity of modular nodes in a pre-boot environment | |
| WO2009033424A1 (en) | A method and system for obtaining information of user's commands and device for registering user's commands | |
| CN115712542A (en) | Dynamic loading method, device and equipment for monitoring process and storage medium | |
| CN108234174B (en) | Method and device for managing virtual network functions | |
| CN107908418B (en) | Method for upgrading logic program of fiber channel node card and fiber channel bus equipment | |
| US20060267798A1 (en) | Systems and methods for generating network messages | |
| CN105589710A (en) | Remote upgrading method and system | |
| CN117851336A (en) | A method, device, equipment and medium for simulating BMC function | |
| KR102595323B1 (en) | System and method for verifying virtual ecu for automotive embedded system | |
| CN117806206A (en) | Device configuration method and device, electronic device and storage medium | |
| CN111399871A (en) | System updating method, device, equipment and medium for HBA card | |
| KR102178273B1 (en) | Apparatus for providing multifunctional information distribution system low volume terminal emulator and method, computer-readable storage medium and computer program for controlling thereof | |
| CN111580857B (en) | Equipment firmware online configuration method, device and system | |
| CN102111446B (en) | Device connection handling method, combination equipment and host equipment | |
| CN115134391B (en) | Device control method and device for non-internet of things device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |