CN109101281B - Universal hot plug detection method - Google Patents
Universal hot plug detection method Download PDFInfo
- Publication number
- CN109101281B CN109101281B CN201810749691.3A CN201810749691A CN109101281B CN 109101281 B CN109101281 B CN 109101281B CN 201810749691 A CN201810749691 A CN 201810749691A CN 109101281 B CN109101281 B CN 109101281B
- Authority
- CN
- China
- Prior art keywords
- hot plug
- message
- service program
- information
- hot
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4411—Configuring for operating with peripheral devices; Loading of device drivers
- G06F9/4413—Plug-and-play [PnP]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4063—Device-to-bus coupling
- G06F13/4068—Electrical coupling
- G06F13/4081—Live connection to bus, e.g. hot-plugging
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
- H04L41/0803—Configuration setting
- H04L41/0806—Configuration setting for initial configuration or provisioning, e.g. plug-and-play
- H04L41/0809—Plug-and-play configuration
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention relates to a general hot plug detection method, which is used for generating equipment nodes for reading and writing of multiple users on a user layer by realizing a hot plug message cache drive on a kernel layer of main equipment, and monitoring hot plug messages of a linux system by realizing a hot plug service program on a user layer of the main equipment; when the hot plug service program monitors the hot plug message, the message is written into a device node generated by the hot plug message cache, and a user can read the device node through a plurality of applications, so that a hot plug event is acquired. Therefore, the invention effectively solves the problems of multi-user use and hot plug message loss.
Description
Technical Field
The invention relates to the technical field of Linux embedded systems, in particular to a universal hot plug detection method.
Background
In the Linux system, the application acquires the plug message of the peripheral device generally through a Netlink mechanism. But it has the following disadvantages:
firstly, each application acquires a plugging message and needs to be coded to realize a Netlink mechanism, and the part of codes are relatively long and belong to repeated wheel manufacturing;
secondly, when the application is unexpectedly crashed and restarted or multiple users are not simultaneously opened, the plugging message is lost;
and thirdly, the peripheral plugging and unplugging message of the remote system cannot be acquired.
Disclosure of Invention
The invention provides a general hot plug detection method, which solves the problem of message loss through a message caching method.
In order to achieve the purpose, the invention adopts the technical scheme that:
a universal hot plug detection method, the said detection method realizes a hot plug message buffer memory drive in the kernel layer of the main apparatus, used for producing an apparatus node for multiuser to read and write; implementing a hot plug service program on the application layer of the main equipment, which is used for monitoring hot plug information of the Linux system; the detection method specifically comprises the following steps:
the hot plug service program of the main equipment monitors hot plug information of a Linux system through a netlink socket system, and converts the hot plug information into a specific information format according to an identification protocol when the hot plug service program monitors the hot plug information of the main equipment;
the hot plug service program of the main equipment writes the hot plug message with a specific message format into an equipment node generated by the hot plug message cache driver;
and reading the equipment node generated by the hot plug message cache drive through the application on the application layer of the main equipment, acquiring the hot plug message cached in the equipment node, analyzing the hot plug message according to the identification protocol, and acquiring a hot plug event.
The master device is connected with the slave device, a hot plug service program is realized on an application layer of the slave device, and the hot plug service program is used for monitoring hot plug messages of the slave device and sending the monitored hot plug messages to the hot plug service program of the master device; the method comprises the following specific steps:
the hot plug service program of the slave device listens to the hot plug information of a Linux system of the slave device through a netlink socket system, and when the hot plug information is monitored, the hot plug information is converted into a specific information format according to an identification protocol;
the slave device sends the hot plug message with a specific message format to the hot plug service program of the master device through the network, the hot plug service program of the master device adds the type of the received hot plug message to the identification of the remote device, and then writes the message into a device node generated by the cache drive of the hot plug message;
and reading the equipment node through the application on the application layer of the main equipment, acquiring the hot plug message cached in the equipment node, analyzing the hot plug message according to the identification protocol, and acquiring the hot plug event of the remote system.
The specific message format is { action, port, type, major, minor }, wherein the action represents the insertion and extraction actions; port represents the device of the second port; type represents the type of device, major represents the master device number; minor denotes the secondary device number.
The hot plug message cache driver is a USB plug message cache driver, and the hot plug service program is a USB plug service program.
After the scheme is adopted, the hot plug message cache driving is realized at the kernel layer, the device node which can be read and written by multiple users is generated at the user layer, and the hot plug message of the Linux system is monitored by realizing a hot plug service program at the user layer; when the hot plug service program monitors the hot plug message, the message is written into a device node generated by the hot plug message cache, and a user can read the device node through a plurality of applications, so that a hot plug event is acquired. When the application of the main device is crashed and restarted, the hot plug message of the main device is still stored in the device node generated by the hot plug message cache. Therefore, the invention effectively solves the problems of multi-user use and hot plug message loss.
In addition, the invention realizes a hot plug service program on the application layer of the slave device, which is used for monitoring the hot plug message of the slave device and sending the message to the hot plug service program of the master device, the hot plug service program of the master device processes the hot plug message of the slave device and then stores the processed message into the device node generated by the hot plug message cache driver, and a user can read the device node through a plurality of applications, thereby obtaining the hot plug event and knowing the hot plug event of the remote system.
Drawings
FIG. 1 is a schematic block diagram of an embodiment of the present invention;
fig. 2 is a schematic block diagram of another embodiment of the present invention.
Detailed Description
As shown in fig. 1, the present invention discloses a general hot plug detection method, which implements a hot plug message cache driver, such as a USB hot plug message cache driver, at a Kernel layer (Kernel space) of a host device, and is used to generate a device node for reading and writing by multiple users; a hot plug service program, such as a USB plug service program, is implemented in a host application layer (User space) and is used for monitoring hot plug messages of a Linux system. The method comprises the following specific steps:
the method comprises the steps that a hot plug service program of a main device monitors hot plug information of a Linux system through a netlink socket character mechanism, and when the hot plug service program monitors the hot plug information of the main device, the hot plug information is converted into a specific information format according to an identification protocol, namely { action, port, type, major, minor }, wherein the action represents the inserting and extracting actions; port represents the device of the second port; type represents the type of device, major represents the master device number; minor denotes the secondary device number.
And the hot plug service program of the main device writes the hot plug message with the specific message format into the device node generated by the hot plug message cache driver.
The user reads the device node through the application (such as application A, application B, and application C) on the application layer of the main device, obtains the hot plug message cached in the device node, and analyzes the hot plug message according to the identification protocol to obtain the hot plug event.
As shown in fig. 2, the master device is further connected to a slave device, and in order to obtain a hot plug message of a remote system, that is, the slave device, a hot plug service program may be implemented at an application layer of the slave device, and configured to listen to the hot plug message of the slave device and send the listened hot plug message to the hot plug service program of the master device.
Monitoring the hot plug message of a Linux system of the slave equipment by a hot plug service program of the slave equipment through a netlink socket machine system, and converting the hot plug message into a specific message format (action, port, type, major, minor) according to an identification protocol when the hot plug message is monitored, wherein the action represents the inserting and extracting actions; port represents the device of the second port; type represents the type of device, major represents the master device number; minor denotes the secondary device number. The slave device sends the hot plug message with a specific message format to the hot plug service program of the master device through the network, the hot plug service program of the master device adds the received hot plug message type to the remote device identification, and then writes the messages into the device node generated by the hot plug message cache driver. The user reads the device node through the application (such as application a, application B, and application C) on the application layer of the main device, may obtain the hot plug message cached in the device node, and parse the hot plug message according to the identification protocol, to obtain the hot plug event of the remote system.
In a specific message format, type is unsigned integer data used for representing the type of the peripheral equipment, the size of the peripheral equipment is 32 bits in total, the highest bit is 0 to represent that the peripheral equipment is a local message, and the highest bit is 1 to represent that the peripheral equipment is a remote system message; the low 31bit indicates a specific device type. For example, the type of the U disk is 0x1, the type of the mouse is 0x2, and the type of the Bluetooth is 0x 101. If the highest bit is 1, 0x80000001 represents the USB flash disk of the remote system, 0x80000002 represents the mouse of the remote system, and 0x80000101 represents the Bluetooth of the remote system.
The key point of the invention is that the invention realizes a hot plug message buffer drive in the kernel layer to generate the equipment node for multi-user reading and writing in the user layer, and realizes a hot plug service program in the user layer to monitor the hot plug message of the Linux system; when the hot plug service program monitors the hot plug message, the message is written into a device node generated by the hot plug message cache, and a user can read the device node through a plurality of applications, so that a hot plug event is acquired. When the application of the main device is crashed and restarted, the hot plug message of the main device is still stored in the device node generated by the hot plug message cache. Therefore, the invention effectively solves the problems of multi-user use and hot plug message loss.
In addition, the invention realizes a hot plug service program on the application layer of the slave device, which is used for monitoring the hot plug message of the slave device and sending the message to the hot plug service program of the master device, the hot plug service program of the master device processes the hot plug message of the slave device and then stores the processed message into the device node generated by the hot plug message cache driver, and a user can read the device node through a plurality of applications, thereby obtaining the hot plug event and knowing the hot plug event of the remote system.
The above description is only exemplary of the present invention and is not intended to limit the technical scope of the present invention, so that any minor modifications, equivalent changes and modifications made to the above exemplary embodiments according to the technical spirit of the present invention are within the technical scope of the present invention.
Claims (3)
1. A general hot plug detection method is characterized in that: the detection method realizes a hot plug message cache drive in a kernel layer of the main equipment and is used for generating an equipment node for multi-user reading and writing; implementing a hot plug service program on the application layer of the main equipment, which is used for monitoring hot plug information of the Linux system; the detection method specifically comprises the following steps:
the hot plug service program of the main equipment monitors hot plug information of a Linux system through a netlink socket system, and converts the hot plug information into a specific information format according to an identification protocol when the hot plug service program monitors the hot plug information of the main equipment;
the hot plug service program of the main equipment writes the hot plug message with a specific message format into an equipment node generated by the hot plug message cache driver;
reading an equipment node generated by a hot plug message cache drive through an application on an application layer of the main equipment, acquiring a hot plug message cached in the equipment node, analyzing the hot plug message according to an identification protocol, and acquiring a hot plug event; the master device is connected with the slave device, a hot plug service program is realized in an application layer of the slave device, and the hot plug service program is used for monitoring hot plug messages of the slave device and sending the monitored hot plug messages to the hot plug service program of the master device; the method comprises the following specific steps:
the hot plug service program of the slave device listens to the hot plug information of a Linux system of the slave device through a netlink socket system, and when the hot plug information is monitored, the hot plug information is converted into a specific information format according to an identification protocol;
the slave device sends the hot plug message with a specific message format to the hot plug service program of the master device through the network, the hot plug service program of the master device adds the type of the received hot plug message to the identification of the remote device, and then writes the message into a device node generated by the cache drive of the hot plug message;
and reading the equipment node through the application on the application layer of the main equipment, acquiring the hot plug message cached in the equipment node, analyzing the hot plug message according to the identification protocol, and acquiring the hot plug event of the remote system.
2. A generic hot plug detection method according to claim 1, characterized in that: the specific message format is { action, port, type, major, minor }, wherein the action represents the insertion and extraction actions; port represents the device of the second port; type represents the type of device, major represents the master device number; minor denotes the secondary device number.
3. A generic hot plug detection method according to claim 1, characterized in that: the hot plug message cache driver is a USB plug message cache driver, and the hot plug service program is a USB plug service program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810749691.3A CN109101281B (en) | 2018-07-10 | 2018-07-10 | Universal hot plug detection method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810749691.3A CN109101281B (en) | 2018-07-10 | 2018-07-10 | Universal hot plug detection method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109101281A CN109101281A (en) | 2018-12-28 |
CN109101281B true CN109101281B (en) | 2021-07-02 |
Family
ID=64846034
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810749691.3A Active CN109101281B (en) | 2018-07-10 | 2018-07-10 | Universal hot plug detection method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109101281B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI710911B (en) * | 2019-05-02 | 2020-11-21 | 緯創資通股份有限公司 | Electronic system, host device and control method |
CN110750306B (en) * | 2019-10-18 | 2022-09-30 | 厦门亿联网络技术股份有限公司 | Method and system for uniformly identifying hot plug of multi-type equipment |
CN111913819A (en) * | 2020-08-07 | 2020-11-10 | 上海格尔安全科技有限公司 | RPC-based USBKEY access method |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102567667A (en) * | 2011-12-13 | 2012-07-11 | 中标软件有限公司 | Intelligent information equipment and operation system thereof |
US8522018B2 (en) * | 2006-08-18 | 2013-08-27 | Fujitsu Limited | Method and system for implementing a mobile trusted platform module |
CN103514030A (en) * | 2012-07-24 | 2014-01-15 | Tcl集团股份有限公司 | Event collecting and reporting system and method of Android system |
CN104038390A (en) * | 2014-06-24 | 2014-09-10 | 汪敏 | Linux server cluster unified peripheral event monitoring method based on netlink |
CN105893293A (en) * | 2014-12-18 | 2016-08-24 | 伊姆西公司 | System and method used for managing hot plug of peripheral component interface express device |
CN108228425A (en) * | 2017-12-29 | 2018-06-29 | 成都三零嘉微电子有限公司 | A kind of linux system implements the system for obtaining equipment hot swap information |
-
2018
- 2018-07-10 CN CN201810749691.3A patent/CN109101281B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8522018B2 (en) * | 2006-08-18 | 2013-08-27 | Fujitsu Limited | Method and system for implementing a mobile trusted platform module |
CN102567667A (en) * | 2011-12-13 | 2012-07-11 | 中标软件有限公司 | Intelligent information equipment and operation system thereof |
CN103514030A (en) * | 2012-07-24 | 2014-01-15 | Tcl集团股份有限公司 | Event collecting and reporting system and method of Android system |
CN104038390A (en) * | 2014-06-24 | 2014-09-10 | 汪敏 | Linux server cluster unified peripheral event monitoring method based on netlink |
CN105893293A (en) * | 2014-12-18 | 2016-08-24 | 伊姆西公司 | System and method used for managing hot plug of peripheral component interface express device |
CN108228425A (en) * | 2017-12-29 | 2018-06-29 | 成都三零嘉微电子有限公司 | A kind of linux system implements the system for obtaining equipment hot swap information |
Non-Patent Citations (1)
Title |
---|
linux热插拔之udev的使用方法;张同光;《博客园网站》;20161218;第1-3页 * |
Also Published As
Publication number | Publication date |
---|---|
CN109101281A (en) | 2018-12-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109101281B (en) | Universal hot plug detection method | |
US20200233909A1 (en) | System, method and computer program product for data transfer management | |
KR101745456B1 (en) | Ecu for transmitting large data in hil test environment, system including the same and method thereof | |
WO2017132797A1 (en) | Data arrangement method, storage apparatus, storage controller and storage array | |
CN106790612B (en) | Dynamic virtual camera mapping method and system | |
CN103534968A (en) | Encoding and decoding method and device for Ethernet physical layer | |
CN102073611A (en) | I2C bus control system and method | |
CN107517277B (en) | Method and device for realizing sanlock | |
US10437849B2 (en) | Method and apparatus for implementing storage of file in IP disk | |
CN112765055B (en) | Control unit of storage device | |
CN112764669B (en) | Hardware accelerator | |
CN113656364B (en) | Sensor data processing method, device and computer readable storage medium | |
CN103414769A (en) | Virtual machine thermal migration method and physical machine | |
CN105700986A (en) | Server system for monitoring operational information | |
TWI722514B (en) | Method for updating ic firmware | |
CN104639892B (en) | Video recording system and method and apparatus for processing image in main system | |
CN109992197B (en) | Data reading and writing method and device, electronic equipment and storage medium | |
CN116208574A (en) | Message processing method, device, electronic equipment and computer readable storage medium | |
JP5162686B2 (en) | Method for retrieving object from DM client and device management system related thereto | |
CN113377813B (en) | Global unique identification code generation method, device, system and computer readable medium | |
CN105631965B (en) | Vehicle-mounted WTB message accountings instrument | |
CN109726181B (en) | Data processing method and data processing device | |
CN110069422B (en) | Memory buffer recovery method based on MIPS multi-core processor | |
CN112905575A (en) | Data acquisition method, system, storage medium and electronic equipment | |
CN204331848U (en) | Vehicle-mounted WTB message accounting instrument |
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 |