CN110244983B - Method for fixing serial port number, terminal equipment and storage medium - Google Patents

Method for fixing serial port number, terminal equipment and storage medium Download PDF

Info

Publication number
CN110244983B
CN110244983B CN201910460214.XA CN201910460214A CN110244983B CN 110244983 B CN110244983 B CN 110244983B CN 201910460214 A CN201910460214 A CN 201910460214A CN 110244983 B CN110244983 B CN 110244983B
Authority
CN
China
Prior art keywords
serial port
port number
key
equipment
name
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.)
Active
Application number
CN201910460214.XA
Other languages
Chinese (zh)
Other versions
CN110244983A (en
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.)
PAX Computer Technology Shenzhen Co Ltd
Original Assignee
PAX Computer Technology Shenzhen 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 PAX Computer Technology Shenzhen Co Ltd filed Critical PAX Computer Technology Shenzhen Co Ltd
Priority to CN201910460214.XA priority Critical patent/CN110244983B/en
Publication of CN110244983A publication Critical patent/CN110244983A/en
Application granted granted Critical
Publication of CN110244983B publication Critical patent/CN110244983B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4411Configuring for operating with peripheral devices; Loading of device drivers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The application is applicable to the technical field of computers, and provides a method for fixing serial port numbers, terminal equipment and a storage medium, wherein the method comprises the following steps: acquiring equipment access information, and creating a corresponding equipment object according to the equipment access information; acquiring a user setting registry key corresponding to the equipment object; the user sets the registry key as a pre-stored registry key; when the fixed serial port number needs to be set for the equipment object according to the user setting registry key, reading the fixed serial port number in the user setting registry key; and configuring access information for the equipment object according to the fixed serial port number. According to the method for fixing the serial port number, the terminal device and the storage medium, the user setting registry entry containing the fixed serial port number is additionally arranged, so that the serial port number of the corresponding device is fixedly set, and the corresponding fixed serial port number can be configured for the device no matter which port of the Windows PC is inserted into the device.

Description

