A printing device connection method, apparatus, device and storage medium

By generating a serial port lookup list to automatically determine the target serial port and baud rate parameters, the problem of low connection efficiency for multi-serial port printing devices is solved, and an efficient and automatic connection process is achieved.

CN116301676BActive Publication Date: 2026-04-10HONGHU WANLIAN (JIANGSU) TECH DEV CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONGHU WANLIAN (JIANGSU) TECH DEV CO LTD
Filing Date
2023-03-17
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In open-source HarmonyOS embedded computing hardware, multiple serial ports increase the workload when manually determining the connection of printing devices, and may lead to errors and reduce connection efficiency.

Method used

By obtaining serial port information from the configuration file, a serial port query list is generated, and the target serial port and baud rate parameters are automatically determined to achieve automatic connection.

Benefits of technology

It reduces manual workload, avoids serial port determination errors, and improves the connection efficiency of printing equipment, especially in the case of multiple devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116301676B_ABST
    Figure CN116301676B_ABST
Patent Text Reader

Abstract

The application discloses a printing device connection method and device, equipment and a storage medium. The method comprises the following steps: obtaining a configuration file, extracting serial port related information in the configuration file, wherein the serial port related information comprises a serial port name and a baud rate parameter; generating a serial port query list according to the serial port related information; determining a target serial port and a target baud rate parameter according to the serial port query list, and establishing a connection with a printing device through the target serial port and the target baud rate parameter. The serial port query list is generated by extracting the serial port name and the baud rate parameter in the configuration file, without the need for artificial memory of the serial port related information. The target serial port and the target baud rate parameter are further determined through the serial port query list, so that the connection with the printing device can be automatically established, the artificial workload is reduced, the error in the determination of the serial port is avoided, and even when there are multiple printing devices, the connection can be quickly established, the connection efficiency of the printing device is improved, and it is more convenient for a user to perform subsequent operations.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of device connection, and in particular to a printing device connection method, device, apparatus and storage medium. BACKGROUND

[0002] The printing device is a commonly used computer output device, which is widely used in people's work, study and life. At present, when establishing a connection with the printing device, the user needs to determine which serial port the printing device is connected to and what the baud rate parameter of the external device serial port is, so as to operate the device in the system application. Otherwise, the user needs to try many times in the software to normally operate the device.

[0003] However, there may be multiple serial ports in the open source Hongmeng embedded computing hardware, so the way of manually determining the connected serial port and the baud rate parameter increases the workload of the user. If the serial port is determined incorrectly, the printing device cannot be normally connected, which reduces the connection efficiency of the printing device and is inconvenient for the user to operate subsequently. SUMMARY

[0004] The present application provides a printing device connection method, device, apparatus and storage medium to realize automatic connection of the printing device.

[0005] According to an aspect of the present application, a printing device connection method is provided, which comprises:

[0006] Obtaining a configuration file and extracting serial port related information in the configuration file, wherein the serial port related information comprises a serial port name and a baud rate parameter;

[0007] Generating a serial port query list according to the serial port related information;

[0008] Determining a target serial port and a target baud rate parameter according to the serial port query list, and establishing a connection with the printing device through the target serial port and the target baud rate parameter.

[0009] Optionally, obtaining the configuration file comprises: obtaining a configuration file template and user input parameters, wherein the user input parameters comprise a connection time, a serial port name and a baud rate parameter; determining target positions corresponding to each user input parameter in the configuration file template; and combining each user input parameter with the configuration file template according to the target positions to generate the configuration file.

[0010] Optionally, the serial port query list is generated according to the serial port related information, including: combining each of the baud rate parameters with the serial port name to generate each of the serial port query instructions; determining the device driver number corresponding to the serial port name, and grouping the serial port query instructions according to the device driver number to generate numbered groups, wherein the serial port query instructions with the same device driver number are included in the numbered groups; sorting the serial port query instructions in each of the numbered groups according to the baud rate parameters in ascending order to generate parameter groups; and sorting the parameter groups according to the device driver numbers in ascending order to generate the serial port query list.

