CN113900603A - Analog printing method, computing device and storage medium - Google Patents

Analog printing method, computing device and storage medium Download PDF

Info

Publication number
CN113900603A
CN113900603A CN202111502923.3A CN202111502923A CN113900603A CN 113900603 A CN113900603 A CN 113900603A CN 202111502923 A CN202111502923 A CN 202111502923A CN 113900603 A CN113900603 A CN 113900603A
Authority
CN
China
Prior art keywords
printer
virtual
server
data
offline
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
CN202111502923.3A
Other languages
Chinese (zh)
Other versions
CN113900603B (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.)
Uniontech Software Technology Co Ltd
Original Assignee
Uniontech Software 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 Uniontech Software Technology Co Ltd filed Critical Uniontech Software Technology Co Ltd
Priority to CN202111502923.3A priority Critical patent/CN113900603B/en
Publication of CN113900603A publication Critical patent/CN113900603A/en
Application granted granted Critical
Publication of CN113900603B publication Critical patent/CN113900603B/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/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1229Printer resources management or printer maintenance, e.g. device status, power levels
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Accessory Devices And Overall Control Thereof (AREA)

Abstract

The invention discloses a simulation printing method, a computing device and a storage medium, and the method comprises the following steps: generating a corresponding printer configuration according to each printer information; constructing a virtual printer corresponding to each entity printer according to the printer configuration to obtain one or more virtual printers, and setting a server to be connected with the one or more virtual printers; when receiving a device list request of a client, sending the device list to the client; when a connection request of a client according to a virtual printer selected from the equipment list is received, generating offline printer data according to printer information and printer configuration corresponding to the selected virtual printer; the offline printer data is sent to the client. The analog printing method of the invention does not need to actually purchase and install the printer, saves a large amount of time and cost, and can complete the development of printer drivers of various printers only by printer information of the printer.

Description

