CN115878213A - Dynamic loading method for Internet of things equipment driver - Google Patents

Dynamic loading method for Internet of things equipment driver Download PDF

Info

Publication number
CN115878213A
CN115878213A CN202211512667.0A CN202211512667A CN115878213A CN 115878213 A CN115878213 A CN 115878213A CN 202211512667 A CN202211512667 A CN 202211512667A CN 115878213 A CN115878213 A CN 115878213A
Authority
CN
China
Prior art keywords
file
drive
loading
internet
dynamic
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.)
Withdrawn
Application number
CN202211512667.0A
Other languages
Chinese (zh)
Inventor
王海
张影影
王剑宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Helio Network Technology Co ltd
Original Assignee
Suzhou Helio Network Technology 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 Suzhou Helio Network Technology Co ltd filed Critical Suzhou Helio Network Technology Co ltd
Priority to CN202211512667.0A priority Critical patent/CN115878213A/en
Publication of CN115878213A publication Critical patent/CN115878213A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention relates to the technical field of embedded application, and discloses a dynamic loading method for an Internet of things device driver, wherein the driver of the Internet of things device is decoupled from an application program, the application program is issued in an ELF file format, and the driver is issued in an SO file format; when a dynamic loading request is sent out, the dynamic loading of the driver is realized by using a dynamic link compiling method. The invention can realize dynamic loading of multiple devices in the scene of the Internet of things, and has stable loading operation and high efficiency.

Description

