CN111142813A - Method and device for detecting connection state of printer - Google Patents

Method and device for detecting connection state of printer Download PDF

Info

Publication number
CN111142813A
CN111142813A CN201911328943.6A CN201911328943A CN111142813A CN 111142813 A CN111142813 A CN 111142813A CN 201911328943 A CN201911328943 A CN 201911328943A CN 111142813 A CN111142813 A CN 111142813A
Authority
CN
China
Prior art keywords
printer
target printer
printing
connection state
target
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.)
Pending
Application number
CN201911328943.6A
Other languages
Chinese (zh)
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.)
Koubei Shanghai Information Technology Co Ltd
Original Assignee
Koubei Shanghai Information 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 Koubei Shanghai Information Technology Co Ltd filed Critical Koubei Shanghai Information Technology Co Ltd
Priority to CN201911328943.6A priority Critical patent/CN111142813A/en
Publication of CN111142813A publication Critical patent/CN111142813A/en
Pending legal-status Critical Current

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/121Facilitating exception or error detection and recovery, e.g. fault, media or consumables depleted
    • 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/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1259Print job monitoring, e.g. job status

Abstract

The invention discloses a method and a device for detecting the connection state of a printer, wherein the method comprises the following steps: setting a white list of the printer according to the model information of the printer suitable for the state query instruction; judging whether the target printer is contained in a printer white list or not according to the model information of the target printer; if so, sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result; if not, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task. Therefore, according to the scheme of the invention, for the printer which does not support the status query instruction, the preset printing test task is sent to the target printer, and the connection status of the target printer is effectively detected according to the execution result, so that the detection of the connection status of the printer is not limited by the model and the manufacturer of the printer any more, and the method and the device can be suitable for various printers.

Description

