Closed-loop bill printing control method and system based on data verification and compression
Through data verification and compression technology, the problems of high error rate and long transmission time in printing data transmission are solved, and data accuracy and transmission efficiency are improved, and system security is enhanced.
Patent Information
- Application Number
- CN202411108636.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-12-27
AI Technical Summary
During the printing data transmission process, traditional methods have high probability of data errors and have long transmission time, making it difficult to quickly detect and troubleshoot equipment problems, affecting printing speed and accuracy.
Using closed-loop bill printing control method based on data verification and compression, the control instructions are streamlined through table lookup, and the printed data is compared using the comparison mark compression method to ensure data consistency and accuracy and reduce duplicate data transmission. , improve transmission efficiency.
It achieves the improvement of data accuracy and transmission efficiency, reduces the risk of errors in data transmission, and enhances the security and printing speed of the system.
Smart Images

Figure CN119201014A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of printers, and in particular to a closed-loop bill printing control method and system based on data verification and compression. Background Art
[0002] In some special printing scenarios, such as the lottery industry and financial bill printing, the printed bills require 100% accuracy. In some abnormal situations, there may be abnormal situations where the printed data is transmitted incorrectly. This requires detecting the occurrence of abnormalities and issuing alarms to avoid the flow of incorrect bills. In order to clearly determine whether it is a problem with the data source or a problem with the printer processing data,
[0003] Since the amount of data that needs to be transmitted for printing is very large, the traditional processing mechanism uses the method of completely returning the original data. Although this method can 100% guarantee the accuracy of the data, due to the limitation of the communication rate, the transmission time is long, which will affect the printing speed. Although the data transmission method using checksum or cyclic redundancy check can greatly reduce the probability of data errors, there is still a low data error rate. When the redundancy algorithm automatically corrects the error, the problems in the transmission line itself are covered up, which is not conducive to the rapid discovery and troubleshooting of positioning equipment problems. Summary of the invention
[0004] Based on this, the embodiment of the present application provides a closed-loop ticket printing control method and system based on data verification and compression. Relying on this algorithm, the printing data can be traced to help clearly locate the source of printing abnormalities. At the same time, compared with the method of completely returning the original data, the transmission volume is reduced. When a data transmission error is found, an alarm can be issued in time to avoid printing erroneous tickets.
[0005] In a first aspect, a closed-loop receipt printing control method based on data verification and compression is provided, the method comprising:
[0006] After the printer is turned on, it sends a power-on completion instruction to the host computer through the physical interface connected to the host computer. After the host computer obtains the power-on completion instruction from the host computer, it sends a predefined data template to the printer, and the printer stores the data template.
[0007] The host computer sends a control instruction to the printer, the printer obtains the control instruction sent by the host computer, simplifies the control instruction data by looking up the table, and feeds back the data simplification completion information to the host computer, and the host computer obtains the data simplification completion information fed back by the printer;
[0008] The host computer sends print data to the printer. The printer obtains the print data sent by the host computer, compares the print data with the stored data template, and generates reply data to feed back to the host computer. The host computer determines the comparison result according to the reply data sent by the printer.
[0009] The host computer sends the comparison result to the printer, and the printer performs corresponding actions based on the data comparison result.
[0010] Optionally, the printer performs corresponding actions based on the data comparison results:
[0011] When the comparison result data is consistent, printing is executed;
[0012] When the comparison result data is inconsistent, the data is discarded and an audible and visual alarm is given to indicate a data transmission error.
[0013] Optionally, the printed data is compared with a stored data template, including:
[0014] Taking a single data or a printing data as a cycle, the sent data is compared with the previously stored standard printing template data, and the starting position of the single data and the standard template data that are the same, as well as the number of the same data, are recorded.
[0015] Optionally, before simplifying the control instructions by table lookup, the method further includes:
[0016] A predefined mapping table is shared between the host computer and the printer; wherein the mapping table maps commonly used control instructions into shorter codes or identifiers;
[0017] When the host computer needs to send a control instruction, it first searches the mapping table to find the corresponding short code, and then replaces the original instruction string with the corresponding short code.
[0018] Optionally, after the host computer obtains the power-on completion instruction of the host computer, it sends a predefined data template to the printer, and the data template includes:
[0019] Includes all the basic control instructions that the printer needs to execute, including line break, positioning, and font setting;
[0020] Define the layout of the ticket, including margins, alignment, and field positions.
[0021] Optionally, the data template is encapsulated into a hexadecimal format for transmission.
[0022] In a second aspect, a closed-loop receipt printing control method based on data verification and compression is provided, which is applied to a printer, and the method includes:
[0023] After powering on, a power-on completion instruction is sent to the host computer through a physical interface connected to the host computer, and a predefined data template sent by the printer is obtained and stored;
[0024] Obtain the control instructions sent by the host computer, simplify the control instructions by looking up the table, and feed back the data simplification completion information to the host computer;
[0025] Obtain the printing data sent by the host computer, compare the printing data with the stored data template, and generate reply data to feed back to the host computer;
[0026] Execute corresponding actions based on the data comparison results fed back by the host computer.
[0027] In a third aspect, a closed-loop receipt printing control method based on data verification and compression is provided, which is applied to a host computer, and the method includes:
[0028] After obtaining the power-on completion instruction from the host computer through the physical interface connected to the printer, a predefined data template is sent to the printer;
[0029] Sending a control instruction to the printer and obtaining data reduction completion information fed back by the printer; wherein the printer reduces the data of the control instruction by looking up a table to obtain the data reduction completion information;
[0030] Sending print data to the printer and determining the comparison result according to the reply data sent by the printer; wherein the host computer generates reply data after comparing the print data with the stored data template;
[0031] The comparison result is sent to the printer so that the printer performs corresponding actions based on the data comparison result.
[0032] In a fourth aspect, a closed-loop ticket printing control system based on data verification and compression is provided, the system comprising:
[0033] The printer is used to send a power-on completion instruction to the host computer through a physical interface connected to the host computer after powering on, and obtain a predefined data template sent by the printer and store the data template; obtain a control instruction sent by the host computer, simplify the control instruction data by table lookup, and feed back the data simplification completion information to the host computer; obtain the print data sent by the host computer, compare the print data with the stored data template, and generate reply data to feed back to the host computer; perform corresponding actions based on the data comparison result fed back by the host computer;
[0034] The host computer is used to send a predefined data template to the printer after obtaining the power-on completion instruction of the host computer through a physical interface connected to the printer; send a control instruction to the printer and obtain the data reduction completion information fed back by the printer; send print data to the printer and determine the comparison result according to the reply data sent by the printer; wherein the printer performs data reduction on the control instruction by table lookup to obtain the data reduction completion information; the host computer generates reply data after comparing the print data with the stored data template; and send the comparison result to the printer so that the printer performs corresponding actions based on the data comparison result.
[0035] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0036] (1) Closed-loop control logic ensures the consistency of printed data with original data, achieving data accuracy.
[0037] (2) The contrast tag compression method reduces the transmission of duplicate data, improves data transmission efficiency, and reduces bandwidth requirements.
[0038] (3) Through data verification and compression technology, the risk of data being tampered with during transmission is reduced, enhancing the security of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.
[0040] Figure 1 A flowchart of a closed-loop receipt printing control method based on data verification and compression provided in an embodiment of the present application;
[0041] Figure 2 A schematic diagram of a lottery ticket printing framework formed by the template data provided in an embodiment of the present application;
[0042] Figure 3 A schematic diagram of lottery ticket printing provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] In the description of the present invention, the terms "comprises", "has" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may also include other steps or units that are not explicitly listed but are inherent to these processes, methods, products or apparatuses, or steps or units added based on further optimization schemes conceived by the present invention.
[0045] To facilitate understanding of this embodiment, a closed-loop receipt printing control method based on data verification and compression disclosed in an embodiment of the present application is first introduced in detail.
[0046] Please refer to Figure 1 , which shows a signaling interaction diagram of a closed-loop bill printing control method based on data verification and compression provided by an embodiment of the present application. The application scenario of the method includes a printer and a host computer. The method may include the following steps:
[0047] 1. After the printer is turned on, it sends a power-on completion instruction to the host computer through the physical interface connected to the host computer. After the host computer obtains the power-on completion instruction from the host computer, it sends a predefined data template to the printer, and the printer stores the data template.
[0048] 2. The host computer sends a control instruction to the printer. The printer obtains the control instruction sent by the host computer, simplifies the control instruction data by looking up the table, and feeds back the data simplification completion information to the host computer. The host computer obtains the data simplification completion information fed back by the printer.
[0049] In this step, the host computer converts the original control command into a shorter code or identifier through a predefined lookup table before sending the control command. This lookup table is shared and synchronized between the printer and the host computer in advance to ensure that both parties understand and interpret the command in the same way.
[0050] The converted short instructions are sent to the printer, which helps to reduce the amount of data transmission and improve transmission efficiency because less data volume is used.
[0051] After the printer receives the short command sent by the host computer, it converts it back to the original control command through reverse lookup in the table to ensure correct execution.
[0052] The printer executes the corresponding control operation and replies a confirmation message to the host computer. This confirmation message may also be simplified by table lookup to maintain the efficiency of data transmission.
[0053] 3. The host computer sends print data to the printer. The printer obtains the print data sent by the host computer, compares the print data with the stored data template, and generates reply data to feed back to the host computer. The host computer determines the comparison result based on the reply data sent by the printer.
[0054] In this step, before the host computer sends the print data, the comparison mark compression method is first applied. The host computer compares the print data with the stored common data template and identifies the control instruction part. After the printer receives the print data, it immediately compares it with the common data template sent and stored by the host computer. Among them, one single data or one print data is a cycle, and the sent data is compared with the previously stored standard print template data, and the starting position of this single data and the standard template data that are the same, as well as the number of identical data, are recorded.
[0055] During the comparison process, the printer identifies the control instruction parts that are the same as the template and records the starting position and number of these identical parts. For the changed data parts, such as company name, amount, etc., they are transmitted normally. For the keyword FF that appears in the data (assuming it is a marker for the same keyword), if the original data contains FF, it needs to be replaced with a specific sequence (such as FEFE or EFEF) to avoid conflict with the compression marker. The printer integrates the comparison results and the compressed data into reply data, including the keyword FF, the starting position of the same data, the total number of the same data, and the changed data parts.
[0056] 4. The host computer sends the comparison results to the printer, and the printer performs corresponding actions based on the data comparison results.
[0057] Specifically, when the comparison result data is consistent, printing is performed; when the comparison result data is inconsistent, the data is discarded, and an audible and visual alarm is issued to prompt a data transmission error.
[0058] In another optional embodiment of the present application, the above method can be applied to a printer, specifically:
[0059] After the printer is turned on, it sends a power-on completion instruction to the host computer through the physical interface connected to the host computer, obtains the predefined data template sent by the printer, and stores the data template;
[0060] Obtain the control instructions sent by the host computer, simplify the control instructions by looking up the table, and feed back the data simplification completion information to the host computer;
[0061] Obtain the printing data sent by the host computer, compare the printing data with the stored data template, and generate reply data to feed back to the host computer;
[0062] Execute corresponding actions based on the data comparison results fed back by the host computer.
[0063] In another optional embodiment of the present application, the above method can be applied to a host computer, specifically:
[0064] After the host computer obtains the power-on completion instruction from the host computer through the physical interface connected to the printer, the host computer sends a predefined data template to the printer;
[0065] Sending a control instruction to the printer and obtaining data reduction completion information fed back by the printer; wherein the printer reduces the data of the control instruction by looking up a table to obtain the data reduction completion information;
[0066] Sending print data to the printer and determining the comparison result according to the reply data sent by the printer; wherein the host computer generates reply data after comparing the print data with the stored data template;
[0067] The comparison result is sent to the printer so that the printer performs corresponding actions based on the data comparison result.
[0068] From the above, it can be seen that the present application specifically discloses the following technologies:
[0069] One of the key technologies of the present invention is that commonly used control instructions adopt a table lookup method, and this table printer is consistent with the upper control machine, and a smaller amount of data is used to refer to the original control instruction, thereby reducing the amount of returned data.
[0070] For example, the instruction 1D 50 53 43 30, assuming it is placed in the first position of the table, will only return 0x01 instead.
[0071] The second key technology of the present invention is to propose a new compression algorithm, which is referred to as the comparison mark compression method. There is a characteristic in the process of bill printing. The printing control instructions are generally fixed and will appear repeatedly before and after the printed data. Only the data content part changes. For example, the invoice issued in daily use has information such as company name, amount, and taxpayer number. The layout of this information in the invoice generally does not change, and the layout of this information is determined by the printing control instruction. The only thing that changes is the company name, amount, taxpayer number and other data information, which are determined by the printing data. Therefore, there is a large amount of identical and unchanged data in the data of a printing package. In view of these characteristics, a new compression algorithm is proposed, which is named the comparison mark compression method. The basic rules of the comparison mark compression algorithm are as follows: take a single data or a printing data as a cycle, compare the sent data with the previously stored standard printing template data, record the starting position of this single data and the standard template data, and the number of identical data, and return the confirmation data containing only the same keyword FF (assuming FF as the same keyword) + the starting position of the same data + the total number of the same data + the different data. If there is FF in the sent data, it needs to be replaced with 2 consecutive FEs + 2 consecutive EFs.
[0072] For example:
[0073] Standard template data:
[0074] 100401100402100403100404CCE5B2CA3CB3ACBCB6B4F3C0D6CDB83E
[0075] The data sent this time:
[0076] 1004011004021004031004043131303532392D3033363330302D3030
[0077] The returned data format is as follows:
[0078] FF+same data starting position+number+00+different data:
[0079] FF800C003131303532392D3033363330302D3030
[0080] Method for identifying the starting position of the same data:
[0081] The number of bytes indicating the starting position is variable length and uses big-endian mode. When the highest bit is 0, it indicates that the subsequent data continues to be the starting position field. When the highest bit is 1, it indicates that the starting position field ends.
[0082] That is, the lower 7 bits of each byte are used to encode data, and the highest bit is the flag bit:
[0083] 1 byte, from 0 (0x00) to 127 (0x7f)
[0084] 2 bytes, from 128 (0x80, 0x01) to 16383 (0Xff, 0x7f)
[0085] Key technology of the present invention three: power-on negotiation
[0086] After the printer starts for the first time, it sends a power-on completion command to the host computer, and the host computer sends a commonly used data template to the slave computer. This template is used as a reference template for subsequent data comparison.
[0087] The fourth key technology of the present invention is to design a closed-loop control logic to ensure 100% data accuracy. The specific closed-loop control process between the printer and the host computer is as follows: Figure 1 shown.
[0088] The control flow is as follows:
[0089] After the printer is turned on, it sends the power-on information to the host computer through the data transmission physical interface connected to the host computer.
[0090] The upper computer sends the commonly used data templates to the lower computer.
[0091] The lower computer temporarily stores the template data.
[0092] The host computer sends control instructions.
[0093] The lower computer obtains the simplified code of the control instruction and replies to the upper computer.
[0094] The upper layer sends print data, which includes print control instructions and print data instructions.
[0095] After receiving the print data packet, the lower computer compares it with the commonly used data template, generates reply data, and sends it to the upper computer.
[0096] The host computer returns the data comparison result.
[0097] The lower computer takes corresponding actions according to the returned data results. If the data is normal, it will print. Otherwise, it will discard the data and sound and light alarms to indicate data transmission errors.
[0098] A specific embodiment using the above method is given below:
[0099] First, design a template data, which will form something like Figure 2 Lottery print frame.
[0100] Template data:
[0101]
[0102] Print data packet sent by the host computer:
[0103]
[0104] The data packet returned to the host computer after comparison and calculation:
[0105] FF80A00031303532392D3033363330302D3030303435302D30303032303320393038 3938312078452F796D67FF01C31F00352F31312F3238FF02931F0030312D30303030 34322D313031203030303032202020202031352F31312F30352031323A34303A3230 FF02DB2300B1B620BACFBCC6363630D4AAFF038A68003031203032203033203034202 02E20202E20202E0AFF038A680030352030362030372030382030392031302031310 AFF04E601140059000101110529036300000450000203908981473045022100ED973 00781AD666F02FA84555E0C11DE083882672C98AB664AEB851ACDB17B3D02204FE2A 6A3A7DAA981DD663E5AD3DBD58189488756E9279652353AF21FAD15ECECFF06CB1000
[0106] The returned data content can be understood as Figure 3 and Figure 2 The difference between the two is that the original data sent by the host computer is 859 bytes, and the data returned to the host computer is 273 bytes, with a compression ratio of 31.78%.
[0107] The embodiment of the present application also provides a block diagram of a closed-loop receipt printing control system based on data verification and compression, including:
[0108] The printer is used to send a power-on completion instruction to the host computer through a physical interface connected to the host computer after powering on, and obtain a predefined data template sent by the printer and store the data template; obtain a control instruction sent by the host computer, simplify the control instruction data by table lookup, and feed back the data simplification completion information to the host computer; obtain the print data sent by the host computer, compare the print data with the stored data template, and generate reply data to feed back to the host computer; perform corresponding actions based on the data comparison result fed back by the host computer;
[0109] The host computer is used to send a predefined data template to the printer after obtaining the power-on completion instruction of the host computer through a physical interface connected to the printer; send a control instruction to the printer and obtain the data reduction completion information fed back by the printer; send print data to the printer and determine the comparison result according to the reply data sent by the printer; wherein the printer performs data reduction on the control instruction by table lookup to obtain the data reduction completion information; the host computer generates reply data after comparing the print data with the stored data template; and send the comparison result to the printer so that the printer performs corresponding actions based on the data comparison result.
[0110] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0111] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the patent application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent application shall be subject to the attached claims.
Claims
1. A closed-loop receipt printing control method based on data verification and compression, characterized in that: The method comprises: After the printer is turned on, it sends a power-on completion instruction to the host computer through the physical interface connected to the host computer. After the host computer obtains the power-on completion instruction from the host computer, it sends a predefined data template to the printer, and the printer stores the data template. The host computer sends a control instruction to the printer, the printer obtains the control instruction sent by the host computer, simplifies the control instruction data by looking up the table, and feeds back the data simplification completion information to the host computer, and the host computer obtains the data simplification completion information fed back by the printer; The host computer sends print data to the printer. The printer obtains the print data sent by the host computer, compares the print data with the stored data template, and generates reply data to feed back to the host computer. The host computer determines the comparison result according to the reply data sent by the printer. The host computer sends the comparison result to the printer, and the printer performs corresponding actions based on the data comparison result.
2. The closed-loop ticket printing control method according to claim 1, characterized in that: The printer performs corresponding actions based on the data comparison results: When the comparison result data is consistent, printing is executed; When the comparison result data is inconsistent, the data is discarded and an audible and visual alarm is given to indicate a data transmission error.
3. The closed-loop ticket printing control method according to claim 1, characterized in that: Compare the printed data with the stored data templates, including: Taking a single data or a printing data as a cycle, the sent data is compared with the previously stored standard printing template data, and the starting position of the single data and the standard template data that are the same, as well as the number of the same data, are recorded.
4. The closed-loop ticket printing control method according to claim 1, characterized in that: Before simplifying the control instructions by table lookup, the method further includes: A predefined mapping table is shared between the host computer and the printer; wherein the mapping table maps commonly used control instructions into shorter codes or identifiers; When the host computer needs to send a control instruction, it first searches the mapping table to find the corresponding short code, and then replaces the original instruction string with the corresponding short code.
5. The closed-loop ticket printing control method according to claim 1, characterized in that: After the host computer obtains the power-on completion instruction from the host computer, it sends a predefined data template to the printer. The data template includes: Includes all the basic control instructions that the printer needs to execute, including line break, positioning, and font setting; Define the layout of the ticket, including margins, alignment, and field positions.
6. The closed-loop ticket printing control method according to claim 1, characterized in that: Encapsulate the data template into hexadecimal format for transmission.
7. A closed-loop ticket printing control method based on data verification and compression, applied to a printer, characterized in that: The method comprises: After powering on, a power-on completion instruction is sent to the host computer through a physical interface connected to the host computer, and a predefined data template sent by the printer is obtained and stored; Obtain the control instructions sent by the host computer, simplify the control instructions by looking up the table, and feed back the data simplification completion information to the host computer; Obtain the printing data sent by the host computer, compare the printing data with the stored data template, and generate reply data to feed back to the host computer; Execute corresponding actions based on the data comparison results fed back by the host computer.
8. A closed-loop ticket printing control method based on data verification and compression, applied to a host computer, characterized in that: The method comprises: After obtaining the power-on completion instruction from the host computer through the physical interface connected to the printer, a predefined data template is sent to the printer; Sending a control instruction to the printer and obtaining data reduction completion information fed back by the printer; wherein the printer reduces the data of the control instruction by looking up a table to obtain the data reduction completion information; Sending print data to the printer and determining the comparison result according to the reply data sent by the printer; wherein the host computer generates reply data after comparing the print data with the stored data template; The comparison result is sent to the printer so that the printer performs corresponding actions based on the data comparison result.
9. A closed-loop ticket printing control system based on data verification and compression, characterized in that: The system comprises: The printer is used to send a power-on completion instruction to the host computer through a physical interface connected to the host computer after powering on, and obtain a predefined data template sent by the printer and store the data template; obtain a control instruction sent by the host computer, simplify the control instruction data by table lookup, and feed back the data simplification completion information to the host computer; obtain the print data sent by the host computer, compare the print data with the stored data template, and generate reply data to feed back to the host computer; perform corresponding actions based on the data comparison result fed back by the host computer; The host computer is used to send a predefined data template to the printer after obtaining the power-on completion instruction of the host computer through a physical interface connected to the printer; send a control instruction to the printer and obtain the data reduction completion information fed back by the printer; send print data to the printer and determine the comparison result according to the reply data sent by the printer; wherein the printer performs data reduction on the control instruction by table lookup to obtain the data reduction completion information; the host computer generates reply data after comparing the print data with the stored data template; and send the comparison result to the printer so that the printer performs corresponding actions based on the data comparison result.