Method for realizing drive-free printing by using HID (high intensity discharge) equipment in USB (universal serial bus) printing equipment
Technical Field
The invention belongs to the technical field of printing, and particularly relates to a method for realizing printing drive-free by using HID (high intensity discharge) equipment in USB (universal serial bus) printing equipment.
Background
Hid (human Interface device) is a common device type in USB devices, and is a USB device that interacts directly with human, such as a keyboard, a mouse, and a joystick. Among USB devices, HID devices are low cost. Drivers for HID devices are built into windows 98 and later versions and can be used directly by applications to communicate with the device. A printer is one of the output devices of a computer for printing the results of a computer process on an associated medium. The indexes for measuring the quality of the printer comprise three items, namely printing resolution, printing speed and noise.
At present, the installation of a printer is generally divided into two parts, one part is the connection between the printer and a computer, and the other part is the installation of a driver of the printer in an operating system. After entering the operating system, the system will prompt to find a printer, and the system will install the printer driver to use the printer. Some operating systems have many printer drivers, and most common printer drivers can be automatically installed. If the operating system does not have the drive of the printer, a drive disc attached to the printer needs to be placed in a computer, and then installation is carried out according to the system prompt; the existing process of installing the driver is relatively redundant, and basically, the driver is required to be operated according to step prompts. When a connecting wire of a USB printer is plugged into a USB interface of a computer, the system prompts a new printer to be found, a drive optical disk is placed into an optical drive according to the prompt, a 'confirm' button is clicked, the system starts to search a drive program of the printer at the moment, the system finds the drive program of the printer and clicks the 'confirm' button again, the system starts to copy files from the optical disk at the moment, the drive program is installed, finally, the installation is prompted to be completed, and the 'complete' button is clicked.
Disclosure of Invention
Aiming at the situation, in order to overcome the defects of the prior art, the invention provides a method for realizing printing drive-free by using an HID in a USB printing device, which abandons the traditional method that the device can be connected to realize printing after a printing device driver is installed, adopts the HID type to realize plug-and-play without installing the driver, thus omitting the step of installing the driver and avoiding various problems caused by the error of driver installation.
The technical scheme adopted by the invention is as follows: the invention discloses a method for realizing printing drive-free by using HID (high intensity discharge) equipment in USB (universal serial bus) printing equipment, which comprises the following steps of:
1) the method comprises the steps that a USB communication protocol is matched and is connected to a PC end through a USB interface, the USB communication comprises control transmission, interrupt transmission, isochronous transmission and block transmission, any transmission needs to be initiated by a USB host interface in the PC end, when a printer device is plugged into the PC end and the process of pulling out the printer device is inquired by a host, after the printer device is connected to the PC end, the host inquires device information of the printer device through the control transmission, then drive configuration is carried out according to the printer device information, and after the configuration is finished, data information is continuously sent through the interrupt transmission until the printer device is pulled out;
2) when the printer equipment is connected with the PC end, the PC end can identify the connected printer equipment through the USB interface, drive is configured according to the equipment information submitted by the printer equipment, the equipment is inquired after configuration is completed, the equipment is obtained through a registration mode after the current equipment is found, the information of the currently connected equipment can be read after registration is successful, and data can be sent to the currently connected equipment to start a printing task;
3) when the printer equipment is connected with the PC through the USB interface, the PC can detect that the equipment is inserted, the equipment is initialized through the init method, the Hid _ find method is called to search the equipment, the Hid _ register method is called to register after the equipment is successfully found, the connected printer equipment is confirmed according to a callback result obtained after registration, at the moment, data can be written into the printer equipment through the Hid _ write method, and the printer equipment starts to print a task until printing is finished after receiving the sent data.
The invention with the structure has the following beneficial effects: according to the method for achieving printing without driving by using the HID in the USB printing equipment, the traditional method that the printing equipment can be connected to realize printing after a driving program of the printing equipment needs to be installed is abandoned, the method is adopted as the HID to achieve plug-and-play without installing the driving program, the step of installing the driver is omitted, and various problems caused by error in driving and installing are avoided.
Drawings
FIG. 1 is a flow chart of a method for implementing printing drive-free by using an HID device in a USB printing device according to the present invention;
fig. 2 is a schematic circuit diagram of the present invention.
The MCU is a central processing unit of the printer, is provided with a USB 2.0 full-speed interface, and has a fixed resistor pulled up in an internal D +; fixed resistors are respectively pulled down on D + and D-of a USB host interface in the PC terminal, and the USB driver is matched with a software protocol to judge the voltage change on a D + line, so that the printer is identified as a full-speed USB device, and then the printer displays the full-speed USB device as a USB HID device on the PC terminal, and drive-free printing is realized.
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments; 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.
As shown in fig. 1-2, the method for implementing print drive-free by using HID device in USB printing device of the present invention includes the following steps:
1) the method comprises the steps that a USB communication protocol is matched and is connected to a PC end through a USB interface, the USB communication comprises control transmission, interrupt transmission, isochronous transmission and block transmission, any transmission needs to be initiated by a USB host interface in the PC end, when a printer device is plugged into the PC end and the process of pulling out the printer device is inquired by a host, after the printer device is connected to the PC end, the host inquires device information of the printer device through the control transmission, then drive configuration is carried out according to the printer device information, and after the configuration is finished, data information is continuously sent through the interrupt transmission until the printer device is pulled out;
2) when the printer equipment is connected with the PC end, the PC end can identify the connected printer equipment through the USB interface, drive is configured according to the equipment information submitted by the printer equipment, the equipment is inquired after configuration is completed, the equipment is obtained through a registration mode after the current equipment is found, the information of the currently connected equipment can be read after registration is successful, and data can be sent to the currently connected equipment to start a printing task;
3) when the printer equipment is connected with the PC through the USB interface, the PC can detect that the equipment is inserted, the equipment is initialized through the init method, the Hid _ find method is called to search the equipment, the Hid _ register method is called to register after the equipment is successfully found, the connected printer equipment is confirmed according to a callback result obtained after registration, at the moment, data can be written into the printer equipment through the Hid _ write method, and the printer equipment starts to print a task until printing is finished after receiving the sent data.
When the printer is connected to the PC end, a host computer inquires about equipment information of the printer equipment through control transmission, then drive configuration is carried out according to the printer equipment information, and after the configuration is finished, data information is continuously sent through interrupt transmission until the printer equipment is pulled out; when the printer equipment is connected with the PC end, the PC end can identify the connected printer equipment through the USB interface, drive is configured according to the equipment information submitted by the printer equipment, the equipment is inquired after configuration is completed, the equipment is obtained through a registration mode after the current equipment is found, the information of the currently connected equipment can be read after registration is successful, and data can be sent to the currently connected equipment to start a printing task; when the printer device is connected with the PC through the USB interface, the PC can detect that the device is inserted, the device is initialized through the init method, the Hid _ find method is called to search the device, the Hid _ register method is called to register after the device is successfully found, the connected printer device is confirmed according to a callback result obtained after registration, data can be written into the printer device through the Hid _ write method, the printer device starts to print a task until printing is completed after receiving the sent data, the whole work flow of the invention is realized, and the step can be repeated when the printer device is used next time.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
The present invention and its embodiments have been described above, and the description is not intended to be limiting, and the drawings are only one embodiment of the present invention, and the actual structure is not limited thereto. In summary, those skilled in the art should appreciate that they can readily use the disclosed conception and specific embodiments as a basis for designing or modifying other structures for carrying out the same purposes of the present invention without departing from the spirit and scope of the invention as defined by the appended claims.