CN109101281A - A kind of general hot plug detection method - Google Patents
A kind of general hot plug detection method Download PDFInfo
- Publication number
- CN109101281A CN109101281A CN201810749691.3A CN201810749691A CN109101281A CN 109101281 A CN109101281 A CN 109101281A CN 201810749691 A CN201810749691 A CN 201810749691A CN 109101281 A CN109101281 A CN 109101281A
- Authority
- CN
- China
- Prior art keywords
- hot plug
- message
- service routine
- equipment
- main equipment
- 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.)
- Granted
Links
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
Abstract
The present invention relates to a kind of general hot plug detection methods, it is by realizing a hot plug message caching driving in main equipment inner nuclear layer, for generating the device node read and write for multi-user in client layer, and the hot plug message of Linux system is monitored by realizing a hot plug service routine in main equipment client layer;When hot plug service routine listens to hot plug message, which can be written into the device node that hot plug message caching generates, and user can read device node by multiple applications, thus obtain hot plug events.Therefore, the present invention efficiently solves the problems, such as that multi-user uses and the problem of hot plug information drop-out.
Description
Technical field
The present invention relates to a kind of Linux embedded system technology fields, and in particular to a kind of general hot plug detection side
Method.
Background technique
In linux system, generally obtained by Netlink mechanism using the plug message for obtaining peripheral hardware.But it has
It has the disadvantage that
One, each application obtains plug message and requires coding realization Netlink mechanism, this partial code is relatively tediously long, belongs to
Wheel is made in repetition;
Two, when the unexpected collapse of application is restarted or multi-user is not to open simultaneously, plug message can be lost;
Three, it can not know the peripheral hardware plug message of remote system.
Summary of the invention
The present invention provides a kind of general hot plug detection method, solves information drop-out by the method that message caches and asks
Topic.
To achieve the above object, the technical solution adopted by the present invention is that:
A kind of general hot plug detection method, the detection method realize a hot plug message caching in main equipment inner nuclear layer
Driving, for generating a device node for multi-user's read-write;Realize that a hot plug services journey in primary device application layer
Sequence, for monitoring the hot plug message of linux system;The detection method is specific as follows:
The hot plug service routine of main equipment monitors the hot plug message of linux system by netlink socket mechanism, works as heat
When plug service routine listens to the hot plug message of main equipment, hot plug message transformation is specifically disappeared according to identification protocol
Cease format;
The hot plug service routine of main equipment gives birth to the hot plug message write-in hot plug message caching driving of specific message format
At device node in;
The device node that the caching driving of hot plug message generates is read by the application in the application layer of main equipment, acquisition is buffered in
Hot plug message in device node, and the hot plug message is parsed according to identification protocol, obtain hot plug events.
The main equipment is connected with from equipment, a hot plug service routine is being realized from the application layer of equipment, for supervising
The hot plug message of equipment is accepted, and the hot plug message listened to is sent in the hot plug service routine of main equipment;
It is specific as follows:
The hot plug from the linux system of equipment is monitored by netlink socket mechanism from the hot plug service routine of equipment
Message, when listening to hot plug message, according to identification protocol by hot plug message transformation be specific message format;
The hot plug message of specific message format is sent to the hot plug service routine of main equipment from equipment by network, master sets
The hot plug type of message that standby hot plug service routine will receive adds remote device identification, then message write-in heat is inserted
It pulls out in the device node that message caching driving generates;
Device node is read by the application on primary device application layer, obtains the hot plug message being buffered in device node, and
The hot plug message is parsed according to identification protocol, obtains the hot plug events of remote system.
The specific message format is { action, port, type, major, minor }, wherein action indicates to insert
Enter, pull action;The equipment which port port indicates;Type indicates the type of equipment, and major indicates major device number;
Minor indicates secondary device number.
The hot plug message caching is driven to USB plug message caching driving, and the hot plug service routine is inserted for USB
Pull out service routine.
After adopting the above scheme, the present invention is by realizing the caching driving of hot plug message in inner nuclear layer, be used to
Family layer generates the device node read and write for multi-user, and is monitored by realizing a hot plug service routine in client layer
The hot plug message of linux system;When hot plug service routine listens to hot plug message, which can be written into hot plug
In the device node that message caching generates, user can read device node by multiple applications, thus obtain hot plug events.
When collapse, which occurs, in the application of main equipment restarts, the hot plug message of main equipment is still stored in setting for hot plug message caching generation
Slave node.Therefore, the present invention efficiently solves the problems, such as that multi-user uses and the problem of hot plug information drop-out.
In addition, the present invention is in the application layer from equipment by realizing a hot plug service routine, for monitoring from setting
Standby hot plug message, and send the message in the hot plug service routine of main equipment, the hot plug of main equipment services journey
Sequence by this from the hot plug message of equipment handled after deposit hot plug message caching driving generate device node in, user
Device node can be read by multiple applications, hot plug events thus be obtained, to know the hot plug thing of remote system
Part.
Detailed description of the invention
Fig. 1 is the functional block diagram of a specific embodiment of the invention;
Fig. 2 is the functional block diagram of another specific embodiment of the present invention.
Specific embodiment
As shown in Figure 1, present invention discloses a kind of general hot plug detection methods, in the inner nuclear layer of main equipment
(Kernel space) realizes a hot plug message caching driving, such as USB plug message caching driving, for generating one
For the device node of multi-user's read-write;A hot plug service routine, example are realized at primary device application layer (User space)
If USB plugs service routine, for monitoring the hot plug message of linux system.This method is specific as follows:
The hot plug service routine of main equipment monitors the hot plug message of linux system by netlink socket mechanism, works as heat
When plug service routine listens to the hot plug message of main equipment, hot plug message transformation is specifically disappeared according to identification protocol
Format is ceased, i.e., { action, port, type, major, minor }, wherein action indicates insertion, pull action;Port is indicated
The equipment of which port;Type indicates the type of equipment, and major indicates major device number;Minor indicates secondary device number.
The hot plug service routine of main equipment drives the hot plug message write-in hot plug message caching of specific message format
In the dynamic device node generated.
User by application in the application layer of main equipment (as using A, using B, using C) read device node, acquisition
The hot plug message being buffered in device node, and the hot plug message is parsed according to identification protocol, obtain hot plug
Event.
As shown in Fig. 2, main equipment is also connected with from equipment, in order to know that remote system disappears from the hot plug of equipment
Breath can realize a hot plug service routine from the application layer of equipment, for monitoring the hot plug message from equipment, and will
Its hot plug message listened to is sent in the hot plug service routine of main equipment.
The heat from the linux system of equipment is monitored by netlink socket mechanism from the hot plug service routine of equipment
Plug message, when listening to hot plug message, according to identification protocol by hot plug message transformation be specific message format,
That is { action, port, type, major, minor }, wherein action indicates insertion, pull action;It is a which port indicates
The equipment of port;Type indicates the type of equipment, and major indicates major device number;Minor indicates secondary device number.It will be special from equipment
The hot plug message for determining message format is sent to the hot plug service routine of main equipment, the hot plug service of main equipment by network
The hot plug type of message received is added remote device identification by program, then these message write-in hot plug message caching is driven
In the dynamic device node generated.User by application on primary device application layer (as using A, using B, using C) reading equipment
Node, the available hot plug message being buffered in device node, and the hot plug message is solved according to identification protocol
Analysis, obtains the hot plug events of remote system.
In specific message format, type is a signless integer data, for indicating the type of peripheral hardware, in total
There is 32bit size, highest order is that 0 expression is the machine message, is the message of remote system for 1 expression;Low 31bit indicates specific
Device type.For example the type of USB flash disk is 0x1, the type of mouse is 0x2, and the type of bluetooth is 0x101.If highest order is 1,
So 0x80000001 indicates that the USB flash disk of remote system, 0x80000002 indicate that the mouse of remote system, 0x80000101 indicate remote
The bluetooth of journey system.
It is of the invention it is critical that the present invention is used to by realizing a hot plug message caching driving in inner nuclear layer
Client layer generates the device node read and write for multi-user, and is monitored by realizing a hot plug service routine in client layer
The hot plug message of linux system;When hot plug service routine listens to hot plug message, which can be written into hot plug
In the device node that message caching generates, user can read device node by multiple applications, thus obtain hot plug events.
When collapse, which occurs, in the application of main equipment restarts, the hot plug message of main equipment is still stored in setting for hot plug message caching generation
Slave node.Therefore, the present invention efficiently solves the problems, such as that multi-user uses and the problem of hot plug information drop-out.
In addition, the present invention is in the application layer from equipment by realizing a hot plug service routine, for monitoring from setting
Standby hot plug message, and send the message in the hot plug service routine of main equipment, the hot plug of main equipment services journey
Sequence by this from the hot plug message of equipment handled after deposit hot plug message caching driving generate device node in, user
Device node can be read by multiple applications, hot plug events thus be obtained, to know the hot plug thing of remote system
Part.
The above is only the embodiment of the present invention, is not intended to limit the scope of the present invention, therefore all
Any subtle modifications, equivalent variations and modifications to the above embodiments according to the technical essence of the invention still fall within this
In the range of inventive technique scheme.
Claims (4)
1. a kind of general hot plug detection method, it is characterised in that: the detection method realizes one in main equipment inner nuclear layer
Hot plug message caching driving, for generating a device node for multi-user's read-write;One is realized in primary device application layer
A hot plug service routine, for monitoring the hot plug message of linux system;The detection method is specific as follows:
The hot plug service routine of main equipment monitors the hot plug message of linux system by netlink socket mechanism, works as heat
When plug service routine listens to the hot plug message of main equipment, hot plug message transformation is specifically disappeared according to identification protocol
Cease format;
The hot plug service routine of main equipment gives birth to the hot plug message write-in hot plug message caching driving of specific message format
At device node in;
The device node that the caching driving of hot plug message generates is read by the application in the application layer of main equipment, acquisition is buffered in
Hot plug message in device node, and the hot plug message is parsed according to identification protocol, obtain hot plug events.
2. the general hot plug detection method of one kind according to claim 1, it is characterised in that: the main equipment is connected with
From equipment, a hot plug service routine is being realized from the application layer of equipment, for monitoring the hot plug message from equipment, and will
Its hot plug message listened to is sent in the hot plug service routine of main equipment;It is specific as follows:
The hot plug from the linux system of equipment is monitored by netlink socket mechanism from the hot plug service routine of equipment
Message, when listening to hot plug message, according to identification protocol by hot plug message transformation be specific message format;
The hot plug message of specific message format is sent to the hot plug service routine of main equipment from equipment by network, master sets
The hot plug type of message that standby hot plug service routine will receive adds remote device identification, then message write-in heat is inserted
It pulls out in the device node that message caching driving generates;
Device node is read by the application on primary device application layer, obtains the hot plug message being buffered in device node, and
The hot plug message is parsed according to identification protocol, obtains the hot plug events of remote system.
3. the general hot plug detection method of one kind according to claim 1 or 2, it is characterised in that: described specifically to disappear
Ceasing format is { action, port, type, major, minor }, wherein action indicates insertion, pull action;Port is indicated
The equipment of which port;Type indicates the type of equipment, and major indicates major device number;Minor indicates secondary device number.
4. the general hot plug detection method of one kind according to claim 1 or 2, it is characterised in that: the hot plug disappears
Breath caching is driven to USB plug message caching driving, and the hot plug service routine is that USB plugs service routine.
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 true CN109101281A (en) | 2018-12-28 |
CN109101281B 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) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110750306A (en) * | 2019-10-18 | 2020-02-04 | 厦门亿联网络技术股份有限公司 | Method and system for uniformly identifying hot plug of multi-type equipment |
CN111881074A (en) * | 2019-05-02 | 2020-11-03 | 纬创资通股份有限公司 | Electronic system, host device and control method |
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的使用方法", 《博客园网站》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111881074A (en) * | 2019-05-02 | 2020-11-03 | 纬创资通股份有限公司 | Electronic system, host device and control method |
CN111881074B (en) * | 2019-05-02 | 2021-11-09 | 纬创资通股份有限公司 | Electronic system, host device and control method |
CN110750306A (en) * | 2019-10-18 | 2020-02-04 | 厦门亿联网络技术股份有限公司 | Method and system for uniformly identifying hot plug of multi-type equipment |
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 |
Also Published As
Publication number | Publication date |
---|---|
CN109101281B (en) | 2021-07-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109101281A (en) | A kind of general hot plug detection method | |
CN106936441B (en) | Data compression method and device | |
WO2017049757A1 (en) | Time sequence data storage method and apparatus | |
CN111831748B (en) | Data synchronization method, device and storage medium | |
CN109189749B (en) | File synchronization method and terminal equipment | |
US20160196226A1 (en) | Method and Apparatuses for Monitoring System Bus | |
WO2022142685A1 (en) | Infection probability prediction method and apparatus for infectious disease, storage medium and electronic device | |
JP5986602B2 (en) | Method, apparatus, terminal and server for synchronizing an exact copy of a terminal data set | |
CN109194736A (en) | Message De-weight method, device, electronic equipment, medium and unmanned vehicle | |
CN104572416A (en) | Operation and maintenance data processing method and device | |
CN112448969A (en) | Link tracking method, device, system, equipment and readable storage medium | |
CN109254922A (en) | A kind of automated testing method and device of server B MC Redfish function | |
WO2019183791A1 (en) | Method and device for transmitting synchronization signal block, and storage medium | |
US8497779B1 (en) | Ensuring power source redundancy | |
CN108806151A (en) | Monitoring alarm method, device, server and storage medium | |
CN104881337A (en) | Method for expanding novel functions of SCSI (small computer system interface) cases | |
CN108874441A (en) | A kind of board configuration method, device, server and storage medium | |
CN103853680A (en) | Bus-signal monitoring device and method | |
EP4300314A3 (en) | Data backup method, apparatus and system | |
CN109347899A (en) | The method of daily record data is written in distributed memory system | |
CN111913861A (en) | Performance test method, device, equipment and medium of Internet of things system | |
US20140325285A1 (en) | Serial attached scsi expander and method for debugging faults thereof | |
WO2021189283A1 (en) | Method and device for data processing, electronic device, and storage medium | |
CN107704201B (en) | Data storage processing method and device | |
CN109726181B (en) | Data processing method and data processing device |
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 |