Sensor data collection method, apparatus, controller and system
Patent Information
- Application Number
- CN202610640614.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-09
- Publication Date
- 2026-09-01
AI Technical Summary
例如,在惯性传感器与飞行传感器共用SPI总线的硬件架构中,飞行传感器固件更新线程优先级高于惯性传感器数据采集线程,惯性传感器数据采集线程被飞行传感器固件更新线程占用通信总线后,导致惯性传感器无法再次触发中断,中断机制失效后,惯性传感器数据采集线程无法被激活
[0017]本公开提供的传感器数据采集方法,本公开提供了一种传感器数据采集方法,在数据读取过程中,数据总线被高优先级任务占用且又被高优先级任务释放使用权时,通过检测检测接收中断信号的接口的电平状态,并在检测到有效状态时重新激活数据读取线程,以恢复数据读取操作,有效解决了中断机制失效的问题,保证了传感器数据采集的完整性和连续性。
Smart Images

Figure CN122672933A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of sensor data acquisition technology, and more specifically, to a sensor data acquisition method, apparatus, controller, and system. Background Technology
[0002] As the functionality of smart wearable devices (such as smartwatches, bracelets, and rings) continues to improve, multi-sensor fusion has become a mainstream trend in the industry. The multiple sensors used in smart wearable devices typically include inertial sensors and flight sensors. The collaborative work of these two types of sensors enables rich interactive experiences.
[0003] In existing technologies, sharing a single communication bus among multiple sensors is a common hardware design approach. For example, in a hardware architecture where an inertial sensor and a flight sensor share an SPI bus, the flight sensor firmware update thread has a higher priority than the inertial sensor data acquisition thread. When the communication bus is occupied by the flight sensor firmware update thread, the inertial sensor cannot trigger an interrupt again. Once the interrupt mechanism fails, the inertial sensor data acquisition thread cannot be activated. Furthermore, the flight sensor firmware update process occupies the communication bus for an extended period, and the inertial sensor continuously acquires new data. This can lead to the loss of newly acquired data once the inertial sensor's data fill volume exceeds a threshold.
[0004] To address the aforementioned technical issues, existing technologies employ methods such as adding a communication bus arbitrator or adopting a dual-bus architecture, which are costly.
[0005] Therefore, there is a need to provide a technical solution that solves the above-mentioned technical problems without increasing hardware costs. Summary of the Invention
[0006] One objective of this invention is to provide a new technical solution for a sensor data acquisition method.
[0007] According to a first aspect of the present invention, a sensor data acquisition method is provided, comprising: If the amount of data in the data buffer of the target sensor is greater than a first preset threshold, an interrupt signal triggered by the target sensor is received, wherein the interrupt signal is used to change the level state of the interface receiving the interrupt signal from an invalid state to an active state. In response to the interrupt signal, a thread that reads data from the data buffer via the data bus is activated to perform a data read operation; During the data reading process, if the data bus is occupied by a high-priority task, the level state of the interface receiving the interrupt signal is detected after the high-priority task is completed. When the level state is valid, the thread that reads data from the data buffer is reactivated to continue the data reading operation.
[0008] Optionally, when the thread reading data from the data buffer changes from a running state to a blocked state, the target sensor is used to detect whether the amount of data in the data buffer is less than or equal to a first preset threshold. If the amount of data in the data buffer is less than or equal to the first preset threshold, the triggered interrupt signal is cleared, and the level state of the interface receiving the interrupt signal changes from an active state to an inactive state.
[0009] Optionally, if a thread reading data from the data cache is not interrupted by a high-priority task, the amount of data read by the thread reading data from the data cache is the current amount of data in the data cache, or the amount of data read by the thread reading data from the data cache is a set amount of data.
[0010] Optionally, the method further includes: when the level state is invalid, not reactivating the thread that reads data from the data buffer.
[0011] Optionally, the method further includes: during the data reading process, if an event occurs in which the data bus is occupied by a high-priority task, then during the execution of the high-priority task, monitoring the amount of data in the data buffer area; If the difference between the amount of data in the data cache and the set maximum storage amount is less than a second preset threshold, the priority of the task that reads data from the data cache is adjusted so that the priority of the task that reads data from the data cache is higher than the priority of the currently executed high-priority task. Based on the adjusted task priority, the currently executing high-priority task is interrupted, and the thread that reads data from the data buffer is reactivated to continue the data reading operation.
[0012] Optionally, the method further includes: If the difference between the amount of data in the data cache and the set maximum storage amount is greater than a third preset threshold, the priority of the task that reads data from the data cache will be adjusted again so that the priority of the task that reads data from the data cache is lower than the priority of the high-priority task. Based on the adjusted task priorities, the thread that reads data from the data cache is stopped, and the execution of high-priority tasks is resumed.
[0013] Optionally, the valid state of the level state is a high level, and the invalid state of the level state is a low level.
[0014] According to a second aspect of the present invention, a sensor data acquisition device is provided, comprising: The receiving module is used to receive an interrupt signal triggered by the target sensor when the amount of data in the data buffer of the target sensor is greater than a first preset threshold. The interrupt signal is used to change the level state of the interface receiving the interrupt signal from an invalid state to an active state. The first activation module is used to activate a thread that reads data from the data buffer via the data bus in response to the interrupt signal, so as to perform a data reading operation; The detection module is used to detect the level status of the interface receiving the interrupt signal after the high-priority task is completed if the data bus is occupied by a high-priority task during the data reading process. The activation module is used to reactivate the thread that reads data from the data buffer when the level state is valid, so as to continue the data reading operation.
[0015] According to a third aspect of the invention, a controller is provided, including a memory and a processor, the memory storing a computer program for controlling the processor to operate in order to perform the method according to any one of the first aspects.
[0016] According to a fourth aspect of the present invention, a sensor data acquisition system is provided, comprising: a sensor data acquisition device as described in the second aspect or a controller and a target sensor as described in the third aspect.
[0017] The sensor data acquisition method disclosed herein provides a method that, during the data reading process, when the data bus is occupied by a high-priority task and then released by the high-priority task, detects the level state of the interface receiving the interrupt signal, and reactivates the data reading thread when a valid state is detected, thereby resuming the data reading operation. This effectively solves the problem of interrupt mechanism failure and ensures the integrity and continuity of sensor data acquisition.
[0018] The features and advantages of the embodiments of this specification will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0019] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments of this specification and, together with their description, serve to explain the principles of these embodiments.
[0020] Figure 1 This is a schematic diagram of the hardware structure of a sensor data acquisition system according to an embodiment of the present invention.
[0021] Figure 2 This is a schematic flowchart of a sensor data acquisition method according to an embodiment of the present invention.
[0022] Figure 3 This is a schematic block diagram of a sensor data acquisition device according to an embodiment of the present invention.
[0023] Figure 4 This is a schematic diagram of the controller according to an embodiment of the present invention. Detailed Implementation
[0024] Various exemplary embodiments of this specification will now be described in detail with reference to the accompanying drawings.
[0025] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the embodiments of this specification or their application or use.
[0026] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0027] To address the aforementioned technical issues, this disclosure provides a sensor data acquisition method. During data reading, when the data bus is occupied by a high-priority task and then released by the same high-priority task, the method detects the level of the interface receiving the interrupt signal and reactivates the data reading thread when a valid state is detected, thereby resuming the data reading operation. This effectively solves the problem of interrupt mechanism failure and ensures the integrity and continuity of sensor data acquisition.
[0028] One embodiment of the present invention provides a sensor data acquisition method. Figure 1 This is a schematic diagram of the hardware structure of a sensor data acquisition system that can apply the methods provided in the embodiments of this disclosure. Figure 1 As shown, the system includes a controller 110 and a target sensor 120. The controller 120 reads data collected by the target sensor via a data bus. The data bus can be an SPI bus. Figure 1 As shown, the data bus is a shared data bus, with the target sensor 120 and other sensors 130 sharing the same data bus to achieve communication with the controller 110. This reduces hardware costs and PCB layout complexity.
[0029] The target sensor 120 has a built-in data buffer for storing data collected by the target sensor 120. This data buffer is implemented using a FIFO structure. In a FIFO structure, new data is written from the tail of the queue, and old data is read from the head of the queue. When the amount of data in the data buffer exceeds a first preset threshold, the target sensor 120... Figure 1 The INT pin shown outputs an interrupt signal, and the controller 110 communicates with it via... Figure 1 The shown I / O interface receives interrupt signals.
[0030] In some embodiments, the target sensor 120 can be an inertial sensor, including an accelerometer and a gyroscope, for real-time acquisition of motion pose data. The accelerometer is used to measure triaxial linear acceleration, and the gyroscope is used to measure triaxial angular velocity. The inertial sensor's built-in data buffer can receive data acquired by the accelerometer and gyroscope in real time. When the amount of data in the data buffer exceeds a first preset threshold, the inertial sensor outputs an interrupt signal through an interrupt pin. Other sensors 130 can be time-of-flight sensors for distance measurement or gesture recognition. The flight sensor needs to perform firmware updates via a shared data bus during system initialization. The priority of firmware updates for the flight sensor is higher than the priority of reading data from the inertial sensor's built-in data buffer. If a firmware update event occurs during the process of the controller 110 reading data from the inertial sensor's built-in data buffer, the operation of reading data from the inertial sensor's built-in data buffer via the data bus is interrupted, and the firmware update operation is performed via the data bus.
[0031] according to Figure 2 As shown, the sensor data processing method provided in this embodiment includes the following steps S210 to S240.
[0032] Step S210: When the amount of data in the data buffer of the target sensor is greater than the first preset threshold, an interrupt signal triggered by the target sensor is received, wherein the interrupt signal is used to change the level state of the interface receiving the interrupt signal from an invalid state to an active state.
[0033] The maximum storage capacity of the data buffer is set to N data points, and the first preset threshold is set to M data points, where M is less than N. For example, the maximum storage capacity N of the data buffer is set to 30 data points, and the first preset threshold M is set to 10 data points. When the data buffer contains 10 data points, the target sensor 120 outputs an interrupt signal to the controller 110 via an interrupt pin. After receiving the interrupt signal, the controller 110 changes the level state of the interface receiving the interrupt signal from an invalid state to an active state. In some embodiments, the invalid state corresponds to a low level, and the active state corresponds to a high level.
[0034] In step S220, in response to an interrupt signal, a thread that reads data from the data buffer via the data bus is activated to perform a data read operation.
[0035] When controller 110 detects that the voltage level of the corresponding interface has changed from invalid to valid, it sends a semaphore to activate the data read thread. This data read thread then transitions from a blocked state to a running state. Controller 110 reads data from the head of the data buffer queue via the data bus.
[0036] In some embodiments, if a thread reading data from the data buffer is not interrupted by a high-priority task, the amount of data read by the thread reading data from the data buffer is the current amount of data in the data buffer, or the amount of data read by the thread reading data from the data buffer is a set amount of data.
[0037] The controller 110 can obtain the current amount of data in the data buffer through the data bus.
[0038] Set the data volume to a fixed value, for example, set the data volume to be less than or equal to a first preset threshold.
[0039] Step S230: If, during the data reading process, an event occurs where the data bus is occupied by a high-priority task, then after the high-priority task is completed, the level state of the interface receiving the interrupt signal is detected.
[0040] High-priority tasks and data reading threads share the data bus. During data reading, if the data bus is occupied by a high-priority task, the data reading thread, with its lower priority, will be unable to use the data bus. Once firmware data transmission is complete using the data bus, the right to use the data bus is released.
[0041] When a thread reading data from the data buffer completes its current data read operation, or when it is interrupted by a higher-priority task, the thread changes from a running state to a blocked state. When the thread changing from a running state to a blocked state detects whether the amount of data in the data buffer is less than or equal to a first preset threshold, the interrupt signal is cleared if the amount of data in the data buffer is less than or equal to the first preset threshold. If the amount of data in the data buffer is greater than the first preset threshold, the interrupt signal clearing condition is not met, and the interrupt signal remains active.
[0042] It should be noted that when the thread reading data from the data buffer is running, the target sensor does not perform the operation of detecting whether the amount of data in the data buffer is less than or equal to the first preset threshold.
[0043] Because data in the data buffer may be written while it is being read, the amount of data in the data buffer may still exceed the first preset threshold when the data reading thread is interrupted. Thus, if the amount of data in the data buffer exceeds the first preset threshold when the data reading thread is interrupted, it indicates that the interrupt signal persists, causing the voltage level of the interface receiving the interrupt signal to remain in a valid state and unable to return to an invalid state. This prevents the controller from detecting new voltage level transitions, a state known as interrupt deadlock, which in turn prevents the data reading thread from executing again. Therefore, in this embodiment, after a high-priority task is completed, the voltage level of the interface receiving the interrupt signal is immediately checked to determine whether the amount of data in the data buffer exceeds the first preset threshold.
[0044] In step S240, if the level state is valid, the thread that reads data from the data buffer is reactivated to continue the data reading operation.
[0045] When the voltage level is active, indicating that the amount of data in the data buffer is still greater than the first preset threshold, the controller reactivates the thread that reads data from the data buffer to continue the data reading operation. The amount of data read by the reactivated thread is the current amount of data in the data buffer, or the amount of data read by the thread that reads data from the data buffer is a set amount.
[0046] When the level is in an invalid state, it indicates that the amount of data in the data buffer is less than or equal to the first preset threshold, and the thread for reading data from the data buffer will not be reactivated. When the amount of data in the target sensor's data buffer is greater than the first preset threshold, the controller receives an interrupt signal triggered by the target sensor and reactivates the thread for reading data from the data buffer.
[0047] During the execution of high-priority tasks, the target sensor's data storage area continuously stores the data it collects, and the amount of data in the data storage area continues to increase. When the amount of data in the data storage area reaches its maximum storage capacity, the new data collected by the target sensor cannot be stored in the data storage area, resulting in the loss of data collected by the target sensor during this period.
[0048] To address this technical problem, in some embodiments, the method further includes: during data reading, if an event occurs where the data bus is occupied by a high-priority task, and during the execution of the high-priority task, monitoring the amount of data in the data buffer; if the difference between the amount of data in the data buffer and the set maximum storage amount is less than a second preset threshold, adjusting the priority of the task reading data from the data buffer so that the priority of the task reading data from the data buffer is higher than the priority of the currently executing high-priority task; based on the adjusted task priority, interrupting the currently executing high-priority task and reactivating the thread reading data from the data buffer to continue executing the data reading operation.
[0049] The target sensor has a built-in status register that records the current amount of data in the data buffer. The controller reads the value of the status register through the data bus to obtain the real-time amount of data stored in the data buffer. During periods when a high-priority task occupies the data bus, the controller can read the status register value during the brief intervals when the high-priority task releases the data bus.
[0050] If the difference between the amount of data in the data cache and the set maximum storage amount is less than the second preset threshold, it indicates that the data cache is about to overflow. The priority of the task that reads data from the data cache is adjusted so that the priority of the task that reads data from the data cache is higher than the priority of the currently executing task.
[0051] In this embodiment, the method further includes: when the difference between the amount of data in the data cache and the set maximum storage amount is greater than a third preset threshold, adjusting the priority of the task that reads data from the data cache again, so that the priority of the task that reads data from the data cache is lower than the priority of the high-priority task; based on the adjusted task priority, stopping the thread that reads data from the data cache and resuming the execution of the high-priority task.
[0052] During the continued data reading operation, the controller can also read the value of the status register through the data bus to obtain the real-time data volume stored in the data buffer. If the difference between the data volume in the data buffer and the set maximum storage volume is greater than the third preset threshold, it indicates that the risk of data buffer overflow has been eliminated. The priority of the task reading data from the data buffer is then adjusted so that the priority of the task reading data from the data buffer is lower than the priority of the higher priority task.
[0053] The second and third preset thresholds can be set according to the maximum storage capacity of the data cache.
[0054] By adjusting task priorities, the controller can promptly increase the priority of data reading tasks when the data buffer is about to overflow, interrupting the currently executing task and proceeding to read data from the data buffer to prevent data overflow. Once the risk of data buffer overflow has been eliminated, the original task priority configuration is restored to ensure the normal execution of the currently executing task.
[0055] One embodiment of the present invention provides a sensor data acquisition device. According to... Figure 3 As shown, the sensor data acquisition device includes a receiving module 310, a first activation module 320, a detection module 330, and a second activation module 340.
[0056] The receiving module 310 is used to receive an interrupt signal triggered by the target sensor when the amount of data in the data buffer of the target sensor is greater than a first preset threshold. The interrupt signal is used to change the level state of the interface receiving the interrupt signal from an invalid state to an active state.
[0057] The first activation module 320 is used to activate a thread that reads data from the data buffer via the data bus in response to an interrupt signal, so as to perform a data reading operation.
[0058] The detection module 330 is used to detect the level status of the interface receiving the interrupt signal after the high-priority task is completed if an event occurs during the data reading process where the data bus is occupied by a high-priority task.
[0059] The second activation module 340 is used to reactivate the thread that reads data from the data buffer when the level state is valid, so as to continue to perform the data reading operation.
[0060] In some embodiments, when the thread reading data from the data buffer changes from a running state to a blocked state, the target sensor is used to detect whether the amount of data in the data buffer is less than or equal to a first preset threshold. If the amount of data in the data buffer is less than or equal to the first preset threshold, the triggered interrupt signal is cleared, and the level state of the interface receiving the interrupt signal changes from an active state to an inactive state.
[0061] In some embodiments, if a thread reading data from the data buffer is not interrupted by a high-priority task, the amount of data read by the thread reading data from the data buffer is the current amount of data in the data buffer, or the amount of data read by the thread reading data from the data buffer is a set amount of data.
[0062] In some embodiments, the device further includes a data read stop module. The data read stop module is used to prevent the thread reading data from the data buffer from being reactivated when the level state is invalid.
[0063] In some embodiments, the device further includes a priority adjustment module.
[0064] The priority adjustment module is used to monitor the amount of data in the data buffer during the data reading process when an event occurs where the data bus is occupied by a high-priority task. If the difference between the amount of data in the data buffer and the set maximum storage capacity is less than a second preset threshold, the priority of the task reading data from the data buffer is adjusted so that the priority of the task reading data from the data buffer is higher than the priority of the currently executing high-priority task. Based on the adjusted task priority, the currently executing high-priority task is interrupted, and the thread reading data from the data buffer is reactivated to continue the data reading operation.
[0065] In some embodiments, the priority adjustment module is further configured to adjust the priority of the task that reads data from the data cache again when the difference between the amount of data in the data cache and the set maximum storage amount is greater than a third preset threshold, so that the priority of the task that reads data from the data cache is lower than the priority of the high-priority task; based on the adjusted task priority, stop the thread that reads data from the data cache and resume the execution of the high-priority task.
[0066] In some embodiments, the valid state of the level state is a high level, and the invalid state of the level state is a low level.
[0067] One embodiment of the present invention provides a controller. According to... Figure 4 As shown, the controller includes a memory 420 and a processor 410. The memory 420 stores a computer program that controls the processor 410 to operate and execute the sensor data acquisition method provided according to the corresponding embodiment described above.
[0068] The processor 410 is used to execute computer instructions, which can be written using instruction sets of architectures such as x86, Arm, RISC, MIPS, and SSE. The memory 420 includes, for example, ROM (Read-Only Memory), RAM (Random Access Memory), and non-volatile memory such as a hard disk, etc., and is not limited thereto.
[0069] One embodiment of the present invention provides a sensor data acquisition system, including a sensor data acquisition device as provided in the above embodiments, or a controller and a target sensor as provided in the above embodiments. See details. Figure 1 I won't go into too much detail here.
[0070] One embodiment of the present invention provides a non-volatile computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, implement the sensor data acquisition method provided in any of the above embodiments.
[0071] This invention can be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of the invention.
[0072] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example, but not limited to, electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0073] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0074] The computer program instructions used to perform the operations of this invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), are personalized by utilizing state information from computer-readable program instructions. These electronic circuits can execute computer-readable program instructions to implement various aspects of the present invention.
[0075] Various aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0076] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0077] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0078] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. It will be known to those skilled in the art that implementation in hardware, implementation in software, and implementation using a combination of software and hardware are equivalent.
[0079] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein. The scope of the invention is defined by the appended claims.
Claims
1. A sensor data acquisition method, characterized in that, If the amount of data in the data buffer of the target sensor is greater than a first preset threshold, an interrupt signal triggered by the target sensor is received, wherein the interrupt signal is used to change the level state of the interface receiving the interrupt signal from an invalid state to an active state. In response to the interrupt signal, a thread that reads data from the data buffer via the data bus is activated to perform a data read operation; During the data reading process, if the data bus is occupied by a high-priority task, the level state of the interface receiving the interrupt signal is detected after the high-priority task is completed. When the level state is valid, the thread that reads data from the data buffer is reactivated to continue the data reading operation.
2. The method according to claim 1, characterized in that, When a thread reading data from the data buffer changes from a running state to a blocked state, the target sensor detects whether the amount of data in the data buffer is less than or equal to a first preset threshold. If the amount of data in the data buffer is less than or equal to the first preset threshold, the triggered interrupt signal is cleared, and the level state of the interface receiving the interrupt signal changes from an active state to an inactive state.
3. The method according to claim 1, characterized in that, If a thread reading data from the data cache is not interrupted by a high-priority task, the amount of data read by the thread reading data from the data cache is the current amount of data in the data cache, or the amount of data read by the thread reading data from the data cache is a set amount of data.
4. The method according to claim 1, characterized in that, The method further includes: If the level state is invalid, the thread that reads data from the data buffer will not be reactivated.
5. The method according to claim 1, characterized in that, The method further includes: If, during the data reading process, the data bus is occupied by a high-priority task, the amount of data in the data buffer is monitored during the execution of the high-priority task. If the difference between the amount of data in the data cache and the set maximum storage amount is less than a second preset threshold, the priority of the task that reads data from the data cache is adjusted so that the priority of the task that reads data from the data cache is higher than the priority of the currently executed high-priority task. Based on the adjusted task priority, the currently executing high-priority task is interrupted, and the thread that reads data from the data buffer is reactivated to continue the data reading operation.
6. The method according to claim 5, characterized in that, The method further includes: If the difference between the amount of data in the data cache and the set maximum storage amount is greater than a third preset threshold, the priority of the task that reads data from the data cache will be adjusted again so that the priority of the task that reads data from the data cache is lower than the priority of the high-priority task. Based on the adjusted task priority, the thread that reads data from the data cache is stopped, and the execution of the high-priority task is resumed.
7. The method according to claim 1, characterized in that, The valid state of the level is a high level, and the invalid state of the level is a low level.
8. A sensor data acquisition device, characterized in that, include: The receiving module is used to receive an interrupt signal triggered by the target sensor when the amount of data in the data buffer of the target sensor is greater than a first preset threshold. The interrupt signal is used to change the level state of the interface receiving the interrupt signal from an invalid state to an active state. The first activation module is used to activate a thread that reads data from the data buffer via the data bus in response to the interrupt signal, so as to perform a data reading operation; The detection module is used to detect the level status of the interface receiving the interrupt signal after the high-priority task is completed if the data bus is occupied by a high-priority task during the data reading process. The second activation module is used to reactivate the thread that reads data from the data buffer when the level state is valid, so as to continue to perform the data reading operation.
9. A controller, characterized in that, It includes a memory and a processor, the memory storing a computer program for controlling the processor to operate in order to perform the method according to any one of claims 1 to 7.
10. A sensor data acquisition system, characterized in that, include: The sensor data acquisition device as described in claim 8, or the controller and target sensor as described in claim 9.