[0011] Optionally, the target serial port and the target baud rate parameter are determined according to the serial port query list, including: sequentially taking the serial port query instructions in the serial port query list as target query instructions; taking the serial port name included in the target query instruction as a to-be-queried serial port, and determining the serial port opening situation of the to-be-queried serial port, wherein the serial port opening situation includes opening success and opening failure; and determining the target serial port and the target baud rate parameter according to the serial port opening situation and the target query instruction.

[0012] Optionally, the target serial port and the target baud rate parameter are determined according to the serial port opening situation and the target query instruction, including: when the serial port opening situation is opening success, sending the target query instruction to the to-be-queried serial port; determining the connection time according to the configuration file; when the response information of the to-be-queried serial port is received within the connection time, taking the to-be-queried serial port as the target serial port, and taking the baud rate parameter included in the target query instruction as the target baud rate parameter.

[0013] Optionally, after the connection time is determined according to the configuration file, the method further includes: when the response information of the to-be-queried serial port is not received within the connection time, determining that the to-be-queried serial port fails to connect, and taking the serial port name at the next position corresponding to the to-be-queried serial port in the serial port query list as a next to-be-queried serial port; and when it is determined that all the to-be-queried serial ports fail to connect, generating a connection failure prompt.

[0014] Optionally, the serial port opening situation of the to-be-queried serial port is determined, including: obtaining a pre-configured serial port operation function, and sending the serial port operation function to the to-be-queried serial port; and judging whether an opening response of the to-be-queried serial port is received within a specified time, if yes, determining that the serial port opening situation is opening success; otherwise, determining that the serial port opening situation is opening failure.

[0015] According to another aspect of the present application, a printing device connection apparatus is provided, the apparatus comprising:

[0016] a serial port related information extraction module configured to obtain a configuration file and extract serial port related information in the configuration file, wherein the serial port related information includes a serial port name and a baud rate parameter;

[0017] The serial port query list generation module is configured to generate a serial port query list according to serial port related information.

[0018] The printing device connection module is configured to determine a target serial port and a target baud rate parameter according to the serial port query list, and establish a connection with the printing device through the target serial port and the target baud rate parameter.

[0019] According to another aspect of the present application, an electronic device is provided, which comprises:

[0020] at least one processor; and

[0021] a memory in communication with the at least one processor; wherein

[0022] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the printing device connection method according to any one of the embodiments of the present application.

[0023] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to perform the printing device connection method according to any one of the embodiments of the present application when executed by the processor.

[0024] The technical solution of the embodiments of the present application extracts the serial port name and the baud rate parameter in the configuration file to generate a serial port query list, without the need for human memory of serial port related information, and the target serial port and the target baud rate parameter can be further determined through the serial port query list to automatically establish a connection with the printing device, thereby reducing the manual workload, avoiding the situation of incorrect serial port determination, and even when there are multiple printing devices, the connection can be quickly established, the connection efficiency of the printing device is improved, and it is more convenient for the user to perform subsequent operations.

[0025] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0027] Figure 1 is a flowchart of a printing device connection method according to the first embodiment of the present application;

[0028] Figure 2 is a flow chart of another printing device connection method according to the second embodiment of the present application;

[0029] Figure 3 is a structural schematic diagram of a printing device connection apparatus according to the third embodiment of the present application;

[0030] Figure 4 is a structural schematic diagram of an electronic device implementing a printing device connection method according to the present application. DETAILED DESCRIPTION

[0031] In order to make the personnel in the technical field better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the scope of protection of the present application.

[0032] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0033] Embodiment One

[0034] Figure 1 A flow chart of a printing device connection method is provided for the first embodiment of the present application. The present embodiment can be applicable to the case of establishing a connection with a printing device. The method can be executed by a printing device connection apparatus, which can be implemented in the form of hardware and / or software, and can be configured in a computer. As shown in the figure, the method comprises: Figure 1

[0035] S110, obtaining a configuration file and extracting serial port related information in the configuration file, wherein the serial port related information comprises a serial port name and a baud rate parameter.