Method for fixing serial port number, terminal equipment and storage medium
Technical Field
The present application belongs to the field of computer technologies, and in particular, to a method for fixing serial port numbers, a terminal device, and a storage medium.
Background
The Windows virtual serial port driver is a driver widely applied in Windows, and uses an API (Application Program Interface, abbreviated as API) of a traditional serial port to access some communication devices. For external devices connected to a Windows PC (personal computer, PC for short), such as a USB-to-serial adapter, and electronic devices connected to the PC through a USB interface, PC-side application software often uses a virtual serial port to access them. The function of virtual serial port access is mainly provided and realized by a Windows virtual serial port driver. However, when the external device changes the port access, the problem that the function of the application program calling the external device in the Windows system is abnormal or cannot run often occurs; meanwhile, some Windows applications provide the requirement of fixing the serial number of the same device, namely: no matter which different slot positions are respectively inserted into the equipment, serial port numbers corresponding to the equipment and seen by the application program are the same.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, a terminal device, and a storage medium for fixing a serial number, so as to solve the problem that an application program calling an external device in a current Windows system has a function abnormality or cannot run.
According to a first aspect, an embodiment of the present application provides a method for fixing a serial number, including: acquiring equipment access information, and creating a corresponding equipment object according to the equipment access information; acquiring a user setting registry key corresponding to the equipment object; the user sets the registry key as a pre-stored registry key; when the fixed serial port number needs to be set for the equipment object according to the user setting registry key, reading the fixed serial port number in the user setting registry key; and establishing a corresponding symbolic link for the equipment object according to the fixed serial port number and configuring access information.
The method for fixing the serial port number, provided by the embodiment of the application, is characterized in that a user setting registry entry is additionally arranged in a Windows registry, and the fixed serial port number is written in the user setting registry entry, so that access information is configured on a corresponding device object by using the fixed serial port number, and the serial port number of the corresponding device is fixedly set.
With reference to the first aspect, in some embodiments, the user setup registry key includes a first key name and a second key name; the first key name is used for indicating whether the serial port number of the equipment object is fixedly set; the second key name is used for storing a fixed serial port number of the equipment object; correspondingly, when it is determined that the fixed serial port number is set for the device object according to the user-set registry key, reading the fixed serial port number in the user-set registry key, including: reading a first key name in the user setting registry key; judging whether a fixed serial port number needs to be set for the equipment object or not according to the first key name; and when the fixed serial port number needs to be set for the equipment object according to the first key name, reading a second key name in the user setting registry key, and taking the second key name as the fixed serial port number.
The method for fixing the serial port number, provided by the embodiment of the application, realizes free selection of the serial port number setting mode by setting the first key name used for indicating whether the serial port number is fixedly set or not and the second key name used for storing the fixed serial port number in the user setting registry entry, can realize fixed setting of the serial port number for the external equipment, and can also reserve the function of dynamically distributing the serial port number in the existing Windows virtual serial port driver, so that the serial port number is more flexibly configured, and the running requirements of more application programs are met.
With reference to the first aspect, in some embodiments, the establishing a corresponding symbolic link for the device object and configuring access information according to the fixed serial port number includes: updating the hardware key of the equipment object according to the fixed serial port number; writing the fixed serial port number into a serial port equipment mapping registry table; establishing a symbolic link corresponding to the equipment object according to the fixed serial port number; and updating the equipment friendly name of the equipment object according to the fixed serial port number.
The method for fixing the serial port number provided by the embodiment of the application provides a specific method for configuring access information for a corresponding device object by using the fixed serial port number stored in the user setting registry entry, so that the user can realize the fixation of the serial port number of the external device according to the configuration method of the access information, and each application program can smoothly use the fixed serial port number of the external device to access the application program.
With reference to the first aspect, in some embodiments, the updating the device-friendly name of the device object according to the fixed serial number includes: creating a temporary thread, and acquiring an equipment instance path of the equipment object according to the temporary thread; reading a first device friendly name of the device object through the temporary thread according to the device instance path; updating the serial port number in the first equipment friendly name through the temporary thread and according to the fixed serial port number to generate a corresponding second equipment friendly name; updating the device friendly name sub-key under the device instance path through the temporary thread and according to the second device friendly name; the temporary thread is terminated.
The method for fixing the serial number provided in the embodiment of the application provides a specific method for setting a device friendly name for a corresponding device object by using the fixed serial number stored in the user setting registry key, so that a user can update the friendly name of the device object according to the method for updating the friendly name, and each application program can smoothly access the device object by using the friendly name.
With reference to the first aspect, in some embodiments, after the obtaining the user-set registry key corresponding to the device object, the method for fixing the serial number further includes: and updating the equipment extension data structure of the equipment object according to the user-set registry key.
According to the method for fixing the serial port number, after the device object is created and the corresponding user setting registry key is read, corresponding updating processing is further performed on the device extension data structure of the device object, so that the running processing process of the temporary thread is facilitated.
With reference to the first aspect, in some embodiments, the device extension data structure includes a first variable and a second variable; the first variable is used for indicating whether the serial port number of the equipment object is fixedly set; the second variable is used for storing a fixed serial number of the device object.
The method for fixing the serial port number, provided by the embodiment of the application, is characterized in that a first variable used for indicating whether the serial port number is fixedly set or not and a second variable used for storing the corresponding fixed serial port number are additionally arranged in an equipment extension data structure, so that not only is the setting of the serial port number fixed for the external equipment supported, but also the function of dynamically distributing the serial port number in the existing Windows virtual serial port driver can be reserved, the configuration of the serial port number is more flexible, and the operation requirements of more application programs are met.
With reference to the first aspect, in some embodiments, the updating the device extension data structure of the device object according to the user setup registry key includes: writing a first key name in the user setting registry key into a first variable in the equipment extension data structure; and writing a second key name in the user setting registry key into a second variable in the equipment extension data structure.
According to the method for fixing the serial port number, after the first key name and the second key name in the registry key set by the user are read, the first key name and the second key name are respectively written into two variables of the equipment extension data structure with the corresponding functions, and therefore updating processing of the equipment extension data structure is achieved.
According to a second aspect, an embodiment of the present application provides a terminal device, including:
the device object creating unit is used for acquiring device access information and creating a corresponding device object according to the device access information;
a registry key reading unit, configured to obtain a user-set registry key corresponding to the device object; the user sets the registry key as a pre-stored registry key; when the fixed serial port number is determined to be set for the equipment object according to the user-set registry key, the registry key reading unit is further used for reading the fixed serial port number in the user-set registry key;
and the serial port number setting unit is used for configuring access information for the equipment object according to the fixed serial port number.
According to a third aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method according to the first aspect or any embodiment of the first aspect when executing the computer program.
According to a fourth aspect, embodiments of the present application provide a computer-readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the steps of the method according to the first aspect or any embodiment of the first aspect.
A fifth aspect of embodiments of the present application provides a computer program product comprising a computer program that, when executed by one or more processors, performs the steps of the method provided by the first aspect of embodiments of the present application.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of a specific example of a method for fixing a serial number provided in an embodiment of the present application;
fig. 2 is a flowchart of another specific example of a method for fixing a serial number according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a specific example of a terminal device provided in an embodiment of the present application;
fig. 4 is a schematic structural diagram of another specific example of the terminal device provided in the embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
There are often multiple ports on a PC that have the same functionality. In general, the Windows virtual serial driver configures dynamically assigned and respectively different serial numbers for devices on different ports, so that each device plugged in different ports can be respectively and independently identified and completed. However, this also poses a problem: if the same device is plugged into different ports, the serial port numbers configured by the Windows virtual serial port driver are different. Since many applications access a serial device using a serial number as an identification name, uncertainty is brought to the application using the device. In order to solve the problem that an application program calling an external device in a Windows system has abnormal functions or cannot run, and is compatible with an original application program, a fixed and unchangeable serial port number needs to be configured for the same external device, namely, no matter the device is inserted into any slot position of a PC, the serial port number corresponding to the device, which is acquired by the application program, is the same.
According to the serial port number fixing method, the existing Windows virtual serial port driver is improved, and the function of fixing the serial port number is added on the premise that all existing functions of the existing Windows virtual serial port driver are reserved. The serial port number fixing method is suitable for Windows software platforms, a registry and an installation mechanism of a device driver provided by a Windows system are utilized, the registry is properly operated and a device symbol link name is properly created in a modified program by modifying a conventional Windows virtual serial port driver, and the function of fixing the serial port number is realized.
The serial number fixing method provided by the application focuses on how to realize the function of fixing the serial number in the Windows virtual serial driver, and focuses on how to realize virtual serial communication in the Windows virtual serial driver and the setting of a communication protocol of the Windows virtual serial driver, so that the contents are not described.
In some embodiments, as shown in fig. 1, the serial number of the external device accessing to the Windows PC may be fixed through the following steps:
step S11: and acquiring equipment access information, and creating a corresponding equipment object according to the equipment access information.
The Windows virtual serial driver can generally run under a corresponding hardware environment. When an external device accesses a port of a Windows PC, the Windows driver creates a corresponding device object for it.
Step S12: and acquiring a user setting registry corresponding to the equipment object.
In practical application, the user sets the registry key as the registry key agreed to be used in the serial number fixing method provided by the embodiment of the application, and the registry key not agreed to be used in the existing Windows system should be pre-stored in the Windows system.
In a specific embodiment, the user may preset the related information, data type and storage location of the registry key. As an example, a user may be contracted to set a registry key to include a first key name with a key name FixedPortEnable and a data type of REG _ DWORD (32-bit integer), and a second key name with a key name of FixedPortNo and a data type of REG _ DWORD (32-bit integer).
The first key name is used for indicating whether the serial port number of the equipment object is fixedly set or not; the second key name is used to store the fixed serial number of the device object.
Specifically, it may be agreed that when the first key name is 0, the first key name represents "not enabled", that is, the serial number of the external device is not fixedly set by using the serial number fixing method provided in the embodiment of the present application. At this time, a conventional dynamic serial port number processing mode may be used, that is, the value of the PortName in the hardware key of the device is read, and is written into the serial port device mapping registry entry, and the value is used as a symbolic link name to establish symbolic link for the created device object name. When the first key name is 1, the key represents enabled, namely the serial number of the external device is fixedly set by adopting the serial number fixing method provided by the embodiment of the application.
By way of example, COM5 may be stored as a fixed serial number in the second key name of the user setup registry key, and the fixed serial number of the corresponding device object is COM 5. When the first key name is 1, the corresponding device object is represented by using a fixed serial number of COM 5.
In addition, in a specific example, the storage location of the registry key is set to HKLM \ SOFTWARE \ FixedVcom by the appointed user. Here, HKLM \ SOFTWARE is a sub-key of the system self-establishment in the Windows registry, and is used to store SOFTWARE and Windows setting information, and is mainly modified by the application program and the system installer; FixedVcom is the next level of subkey name established in the embodiments of the application.
Step S13: and judging whether a fixed serial port number needs to be set for the equipment object or not according to the registry key set by the user. When determining that a fixed serial port number needs to be set for the device object according to the user-set registry key, executing step S14; and when determining that the fixed serial number does not need to be set for the equipment object according to the registry key set by the user, configuring the dynamic serial number for the equipment object by using a conventional dynamic serial number processing mode.
Step S14: and reading the fixed serial port number in the registry key set by the user.
In a specific embodiment, the process from step S13 to step S14 may be implemented by the following several sub-steps:
step S131: and reading a first key name in the user setting registry key.
Step S132: and judging whether a fixed serial port number needs to be set for the equipment object or not according to the first key name. When it is determined that the fixed serial number needs to be set for the device object according to the first key name, performing step S141; and when the fixed serial number does not need to be set for the equipment object according to the first key name, configuring the dynamic serial number for the equipment object by using a conventional dynamic serial number processing mode. As an example, when the first key name is 1, it may be determined that a fixed serial number needs to be set for the device object; when the first key name is 0, it is determined that a fixed serial number does not need to be set for the device object.
Step S141: and reading a second key name in the user-set registry key.
Step S142: and taking the second key name as a fixed serial number.
Step S15: and establishing corresponding symbolic links for the equipment objects according to the fixed serial port numbers and configuring access information.
In a specific embodiment, the process of step S15 can be implemented by the following several sub-steps:
step S151: and updating the hardware key of the equipment object according to the fixed serial port number.
Specifically, the read fixed serial port number may be used to update the PortName key value in the hardware key of the corresponding device object, that is, the PortName key value is set as the corresponding fixed serial port number.
Step S152: and writing the fixed serial port number into a serial port device mapping registry table.
The serial port equipment mapping registry key is a registry key appointed by the Windows system for the serial port equipment, and is used for recording and indicating a symbol link name corresponding to the equipment name of the serial port equipment, so that the serial port equipment mapping registry key can be accessed and used by related system functions.
Step S153: and establishing a symbolic link corresponding to the equipment object according to the fixed serial port number.
Step S154: and updating the device friendly name of the device object according to the fixed serial port number.
The Windows system has a large number of names named by numbers, which is not convenient for users to identify and memorize, so the Windows system is compensated by using device-friendly names. In the device manager of Windows, a device friendly name, i.e., a device name described in popular texts and convenient for a user to understand and memorize, is displayed. The friendly name of the virtual serial port device generally contains serial port number description. For example, if a device is called a USB Virtual Port (COM5) with a friendly name, the COM5 is a serial number, which is convenient for a user to recognize and use. The serial number in the friendly name describes a character sequence and is called a serial number substring.
Since the device-friendly name includes the serial number of the corresponding device object, when the fixed serial number of the device object is configured, the corresponding device-friendly name needs to be updated.
In a specific embodiment, the step S154 of updating the device friendly name of the device object according to the fixed serial number may be implemented by the following steps:
step S1541: and creating a temporary thread, and acquiring a device instance path of the device object according to the temporary thread.
There are various ways to obtain the device instance path. For example, sending an IRP request related to an acquisition device instance path to a bottom layer device stack and acquiring corresponding response information; or obtaining a device symbol link name by calling a device interface registration function IoRegisterDeviceInterface (), taking out a device instance identifier from the device symbol link name, and synthesizing a device instance path together with the device enumeration tree; or obtaining the device symbol link name by calling a device interface obtaining function IoGetDeviceInterfaces (), taking the device instance identifier from the device symbol link name, and synthesizing the device instance path together with the device enumeration tree.
Step S1542: and reading the first device friendly name of the device object through the temporary thread according to the device instance path. The first device-friendly name of the device object is the device-friendly name before the device-friendly name of the device object is updated with the fixed serial number.
The FriendlyName sub-key (i.e., device friendly name) is read from the device instance path in a loop until successful or timed out. And if the time is out, clearing the running mark of the temporary thread and terminating the temporary thread.
Here, the timeout value may be self-adjusted and set according to the installation speed of a specific device, such as 3 seconds, 5 seconds, or 10 seconds, etc. The circular reading flow is designed because the temporary thread and the device installation program run in parallel when the device driver is updated, and the value reading of the temporary thread is successful only after the device installation program writes the FriendlyName sub-key value. Therefore, the cyclic reading process can ensure that the temporary thread can correctly write the FriendlyName sub-key when the device driver is updated.
Step S1543: and updating the serial port number in the first device friendly name through the temporary thread and according to the fixed serial port number to generate a corresponding second device friendly name.
And the second device-friendly name of the device object is the device-friendly name obtained after the device-friendly name of the device object is updated by adopting the fixed serial port number.
Specifically, the serial number in the read first device-friendly name may be modified to be the current fixed serial number. For example, if the first device friendly name read is: the USB Virtual Port (COM3), the current fixed serial Port number being COM5, has a modified device-friendly name (i.e. second device-friendly name) of: USB Virtual Port (COM 5).
Step S1544: and updating the device friendly name sub-key under the device instance path through the temporary thread and according to the second device friendly name.
Specifically, the device-friendly name after the serial number is modified, that is, the second device-friendly name, may be written into the device-friendly name sub-key in the device instance path. The device friendly name sub-key is a registry key for storing the device friendly name agreed by the Windows system, and the key name is FriendlyName and is positioned under a corresponding device instance path.
Step S1545: the temporary thread is terminated.
In a specific embodiment, the existing device removal routine and device sudden removal routine of the Windows virtual serial port driver can be further modified.
The DEVICE REMOVAL routine is a processing routine of IRP _ MN _ REMOVE _ DEVICE, and the DEVICE sudden REMOVAL routine is a processing routine of IRP _ MN _ surfrise _ REMOVE.
In both processing flows, wait processing for the temporary thread is increased until the temporary thread has exited before forwarding the IRP to the underlying device. This process is added to avoid system blue screen failures caused by temporary threads continuing to run after device deletion.
Optionally, as shown in fig. 2, after obtaining the user-set registry key corresponding to the device object in step S102, the following steps may be added in the serial port number fixing method:
step S16: and updating the equipment extension data structure of the equipment object according to the registry key set by the user.
The memory space of the device extension data structure is allocated by a system when a device object is created, and a driver accesses each field in the structure through a pointer of the structure; the configuration pointer is stored in the DeviceExtension field of the device object, so the driver accesses the device extension data structure by accessing the DeviceExtension field of the device object.
Specifically, the definition of the variable related to the fixed serial number may be added to the device extension data structure, so as to facilitate the process control of the embodiment of the present application. The variables that need to be added in the device extension data structure include a first variable and a second variable. The first variable is used for indicating whether the serial port number of the equipment object is fixedly set or not, and the function of the first variable corresponds to the function of setting a first key name in a registry key by a user; the second variable is used to store a fixed serial number for the device object, whose function corresponds to the function of the user setting the second key name in the registry key.
Optionally, a third variable and a fourth variable may be added to the device extension data structure. Specifically, the third variable may be a temporary thread running flag variable, which is used to indicate whether a temporary thread that updates the device friendly name is in a running state. As an example, it may be agreed that when the third variable is 0, it represents "temporary thread stop running"; when the third variable is 1, the representation represents "temporary thread is running".
The fourth variable may be an apparatus instance path variable, and is used to store an instance path name of the virtual serial port apparatus.
In a specific embodiment, the process of step S16 can be implemented by the following sub-steps:
step S161: writing a first key name in the user-set registry key into a first variable in the device extension data structure.
Step S162: and writing a second key name in the user-set registry key into a second variable in the equipment extension data structure.
In practical applications, the user may set the first key name and the second key name in the user setting registry key by driving an installer or other tool (e.g., regedit). The tool programs write the two items of configuration information into a registry for subsequent reading and use by the virtual serial port driver.
If the fixed serial port number mode is to be used, the user needs to set the first key name in the user-set registry key to 1, and set the second key name in the user-set registry key to the serial port number that needs to be fixed, for example, 5.
If the fixed serial number mode is not wanted to be used, but the conventional dynamic serial number mode is wanted to be used, the user only needs to set the first key name in the user setting registry key to be 0.
Installing the modified Windows virtual serial port driver provided by the embodiment of the application by adopting an installation tool provided by a Windows system or an installation tool provided by an application program; after the virtual device or the external device is inserted into the Windows system slot, the application program can access the device through the corresponding fixed serial port number.
The serial port number fixing method and the modified Windows virtual serial port driver provided by the embodiment of the application enhance the adaptability of the Windows driver to special scenes and special requirements, and expand the application range of Windows. The serial number fixing method and the modified Windows virtual serial driver provided by the embodiment of the application can support a fixed serial number mode, can also support an existing dynamic serial number mode in a compatible mode, and have better compatibility and adaptability. The temporary thread is skillfully and reasonably utilized to complete the updating of the equipment user name, so that the equipment name seen in the equipment manager is ensured to be consistent with the serial port number fixed in the driving program. The serial port number fixing method and the modified Windows virtual serial port driver provided by the embodiment of the application only need to partially and slightly modify the existing Windows virtual serial port driver, and the implementation scheme is simple and effective.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
An embodiment of the present application further provides a terminal device, as shown in fig. 3, where the terminal device may include: a device object creation unit 301, a registry key reading unit 302, and a serial number configuration unit 303.
The device object creating unit 301 is configured to obtain device access information, and create a corresponding device object according to the device access information; the corresponding working process can be referred to step S11 in the above method embodiment.
The registry key reading unit 302 is configured to obtain a user-set registry key corresponding to the device object; a user sets a registry key as a pre-stored registry key; when determining that a fixed serial port number is set for the device object according to the user-set registry key, the registry key reading unit 303 is further configured to read the fixed serial port number in the user-set registry key; the corresponding working process can be found in step S12 to step S14 in the above method embodiment.
The serial port number configuration unit 303 is configured to configure access information for the device object according to the fixed serial port number; the corresponding working process can be referred to step S15 in the above method embodiment.
Optionally, the serial number configuration unit 303 may also be configured to update the device extension data structure of the device object according to the registry key set by the user, and a corresponding working process of the serial number configuration unit may be described in step S16 in the foregoing method embodiment.
Fig. 4 is a schematic diagram of a terminal device according to an embodiment of the present application. As shown in fig. 4, the terminal device 600 of this embodiment includes: a processor 601, a memory 602, and a computer program 603, such as a serial number fixed program, stored in the memory 602 and operable on the processor 601. The processor 601 executes the computer program 603 to implement the steps in the serial number fixing method embodiments, such as the steps S11 to S15 shown in fig. 1. Alternatively, the processor 601, when executing the computer program 603, implements the functions of each module/unit in the above-described apparatus embodiments, for example, the functions of the device object creating unit 301, the registry key reading unit 302, and the serial number configuring unit 303 shown in fig. 3.
The computer program 603 may be partitioned into one or more modules/units that are stored in the memory 602 and executed by the processor 601 to complete the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 603 in the terminal device 600. For example, the computer program 603 may be partitioned into a synchronization module, a summarization module, an acquisition module, a return module (a module in a virtual device).
The terminal device 600 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 601, a memory 602. Those skilled in the art will appreciate that fig. 4 is merely an example of a terminal device 600 and does not constitute a limitation of terminal device 600 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 601 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 602 may be an internal storage unit of the terminal device 600, such as a hard disk or a memory of the terminal device 600. The memory 602 may also be an external storage device of the terminal device 600, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 600. Further, the memory 602 may also include both an internal storage unit and an external storage device of the terminal device 600. The memory 602 is used for storing the computer programs and other programs and data required by the terminal device. The memory 602 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (9)

