CN113971045A - Control method, control device and storage medium - Google Patents

Control method, control device and storage medium Download PDF

Info

Publication number
CN113971045A
CN113971045A CN202111070716.5A CN202111070716A CN113971045A CN 113971045 A CN113971045 A CN 113971045A CN 202111070716 A CN202111070716 A CN 202111070716A CN 113971045 A CN113971045 A CN 113971045A
Authority
CN
China
Prior art keywords
sensing data
layer
sensor
storage space
service layer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111070716.5A
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.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software 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 Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202111070716.5A priority Critical patent/CN113971045A/en
Publication of CN113971045A publication Critical patent/CN113971045A/en
Pending legal-status Critical Current

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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3004Arrangements for executing specific machine instructions to perform operations on memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/102Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The present disclosure relates to a control method, a control device, and a storage medium, wherein the method is applied to a control system, and the control system includes: an application layer, a service layer, and a plurality of driver layers, the method comprising: the service layer broadcasts theme information of the sensing data to the application layer, wherein different sensing data are generated by different sensors; responding to a subscription request of an application layer for at least one topic information, and controlling a driving layer corresponding to the at least one topic information to read target sensing data from a sensor by a service layer; and the service layer issues the target sensing data to the application layer.

Description

Control method, control device and storage medium
Technical Field
The present disclosure relates to the field of embedded system technologies, and in particular, to a control method, an apparatus, and a storage medium.
Background
The sensor is an important part in the field of the Internet of things, senses eyes of all things in the world by equipment, converts all things and environment changes thereof into digital information, and enables lives of people to be more intelligent and efficient through forwarding processing of the Internet of things.
With the development of the internet of things, the types of sensors are more and more, and although the selectivity of developers is increased, the difficulty of application program development is increased. Because different sensors need to be matched with own unique drivers to operate, the application program needs to be adapted to different sensors when being developed, so that the development difficulty of the application program is higher, and the development period is longer.
Disclosure of Invention
The disclosure provides a control method, a control device and a storage medium.
According to a first aspect of the embodiments of the present disclosure, there is provided a control method applied to a control system, where the control system includes: an application layer, a service layer, and a plurality of driver layers, the method comprising:
the service layer broadcasts theme information of the sensing data to the application layer, wherein different sensing data are generated by different sensors;
responding to a subscription request of an application layer for at least one topic information, and controlling a driving layer corresponding to the at least one topic information to read target sensing data from a sensor by a service layer;
and the service layer issues the target sensing data to the application layer.
Optionally, the driving layer comprises:
a first sub-layer, wherein different first sub-layers contain drivers for different sensors for interacting with the sensors;
and the second sub-layer is a common driving sub-layer shared by different sensors, and provides a storage space for writing sensing data by interacting with the first sub-layer.
Optionally, the storage space is an annular storage space;
after a second storage address of the annular storage space is occupied, target sensing data are written into a first storage address of the annular storage space, wherein the first storage address is a starting storage address of a storage area corresponding to the annular storage space; the second storage address is an end storage address of a storage area corresponding to the annular storage space.
Optionally, the controlling, by the service layer, the at least one driving layer corresponding to the theme information to read the target sensing data from the sensor includes:
the service layer issues a control instruction to the first sublayer; the control instruction is used for triggering the first sublayer to read target sensing data from the connected sensor and writing the target sensing data into a storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
Optionally, the controlling, by the service layer, the at least one driving layer corresponding to the theme information to read the target sensing data from the sensor includes:
the service layer issues a parameter adjusting instruction to the first sublayer; the parameter adjusting instruction is used for triggering the first sublayer to adjust the acquisition parameters, reading target sensing data from the connected sensors based on the adjusted acquisition parameters, and writing the target sensing data into the storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
Optionally, the acquisition parameters include:
the acquisition frequency of the sensing data;
and/or the acquisition modes of the sensing data are different, wherein the preset lengths and/or the reading modes of the sensing data read from the annular storage space by the service layer corresponding to different acquisition modes are different.
Optionally, after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer, including:
after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer sequentially reads the sensing data with preset length in the storage space from the data reading position indicated by the reading pointer of the storage space;
and moving the read pointer to a position next to the current read position.
Optionally, the broadcasting, by the service layer, theme information of the sensing data to the application layer includes:
the service layer acquires the type information of a registered first type sensor in the control system;
determining subject information of sensing data sensed by the first type sensor based on the type information of the first type sensor; the first type of sensor is a sensor only having a preset function;
the service layer broadcasts theme information of the sensing data sensed by the first type of sensor to the application layer.
Optionally, the method further comprises:
the application layer issues a control instruction to a second type of registered sensors in the control system through a preset operation function interface;
the control instruction is used for triggering the driving layer of the second type sensor to call the operation function corresponding to the operation function interface, executing the control instruction, and transmitting an execution result to the application layer through the operation function interface.
According to a second aspect of the embodiments of the present disclosure, there is provided a control apparatus applied to a control system including: the application layer, the service layer and the plurality of driving layers comprise:
the broadcasting module is used for broadcasting the theme information of the sensing data to the application layer by the service layer, wherein different sensing data are generated by different sensors;
the system comprises a first acquisition module, a first storage module and a first processing module, wherein the first acquisition module is used for responding to a subscription request of an application layer for at least one topic information, and a service layer controls a driving layer corresponding to the at least one topic information to read target sensing data from a sensor;
and the issuing module is used for issuing the target sensing data to the application layer by the service layer.
Optionally, the driving layer comprises:
a first sub-layer, wherein different first sub-layers contain drivers for different sensors for interacting with the sensors;
and the second sub-layer is a common driving sub-layer shared by different sensors, and provides a storage space for writing sensing data by interacting with the first sub-layer.
Optionally, the storage space is an annular storage space;
after a second storage address of the annular storage space is occupied, target sensing data are written into a first storage address of the annular storage space, wherein the first storage address is a starting storage address of a storage area corresponding to the annular storage space; the second storage address is an end storage address of a storage area corresponding to the annular storage space.
Optionally, the first obtaining module is configured to:
the service layer issues a control instruction to the first sublayer; the control instruction is used for triggering the first sublayer to read target sensing data from the connected sensor and writing the target sensing data into a storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
Optionally, the first obtaining module is configured to:
the service layer issues a parameter adjusting instruction to the first sublayer; the parameter adjusting instruction is used for triggering the first sublayer to adjust the acquisition parameters, reading target sensing data from the connected sensors based on the adjusted acquisition parameters, and writing the target sensing data into the storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
Optionally, the acquisition parameters include:
the acquisition frequency of the sensing data;
and/or the acquisition modes of the sensing data are different, wherein the preset lengths and/or the reading modes of the sensing data read from the annular storage space by the service layer corresponding to different acquisition modes are different.
Optionally, the first obtaining module is further configured to:
after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer sequentially reads the sensing data with preset length in the storage space from the data reading position indicated by the reading pointer of the storage space;
and moving the read pointer to a position next to the current read position.
Optionally, the broadcasting module is configured to:
the service layer acquires the type information of a registered first type sensor in the control system;
determining subject information of sensing data sensed by the first type sensor based on the type information of the first type sensor; the first type of sensor is a sensor only having a preset function;
the service layer broadcasts theme information of the sensing data sensed by the first type of sensor to the application layer.
Optionally, the apparatus further comprises: a second obtaining module to:
the application layer issues a control instruction to a second type of registered sensors in the control system through a preset operation function interface;
the control instruction is used for triggering the driving layer of the second type sensor to call the operation function corresponding to the operation function interface, executing the control instruction, and transmitting an execution result to the application layer through the operation function interface.
According to a third aspect of the embodiments of the present disclosure, there is provided a control apparatus including:
a processor;
a memory for storing executable instructions;
wherein the processor is configured to: when the executable instructions stored in the memory are executed, the steps in the control method of the first aspect of the embodiments of the present disclosure are implemented.
According to a fourth aspect of embodiments of the present disclosure, there is provided a non-transitory computer readable storage medium, wherein instructions, when executed by a processor of a control device, enable the control device to perform the steps of the control method according to the first aspect of embodiments of the present disclosure.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
the method includes the steps that theme information of sensing data is broadcasted to an application layer through a service layer, and a subscription request of the application layer for the theme information is responded, and a driving layer corresponding to the theme information is controlled so that target sensing data can be read from a sensor; the service layer issues the target sensing data to the application layer; therefore, by introducing the service layer and interacting with the application layer through the service layer, the development difficulty of the application program is reduced without paying attention to a driving program of a sensor in the development process of the application program; through interaction between the service layer and the driving layer of the sensor, the sensor device is controlled and the sensing data acquired by the sensor is published according to the subscription condition of the theme information of the sensing data, so that the application layer and the driving layer are completely decoupled.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a block diagram illustrating a RTOS system in accordance with an exemplary embodiment.
Fig. 2 is a first schematic diagram of a sensor driving framework of an RT-Thread system according to an exemplary embodiment.
Fig. 3 is a sensor drive framework diagram two of an RT-Thread system according to an exemplary embodiment.
Fig. 4 is a first flowchart illustrating a control method according to an exemplary embodiment.
FIG. 5 is a flowchart illustration two of a control method according to an exemplary embodiment.
FIG. 6 is a software framework diagram of a control system shown in accordance with an exemplary embodiment.
FIG. 7 is a block diagram illustrating a sensor drive layer in accordance with an exemplary embodiment.
FIG. 8 is a schematic diagram illustrating a drive model of different sensor modules according to an exemplary embodiment.
FIG. 9 is a third flowchart illustrating a control method according to an exemplary embodiment.
FIG. 10 is a block diagram illustrating a framework for application development in accordance with an illustrative embodiment.
Fig. 11 is a schematic diagram illustrating a configuration of a control device according to an exemplary embodiment.
FIG. 12 is a block diagram illustrating a control device according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of devices consistent with certain aspects of the present disclosure, as detailed in the appended claims.
For embedded devices or internet of things devices, Random Access (RAM) memories or Read-Only Memory (ROM) memories are generally in the order of KB and MB, and for storage of GB and GB, sensors with low power consumption and limited resources are difficult to implement, so in an embedded platform or an internet of things platform, a rot system is generally selected to perform function scheduling between sensors under the condition that the use functions and the use scenes are complex.
Currently, the more common RTOS system includes: freetos, uc/OS-II, Zypher, RT-Thread, etc., but most of these ROTS systems implement only a driver for the control of sensors, as shown in FIG. 1, which is a block schematic diagram of an RTOS system according to an exemplary embodiment. The sensor is registered as character equipment, and the application program conducts difference control on the sensor through the character equipment node so as to meet the functional requirements of the embedded platform or the platform of the Internet of things.
The RTOS system is simply introduced below by taking the RT-Thread system as an example; as shown in fig. 2 and 3, fig. 2 is a first schematic diagram of a sensor driving framework of an RT-Thread system according to an exemplary embodiment; fig. 3 is a sensor drive framework diagram two of an RT-Thread system according to an exemplary embodiment. In the RT-Thread system, a sensor driver layer provides a driver interface (e.g., open, close, read, or control) to an application layer, so that an application program of the application layer opens a corresponding sensor character device node through the driver interface, thereby accessing the driver layer of the sensor; the sensor driving layer also provides an operation command interface (fetch _ data or control) for the underlying driver, and the sensor is controlled by the operation command interface which is connected with the underlying driver of the specific sensor hardware.
In the RTOS system, a development model of a software algorithm is mixed with a bottom layer driver, so that data processing codes of the bottom layer of the driver and codes in the software algorithm are mutually crossed, and when a plurality of applications read sensing data of one sensor at the same time, complex mutually exclusive codes and downsampling codes meeting different sampling rates need to be realized in the driver; on one hand, the development difficulty and the development period of the application program are increased, and on the other hand, the problem of program errors is easy to occur.
In view of this, the disclosed embodiments provide a control method. Fig. 4 is a flowchart illustrating a control method according to an exemplary embodiment, as shown in fig. 4, the method including:
step S101, a service layer broadcasts theme information of sensing data to an application layer, wherein different sensing data are generated by different sensors;
step S102, responding to a subscription request of an application layer to at least one topic information, a service layer controls a driving layer corresponding to at least one topic information to read target sensing data from a sensor;
step S103, the service layer issues the target sensing data to the application layer.
The control method provided by the embodiment of the disclosure is applied to a control system, and the control system comprises: an application layer, a service layer, and a plurality of driver layers.
In step S101, the topic information may include: topic name, content of the sensed data, type of the sensed data, etc., for example, the topic information may be accelerometer data, audio data, bluetooth WiFi status, or any intermediate quantity generated by the system.
It should be noted that different subject information has unique names. Different subject information may also correspond to different structures. The structure body contains description information of the subject state, for example, the name of the subject information may be accelerometer data, and the corresponding structure body contains acceleration vectors of x, y and z axes and timestamp messages.
The service layer can obtain sensing data sensed by different sensors in the control system, determine the theme information according to the sensing data, and broadcast the theme information to the application layer through a preset interface.
In some embodiments, the default interface may be a Micro Object Request Broker (uORB) interface through which broadcasting of the theme information is implemented.
It should be noted that the uORB interface is an application program interface of a message mechanism for asynchronous publish-subscribe between threads/processes; the uORB interface is an asynchronous communication mechanism, and the uORB interface does not guarantee that all data of a publisher can be received by a subscriber in the data publishing and receiving process, but only guarantees that the subscriber can receive the latest data when the subscriber wants to receive the data. That is, in the communication process, the publisher is only responsible for publishing data, and does not care who receives the data, nor does it care whether the subscriber can receive all the data; it is not a concern to the subscriber who the data is published by, nor is it a concern whether all the data is received during the receiving process.
Illustratively, the service layer may broadcast the subject information of the sensed data using a uORB interface such as orb _ addtitise or orb _ addtitise _ multi. When the application layer has an application program to subscribe to the theme information of a certain sensing data by using an interface of orb _ subscribe or orb _ subscribe _ multi, etc., the service layer will receive the notification.
In step S102, each application program in the application layer subscribes subject information of the sensor data required by the application program according to the subject information broadcast by the service layer, and after receiving the subscription request of the application layer, the service layer controls the driver layer corresponding to the subject information to read the target sensor data from the sensor.
It should be noted that the driving layers corresponding to different sensors are different, and the service layer may determine the sensing data required by the application layer according to the topic information targeted by the subscription request, so as to control the corresponding driving layers and read the target sensing data from the connected sensors.
The subscription request may be a request for obtaining one or more items of topic information by an application program in the application layer, or may be a subscription request for one or more items of topic information by multiple application programs in the application layer, which is not limited in this embodiment of the disclosure.
In step S103, after the driver layer reads target sensing data from the sensor, the service layer obtains the target sensing data from the driver layer, and issues the target sensing data to an application program subscribed with topic information of the target sensing data in the application layer through a preset interface, so that the application program obtains the target sensing data.
In some embodiments, the preset interface may be a uORB interface;
illustratively, after the service layer obtains the target sensing data from the driver layer, the target sensing data can be published by using a uORB interface (e.g., orb _ publish), all applications subscribing to the subject information of the target sensing data can be notified, and the applications can obtain the target sensing data by using the uORB interface (e.g., orb _ copy).
When a plurality of application programs in the application layer subscribe the theme information of the same sensing data, the uORB interface performs data transmission based on the shared memory among the multiple processes, so the uORB interface can distribute the sensing data to the multiple application programs in a memory sharing mode, and the mutual exclusion problem among the application programs can be reduced.
According to the embodiment of the disclosure, the service layer is introduced, and the service layer interacts with the application layer, so that in the development process of the application program, a driver of a sensor does not need to be concerned, and the development difficulty of the application program is reduced; through interaction between the service layer and the driving layer of the sensor, the sensor device is controlled and the sensing data acquired by the sensor is published according to the subscription condition of the theme information of the sensing data, so that the application layer and the driving layer are completely decoupled.
Optionally, the driving layer comprises:
a first sub-layer, wherein different first sub-layers contain drivers for different sensors for interacting with the sensors;
and the second sub-layer is a common driving sub-layer shared by different sensors, and provides a storage space for writing sensing data by interacting with the first sub-layer.
In an embodiment of the present disclosure, the driving layer may include: a first sublayer and a second sublayer; the first sublayer comprises a driver of the sensor corresponding to the driver layer, and the access operation to the sensor can be realized by calling a corresponding operation function from the first sublayer.
It can be understood that, since different sensors need to be configured with their own unique drivers to operate, in order for the first sub-layer to directly interact with the connected sensors, the first sub-layer needs to include the drivers of the connected sensors; since the sensors connected are different for different first sublayers, different first sublayers contain drivers for different sensors.
The second sublayer is a common driving sublayer shared by different sensors, is not interacted with the sensors and is used for providing common functions of the sensors; such as functions of registering character device nodes, batch mode management, or reference counting.
It should be noted that, because the drivers of different sensors are different, when the number of sensors in the control system is large, the amount of codes of the driver included in the driver layer of the sensor is large; in order to reduce redundant codes and increase multiplexing, the driving layer of the sensor may be divided into a first sublayer and a second sublayer, and the second sublayer includes the same part (i.e. the driver of the general function of the sensor) in the driver of the sensor, so that when the codes are implemented, one copy of the codes of the second sublayer may be reserved; and calling the code of the second sublayer to realize the general function of the sensor.
The service layer can acquire target sensing data from the sensor by controlling the first sublayer, and the second sublayer writes the target sensing data acquired from the first sublayer into a storage space of the second sublayer by interacting with the first sublayer, so that the service layer can read the target sensing data from the storage space of the second sublayer.
It should be noted that different sensors correspond to different driver layers, and the storage spaces in the second sub-layers of the different sensors are independent from each other and do not affect each other, for example, the storage spaces are all in the memory or flash memory of the smart phone, but the memory or flash memory is divided into different storage areas according to needs for separation, so that the storage spaces do not affect each other.
Optionally, the storage space is an annular storage space;
after a second storage address of the annular storage space is occupied, target sensing data are written into a first storage address of the annular storage space, wherein the first storage address is a starting storage address of a storage area corresponding to the annular storage space; the second storage address is an end storage address of a storage area corresponding to the annular storage space.
In the embodiment of the present disclosure, the storage space of the second sublayer may be an annular storage space; it should be noted that the circular storage space is a data structure for representing fixed-length, head-to-tail storage areas; the annular memory space typically has a read pointer and a write pointer; the reading pointer points to the storage position of readable data in the annular storage space, the writing pointer points to the storage position of writable data in the annular storage space, and data reading and writing in the annular storage space can be realized by moving the reading pointer and the writing pointer.
After the first sublayer acquires target sensing data from the sensor, transmitting the target sensing data to the second sublayer, and determining whether the annular buffer space is full or not by judging whether a second storage address in the annular storage space is occupied or not by the second sublayer; if the second storage address of the annular storage space is not occupied, that is, the annular storage space is not full, the target sensing data can be written into the storage address corresponding to the write pointer of the annular storage space.
If the second storage address of the annular storage space is occupied, that is, the annular storage space is full, the write pointer of the annular storage space can be moved to the first storage address of the annular storage space, so that the target sensing data is written into the first storage address to cover the data originally stored by the first storage address.
It should be noted that, because the annular storage space is a first-in first-out circular storage space, when the annular storage space is full and new data needs to be stored, the new data can be directly stored into the initial storage address of the storage area corresponding to the annular storage space, and the data with the longest history stored in the initial storage address is discarded, so that frequent memory allocation is not needed.
Optionally, the step S102 of controlling, by the service layer, at least one driving layer corresponding to the theme information to read the target sensing data from the sensor includes:
the service layer issues a control instruction to the first sublayer; the control instruction is used for triggering the first sublayer to read target sensing data from the connected sensor and writing the target sensing data into a storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
In the embodiment of the present disclosure, the service layer sends a control instruction to the first sublayer, and since the first sublayer includes a driver of the sensor, the service layer can call an operation function corresponding to the control instruction from the first sublayer so as to control the sensor to execute a corresponding operation, and write the acquired target sensing data into a storage space of the second sublayer; and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer can directly acquire the target sensing data from the storage space, so that the sensor is controlled.
In some embodiments, if the service layer does not detect the subscription request of the application layer within a preset time period, the service layer issues a shutdown instruction to the first sublayer, where the shutdown instruction is used to trigger the first sublayer to control the connected sensor to switch to a shutdown state.
It should be noted that, if the subscription request of the application layer is not detected in the preset time period, it is indicated that the application program of the application layer does not need the sensing data of the sensor at this time, so the service layer can switch to the off state by controlling the sensor, thereby achieving the effect of reducing power consumption.
In other embodiments, if the service layer receives the subscription cancellation request from the application layer and the topic information of the sensing data indicated by the subscription cancellation request is not subscribed by other application programs of the application layer, the service layer issues a close instruction to the first sub-layer corresponding to the topic information.
In the embodiment of the disclosure, if the application program of the application layer unsubscribes the topic information of the sensing data, the service layer receives a notification of unsubscribing; if all the application programs subscribing the theme information of a certain sensing data cancel subscription of the theme information, the service layer can switch to the relation state by controlling the sensor corresponding to the theme information, so that the effect of reducing power consumption is achieved.
Optionally, the step S102 of controlling, by the service layer, at least one driving layer corresponding to the theme information to read the target sensing data from the sensor includes:
the service layer issues a parameter adjusting instruction to the first sublayer; the parameter adjusting instruction is used for triggering the first sublayer to adjust the acquisition parameters, reading target sensing data from the connected sensors based on the adjusted acquisition parameters, and writing the target sensing data into the storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
In the embodiment of the present disclosure, if the application layer sends parameter setting information to the service layer through the preset interface, the service layer may issue a parameter adjustment instruction to the first sublayer according to the parameter setting information, so that the first sublayer acquires target sensing data from the connected sensor according to an acquisition parameter indicated by the parameter adjustment instruction; and writing the target sensing data into the storage space of the second sublayer.
Here, the preset interface may be a uORB interface, for example, the application may set the sampling rate of the sensor by using the uORB interface (e.g., orb _ set _ interval).
In some embodiments, the method further comprises:
the service layer determines the maximum sampling frequency in response to the parameter setting information used by the application layer to indicate a plurality of sampling frequencies;
based on the maximum sampling frequency, issuing a parameter control instruction to the first sublayer, wherein the parameter control instruction is used for triggering the first sublayer to acquire target sensing data from a connected sensor based on the maximum sampling frequency and write the target sensing data into a storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer, and performs down-sampling processing on the target sensing data to obtain a plurality of target sensing data meeting a plurality of sampling frequencies.
Here, the parameter setting information may include: the set acquisition parameters indicating the sensor and/or the working parameters of the sensor. For example, the parameter setting information may be an acquisition frequency and/or an acquisition mode of the sensor, and the like. The operating parameters of the sensor include, but are not limited to: an operating period parameter of the sensor, an operating mode parameter of the sensor and/or a power parameter of the sensor, etc.
In the embodiment of the present disclosure, the parameter setting information is different acquisition frequencies of the same sensor indicated by a plurality of application programs in the application layer.
In the embodiment of the present disclosure, if multiple application programs in the application layer subscribe to the same topic information and sampling frequencies of the sensor data subscribed by different application programs are different, the service layer may determine the maximum sampling frequency according to the sampling frequencies in multiple subscription requests; based on the maximum sampling frequency, issuing a parameter adjustment instruction to the first sublayer; the first sublayer acquires target sensing data from the sensor according to the maximum sampling frequency indicated by the parameter adjusting instruction, and writes the acquired target sensing data into a storage space of the second sublayer; and after acquiring the target sensing data from the storage space, the service layer performs down-sampling processing on the target sensing data to obtain target sensing data with different sampling frequencies, so that the target sensing data with different sampling frequencies are issued to the application layer.
Optionally, the acquisition parameters include:
the acquisition frequency of the sensing data;
and/or the acquisition modes of the sensing data are different, wherein the preset lengths and/or the reading modes of the sensing data read from the annular storage space by the service layer corresponding to different acquisition modes are different.
In this disclosure, if the acquisition parameter may be the acquisition frequency of the sensing data, the service layer may issue a parameter adjustment instruction to the first sublayer according to the sampling frequency indicated by the subscription request; and the first sublayer reads target sensing data from the connected sensors according to the acquisition frequency indicated by the parameter adjusting instruction, and writes the acquired target sensing data into the storage space of the second sublayer, so that the service layer can read the target sensing data from the storage space and issue the target sensing data to an application program which subscribes the subject information of the sensing data in the application layer.
The acquisition mode of the sensing data may include: an interrupt control mode, a polling mode, and a First Input First Output (FIFO) mode;
it should be noted that, if the read mode of the sensing data is the interrupt control mode, when the service layer receives the subscription request, the service layer sends a control instruction to the first sublayer to trigger generation of an interrupt signal, and after the first sublayer detects the interrupt signal, the first sublayer reads the target sensing data from the sensor, and writes the target sensing data into the storage space of the second sublayer, so that the service layer can read the target sensing data.
If the reading mode of the sensing data is a polling mode, the first sublayer acquires target sensing data from the sensor at regular time; and writing the target sensing data into a storage space of a second sublayer, so that the target sensing data can be directly read from the storage space after the service layer receives the subscription request.
The FIFO mode needs the hardware support of a sensor, and if the reading mode of the sensing data is the FIFO mode, the service layer sends a control instruction to the first sublayer to control the first sublayer to read the target sensing data with the preset length; the first sublayer can read target sensing data from the sensor, store the read target sensing data in the hardware FIFO, and write the target sensing data with a preset length into the storage space of the second sublayer after the hardware FIFO stores the target sensing data with the preset length; and the target sensing data is read without generating an interrupt signal every time when the service layer is triggered, so that the CPU resource is saved, and the method is suitable for a low-power-consumption mode.
If the acquisition parameter is the reading mode of the sensing data, the service layer can issue a parameter adjusting instruction to the first sublayer according to the reading mode indicated by the subscription request, and the first sublayer reads target sensing data with a preset length from a connected sensor in a reading mode corresponding to the reading mode according to the reading mode indicated by the parameter adjusting instruction; and writing the read target sensing data into the storage space of the second sublayer, so that the service layer can read the target sensing data from the storage space of the second sublayer and publish the target sensing data to an application program which is subscribed with the theme information of the sensing data in the application layer.
Optionally, after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer, including:
after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer sequentially reads the sensing data with preset length in the storage space from the data reading position indicated by the reading pointer of the storage space;
and moving the read pointer to a position next to the current read position.
In this disclosure, since the storage space of the second sublayer is an annular storage space, after detecting that the data stored in the storage space of the second sublayer is updated, the service layer may sequentially read the target sensing data stored in the annular storage space and having a preset length according to a data reading position indicated by a read pointer of the annular storage space; and after the data reading is finished, moving the reading pointer of the annular storage space to the next position of the current reading position, so as to facilitate the subsequent reading of the sensing data and reduce the problem of repeatedly reading the same sensing data.
It should be noted that, because the preset lengths corresponding to different reading modes are different, for example, the interrupt control mode reads the sensing data from the sensor once every time an interrupt signal is received, the preset length corresponding to the interrupt control mode may be the length of the sensing data; the FIFO mode reads a plurality of sensing data from the sensor after receiving a control command once, so that the preset length corresponding to the FIFO mode can be the length of the plurality of sensing data.
Optionally, the broadcasting, by the service layer in step S101, the theme information of the sensing data to the application layer includes:
the service layer acquires the type information of a registered first type sensor in the control system;
determining subject information of sensing data sensed by the first type sensor based on the type information of the first type sensor; the first type of sensor is a sensor only having a preset function;
the service layer broadcasts theme information of the sensing data sensed by the first type of sensor to the application layer.
In the embodiment of the present disclosure, the first type of sensor may be a preset type of sensor, which only has a preset function; here, the preset type may be set according to actual conditions, for example, the first type sensor includes: accelerometers, gyroscopes or magnetometers, etc. 25 known types of sensors.
The service layer obtains the type information of the first type of sensor by scanning the character equipment nodes of the first type of sensor registered in the control system; according to the type information of the first type of sensor, theme information of sensing data sensed by the first type of sensor is generated, and the theme information of the sensing data is broadcasted to the application layer through a preset interface, so that an application program in the application layer subscribes the sensing data required by the application program according to the theme information.
It should be noted that, in the embodiment of the present disclosure, all the first type sensors in the control system are managed uniformly by the service layer, the service layer actively acquires the type information of the first type sensors to determine the theme information of the sensing data sensed by the first type sensors, and the service layer broadcasts the theme information of the sensing data to the application layer, so that each application program in the application layer subscribes the sensing data required by itself according to the theme information.
Optionally, the method further comprises:
the application layer issues a control instruction to a second type of registered sensors in the control system through a preset operation function interface;
the control instruction is used for triggering the driving layer of the second type sensor to call the operation function corresponding to the operation function interface, executing the control instruction, and transmitting an execution result to the application layer through the operation function interface.
In the embodiment of the present disclosure, the second sensor may be a sensor without a preset function or having a preset function and other complex functions; the second type of sensor is not uniformly managed by the service layer and needs to be directly controlled and managed by the application layer.
The application layer can directly open the character equipment node of the second type of sensor through a preset operation function interface, so as to access the driving layer of the second type of sensor and issue a control instruction to the second type of sensor; and the driving layer of the second sensor controls the second sensor to execute the control instruction by calling the operation function corresponding to the operation function interface, acquires sensing data from the second sensor, and transmits the sensing data to the application layer through the operation function interface.
Here, the preset operation function interface may be a functional interface predefined for adapting to a driver of the second type sensor during development of an application layer. Such as an open, close, read or control interface.
It should be noted that, because the operation of the second type sensor is not general, the type of the sensor sensed by the second type sensor is uncertain, and the second type sensor cannot be directly controlled by the service layer, in order to control the second type sensor, an application program of the application layer needs to be adapted to a driver of the second type sensor, and according to the driver of the second type sensor, an operation function interface of the second type sensor is predefined, so that the application program of the application layer can directly access the character device node of the second type sensor through the operation function interface, thereby controlling the second type sensor.
In some embodiments, in order to facilitate data interaction between a sensor in a control system and a service layer or an application layer, the sensor needs to be registered in the control system, and the method further includes:
based on a sensor driver within the first sub-layer, the second sub-layer determines type information of the sensor;
and the second sublayer registers the character equipment corresponding to the sensor according to the type information of the sensor.
In the embodiment of the present disclosure, since the character device may operate the character device file using the same file operation command as the normal file, after the physical connection is established with the sensor, the character device file needs to be created for the sensor, and then the data collected by the sensor may be operated.
It is understood that since sensors can be classified into a first type of sensor and a second type of sensor; the functions of the first type of sensor and the second type of sensor may be different, the first type of sensor only has a preset function, and the service layer can uniformly manage the first type of sensor; the second type of sensor needs to be controlled and managed by an application layer, so that when the sensor is registered, the first type of sensor and the second type of sensor need to be distinguished according to the type information of the sensor, and the first type of sensor and the second type of sensor need to be registered respectively.
If the sensor is a first type sensor, the second sub-layer can determine the identification information of the character equipment corresponding to the first type sensor according to the type information of the first type sensor and register the character equipment corresponding to the first type sensor;
if the sensor is a second type sensor, based on a driving program of the second type sensor in the first sublayer, the second sublayer determines a storage space address and a storage amount corresponding to the second type sensor and identification information of the second type sensor; and registering character equipment corresponding to the second type of sensor based on the storage space address, the storage amount and the identification information.
Here, the identification information may be a name and/or an ID number of the character device; the character device can be uniquely determined by the identification information.
The service layer can determine the character devices of the first type of sensor and the theme information of the sensing data sensed by the first type of sensor by acquiring the identification information of all the character devices in the control system, so that the theme information is broadcasted to the application layer. And the application layer acquires the sensing data sensed by the first type of sensor by subscribing the theme information.
If the application layer needs to acquire the sensing data of the second type of sensor, an operation function interface needs to be predefined according to a driving program of the second type of sensor, so that the application layer can directly access the character equipment of the second type of sensor through the operation function interface in the subsequent processing process, and the sensing data sensed by the second type of sensing data is acquired.
The present disclosure also provides the following embodiments:
FIG. 5 is a flowchart illustration two of a control method according to an exemplary embodiment, the method comprising:
step S201, a service layer acquires the type information of a registered first type sensor in a control system; determining subject information of sensing data sensed by the first type sensor based on the type information of the first type sensor; the service layer broadcasts theme information of the sensing data sensed by the first type of sensor to the application layer;
in this example, the control method is applied to a control system including: an application layer, a service layer, and a plurality of driver layers. As shown in FIG. 6, FIG. 6 is a software framework diagram of a control system shown according to an exemplary embodiment. The software framework of the control system mainly comprises: an application layer, a sensor service layer and a sensor driver layer.
Here, the service layer may be a sensor service layer that provides the ability to publish sensor data and automation. The driving layer may be a sensor driving layer; the sensor driver layer provides the ability to interact with the sensor device.
The driving layer includes:
a first sub-layer, wherein different first sub-layers contain drivers for different sensors for interacting with the sensors;
and the second sub-layer is a common driving sub-layer shared by different sensors, and provides a storage space for writing sensing data by interacting with the first sub-layer.
In this example, the first sublayer may be a lower layer and the second sublayer may be an upper layer. Wherein the upper layer does not interact with the real sensor device, and provides general functions for the sensor driver layer, such as registering device nodes, binding syscall callback set, multi-user access, providing circular buffer, batch mode management, controlling the sensor, etc. The Lower layer is a real driver, responsible for interacting with the sensor device, and is represented as: activation, sampling rate setting, batch processing, etc., and transfers the sensing data collected from the sensor device to the storage space of the upper layer.
It should be noted that, in the control system, each sensor device corresponds to one sensor driving layer, and in order to reduce redundant codes and improve multiplexing, the sensor driving layer may be divided into an upper layer and a lower layer, where the upper layer of each sensor device is the same and provides a general function of the sensor device; therefore, when the code is implemented, only one copy of driver code of the upper layer needs to be written; each sensor driver may call this upper layer code; and the lower layer is a real driver, and the code of the lower layer corresponding to each sensor device is different.
The method can be realized by extracting a common part of the drivers of all the sensor devices in the control system as an upper layer and taking the rest of the drivers as lower layers; as shown in fig. 7, fig. 7 is a schematic diagram of a framework of a sensor driving layer according to an exemplary embodiment. The data structure struct lowerhalf _ s is used as a bridge to connect the upper layer and the lower layer, and expresses the sensor type of the lower layer, the size of the annular storage space, whether the sensor data is calibrated or not and controls the sensor behavior set upwards; and transmitting the event push notification, the event push interface and the pointer of the upper layer downwards.
It is understood that in this example, the driver layer only focuses on the physical sensor type, and for the virtual sensor type, there is a convergence of the upper layer applications, and there is no focus here. struct lowerhalf _ s represents a specific physical sensor type, for example, an acceleration sensor.
In some embodiments, according to the type of the sensor module, the following can be classified: a single chip single sensor, such as IAM20381, containing only three axis acceleration sensors; and a single chip multi-sensor, e.g., ICM20948, nine axis IMU, containing acceleration sensors, gyroscopes, and magnetometers.
It can be understood that the driving models corresponding to different types of sensor modules are different, and for a sensor module integrating a plurality of sensors, a plurality of struct lowerhalf _ s bridges need to be built to generate a plurality of character device nodes. As shown in fig. 8, fig. 8 is a schematic diagram illustrating a driving model of different sensor modules according to an exemplary embodiment.
In this example, the application layer and the sensor service layer interact with each other through a uORB interface.
It should be noted that the uORB interface is a very important interface module in the open-source flight control PX4, and is mainly responsible for data transmission between modules in the system. The method is a middleware for message publishing-subscribing, the real-time of the UORB interface is completely independent of threads and work queues, a master needs to ensure the initialization of some global data, and the communication of the method is realized based on a shared memory among multiple processes.
The UORB interface belongs to an asynchronous communication mechanism, and has two roles, wherein one role is a publisher, and the generated data can be published in a theme form through the UORB interface; one is a subscriber, and the information of interest can be subscribed in the form of a topic through the uORB interface. Since the publisher and subscriber use completely separate storage spaces, they do not interact and wait.
The uORB interface has an optimal amount of code and is capable of providing low-latency data exchange, and is implemented based on system calls: open, read, write, close, ioctl and other operation function interfaces; the transplantation of the UORB is very simple, and the transplantation can be successful only by using a lib c + + library of the system to participate in compilation together and solving some problems of compiling error report.
The subject may be specific sensor data, such as accelerometer data; alternatively, it may be any intermediate quantity produced by the system; each topic may have a specific and unique name and corresponding structure that contains a description of the state of the topic, e.g., an accelerometer contains an x, y, z tri-axial acceleration vector and a time stamp message.
The Sensor service layer can broadcast the theme of all sensors in the system by using a uORB interface of orb _ advertisement, orb _ advertisement _ multi and the like, and when an application program of the application layer subscribes to the specified Sensor theme by using orb _ describe and orb _ describe _ multi, the Sensor service layer receives a notice and interacts with the driver layer to open the Sensor hardware.
In this example, the control system includes: a first type of sensor and a second type of sensor; the first type of sensor is a sensor only having a preset function.
The first type of sensors are managed by a sensor service layer in a unified mode, the second type of sensors are self-defined sensors, control management is carried out through upper application, unconventional operation can be carried out on the second type of sensors, and complex function control is achieved.
It should be noted that, a sensor driving layer can be registered as a character device node to a user, and for an application layer or a sensor service layer, the sensor corresponding to the character device node is controlled by performing operations such as opening and reading on the character device node.
For the first type of sensor, the character device node can be registered through an example lowerhalf pointer and a device number;
int sensor_register(structsensor_lowerhalf_s*dev,int devno);
void sensor_unregister(structsensor_lowerhalf_s*dev,int devno);
wherein, the upper layer of the first type sensor device determines the name and ID of the character device node according to the type of the sensor. Wherein the first type of sensor may be 25 predetermined types of sensors.
For the second type of sensor, the character device node of the second type of sensor can be registered by instantiating the lowerhalf pointer and the device node address and the custom sensorvent buffer size.
int sensor_custom_redister(structsensor_lowerhalf_s*lower,const char*path,uint8_tesize);
void sensor_custom_unregister(FAR structsensor_lowerhalf_s*lower,const char*path);
It can be understood that, since the second type of sensor not only has the preset function, but also has other functions, the interface needs to be customized for the other functions of the second type of sensor.
In this example, for the first type of sensor, the application APP of the application layer may not directly access the character device node to control and obtain the sensing data, but subscribe to topic information of the sensing data published by the sensor service layer through the UORB interface to obtain the sensing data.
In the starting process of the control system, a sensor service layer scans all first-class sensors registered in the control system, and determines theme information of sensing data sensed by the first-class sensors according to the types of the first-class sensors; and broadcasting the theme information of the sensing data to an application layer through a uORB interface so that the application layer can determine whether to subscribe the sensing data according to the theme information.
In some embodiments, if the service layer does not detect a subscription request of the application layer for the topic information, the sensor service layer may turn off the sensor to save power consumption.
Step S202, responding to a subscription request of an application layer to at least one topic information, a service layer issues a control instruction to a first sublayer of a drive layer; the control instruction is used for triggering the first sublayer to read target sensing data from a connected sensor and writing the target sensing data into a storage space of a second sublayer of the driving layer;
in this example, the application layer determines the sensing data required by the application layer according to the theme information of the sensing data broadcast by the sensor service layer, and subscribes the theme information corresponding to the sensing data; after the sensor service layer detects a subscription request of the application layer for at least one topic information, the sensor service layer opens interruption of the sensor by controlling a lower layer of a sensor driving layer to acquire sensing data; and reporting the sensing data to an upper layer to be stored in a storage space of the upper layer.
In some embodiments, the method further comprises:
the service layer issues a parameter adjusting instruction to the first sublayer; the parameter adjusting instruction is used for triggering the first sublayer to adjust the acquisition parameters, reading target sensing data from the connected sensors based on the adjusted acquisition parameters, and writing the target sensing data into the storage space of the second sublayer;
in the example, the application layer can control the sensor in the control system according to the self requirement, and the application layer can send parameter setting information to the sensor service layer by calling the uORB interface; the sensor service layer issues a parameter adjusting instruction to the lower layer according to the parameter setting information; and after receiving the parameter adjusting instruction, the first sublayer reads target sensing data from the connected sensors according to the acquisition parameters indicated by the parameter adjusting instruction, and writes the read target sensing data into the storage space of the upper layer.
The acquisition parameters include:
the acquisition frequency of the sensing data;
and/or the acquisition modes of the sensing data are different, wherein the preset lengths and/or the reading modes of the sensing data read from the annular storage space by the service layer corresponding to different acquisition modes are different.
In this example, the application at the application layer may set the sampling frequency of the sensor by calling the interface orb _ set _ interval of the uORB; when a plurality of application programs set different sampling frequencies, the sensor service layer determines the maximum sampling frequency and generates a parameter adjusting instruction based on the maximum sampling frequency so as to send the parameter adjusting instruction to the lower layer; after the sensor service layer acquires the sensing data acquired based on the maximum sampling frequency, the inside of the UORB performs down-sampling processing on the sensing data of the maximum sampling frequency, respectively obtains the sensing data of different sampling frequencies, and respectively sends the sensing data to different application programs.
The acquisition mode of the sensing data may include: FIFO mode, polling mode and interrupt control mode; and the preset lengths and/or reading modes of the sensing data read from the annular storage space by the service layers corresponding to different acquisition modes are different.
Step S203, after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer sequentially reads the sensing data with preset length in the storage space from the data reading position indicated by the reading pointer of the storage space; and moving the read pointer to a position next to the current read position.
In this example, the storage space is an annular storage space;
after a second storage address of the annular storage space is occupied, target sensing data are written into a first storage address of the annular storage space, wherein the first storage address is a starting storage address of a storage area corresponding to the annular storage space; the second storage address is the tail storage address of the storage area corresponding to the annular storage space
After the lower layer acquires sensing data from the sensor and transmits the sensing data to the upper layer, the upper layer judges whether a second storage address of the annular storage space is occupied or not and determines whether the annular storage space is full or not; if the second storage address of the annular storage space is not occupied, namely the annular storage space is not full, target sensing data can be stored behind the storage position of the stored data in the annular storage space; if the second storage address of the annular storage space is occupied, that is, the annular storage space is full, the target sensing data can be stored in the first storage address of the annular storage space, that is, the data stored in the first storage address of the first annular storage space is overwritten.
It can be understood that the storage space of the upper layer is set as the annular storage space, so that the frequent memory allocation is not needed, and meanwhile, the overflow condition can be effectively avoided; the problem of data loss caused by blocking, delay and untimely reading of the application program is solved.
In this example, a preset length for reading the target sensing data may be determined according to a reading mode of the sensing data; when the sensor service layer monitors that the data stored in the storage space of the upper layer is updated, the sensor service layer reads the sensing data with the preset length in sequence from the data reading position indicated by the reading pointer of the storage space, and moves the reading pointer to the next position of the current reading position so as to facilitate the next reading.
Step S204, the service layer issues the target sensing data to the application layer;
in this example, after obtaining the target sensing data, the service layer publishes the target sensing data through the uORB interface, and an application program subscribing to the topic information of the target sensing data in the application layer receives the target sensing data through the uORB interface.
Step S205, the application layer issues a control instruction to a second type of registered sensors in the control system through a preset operation function interface; the control instruction is used for triggering the driving layer of the second type sensor to call the operation function corresponding to the operation function interface, executing the control instruction, and transmitting an execution result to the application layer through the operation function interface.
In this example, since the operation of the second type sensor is not general and the event type is uncertain, the second type sensor cannot be managed by the sensor service layer in a unified manner, and when an application program of the application layer needs to use a system call to directly access the character device node of the second type sensor, the second type sensor is controlled.
It should be noted that, for the standard type sensor, when the control of the sensor service layer cannot meet the product requirement, that is, in addition to activation, acquisition rate setting and batch processing, additional control is required for the sensor, a control command can be separately set through the control interface and set to the character device node, so that the control command is transmitted to the driving layer of the sensor, and the driving layer responds to the control command.
Exemplarily, as shown in fig. 9, fig. 9 is a third flowchart illustrating a control method according to an exemplary embodiment.
Step S301, starting a control system;
step S302, a service layer scans and opens character device files of all first-class sensors in a control system to obtain file handles;
step S303, the service layer broadcasts the subject information of the sensing data of the first type of sensor to the application layer to obtain an advertisement handle;
step S304, adding all file handles and advertisement handles into an epoll queue for monitoring;
step S305, judging the handle type of the handle, and if the handle is the advertisement handle, executing step S306; if the handle is a file handle, executing step S307;
step S306, according to the advertisement handle, the service layer controls the activation state, the sampling rate and the batch processing mode of the corresponding sensor;
and step S305, controlling the corresponding driving layer to acquire the sensing data of the sensor by the service layer according to the file handle.
In this example, the service layer manages all the first sensors in the control system in a unified way, while for the second sensor, because the operation is not general and the type of the sensing data is uncertain, the second sensor cannot be managed by the service layer in a unified way, so that the application program needs to use a system call to access the character device of the second sensor.
Since the service layer is introduced in the example to completely decouple the application layer and the driver layer of the sensor, the driver of the sensor does not need to be considered in the process of developing the application program. Next, the present example further provides a model of software algorithm development, as shown in fig. 10, and fig. 10 is a schematic diagram of a framework for application development according to an exemplary embodiment.
When the sensor uncalibrated sensing data is read by the service layer through the character device node and is published by the UORB interface, the calibration algorithm application program can obtain the uncalibrated sensing data by subscribing the subject information of the uncalibrated sensing data, and publish the calibrated sensing data after completing the calibration processing of the uncalibrated sensing data; the motion algorithm application program may obtain the calibrated sensing data and the uncalibrated sensing data by subscribing to subject information of the calibrated sensing data and subject information of the uncalibrated sensing data.
Therefore, the application layer and the driving layer of the sensor are completely decoupled by introducing the service layer, so that when the hardware of the sensor at the bottom layer is replaced, the logic of an upper algorithm and any intermediate variable do not need to be changed, the workload is reduced, and the development efficiency of the application program is improved.
The embodiment of the disclosure also provides a control device. Fig. 11 is a schematic structural diagram showing a control apparatus according to an exemplary embodiment, which is applied to a control system as shown in fig. 11, the control system including: an application layer, a service layer, and a plurality of driver layers, the control device 100 includes:
a broadcasting module 101, configured to broadcast, by the service layer, theme information of sensing data to the application layer, where different sensing data are generated by different sensors;
the first obtaining module 102 is configured to respond to a subscription request of an application layer for at least one topic information, and a service layer controls a driving layer corresponding to the at least one topic information to read target sensing data from a sensor;
the publishing module 103 is configured to publish, by the service layer, the target sensing data to the application layer.
Optionally, the driving layer comprises:
a first sub-layer, wherein different first sub-layers contain drivers for different sensors for interacting with the sensors;
and the second sub-layer is a common driving sub-layer shared by different sensors, and provides a storage space for writing sensing data by interacting with the first sub-layer.
Optionally, the storage space is an annular storage space;
after a second storage address of the annular storage space is occupied, target sensing data are written into a first storage address of the annular storage space, wherein the first storage address is a starting storage address of a storage area corresponding to the annular storage space; the second storage address is an end storage address of a storage area corresponding to the annular storage space.
Optionally, the first obtaining module 102 is configured to:
the service layer issues a control instruction to the first sublayer; the control instruction is used for triggering the first sublayer to read target sensing data from the connected sensor and writing the target sensing data into a storage space of the second sublayer; and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
Optionally, the first obtaining module 102 is configured to:
the service layer issues a parameter adjusting instruction to the first sublayer; the parameter adjusting instruction is used for triggering the first sublayer to adjust the acquisition parameters, reading target sensing data from the connected sensors based on the adjusted acquisition parameters, and writing the target sensing data into the storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
Optionally, the acquisition parameters include:
the acquisition frequency of the sensing data;
and/or the acquisition modes of the sensing data are different, wherein the preset lengths and/or the reading modes of the sensing data read from the annular storage space by the service layer corresponding to different acquisition modes are different.
Optionally, the first obtaining module 102 is further configured to:
after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer sequentially reads the sensing data with preset length in the storage space from the data reading position indicated by the reading pointer of the storage space;
and moving the read pointer to a position next to the current read position.
Optionally, the broadcasting module 101 is configured to:
the service layer acquires the type information of a registered first type sensor in the control system;
determining subject information of sensing data sensed by the first type sensor based on the type information of the first type sensor; the first type of sensor is a sensor only having a preset function;
the service layer broadcasts theme information of the sensing data sensed by the first type of sensor to the application layer.
Optionally, the apparatus further comprises: a second obtaining module to:
the application layer issues a control instruction to a second type of registered sensors in the control system through a preset operation function interface;
the control instruction is used for triggering the driving layer of the second type sensor to call the operation function corresponding to the operation function interface, executing the control instruction, and transmitting an execution result to the application layer through the operation function interface.
FIG. 12 is a block diagram illustrating a control device according to an exemplary embodiment. For example, the device 800 may be a mobile phone, a mobile computer, etc.
Referring to fig. 12, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as Wi-Fi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (12)