Method and device for detecting connection state of printer
Technical Field
The invention relates to the technical field of Internet, in particular to a method and a device for detecting a connection state of a printer.
Background
In the development and practical application of the printer SDK, the connection status of the printer is a problem that needs attention all the time. Meanwhile, there are many types of printers in the market, which may be classified into a bluetooth connection printer, a USB connection printer, and a network printer according to the connection type, or an ESC printer, a label printer, and the like according to the supported instruction.
Moreover, different types and manufacturers of printers often have some differences in performance and quality, and the connection status detection scheme that is more effective for some types or manufacturers of printers is often not suitable for other types or manufacturers of printers. For example, a relatively regular printer manufacturer usually provides a printer status query instruction to assist in determining the connection status of the printer, but the instruction of each manufacturer has a certain difference, which results in that the general applicability of the detection method is not high; meanwhile, a large number of three-party small manufacturer printers do not support the status query instruction at all, and the printer is likely to be blocked instead of acquiring the connection status in the detection mode.
Therefore, a connection status detection scheme that is efficient and generally applicable to various printers is needed to solve the problem of querying the connection status of the printer.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are proposed to provide a method and apparatus for detecting a connection state of a printer that overcome or at least partially solve the above problems.
According to an aspect of an embodiment of the present invention, there is provided a method for detecting a connection state of a printer, including:
setting a white list of the printer according to the model information of the printer suitable for the state query instruction;
judging whether the target printer is contained in a printer white list or not according to the model information of the target printer; if yes, sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result;
if not, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
Optionally, after determining that the model information of the target printer is not included in the printer white list, the method further includes:
monitoring the printing queue, and judging whether to trigger pre-detection according to a monitoring result;
the sending of the preset printing test task to the target printer specifically comprises: and if the pre-detection is triggered, sending a preset printing test task to the target printer.
Optionally, the monitoring the print queue, and determining whether to trigger the pre-detection according to the monitoring result further includes:
and monitoring the printing queue at a preset time interval, judging whether the monitoring result is that the printing task exists or not, and judging whether the monitoring result is that the printing task does not exist or not at the previous time, and if so, judging to trigger the pre-detection.
Optionally, the sending a preset print test task to the target printer further includes: and sending a writing and printing task for writing N blank characters to the target printer.
Optionally, the sending the writing and printing task for writing the N blank characters to the target printer further includes:
reading width information of printing tickets in a printing task, and setting the number of blank characters consistent with the width information;
and sending a writing and printing task for writing the plurality of blank characters of the number to the target printer.
Optionally, the determining the connection state of the target printer according to the execution result of the print test task further includes:
and if the execution result is that the writing is abnormal and/or the waiting time exceeds the preset time, determining that the connection state of the target printer is the abnormal connection state.
Optionally, the determining the connection state of the target printer according to the execution result of the print test task further includes:
and if the execution result is that the writing is normal and the waiting time does not exceed the preset time length, determining that the connection state of the target printer is a connection normal state.
Optionally, the method further includes: if the connection state of the target printer is determined to be a normal connection state, starting printing processing of a printing task; alternatively, the first and second electrodes may be,
and if the connection state of the target printer is determined to be the abnormal connection state, the reconnection operation of the target printer is executed.
According to another aspect of the embodiments of the present invention, there is provided a printer connection state detection apparatus including:
the setting module is suitable for setting a white list of the printer according to the model information of the printer suitable for the state query instruction;
the first judgment module is suitable for judging whether the target printer is contained in a printer white list or not according to the model information of the target printer;
the detection module is suitable for sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result if the detection module is contained in a white list of printers; and if the printer is not included in the printer white list, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
Optionally, the apparatus further comprises:
the monitoring module is suitable for monitoring the printing queue and judging whether to trigger the pre-detection according to a monitoring result;
the detection module is further adapted to: and if the pre-detection is triggered, sending a preset printing test task to the target printer.
Optionally, the monitoring module is further adapted to:
and monitoring the printing queue at a preset time interval, judging whether the monitoring result is that the printing task exists or not, and judging whether the monitoring result is that the printing task does not exist or not at the previous time, and if so, judging to trigger the pre-detection.
Optionally, the detection module is further adapted to: and sending a writing and printing task for writing N blank characters to the target printer.
Optionally, the detection module is further adapted to:
reading width information of printing tickets in a printing task, and setting the number of blank characters consistent with the width information;
and sending a writing and printing task for writing the plurality of blank characters of the number to the target printer.
Optionally, the detection module is further adapted to: and if the execution result is that the writing is abnormal and/or the waiting time exceeds the preset time, determining that the connection state of the target printer is the abnormal connection state.
Optionally, the detection module is further adapted to: and if the execution result is that the writing is normal and the waiting time does not exceed the preset time length, determining that the connection state of the target printer is a connection normal state.
Optionally, the apparatus further comprises: the starting module is suitable for starting the printing processing of the printing task if the connection state of the target printer is determined to be a normal connection state; alternatively, the first and second electrodes may be,
and the reconnection module is suitable for executing reconnection operation of the target printer if the connection state of the target printer is determined to be the abnormal connection state.
According to still another aspect of an embodiment of the present invention, there is provided a computing device including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the detection method of the printer connection state.
According to a further aspect of the embodiments of the present invention, there is provided a computer storage medium, in which at least one executable instruction is stored, and the executable instruction causes a processor to execute an operation corresponding to the method for detecting a connection status of a printer.
According to the method and the device for detecting the connection state of the printer, the white list of the printer is set, whether the target printer is in the white list of the printer is judged, and if the target printer is in the white list of the printer, the connection state of the target printer is detected by using a state inquiry command; if the target printer is not in the connection state, the preset printing test task is sent to the target printer, and the connection state of the target printer is determined according to the execution result of the loop back. Therefore, according to the scheme of the embodiment, on the basis of detecting the connection state by using the state inquiry instruction, for the printer which does not support the state inquiry instruction, the target printer executes the writing operation of the simple characters by sending the preset printing test task to the target printer, and the connection state of the target printer is effectively detected according to the execution result, so that the detection of the connection state of the printer is not limited by the model and the manufacturer of the printer, and the method and the device can be suitable for various printers; and the preset printing test task can not cause the blockage of the printer, and the detection can be completed quickly and accurately.
The foregoing description is only an overview of the technical solutions of the embodiments of the present invention, and the embodiments of the present invention can be implemented according to the content of the description in order to make the technical means of the embodiments of the present invention more clearly understood, and the detailed description of the embodiments of the present invention is provided below in order to make the foregoing and other objects, features, and advantages of the embodiments of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the embodiments of the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart illustrating a method for detecting a connection status of a printer according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method of detecting a connection state of a printer according to another embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a device for detecting a connection status of a printer according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computing device provided in an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can 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 invention to those skilled in the art.
Fig. 1 is a flowchart illustrating a method for detecting a connection status of a printer according to an embodiment of the present invention. As shown in fig. 1, the method comprises the steps of:
step S110: and setting a white list of the printer according to the model information of the printer applicable to the state inquiry instruction.
The printer white list stores information of printers supporting the status query instruction, for example, printer signals recorded in the printer white list.
Step S120: judging whether the target printer is contained in a printer white list or not according to the model information of the target printer; if yes, go to step S130; if not, go to step S140.
According to the embodiment of the invention, whether the connection between the equipment to be printed and the target printer is abnormal or not is determined by detecting the connection state of the target printer in the equipment to be printed. The device to be printed is a device which needs to establish connection with a target printer and send a printing task to the target printer to complete printing. For example, if a file in a computer needs to be printed out through a printer a, the computer is a device to be printed, and the printer a is a target printer.
Specifically, when it is determined that the target printer is included in the printer white list, step S130 is performed to determine the connection status of the target printer by sending a status query instruction to the target printer and according to the query result; otherwise, when it is determined that the target printer is not included in the printer white list, it indicates that the target printer does not support the status query command, and then step S140 is executed to solve the problem that the status query command does not support the printer connection status detection.
Step S130: and sending a state inquiry command to the target printer and determining the connection state of the target printer according to an inquiry result.
Step S140: and sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
Specifically, a writing printer task is sent to the target printer, the writing printing task is different from the printing tasks in the printing queue, and the preset printing test task is generally a task of writing a small number of specific characters into the target printer, wherein the specific characters are simple characters which do not influence the content of the printed receipt. Through the preset printing test task for the target printer, the connection state of the target printer is efficiently and accurately detected by using a small amount of specific characters which do not influence the content of the printed receipt. In the embodiment of the invention, the specific type of the specific character is not limited, and in actual implementation, all simple characters which do not affect the content of the receipt can be used as the specific character, for example, the specific character can be a blank character, a line-feed character, a tabulation character, an underline character, an upper-line character, a dotted-line character, a double-line character and the like; and, in the embodiment of the present invention, the specific number of the specific characters is not limited, and in practical implementation, a person skilled in the art may flexibly set the specific characters, and preferably, the number of the specific characters is less than the number of characters in a line of the receipt.
And the execution result of the preset test printing task can reflect whether the process of writing the specific character into the target printer is normal or not and reflect the writing duration, and on the basis, after the preset print test task is sent to the target printer, the execution result of the system back-throwing is received to determine the connection state of the target printer.
The above embodiment of the present invention is executed by a device to be printed, and may specifically be executed by a detection module dedicated to connection status detection in the device to be printed.
According to the method for detecting the connection state of the printer, a white list of the printer is set, whether the target printer is in the white list of the printer is judged, and if yes, the connection state of the target printer is detected by using a state inquiry instruction; if the target printer is not in the connection state, the preset printing test task is sent to the target printer, and the connection state of the target printer is determined according to the execution result of the loop back. Therefore, according to the scheme of the embodiment, on the basis of detecting the connection state by using the state inquiry instruction, for the printer which does not support the state inquiry instruction, the target printer executes the writing operation of the simple characters by sending the preset printing test task to the target printer, and the connection state of the target printer is effectively detected according to the execution result, so that the detection of the connection state of the printer is not limited by the model and the manufacturer of the printer, and the method and the device can be suitable for various printers; and the preset printing test task can not cause the blockage of the printer, and the detection can be completed quickly and accurately.
Fig. 2 is a flowchart illustrating a method for detecting a connection status of a printer according to another embodiment of the present invention. In the present embodiment, a preset print test job is explained as a write print job for writing a blank character. As shown in fig. 2, the method comprises the steps of:
step S210: and setting a white list of the printer according to the model information of the printer applicable to the state inquiry instruction.
Step S220: judging whether the target printer is contained in a printer white list or not according to the model information of the target printer; if not, step S230 is executed, and if yes, step S250 is executed.
Step S230: and monitoring the printing queue, judging whether to trigger pre-detection according to a monitoring result, and if so, sending a writing and printing task for writing N blank characters to the target printer.
The printing queue refers to a queue for storing printing tasks in the equipment to be printed.
Specifically, the condition of the print jobs in the print queue, such as whether there are print jobs, the number of print jobs, and the like, can be obtained by monitoring the print queue in the device to be printed, and based on this, it is determined whether to trigger a pre-detection, which is a detection of the connection state of the target printer before sending the print job to the target printer. It should be noted that, in the present invention, the specific triggering manner of the pre-detection is not limited, and in the specific implementation, a person skilled in the art can flexibly set the triggering manner according to the requirement of the pre-detection. Optionally, the determination may be performed according to whether there is a change in the print jobs in the print queue, or according to the number of print jobs in the print queue.
Further, the printing queue is monitored at preset time intervals, whether the current monitoring result is that a printing task exists or not and whether the previous monitoring result is that no printing task exists or not are judged, if yes, the triggering pre-detection is judged, and if not, the monitoring is continuously carried out. The method comprises the steps that a detection module in equipment to be printed monitors a printing queue at a preset time interval, whether a printing task exists in the printing queue is monitored, whether the current monitoring result is that the printing task exists and the previous monitoring result is that the printing task does not exist is judged, and if yes, the printing task in the printing queue is changed from the nonexistence to the existence from the previous monitoring time to the current time; if not, the possible conditions are indicated to comprise: the printing tasks exist or do not exist in the printing queue from the previous monitoring time to the current monitoring time, or the printing tasks in the printing queue are changed from the existence to the nonexistence from the previous monitoring time to the current monitoring time. In all cases of yes or no, only when the judgment result is yes, a new printing task is considered to arrive after the printer is idle for a period of time, and at the moment, the pre-detection is judged to be triggered and executed; otherwise, the monitoring is continuously carried out.
By judging whether to trigger the pre-detection in the mode, the pre-detection can be triggered once before a batch of continuous printing tasks are processed, so that the detection of the connection state of the target printer is completed by writing a small amount of blank characters before a large number of printing tasks are started, and the detection efficiency is improved. For example, if the previous monitoring shows that no print job exists in the print queue, and the current monitoring shows that the print job exists in the print queue, the pre-detection is triggered, and then if the print jobs in the print queue are continuously monitored, the pre-detection is not triggered, so that the pre-detection is only carried out before the batch print jobs.
Further, when it is determined that the pre-detection is triggered, a write-print job is sent to the target printer to perform detection of the connection state. The method comprises the steps of reading width information of a printing receipt in a printing task, setting the number of blank characters consistent with the width information, reading the width information by a detection module, setting the number of the blank characters consistent with the width information when the number of characters which can be contained in each row of the receipt corresponding to different width information is different, and sending a writing and printing task for writing a plurality of blank characters in the number to a target printer, wherein the blank characters in one row can be written just, and the influence on the content in the printed receipt is reduced as much as possible. For example, the width information is 58 mm, a row can hold 16 characters, and the number of blank characters is set to 16; the width information is 80 mm, and one line can accommodate 32 systems, the number of blank characters is set to 16.
Step S240: receiving an execution result of the writing and printing task; determining a connection state of the target printer according to the execution result; and if the execution result is that the writing is abnormal and/or the waiting time exceeds the preset time, determining that the connection state of the target printer is the abnormal connection state.
Specifically, after sending a writing and printing task to a target printer, a system for printing the SDK operation of the printing equipment throws back an execution result according to a writing condition, and when the execution result is abnormal writing, that is, N blank characters are not successfully written, and/or the waiting time for writing the N blank characters exceeds a preset time length, the connection state of the target printer is determined to be an abnormal connection state; and if the execution result is that the writing is normal and the waiting time does not exceed the preset time length, determining that the connection state of the target printer is a connection normal state.
If the connection state of the target printer is determined to be a normal connection state, starting the printing processing of the printing tasks, namely processing the printing tasks in the printing queue; or, if the connection state of the target printer is determined to be the connection abnormal state, the reconnection operation of the target printer is executed.
Step S250: and sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result.
It should be noted that, in the present embodiment, the preset print test task is mainly described as writing a blank character as an example, but in actual implementation, the blank character may be replaced by other simple characters, for example, a line-feed character, a tab character, an underline character, an upperline character, a dashed line character, a double-dashed line character, and the like.
According to the detection method of the connection state of the printer, the printing queue is monitored at preset time intervals, the pre-detection is triggered when the current monitoring result indicates that the printing task exists and the previous monitoring result indicates that the printing task does not exist, and then the connection state of the target printer is pre-detected before a new batch of printing tasks are printed, so that the pre-detection in the printing process of continuous printing tasks or in the absence of the printing tasks is reduced, and the pertinence of the pre-detection is improved; when the pre-detection is judged to be triggered, setting the number of blank characters by reading the width information of the printed receipt, and sending a writing and printing task for writing a plurality of blank characters of the number to the target printer, so that the written blank characters reduce the influence on the content of the printed receipt; and whether the target printer can support the state inquiry command is judged, and the connection state of the unsupported target printer is detected by using the writing and printing task, so that the problem of insufficient applicability of detection of the state inquiry command is solved. Therefore, the scheme of the embodiment can be applied to detecting the connection states of various printers by detecting the connection state of the target printer through the writing and printing task; moreover, the printer cannot be blocked by writing blank characters for detection, so that the method is safe and cannot influence the content of the printed receipt.
Fig. 3 is a schematic structural diagram illustrating a detection apparatus for detecting a connection state of a printer according to an embodiment of the present invention. As shown in fig. 3, the apparatus includes:
the setting module 310 is suitable for setting a white list of the printer according to the model information of the printer suitable for the status inquiry instruction;
a first judging module 320, adapted to judge whether the target printer is included in the printer white list according to the model information of the target printer;
the detection module 330 is adapted to send a status query instruction to the target printer and determine the connection status of the target printer according to a query result if the status query instruction is included in the printer white list; and if the printer is not included in the printer white list, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
In an alternative embodiment, the apparatus further comprises:
the monitoring module is suitable for monitoring the printing queue and judging whether to trigger the pre-detection according to a monitoring result;
the detection module is further adapted to: and if the pre-detection is triggered, sending a preset printing test task to the target printer.
In an alternative embodiment, the monitoring module is further adapted to:
and monitoring the printing queue at a preset time interval, judging whether the monitoring result is that the printing task exists or not, and judging whether the monitoring result is that the printing task does not exist or not at the previous time, and if so, judging to trigger the pre-detection.
In an alternative embodiment, the detection module is further adapted to: and sending a writing and printing task for writing N blank characters to the target printer.
In an alternative embodiment, the detection module is further adapted to:
reading width information of printing tickets in a printing task, and setting the number of blank characters consistent with the width information;
and sending a writing and printing task for writing the plurality of blank characters of the number to the target printer.
In an alternative embodiment, the detection module is further adapted to: and if the execution result is that the writing is abnormal and/or the waiting time exceeds the preset time, determining that the connection state of the target printer is the abnormal connection state.
In an alternative embodiment, the detection module is further adapted to: and if the execution result is that the writing is normal and the waiting time does not exceed the preset time length, determining that the connection state of the target printer is a connection normal state.
In an alternative embodiment, the apparatus further comprises: the starting module is suitable for starting the printing processing of the printing task if the connection state of the target printer is determined to be a normal connection state; alternatively, the first and second electrodes may be,
and the reconnection module is suitable for executing reconnection operation of the target printer if the connection state of the target printer is determined to be the abnormal connection state.
An embodiment of the present invention provides a non-volatile computer storage medium, where the computer storage medium stores at least one executable instruction, and the computer executable instruction may execute the method for detecting the connection state of the printer in any of the above method embodiments.
Fig. 4 is a schematic structural diagram of a computing device according to an embodiment of the present invention, and the specific embodiment of the present invention does not limit the specific implementation of the computing device.
As shown in fig. 4, the computing device may include: a processor (processor)402, a Communications Interface 404, a memory 406, and a Communications bus 408.
Wherein: the processor 402, communication interface 404, and memory 406 communicate with each other via a communication bus 408. A communication interface 404 for communicating with network elements of other devices, such as clients or other servers. The processor 402, configured to execute the program 410, may specifically execute relevant steps in the above-described method for detecting a printer connection status of a computing device.
In particular, program 410 may include program code comprising computer operating instructions.
The processor 402 may be a central processing unit CPU, or an application specific Integrated circuit asic, or one or more Integrated circuits configured to implement an embodiment of the present invention. The computing device includes one or more processors, which may be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And a memory 406 for storing a program 410. Memory 406 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 410 may specifically be configured to cause the processor 402 to perform the following operations:
setting a white list of the printer according to the model information of the printer suitable for the state query instruction;
judging whether the target printer is contained in a printer white list or not according to the model information of the target printer; if yes, sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result;
if not, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
In an alternative, the program 410 causes the processor to:
monitoring the printing queue, and judging whether to trigger pre-detection according to a monitoring result;
and if the pre-detection is triggered, sending a preset printing test task to the target printer.
In an alternative, the program 410 causes the processor to:
and monitoring the printing queue at a preset time interval, judging whether the monitoring result is that the printing task exists or not, and judging whether the monitoring result is that the printing task does not exist or not at the previous time, and if so, judging to trigger the pre-detection.
In an alternative, the program 410 causes the processor to:
and sending a writing and printing task for writing N blank characters to the target printer.
In an alternative, the program 410 causes the processor to:
reading width information of printing tickets in a printing task, and setting the number of blank characters consistent with the width information;
and sending a writing and printing task for writing the plurality of blank characters of the number to the target printer.
In an alternative, the program 410 causes the processor to:
and if the execution result is that the writing is abnormal and/or the waiting time exceeds the preset time, determining that the connection state of the target printer is the abnormal connection state.
In an alternative, the program 410 causes the processor to:
and if the execution result is that the writing is normal and the waiting time does not exceed the preset time length, determining that the connection state of the target printer is a connection normal state.
In an alternative, the program 410 causes the processor to:
if the connection state of the target printer is determined to be a normal connection state, starting printing processing of a printing task; or, if the connection state of the target printer is determined to be the connection abnormal state, the reconnection operation of the target printer is executed.
The algorithms or displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. In addition, embodiments of the present invention are not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of embodiments of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best modes of embodiments of the invention.
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 embodiments 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 is, the claimed embodiments of the invention require more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
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. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. 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 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. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components according to embodiments of the present invention. Embodiments of the invention may also be implemented as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing embodiments of the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. Embodiments of the invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names. The steps in the above embodiments should not be construed as limiting the order of execution unless specified otherwise.