1. A method of fixing serial port numbers, comprising:
acquiring equipment access information, and creating a corresponding equipment object according to the equipment access information;
acquiring a user setting registry key corresponding to the equipment object; the user sets the registry key as a pre-stored registry key;
when the fixed serial port number needs to be set for the equipment object according to the user setting registry key, reading the fixed serial port number in the user setting registry key;
establishing a corresponding symbolic link for the equipment object according to the fixed serial port number and configuring access information;
the user setting registry key comprises a first key name and a second key name;
the first key name is used for indicating whether the serial port number of the equipment object is fixedly set;
the second key name is used for storing a fixed serial port number of the equipment object;
correspondingly, when it is determined that the fixed serial port number is set for the device object according to the user-set registry key, reading the fixed serial port number in the user-set registry key, including:
reading a first key name in the user setting registry key;
judging whether a fixed serial port number needs to be set for the equipment object or not according to the first key name;
and when the fixed serial port number needs to be set for the equipment object according to the first key name, reading a second key name in the user setting registry key, and taking the second key name as the fixed serial port number.
2. The method for fixing serial port number according to claim 1, wherein the establishing of the corresponding symbolic link for the device object and the configuration of the access information according to the fixed serial port number comprises:
updating the hardware key of the equipment object according to the fixed serial port number;
writing the fixed serial port number into a serial port equipment mapping registry table;
establishing a symbolic link corresponding to the equipment object according to the fixed serial port number;
and updating the equipment friendly name of the equipment object according to the fixed serial port number.
3. The method of fixing a serial number as recited in claim 2, wherein said updating the device-friendly name of the device object according to the fixed serial number comprises:
creating a temporary thread, and acquiring an equipment instance path of the equipment object according to the temporary thread;
reading a first device friendly name of the device object through the temporary thread according to the device instance path;
updating the serial port number in the first equipment friendly name through the temporary thread and according to the fixed serial port number to generate a corresponding second equipment friendly name;
updating the device friendly name sub-key under the device instance path through the temporary thread and according to the second device friendly name;
the temporary thread is terminated.
4. The method of fixing a serial number of claim 1, wherein after the obtaining of the user-set registry key corresponding to the device object, the method of fixing a serial number further comprises:
and updating the equipment extension data structure of the equipment object according to the user-set registry key.
5. The method of fixing a serial number of claim 4, wherein the device extension data structure includes a first variable and a second variable;
the first variable is used for indicating whether the serial port number of the equipment object is fixedly set;
the second variable is used for storing a fixed serial number of the device object.
6. The method of fixing a serial number as recited in claim 5, wherein said updating the device extension data structure of the device object according to the user setup registry key comprises:
writing a first key name in the user setting registry key into a first variable in the equipment extension data structure;
and writing a second key name in the user setting registry key into a second variable in the equipment extension data structure.
7. A terminal device, comprising:
the device object creating unit is used for acquiring device access information and creating a corresponding device object according to the device access information;
a registry key reading unit, configured to obtain a user-set registry key corresponding to the device object; the user sets the registry key as a pre-stored registry key; when determining that a fixed serial port number is set for the device object according to the user-set registry key, the registry key reading unit is further configured to read the fixed serial port number in the user-set registry key, where the user-set registry key includes a first key name and a second key name, the first key name is used to indicate whether the serial port number of the device object is fixedly set, and the second key name is used to store the fixed serial port number of the device object; correspondingly, when it is determined that the fixed serial port number is set for the device object according to the user-set registry key, reading the fixed serial port number in the user-set registry key, including: reading a first key name in the user setting registry key, judging whether a fixed serial port number needs to be set for the equipment object according to the first key name, reading a second key name in the user setting registry key when the fixed serial port number needs to be set for the equipment object according to the first key name, and taking the second key name as the fixed serial port number;
and the serial port number configuration unit is used for establishing a corresponding symbol link for the equipment object according to the fixed serial port number and configuring access information.
8. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN201910460214.XA 2019-05-30 2019-05-30 Method for fixing serial port number, terminal equipment and storage medium Active CN110244983B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910460214.XA CN110244983B (en) 2019-05-30 2019-05-30 Method for fixing serial port number, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910460214.XA CN110244983B (en) 2019-05-30 2019-05-30 Method for fixing serial port number, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110244983A CN110244983A (en) 2019-09-17
CN110244983B true CN110244983B (en) 2022-04-12

