Data printing method and device, electronic equipment and computer storage medium
By automatically identifying the target printing mode of the printing device and selecting the corresponding protocol processing function, the problem that the printing device in the prior art only supports a single protocol is solved, achieving higher compatibility and flexibility.
Patent Information
- Application Number
- CN202510078856.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-01-17
AI Technical Summary
Existing printing equipment usually communicates based on a single protocol, limiting the diversity of information transmission and making it difficult to meet complex user interaction needs.
By obtaining the data to be printed, the current target printing mode of the printing device is automatically identified, and the corresponding target protocol processing function is determined according to the mode, and the printing process is performed. This method supports multiple preset printing modes and protocol processing functions, including ESC instruction set, CPCL instruction set, and private protocol.
It significantly improves the compatibility and operation flexibility of printing equipment, can meet the printing needs of different scenarios, and avoids the limitation of traditional printing equipment that only supports a single protocol.
Smart Images

Figure CN120029566A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of printing technology, and in particular to a data printing method, device, electronic device and computer storage medium. Background Art
[0002] In the current electronic printing technology, commonly used printing protocols include standard protocols and private protocols, among which standard protocols include Epson standard instruction set ESC (Epson Standard Code) and Continuous Path Command Language (CPCL) instruction set. The ESC instruction set is usually used for cash register receipt printing, the CPCL instruction set is usually used for label printing, and private protocols are usually used for mobile phone software (Application, APP) to print labels. In actual applications, most users in home scenarios tend to use APP to print labels, while corporate users, such as the express delivery industry and government construction departments, prefer to use customized software to communicate with the printer using the CPCL protocol, and the merchant cash register system generally uses the ESC instruction set standard protocol to communicate with the printer.
[0003] Printing devices in related technologies usually communicate based on a single protocol. Although this approach simplifies data processing, it often limits the diversity of information transmission and is difficult to meet complex user interaction needs. Summary of the invention
[0004] The embodiments of the present application provide a data printing method, device, electronic device and computer storage medium, which can avoid the limitation that traditional printing devices only support a single protocol and significantly improve the compatibility and operation flexibility of the printing device. The above technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a data printing method, the method comprising:
[0006] Get the data to be printed;
[0007] Determine the target printing mode currently in which the printing device is located based on the data to be printed, wherein the target printing mode is any one of a plurality of preset printing modes;
[0008] Determine the corresponding target protocol processing function based on the target printing mode;
[0009] The data to be printed is processed for printing based on the target protocol processing function.
[0010] In a possible implementation, the plurality of preset printing modes include at least: a first printing mode and a second printing mode, wherein the first printing mode is used to print ticket information, and the second printing mode is used to print label information.
[0011] In a possible implementation, the determining the current target printing mode of the printing device based on the to-be-printed data includes:
[0012] Acquire sub-data of the data to be printed from a preset buffer, the preset buffer being used to cache the data to be printed, the sub-data including mode identification information corresponding to the printing device;
[0013] The target printing mode currently corresponding to the printing device is determined based on the mode identification information in the sub-data.
[0014] In a possible implementation, the above-mentioned determining the corresponding target protocol processing function based on the above-mentioned target printing mode includes:
[0015] When the target printing mode is the first printing mode, the ESC instruction set is used as the target protocol processing function;
[0016] In the case where the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the ESC instruction set, the ESC instruction set is used as the target protocol processing function;
[0017] In the case where the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the CPCL instruction set, the CPCL instruction set is used as the target protocol processing function.
[0018] In a possible implementation, the above-mentioned determining the corresponding target protocol processing function based on the above-mentioned target printing mode includes:
[0019] When the target printing mode is the second printing mode, if the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set and does not hit the characteristic byte of the CPCL instruction set, the preset private protocol is used as the target protocol processing function.
[0020] In a possible implementation, the printing process of the data to be printed based on the target protocol processing function includes:
[0021] Parsing the data to be printed based on the target protocol processing function to obtain a printing control instruction corresponding to the data to be printed;
[0022] The data to be printed is printed based on the print control instruction.
[0023] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0024] Open command, pre-feed command, print command, heating command and print end command.
[0025] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0026] Open command, label paper feeding command, pre-feeding command, printing command, heating command, label paper positioning command and printing end command.
[0027] In a possible implementation, the method further includes:
[0028] Detecting a click operation of a preset button of the printing device based on a preset period;
[0029] When it is detected that the click operation on the preset button meets the preset mode switching condition, the current target printing mode of the printing device is switched, and the mode identification information corresponding to the printing device is modified.
[0030] In a possible implementation, the preset mode switching condition is: the number of cycles of continuously detecting the click operation on the preset button reaches a preset number threshold;
[0031] The above method further includes:
[0032] When it is detected that the duration of clicking the preset button exceeds the preset duration, it is determined that a click operation on the preset button is detected.
[0033] In a possible implementation, the preset number threshold is 4, and the preset time length is 300 milliseconds.
[0034] In a possible implementation, the step of obtaining the data to be printed includes:
[0035] Receive external data to be printed via any of the following methods: Bluetooth, USB.
[0036] In a second aspect, an embodiment of the present application provides a data printing device, the device comprising:
[0037] An acquisition module, used for acquiring data to be printed;
[0038] A first determining module, configured to determine a target printing mode currently in which the printing device is located based on the data to be printed, wherein the target printing mode is any one of a plurality of preset printing modes;
[0039] A second determination module, used to determine a corresponding target protocol processing function based on the target printing mode;
[0040] The printing module is used to perform printing processing on the above-mentioned data to be printed based on the above-mentioned target protocol processing function.
[0041] In a possible implementation, the plurality of preset printing modes include at least: a first printing mode and a second printing mode, wherein the first printing mode is used to print ticket information, and the second printing mode is used to print label information.
[0042] In a possible implementation, the first determining module includes:
[0043] An acquisition unit, used for acquiring sub-data of the data to be printed from a preset buffer, the preset buffer being used for caching the data to be printed, the sub-data including mode identification information corresponding to the printing device;
[0044] The first determining unit is used to determine the target printing mode currently corresponding to the printing device based on the mode identification information in the sub-data.
[0045] In a possible implementation, the second determining module includes:
[0046] A second determining unit is used to use the ESC instruction set as a target protocol processing function when the target printing mode is the first printing mode;
[0047] A third determining unit is used for, when the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the ESC instruction set, using the ESC instruction set as the target protocol processing function;
[0048] The fourth determining unit is used to use the CPCL instruction set as the target protocol processing function if the frame header data of the sub-data hits the characteristic byte of the CPCL instruction set when the target printing mode is the second printing mode.
[0049] In a possible implementation, the second determining module includes:
[0050] The fifth determination unit is used to use the preset private protocol as the target protocol processing function when the target printing mode is the second printing mode and the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set and does not hit the characteristic byte of the CPCL instruction set.
[0051] In a possible implementation, the printing module includes:
[0052] A parsing unit, used for parsing the data to be printed based on the target protocol processing function to obtain a printing control instruction corresponding to the data to be printed;
[0053] The printing unit is used to print the data to be printed based on the printing control instruction.
[0054] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0055] Open command, pre-feed command, print command, heating command and print end command.
[0056] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0057] Open command, label paper feeding command, pre-feeding command, printing command, heating command, label paper positioning command and printing end command.
[0058] In a possible implementation, the above device further includes:
[0059] A detection module, used for detecting a click operation on a preset button of the printing device based on a preset period;
[0060] The switching module is used to switch the current target printing mode of the printing device and modify the mode identification information corresponding to the printing device when it is detected that the click operation on the preset button meets the preset mode switching condition.
[0061] In a possible implementation, the preset mode switching condition is: the number of cycles of continuously detecting the click operation on the preset button reaches a preset number threshold;
[0062] The above device also includes:
[0063] The third determining module is used to determine that a click operation is detected on the preset button when it is detected that the preset button is clicked for a duration exceeding a preset duration.
[0064] In a possible implementation, the preset number threshold is 4, and the preset time length is 300 milliseconds.
[0065] In a possible implementation, the acquisition module includes:
[0066] The receiving unit is used to receive external data to be printed through any of the following methods: Bluetooth, USB.
[0067] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory;
[0068] The above-mentioned memory stores a computer program, and the above-mentioned computer program is suitable for being loaded by the above-mentioned processor and executing the steps of the method provided by the first aspect of the embodiment of the present application or any possible implementation method of the first aspect.
[0069] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores multiple instructions, and the instructions are suitable for being loaded by a processor and executing the steps of the method provided by the first aspect of the embodiment of the present application or any possible implementation method of the first aspect.
[0070] The embodiment of the present application obtains the data to be printed; determines the target printing mode currently in the above-mentioned printing device based on the above-mentioned data to be printed, and the above-mentioned target printing mode is any one of multiple preset printing modes; determines the corresponding target protocol processing function based on the above-mentioned target printing mode; and performs printing processing on the above-mentioned data to be printed based on the above-mentioned target protocol processing function. Thus, the printing mode currently in the printing device is automatically identified through the data to be printed, and the corresponding protocol processing function can be used for targeted processing; the setting of multiple printing modes can enable the printing device to support multiple scenarios and meet different printing needs, avoiding the limitation that traditional printing devices only support a single protocol, and significantly improving the compatibility and operation flexibility of the printing device. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0072] Figure 1 A structural schematic diagram of a data printing system provided for an exemplary embodiment of the present application;
[0073] Figure 2 A flowchart of a data printing method provided by an exemplary embodiment of the present application;
[0074] Figure 3 A flowchart of a method for determining a target protocol processing function provided by an exemplary embodiment of the present application;
[0075] Figure 4 A flowchart of a data printing method provided by an exemplary embodiment of the present application;
[0076] Figure 5 A flow chart of a printing mode switching method provided by an exemplary embodiment of the present application;
[0077] Figure 6 A schematic diagram of the structure of a data printing device provided by an exemplary embodiment of the present application;
[0078] Figure 7 A schematic structural diagram of an electronic device provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0079] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0080] The terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0081] In the current electronic printing technology, commonly used printing protocols include standard protocols and private protocols, among which standard protocols include ESC instruction set and CPCL instruction set. The ESC instruction set is usually used for cash register receipt printing, the CPCL instruction set is usually used for label printing, and private protocols are usually used for APP printing labels. In actual applications, most users in home scenarios tend to use APP to print labels, while corporate users, such as the express delivery industry and government construction departments, prefer to use customized software to communicate with the printer for CPCL protocol, and the merchant cash register system generally uses the ESC instruction set standard protocol to communicate with the printer. The printing devices in the related art usually communicate based on a single protocol. Although this approach simplifies data processing, it often limits the diversity of information transmission and is difficult to meet complex user interaction needs. Therefore, the present application provides a data printing method to solve the technical problem that the printing devices in the above-mentioned related art that communicate based on a single protocol are difficult to meet complex user interaction needs.
[0082] Please refer to the following Figure 1 , which exemplarily shows a structural diagram of a data printing system provided by an embodiment of the present application. Figure 1 As shown, the system includes a printing device 110 and a terminal device 120, and the printing device 110 and the terminal device 120 are communicatively connected, for example, through a wired or wireless network connection, or through a parallel interface connection.
[0083] The terminal device 120 may be used to display a graphical user interface. The terminal device 120 is used to interact with the user through the graphical user interface, for example, downloading and installing a corresponding print driver and running it through the terminal device 120. In an embodiment of the present application, the terminal device 120 may be a terminal device for a user to upload data to be printed.
[0084] In some embodiments, a user can upload data to be printed on an interface displayed by the terminal device 120, and the printing device 110 obtains the data to be printed from the terminal device 120, and determines the current target printing mode of the printing device based on the data to be printed, and determines the corresponding target protocol processing function based on the target printing mode; and prints the data to be printed based on the target protocol processing function.
[0085] In other embodiments, the above system may only include the printing device 110 , and the user may upload the data to be printed through the relevant interface of the printing device 110 .
[0086] In some embodiments, the printing device 110 is used to perform the following steps: obtaining data to be printed;
[0087] Based on the above data to be printed, the target printing mode currently in which the above printing device is located is determined, and the above target printing mode is any one of multiple preset printing modes; based on the above target printing mode, the corresponding target protocol processing function is determined; and based on the above target protocol processing function, the above data to be printed is printed.
[0088] Optionally, the data to be printed is content that needs to be printed on a print medium, and the data to be printed may include documents, images, or other content that needs to be output through a printing device.
[0089] Optionally, the data to be printed may be determined by the user, and the user may provide the data to be printed in different ways, such as uploading the data to be printed by means of a computer, a mobile phone, a cloud storage, etc.
[0090] Optionally, the printing device can pre-define multiple different printing modes to adapt to different types of printing tasks. Each mode can perform corresponding printing processing according to different printing requirements (such as quality, speed, paper size, etc.).
[0091] Optionally, the printing device can support multiple protocol processing functions, and the multiple protocol processing functions include but are not limited to: CPCL instruction set, ESC instruction set, and enterprise-private protocol processing functions.
[0092] Optionally, the target protocol processing function can be any one of the above multiple protocol processing functions.
[0093] An exemplary embodiment of the present application provides a data printing method. This data printing method can be applied to the above printing device. For details, please refer to Figure 2 , which exemplarily shows a flowchart of a data printing method provided by an embodiment of the present application. As Figure 2 shown, this data printing method includes the following S21 - S24:
[0094] S21. Obtain the data to be printed.
[0095] In some embodiments, the data to be printed is the content that needs to be printed on a printing medium (such as paper), and the data to be printed can include documents, images, or other content that needs to be output by the printing device.
[0096] In some embodiments, the data to be printed can be determined by the user, and the user can provide the data to be printed in different ways, such as uploading the data to be printed through a computer, mobile phone, cloud storage, etc.
[0097] In some embodiments, in S21, the above-mentioned obtaining the data to be printed includes:
[0098] Receiving the external data to be printed through any one of the following ways: Bluetooth, USB.
[0099] By supporting multiple connection methods, users can select a more suitable connection method according to different needs and scenarios and upload the data to be printed to the printing device. For example, Bluetooth is suitable for convenient scenarios that require wireless connection, while USB is suitable for scenarios that require high data transfer rate and stable connection. The flexible connection method can meet the needs of different users and improve the usability and flexibility of the printing device.
[0100] S22. Determine the target printing mode in which the above printing device is currently located, and the target printing mode is any one of multiple preset printing modes.
[0101] In some embodiments, the plurality of preset printing modes include at least: a first printing mode and a second printing mode, wherein the first printing mode is used to print ticket information, and the second printing mode is used to print label information.
[0102] The printing device may pre-define a plurality of different printing modes to adapt to different types of printing tasks. Each mode may perform corresponding printing processing according to different printing requirements (such as quality, speed, paper size, etc.).
[0103] In some embodiments, the ticket information may include information such as receipts, invoices, slips, etc. For example, a merchant may print a sales invoice through a first printing mode of a printing device.
[0104] In some embodiments, label information refers to identification information attached to products, articles, documents, etc., usually a card made of paper or other materials, used to provide key information related to the article to users or staff. Optionally, the label information may include one or more of the product name, barcode / QR code, production date / expiration date, batch number, price information, etc.
[0105] By providing multiple print modes, the printing device can adapt to various printing needs. Each print mode can be optimized according to specific task requirements. For example, ticket information may require a higher print speed, while label information printing may require a high resolution to ensure clear and readable barcodes. By defining different modes for each task, performance can be customized to improve printing results and efficiency.
[0106] S23. Determine a corresponding target protocol processing function based on the target printing mode.
[0107] In some embodiments, the printing device may support multiple protocol processing functions, including but not limited to: CPCL instruction set, ESC instruction set, and enterprise-proprietary protocol processing functions.
[0108] In some embodiments, the target protocol processing function may be any one of the above-mentioned multiple protocol processing functions.
[0109] S24, performing printing processing on the data to be printed based on the target protocol processing function.
[0110] The above-mentioned multiple protocol processing functions can be used for different printing scenarios or functions. The printing device can perform printing processing on the data to be printed according to the target protocol processing function corresponding to the data to be printed, so that the data to be printed is processed according to the correct format and protocol.
[0111] In some embodiments, the printing process may include converting the data to be printed into instructions that can be understood and executed by the printing device, and outputting the final printing result through the printing device.
[0112] The embodiment of the present application obtains the data to be printed; determines the target printing mode currently in the above-mentioned printing device based on the above-mentioned data to be printed, and the above-mentioned target printing mode is any one of multiple preset printing modes; determines the corresponding target protocol processing function based on the above-mentioned target printing mode; and performs printing processing on the above-mentioned data to be printed based on the above-mentioned target protocol processing function. Thus, the printing mode currently in the printing device is automatically identified through the data to be printed, and the corresponding protocol processing function can be used for targeted processing; the setting of multiple printing modes can enable the printing device to support multiple scenarios and meet different printing needs, avoiding the limitation that traditional printing devices only support a single protocol, and significantly improving the compatibility and operation flexibility of the printing device.
[0113] In some embodiments, in the above S22, determining the current target printing mode of the above printing device based on the above data to be printed includes S221-S222:
[0114] S221. Obtain sub-data of the data to be printed from a preset buffer, where the preset buffer is used to cache the data to be printed, and the sub-data includes mode identification information corresponding to the printing device.
[0115] In some embodiments, after receiving the data to be printed, the data to be printed may be cached in a preset buffer, which may be a ring buffer. The ring buffer is a storage structure that can be used to process the cache of received and sent data and can realize circular storage of data.
[0116] In some embodiments, the sub-data of the data to be printed may be 1 byte of data to be printed in the buffer.
[0117] That is to say, 1 byte of data is taken from the buffer for processing each time, and then the first frame header parsing stage is entered. The frame header is the beginning part of the data to be printed, and can represent basic information such as mode identification information and length of the data to be printed.
[0118] S222: Determine the target printing mode currently corresponding to the printing device based on the mode identification information in the sub-data.
[0119] In the first frame header parsing stage, the 1-byte sub-data extracted from the buffer can be parsed to obtain mode identification information in the sub-data, and the mode identification information in the sub-data is used to uniquely identify the corresponding printing mode.
[0120] In the embodiment of the present application, each time a byte of data is extracted from the buffer for parsing, the current target printing mode can be determined in real time, and then the corresponding processing protocol function is used for printing. As a result, the printing device can dynamically adapt to different printing requirements according to the received data to be printed, thereby improving printing efficiency and accuracy. In addition, the ring buffer provides an efficient storage mechanism that can continuously store and read data in a loop, which is very effective for processing continuous stream data, avoiding memory waste and reducing management complexity.
[0121] In some embodiments, in the above S23, the above determination of the corresponding target protocol processing function based on the above target printing mode includes S231-S233:
[0122] S231. When the target printing mode is the first printing mode, use the ESC instruction set as the target protocol processing function.
[0123] Among them, the ESC instruction set is a standardized instruction set for controlling printers, which is widely used in dot matrix printers and thermal printers. The ESC instruction set can provide fast, simple and efficient text processing and formatting functions, while supporting efficient paper management (such as paper cutting, paper changing, etc.), which can meet the needs of high-frequency ticket printing in commercial scenarios. Therefore, when the target printing mode is the first printing mode for printing ticket information, the ESC instruction set can be used for printing operations.
[0124] In some embodiments, when it is determined that the current target printing mode is the first printing mode, the ESC instruction set processing function can be directly determined and the current state machine can be exited without performing subsequent frame header, data frame, and frame tail processing procedures of the private protocol.
[0125] S232. When the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the ESC instruction set, the ESC instruction set is used as the target protocol processing function.
[0126] The characteristic byte is the header information in the data transmission, which can be used to identify the type of processing protocol function.
[0127] In some embodiments, the characteristic byte of the ESC instruction set may be 0x1B, i.e., a character (ESC character) with an ASCII code of 27. When the target printing mode is the second printing mode, it may be determined whether the frame header of the sub-data includes 0x1B (ESC character). If so, it is determined that the frame header data of the sub-data hits the characteristic byte of the ESC instruction set; if not, it is determined that the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set.
[0128] The ESC instruction set defines a set of commands and instructions that can control the behavior of the printer, such as text formatting, paper control, printing start and end, etc. Since the ESC instruction set is very commonly used in printing devices, when the frame header data matches the characteristic byte of the ESC instruction set, it means that the sub-data conforms to the format and specification of the ESC instruction set. By matching the characteristic byte to confirm that it is the ESC instruction set, the relevant processing function can be directly called, avoiding complex protocol parsing steps and improving the processing efficiency of the system.
[0129] S233. When the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the CPCL instruction set, the CPCL instruction set is used as the target protocol processing function.
[0130] CPCL is a language used to control printer behavior and is widely used in barcode printers and label printers. CPCL instruction set provides users with a flexible printing instruction set to define various parameters of printing tasks, such as print format, font style, image processing, and print speed.
[0131] In some embodiments, the characteristic byte of the CPCL instruction set can be "!" (exclamation mark and space). When the above-mentioned target printing mode is the above-mentioned second printing mode, it can be determined whether the first two bytes of the frame header of the sub-data are an exclamation mark and a space. If so, it is determined that the frame header data of the sub-data hits the characteristic bytes of the above-mentioned CPCL instruction set; if not, it is determined that the frame header data of the sub-data does not hit the characteristic bytes of the above-mentioned CPCL instruction set.
[0132] In the communication protocol, the frame header usually contains some key information to identify the data type and protocol type. The feature byte is a part of the sub-data, which is used to indicate that the sub-data follows a specific protocol specification. If the frame header data hits the feature byte of the CPCL instruction set, it means that the sub-data conforms to the format and structure of the CPCL protocol. By matching the protocol through the feature byte, it can be automatically identified that the data to be printed belongs to the CPCL protocol without the need for additional parsing steps, and then the CPCL protocol processing function can be directly called to process the data, simplifying the protocol parsing process and improving data processing efficiency. In addition, by using the CPCL instruction set, the printing device can accurately control the printing format, image, font, barcode and other contents to ensure that the output results match the user's needs, thereby avoiding printing errors or equipment failures.
[0133] In the embodiment of the present application, the printing device can support multiple protocol processing functions. Therefore, the corresponding protocol processing functions can be flexibly used according to different printing tasks or device configurations, so that the printing device can adapt to a wider range of applications and is not limited to a certain instruction set or protocol, thereby improving the compatibility and stability of the printer device. In addition, if new printing modes or protocol processing functions need to be added in the future, it is only necessary to simply add new protocol processing functions and mode mappings, so that new printing modes and protocol processing functions can be easily supported in subsequent updates, effectively improving the scalability of the printing device.
[0134] In some embodiments, in the above S23, the above determination of the corresponding target protocol processing function based on the above target printing mode further includes S234:
[0135] When the target printing mode is the second printing mode, if the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set and does not hit the characteristic byte of the CPCL instruction set, the preset private protocol is used as the target protocol processing function.
[0136] In some embodiments, the enterprise private protocol can be a protocol customized for the printing equipment of certain enterprises or organizations according to their specific needs. Different from standard protocols (such as CPCL, ESC, etc.), the enterprise private protocol is usually proprietary and can only be used in the printing equipment and systems of the enterprise or its partners.
[0137] The above-mentioned ESC and CPCL are known standard printing protocols. When the frame header data of the sub-data does not hit the characteristic bytes of these standard protocols, it can be considered that the sub-data may come from different devices or use different protocol formats. If not processed, it may cause protocol parsing failure or conflict, thus affecting the entire printing process. By introducing a private protocol as a fallback solution, data processing can continue when encountering unknown or non-standard protocol data, without crashing or stopping due to unrecognizable protocols. This fault-tolerant mechanism improves the stability and robustness of the printing process.
[0138] Figure 3 A flowchart of a method for determining a target protocol processing function provided by an exemplary embodiment of the present application is shown as follows: Figure 3 As shown, the method for determining the target protocol processing function includes S301-S309:
[0139] S301, obtaining data to be printed.
[0140] S302, obtaining sub-data of the data to be printed from a preset buffer.
[0141] S303, determine whether the target printing mode is the first printing mode. If yes, execute S304; if no, execute S305.
[0142] S304: Use the ESC instruction set as the target protocol processing function.
[0143] S305: Determine that the target printing mode is the second printing mode.
[0144] S306: Determine whether the frame header data of the sub-data matches the characteristic byte of the ESC instruction set. If yes, execute S304; if no, execute S307.
[0145] S307, determine whether the frame header data of the sub-data matches the characteristic byte of the CPCL instruction set. If yes, execute S308; if no, execute S309.
[0146] S308. Use the CPCL instruction set as the target protocol processing function.
[0147] S309: Use the preset private protocol as the target protocol processing function.
[0148] Optionally, the specific steps of S301-S309 are consistent with the specific steps of S21-S23 described above, and are not repeated here.
[0149] In the embodiment of the present application, by judging whether the frame header data conforms to the characteristic bytes of ESC or CPCL, different printing protocols can be automatically identified and adapted. If the frame header of the sub-data does not hit the characteristic bytes of any standard protocol instruction set (i.e., it does not hit ESC or CPCL), it can fall back to using the enterprise's private protocol for processing. This mechanism can ensure that the system can work normally under a variety of different protocols without relying on external intervention, thereby improving the stability and robustness of the printing process.
[0150] In some embodiments, in the above S24, the above printing process of the above data to be printed based on the above target protocol processing function includes S241-S242:
[0151] S241. Parse the data to be printed based on the target protocol processing function to obtain a printing control instruction corresponding to the data to be printed.
[0152] The target protocol processing function can be used to parse the data to be printed and understand the instructions and commands in the data to be printed. The printing control instructions corresponding to the data to be printed are instructions for controlling the specific behavior of the printing device.
[0153] S242: Print the data to be printed based on the print control instruction.
[0154] In some embodiments, when the target printing mode is the first printing mode, the printing control instruction at least includes: a start instruction, a pre-feed instruction, a printing instruction, a heating instruction and a printing end instruction.
[0155] Among them, the start instruction is an instruction to start the printing device or printing function; the pre-paper feeding instruction is an instruction to control the printing device to feed paper to a specified position so as to start printing; the printing instruction is an instruction to actually start printing the above-mentioned data to be printed; the heating instruction can be an instruction to control the printing device to heat; the printing end instruction is an instruction to indicate that the printing operation is completed and ended.
[0156] In some embodiments, when the target printing mode is the first printing mode, the printing control instructions include at least: a start instruction, a label paper feeding instruction, a pre-feeding instruction, a printing instruction, a heating instruction, a label paper positioning instruction and a printing end instruction.
[0157] Among them, the label paper feeding instruction is an instruction to control the printing device to rewind the label paper from near the print head. Specifically, it can be to return the label paper to the appropriate starting position when the printing device is printing, so as to print the next label or complete the label printing process; the label paper positioning instruction is an instruction for accurately positioning the position of the label paper in the printing device, which can make the label paper in the correct position under the print head, thereby ensuring that the printed content of the label matches the actual position of the label paper.
[0158] The combination of the above-mentioned different instructions makes the entire printing process more precise and efficient. Each step is controlled in an orderly manner to avoid possible errors or omissions. The precise label paper positioning, heating control and printing instructions make the printed content clearer and more accurate. Pre-feed instructions, paper return instructions, etc. are used to avoid paper waste and label misalignment, thereby improving the utilization rate of label paper resources.
[0159] Figure 4 A flowchart of a data printing method provided by an exemplary embodiment of the present application is shown as follows: Figure 4 As shown, the data printing method includes S401-S414:
[0160] S401: Determine whether the printing device is idle.
[0161] Optionally, the current status of the printing device can be obtained through relevant status query commands (such as the status query command of the printing device driver interface or the printer itself). These statuses usually include whether it is in an idle state, whether it is printing, whether an error or failure occurs, etc.
[0162] S402: Determine whether the target printing mode is the second printing mode. If yes, execute S403; if no, execute S410.
[0163] Optionally, when the printing mode of the printing device includes only the first printing mode and the second printing mode, if it is determined that the target printing mode is not the second printing mode, the target printing mode may be directly determined to be the first printing mode.
[0164] S403: Execute the start instruction.
[0165] S404, executing the label paper feeding instruction.
[0166] S405, executing the pre-paper feeding instruction.
[0167] S406: Execute the printing instruction.
[0168] S407, executing the heating instruction.
[0169] S408, executing the label paper positioning instruction.
[0170] S409, execute the print end instruction.
[0171] S410, executing the opening instruction.
[0172] S411, execute the pre-paper feeding instruction.
[0173] S412: Execute the printing instruction.
[0174] S413, executing the heating instruction.
[0175] S414, execute the print end instruction.
[0176] In the embodiment of the present application, different printing control instructions are set for different printing modes, so that the printing device can optimize processing for specific tasks and avoid unnecessary operations or redundant instructions, thereby optimizing the printing process, reducing the operating complexity of the printing device, improving printing efficiency, and making the printing process more intelligent and automated.
[0177] In some embodiments, the above method further includes S31-S32:
[0178] S31. Detecting a click operation on a preset button of the printing device based on a preset period.
[0179] In some embodiments, the preset button may be a specific button in the printing device, and the preset button may have at least one predefined function or trigger operation, for example, may include operations such as printing mode switching, etc. Optionally, the preset period may be 1 millisecond.
[0180] For example, the status of a preset button can be periodically checked (every 1 ms) in the interrupt function of the system tick timer Systick, and it can be determined whether the preset button is pressed, lifted, or long-pressed through a basic debounce algorithm.
[0181] In some embodiments, for the detection of the click operation on the above-mentioned preset button, the above method further includes: when it is detected that the duration of the click on the above-mentioned preset button exceeds a preset duration, it is determined that a click operation on the above-mentioned preset button is detected.
[0182] In some embodiments, the above-mentioned preset duration is 300 milliseconds.
[0183] That is to say, if the time when the preset button is pressed exceeds the preset duration (e.g., 300 milliseconds), this pressing action can be considered a valid click operation rather than a short accidental touch or inadvertent press. Among them, the role of the preset duration is to distinguish between a long press and a short press.
[0184] By setting a preset duration such as 300 milliseconds, the printing device can distinguish between valid clicks and short accidental touches or inadvertent operations. This not only avoids mis-triggering but also improves the user experience, achieving a balance between response speed and accuracy, making the printing device more intelligent, stable, and better adapted to actual operation requirements.
[0185] S32. When it is detected that the click operation on the above-mentioned preset button meets the preset mode switching condition, switch the current target printing mode of the above-mentioned printing device and modify the corresponding mode identification information of the above-mentioned printing device.
[0186] In some embodiments, the above-mentioned preset mode switching condition is: the number of cycles of continuously detecting click operations on the above-mentioned preset button reaches a preset number threshold;
[0187] In some embodiments, the above-mentioned preset number threshold is 4. That is to say, if the preset button is continuously clicked 4 times, and each click lasts for more than 300 milliseconds, then it can be considered that this is a signal from the user requesting to switch the printing mode, and the mode switching is executed.
[0188] Figure 5 The flowchart of a printing mode switching method provided by an exemplary embodiment of the present application is as Figure 5 shown, and this printing mode switching method includes S501 - S507:
[0189] S501. Based on a preset period, determine whether it is detected that the duration of the click on the preset button exceeds the preset duration. If so, execute S502; if not, enter the next period and return to execute S501.
[0190] S502: Determine whether a click operation on a preset button is detected.
[0191] S503: Determine the number of cycles in which a click operation on a preset button is continuously detected.
[0192] S504: Determine whether the number of cycles in which the click operation on the preset button is detected continuously reaches the preset number threshold. If yes, execute S505; if no, enter the next cycle and return to execute S501.
[0193] S505: Determine the number of cycles in which a click operation on a preset button is continuously detected.
[0194] S506: Determine whether the detected click operation on the preset button satisfies the preset mode switching condition.
[0195] S507: Switch the current target printing mode of the printing device, and modify the mode identification information corresponding to the printing device.
[0196] Optionally, the specific steps of S501-S507 are consistent with the specific steps of S31-S32 described above, and are not repeated here.
[0197] In the embodiment of the present application, through continuous detection and threshold judgment, it is possible to have better fault tolerance for the user's unintentional or accidental clicking behavior, avoid interference with the printing device, and effectively improve the stability of the printing device during operation.
[0198] In actual application scenarios, enterprise private protocols can be used to meet the needs of APP to print multiple labels, use the ESC instruction set protocol to print receipts, and use the CPCL instruction set protocol to print labels. Specifically, for home use scenarios, labels can be printed through APP, and for corporate users (such as the express delivery industry, government construction, etc.), they can be printed through customized software based on the enterprise private protocol. For example, the enterprise can use the CPCL protocol to communicate with the printing device through secondary developed software. In addition, merchants such as cash registers can use the ESC instruction set protocol to communicate with the printing device through the cash register system.
[0199] This application implements mode switching for different application scenarios, avoiding users from purchasing different printing devices to meet multiple needs, and effectively improving the reusability and scalability of printing devices. By organically combining the needs of the enterprise and personal ends, the printing needs of different scenarios can be met on the same printing device, and different printing methods can be used according to different printing modes, thereby improving the response speed of data processing and printing processes.
[0200] Please refer to the following Figure 6, which is a schematic structural diagram of a data printing device provided by an exemplary embodiment of the present application. As Figure 6 shown, the above-mentioned data printing device 600 includes:
[0201] An acquisition module 601, configured to acquire data to be printed;
[0202] A first determination module 602, configured to determine a target printing mode in which the printing device is currently located based on the data to be printed, and the target printing mode is any one of a plurality of preset printing modes;
[0203] A second determination module 603, configured to determine a corresponding target protocol processing function based on the target printing mode;
[0204] A printing module 604, configured to perform printing processing on the data to be printed based on the target protocol processing function.
[0205] In a possible implementation manner, the above-mentioned plurality of preset printing modes at least include: a first printing mode and a second printing mode, wherein the first printing mode is used to print bill information, and the second printing mode is used to print label information.
[0206] In a possible implementation manner, the first determination module 602 includes:
[0207] An acquisition unit, configured to acquire sub-data of the data to be printed from a preset buffer, the preset buffer is used to cache the data to be printed, and the sub-data includes mode identification information corresponding to the printing device;
[0208] A first determination unit, configured to determine the target printing mode currently corresponding to the printing device based on the mode identification information in the sub-data.
[0209] In a possible implementation manner, the second determination module 603 includes:
[0210] A second determination unit, configured to use the ESC instruction set as the target protocol processing function when the target printing mode is the first printing mode;
[0211] A third determination unit, configured to use the ESC instruction set as the target protocol processing function when the target printing mode is the second printing mode and the frame header data of the sub-data hits the characteristic byte of the ESC instruction set;
[0212] A fourth determination unit, configured to use the CPCL instruction set as the target protocol processing function when the target printing mode is the second printing mode and the frame header data of the sub-data hits the characteristic byte of the CPCL instruction set.
[0213] In a possible implementation, the second determining module 602 includes:
[0214] The fifth determination unit is used to use the preset private protocol as the target protocol processing function when the target printing mode is the second printing mode and the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set and does not hit the characteristic byte of the CPCL instruction set.
[0215] In a possible implementation, the printing module 604 includes:
[0216] A parsing unit, used for parsing the data to be printed based on the target protocol processing function to obtain a printing control instruction corresponding to the data to be printed;
[0217] The printing unit is used to print the data to be printed based on the printing control instruction.
[0218] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0219] Open command, pre-feed command, print command, heating command and print end command.
[0220] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0221] Open command, label paper feeding command, pre-feeding command, printing command, heating command, label paper positioning command and printing end command.
[0222] In a possible implementation, the apparatus 600 further includes:
[0223] A detection module, used for detecting a click operation on a preset button of the printing device based on a preset period;
[0224] The switching module is used to switch the current target printing mode of the printing device and modify the mode identification information corresponding to the printing device when it is detected that the click operation on the preset button meets the preset mode switching condition.
[0225] In a possible implementation, the preset mode switching condition is: the number of cycles of continuously detecting the click operation on the preset button reaches a preset number threshold;
[0226] The above-mentioned device 600 further includes:
[0227] The third determining module is used to determine that a click operation is detected on the preset button when it is detected that the preset button is clicked for a duration exceeding a preset duration.
[0228] In a possible implementation, the preset number threshold is 4, and the preset time length is 300 milliseconds.
[0229] In a possible implementation, the acquisition module 601 includes:
[0230] The receiving unit is used to receive external data to be printed through any of the following methods: Bluetooth, USB.
[0231] The division of the modules in the above-mentioned data printing device 600 is only for illustration. In other embodiments, the data printing device can be divided into different modules as needed to complete all or part of the functions of the above-mentioned data printing device. The implementation of each module in the data printing device provided in the embodiment of this specification can be in the form of a computer program. The computer program can be run on a terminal or a server. The program modules constituted by the computer program can be stored in the memory of the terminal or the server. When the computer program is executed by the processor, all or part of the steps of the data printing method described in the embodiment of this specification are implemented.
[0232] See next Figure 7 , which is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application. Figure 7 As shown, the electronic device 700 may include: a processor 710 and a memory 720 , and may also include a user interface 730 , a network interface 740 and a communication bus 750 .
[0233] Among them, the processor 710 may include one or more processing cores. The processor 710 uses various interfaces and lines to connect various parts of the entire electronic device 700, and executes various functions and processes data of the electronic device 700 by running or executing instructions, programs, code sets or instruction sets stored in the memory 720, and calling data stored in the memory 720. Optionally, the processor 710 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 710 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes operating systems and applications, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 710, and it can be implemented separately through a chip.
[0234] Among them, the memory 720 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 720 includes a non-transitory computer-readable storage medium. The memory 720 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 720 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a receiving function, a control function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 720 may also be optionally at least one storage device located away from the aforementioned processor 710. As Figure 7 As shown, the memory 720 as a computer storage medium may include an operating system, a network communication module, a user interface module, and program instructions.
[0235] Optionally, the communication bus 750 is used to realize the connection and communication between these components. The user interface 730 may include a display screen (Display), a camera (Camera), and may also include a standard wired interface and a wireless interface; the network interface 740 may optionally include a standard wired interface and a wireless interface (such as a WI FI interface).
[0236] exist Figure 7 In the electronic device 700 shown, the processor 710 may be used to call program instructions stored in the memory 720 and specifically perform the following operations:
[0237] Get the data to be printed;
[0238] Determine the target printing mode currently in which the printing device is located based on the data to be printed, wherein the target printing mode is any one of a plurality of preset printing modes;
[0239] Determine the corresponding target protocol processing function based on the target printing mode;
[0240] The data to be printed is processed for printing based on the target protocol processing function.
[0241] In a possible implementation, the plurality of preset printing modes include at least: a first printing mode and a second printing mode, wherein the first printing mode is used to print ticket information, and the second printing mode is used to print label information.
[0242] In a possible implementation, the determining the current target printing mode of the printing device based on the to-be-printed data includes:
[0243] Acquire sub-data of the data to be printed from a preset buffer, the preset buffer being used to cache the data to be printed, the sub-data including mode identification information corresponding to the printing device;
[0244] The target printing mode currently corresponding to the printing device is determined based on the mode identification information in the sub-data.
[0245] In a possible implementation, the above-mentioned determining the corresponding target protocol processing function based on the above-mentioned target printing mode includes:
[0246] When the target printing mode is the first printing mode, the ESC instruction set is used as the target protocol processing function;
[0247] In the case where the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the ESC instruction set, the ESC instruction set is used as the target protocol processing function;
[0248] In the case where the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the CPCL instruction set, the CPCL instruction set is used as the target protocol processing function.
[0249] In a possible implementation, the above-mentioned determining the corresponding target protocol processing function based on the above-mentioned target printing mode includes:
[0250] When the target printing mode is the second printing mode, if the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set and does not hit the characteristic byte of the CPCL instruction set, the preset private protocol is used as the target protocol processing function.
[0251] In a possible implementation, the printing process of the data to be printed based on the target protocol processing function includes:
[0252] Parsing the data to be printed based on the target protocol processing function to obtain a printing control instruction corresponding to the data to be printed;
[0253] The data to be printed is printed based on the print control instruction.
[0254] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0255] Open command, pre-feed command, print command, heating command and print end command.
[0256] In a possible implementation, when the target printing mode is the first printing mode, the printing control instruction at least includes:
[0257] Open command, label paper feeding command, pre-feeding command, printing command, heating command, label paper positioning command and printing end command.
[0258] In a possible implementation, the method further includes:
[0259] Detecting a click operation of a preset button of the printing device based on a preset period;
[0260] When it is detected that the click operation on the preset button meets the preset mode switching condition, the current target printing mode of the printing device is switched, and the mode identification information corresponding to the printing device is modified.
[0261] In a possible implementation, the preset mode switching condition is: the number of cycles of continuously detecting the click operation on the preset button reaches a preset number threshold;
[0262] The above method further includes:
[0263] When it is detected that the duration of clicking the preset button exceeds the preset duration, it is determined that a click operation on the preset button is detected.
[0264] In a possible implementation, the preset number threshold is 4, and the preset time length is 300 milliseconds.
[0265] In a possible implementation, the step of obtaining the data to be printed includes:
[0266] Receive external data to be printed via any of the following methods: Bluetooth, USB.
[0267] The present application also provides a computer-readable storage medium, which stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes one or more steps in the above embodiment. If the components of the above data printing device are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium.
[0268] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The above-mentioned computer program product includes one or more computer instructions. When the above-mentioned computer program instructions are loaded and executed on a computer, the above-mentioned process or function according to the embodiment of the present application is generated in whole or in part. The above-mentioned computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices. The above-mentioned computer instructions can be stored in a computer-readable storage medium or transmitted by the above-mentioned computer-readable storage medium. The above-mentioned computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (such as coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The above-mentioned computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integrated. The above-mentioned available media can be magnetic media (for example, floppy disks, hard disks, tapes), optical media (for example, digital versatile discs (DVD)), or semiconductor media (for example, solid state disks (SSD)), etc.
[0269] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes. In the absence of conflict, the technical features in this embodiment and the implementation scheme can be combined arbitrarily.
[0270] The above-mentioned embodiments are merely preferred embodiments of the present application and are not intended to limit the scope of the present application. Without departing from the design spirit of the present application, various modifications and improvements made to the technical solutions of the present application by ordinary technicians in this field should fall within the protection scope determined by the claims of the present application.
Claims
1. A data printing method, applied to a printing device, characterized in that: include: Get the data to be printed; Determining a target printing mode currently in which the printing device is located based on the data to be printed, wherein the target printing mode is any one of a plurality of preset printing modes; Determine a corresponding target protocol processing function based on the target printing mode; Printing processing is performed on the data to be printed based on the target protocol processing function.
2. The method according to claim 1, characterized in that The plurality of preset printing modes include at least: a first printing mode and a second printing mode, wherein the first printing mode is used for printing ticket information, and the second printing mode is used for printing label information.
3. The method according to claim 2, characterized in that The determining the target printing mode currently in which the printing device is located based on the data to be printed includes: Acquire sub-data of the data to be printed from a preset buffer, the preset buffer being used to cache the data to be printed, the sub-data including mode identification information corresponding to the printing device; The target printing mode currently corresponding to the printing device is determined based on the mode identification information in the sub-data.
4. The method according to claim 3, characterized in that The determining of the corresponding target protocol processing function based on the target printing mode includes: When the target printing mode is the first printing mode, using an ESC instruction set as a target protocol processing function; In the case where the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the ESC instruction set, the ESC instruction set is used as the target protocol processing function; When the target printing mode is the second printing mode, if the frame header data of the sub-data hits the characteristic byte of the CPCL instruction set, the CPCL instruction set is used as the target protocol processing function.
5. The method according to claim 3, characterized in that The determining of the corresponding target protocol processing function based on the target printing mode includes: When the target printing mode is the second printing mode, if the frame header data of the sub-data does not hit the characteristic byte of the ESC instruction set and does not hit the characteristic byte of the CPCL instruction set, the preset private protocol is used as the target protocol processing function.
6. The method according to claim 2, characterized in that The printing process of the data to be printed based on the target protocol processing function includes: Parsing the data to be printed based on the target protocol processing function to obtain a printing control instruction corresponding to the data to be printed; The data to be printed is printed based on the printing control instruction.
7. The method according to claim 6, characterized in that When the target printing mode is the first printing mode, the printing control instruction at least includes: Open command, pre-feed command, print command, heating command and print end command.
8. The method according to claim 6, characterized in that When the target printing mode is the first printing mode, the printing control instruction at least includes: Open command, label paper feeding command, pre-feeding command, printing command, heating command, label paper positioning command and printing end command.
9. The method according to claim 2, characterized in that The method further comprises: Detecting a click operation on a preset button of the printing device based on a preset period; When it is detected that the click operation on the preset button meets the preset mode switching condition, the current target printing mode of the printing device is switched, and the mode identification information corresponding to the printing device is modified.
10. The method according to claim 9, characterized in that The preset mode switching condition is: the number of cycles of continuously detecting the click operation on the preset button reaches a preset number threshold; The method further comprises: When it is detected that the duration for which the preset button is clicked exceeds the preset duration, it is determined that a click operation on the preset button is detected.
11. The method according to claim 10, characterized in that The preset number threshold is 4, and the preset duration is 300 milliseconds.
12. The method according to claim 1, characterized in that The step of obtaining the data to be printed includes: Receive external data to be printed via any of the following methods: Bluetooth, USB.
13. A data printing device, applied to a printing device, characterized in that: include: An acquisition module, used for acquiring data to be printed; A first determining module, configured to determine a target printing mode currently in which the printing device is located based on the data to be printed, wherein the target printing mode is any one of a plurality of preset printing modes; A second determination module, configured to determine a corresponding target protocol processing function based on the target printing mode; A printing module is used to perform printing processing on the data to be printed based on the target protocol processing function.
14. An electronic device, characterized in that: include: Processor and memory; The memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method according to any one of claims 1 to 12.
15. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the steps of the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Data connection printing
CN109313712A
Online printing method and device and electronic equipment
CN112181322A
Printing method and device, electronic equipment and computer readable storage medium
CN113190187A
Printing control method and device, electronic equipment printer and storage medium
CN114780046A
Cloud platform printing method and device, equipment and storage medium
CN115686388A