[0036] ​The configuration file refers to a file in which on-board configuration information of a computer serial port is stored. The configuration file is predefined by a system developer and pre-installed in a fixed position of an embedded board. Serial port related information, including serial port name and baud rate parameter, can be extracted from the configuration file. The serial port related information includes the number of serial ports connectable to the embedded computing hardware, and the baud rate parameter with which each serial port can be operated. The serial port refers to a serial interface, i.e., an expansion interface in a serial communication mode, which means that data is transmitted sequentially one bit at a time. The baud rate parameter refers to the communication rate of the serial port, i.e., the rate of the carrier wave modulated by the effective data signal, and is also the number of times of carrier wave modulation state change per unit time. The baud rate represents the number of code symbol transmitted per second, and is a measure of the symbol transmission rate. One baud refers to the transmission of one symbol per second. In the present embodiment, the baud rate parameter specifically refers to the baud rate parameter when the serial port is connected to a printer. By way of example, the baud rate parameter can refer to the system description of a printer device already adapted to a computer.

[0037] Optionally, the configuration file is obtained, including: obtaining a configuration file template and user input parameters, wherein the user input parameters include connection time, serial port name and baud rate parameter; determining target positions corresponding to the user input parameters in the configuration file template; and combining the user input parameters with the configuration file template according to the target positions to generate the configuration file.

[0038] Specifically, the user refers to a developer or technical personnel of the Hongmeng system. The controller can obtain the configuration file template and the user input parameters input by the user. The user input parameters include connection time, serial port name and baud rate parameter. The controller can fill the user parameters, including connection time, serial port name and baud rate parameter, into the target positions of the configuration file template, so as to generate the configuration file. By way of example, the serial port name COM1 can be combined with the field name="000" in the configuration file template, and the combined format is name="COM1", indicating that the serial port name is COM1. The baud rate parameter 4800 can be combined with the field type="baud_rate" value="…" in the configuration file template, and the combined format is type="baud_rate" value="4800", indicating that the baud rate parameter is 4800.

[0039] S120, generating a serial port query list according to the serial port related information.

[0040] Optionally, the serial port query list is generated according to the serial port related information, including: combining each baud rate parameter with a serial port name to generate a serial port query instruction; determining a device driver number corresponding to the serial port name, and grouping the serial port query instructions according to the device driver number to generate a number group, wherein the serial port query instructions with the same device driver number are included in the number group; sorting the serial port query instructions in each number group according to the baud rate parameters from small to large to generate a parameter group; and sorting the parameter groups according to the device driver numbers from small to large to generate the serial port query list.

[0041] Specifically, the serial port query list includes a plurality of serial port query instructions, and the serial port query instruction is an instruction for sending a query to a serial port to print a device ID according to a configuration file. The serial port query instruction can determine the serial port connected to the printing device and the connected baud rate parameter. The controller combines each baud rate parameter with a serial port name to generate a serial port query instruction, then determines a device driver number corresponding to the serial port name, the device driver number is a serial port driver order set by the user, and the controller can divide the serial port query instructions with the same device driver number into the same group to generate a number group, then sorts the serial port query instructions in each number group according to the baud rate parameters from small to large to generate a parameter group. For example, the number group includes serial port query instruction A1: opening COM1 using baud rate parameter 9600, serial port query instruction A2: opening COM1 using baud rate parameter 19200, and serial port query instruction A3: opening COM1 using baud rate parameter 4800. The parameter group generated by sorting the serial port query instructions A1-A3 according to the baud rate parameters from small to large is in the order of A3: opening COM1 using baud rate parameter 4800, A1: opening COM1 using baud rate parameter 9600, and A2: opening COM1 using baud rate parameter 19200. Then, the parameter groups are sorted according to the device driver numbers from small to large to generate the serial port query list.

[0042] For example, there are baud rate parameters 4800, 9600 and 19200, and serial port names COM1 and COM2. The corresponding serial port query instructions in the generated serial port query list are in the order of: opening COM1 using baud rate parameter 4800, opening COM1 using baud rate parameter 9600, opening COM1 using baud rate parameter 19200, opening COM2 using baud rate parameter 4800, opening COM2 using baud rate parameter 9600, and opening COM2 using baud rate parameter 19200.

[0043] S130, determining a target serial port and a target baud rate parameter according to the serial port query list, and establishing a connection with the printing device through the target serial port and the target baud rate parameter.