Family

ID=67885461

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910460214.XA Active CN110244983B (en) 2019-05-30 2019-05-30 Method for fixing serial port number, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110244983B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110795378B (en) * 2019-09-20 2023-03-21 深圳震有科技股份有限公司 Equipment number distribution method of serial equipment, intelligent terminal and storage medium
CN111562436B (en) * 2020-07-15 2020-11-03 南方电网数字电网研究院有限公司 Equipment driving method and device of double-core intelligent electric meter
CN114673819A (en) * 2020-12-24 2022-06-28 金卡智能集团股份有限公司 Multi-valve self-adaption method and system and gas meter
CN112596818B (en) * 2020-12-30 2023-12-05 上海众源网络有限公司 Application program control method, system and device
CN113965917B (en) * 2021-10-19 2024-04-02 深圳市元征科技股份有限公司 Communication method, device and terminal equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281474A (en) * 2008-05-06 2008-10-08 北京握奇数据系统有限公司 Method and apparatus for opening appoint terminal port USB equipment
CN102394942A (en) * 2011-08-08 2012-03-28 北京登合科技有限公司 Method for automatically installing bluetooth serial port equipment
CN102567268A (en) * 2010-12-31 2012-07-11 重庆重邮信科通信技术有限公司 Detection method for USB to virtual serial port/MODEM
CN106371841A (en) * 2016-08-31 2017-02-01 福建联迪商用设备有限公司 Management method of ADB (Android) devices and system thereof
CN106708762A (en) * 2015-11-18 2017-05-24 厦门雅迅网络股份有限公司 Unified management system and method for serial devices in LINUX
CN106919836A (en) * 2015-12-28 2017-07-04 阿里巴巴集团控股有限公司 The port detecting method and device of application
CN107967229A (en) * 2017-12-22 2018-04-27 安徽博微长安电子有限公司 A kind of serial ports automatic identifying method, system and computer-readable recording medium
CN109597779A (en) * 2018-11-21 2019-04-09 Oppo(重庆)智能科技有限公司 A kind of serial-port inquiring method and equipment and computer storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281474A (en) * 2008-05-06 2008-10-08 北京握奇数据系统有限公司 Method and apparatus for opening appoint terminal port USB equipment
CN102567268A (en) * 2010-12-31 2012-07-11 重庆重邮信科通信技术有限公司 Detection method for USB to virtual serial port/MODEM
CN102394942A (en) * 2011-08-08 2012-03-28 北京登合科技有限公司 Method for automatically installing bluetooth serial port equipment
CN106708762A (en) * 2015-11-18 2017-05-24 厦门雅迅网络股份有限公司 Unified management system and method for serial devices in LINUX
CN106919836A (en) * 2015-12-28 2017-07-04 阿里巴巴集团控股有限公司 The port detecting method and device of application
CN106371841A (en) * 2016-08-31 2017-02-01 福建联迪商用设备有限公司 Management method of ADB (Android) devices and system thereof
CN107967229A (en) * 2017-12-22 2018-04-27 安徽博微长安电子有限公司 A kind of serial ports automatic identifying method, system and computer-readable recording medium
CN109597779A (en) * 2018-11-21 2019-04-09 Oppo(重庆)智能科技有限公司 A kind of serial-port inquiring method and equipment and computer storage medium