Dynamic loading method for equipment driver of Internet of things
Technical Field
The invention relates to the technical field of embedded application, in particular to a dynamic loading method for an internet of things device driver.
Background
In an application scene of the internet of things, a large number of sensing devices or IO control devices based on MODBUS-RTU/MODBUS-TCP protocols need to be subjected to butt joint development work. Under the condition determined by the embedded hardware platform, in order to meet different positioning and design requirements of products, the requirement that a sensor/IO controller supporting multiple manufacturers is designed on the same peripheral interface is required to be met. Meanwhile, in actual field application, a single internet of things device can be connected with at most two or three devices at the same time. In order to meet different adaptations, the docking drive of the sensor needs to be provided with a standard interface. However, in the existing technical solution, device drivers and applications are usually mixed in an individual program ELF file, and a device driver needs to be continuously added in the program file when a new device adaptation is subsequently performed, so that the ELF file is continuously increased, version iterations of the ELF file are frequent, and the loading speed and stability of the device driver are affected.
Disclosure of Invention
Therefore, the technical problem to be solved by the invention is to overcome the defects in the prior art, and provide a dynamic loading method for an internet of things device driver, which can realize dynamic loading of multiple devices in an internet of things scene, and has the advantages of stable loading operation and high efficiency.
In order to solve the technical problem, the invention provides a dynamic loading method for an internet of things device driver, which comprises the following steps:
decoupling a driver of the Internet of things device from an application program, wherein the application program is issued in an ELF file format, and the driver is issued in an SO file format;
when a dynamic loading request is sent out, the dynamic loading of the driver is realized by using a dynamic link compiling method.
In an embodiment of the present invention, the method for implementing dynamic loading of a driver using dynamic link compilation includes:
s1: establishing a drive loading linked list, running an application program, searching a drive SO file corresponding to the current dynamic loading request in a drive directory, and judging whether the corresponding drive SO file is in the drive loading linked list or not; if not, executing S2 in the drive loading linked list, and if not, executing S3 in the drive loading linked list;
s2: generating a loading request using the corresponding drive SO file, distributing a file descriptor, and adding the identifier of the loading request and the distributed file descriptor into the drive loading linked list;
s3: relocating the corresponding drive SO file according to the allocated file descriptor, and loading the corresponding drive SO file into an operating memory of the Internet of things equipment;
s4: and analyzing the binary segment address of the general IO interface in the corresponding drive SO file and the binary segment address of the drive equipment description structure body, returning the binary segment addresses to the application program, and dynamically loading the drive program in real time.
In an embodiment of the present invention, when a drive SO file corresponding to a current dynamic loading request does not exist in a drive directory, a docking device MODBUS instruction is packaged to generate a corresponding shared dynamic link library, and the shared dynamic link library is independently compiled to generate a drive SO file corresponding to a dynamic loading request.
In an embodiment of the present invention, when the corresponding driver SO file is loaded into the operating memory of the internet of things device, the internet of things device detecting system detects a new addition operation of the driver SO file and responds to a request of a dynamic link management list of an application program, and determines whether the driver SO file is already loaded into the dynamic link management list according to the representation of the driver SO file; and if the drive SO file is loaded, opening the dynamic link management list by using a system interface, loading the dynamic link management list into an operating memory, and adding the back-allocated handle into the dynamic link management list.
In an embodiment of the present invention, when the binary segment address of the general IO interface and the binary segment address of the driver device description structure in the corresponding driver SO file are analyzed and returned to the application program, the standard API of the driver load linked list is obtained through the returned handle and the specified connector name and returned to the API dynamic link management list of the application program.
In one embodiment of the present invention, the dynamic link management list includes: a drive file path pointer and a drive file descriptor,
the drive file path pointer is used for storing a path name character string of the drive SO file, and the drive file descriptor is used for representing the loading state of the drive SO file.
In an embodiment of the present invention, the table node driving the load linked list includes: registration identification, data reporting identification, sensor number, bus attribute pointer and sensor attribute pointer,
when a dynamic loading request is received, a newly generated node is used for storing information from a driver, the IO reads the address information of the binary segment of the interface and connects the newly generated node to the tail pointer of the driver loading linked list.
In an embodiment of the present invention, the structural attributes of the driver and the application include: name of driving device, number of supporting driving devices, number of all-in-one sensors, type of communication protocol, type of driving device,
the driving device name is used for describing the device name of the driving butt joint, the number of the supporting driving devices is used for describing the number of the same devices which are driven to be butt jointed simultaneously, the number of the all-in-one sensors is used for describing the specific number of the sensors on the butt joint device, the communication protocol type is used for describing the protocol type, and the driving device type is used for describing the device type of the driving butt joint.
In one embodiment of the invention, the application program provides two data transmission interfaces of MODBUS-TCP and MODBUS-RTU.
In an embodiment of the invention, when the dynamic loading of the driver is realized by using a dynamic link compiling method, the IO cache is realized by using a HASH table, a key value of the HASH table is composed of a mixed ID of a sensor node and an equipment ID of the internet of things, and a HASH address is generated by using a folding method.
Compared with the prior art, the technical scheme of the invention has the following advantages:
the method comprises the steps of decoupling a driver of the Internet of things device from an application program, respectively issuing the application program through an ELF file format and issuing the driver through an SO file format, and realizing dynamic loading of the driver by using a dynamic link compiling method on the basis; the dynamic loading of multiple devices in the scene of the Internet of things can be realized, and the loading operation is stable and efficient.
Drawings
In order that the present disclosure may be more readily and clearly understood, reference is now made to the following detailed description of the present disclosure taken in conjunction with the accompanying drawings, in which:
figure 1 is a schematic view of the framework of the invention,
FIG. 2 is a diagram illustrating the structure of a table node driving a load linked list according to an embodiment of the present invention,
FIG. 3 is a schematic diagram of structural attributes of a driver and an application in an embodiment of the present invention,
figure 4 is a schematic diagram of the structure of a table node dynamically linking management lists in an embodiment of the present invention,
fig. 5 is a schematic structural diagram of a HASH table used in the IO cache according to an embodiment of the present invention.
Detailed Description
The present invention is further described below in conjunction with the following figures and specific examples so that those skilled in the art may better understand the present invention and practice it, but the examples are not intended to limit the present invention.
Referring to fig. 1, the invention discloses a dynamic loading method for an internet of things device driver, which includes: decoupling a driver of the Internet of things device from an application program, wherein the application program is issued in an ELF file format, and the driver is issued in an SO file format; when a dynamic loading request is sent out, the dynamic loading of the driving program is realized by using a dynamic link compiling method.
The devices connected in the application scene of the internet of things are provided with a single sensor and an all-in-one sensor, so that in order to support heterogeneous multiple devices and composite external devices, the driving program and the application program in the invention are respectively filled and called according to the structural body attributes shown in fig. 3. The method specifically comprises the following steps: the device comprises a driving device name, a supporting driving device number, an all-in-one sensor number, a communication protocol type and a driving device type, wherein the driving device name is used for describing the device name of the driving butt joint, the supporting driving device number is used for describing the number of the same devices which are driven to be in butt joint simultaneously, the all-in-one sensor number is used for supporting the added attribute of the all-in-one sensor and describing the specific sensor number on the butt joint device, the communication protocol type is used for describing the protocol type and supporting two protocols of MODBUS-TCP and MODBUS-RTU, and the driving device type is used for describing the device type which is driven to be in butt joint, driving the device which supports to be in butt joint and only reading sensor devices and supporting reading and writing IO controllers.
The method for realizing dynamic loading of the driver by using dynamic link compilation comprises the following steps:
s1: establishing a drive loading linked list, running an application program and searching a drive SO file corresponding to the current dynamic loading request in a drive directory;
when a driving SO file corresponding to the current dynamic loading request does not exist in the driving directory, packaging the MODBUS instruction of the docking equipment to generate a corresponding shared dynamic link library, and independently compiling the shared dynamic link library to generate a driving SO file corresponding to the dynamic loading request; when a drive SO file corresponding to the current dynamic loading request exists in the drive directory, judging whether the corresponding drive SO file is in a drive loading linked list or not; and if the S2 is not executed in the drive loading linked list, and if the S3 is executed in the drive loading linked list.
The sensor value or IO state acquisition interface provided by the device driver needs polling calling of an application program to achieve the purpose of continuous acquisition. Therefore, the driving management method in the invention has the following modes: extracting and abstracting the attribute of the driver, designing a linked list corresponding to a driver operation function, namely a driver loading linked list, wherein the driver loading linked list is designed by using a single linked list, the members of the table nodes are shown in figure 2, and the table nodes of the driver loading linked list comprise: the method comprises the steps of registering identification, data reporting identification, sensor number, 485 bus attribute pointer and sensor attribute pointer, when a dynamic loading request is received, newly generating a node for storing information from a driver, reading binary segment address information of an interface by IO (input output) and connecting the node to a tail pointer of a driver loading linked list.
S2: and generating a loading request using the corresponding drive SO file, distributing a file descriptor, and adding the identifier of the loading request and the distributed file descriptor into a drive loading linked list.
S3: and relocating the corresponding drive SO file according to the allocated file descriptor, and loading the corresponding drive SO file into an operating memory of the Internet of things equipment.
The Internet of things equipment detection system detects the newly added operation of the driving SO file and responds to the request of the dynamic link management list of the application program, and whether the driving SO file is loaded into the dynamic link management list is judged according to the representation of the driving SO file; and if the drive SO file is loaded, opening the dynamic link management list by using a system interface, loading the dynamic link management list into an operating memory, and adding the back-allocated handle into the dynamic link management list.
When an application program runs, after the driver is detected to be led into a specified directory, a newly added device driver is loaded and returns a handle to enter a dynamic link management list, a device data acquisition thread performs polling on the dynamic link management list at the moment, and an API executes reading data to an IO cache. Loading and using inotify prototype realization provided by a LINUX system during operation, and designating a detection path through a file descriptor returned by the interface; two operation events, namely file adding and file removing, are mainly intercepted. The driver loading needs to be uniformly added to the dynamic link management list, so that the length of the name of the driver file is limited in the structure body in order to avoid resource waste; the dynamic link management list is implemented by using an array, the number of the driver devices loaded by a single network device in practical application is about 2 to 4, the array structure is shown in fig. 4, and the dynamic link management list comprises: the drive file path pointer is used for storing a path name character string of the drive SO file, and the drive file descriptor is distributed by a Linux system and used for representing the loading state of the drive SO file. On the embedded device, because the support quantity of the drive needs to be limited by system resources, the whole drive queue can be accommodated by a fixed structure array.
S4: and analyzing the binary segment address of the general IO interface and the binary segment address of the drive equipment description structure in the corresponding drive SO file and returning the binary segment addresses to the application program, and acquiring the standard API of the drive loading linked list through the returned handle and the specified connector name and returning the standard API to an API dynamic link management list of the application program. And uploading the corresponding drive SO file to the Internet of things equipment through a general FTP program, and automatically completing monitoring and loading operation during operation of the Internet of things equipment and dynamically loading the drive program in real time.
In this embodiment, the application provides two data transmission interfaces, namely MODBUS-TCP and MODBUS-RTU, to the driver callback, and the specific instruction is implemented by the corresponding device driver. The MODBUS-TCP communication protocol parameters need IP addresses, ports and slave addresses; the MODBUS-RTU communication protocol parameters only need slave addresses. The two protocol interfaces are both realized in an application program, and corresponding interface function pointers are assigned according to the described communication protocol type members returned by the drive file.
In this embodiment, when the dynamic link compiling method is used to implement dynamic loading of the driver, the IO cache is implemented by using the HASH table, and data addition, deletion, modification and check can be performed quickly by using the HASH method. In the device driver, each sensor node has a fixed six-byte mixed ID, a key value of the HASH table consists of the six-byte mixed ID of the sensor node and the two-byte Internet of things device ID, and a folding method is used for generating the Hash address. The number of keys using the 8-byte table is large, the number distribution on each bit is uniform, and the folding method is used in design to realize the function. The key is divided into 4 segments (separated by two bytes) and the sum of these parts is taken as the hash address. The Hash Table is described by a structural body Hash _ Table _ t, and in order to be compatible with data types of different devices, the storage space can be saved conveniently by using a union, and a specific structural body is shown in fig. 5 below, wherein a keyword is implemented by an array with the size of 8 bytes, and a data union comprises four types, namely double, agent 64_ t, int and agent 32_ t.
The method comprises the steps of decoupling a driver of the Internet of things device from an application program, respectively issuing the application program through an ELF file format and issuing the driver through an SO file format, and realizing dynamic loading of the driver by using a dynamic link compiling method on the basis; the method solves the problems that when the drive is newly added, the content of the original drive file is required to be continuously increased, so that the drive file is complex and the iteration is frequent, and when the method is applied to the field of the Internet of things, the dynamic loading of multiple devices in the scene of the Internet of things is realized, the loading operation is stable and the efficiency is high.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications of the invention may be made without departing from the spirit or scope of the invention.