Analog printing method, computing device and storage medium
Technical Field
The present invention relates to the field of operating systems, and in particular, to a method for simulating printing, a computing device, and a storage medium.
Background
With the development of various operating systems, the adaptability of hardware, such as a printer, for the operating systems needs to be improved. In the operating system, a driver is required for calling the printer so that the user can normally use the printer. In order to better adapt the printer, the printer is sometimes connected to a computer, and a printing task is executed through a driver, and the driver of the printer outputs printing data. By researching and analyzing the printing data, the printing driver can be better developed and adapted.
However, in the prior art, when an offline printer is added and a corresponding printer driver is installed, and printing is performed by using any program, the added printer can be normally selected as a target printer to generate a print job, but the corresponding printer driver is not operated, and the system does not call the printer driver if the system does not detect a physical printer. Therefore, when the printer driver of the printer is tested and adapted, if the physical printer is not connected, the printer driver cannot be normally called.
For this reason, a new analog printing method is required.
Disclosure of Invention
To this end, the present invention provides an analog printing method in an attempt to solve or at least alleviate the above-identified problems.
According to one aspect of the present invention, there is provided a method for simulating printing, adapted to be executed in a server, the server being in communication with one or more clients, the server storing therein printer information of one or more physical printers, the clients including therein printer drivers, the method comprising the steps of: generating a corresponding printer configuration according to each printer information; constructing a virtual printer corresponding to each entity printer according to the printer configuration to obtain one or more virtual printers, and setting a server to be connected with the one or more virtual printers; transmitting a device list to the client when receiving a device list request of the client, the device list including one or more virtual printers connected to the server; when a connection request of a client according to a virtual printer selected from the equipment list is received, generating offline printer data according to printer information and printer configuration corresponding to the selected virtual printer; and sending the offline printer data to the client so that the client calls a printer driver according to the offline printer data and outputs the printing data.
Optionally, in the method according to the present invention, the printer information includes a manufacturer identifier, a product identifier, and a communication identifier of the printer, and generating the corresponding printer configuration according to each piece of printer information includes: and generating corresponding printer configuration according to the manufacturer identification, the product identification and the communication identification.
Optionally, in the method according to the present invention, the printer configuration includes a device descriptor, a configuration descriptor, an interface descriptor, and a termination descriptor, and the building of the virtual printer corresponding to each physical printer according to the printer configuration includes: and constructing a virtual printer corresponding to the entity printer according to the device descriptor, the configuration descriptor, the interface descriptor and the termination point descriptor.
Optionally, in the method according to the present invention, when receiving a connection request from the client according to a virtual printer selected from the device list, generating offline printer data according to printer information and printer configuration corresponding to the selected virtual printer includes: sending connection confirmation information to the client so that the client establishes communication connection with the virtual printer according to the connection confirmation information and sends a request for acquiring offline printer data to the server according to the communication connection with the virtual printer; and after receiving a request for acquiring the offline printer data from the client, generating the offline printer data according to the printer information and the printer configuration corresponding to the selected virtual printer.
Optionally, in the method according to the present invention, the offline printer data includes a device descriptor, a communication identifier, and port information, the client is configured with a host controller and runs an operating system, the operating system includes a kernel and a driver library, the driver library includes multiple drivers, and the client calls the printer driver according to the offline printer data includes the steps of: the host controller sends an enumeration equipment request to the kernel according to port information in the offline printer data; after receiving the enumeration equipment request, the kernel matches a driver corresponding to the virtual printer from a driver library according to the equipment descriptor and the communication identifier; and the kernel calls the matched driver to output the print data.
According to one aspect of the present invention, there is provided a method for simulating printing, adapted to be executed in a client, the client being in communication connection with a server, an operating system running in the client, the operating system including a kernel and a driver library, the driver library including a plurality of drivers, the method including the steps of: sending a device list request to a server to obtain one or more virtual printers connected to the server; selecting a virtual printer to be connected from the device list transmitted by the server, and transmitting a virtual printer connection request to the server so that the server generates offline printer data according to the selected virtual printer; when receiving offline printer data sent by a server, constructing a host controller, and sending an enumeration device request to a kernel through a virtual host controller according to the offline printer data; after receiving the enumeration equipment request, the kernel matches a driver corresponding to the virtual printer from a driver library according to the offline printer data; and calling the matched driver by the kernel to output the print data.
Alternatively, in the method according to the present invention, selecting a virtual printer to be connected from the device list transmitted by the server, and transmitting a virtual printer connection request to the server so that the server generates offline printer data according to the selected virtual printer includes the steps of: and when receiving the connection confirmation information sent by the server, establishing communication connection with the virtual printer according to the connection confirmation information, and sending a request for acquiring the offline printer data to the server according to the communication connection with the virtual printer, so that the server generates the offline printer data after receiving the request for acquiring the offline printer data by the client.
Optionally, in the method according to the present invention, the offline printer data includes port information, and sending an enumeration device request to the kernel according to the offline printer data includes: and sending an enumeration device request to the kernel according to the port information in the offline printer data.
Optionally, in the method according to the present invention, the offline printer data further includes a device descriptor and a communication identifier, and the step of matching the driver corresponding to the virtual printer from the driver library according to the offline printer data includes: and matching the driver corresponding to the virtual printer from the driver library according to the device descriptor and the communication identifier.
Optionally, in the method according to the present invention, further comprising the step of: constructing a new driver according to the printing data, wherein the new driver is adapted to the new operating system; and installing a new operating system in the client, and running a new driver in the new operating system to call the entity printer corresponding to the virtual printer.
According to another aspect of the present invention, there is provided a computing device comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for performing the analog printing method according to the present invention.
According to yet another aspect of the present invention, there is provided a computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computing device, cause the computing device to perform a simulated printing method according to the present invention.
The invention discloses a simulation printing method which is suitable for being executed in a server. Specifically, only the printer information of the entity printer is needed, the printer configuration is generated according to the printer information, and further the virtual printer can be constructed according to the printer configuration. And when receiving a connection request of the client according to the virtual printer selected from the equipment list, the server generates offline printer data according to printer information and printer configuration corresponding to the virtual printer. And then, the virtual printer data is sent to the client, and the client can call a printer driver according to the offline printer data and output the printing data. The analog printing method of the invention does not need to actually purchase and install the printer, saves a large amount of time and cost, and can complete the development of printer drivers of various printers only by printer information of the printer. And through constructing the virtual printer at the server side, the client side can call the virtual printer of the server after acquiring the offline printer data of the virtual printer, and can normally perform offline printing through the offline printer data even after being connected with the server in a cutting mode, call a printer driver and output the printing data.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description when read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a server and client communication connection according to an example embodiment of the present invention;
FIG. 2 illustrates a block diagram of a computing device 200, according to an exemplary embodiment of the invention;
FIG. 3 shows a schematic flow diagram of a method 300 of simulating printing according to an exemplary embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art. Like reference numerals generally refer to like parts or elements.
Fig. 1 shows a schematic diagram of a server and a client communication connection according to an exemplary embodiment of the present invention. As shown in FIG. 1, client 110 is communicatively coupled to server 120. In the present invention, the server may be connected to one or more clients, and the connection manner between the server 120 and the clients shown in fig. 1 is only exemplary, and the present invention does not limit the number of clients connected to the server 120.
The client 110 includes a hardware layer 111 and runs an operating system 113. Also included in operating system 113 are driver library 115 and kernel 114. The driver library 115 includes a plurality of printer drivers, each adapted to a physical printer. The present invention does not limit the type of the operating system 113, and the operating system 113 may be implemented as a Windows system. The system layer 111 is configured with a host controller 112, and the host controller 112 is a virtual host controller and is used for connecting to a virtual printer, so that the kernel 114 calls a printer driver in the driver library 115 according to offline printer data of the virtual printer and outputs print data. The offline printer data includes device descriptors, communication identifiers, and port information.
The server 120 includes a hardware layer 121, the hardware layer 121 includes an external memory 123, and is configured with a host controller 122. The external memory stores a host controller 112 as a virtual host controller for connecting to a virtual printer. The server 120 collects the printer information of one or more entity printers in advance, and specifically, the printer information can be obtained by searching from a network or entered by a developer. The host controller 112 is a virtual host controller for connecting to a virtual printer. The operating system 124 is also run in the server 120, the present invention does not limit the type of the operating system 124, and when the operating system 124 is implemented as a linux system, the kernel 125 can be implemented as a linux kernel. The printer information includes a manufacturer identification, a product identification, and a communication identification of the printer.
Client 110 and server 120 in FIG. 1 may be implemented as a computing device. FIG. 2 illustrates a block diagram of a computing device 200, according to an exemplary embodiment of the invention. As shown in FIG. 2, in a basic configuration 202, a computing device 200 typically includes a system memory 206 and one or more processors 204. A memory bus 208 may be used for communication between the processor 204 and the system memory 206.
Depending on the desired configuration, the processor 204 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a digital information processor (DSP), or any combination thereof. The processor 204 may include one or more levels of cache, such as a level one cache 210 and a level two cache 212, a processor core 214, and registers 216. Example processor cores 214 may include Arithmetic Logic Units (ALUs), Floating Point Units (FPUs), digital signal processing cores (DSP cores), or any combination thereof. The example memory controller 218 may be used with the processor 204, or in some implementations the memory controller 218 may be an internal part of the processor 204.
Depending on the desired configuration, system memory 206 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 206 may include an operating system 220, one or more programs 222, and program data 228. In some embodiments, the program 222 may be arranged to execute the instructions 223 of the method 300 according to the invention on an operating system by one or more processors 204 using the program data 228.
Computing device 200 may also include a storage interface bus 234. The storage interface bus 234 enables communication from the storage devices 232 (e.g., removable storage 236 and non-removable storage 238) to the basic configuration 202 via the bus/interface controller 230. Operating system 220, programs 222, and at least a portion of data 224 can be stored on removable storage 236 and/or non-removable storage 238, and loaded into system memory 206 via storage interface bus 234 and executed by one or more processors 204 when computing device 200 is powered on or programs 222 are to be executed.
Computing device 200 may also include an interface bus 240 that facilitates communication from various interface devices (e.g., output devices 242, peripheral interfaces 244, and communication devices 246) to the basic configuration 202 via the bus/interface controller 230. The example output device 242 includes a graphics processing unit 248 and an audio processing unit 250. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 252. Example peripheral interfaces 244 can include a serial interface controller 254 and a parallel interface controller 256, which can be configured to facilitate communications with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 258. An example communication device 246 may include a network controller 260, which may be arranged to communicate with one or more other computing devices 200 over a network communication link via one or more communication ports 264.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
In computing device 200 according to the present invention, program 222 includes a plurality of program instructions for analog printing method 300 that may direct processor 204 to perform some of the steps of analog printing method 300 operating in computing device 200 of the present invention so that various portions of computing device 200 effect the output of print data by performing analog printing method 300 of the present invention.
Computing device 200 may be implemented as a server, e.g., file server 240, database 250, a server, an application server, etc., which may be a device such as a Personal Digital Assistant (PDA), a wireless web-browsing device, an application-specific device, or a hybrid device that include any of the above functions. May be implemented as a personal computer including both desktop and notebook computer configurations, and in some embodiments, computing device 200 is configured to simulate printing method 300.
FIG. 3 shows a schematic flow diagram of a method 300 of simulating printing according to an exemplary embodiment of the invention. Steps S301, S302, S304, S306 and S307 in the analog printing method 300 in the present invention are adapted to be executed in a server, and steps S303, S305, S308, S309 and S310 are adapted to be executed in a client.
The method 300 is described below in conjunction with the client 110 and the server 120. The server 120 stores therein printer information for one or more physical printers. The printer information is used to identify the physical printers, and the printer information of each physical printer is different. The printer information includes a manufacturer identification, a product identification, and a communication identification of the printer. At present, most of printers are connected with a computer through a USB (universal serial bus), the printers belong to USB equipment, and each USB equipment is provided with a corresponding manufacturer identifier, a corresponding product identifier and a corresponding communication identifier.
The Vendor Identification (VID) is a unique vendor ID assigned by the USB Association to each USB device manufacturer, 03f0 according to one embodiment of the present invention.
The Product Identification (PID) is a unique product ID, also 4 characters, assigned to its own USB device by each USB device manufacturer. According to one embodiment of the invention, the product identification of one physical printer is ac2 a.
The communication identifier (IEEE 1284 ID) is an identification rule set by the IEEE1284 standard of the institute of electrical and electronics engineers to uniquely identify a certain type of printer device. According to one embodiment of the present invention, the communication identifier of an entity PRINTER is MFG HP, CMD PJL, PML, PCLXL, PWG _ RASTER, URP, PCL, PDF, POSTSCRIPT, MDL HP ColorLaserJet M253-M254, CLS PRINTER, DES HP Color LaserJet M254dw, MEM =219MB, PRN T6B60A, COMMENT RES =600x8, LEDMDIS USB # FF #04#01, HPCID LJPDLV1, IPP-E FF-04-01, FF-04-01, FF-09-01, MCT: PR, MCL: DL, MCV: 2.0;
the communication identifier includes important information such as the manufacturer name, model, and supported printer language of the printer.
Step S301 is first executed to generate a corresponding printer configuration from each printer information. And when generating the printer configuration, generating the corresponding printer configuration according to the manufacturer identification, the product identification and the communication identification. Specifically, various parameters of the printer configuration are determined according to the manufacturer identification, the product identification and the communication identification.
The printer configuration is configuration information of the physical printer, and a virtual printer corresponding to the physical printer can be constructed according to the printer configuration. Each virtual printer corresponds to one entity printer, when the client or the server is connected with the virtual printer, the client and the server call the virtual printer as the entity printer, and the output printing data is the same as the response data output when the entity printer is connected.
The printer configuration includes a device descriptor, a configuration descriptor, an interface descriptor, and a termination descriptor. The device descriptor is the device identification of each USB device, and contains related information about the device. Specifically, the device identifiers include VID, PID, bcdsub, and bcdddevice. Wherein the bcdsub field indicates the version of the USB specification to which the device conforms, e.g., 0x0200 indicates that the device is designed in accordance with the USB 2.0 specification. The bcdddevice field indicates the revision number of the device definition.
The configuration descriptor comprises a series of interfaces, each interface comprising one or more backup arrangements, each backup arrangement consisting of a set of termination points. The configuration descriptor includes an interface, a standby setting, and a termination point. The configuration descriptors may also include custom descriptors defined by the device manufacturer. The initial part of the configuration descriptor is a fixed 9 bytes, the rest are variable, depending on the number of interfaces and their backup settings, and the termination points supported by the device.
The interface descriptor contains information about the alternate settings of the USB interface. Each endpoint in the interface in the endpoint descriptor describes a single input or output stream of the device. The endpoint descriptor contains the address, type, direction, and amount of data that the endpoint can process.
According to one embodiment of the present invention, a physical PRINTER manufacturer identification (VID) 03f0, Product Identification (PID) ac2a, communication identification (IEEE 1284 ID) MFG: HP, CMD: PJL, PML, PCLXL, PWG _ RASTER, URP, PCL, PDF, POSTSCRIPT, MDL: HP ColorLaserJet M253-M254, CLS: PRINTER, DES: HP Color LaserJet M254dw, MEM: MEM =219MB, PRN: T6B60A, COMMENT: RES =600x8, LEDMDIS: USB # FF #04#01, CID: HPLJPDLV1, IPP-E: 04-01, MCFF-04-01, FF-09-01, MCT: PR, MCL: DL, MCV: 2.0.
Generating a corresponding printer configuration according to the printer information of the physical printer, wherein the device descriptor includes:
class DeviceDescriptor():
def __init__(self,
bLength = 18,
bDescriptorType = 1,
bcdUSB = 0,
bDeviceClass = 0,
bDeviceSubClass = 0,
bDeviceProtocol = 0,
bMaxPacketSize0 = 0,
idVendor = 0,
idProduct = 0,
bcdDevice = 0,
iManufacturer = 0,
iProduct = 0,
iSerialNumber = 0,
bNumConfigurations = 0):
self.bLength = bLength
self.bDescriptorType = bDescriptorType
self.bcdUSB = bcdUSB
self.bDeviceClass = bDeviceClass
self.bDeviceSubClass = bDeviceSubClass
self.bDeviceProtocol = bDeviceProtocol
self.bMaxPacketSize0 = bMaxPacketSize0
self.idVendor = idVendor
self.idProduct = idProduct
self.bcdDevice = bcdDevice
self.iManufacturer = iManufacturer
self.iProduct = iProduct
self.iSerialNumber = iSerialNumber
self.bNumConfigurations = bNumConfigurations
def __bytes__(self):
return struct.pack('!BBHBBBBHHHBBBB', self.bLength,
self.bDescriptorType, self.bcdUSB, self.bDeviceClass,
self.bDeviceSubClass, self.bDeviceProtocol,
self.bMaxPacketSize0, self.idVendor, self.idProduct,
self.bcdDevice, self.iManufacturer, self.iProduct,
self.iSerialNumber, self.bNumConfigurations)
the configuration descriptor includes: class configuration descriptor ():
def __init__(self,
bLength = 9,
bDescriptorType = 2,
wTotalLength = 0,
bNumInterfaces = 0,
bConfigurationValue = 1,
iConfiguration = 0,
bmAttributes = 0,
bMaxPower = 0x1):
self.bLength = bLength
self.bDescriptorType = bDescriptorType
self.wTotalLength = wTotalLength
self.bNumInterfaces = bNumInterfaces
self.bConfigurationValue = bConfigurationValue
self.iConfiguration = iConfiguration
self.bmAttributes = bmAttributes
self.bMaxPower = bMaxPower
def __bytes__(self):
return struct.pack('BBHBBBBB',self.bLength, self.bDescriptorType,
self.wTotalLength, self.bNumInterfaces,
self.bConfigurationValue, self.iConfiguration,
self.bmAttributes, self.bMaxPower)
the interface descriptor includes:
class InterfaceDescriptor():
def __init__(self,
bLength = 9,
bDescriptorType = 4,
bInterfaceNumber = 0,
bAlternateSetting = 0,
bNumEndpoints = 0,
bInterfaceClass = 0,
bInterfaceSubClass = 0,
bInterfaceProtocol = 0,
iInterface = 0):
self.bLength = bLength
self.bDescriptorType = bDescriptorType
self.bInterfaceNumber = bInterfaceNumber
self.bAlternateSetting = bAlternateSetting
self.bNumEndpoints = bNumEndpoints
self.bInterfaceClass = bInterfaceClass
self.bInterfaceSubClass = bInterfaceSubClass
self.bInterfaceProtocol = bInterfaceProtocol
self.iInterface = iInterface
def __bytes__(self):
return struct.pack('BBBBBBBBB', self.bLength,
self.bDescriptorType, self.bInterfaceNumber,
self.bAlternateSetting, self.bNumEndpoints,
self.bInterfaceClass, self.bInterfaceSubClass,
self.bInterfaceProtocol, self.iInterface)
the termination point descriptor includes:
class EndpointDescriptor():
def __init__(self,
bLength = 7,
bDescriptorType = 5,
bEndpointAddress = 0,
bmAttributes = 0,
wMaxPacketSize = 0,
bInterval = 0):
self.bLength = bLength
self.bDescriptorType = bDescriptorType
self.bEndpointAddress = bEndpointAddress
self.bmAttributes = bmAttributes
self.wMaxPacketSize = wMaxPacketSize
self.bInterval = bInterval
def __bytes__(self):
return struct.pack('!BBBBHB', self.bLength,
self.bDescriptorType, self.bEndpointAddress,
self.bmAttributes, self.wMaxPacketSize, self.bInterval)
subsequently, step S320 is executed to construct a virtual printer corresponding to each physical printer according to the printer configuration, obtain one or more virtual printers, and set the server 120 to connect with the one or more virtual printers. And when the virtual printer corresponding to each entity printer is constructed according to the printer configuration, constructing the virtual printer corresponding to the entity printer according to the device descriptor, the configuration descriptor, the interface descriptor and the termination descriptor.
A host controller 122 is built into the server 120. The host controller 122 may be implemented as a USB host controller, and the present invention is not limited by the type of the host controller 122. The host controller 122 is a virtual host controller for connecting to a virtual printer built by the server 120.
The server 120 generates a device list including one or more virtual printers connected to the server 120. Specifically, the server 120 constructs and manages a printer list by defining a class (DeviceList class) of a device list.
The DeviceList class includes:
class DeviceList():
def __init__(self):
self.device_list = []
def add(self, device):
self.device_list.append(device)
def __bytes__(self):
ret = struct.pack('!I', len(self.device_list))
for device in self.device_list:
ret += bytes(device)
return ret
def find_device(self, busid):
for device in self.device_list:
if busid == device.busid:
return device
subsequently, step S330 is performed, and the server 120 transmits a device list request to acquire one or more virtual printers connected to the server 120. The client 110 runs an operating system 113, and the operating system 113 includes a kernel 114 and a driver library 115, and the driver library 115 includes a plurality of drivers.
According to one embodiment of the invention, the client 110 communicates with the server 120 using the USBIP protocol. A particular client 110, by sending a command to the server 120: OP _ REQ _ devilist, which sends a device list request to the server 120.
Subsequently, step S340 is performed, and the server 120 transmits the device list to the client 110 when receiving the device list request of the client 110. The device list request of the client 110 is parsed by defining a class of the USBIP protocol in the server 120.
The classes of the USBIP protocol include:
class USBIPHeader():
def __init__(self, data):
tpl = struct.unpack('!HHI', data)
self.version = tpl[0]
self.code = tpl[1]
self.status = tpl[2]
def __str__(self):
return 'version:{0:x}, code:{1:x}, status:{2:x}'.format(
self.version, self.code, self.status)
def __bytes__(self):
return struct.pack('!HHI', self.version, self.code, self.status)
the server 120 parses the device list request of the client 110 and sends the device list to the client 110.
Subsequently, the client 110 performs step S350, selects a virtual printer to be connected from the device list transmitted by the server 120, and transmits a virtual printer connection request to the server 120, so that the server 120 generates offline printer data according to the selected virtual printer.
According to one embodiment of the present invention, the client 110 sends a virtual printer connection request to the server 120 by sending a command OP _ REQ _ IMPORT to the server 120.
The virtual printer connection request includes the virtual printer selected by the client 110 from the device list. Upon receiving the virtual printer connection request, the server 120 transmits connection confirmation information to the client 110. When receiving the connection confirmation information sent by the server 120, the client 110 establishes communication connection with the virtual printer according to the connection confirmation information, and sends a request for acquiring offline printer data to the server 120 according to the communication connection with the virtual printer, so that the server 120 generates offline printer data after receiving the request for acquiring offline printer data by the client 110.
According to one embodiment of the present invention, the client 110 sends a request to the server 120 to acquire offline printer data by sending a command USBIP _ CMD _ SUBMIT to the server 120.
The request for acquiring the offline printer data comprises a request device descriptor, a request communication identifier and a self-command for requesting port information, which are respectively used for acquiring the device descriptor, the communication identifier and the port information.
Subsequently, the server 120 executes step S360, and when receiving a connection request from the client 110 according to the virtual printer selected in the device list, generates offline printer data according to printer information and printer configuration corresponding to the selected virtual printer.
Specifically, the server 120 sends connection confirmation information to the client 110, so that the client 110 establishes a communication connection with the virtual printer according to the connection confirmation information, and sends a request for acquiring offline printer data to the server 120 according to the communication connection with the virtual printer.
According to one embodiment of the invention, the server 120: and USBIP _ RET _ SUBMIT, which sends connection confirmation information to the client 110.
After receiving the request of the client 110 to obtain the offline printer data, the server 120 generates the offline printer data according to the printer information and the printer configuration corresponding to the selected virtual printer. The offline printer data includes device descriptors, communication identifiers, and port information. When the server 120 generates offline printer data, the communication identifier is obtained from the device information, the device descriptor is obtained from the configuration information, and the port information is determined according to the port number and the port state value of the host controller 122 connected to the virtual printer.
Subsequently, step S307 is executed to send the offline printer data to the client 110, so that the client calls a printer driver according to the offline printer data and outputs the print data.
According to one embodiment of the invention, the server 120: and USBIP _ RET _ SUBMIT, which transmits offline print data to the client 110. And the offline printing data is packaged into a URB data block, and the URB (USB request block) is used in the USB device driver to describe a basic carrier and a core data structure used for communicating with the USB device, and comprises important information such as a requested USB endpoint, a data transmission direction and the like.
Subsequently, step S308 is executed, and when offline printer data transmitted by the server 120 is received, the host controller 112 is constructed, and an enumeration device request is transmitted to the kernel 114 according to the offline printer data through the virtual host controller 112. The client 110 builds a host controller 112 for invoking the virtual server 120 connected at the server 120 side.
The host controller 112, upon receiving the port information, may assume that a physical printer is actually connected in the client 110. An enumeration device request is then sent to the kernel 114 based on port information in the offline printer data. The enumeration device request is used to inform the kernel 114 of the driver matching based on offline printer data.
Subsequently, step S309 is executed, and after receiving the enumeration device request, the kernel 114 matches the driver corresponding to the virtual printer from the driver library 115 according to the offline printer data. Specifically, the driver corresponding to the virtual printer is matched from the driver library 115 according to the device descriptor and the communication identifier, and the driver corresponding to the virtual printer is found from the driver library 115.
Finally, step S310 is executed to call the matched driver by the kernel 114 to output the print data. Specifically, the kernel 114 simulates installation of the physical printer according to the offline printer data of the virtual printer through the USBIP driver, and registers the simulated physical printer to the device bus of the operating system 113. So that the printer driver test program in the operating system 113 can normally call the driver matched with the simulated physical printer to output the print data. The print data includes commands for controlling the operation of the printer, so that the printer organizes the printed documents according to the commands, and the printer processes the print data from the computer according to the commands, and finally prints out characters and images accurately.
Based on the print data, a print driver can be developed and debugged. When a new operating system is developed, in order to construct a new print driver to adapt to an entity printer, the working principle and the bottom layer dependence of a driver of the entity printer under the existing operating system need to be researched, and the print driver can be developed and debugged according to the print data of the print driver. The number of the printers is large, some old printers cannot be purchased from the market, and the printers are scattered all over the country, so that the printers cannot be tested on site. And the operating system judges that the computer is not connected with the entity printer, and does not call the printing driver to output the response data. The present invention therefore obtains print data via method 300.
According to an embodiment of the invention, the method further comprises the step of: and constructing a new driver according to the printing data, wherein the new driver is adapted to the new operating system. And the new driver is constructed according to the response data and the new operating system, is used for running in the environment of the new operating system and provides service for the corresponding entity printer. The new operating system is then installed in the client 110, i.e., a new driver can be run in the new operating system to call the physical printer corresponding to the virtual printer.
The invention discloses a simulation printing method which is suitable for being executed in a server. Specifically, only the printer information of the entity printer is needed, the printer configuration is generated according to the printer information, and further the virtual printer can be constructed according to the printer configuration. And when receiving a connection request of the client according to the virtual printer selected from the equipment list, the server generates offline printer data according to printer information and printer configuration corresponding to the virtual printer. And then, the virtual printer data is sent to the client, and the client can call a printer driver according to the offline printer data and output the printing data. The analog printing method of the invention does not need to actually purchase and install the printer, saves a large amount of time and cost, and can complete the development of printer drivers of various printers only by printer information of the printer. And through constructing the virtual printer at the server side, the client side can call the virtual printer of the server after acquiring the offline printer data of the virtual printer, and can normally perform offline printing through the offline printer data even after being connected with the server in a cutting mode, call a printer driver and output the printing data.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim.
Those skilled in the art will appreciate that the modules or units or groups of devices in the examples disclosed herein may be arranged in a device as described in this embodiment, or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. Modules or units or groups in embodiments may be combined into one module or unit or group and may furthermore be divided into sub-modules or sub-units or sub-groups. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to execute the analog printing method of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, computer readable media may comprise computer storage media and communication media. Computer-readable media includes both computer storage media and communication media. Computer storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of computer readable media.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense, and the scope of the present invention is defined by the appended claims.