Also Published As

Publication number Publication date
CN110244983A (en) 2019-09-17

Similar Documents

Publication Publication Date Title
CN110244983B (en) Method for fixing serial port number, terminal equipment and storage medium
US7590835B1 (en) Dynamically updating a computer system firmware image
US6487608B2 (en) Method for automatically configuring network interface card and capable of randomizing a media access controller address of the network interface card
US7577830B2 (en) Peripheral device with hardware linked list
US8762695B2 (en) Computing device and method for registering identification information of network interface card in operating system
US20150356049A1 (en) Assigning processors to memory mapped configuration
CN106796521B (en) API version control independent of product release
CN113703859A (en) Dynamic link library injection method, device, equipment and storage medium
US8386659B2 (en) Configuration adaptation layer for mapping I/O device resources
US7178014B2 (en) Method and apparatus for using a memory region to pass parameters between a run time environment and SMM handler
CN111752623B (en) Display configuration method, device, electronic equipment and readable storage medium
CN112306472A (en) Program interface parameter transmission method, system and related equipment
WO2023121815A1 (en) Dynamic provisioning of pcie devices at run time for bare metal servers
CN115878327A (en) Bus reservation method, device, server, electronic equipment and storage medium
CN112492064B (en) Multi-network-port MAC address allocation method of embedded equipment and terminal
TWI411921B (en) Electronic systems, computer-readable storage medium and methods for interconnecting peripheral devices and electronic systems
US6792610B2 (en) Attaching a device driver to multiple logical devices of one physical device
CN104301297A (en) Packet generating indicaiton instruction and/or partial execution result sending the instruction
CN113760810A (en) Information processing method, information processing device, equipment and storage medium
CN108196848B (en) Interface embedded display method and device, user terminal and readable storage medium
CN111813454A (en) Electronic device, startup picture display method and computer readable storage medium
CN110780920B (en) Data processing method, device, client and medium
CN113608791A (en) Program operation control method, terminal device, and computer-readable storage medium
CN118151860A (en) Method and device for determining hard disk identifier of virtual hard disk, computer equipment and storage medium
CN117707579A (en) Program upgrading method, system, terminal equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant