CN111104075A - USB equipment simulation device and method - Google Patents

USB equipment simulation device and method Download PDF

Info

Publication number
CN111104075A
CN111104075A CN201911314876.2A CN201911314876A CN111104075A CN 111104075 A CN111104075 A CN 111104075A CN 201911314876 A CN201911314876 A CN 201911314876A CN 111104075 A CN111104075 A CN 111104075A
Authority
CN
China
Prior art keywords
usb
usb device
upper computer
interface
information
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
CN201911314876.2A
Other languages
Chinese (zh)
Other versions
CN111104075B (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.)
Beijing Data Driven Technology Co ltd
Original Assignee
Beijing Data Driven Technology 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 Beijing Data Driven Technology Co ltd filed Critical Beijing Data Driven Technology Co ltd
Priority to CN201911314876.2A priority Critical patent/CN111104075B/en
Publication of CN111104075A publication Critical patent/CN111104075A/en
Application granted granted Critical
Publication of CN111104075B publication Critical patent/CN111104075B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1203Improving or facilitating administration, e.g. print management
    • G06F3/1205Improving or facilitating administration, e.g. print management resulting in increased flexibility in print job configuration, e.g. job settings, print requirements, job tickets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1224Client or server resources management
    • G06F3/1228Printing driverless or using generic drivers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1236Connection management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1278Dedicated interfaces to print systems specifically adapted to adopt a particular infrastructure
    • G06F3/1279Controller construction, e.g. aspects of the interface hardware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy 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 device simulation device and a method, wherein the device comprises a controller and a USB interface connected with the controller; the controller is connected with an upper computer through the USB interface; an embedded Linux system runs in the controller, a USB Device driving program is loaded in the embedded Linux system in advance, and enumeration information of the simulated USB Device is preset in the USB Device driving program; 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 identified as the simulated USB equipment by the upper computer. According to the invention, the enumeration information of the simulated USB device is obtained, and when the USB device is enumerated by the upper computer, the enumeration information is sent to the upper computer by the controller based on the embedded Linux system, so that the upper computer recognizes the USB device as the simulated USB device.

Description

USB equipment simulation device and method
Technical Field
The invention relates to the technical field of interfaces, in particular to a USB device simulation device and method.
Background
The USB printer is favored by more and more office users due to the advantages of flexible plugging and unplugging, convenient operation, and the like. In some scenarios, a large number of USB printers are required for a job, and the types of USB printers that may actually be put into production use vary. Thus, in the maintenance of the printer, once a certain printer is damaged, it is necessary to resume the print job by replacing a new printer in time.
Currently, in the above application scenario, if a printer of the same model as the damaged printer is absent or not present, after replacing the printer of a different model, a new print driver needs to be reinstalled on the host computer connected to the printer. This printing apparatus replacement requires much time and is cumbersome to operate.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a USB device simulation apparatus and method, which can simulate information of an original USB printing device, do not need to reinstall a print driver, quickly replace the original USB printing device, and are simpler and more convenient to operate.
In a first aspect, an embodiment of the present invention provides a USB device simulation apparatus, including: the controller and the USB interface connected with the controller; the controller is connected with an upper computer through the USB interface; an embedded Linux system runs in the controller, a USB Device driving program is loaded in the embedded Linux system in advance, and enumeration information of the simulated USB Device is preset in the USB Device driving program; 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 identified as the simulated USB equipment by the upper computer.
In a preferred embodiment of the present invention, the simulated USB device is a USB printer.
In a preferred embodiment of the present invention, the USB device simulation apparatus further includes a printing module, and the printing module is connected to the controller.
In a preferred embodiment of the present invention, the USB interface has a USB Type B interface.
In a preferred embodiment of the present invention, the USB device simulation apparatus further includes a USB Type a interface, 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, an 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 pre-loaded in the embedded Linux system, and enumeration information of a simulated USB Device is pre-set in the USB Device driver; the method comprises the following steps: and when an inquiry signal of an upper computer is received, the enumeration information is sent to the upper computer through the USBDevice driver so as to be identified as the simulated USB equipment by the upper computer.
In a preferred embodiment of the present invention, the enumeration information of the simulated USB device is obtained by: monitoring the equipment management event of the embedded Linux system; when the fact that a USB device is inserted into a specified USB interface is monitored, interface event information of the USB device is obtained; generating a file path of the 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.
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: acquiring a devpath character string in the interface event information; and splicing the devpath character string and/sys/character string to obtain a file path of the sysfs file system of the USB device.
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 simulated USB Device is transferred to the USB Device driver in a parameter transfer mode, so that the enumeration information is set 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 an upper computer through the USB interface; an embedded Linux system runs in the controller, a USB Device driving program is loaded in the embedded Linux system in advance, and enumeration information of the simulated USB Device is preset in the USB Device driving program; 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 identified as the simulated USB equipment by the upper computer. In the mode, by acquiring enumeration information of the simulated USB device, when the USB device is enumerated by the upper computer, the enumeration information is sent to the upper computer by the controller based on the embedded Linux system, so that the USB device is identified as the simulated USB device by the upper computer. Moreover, when the simulated USB equipment is the USB printing equipment, the device can simulate the information of the original USB printing equipment, does not need to reinstall a printing drive program, 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 may be learned by the practice of the above-described techniques of the disclosure, or may be learned by practice of the disclosure.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
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 structural diagram of another USB device simulation apparatus according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a USB device simulation method according to an embodiment of the present invention;
fig. 4 is a flowchart illustrating another USB device simulation method according to an embodiment of the present invention.
Icon: 100-USB device simulation apparatus; 11-a controller; 12-a USB interface; 200-an upper computer; 21-USB type a interface; 22-USB Type B interface; 23-a printing module; 300-USB printer.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Considering that in some application scenarios, if a printer with the same model as a damaged printer is absent or not present, after a printer with a different model is replaced, a new print driver needs to be reinstalled on a host connected to the printer, and this print device replacement method needs to take much time and is cumbersome to operate. For the convenience of understanding the present embodiment, a detailed description will be first given of a USB device simulation apparatus disclosed in the present embodiment.
Referring to fig. 1, which is a schematic structural diagram of a USB device simulation apparatus according to an embodiment of the present invention, as shown in fig. 1, the USB device simulation apparatus 100 includes a controller 11 and a USB interface 12 connected to the controller 11, where the controller 11 is connected to an upper computer 200 through the USB interface 12. In one possible embodiment, the USB interface 12 is of the USB Type B interface 22.
In the USB Device simulation apparatus 100, an embedded Linux system is running in the controller 11, and a USB Device driver is loaded in the embedded Linux system in advance, and enumeration information of a simulated USB Device is set in the USB Device driver in advance. The embedded Linux system is an operating system which cuts and modifies an increasingly popular Linux operating system so that the Linux operating system can run on an embedded computer system. The embedded Linux not only inherits the unlimited open source code resources on the Internet, but also has the characteristics of an embedded operating system.
In addition, the USB Device driver is a USB Device driver installer, which is a source code provided by the Linux kernel in this embodiment. In the USB Device driver, enumeration information of the emulated USB Device is set in advance. The simulated USB device can be a USB printer, a USB flash disk and other USB devices.
Here, the USB device is a piece of hardware at the end of the USB cable, and may be divided into three parts, a USB bus interface, a USB logical device, and a functional device. Also, USB devices typically contain device descriptors that indicate the properties and characteristics of a given device. These USB devices provide host software with a range of USB device features and capabilities for configuring the device and locating the USB drivers. Additionally, the USB device driver may also use the device descriptor to determine 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 upper computer 200, the controller 11 sends the enumeration information to the upper computer 200 through the USBDevice driver, so that the upper computer 200 recognizes the enumeration information as the simulated USB device. Here, when the USB interface 12 of the apparatus is connected to the upper computer 200, the upper computer 200 initiates an inquiry to the USB Device to enumerate the connected devices, and at this time, the USB Device driver loaded in the controller 11 initializes and sends the enumeration information to the upper computer 200 so as to be recognized as an emulated USB Device by the upper computer 200.
Here, it is assumed that the emulated USB Device is a USB printer, so that the enumeration information of the USB printer is obtained in advance and set in the 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 upper computer 200 through the USB interface 12, the upper computer 200 issues an inquiry to the apparatus; when the controller 11 receives the inquiry information of the upper computer 200, the enumeration information is sent to the upper computer 200 through the USB Device driver, and at this time, the upper computer 200 acquires the enumeration information of the USB printer, so that the USB Device simulation apparatus 100 is recognized as the USB printer.
Therefore, communication is established between the upper computer 200 and the USB equipment simulation device 100, the USB equipment simulation device 100 simulates a USB printer to interact with the upper computer 200, the upper computer 200 can send printing data to the USB equipment simulation device 100, and the USB equipment simulation device 100 can send printing state information to the upper computer 200, so that the operation of the printer is simulated. 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 upper computer 200, a printing operation can be performed through the printing module, thereby completely replacing a USB printer.
Thus, in some application scenarios, if there is no USB printer with the same model as the damaged printer or the damaged printer is absent, the USB device simulation apparatus 100 provided by the present invention can simulate the USB printer to be replaced without reinstalling the driver, and the USB printer can be identified as the "replaced USB printer" by the upper computer 200 connected to the original, so as to implement printing and quickly recover the printing job. Compared with the mode of replacing printers with different models and reinstalling the printing driver 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 another possible embodiment, when the emulated device is a USB disk, correspondingly, by presetting enumeration information of the USB disk in the USB device driver, when the upper computer 200 queries the device, the controller 11 of the USB device emulation apparatus 100 sends the enumeration information to the upper computer 200, and the enumeration information is the same as the enumeration information returned to the upper computer 200 when the USB disk is connected to the upper computer 200, so that the emulated device is recognized as a USB disk by the upper computer 200. Similarly, other USB devices may also be simulated by the USB device simulation apparatus 100.
The USB equipment simulation device provided by the embodiment of the invention comprises a controller and a USB interface connected with the controller; the controller is connected with an upper computer through the USB interface; an embedded Linux system runs in the controller, a USB Device driving program is loaded in the embedded Linux system in advance, and enumeration information of the simulated USB Device is preset in the USB Device driving program; 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 identified as the simulated USB equipment by the upper computer. In the device, by acquiring enumeration information of the simulated USB equipment, when the USB equipment is enumerated by the upper computer, the enumeration information is sent to the upper computer by the controller based on the embedded Linux system, so that the upper computer recognizes the enumeration information as the simulated USB equipment. Moreover, when the simulated USB equipment is the USB printing equipment, the device can simulate the information of the original USB printing equipment, does not need to reinstall a printing drive program, 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, the present embodiment further provides another USB device simulation apparatus, which is shown in fig. 2 and 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 respectively connected to the controller 11. The controller 11 is connected to the upper 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 an emulated USB device, and the USB device emulation apparatus 100 is configured to emulate the USB printer 300, so that the host computer 200 recognizes the emulated USB printer 300 and prints on the host computer 200 through the USB device emulation apparatus 100.
In the USB Device simulation apparatus 100 shown in fig. 2, an embedded Linux system is running in the controller 11, and a USB Device driver is loaded in advance in the embedded Linux system, and enumeration information of the simulated USB Device is preset in the USB Device driver, that is, enumeration information of the USB printer 300 is preset in the USB Device driver. In this way, when the controller 11 receives the inquiry signal of the host computer 200, the controller 11 transmits the enumeration information to the host computer 200 through the USBDevice 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 the print data acquired from the host computer 200 to the print module 23, so that the print module 23 executes a print operation. In at least one possible embodiment, the USB device simulation apparatus 100 may further include a power module for supplying power to the apparatus; in addition, the device can 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: a network connection module, a serial port, etc., and the specific extension components may be set as required, 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 the printing driver, realizes quick replacement of the USB printing equipment, and is simpler and more convenient to operate.
Corresponding to the USB Device simulation apparatus, this embodiment further provides a USB Device simulation method, and referring to fig. 3, a flowchart of the USB Device simulation method is shown, where the method is applied to an embedded Linux system, and a USB Device driver is pre-loaded in the embedded Linux system, and enumeration information of a simulated USB Device is pre-set in the USB Device driver. As can be seen from fig. 3, the method comprises the following steps:
step S302: when an inquiry signal of an upper computer is received, the enumeration information is sent to the upper computer through the USB Device driving program so as to be identified as the simulated USB equipment by the upper computer.
In the USB device simulation method, the enumeration information of the simulated USB device is acquired, and when the USB device is enumerated by the upper computer, the enumeration information is sent to the upper computer by the controller based on the embedded Linux system, so that the USB device is identified as the simulated USB device by the upper computer. Moreover, when the simulated USB equipment is the USB printing equipment, the device can simulate the information of the original USB printing equipment, does not need to reinstall a printing drive program, 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 USB device simulation method provided by the embodiment of the present invention are the same as those of the USB device simulation apparatus embodiment described above, and for brief description, reference may be made to corresponding contents in the USB device simulation apparatus embodiment described above for the part of the embodiment of the USB device simulation method not mentioned above.
In another embodiment, referring to fig. 4, a flow chart of another USB Device emulation method is shown, wherein the method is applied to an embedded Linux system, and a USB Device driver is pre-loaded in the embedded Linux system, and the method includes the following steps:
s402: and monitoring the equipment management event of the embedded Linux system.
In one possible implementation manner, firstly, system kernel information of the embedded Linux system is obtained; then, the device management event in the system kernel information is monitored.
S404: and when the specified USB interface is monitored to have the USB equipment inserted, acquiring the interface event information of the USB equipment.
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 by the following steps 21 to 22:
(21) acquiring a devpath character string in the interface event information;
(22) and splicing the devpath character string and/sys/character string to obtain a file path of the sysfs file system of the USB device.
S408: and acquiring enumeration information of the USB equipment from the USB equipment 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, manfacturer, serial, ieee1284_ id, bInterfaceClass, bInterfaceSub Class, bInterface Protocol.
S410: when the USB Device driver is loaded, the enumeration information of the simulated USB Device is transferred to the USB Device driver in a parameter transfer mode, so that the enumeration information is set into a corresponding data structure in the USB Device driver.
S412: when an inquiry signal of an upper computer is received, the enumeration information is sent to the upper computer through the USB Device driving program so as to be identified as the simulated USB equipment by the upper computer.
The USB device simulation method provided by the embodiment of the present invention has the same technical features as the USB device simulation apparatus provided by the above 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 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 for simulating a USB printer refers to fig. 2 and includes the following specific steps.
Step 1: the USB equipment simulation device is powered on, an embedded Linux system is started, a system udev is initialized, kernel information of an operating system is acquired through a netlink, and equipment management events (namely udev events) of the kernel are monitored. Here, udev is a Linux kernel 2.6 family device manager whose main function is to manage device nodes under the/dev directory.
Step 2: and receiving the acquired device plugging or unplugging event sent by the kernel, and if the device plugging or unplugging event is a plugging event, judging whether the device is a USB device.
And step 3: and connecting the USB printer needing to be simulated to the USB Type A interface of the USB equipment simulation device.
And 4, step 4: obtaining the relevant information of the bus and interface events of the equipment through udev, including: busnum, devname, devnum, devpath, devtype, major, minor, product, seqnum, and subsystem.
And 5: and splicing the devpath character string and/sys/character string in the interface event into a related file path of the sysfs file system of the USB printer. Acquiring enumeration information of the USB printer through the file under the path, wherein the enumeration information acquired from the sysfs file system comprises the following steps: VendorID, ProductID, bcdDevice, manfacturer, serial, ieee1284_ id, bInterfaceClass, bInterfaceSubClass, and bInterfaceProtocol. And, the type of the inserted USB device is determined by the information.
Step 6: and recording the enumeration information of the USB equipment acquired in the sysfs into a database.
And 7: judging whether the USB Device driver of the USB Device simulation Device is added into the system or not, and if so, unloading the USB Device driver.
And 8: and transmitting the acquired enumeration information of the USB printer in a parameter transmission mode when the USB Device driver is reloaded. The USB Device driver sets the incoming enumeration information for the USB printer into the corresponding data structure.
And 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 USBDevice drive of the USB equipment simulation device can be initialized, and the device can return enumeration information to the upper computer after initialization, so that the effect of simulating the USB printer is achieved.
Unless specifically stated otherwise, the relative steps, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
The flowchart 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 the embodiments of the present invention, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular 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 nonvolatile program code executable by a processor, where instructions included in the program code may be used to execute the USB device simulation method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, which is not described herein again.
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 such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute 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), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. An apparatus for simulating a USB device, comprising: the controller and the USB interface are connected with the controller; the controller is connected with the upper computer through the USB interface; an embedded Linux system runs in the controller, a USB Device driving program is loaded in the embedded Linux system in advance, and enumeration information of the simulated USB Device is preset in the USB Device driving program;
and 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 identified as the simulated USB equipment by the upper computer.
2. The USB device emulation apparatus of claim 1, wherein the emulated USB device is a USB printer.
3. The USB device emulation apparatus of claim 2, further comprising a print module, the print module coupled to the controller.
4. The USB device simulator of claim 2, wherein the USB interface is USBType B interface.
5. The USB device simulation apparatus according to claim 4, further comprising a USB Type A interface, wherein 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.
6. A USB Device simulation method is characterized by being applied to an embedded Linux system, wherein a USB Device driving program is loaded in the embedded Linux system in advance, and enumeration information of a simulated USB Device is preset in the USB Device driving program; the method comprises the following steps:
and 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 equipment by the upper computer.
7. The method according to claim 6, wherein the enumeration information of the emulated USB device is obtained by:
monitoring the equipment management event of the embedded Linux system;
when the fact that a USB device is inserted into a specified USB interface 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.
8. The USB device emulation method of claim 7, 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 devpath character strings in the interface event information;
and splicing the devpath character string and/sys/character string to obtain a file path of the sysfs file system of the USB equipment.
9. The USB device emulation method of claim 7, 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 the equipment management event in the system kernel information.
10. The USB Device emulation method of claim 6, wherein the enumeration information for the emulated USB Device is set into the USB Device driver by:
when the USB Device driver is loaded, the enumeration information of the simulated USB Device is transmitted to the USB Device driver in a parameter transmission mode, so that the enumeration information is set into a corresponding data structure in the USB Device driver.
CN201911314876.2A 2019-12-18 2019-12-18 USB equipment simulation device and method Active CN111104075B (en)

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 true CN111104075A (en) 2020-05-05
CN111104075B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117991999A (en) * 2024-01-02 2024-05-07 深圳市链科网络科技有限公司 Cloud printing method based on ARM architecture
WO2024093542A1 (en) * 2022-10-31 2024-05-10 深圳市广和通无线股份有限公司 Usb drive-free communication method and apparatus, and electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
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