1. A control method is applied to a control system, and the control system comprises: an application layer, a service layer, and a plurality of driver layers, the method comprising:
the service layer broadcasts theme information of the sensing data to the application layer, wherein different sensing data are generated by different sensors;
responding to a subscription request of an application layer for at least one topic information, and controlling a driving layer corresponding to the at least one topic information to read target sensing data from a sensor by a service layer;
and the service layer issues the target sensing data to the application layer.
2. The method of claim 1, wherein the driving layer comprises:
a first sub-layer, wherein different first sub-layers contain drivers for different sensors for interacting with the sensors;
and the second sub-layer is a common driving sub-layer shared by different sensors, and provides a storage space for writing sensing data by interacting with the first sub-layer.
3. The method of claim 2, wherein the storage space is an annular storage space;
after a second storage address of the annular storage space is occupied, target sensing data are written into a first storage address of the annular storage space, wherein the first storage address is a starting storage address of a storage area corresponding to the annular storage space; the second storage address is an end storage address of a storage area corresponding to the annular storage space.
4. The method of claim 3, wherein the service layer controls a driving layer corresponding to at least one of the theme information to read the target sensing data from the sensor, and the method comprises:
the service layer issues a control instruction to the first sublayer; the control instruction is used for triggering the first sublayer to read target sensing data from the connected sensor and writing the target sensing data into a storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
5. The method of claim 3, wherein the service layer controls a driving layer corresponding to at least one of the theme information to read the target sensing data from the sensor, and the method comprises:
the service layer issues a parameter adjusting instruction to the first sublayer; the parameter adjusting instruction is used for triggering the first sublayer to adjust the acquisition parameters, reading target sensing data from the connected sensors based on the adjusted acquisition parameters, and writing the target sensing data into the storage space of the second sublayer;
and after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer acquires the target sensing data from the storage space of the second sublayer.
6. The method of claim 5, wherein the acquisition parameters comprise:
the acquisition frequency of the sensing data;
and/or the acquisition modes of the sensing data are different, wherein the preset lengths and/or the reading modes of the sensing data read from the annular storage space by the service layer corresponding to different acquisition modes are different.
7. The method according to claim 4 or 5, wherein the obtaining, by the service layer, the target sensing data from the storage space of the second sub-layer after monitoring that the data stored in the storage space of the second sub-layer is updated comprises:
after monitoring that the data stored in the storage space of the second sublayer is updated, the service layer sequentially reads the sensing data with preset length in the storage space from the data reading position indicated by the reading pointer of the storage space;
and moving the read pointer to a position next to the current read position.
8. The method of claim 1, wherein the service layer broadcasts topic information of the sensing data to the application layer, comprising:
the service layer acquires the type information of a registered first type sensor in the control system;
determining subject information of sensing data sensed by the first type sensor based on the type information of the first type sensor; the first type of sensor is a sensor only having a preset function;
the service layer broadcasts theme information of the sensing data sensed by the first type of sensor to the application layer.
9. The method of claim 8, further comprising:
the application layer issues a control instruction to a second type of registered sensors in the control system through a preset operation function interface;
the control instruction is used for triggering the driving layer of the second type sensor to call the operation function corresponding to the operation function interface, executing the control instruction, and transmitting an execution result to the application layer through the operation function interface.
10. A control device, characterized in that, applied to a control system, the control system comprises: the application layer, the service layer and the plurality of driving layers comprise:
the broadcasting module is used for broadcasting the theme information of the sensing data to the application layer by the service layer, wherein different sensing data are generated by different sensors;
the system comprises a first acquisition module, a first storage module and a first processing module, wherein the first acquisition module is used for responding to a subscription request of an application layer for at least one topic information, and a service layer controls a driving layer corresponding to the at least one topic information to read target sensing data from a sensor;
and the issuing module is used for issuing the target sensing data to the application layer by the service layer.
11. A control device, comprising:
a processor;
a memory for storing executable instructions;
wherein the processor is configured to: the control method of any one of claims 1 to 9 is implemented when executing executable instructions stored in the memory.
12. A non-transitory computer-readable storage medium in which instructions, when executed by a processor of a control apparatus, enable the control apparatus to perform the control method of any one of claims 1 to 9.
CN202111070716.5A 2021-09-13 2021-09-13 Control method, control device and storage medium Pending CN113971045A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111070716.5A CN113971045A (en) 2021-09-13 2021-09-13 Control method, control device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111070716.5A CN113971045A (en) 2021-09-13 2021-09-13 Control method, control device and storage medium