Claims (10)

1. A method for detecting a printer connection state includes:
setting a white list of the printer according to the model information of the printer suitable for the state query instruction;
judging whether the target printer is contained in a printer white list or not according to the model information of the target printer; if yes, sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result;
if not, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
2. The method of claim 1, wherein after determining that model information of the target printer is not included in the printer whitelist, the method further comprises:
monitoring the printing queue, and judging whether to trigger pre-detection according to a monitoring result;
the sending of the preset printing test task to the target printer specifically comprises: and if the pre-detection is triggered, sending a preset printing test task to the target printer.
3. The method of claim 2, wherein monitoring the print queue and determining whether to trigger the pre-detection based on the monitoring further comprises:
and monitoring the printing queue at a preset time interval, judging whether the monitoring result is that the printing task exists or not, and judging whether the monitoring result is that the printing task does not exist or not at the previous time, and if so, judging to trigger the pre-detection.
4. The method of any of claims 1-3, wherein said sending a preset print test job to the target printer further comprises:
and sending a writing and printing task for writing N blank characters to the target printer.
5. The method of claim 4, wherein sending a write print job to the target printer that writes N blank characters further comprises:
reading width information of printing tickets in a printing task, and setting the number of blank characters consistent with the width information;
and sending a writing and printing task for writing the plurality of blank characters of the number to the target printer.
6. The method of any of claims 1-5, wherein determining a connection status of a target printer based on a result of the execution of the print test task further comprises:
and if the execution result is that the writing is abnormal and/or the waiting time exceeds the preset time, determining that the connection state of the target printer is the abnormal connection state.
7. The method of any of claims 1-5, wherein determining a connection status of a target printer based on a result of the execution of the print test task further comprises:
and if the execution result is that the writing is normal and the waiting time does not exceed the preset time length, determining that the connection state of the target printer is a connection normal state.
8. A printer connection state detection device comprising:
the setting module is suitable for setting a white list of the printer according to the model information of the printer suitable for the state query instruction;
the first judgment module is suitable for judging whether the target printer is contained in a printer white list or not according to the model information of the target printer;
the detection module is suitable for sending a state query instruction to the target printer and determining the connection state of the target printer according to a query result if the detection module is contained in a white list of printers; and if the printer is not included in the printer white list, sending a preset printing test task to the target printer, and determining the connection state of the target printer according to the execution result of the printing test task.
9. A computing device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the detection method of the printer connection state according to any one of claims 1-7.
10. A computer storage medium having stored therein at least one executable instruction for causing a processor to perform operations corresponding to the method for detecting a connection status of a printer according to any one of claims 1 to 7.
CN201911328943.6A 2019-12-20 2019-12-20 Method and device for detecting connection state of printer Pending CN111142813A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911328943.6A CN111142813A (en) 2019-12-20 2019-12-20 Method and device for detecting connection state of printer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911328943.6A CN111142813A (en) 2019-12-20 2019-12-20 Method and device for detecting connection state of printer