[0044] Specifically, the controller can send serial port query instructions in turn according to the serial port query list to receive the connection response of the printing device, and determine the target serial port connected with the printing device and the corresponding target baud rate parameter through the connection response of the printing device. The printing device is an output device of the computer, and the computer processing result can be printed on the related medium through the printing device. Through the connection with the printing device in the embodiment, the user does not need to remember the connection parameters (baud rate parameters) of the device, and does not need to deliberately observe which serial port the device is connected to, so that the connection with the printing device can be automatically established, and multiple serial port printing devices can be connected, the connection speed is improved, and the operation of the user is facilitated.

[0045] The technical scheme of the embodiment of the application generates the serial port query list by extracting the serial port name and the baud rate parameter in the configuration file, does not need to remember the serial port related information artificially, and can automatically establish the connection with the printing device by further determining the target serial port and the target baud rate parameter, so that the artificial workload is reduced, the error in the determination of the serial port is avoided, even when there are multiple printing devices, the connection can be quickly established, the connection efficiency of the printing device is improved, and the subsequent operation of the user is facilitated.

[0046] Embodiment two

[0047] Figure 2 A flowchart of a printing device connection method provided by the embodiment two of the application, the embodiment two adds the specific process of determining the target serial port and the target baud rate parameter according to the serial port query list and establishing the connection with the printing device through the target serial port and the target baud rate parameter on the basis of the embodiment one. The specific content of steps S210-S220 is substantially the same as that of steps S110-S120 in the embodiment one, and thus the embodiment two will not be described in detail. As shown in the figure, the method comprises the following steps. Figure 2

[0048] S210, a configuration file is acquired, and serial port related information in the configuration file is extracted, wherein the serial port related information comprises a serial port name and a baud rate parameter.

[0049] Optionally, the configuration file is acquired, and the method comprises the following steps: acquiring a configuration file template and user input parameters, wherein the user input parameters comprise a connection time, a serial port name and a baud rate parameter; determining target positions corresponding to the user input parameters in the configuration file template; and combining the user input parameters with the configuration file template according to the target positions to generate the configuration file.

[0050] S220, a serial port query list is generated according to the serial port related information.

[0051] ​Optionally, the serial port query list is generated according to the serial port related information, including: combining each baud rate parameter with a serial port name to generate a serial port query instruction; determining a device driver number corresponding to the serial port name, and grouping the serial port query instructions according to the device driver number to generate a number group, wherein the serial port query instructions with the same device driver number are included in the number group; sorting the serial port query instructions in each number group according to the baud rate parameters in ascending order to generate a parameter group; and sorting the parameter groups according to the device driver numbers in ascending order to generate the serial port query list.

[0052] S230, sequentially taking the serial port query instructions in the serial port query list as target query instructions.

[0053] S240, taking the serial port name contained in the target query instruction as a to-be-queried serial port, and determining a serial port opening situation of the to-be-queried serial port, wherein the serial port opening situation includes opening success and opening failure.

[0054] Optionally, the serial port opening situation of the to-be-queried serial port is determined, including: obtaining a pre-configured serial port operation function, and sending the serial port operation function to the to-be-queried serial port; determining whether an opening response of the to-be-queried serial port is received within a specified time, if yes, determining that the serial port opening situation is opening success; otherwise, determining that the serial port opening situation is opening failure.

[0055] Specifically, the controller will open the serial ports in sequence according to the order of the serial port query list and send the serial port query instructions, and only when the serial port is opened successfully, the controller will continue to send the serial port query instruction to the serial port to query the printing device ID. The controller can send a pre-configured serial port operation function to the to-be-queried serial port to perform the operation of opening the serial port. If an opening response of the to-be-queried serial port is received within a specified time, it indicates that the serial port is opened successfully. If no opening response of the to-be-queried serial port is received, it indicates that the serial port is opened unsuccessfully, and at this time the controller will continue to open the next serial port according to the order of the serial port query list.

[0056] S250, determining a target serial port and a target baud rate parameter according to the serial port opening situation and the target query instruction.

[0057] Optionally, the target serial port and the target baud rate parameter are determined according to the serial port opening situation and the target query instruction, including: when the serial port opening situation is opening success, sending the target query instruction to the to-be-queried serial port; determining a connection time according to a configuration file; when response information of the to-be-queried serial port is received within the connection time, taking the to-be-queried serial port as the target serial port, and taking the baud rate parameter contained in the target query instruction as the target baud rate parameter.