Publications (1)

Publication Number Publication Date
CN113971045A true CN113971045A (en) 2022-01-25

Family

ID=79586516

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111070716.5A Pending CN113971045A (en) 2021-09-13 2021-09-13 Control method, control device and storage medium

Country Status (1)

Country Link
CN (1) CN113971045A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114845169A (en) * 2022-04-29 2022-08-02 东风汽车有限公司东风日产乘用车公司 Play control method, play control device, play terminal, and storage medium
WO2023231837A1 (en) * 2022-05-31 2023-12-07 华为技术有限公司 Data processing method and apparatus, and device, storage medium and system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114845169A (en) * 2022-04-29 2022-08-02 东风汽车有限公司东风日产乘用车公司 Play control method, play control device, play terminal, and storage medium
CN114845169B (en) * 2022-04-29 2023-07-25 东风汽车有限公司东风日产乘用车公司 Playback control method, playback control device, playback terminal, and storage medium
WO2023231837A1 (en) * 2022-05-31 2023-12-07 华为技术有限公司 Data processing method and apparatus, and device, storage medium and system

Similar Documents

Publication Publication Date Title
EP2993584B1 (en) Method and device for controlling background application
US20150333971A1 (en) Method and device for managing processes of application program
CN113971045A (en) Control method, control device and storage medium
JP6250844B2 (en) Power consumption control method, apparatus, program, and recording medium
KR102566622B1 (en) Method, apparatus, electronic device for multi-core communication and storage medium
CN111512286A (en) Method for arranging program and electronic equipment
CN115793916A (en) Method, electronic device and system for displaying multiple windows
CN112114733B (en) Screen capturing and recording method, mobile terminal and computer storage medium
CN114339332B (en) Mobile terminal, display device and cross-network screen projection method
EP4280058A1 (en) Information display method and electronic device
EP3073371A1 (en) Method and device for loading theme application
CN105930213A (en) Application running method and apparatus
CN112527174A (en) Information processing method and electronic equipment
CN115576645B (en) Virtual processor scheduling method and device, storage medium and electronic equipment
EP3232325A1 (en) Method and device for starting application interface
EP3913457A1 (en) Lockscreen display control method and device, and storage medium
CN113593279A (en) Vehicle, interactive parameter adjusting method thereof and mobile terminal
CN113312103A (en) Software definition method and device for intelligent camera, electronic equipment and storage medium
CN114530148A (en) Control method and device and electronic equipment
CN112000932A (en) Mobile terminal and application control method thereof
CN111008050A (en) Page task execution method, device, terminal and storage medium
US10757246B2 (en) Method and apparatus for performing at least one operation based on devices context
CN114090303B (en) Software module scheduling method and device, electronic equipment, storage medium and product
CN112148499A (en) Data reporting method and device, computer equipment and medium
CN113079332B (en) Mobile terminal and screen recording method thereof

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