Publications (1)

Publication Number Publication Date
CN111142813A true CN111142813A (en) 2020-05-12

Family

ID=70519181

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911328943.6A Pending CN111142813A (en) 2019-12-20 2019-12-20 Method and device for detecting connection state of printer

Country Status (1)

Country Link
CN (1) CN111142813A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698796A (en) * 2020-12-29 2021-04-23 北京北信源软件股份有限公司 Printing control method and device based on printer, electronic equipment and storage medium
CN113844187A (en) * 2021-09-18 2021-12-28 上海中通吉网络技术有限公司 Printing pre-inspection method and system based on thermal printer

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020089687A1 (en) * 2001-01-11 2002-07-11 Ferlitsch Andrew Rodney Methods and systems for print-processor-based printer status detection and print task distribution
US20040030809A1 (en) * 2002-08-07 2004-02-12 Lozano Rosa Aurora Method and apparatus for automating printer and printer driver diagnostics and repair
WO2009018704A1 (en) * 2007-08-06 2009-02-12 Shandong New Beiyang Information Technology Co., Ltd. Print control method and device
CN101826048A (en) * 2010-02-09 2010-09-08 蓝盾信息安全技术股份有限公司 Method and system for monitoring printing
CN102508624A (en) * 2011-10-26 2012-06-20 苏州工业园区鑫海胜电子有限公司 Transparent proxy printing method for local area network
WO2016114744A2 (en) * 2013-08-23 2016-07-21 Hewlett-Packard Development Company, L.P. Mobile device for automatically delivering print jobs to printers
US20160266849A1 (en) * 2015-03-12 2016-09-15 Canon Kabushiki Kaisha Information processing apparatus, method, and storage medium storing program
CN106155598A (en) * 2015-03-26 2016-11-23 富士施乐实业发展(中国)有限公司 Intelligent printing method, intelligence printer and intelligent printing system
CN106201373A (en) * 2016-06-30 2016-12-07 北京嘉华龙马科技有限公司 A kind of method strengthening existing printer security performance
CN110162278A (en) * 2019-05-16 2019-08-23 口碑(上海)信息技术有限公司 The adding method and device of POS machine built-in printer
CN110399106A (en) * 2019-07-18 2019-11-01 浙江口碑网络技术有限公司 Print control program, the apparatus and system of bill printer

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020089687A1 (en) * 2001-01-11 2002-07-11 Ferlitsch Andrew Rodney Methods and systems for print-processor-based printer status detection and print task distribution
US20040030809A1 (en) * 2002-08-07 2004-02-12 Lozano Rosa Aurora Method and apparatus for automating printer and printer driver diagnostics and repair
WO2009018704A1 (en) * 2007-08-06 2009-02-12 Shandong New Beiyang Information Technology Co., Ltd. Print control method and device
CN101826048A (en) * 2010-02-09 2010-09-08 蓝盾信息安全技术股份有限公司 Method and system for monitoring printing
CN102508624A (en) * 2011-10-26 2012-06-20 苏州工业园区鑫海胜电子有限公司 Transparent proxy printing method for local area network
WO2016114744A2 (en) * 2013-08-23 2016-07-21 Hewlett-Packard Development Company, L.P. Mobile device for automatically delivering print jobs to printers
US20160266849A1 (en) * 2015-03-12 2016-09-15 Canon Kabushiki Kaisha Information processing apparatus, method, and storage medium storing program
CN106155598A (en) * 2015-03-26 2016-11-23 富士施乐实业发展(中国)有限公司 Intelligent printing method, intelligence printer and intelligent printing system
CN106201373A (en) * 2016-06-30 2016-12-07 北京嘉华龙马科技有限公司 A kind of method strengthening existing printer security performance
CN110162278A (en) * 2019-05-16 2019-08-23 口碑(上海)信息技术有限公司 The adding method and device of POS machine built-in printer
CN110399106A (en) * 2019-07-18 2019-11-01 浙江口碑网络技术有限公司 Print control program, the apparatus and system of bill printer

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112698796A (en) * 2020-12-29 2021-04-23 北京北信源软件股份有限公司 Printing control method and device based on printer, electronic equipment and storage medium
CN113844187A (en) * 2021-09-18 2021-12-28 上海中通吉网络技术有限公司 Printing pre-inspection method and system based on thermal printer
CN113844187B (en) * 2021-09-18 2023-08-11 上海中通吉网络技术有限公司 Printing pre-detection method and system based on thermal printer