Claims (10)

1. A dynamic loading method for an Internet of things device driver is characterized by comprising the following steps:
decoupling a driver of the Internet of things device from an application program, wherein the application program is issued in an ELF file format, and the driver is issued in an SO file format;
when a dynamic loading request is sent out, the dynamic loading of the driver is realized by using a dynamic link compiling method.
2. The dynamic loading method of the internet of things device driver according to claim 1, wherein: the method for realizing dynamic loading of the driver by using dynamic link compilation comprises the following steps:
s1: establishing a drive loading linked list, running an application program, searching a drive SO file corresponding to the current dynamic loading request in a drive directory, and judging whether the corresponding drive SO file is in the drive loading linked list or not; if not, executing S2 in the drive loading linked list, and if not, executing S3 in the drive loading linked list;
s2: generating a loading request using the corresponding drive SO file, distributing a file descriptor, and adding the identifier of the loading request and the distributed file descriptor into the drive loading linked list;
s3: relocating the corresponding drive SO file according to the allocated file descriptor, and loading the corresponding drive SO file into an operating memory of the Internet of things equipment;
s4: and analyzing the binary segment address of the general IO interface in the corresponding driving SO file and the binary segment address of the driving equipment description structure body, returning the binary segment addresses to the application program, and dynamically loading the driving program in real time.
3. The dynamic loading method of the internet of things device driver as claimed in claim 2, wherein: and when the driving SO file corresponding to the current dynamic loading request does not exist in the driving directory, packaging the MODBUS instruction of the docking equipment to generate a corresponding shared dynamic link library, and independently compiling the shared dynamic link library to generate the driving SO file corresponding to the dynamic loading request.
4. The dynamic loading method of the internet of things device driver as claimed in claim 2, wherein: when the corresponding driving SO file is loaded into the running memory of the Internet of things equipment, the Internet of things equipment detection system detects the newly added operation of the driving SO file and responds to the request of a dynamic link management list of an application program, and whether the driving SO file is loaded into the dynamic link management list is judged according to the representation of the driving SO file; and if the drive SO file is loaded, opening the dynamic link management list by using a system interface, loading the dynamic link management list into an operating memory, and adding the back-allocated handle into the dynamic link management list.
5. The dynamic loading method of the internet of things device driver as claimed in claim 4, wherein: and when the binary segment address of the general IO interface and the binary segment address of the drive equipment description structure in the corresponding drive SO file are analyzed and returned to the application program, the standard API of the drive loading linked list is obtained through the returned handle and the specified connector name and returned to an API dynamic link management list of the application program.
6. The dynamic loading method of the internet of things device driver as claimed in claim 4, wherein: the dynamic link management list includes: a drive file path pointer and a drive file descriptor,
the drive file path pointer is used for storing a path name character string of the drive SO file, and the drive file descriptor is used for representing the loading state of the drive SO file.
7. The dynamic loading method of the internet of things device driver as claimed in claim 2, wherein: the table node of the drive loading linked list comprises: registration identification, data reporting identification, sensor number, bus attribute pointer and sensor attribute pointer,
when a dynamic loading request is received, a newly generated node is used for storing information from a driver, the IO reads the address information of the binary segment of the interface and connects the newly generated node to the tail pointer of the driver loading linked list.
8. The dynamic loading method of the internet of things device driver according to claim 1, wherein: the structure attributes of the driver and the application include: name of driving device, number of supporting driving devices, number of all-in-one sensors, type of communication protocol, type of driving device,
the driving device name is used for describing the device name of the driving butt joint, the number of the supporting driving devices is used for describing the number of the same devices which are driven to butt joint simultaneously, the number of the all-in-one sensors is used for describing the specific number of the sensors on the butt joint device, the communication protocol type is used for describing the protocol type, and the driving device type is used for describing the device type of the driving butt joint.
9. The dynamic loading method for the internet-of-things device driver as claimed in claim 1, wherein: the application program provides two data transmission interfaces of MODBUS-TCP and MODBUS-RTU.
10. The dynamic loading method of the internet of things device driver according to any one of claims 1 to 9, wherein: when the dynamic loading of the driving program is realized by using a dynamic link compiling method, the IO cache is realized by using a HASH table, a key value of the HASH table consists of a mixed ID of the sensor node and an ID of the Internet of things equipment, and a folding method is used for generating a Hash address.
CN202211512667.0A 2022-11-28 2022-11-28 Dynamic loading method for Internet of things equipment driver Withdrawn CN115878213A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211512667.0A CN115878213A (en) 2022-11-28 2022-11-28 Dynamic loading method for Internet of things equipment driver

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211512667.0A CN115878213A (en) 2022-11-28 2022-11-28 Dynamic loading method for Internet of things equipment driver

Publications (1)

Publication Number Publication Date
CN115878213A true CN115878213A (en) 2023-03-31

Family

ID=85764624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211512667.0A Withdrawn CN115878213A (en) 2022-11-28 2022-11-28 Dynamic loading method for Internet of things equipment driver

Country Status (1)

Country Link
CN (1) CN115878213A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909656A (en) * 2023-09-14 2023-10-20 北京中天星控科技开发有限公司 Method for realizing embedded dynamic APP loading based on elf file

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909656A (en) * 2023-09-14 2023-10-20 北京中天星控科技开发有限公司 Method for realizing embedded dynamic APP loading based on elf file
CN116909656B (en) * 2023-09-14 2023-12-08 北京中天星控科技开发有限公司 Method for realizing embedded dynamic APP loading based on elf file

Similar Documents

Publication Publication Date Title
CN108037961B (en) Application program configuration method, device, server and storage medium
US20100205604A1 (en) Systems and methods for efficiently running multiple instances of multiple applications
US20070226715A1 (en) Application server system and computer product
CN107807815B (en) Method and device for processing tasks in distributed mode
CN111309335B (en) Compiling method and device of plug-in application and computer readable storage medium
CN110912782B (en) Data acquisition method, device and storage medium
CN110750315B (en) Class loading method, device, equipment and storage medium in Android system
CN115878213A (en) Dynamic loading method for Internet of things equipment driver
CN108804100B (en) Method and device for creating interface element, storage medium and mobile terminal
WO2021252043A1 (en) Running pbs jobs in kubernets
CN106406980A (en) Deployment method and device for virtual machines
JP2005301985A (en) Information processor, object generation method, object conversion method, object generation program, object conversion program, and recording medium
Clem et al. Static analysis at github: An experience report
US20020029301A1 (en) Processor system
CN106484375B (en) Instruction block loading method, soft switch equipment and system
CN112069144A (en) Method and device for collecting system logs by multi-control cluster
CN110806891A (en) Method and device for generating software version of embedded equipment
CN115328679A (en) Automatic integration method of heterogeneous function library, computing equipment and system thereof
CN113495723B (en) Method, device and storage medium for calling functional component
CN113885875A (en) Distributed compiling method, system, main server and storage medium
KR20100089831A (en) Generation and management of managed javabean objects
CN111669358B (en) Method and device for processing vrouter network isolation spaces in batch
CN114816445A (en) System platform architecture, function publishing method and device, platform and storage medium
KR102485154B1 (en) Power Communication Service
WO2024055660A1 (en) Data computing method and apparatus, and 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
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20230331