Claims (12)

1. A method for simulating printing, adapted to be executed in a server, the server being in communication with one or more clients, the server storing therein printer information of one or more physical printers, the clients including therein printer drivers, the method comprising the steps of:
generating a corresponding printer configuration according to each printer information;
constructing a virtual printer corresponding to each entity printer according to the printer configuration to obtain one or more virtual printers, and setting the server to be connected with the one or more virtual printers;
transmitting a device list to the client when receiving a device list request of the client, the device list including one or more virtual printers connected with the server;
when a connection request of the client according to the selected virtual printer in the equipment list is received, generating offline printer data according to printer information and printer configuration corresponding to the selected virtual printer;
and sending the offline printer data to the client so that the client can call a printer driver according to the offline printer data and output printing data.
2. The method of claim 1, wherein the printer information includes a manufacturer identifier, a product identifier, and a communication identifier of the printer, and the generating the corresponding printer configuration according to each printer information includes the steps of:
and generating corresponding printer configuration according to the manufacturer identification, the product identification and the communication identification.
3. The method of claim 2, wherein the printer configuration includes a device descriptor, a configuration descriptor, an interface descriptor, and an endpoint descriptor, and wherein the building of the virtual printer corresponding to each physical printer according to the printer configuration includes the steps of:
and constructing a virtual printer corresponding to the entity printer according to the device descriptor, the configuration descriptor, the interface descriptor and the termination point descriptor.
4. The method according to any one of claims 1-3, wherein the generating offline printer data according to printer information and printer configuration corresponding to the selected virtual printer when receiving a connection request of the client according to the selected virtual printer in the device list comprises:
sending connection confirmation information to the client so that the client establishes communication connection with the virtual printer according to the connection confirmation information and sends a request for acquiring offline printer data to the server according to the communication connection with the virtual printer;
and after receiving a request for acquiring the offline printer data from the client, generating the offline printer data according to the printer information and the printer configuration corresponding to the selected virtual printer.
5. The method as claimed in claim 4, wherein the offline printer data includes device descriptor, communication identifier and port information, the client is configured with a host controller and runs an operating system, the operating system includes a kernel and a driver library, the driver library includes a plurality of drivers, and the client calls the printer driver according to the offline printer data includes the steps of:
the host controller sends an enumeration equipment request to the kernel according to port information in offline printer data;
after receiving an enumeration device request, the kernel matches a driver corresponding to the virtual printer from a driver library according to the device descriptor and the communication identifier;
and the kernel calls the matched driver to output the print data.
6. A method for simulating printing, adapted to be executed in a client, the client being in communication connection with a server, an operating system running in the client, the operating system including a kernel and a driver library, the driver library including a plurality of drivers, the method comprising the steps of:
sending a device list request to the server to obtain one or more virtual printers connected to the server;
selecting a virtual printer to be connected from the equipment list sent by the server, and sending a virtual printer connection request to the server so that the server can generate offline printer data according to the selected virtual printer;
when receiving offline printer data sent by the server, constructing a host controller, and sending an enumeration device request to the kernel through a virtual host controller according to the offline printer data;
after receiving an enumeration device request, the kernel matches a driver corresponding to a virtual printer from the driver library according to the offline printer data;
and calling the matched driver through the kernel to output the print data.
7. The method of claim 6, wherein the selecting a virtual printer to be connected from the device list transmitted from the server and transmitting a virtual printer connection request to the server so that the server generates offline printer data according to the selected virtual printer comprises the steps of:
and when receiving the connection confirmation information sent by the server, establishing communication connection with the virtual printer according to the connection confirmation information, and sending a request for acquiring offline printer data to the server according to the communication connection with the virtual printer, so that the server generates the offline printer data after receiving the request for acquiring the offline printer data by the client.
8. The method of claim 7, wherein the offline printer data includes port information, the sending an enumeration device request to the kernel based on the offline printer data comprising the steps of:
and sending an enumeration device request to the kernel according to the port information in the offline printer data.
9. The method of claim 8, wherein the offline printer data further includes device descriptors and communication identifiers, and the step of matching the driver corresponding to the virtual printer from the driver library according to the offline printer data includes the steps of:
and matching a driver corresponding to the virtual printer from a driver library according to the device descriptor and the communication identifier.
10. The method according to any of claims 6-9, wherein the method further comprises the step of:
constructing a new driver according to the printing data, wherein the new driver is adapted to a new operating system;
and installing a new operating system in the client, and running a new driver in the new operating system to call the entity printer corresponding to the virtual printer.
11. A computing device, comprising:
one or more processors;
a memory; and
one or more apparatuses comprising instructions for performing the method of any of claims 1-10.
12. A computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computing device, cause the computing device to perform the method of any of claims 1-10.
CN202111502923.3A 2021-12-10 2021-12-10 Analog printing method, computing device and storage medium Active CN113900603B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111502923.3A CN113900603B (en) 2021-12-10 2021-12-10 Analog printing method, computing device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111502923.3A CN113900603B (en) 2021-12-10 2021-12-10 Analog printing method, computing device and storage medium

Publications (2)

Publication Number Publication Date
CN113900603A true CN113900603A (en) 2022-01-07
CN113900603B CN113900603B (en) 2022-04-01

Family

ID=79025482

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111502923.3A Active CN113900603B (en) 2021-12-10 2021-12-10 Analog printing method, computing device and storage medium

Country Status (1)

Country Link
CN (1) CN113900603B (en)

Cited By (1)

* 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

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040218212A1 (en) * 2003-04-30 2004-11-04 Jang Ki-Jung Printer management and printing control system used with printers
CN1567284A (en) * 2003-06-13 2005-01-19 北京北佳信息系统有限公司 Method for controlling using of printer under network environment
CN102841766A (en) * 2012-08-22 2012-12-26 青岛飞鸽软件有限公司 Local area network printing system and method
CN105183403A (en) * 2015-09-21 2015-12-23 西安电子科技大学 Printing management and control method based on CUPS framework
CN106557288A (en) * 2016-11-15 2017-04-05 华为技术有限公司 A kind of method and device for obtaining print data
CN111638860A (en) * 2020-05-28 2020-09-08 广州市金库物联科技有限公司 Method for realizing UHF printer and UHF printer
CN112313614A (en) * 2019-05-30 2021-02-02 华为技术有限公司 Method, device and system for printing file in virtual machine by using terminal equipment
CN112732205A (en) * 2020-12-18 2021-04-30 航天信息股份有限公司 Universal printing equipment control method, electronic equipment, storage medium and system
CN113434100A (en) * 2021-08-27 2021-09-24 统信软件技术有限公司 Cloud printing method, computing device and storage medium
CN113741831A (en) * 2021-09-07 2021-12-03 苏州博瑞凯德信息技术有限公司 Intelligent printing method and device, storage medium and electronic equipment

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040218212A1 (en) * 2003-04-30 2004-11-04 Jang Ki-Jung Printer management and printing control system used with printers
CN1550973A (en) * 2003-04-30 2004-12-01 三星电子株式会社 Printer management and printing control system used with printers
CN1567284A (en) * 2003-06-13 2005-01-19 北京北佳信息系统有限公司 Method for controlling using of printer under network environment
CN102841766A (en) * 2012-08-22 2012-12-26 青岛飞鸽软件有限公司 Local area network printing system and method
CN105183403A (en) * 2015-09-21 2015-12-23 西安电子科技大学 Printing management and control method based on CUPS framework
CN106557288A (en) * 2016-11-15 2017-04-05 华为技术有限公司 A kind of method and device for obtaining print data
CN112313614A (en) * 2019-05-30 2021-02-02 华为技术有限公司 Method, device and system for printing file in virtual machine by using terminal equipment
CN111638860A (en) * 2020-05-28 2020-09-08 广州市金库物联科技有限公司 Method for realizing UHF printer and UHF printer
CN112732205A (en) * 2020-12-18 2021-04-30 航天信息股份有限公司 Universal printing equipment control method, electronic equipment, storage medium and system
CN113434100A (en) * 2021-08-27 2021-09-24 统信软件技术有限公司 Cloud printing method, computing device and storage medium
CN113741831A (en) * 2021-09-07 2021-12-03 苏州博瑞凯德信息技术有限公司 Intelligent printing method and device, storage medium and electronic equipment