Similar Documents

Publication Publication Date Title
US20210037148A1 (en) Image forming apparatus, information processing apparatus, method of controlling image forming apparatus, method of controlling information processing apparatus, and storage medium
US20030105995A1 (en) Method and apparatus for rebooting a printer
CN108123851B (en) Survival detection method and device for master-slave node synchronous link in distributed system
CN111142813A (en) Method and device for detecting connection state of printer
US8730490B2 (en) Printer driver, information processing apparatus, and computer program product
JP4618358B2 (en) Peripheral device management program and peripheral device management system
US9760318B2 (en) System, printing apparatus and method for controlling the same, and post-processing apparatus and method for controlling the same
US9940082B2 (en) System, printing apparatus and method for controlling the same, and post-processing apparatus and method for controlling the same for performing re-printing processing for a first job preferentially
US10650292B2 (en) Printing apparatus and method of controlling printing apparatus
US10062021B2 (en) Image processing apparatus, information processing method and storage medium
US9906680B2 (en) Information processing system, information processing apparatus and information processing method
US20180321886A1 (en) Image processing apparatus capable of obtaining prediction value of time relating to printing, image processing method, and storage medium
CN114257492B (en) Fault processing method and device for intelligent network card, computer equipment and medium
CN110519098B (en) Method and device for processing abnormal single board
JP5286814B2 (en) Semiconductor device, portable electronic device, self-diagnosis method, self-diagnosis program
JP5723961B2 (en) Image forming apparatus
US20180052643A1 (en) Image forming apparatus, control method thereof, and storage medium
CN107729170B (en) Method and device for generating dump file by HBA card
US11376871B2 (en) Printing apparatus, notification control method and storage medium
US8988721B2 (en) Printing apparatus and method for controlling a timing at which print data and status information communication ports are opened
JP2009288953A (en) Electronic control device
JP5448794B2 (en) Image forming apparatus
CN113268357A (en) Distributed lock processing method, device and system for batch processing
JP4577946B2 (en) Printer, printing method, and computer-readable storage medium
JP2010105230A (en) Printing apparatus and method for controlling the same

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