[0058] Specifically, when the serial port is opened, the controller can send a target query instruction to the serial port to be queried to query the printing device ID, and there is a waiting time for the serial port response, which is time_out in the configuration file. For example, when the connection time is 1000, it means waiting for one second, that is, the connection time in the configuration file can be used as a judgment standard for device connection. When the response information of the serial port to be queried is received within the connection time, the serial port to be queried is used as the target serial port, and the baud rate parameter contained in the target query instruction is used as the target baud rate parameter. At this time, the controller can query the ID protocol character of the printing device connected to the serial port through the serial port query instruction, and the data is derived from the device development SDK.

[0059] Optionally, after determining the connection time according to the configuration file, it further includes: when the response information of the serial port to be queried is not received within the connection time, determining that the serial port to be queried fails to connect, and using the serial port name at the next position corresponding to the serial port to be queried in the serial port query list as the next serial port to be queried; and when it is determined that all the serial ports to be queried fail to connect, generating a connection failure prompt.

[0060] Specifically, when the response information of the serial port to be queried is not received within the connection time, it can be determined that the serial port to be queried fails to connect, indicating that there is no normal printing device connected to the serial port. At this time, the controller will continue to send the serial port query instruction using the serial port name at the next position corresponding to the serial port to be queried in the serial port query list as the next serial port to be queried. It should be noted that when it is determined that all the serial ports to be queried fail to connect, it indicates that there is no printing device connected to the computer. At this time, the controller will generate a connection failure prompt and display the connection failure prompt to the user through the user terminal connected to the controller, so that the user can timely master the connection failure of the printing device, so as to check and adjust the serial port and the printing device to ensure the normal connection of the printing device.

[0061] S260, establishing a connection with the printing device through the target serial port and the target baud rate parameter.

[0062] Specifically, after the target serial port and the target baud rate parameter are determined, the serial port and the baud rate parameter connected to the printing device are determined. At this time, the application can be notified to obtain the connection device information and perform the next operation on the device. A complete automatic detection of the serial port device is completed. Further, in actual application, since one embedded computing hardware board can have multiple serial ports and can be connected to multiple printing devices, after one serial port is successfully connected, the next serial port query instruction is still processed until all the connected serial port devices are detected as a device list for user selection.

[0063] The technical scheme of the embodiment of the present application extracts the serial port name and the baud rate parameter in the configuration file to generate a serial port query list, does not need to artificially remember the serial port related information, and can automatically establish a connection with the printing device by further determining the target serial port and the target baud rate parameter through the serial port query list, thereby reducing the artificial workload, avoiding the situation of incorrect serial port determination, and even when there are multiple printing devices, the connection can be quickly established, the connection efficiency of the printing device is improved, and it is more convenient for the user to perform subsequent operations.

[0064] Embodiment three

[0065] Figure 3 A structural schematic diagram of a printing device connection apparatus provided by the third embodiment of the present application is shown in FIG. 3. As shown in the figure, the apparatus includes: a serial port related information extraction module 310 configured to obtain a configuration file and extract serial port related information in the configuration file, wherein the serial port related information includes a serial port name and a baud rate parameter; a serial port query list generation module 320 configured to generate a serial port query list according to the serial port related information; and a printing device connection module 330 configured to determine a target serial port and a target baud rate parameter according to the serial port query list, and establish a connection with a printing device through the target serial port and the target baud rate parameter. Figure 3

[0066] Optionally, the serial port related information extraction module 310 specifically includes: a configuration file obtaining unit configured to obtain a configuration file template and user input parameters, wherein the user input parameters include a connection time, a serial port name, and a baud rate parameter; determine target positions of the user input parameters in the configuration file template; and combine the user input parameters with the configuration file template according to the target positions to generate a configuration file.

[0067] Optionally, the serial port query list generation module 320 is specifically configured to: combine each baud rate parameter with a serial port name to generate a serial port query instruction; determine a device driver number corresponding to the serial port name, group the serial port query instructions according to the device driver number to generate a number group, wherein the number group includes serial port query instructions with the same device driver number; sort the serial port query instructions in each number group according to the baud rate parameter in ascending order to generate a parameter group; and sort the parameter groups according to the device driver number in ascending order to generate a serial port query list.

[0068] ​Optionally, the printing device connection module 330 specifically comprises: a target query instruction determination unit, configured to sequentially take the serial port query instructions in the serial port query list as target query instructions; a serial port opening condition determination unit, configured to take the serial port name contained in the target query instruction as a to-be-queried serial port, and determine the serial port opening condition of the to-be-queried serial port, wherein the serial port opening condition comprises opening success and opening failure; and a target parameter determination unit, configured to determine the target serial port and the target baud rate parameter according to the serial port opening condition and the target query instruction.

[0069] Optionally, the target parameter determination unit specifically comprises: a target query instruction sending subunit, configured to send the target query instruction to the to-be-queried serial port when the serial port opening condition is opening success; a connection time determination subunit, configured to determine the connection time according to the configuration file; and a target serial port determination subunit, configured to take the to-be-queried serial port as the target serial port, and take the baud rate parameter contained in the target query instruction as the target baud rate parameter when the response information of the to-be-queried serial port is received within the connection time.

[0070] Optionally, the target parameter determination unit further comprises: a connection prompt subunit, configured to determine that the to-be-queried serial port fails to be connected when the response information of the to-be-queried serial port is not received within the connection time after the connection time is determined according to the configuration file, and take the serial port name at the next position corresponding to the to-be-queried serial port in the serial port query list as the next to-be-queried serial port; and generate a connection failure prompt when it is determined that all the to-be-queried serial ports fail to be connected.

[0071] Optionally, the serial port opening condition determination unit is specifically configured to: acquire a serial port operation function configured in advance, and send the serial port operation function to the to-be-queried serial port; and judge whether an opening response of the to-be-queried serial port is received within a specified time, and if yes, determine that the serial port opening condition is opening success; otherwise, determine that the serial port opening condition is opening failure.

[0072] The technical scheme of the embodiment of the application extracts the serial port name and the baud rate parameter in the configuration file to generate the serial port query list, does not need to artificially remember the serial port related information, and can automatically establish connection with the printing device by further determining the target serial port and the target baud rate parameter through the serial port query list, thereby reducing the artificial workload, avoiding the situation of serial port determination error, and even when there are multiple printing devices, the connection can be quickly established, the connection efficiency of the printing device is improved, and it is more convenient for the user to perform subsequent operations.

[0073] The printing device connection apparatus provided in the embodiment of the application can execute the printing device connection method provided in any embodiment of the application, and has the corresponding function modules and beneficial effects of the execution method.

[0074] Embodiment four

[0075] Figure 4 A structural diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application described and / or claimed in this document.

[0076] As shown in Figure 4 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected to the at least one processor 11 in communication, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0077] Various components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunications networks.

[0078] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, and the like. The processor 11 performs various methods and processes described above, such as a printing device connection method. That is, a configuration file is obtained, serial port related information in the configuration file is extracted, the serial port related information including a serial port name and a baud rate parameter, a serial port query list is generated according to the serial port related information, a target serial port and a target baud rate parameter are determined according to the serial port query list, and a connection with a printing device is established through the target serial port and the target baud rate parameter.

[0079] In some embodiments, a printing device connection method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of a printing device connection method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform a printing device connection method by any other appropriate means, such as by means of firmware.

[0080] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0081] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, can cause instructions defined in the flow charts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package and partially on a remote machine or entirely on a remote machine or server.

[0082] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0083] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0084] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0085] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0086] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be executed in parallel, executed in series, or executed in different orders, as long as the desired results of the technical solutions of the present disclosure can be achieved, and the present disclosure is not limited herein.