Cited By (1)

* 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

Also Published As

Publication number Publication date
CN113900603B (en) 2022-04-01

Similar Documents

Publication Publication Date Title
US7752029B2 (en) Method to change USB device descriptors from host to emulate a new device
CN112181328B (en) Printing control system and method and computing device
CN107256134B (en) Method and device for virtualizing POS terminal as computer printer and POS terminal
EP3647956B1 (en) Generalized virtualization platform for systems using hardware abstraction software layers
CN113900603B (en) Analog printing method, computing device and storage medium
US9959130B2 (en) Process simulation for information processing system, information processing method, and information processing program product
CN113157290B (en) Multi-system installation method, computing equipment and storage medium
CN112764694A (en) Printing system, printing method and computing device
CN111610939A (en) Image forming apparatus, method of controlling the same, and computer-readable storage medium
US9691010B2 (en) Information processing apparatus, distributed printing system, and method of controlling printing
US20100149579A1 (en) Methods and structure for automated devcaps file verification
EP2693329A1 (en) Image forming system sharing resources such as fonts
CN115576711A (en) Method and system for simulating returned data and computing equipment
JP2011180771A (en) Information processing device, emulation system and emulation program
JP6973063B2 (en) Image processing system and information processing equipment
CN103034461B (en) Information processing system, data processing equipment and information processing method
US20110283282A1 (en) Image forming apparatus, method of acquiring identification information, and non-transitory computer readable medium
JPH09269874A (en) Information processor, its data processing method and storage medium storing program readable by means of computer
US8643885B2 (en) Printing control apparatus and non-transitory computer readable medium with setting authentication information in a devmode structure
JP2006164026A (en) Device, system, and method for setting output management system, program, and storage medium
JP2012064184A (en) Printing system and printer
JP2009043078A (en) Simulation program and recording medium
KR100657307B1 (en) Print data processing method and apparatus
CN114895927A (en) Software deployment method and system based on cooperative working platform
JP2004021464A (en) Print controller

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