CN116483751A - Method, device and medium for identifying serial numbers - Google Patents

Method, device and medium for identifying serial numbers Download PDF

Info

Publication number
CN116483751A
CN116483751A CN202310371488.8A CN202310371488A CN116483751A CN 116483751 A CN116483751 A CN 116483751A CN 202310371488 A CN202310371488 A CN 202310371488A CN 116483751 A CN116483751 A CN 116483751A
Authority
CN
China
Prior art keywords
serial number
serial
access
communication channel
access serial
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310371488.8A
Other languages
Chinese (zh)
Inventor
何永正
闻丹丹
钱钰琦
李海锋
王亚威
许菲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Henan Xiangyu Medical Equipment Co Ltd
Original Assignee
Henan Xiangyu Medical Equipment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Henan Xiangyu Medical Equipment Co Ltd filed Critical Henan Xiangyu Medical Equipment Co Ltd
Priority to CN202310371488.8A priority Critical patent/CN116483751A/en
Publication of CN116483751A publication Critical patent/CN116483751A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/102Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4081Live connection to bus, e.g. hot-plugging
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application discloses a serial number identification method, a device and a medium, which relate to the field of communication and solve the problem that connection failure is likely to be caused by utilizing VID and PID identification of USB equipment to identify a communication serial number. The serial number corresponding to the USB-to-serial device under different conditions can be accurately identified, the serial number identification method is not only suitable for primary identification, but also suitable for the situation that the serial number changes after the serial number is plugged again, and after the chip type of the USB device is replaced or a manufacturer is replaced, special processing is not needed for restarting software, so that the maintainability of an application program is improved, and meanwhile, the experience of use is indirectly improved.

Description