[0087] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for connecting a printing device, characterized in that, include: Obtain the configuration file and extract the serial port related information from the configuration file, wherein the serial port related information includes the serial port name and baud rate parameter; Generate a serial port query list based on the serial port information; The target serial port and target baud rate parameter are determined according to the serial port query list, and a connection is established with the printing device through the target serial port and the target baud rate parameter. The step of generating a serial port query list based on the serial port related information includes: Each of the baud rate parameters is combined with the serial port name to generate a serial port query command. Determine the device driver number corresponding to the serial port name, and group each serial port query instruction according to the device driver number to generate a number group, wherein the number group includes serial port query instructions with the same device driver number; The serial port query commands in each of the numbered groups are sorted in ascending order of the baud rate parameter to generate parameter groups; The parameters are grouped and sorted in ascending order of the device driver number to generate the serial port query list; The step of determining the target serial port and target baud rate parameters based on the serial port lookup list includes: The serial port query commands in the serial port query list are used as target query commands in sequence. The serial port name contained in the target query instruction is used as the serial port to be queried, and the serial port opening status of the serial port to be queried is determined, wherein the serial port opening status includes successful opening and failed opening; The target serial port and target baud rate parameters are determined based on the serial port opening status and the target query command. The step of determining the target serial port and target baud rate parameters based on the serial port opening status and the target query command includes: When the serial port is successfully opened, the target query command is sent to the serial port to be queried; The connection time is determined based on the configuration file; When the response information of the serial port to be queried is received within the connection time, the serial port to be queried is taken as the target serial port, and the baud rate parameter contained in the target query instruction is taken as the target baud rate parameter.

2. The method according to claim 1, characterized in that, The process of obtaining the configuration file includes: Obtain the configuration file template and user input parameters, wherein the user input parameters include connection time, serial port name, and baud rate parameters; Determine the target location corresponding to each user input parameter in the configuration file template; The user input parameters are combined with the configuration file template according to the target location to generate the configuration file.

3. The method according to claim 1, characterized in that, After determining the connection time based on the configuration file, the method further includes: If no response information is received from the serial port to be queried within the connection time, it is determined that the serial port to be queried has failed to connect, and the name of the next serial port corresponding to the serial port to be queried in the serial port query list is taken as the next serial port to be queried. When it is determined that all serial port connections to be queried have failed, a connection failure message is generated.

4. The method according to claim 1, characterized in that, Determining the serial port open status of the serial port to be queried includes: Obtain the pre-configured serial port operation function and send the serial port operation function to the serial port to be queried; Determine whether an open response is received for the serial port to be queried within a specified time. If so, determine that the serial port is successfully opened. Otherwise, the serial port opening status is determined to be an opening failure.

5. A printing equipment connection device, characterized in that, include: A serial port related information extraction module is used to obtain a configuration file and extract serial port related information from the configuration file, wherein the serial port related information includes the serial port name and baud rate parameters; The serial port query list generation module is used to generate a serial port query list based on the serial port related information. The printing device connection module is used to determine the target serial port and target baud rate parameters according to the serial port query list, and establish a connection with the printing device through the target serial port and the target baud rate parameters; The serial port query list generation module is specifically used for: combining each baud rate parameter with the serial port name to generate each serial port query command; determining the device driver number corresponding to the serial port name; grouping each serial port query command according to the device driver number to generate numbered groups, wherein the numbered groups include serial port query commands with the same device driver number; sorting each serial port query command in each numbered group according to the baud rate parameter in ascending order to generate each parameter group; and sorting each parameter group according to the device driver number in ascending order to generate a serial port query list. The printing device connection module specifically includes: a target query instruction determination unit, used to sequentially use serial port query instructions from the serial port query list as target query instructions; a serial port open status determination unit, used to use the serial port name contained in the target query instruction as the serial port to be queried, and determine the serial port open status of the serial port to be queried, wherein the serial port open status includes open successfully and open failed; and a target parameter determination unit, used to determine the target serial port and target baud rate parameters based on the serial port open status and the target query instruction. The target parameter determination unit specifically includes: a target query instruction sending subunit, used to send a target query instruction to the serial port to be queried when the serial port is successfully opened; a connection time determination subunit, used to determine the connection time according to the configuration file; and a target serial port determination subunit, used to take the serial port to be queried as the target serial port and the baud rate parameter contained in the target query instruction as the target baud rate parameter when the response information of the serial port to be queried is received within the connection time.

6. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.

7. A computer storage medium, characterized in that, The computer storage medium stores computer instructions that are used to cause the processor to execute the method of any one of claims 1-4.

Citation Information

Patent Citations

  • General processing method for serial port data

    CN108415857A