Patent Citations (2)

* Cited by examiner, † Cited by third party
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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024093542A1 (en) * 2022-10-31 2024-05-10 深圳市广和通无线股份有限公司 Usb drive-free communication method and apparatus, and electronic device and storage medium
CN117991999A (en) * 2024-01-02 2024-05-07 深圳市链科网络科技有限公司 Cloud printing method based on ARM architecture

Also Published As

Publication number Publication date
CN111104075B (en) 2023-11-07

Similar Documents

Publication Publication Date Title
US11983406B2 (en) Method for using BMC as proxy NVMeoF discovery controller to provide NVM subsystems to host
US11983129B2 (en) Self-configuring baseboard management controller (BMC)
US11151225B2 (en) License management in pre-boot environments
CN106933753B (en) Control method and device of intelligent interface card
US20170161471A1 (en) Managing Heterogeneous Product Features Using a Unified License Manager
CN112689083B (en) Vehicle-mounted camera configuration method and device, electronic equipment and storage medium
CN111104075A (en) USB equipment simulation device and method
CN111104321A (en) Docker-based cloud platform stability testing method and system
CN109918096A (en) A kind of installation method of server operating system, system and associated component
CN106528226B (en) Installation method and device of operating system
WO2022111277A1 (en) Hot-plug device information transmission method, computer device and readable medium
CN107181606B (en) Method and apparatus for controlling network nodes
CN107277163B (en) Equipment remote mapping method and device
CN108540344B (en) Router upgrading test method and system
CN108234174B (en) Management method and device of virtual network function
CN114115955B (en) Method, system, terminal and storage medium for upgrading FPGA firmware of server resource box
CN107908418B (en) Method for upgrading logic program of fiber channel node card and fiber channel bus equipment
CN115408016A (en) Computing cluster deployment method and device, electronic equipment and storage medium
CN109688000B (en) Method for simultaneously accessing multiple IPTV network management server platforms
CN106445571B (en) Mainboard and starting method
KR102595323B1 (en) System and method for verifying virtual ecu for automotive embedded system
US11374811B2 (en) Automatically determining supported capabilities in server hardware devices
CN116996504A (en) File transmission method, device, equipment and medium
CN116737199A (en) Network card driver installation method, device, equipment and storage medium
CN116820497A (en) Middleware processing method and device, server and storage medium

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