Method, device and medium for identifying serial numbers
Technical Field
The present invention relates to the field of communications, and in particular, to a method, an apparatus, and a medium for identifying a serial number.
Background
The conversion from the USB interface to the universal serial port of the computer is realized by converting the universal serial bus (Universal Serial Bus, USB) to the serial port. The method provides a quick channel for the computer without a serial port, and the use of the USB to serial port device is equal to the change of the traditional serial port device into a plug and play USB device.
All USB devices have Vendor ID (VID) and Product ID (PID), and at present, the identification of a USB-to-serial port device mostly uses the VID and PID of the USB-to-serial device to identify the USB device and the corresponding serial number.
On one hand, the configuration file needs to be manually modified in advance, VID and PID information of the USB equipment are stored in the configuration file, and the burden of a user is increased; on the other hand, for convenience, many USB device manufacturers do not apply own VID to the USB execution forum, but still keep using the VID of the master control manufacturer or write the VID and PID to the product at will; meanwhile, a regular manufacturer only needs to apply VID, and the PID is determined by the manufacturer, so that products with the same model exist, different main controls can be adopted, the PIDs of the products are the same, the main control model of the USB equipment cannot be accurately identified through the VID and the PID based on the reasons, and further the corresponding serial number cannot be accurately identified; if the USB device line is changed to the USB device of different factories, the USB device VID and PID of the original manufacturer are not used, so that the VID and PID identification of the USB device are used, the serial number required to be communicated is difficult to automatically and accurately identify under many conditions, and the situation that the upper computer system is not connected or the device is not controlled when the device is controlled is caused, and bad experience is brought to a user.
Therefore, how to solve the problem that the connection failure may be caused by using the VID and PID identification of the USB device to identify the communication serial number is a technical problem that needs to be solved by those skilled in the art.
Disclosure of Invention
The purpose of the application is to provide a method, a device and a medium for identifying serial numbers, which solve the problem that connection failure may be caused by utilizing VID and PID identification of USB equipment to identify communication serial numbers.
In order to solve the above technical problem, the present application provides a serial number identification method, which is characterized by comprising:
acquiring all access serial numbers in real time through an application programming interface;
traversing all access serial numbers, opening corresponding serial ports, and sending check data to the corresponding serial ports;
if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number.
As a preferred solution, in the above method for identifying a serial number, determining that the current access serial number is the serial number used by the current communication channel further includes:
and storing the communication channel and the corresponding access serial number into a configuration file.
As a preferred solution, in the above method for identifying a serial number, the method further includes:
judging whether an access serial number corresponding to the current communication channel exists in the configuration file or not;
if the access serial number exists, opening a serial port corresponding to the stored access serial number, and sending check data to the corresponding serial port;
if the correct reply data is received, determining the serial number used by the communication channel as the current access serial number;
if no reply data is received, returning to the step of acquiring all the access serial numbers through the application programming interface.
As a preferred embodiment, the method for identifying a serial number further includes:
when the communication of the communication channel is interrupted, acquiring all access serial numbers in real time through an application programming interface;
judging whether all the current access serial numbers comprise the access serial numbers used before the interruption of the communication channel;
if not, starting the monitoring thread, and if the USB device is monitored to be inserted, returning to the step of acquiring all the access serial numbers in real time through the application programming interface.
As a preferred solution, in the above method for identifying a serial number, if all current access serial numbers include an access serial number used before interruption of a communication channel, the method further includes:
closing and reopening an access serial number used before interruption of a communication channel corresponds to a serial port;
if the opening fails, soft restarting is carried out on the serial port, and the step of closing and reopening the serial port corresponding to the access serial port number used before the interruption of the communication channel is returned until the soft restarting time reaches the preset maximum value, and the process is ended;
if the serial port is successfully opened, check data is sent to the corresponding serial port;
if the reply data is received, determining that the communication of the communication channel is recovered to be normal;
if the reply data is not received, determining that the receiving equipment fails.
As a preferred solution, in the above method for identifying a serial number, traversing an access serial number includes:
opening the access serial numbers in sequence, and opening the next access serial number if the access serial number is the same as the access serial number corresponding to the current communication channel in the configuration file;
if the access serial number has been opened, then the next access serial number is opened.
As a preferred embodiment, the method for identifying a serial number further includes:
if the cycle identification thread is started, the step of acquiring all the access serial numbers in real time through the application programming interface is started to be executed at intervals of preset time.
In order to solve the above technical problem, the present application further provides a serial port number identifying device, which is characterized by comprising:
the acquisition module is used for acquiring all access serial numbers in real time through an application programming interface;
the traversal module is used for traversing all the access serial numbers, opening the corresponding serial ports and sending check data to the corresponding serial ports;
and the determining module is used for determining that the serial number used by the communication channel is the current access serial number if the correct reply data is received.
In order to solve the above technical problem, the present application further provides a serial port number identifying device, which is characterized by comprising:
a memory for storing a computer program;
and the processor is used for realizing the steps of the serial number identification method when executing the computer program.
In order to solve the above technical problem, the present application further provides a computer readable storage medium, where a computer program is stored on the computer readable storage medium, and the steps of the serial number identification method are implemented when the computer program is executed by a processor.
According to the serial number identification method, all access serial numbers in real time are obtained through an application programming interface, all access serial numbers are traversed, corresponding serial ports are opened, and verification data are sent to the corresponding serial ports; if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number. When one communication channel needs to identify the access serial number, all the access serial numbers in real time are obtained through the application programming interface, check data are sent to the serial ports which can be used on the upper computer one by one, and then the serial number used by the communication channel is judged to be the current access serial number according to whether reply data are received or not and whether the received reply data are correct or not. The serial number corresponding to the USB-to-serial device under different conditions can be accurately identified, the serial number identification method is not only suitable for primary identification, but also suitable for the situation that the serial number changes after the serial number is plugged again, special treatment is not needed after the chip type or the manufacturer is replaced by the USB-to-serial device, software is not required to be restarted, the robustness and maintainability of an application program are improved, and meanwhile the experience of use is indirectly improved.
In addition, the application also provides a device and a medium, which correspond to the method and have the same effects.
Drawings
For a clearer description of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described, it being apparent that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a serial number identification method provided in an embodiment of the present application;
fig. 2 is a block diagram of a serial number identifying device according to an embodiment of the present application;
fig. 3 is a block diagram of another serial number identifying apparatus according to an embodiment of the present application.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments herein without making any inventive effort are intended to fall within the scope of the present application.
The core of the application is to provide a serial number identification method, a serial number identification device and a serial number identification medium.
In order to provide a better understanding of the present application, those skilled in the art will now make further details of the present application with reference to the drawings and detailed description.
The USB to serial port realizes the conversion from the computer USB interface to the universal serial port. The method provides a quick channel for the computer without a serial port, and the use of the USB to serial port device is equal to the change of the traditional serial port device into a plug and play USB device. All USB devices have VIDs and PIDs, and at present, the identification of USB serial ports mostly utilizes the VIDs and PIDs of the USB serial port devices to identify the USB devices and corresponding serial numbers.
On one hand, the configuration file needs to be manually modified in advance, VID and PID information of the USB equipment are stored in the configuration file, and the burden of a user is increased; on the other hand, for convenience, many USB device manufacturers do not apply own VID to the USB execution forum, but still keep using the VID of the master control manufacturer or write the VID and PID to the product at will; meanwhile, a regular manufacturer only needs to apply VID, and the PID is determined by the manufacturer, so that products with the same model exist, different main controls can be adopted, the PIDs of the products are the same, the main control model of the USB equipment cannot be accurately identified through the VID and the PID based on the reasons, and further the corresponding serial number cannot be accurately identified; if the USB device line is changed to the USB device of different factories, the USB device VID and PID of the original manufacturer are not used, so that the VID and PID identification of the USB device are used, the serial number required to be communicated is difficult to automatically and accurately identify under many conditions, and the situation that the upper computer system is not connected or the device is not controlled when the device is controlled is caused, and bad experience is brought to a user.
To solve the above problem, this embodiment provides a method for identifying a serial number, and fig. 1 is a flowchart of a method for identifying a serial number provided in an embodiment of the present application, including:
s11: acquiring all access serial numbers in real time through an application programming interface;
s12: traversing all access serial numbers, opening corresponding serial ports, and sending check data to the corresponding serial ports;
s13: if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number.
Based on the angle of the upper computer, when some USB devices are required to be controlled by the upper computer, the communication connection with the USB devices is realized by identifying serial numbers required to be communicated. For example, when the upper computer software controls the medical rehabilitation equipment, the communication mode of the USB to serial port is needed to interact with the equipment for data and command, so that the control and the real-time monitoring of the medical equipment are realized.
An application programming interface (Application Programming Interface, API), which is a number of predefined functions, is designed to provide the application and developer the ability to access a set of routines based on certain software or hardware without having to access source code or understand the details of the internal operating mechanisms. In practical application, the upper computer may include a plurality of external communication channels to realize control over a plurality of devices, and when each device is accessed, all the current access serial numbers can be obtained through the application programming interface. The embodiment does not limit the specific scenario requiring identifying the serial number, and can identify the serial number by the method provided by the embodiment when one communication channel needs to identify the access serial number when the connection is first established or when the communication is interrupted and reconnection is required.
Step S12 traverses all the access serial numbers, opens the corresponding serial ports, and sends check data to the corresponding serial ports; the embodiment does not limit the form of the check data, and the check data can be set according to actual needs. Step S13, if the correct reply data is received, the serial number used by the communication channel is determined as the current access serial number. If no reply data is received, the next access serial number is opened continuously. For example, if a string of data is sent to be 01 (denoted as DS), then a received data of 01 (denoted as DR) is a successful pairing, and the matching principle can be freely specified. And sending a piece of check data to serial ports which can be used on the upper computer one by one, and judging the access serial port number to be used by the current function according to whether reply data are received or not and whether the received reply data are matched with the sent check data or not.
According to the serial number identification method provided by the embodiment, all access serial numbers in real time are obtained through an application programming interface, all access serial numbers are traversed, the corresponding serial ports are opened, and check data are sent to the corresponding serial ports; if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number. When one communication channel needs to identify the access serial number, all the access serial numbers in real time are obtained through the application programming interface, check data are sent to the serial ports which can be used on the upper computer one by one, and then the serial number used by the communication channel is judged to be the current access serial number according to whether reply data are received or not and whether the received reply data are correct or not. The serial number corresponding to the USB-to-serial device under different conditions can be accurately identified, the serial number identification method is not only suitable for primary identification, but also suitable for the situation that the serial number changes after the serial number is plugged again, special treatment is not needed after the chip type or the manufacturer is replaced by the USB-to-serial device, software is not required to be restarted, the robustness and maintainability of an application program are improved, and meanwhile the experience of use is indirectly improved.
According to the above embodiment, in an actual application environment, generally, one communication channel is fixedly connected to the same USB device, so in order to improve recognition efficiency, this embodiment provides a preferred scheme, and then further includes:
and storing the communication channel and the corresponding access serial number into a configuration file.
After each correct identification, the communication channel and the corresponding access serial number are stored in a configuration file. The information recorded in the configuration file can be directly used next time, so that the recognition efficiency is improved.
Specifically, the method acquires all access serial numbers in real time through an application programming interface, and the method further comprises the following steps:
judging whether an access serial number corresponding to the current communication channel exists in the configuration file or not;
if the access serial number exists, opening a serial port corresponding to the stored access serial number, and sending check data to the corresponding serial port;
if the correct reply data is received, determining the serial number used by the communication channel as the current access serial number;
if no reply data is received, returning to the step of acquiring all the access serial numbers through the application programming interface.
If the configuration file records the access serial number corresponding to the current communication channel, the connection is attempted through the stored access serial number, and if the connection is unsuccessful, the step S11 is returned to carry out traversal, and the correct serial number is found.
In a specific application, if the communication is interrupted, it may be that the USB device is unplugged, or that the communication connection network is not good, so this embodiment provides a preferred solution, and further includes:
when the communication of the communication channel is interrupted, acquiring all access serial numbers in real time through an application programming interface;
judging whether all the current access serial numbers comprise the access serial numbers used before the interruption of the communication channel;
if not, starting the monitoring thread, and if the USB device is monitored to be inserted, returning to the step of acquiring all the access serial numbers in real time through the application programming interface.
The purpose of acquiring all real-time access serial numbers when the communication is interrupted is different from that of step S11, and this embodiment is to confirm whether the current real-time serial number includes the access serial number used before the interruption of the communication channel; if not, the USB device is pulled out. If a new USB device is inserted later, step S11 is executed to identify the serial number.
If all the current access serial numbers comprise the access serial numbers used before the interruption of the communication channel, the method further comprises the following steps:
closing and reopening an access serial number used before interruption of a communication channel corresponds to a serial port;
if the opening fails, soft restarting is carried out on the serial port, and the step of closing and reopening the serial port corresponding to the access serial port number used before the interruption of the communication channel is returned until the soft restarting time reaches the preset maximum value, and the process is ended;
if the serial port is successfully opened, check data is sent to the corresponding serial port;
if the reply data is received, determining that the communication of the communication channel is recovered to be normal;
if the reply data is not received, determining that the receiving equipment fails.
In this embodiment, if all the current access serial numbers include the access serial number used before the interruption of the communication channel, the reconnection is attempted by closing and reopening, if the connection is successful, the check data is sent to the corresponding serial port to determine whether the communication is normal, if the connection fails, the serial port is soft restarted, and the step of closing and reopening the corresponding serial port of the access serial number used before the interruption of the communication channel is returned until the soft restart time reaches the preset maximum value. If the serial port can be successfully opened, but the reply data cannot be received, the fault of the receiving equipment is indicated, and fault prompt information can be sent.
For the phenomenon of interruption (including the situation of the operation of pulling out and plugging in a communication line) in the running process of the device, the method of performing soft restart (firstly disabling and then enabling by using a program) on the USB device by using a programming technology is used for restarting the USB device in the background, so that the problem that the serial port cannot be opened normally due to occupation of the prompt serial port or other reasons when the program directly reopens the serial port is avoided. Because the method does not depend on any information of external hardware equipment, all used information is dynamically acquired in the running process of the program, and therefore, the serial number can still be correctly identified without special treatment for the condition of replacing the USB serial port model or a manufacturer.
According to the above embodiment, through the configuration file, the corresponding access serial number recorded by the current communication channel may be known, and preferably traversing the access serial number includes:
opening the access serial numbers in sequence, and opening the next access serial number if the access serial number is the same as the access serial number corresponding to the current communication channel in the configuration file;
if the access serial number has been opened, then the next access serial number is opened.
Because in case no reply data is received, the step of obtaining all access serial numbers through the application programming interface is returned. And if the access serial number is opened, indicating that the serial port is used and is unlikely to be the serial port to be used by the current communication channel, opening the next access serial number.
In addition, if the upper computer is turned on first and the rehabilitation device is turned on later, the result of the determination in step S11 is that the correct serial number is not found, and in order to cope with this situation, the embodiment provides a preferred solution, and further includes:
if the cycle identification thread is started, the step of acquiring all the access serial numbers in real time through the application programming interface is started to be executed at intervals of preset time.
In this embodiment, the background of the upper computer system starts a cycle identification thread, and executes step S11 every other preset time, so that the purpose of accurately identifying the communication port can be achieved after the equipment is powered on and the data line connection is normal.
In the above embodiments, the serial number identification method is described in detail, and the present application further provides an embodiment corresponding to the serial number identification device. It should be noted that the present application describes an embodiment of the device portion from two angles, one based on the angle of the functional module and the other based on the angle of the hardware.
Based on the angle of the functional module, fig. 2 is a structural diagram of a serial number identifying device provided in the embodiment of the present application, as shown in fig. 2,
an acquiring module 21, configured to acquire all access serial numbers in real time through an application programming interface;
the traversing module 22 is configured to traverse all access serial numbers, open corresponding serial ports, and send check data to the corresponding serial ports;
the determining module 23 is configured to determine that the serial number used by the communication channel is the current access serial number if the correct reply data is received.
In the serial number identification device provided in this embodiment, the acquisition module 21 acquires all access serial numbers in real time through an application programming interface; the traversal module 22 traverses all the access serial numbers, opens the corresponding serial ports, and sends check data to the corresponding serial ports; the determining module 23 determines the serial number used by the communication channel as the current access serial number if the correct reply data is received. When one communication channel needs to identify the access serial number, all the access serial numbers in real time are obtained through the application programming interface, check data are sent to the serial ports which can be used on the upper computer one by one, and then the serial number used by the communication channel is judged to be the current access serial number according to whether reply data are received or not and whether the received reply data are correct or not. The serial number corresponding to the USB-to-serial device under different conditions can be accurately identified, the serial number identification method is not only suitable for primary identification, but also suitable for the situation that the serial number changes after the serial number is plugged again, special treatment is not needed after the chip type or the manufacturer is replaced by the USB-to-serial device, software is not required to be restarted, the robustness and maintainability of an application program are improved, and meanwhile the experience of use is indirectly improved.
Since the embodiments of the apparatus portion and the embodiments of the method portion correspond to each other, the embodiments of the apparatus portion are referred to the description of the embodiments of the method portion, and are not repeated herein.
Fig. 3 is a block diagram of another serial number identifying apparatus according to an embodiment of the present application, where, as shown in fig. 3, the serial number identifying apparatus includes: a memory 30 for storing a computer program;
a processor 31 for implementing the steps of the method of acquiring user operation habit information according to the above-described embodiment (serial number identification method) when executing a computer program.
The serial number identification device provided in this embodiment may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, or the like.
Processor 31 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 31 may be implemented in hardware in at least one of a digital signal processor (Digital Signal Processor, DSP), a Field programmable gate array (Field-Programmable Gate Array, FPGA), a programmable logic array (Programmable Logic Array, PLA). The processor 31 may also comprise a main processor, which is a processor for processing data in an awake state, also called central processor (Central Processing Unit, CPU), and a coprocessor; a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 31 may be integrated with an image processor (Graphics Processing Unit, GPU) for rendering and rendering of content required to be displayed by the display screen. In some embodiments, the processor 31 may also include an artificial intelligence (Artificial Intelligence, AI) processor for processing computing operations related to machine learning.
Memory 30 may include one or more computer-readable storage media, which may be non-transitory. Memory 30 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 30 is at least used for storing a computer program 301, which, when loaded and executed by the processor 31, is capable of implementing the relevant steps of the serial number identification method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 30 may further include an operating system 302, data 303, and the like, where the storage manner may be transient storage or permanent storage. The operating system 302 may include Windows, unix, linux, among other things. The data 303 may include, but is not limited to, data involved in implementing a serial number identification method, and the like.
In some embodiments, the serial number identification device may further include a display screen 32, an input/output interface 33, a communication interface 34, a power supply 35, and a communication bus 36.
It will be appreciated by those skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the serial number identification device, and may include more or fewer components than shown.
The serial number identification device provided by the embodiment of the application comprises a memory and a processor, wherein the processor can realize the following method when executing a program stored in the memory: the serial number identification method comprises the steps of acquiring all access serial numbers in real time through an application programming interface, traversing all access serial numbers, opening corresponding serial ports, and sending check data to the corresponding serial ports; if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number. When one communication channel needs to identify the access serial number, all the access serial numbers in real time are obtained through the application programming interface, check data are sent to the serial ports which can be used on the upper computer one by one, and then the serial number used by the communication channel is judged to be the current access serial number according to whether reply data are received or not and whether the received reply data are correct or not. The serial number corresponding to the USB-to-serial device under different conditions can be accurately identified, the serial number identification method is not only suitable for primary identification, but also suitable for the situation that the serial number changes after the serial number is plugged again, special treatment is not needed after the chip type or the manufacturer is replaced by the USB-to-serial device, software is not required to be restarted, the robustness and maintainability of an application program are improved, and meanwhile the experience of use is indirectly improved.
Finally, the present application also provides a corresponding embodiment of the computer readable storage medium. The computer-readable storage medium stores a computer program which, when executed by a processor, performs the steps described in the above-described serial number identification method embodiment.
It will be appreciated that the methods of the above embodiments, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored on a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution contributing to the prior art, or in a software product stored in a storage medium, performing all or part of the steps of the methods of the various embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The computer readable storage medium provided in this embodiment has a computer program stored thereon, which when executed by a processor, can implement the following method: the serial number identification method comprises the steps of acquiring all access serial numbers in real time through an application programming interface, traversing all access serial numbers, opening corresponding serial ports, and sending check data to the corresponding serial ports; if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number. When one communication channel needs to identify the access serial number, all the access serial numbers in real time are obtained through the application programming interface, check data are sent to the serial ports which can be used on the upper computer one by one, and then the serial number used by the communication channel is judged to be the current access serial number according to whether reply data are received or not and whether the received reply data are correct or not. The serial number corresponding to the USB-to-serial device under different conditions can be accurately identified, the serial number identification method is not only suitable for primary identification, but also suitable for the situation that the serial number changes after the serial number is plugged again, special treatment is not needed after the chip type or the manufacturer is replaced by the USB-to-serial device, software is not required to be restarted, the robustness and maintainability of an application program are improved, and meanwhile the experience of use is indirectly improved.
The method, the device and the medium for identifying the serial number provided by the application are described in detail above. In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section. It should be noted that it would be obvious to those skilled in the art that various improvements and modifications can be made to the present application without departing from the principles of the present application, and such improvements and modifications fall within the scope of the claims of the present application.
It should also be noted that in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A method for identifying a serial number, comprising:
acquiring all access serial numbers in real time through an application programming interface;
traversing all the access serial numbers, opening the corresponding serial ports, and sending check data to the corresponding serial ports;
if the correct reply data is received, the serial number used by the communication channel is determined to be the current access serial number.
2. The method for identifying a serial number according to claim 1, wherein said determining that the current access serial number is a serial number used by a current communication channel further comprises:
and storing the communication channel and the corresponding access serial number into a configuration file.
3. The method for identifying serial numbers according to claim 2, wherein said obtaining all access serial numbers in real time through the application programming interface further comprises:
judging whether the configuration file has the access serial number corresponding to the current communication channel or not;
if the access serial number exists, opening a serial port corresponding to the stored access serial number, and sending check data to the corresponding serial port;
if the correct reply data is received, determining the serial number used by the communication channel as the current access serial number;
and if the reply data is not received, returning to the step of acquiring all the access serial numbers through the application programming interface.
4. The method for identifying a serial number according to claim 1, further comprising:
when the communication of the communication channel is interrupted, acquiring all access serial numbers in real time through an application programming interface;
judging whether all the current access serial numbers comprise the access serial numbers used before the interruption of the communication channel;
if not, starting a monitoring thread, and if the USB equipment is monitored to be inserted, returning to the step of acquiring all the access serial numbers in real time through the application programming interface.
5. The method for identifying a serial number according to claim 4, further comprising, if all the current access serial numbers include the access serial number used before the communication channel was interrupted:
closing and reopening a serial port corresponding to the access serial port number used before interruption of the communication channel;
if the opening fails, carrying out soft restarting on the serial port, returning to the step of closing and restarting the serial port corresponding to the serial port number used before the interruption of the communication channel, and ending the flow until the soft restarting time reaches a preset maximum value;
if the serial port is successfully opened, check data is sent to the corresponding serial port;
if the reply data is received, determining that the communication of the communication channel is recovered to be normal;
if the reply data is not received, determining that the receiving equipment fails.
6. A method of serial number identification as claimed in claim 3, wherein said traversing the access serial number comprises:
opening the access serial numbers in sequence, and opening the next access serial number if the access serial number is the same as the access serial number corresponding to the current communication channel in the configuration file;
and if the access serial number is opened, opening the next access serial number.
7. The method for identifying a serial number according to claim 1, further comprising:
and if the period identification thread is started, starting to execute the step of acquiring all the access serial numbers in real time through the application programming interface at intervals of preset time.
8. A serial number identification device, characterized by comprising:
the acquisition module is used for acquiring all access serial numbers in real time through an application programming interface;
the traversing module is used for traversing all the access serial numbers, opening the corresponding serial ports and sending check data to the corresponding serial ports;
and the determining module is used for determining that the serial number used by the communication channel is the current access serial number if the correct reply data is received.
9. A serial number identification device, characterized by comprising:
a memory for storing a computer program;
processor for implementing the steps of the serial number identification method according to any one of claims 1 to 7 when executing said computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the serial number identification method according to any of claims 1 to 7.
CN202310371488.8A 2023-04-06 2023-04-06 Method, device and medium for identifying serial numbers Pending CN116483751A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310371488.8A CN116483751A (en) 2023-04-06 2023-04-06 Method, device and medium for identifying serial numbers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310371488.8A CN116483751A (en) 2023-04-06 2023-04-06 Method, device and medium for identifying serial numbers

Publications (1)

Publication Number Publication Date
CN116483751A true CN116483751A (en) 2023-07-25

Family

ID=87224365

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310371488.8A Pending CN116483751A (en) 2023-04-06 2023-04-06 Method, device and medium for identifying serial numbers

Country Status (1)

Country Link
CN (1) CN116483751A (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104483940A (en) * 2014-12-10 2015-04-01 西安理邦科学仪器有限公司 Networking method and device for monitoring system
CN104811359A (en) * 2015-04-10 2015-07-29 深圳市元征科技股份有限公司 Serial port communication method and terminal
CN105007195A (en) * 2015-07-15 2015-10-28 广东欧珀移动通信有限公司 Port binding method and device
WO2017193898A1 (en) * 2016-05-09 2017-11-16 广州广电运通金融电子股份有限公司 Serial port mapping method and device based on linux or unix kernel operating system
CN107967229A (en) * 2017-12-22 2018-04-27 安徽博微长安电子有限公司 A kind of serial ports automatic identifying method, system and computer-readable recording medium
CN108415857A (en) * 2018-03-01 2018-08-17 合肥威艾尔智能技术有限公司 A kind of universal process method of serial data
CN109597779A (en) * 2018-11-21 2019-04-09 Oppo(重庆)智能科技有限公司 A kind of serial-port inquiring method and equipment and computer storage medium
CN110457244A (en) * 2018-05-08 2019-11-15 深圳市优必选科技有限公司 A kind of communication mode conversion method, system and the processor of serial ports
CN112669956A (en) * 2020-12-30 2021-04-16 上海电气集团股份有限公司 Method and equipment for collecting medical instrument data
CN113886302A (en) * 2021-10-19 2022-01-04 深圳市元征科技股份有限公司 Serial port number obtaining method and device of application equipment, terminal equipment and storage medium
CN114860613A (en) * 2022-05-31 2022-08-05 京东方科技集团股份有限公司 Automatic testing method and device

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104483940A (en) * 2014-12-10 2015-04-01 西安理邦科学仪器有限公司 Networking method and device for monitoring system
CN104811359A (en) * 2015-04-10 2015-07-29 深圳市元征科技股份有限公司 Serial port communication method and terminal
CN105007195A (en) * 2015-07-15 2015-10-28 广东欧珀移动通信有限公司 Port binding method and device
WO2017193898A1 (en) * 2016-05-09 2017-11-16 广州广电运通金融电子股份有限公司 Serial port mapping method and device based on linux or unix kernel operating system
CN107967229A (en) * 2017-12-22 2018-04-27 安徽博微长安电子有限公司 A kind of serial ports automatic identifying method, system and computer-readable recording medium
CN108415857A (en) * 2018-03-01 2018-08-17 合肥威艾尔智能技术有限公司 A kind of universal process method of serial data
CN110457244A (en) * 2018-05-08 2019-11-15 深圳市优必选科技有限公司 A kind of communication mode conversion method, system and the processor of serial ports
CN109597779A (en) * 2018-11-21 2019-04-09 Oppo(重庆)智能科技有限公司 A kind of serial-port inquiring method and equipment and computer storage medium
CN112669956A (en) * 2020-12-30 2021-04-16 上海电气集团股份有限公司 Method and equipment for collecting medical instrument data
CN113886302A (en) * 2021-10-19 2022-01-04 深圳市元征科技股份有限公司 Serial port number obtaining method and device of application equipment, terminal equipment and storage medium
CN114860613A (en) * 2022-05-31 2022-08-05 京东方科技集团股份有限公司 Automatic testing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张宏桥 等: "基于Websocket的串口控制系统的研究", 软件工程, vol. 22, no. 06, 5 June 2019 (2019-06-05), pages 22 - 25 *

Similar Documents

Publication Publication Date Title
CN114003538B (en) Identification method of intelligent network card and intelligent network card
CN111414285A (en) Test method, test device and test equipment for starting function of server system
WO2019184527A1 (en) Method and apparatus for testing stability of set top box, and electronic device
CN109966742A (en) The method and device of rendering performance data is obtained in game running
WO2022222293A1 (en) Storage device test method and apparatus, television, and storage medium
CN112996020A (en) Bluetooth-based automatic testing method and device and Bluetooth testing terminal
CN110851297A (en) Method, device, system and medium for processing interface jitter state
CN106878486A (en) A kind of method and system for preventing Onboard NIC MAC Address from being changed
CN112667442B (en) Control method, device and equipment based on nonvolatile memory device starting system
CN111128139B (en) Non-invasive voice test method and device
CN116483751A (en) Method, device and medium for identifying serial numbers
CN107357682A (en) A kind of method and device for recovering to go back original system
CN116775413A (en) PCIE topology scanning method, device, equipment and readable storage medium
CN115951949A (en) Recovery method and device for configuration parameters of BIOS (basic input output System) and computing equipment
CN113434467B (en) Network file transmission method, device and computer readable storage medium
CN111984568B (en) Method and system for PHY port polarity self-adaption of SAS controller
CN113900875A (en) Startup test method and device, computer equipment and storage medium
CN109427410A (en) Method for restarting flash memory device and device using the same
CN115168119A (en) PCIE (peripheral component interface express) link detection method, device and medium for server
CN115580550A (en) Network card stability testing method, device, equipment and storage medium
CN111371799B (en) Method, device and equipment for controlling data receiving and transmitting of MCTP (Multi-channel media Port) controller
CN114281422A (en) Cloud computer control method, device and medium
CN112669956A (en) Method and equipment for collecting medical instrument data
CN114461471A (en) Method, device and medium for judging PCIE link training process state
CN108182157B (en) Method, BMC, device and storage medium for realizing heterogeneous hybrid memory

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination