Batching sensor results

Edge Impulse BYOM:边缘AI模型部署的确定性实践指南 边缘AI部署长期面临算法、嵌入式与硬件三重割裂,导致模型落地周期长、性能不可预测、调试依赖示波器等硬工具。其本质是缺乏对算子级硬件行为的可观测性与可控制性。基于ONNX模型封装、硬件感知编译与部署抽象三层解耦架构,现代边缘AI平台正将‘模型即接口’变为现实——通过声明式硬件约束(如ram_budget_kb、target_hardware)驱动自动优化,并输出带汇编级映射的性能报告。这不仅提升部署效率,更赋予工程师对延迟、内存、功耗的确定性掌控力,支撑工业预测、可穿戴生物信号、语音唤醒等实时敏感场景的量产闭 阅读详情



原文:http://source.android.com/devices/sensors/batching.html

Why batch?


This page presents the specificities of Batch mode and the expected behaviors of sensors while in batch mode. Batching can enable significant power savings by preventing the application processor from waking up to receive each event. Instead, these events can be grouped and processed together.

batch(int handle, int flags, int64_t period_ns, int64_t max_report_latency)


Enabling batch mode for a given sensor sets the delay between events. max_report_latency sets the maximum time by which events can be delayed and batched together before being reported to the applications. A value of zero disables batch mode for the given sensor. The period_ns parameter is equivalent to calling setDelay() -- this function both enables or disables the batch mode AND sets the event's period in nanoseconds. See setDelay() for a detailed explanation of the period_ns parameter.

In non-batch mode, all sensor events must be reported as soon as they are detected. For example, an accelerometer activated at 50Hz will trigger interrupts 50 times per second.
While in batch mode, sensor events do not need to be reported as soon as they are detected. They can be temporarily stored and reported in batches, as long as no event is delayed by more thanmaxReportingLatency nanoseconds. That is, all events since the previous batch are recorded and returned at once. This reduces the amount of interrupts sent to the SoC and allows the SoC to switch to a lower power mode (idle) while the sensor is capturing and batching data.

setDelay() is not affected and it behaves as usual. 

Each event has a timestamp associated with it. The timestamp must be accurate and correspond to the time at which the event physically happened.

Batching does not modify the behavior of poll(): batches from different sensors can be interleaved and split. As usual, all events from the same sensor are time-ordered.

Behavior outside of suspend mode


These are the power modes of the application processor: on, idle, and suspend. The sensors behave differently in each of these modes. As you would imagine, on mode is when the application processor is running. Idle mode is a medium power mode where the application processor is powered but doesn't perform any tasks. Suspend is a low-power mode where the application processor is not powered. The power consumption of the device in this mode is usually 100 times less than in the On mode.

When the SoC is awake (not in suspend mode), events must be reported in batches at least every maxReportingLatency. No event shall be dropped or lost. If internal hardware FIFOs fill up before the maxReportingLatency, then events are reported at that point to ensure no event is lost.

Normal behavior in suspend mode


By default, batch mode doesn't significantly change the interaction with suspend mode. That is, sensors must continue to allow the SoC to go into suspend mode and sensors must stay active to fill their internal FIFO. In this mode, when the FIFO fills up, it shall wrap around and behave like a circular buffer, overwriting older events.

As soon as the SoC comes out of suspend mode, a batch is produced with as much as the recent history as possible, and batch operation resumes as usual.

The behavior described above allows applications to record the recent history of a set of sensor types while keeping the SoC in suspend. It also allows the hardware to not have to rely on a wake-up interrupt line.

WAKE_UPON_FIFO_FULL behavior in suspend mode


There are cases, however, where an application cannot afford to lose any events, even when the device goes into suspend mode.

For a given rate, if a sensor has the capability to store at least 10 seconds worth of events in its FIFO and is able to wake up the SoC, it can implement an optional secondary mode: the WAKE_UPON_FIFO_FULL mode.

The caller will set the SENSORS_BATCH_WAKE_UPON_FIFO_FULL flag to activate this mode. If the sensor does not support this mode, batch() will fail when the flag is set.

In batch mode, and only when the flag SENSORS_BATCH_WAKE_UPON_FIFO_FULL is set and supported, the specified sensor must be able to wake-up the SoC and be able to buffer at least 10 seconds worth of the requested sensor events.

When running with the WAKE_UPON_FIFO_FULL flag set, no events can be lost. When the FIFO is getting full, the sensor must wake up the SoC from suspend and return a batch before the FIFO fills-up.

Depending on the device, it might take a few milliseconds for the SoC to entirely come out of suspend and start flushing the FIFO. Enough head room must be allocated in the FIFO to allow the device to entirely come out of suspend without the FIFO overflowing (no events shall be lost).

Implementing the WAKE_UPON_FIFO_FULL mode is optional. If the hardware cannot support this mode, or if the physical FIFO is so small that the device would never be allowed to go into suspend for at least 10 seconds, then this function must fail when the flag SENSORS_BATCH_WAKE_UPON_FIFO_FULL is set, regardless of the value of the maxReportingLatency parameter.

Implementing batching


Batch mode, if supported, should happen at the hardware level, typically using hardware FIFOs. In particular, it SHALL NOT be implemented in the HAL, as this would be counter productive. The goal here is to save significant amounts of power. Batching should be implemented without the aid of the SoC, which should be allowed to be in suspend mode during batching.

In some implementations, events from several sensors can share the same physical FIFO. In that case, all events in the FIFO can be sent and processed by the HAL as soon as one batch must be reported.

For example, if the following sensors are activated:

  • accelerometer batched with maxReportingLatency = 20s
  • gyroscope batched with maxReportingLatency = 5s

Then the accelerometer batches can be reported at the same time the gyroscope batches are reported (every 5 seconds).

Batch mode can be enabled or disabled at any time, in particular while the specified sensor is already enabled; and this shall not result in the loss of events.

FiFo allocation priority


On platforms in which hardware FIFO size is limited, the system designers may have to choose how much FIFO to reserve for each sensor. To help with this choice, here is a list of applications made possible when batching is implemented on the different sensors.

High value: Low power pedestrian dead reckoning
Target batching time: 20 seconds to 1 minute
Sensors to batch:
- Step detector
- Rotation vector or game rotation vector at 5Hz
Gives us step and heading while letting the SoC go to Suspend.

High value: Medium power activity/gesture recognition
Target batching time: 3 seconds
Sensors to batch: accelerometer between 20Hz and 50Hz
Allows recognizing arbitrary activities and gestures without having
to keep the SoC fully awake while the data is collected.

Medium-high value: Interrupt load reduction
Target batching time: < 1 second
Sensors to batch: any high frequency sensor.
If the gyroscope is set at 240Hz, even batching just 10 gyro events can
reduce the number of interrupts from 240/second to 24/second.

Medium value: Continuous low frequency data collection
Target batching time: > 1 minute
Sensors to batch: barometer, humidity sensor, other low frequency
sensors.
Allows creating monitoring applications at low power.

Medium value: Continuous full-sensors collection
Target batching time: > 1 minute
Sensors to batch: all, at high frequencies
Allows full collection of sensor data while leaving the SoC in
suspend mode. Only to consider if fifo space is not an issue.

In each of the cases above, if WAKE_UPON_FIFO_FULL is implemented, the
applications might decide to let the SoC go to suspend, allowing for even
more power savings.

Dry run


If the flag SENSORS_BATCH_DRY_RUN is set, this function returns without modifying the batch mode or the event period and has no side effects, but returns errors as usual (as it would if this flag was not set). This flag is used to check if batch mode is available for a given configuration, in particular for a given sensor at a given rate.

Return values


Because sensors must be independent, the return value must not depend on the state of the system (whether another sensor is on or not), nor on whether the flag SENSORS_BATCH_DRY_RUN is set (in other words, if a batch call with SENSORS_BATCH_DRY_RUN is successful, the same call without SENSORS_BATCH_DRY_RUNmust succeed as well).

If successful, 0 is returned.

If the specified sensor doesn't support batch mode, -EINVAL is returned.
If the specified sensor's trigger-mode is one-shot, -EINVAL is returned.

If WAKE UPON FIFO_FULL is specified and the specified sensor's internal FIFO is too small to store at least 10 seconds worth of data at the given rate, -EINVAL is returned. Note that as stated above, this has to be determined at compile time and not based on the state of the system.

If some other constraints above cannot be satisfied, -EINVAL is returned.

Note: The maxReportingLatency parameter when > 0 has no impact on whether this function succeeds or fails.

If maxReportingLatency is set to 0, this function must succeed.

Supporting documentation


Developer - Location and Sensors APIs

Developer - Sensors Overview

Sensors SDK API reference

Android Hardware Abstraction Layer - sensors.h

SensorManager


Sensor系列之Sensor HAL层数据获取,基于Qualcomm平台 前面我们分析了Android Sensor HAL层源码分析(基于Qualcomm平台),该篇博文主要讲解了Sensor HAL的初始化,以及hal层是怎样获取所有sensor列表的。今天我们来进一步了解下sensor hal层的数据获取流程。我们知道Native层SensorService启动后,会进入我们的treadLoop方法:bool SensorService::threadLoop()... 阅读详情

相关推荐

【信息科学与工程学】计算机科学与自动化 第二百三十三篇 凤凰架构01

编号类型领域系统软件/硬件或系统集成方案及系统架构模块子模块函数名称/算法名称算法的数学分析及计算机体系架构及数据结构与算法详细设计及参数列表及数值范围设计关联知识1共识算法分布式基石状态机复制架构:Proposer/Acceptor/Learner 多节点角色模型,基于操作转移(Operation Transfer)分布式共识PaxosPaxos 协议(Prepare/Promise/Accept/Accepted 两阶段)数学基础:多数派(Quorum)投票,基于鸽巢原理保证 W+R>N 时读写集合必有

weixin_49199313的博客 269

Android 源码分析 - 传感器 - 流程

服务创建过程 SensorService::onFirstRef SensorDevice::getInstance new SensorDevice hw_get_module sensors_open_1 mSensorModule->get_sensors_list dev.getSensorList mSensorModule->get_sensors_list foreach list registerSensor(..

luansxx的专栏 1269

【信息科学与工程学】计算机科学与自动化—第十五篇 云计算 11 算法篇01

编号类型领域问题问题的数学分析(含几何学/拓扑学/代数学/数论/集合论/离散数学/概率论/统计学/其他)及数值分析及算法分析及参数列表及参数数值设计C/C++/rust/python代码软件(含编译器)及硬件资源需求(CPU/GPU/内存【NAND/DRAM/HBM/其他】/HBM、HDD、SSD、RAID卡、其他)关联知识1工作负载调度数据中心最小化总完成时间/成本。

weixin_49199313的博客 226

Google Android Sensor -- 002 -- 报告模式

文章目录报告模式连续模式变化模式单次模式特殊模式 说明:Sensor 系列文章请参考 Android Sensor。此篇搬运自 android官方网站 report-modes 。 报告模式 传感器可以不同的方式(称为报告模式)生成事件;每种传感器类型有且仅有一个与之关联的报告模式。共有 4 种报告模式。   连续模式 以传递给 batch 函数的 sampling_period_ns 参数所...

Change The World 566

【信息科学与工程学】【数据中心】第三十五篇 云计算数据中心的学科知识04

编号学科(课程)核心知识点在云计算/云存储/云网络/云安全/云MaaS中的作用代表教材/资料/论文 + 数学方程式列表工业界应用D1421​云原生数据库:TiDB​HTAP(混合事务/分析处理)、分布式SQL、水平扩展、强一致(Raft)、自动故障恢复、与MySQL兼容、TiFlash列式引擎提供弹性扩展的分布式数据库;支撑高并发在线交易与实时分析教材:《TiDB in Action》PingCAP(2020) 论文:《TiDB: A Raft-based HTAP Database》(2017)

weixin_49199313的博客 419

SensorTest

其中包括光照,加速度,方向等传感器的简单案例,仅供参考

android-5.0 sensor框架简介

Android Sensor 主要包括3 大部分,各个部分的主要功能如下: Application Framework 这一部分主要包括Sensor Manager,功能是为Application提供 Java API接口,以便Application可以开启所需的 Sensor 并获取数据。 Libraries 这一部分主要有Sens

1993

Qt开发实战:QWebEngineView缓存路径详解与自定义配置(Windows/Linux)

本文详细解析了Qt框架中QWebEngineView组件的缓存机制,提供了Windows和Linux系统下的默认缓存路径及自定义配置方案。通过实战代码示例,展示了如何实现跨平台缓存路径管理、权限设置以及企业级应用中的多用户隔离策略,帮助开发者有效管理Web内容缓存,提升应用性能和数据安全性。

weixin_42519826的博客 404

Android Sensor 传感器总结

ref:https://www.jianshu.com/p/8440a5897944 https://developer.android.google.cn/guide/topics/sensors/ Android Sensor Framework 概览 关于Android 传感器坐标与读数的进一步讨论 1. 传感器分类 Android平台支持三个大类的传感器 Motion sensors(运动传感器) 这些传感器测量加速力,并沿三个轴的旋转力。此类别包括加速度计,重力感应器, 陀螺仪和旋转

hjwang1的专栏 5711

V.PhyloMaker实战:从物种列表到维管束植物系统发育树的完整流程

本文详细介绍了使用V.PhyloMaker工具包,从物种列表快速构建维管束植物系统发育树的完整实战流程。内容涵盖R包安装、物种名标准化、核心函数phylo.maker的三种构建方案选择、结果树的可视化与导出,以及与picante包的联动分析,为生态学和生物地理学研究提供了高效解决方案。

weixin_29057237的博客 379

CDD数据库文件制作(三)——服务配置(0x10)

根据诊断调查表进行每一步配置的详细操作,与背后逻辑解释 1.会话切换配置 1.1.根据诊断调查表进行信息提取(0x1001) 1.2.会话转换配置(0x1001) 1.3.根据诊断调查表进行信息提取(0x1002) 1.4.会话转换配置(0x1002) 1.5.根据诊断调查表进行信息提取(0x1003) 1.6.会话转换配置(0x1003) 1.7.会话切换配置完成后效果图 2.安全等级配置信息提取 2.1.安全访问配置(0x1001) 2.2.安全访问配置(0x1002) 2.3.安全访问配置(0x100

LOVE135149的博客 5841

CTS Verifier apk 测试失败Sensor Batching test failed(关于时间戳的问题)

标题:android5.1 CTS 测试失败 测试环境:使用CTS Verifier apk 测试失败 上层分析: 经过代码分析和本地调试,发现底层上传的event.timestamp上传的是当前绝对时间,而CTS中的low和up对应的范围是SystemClock.elapsedRealtimeNanos(),故使得eventTimestampNs大于upperThresholdNs而满

Yasin Lee 6301

大数据领域数据服务的数据分析工具推荐

你有没有过这样的经历?——领导说“帮我分析一下上个月的销量”,你打开Excel却发现数据有100万行,电脑直接卡死;或者想实时知道“现在直播间的观众在买什么”,却不知道用什么工具处理每秒10万条的点击数据。本文的目的:帮你解决“选什么工具做什么事”的问题,覆盖大数据服务的全流程(采集→存储→处理→分析→可视化),推荐高频、实用、易上手的工具,并讲清楚它们的“适用场景”和“优缺点”。范围。

大数据洞察的博客 1932

Android Senor Framework (三)SensorService启动

SystemServer 启动SensorService Zygote启动之后,调用SystemServer的main方法(调用run方法)启动系统服务; 代码路径: ./frameworks/base/services/java/com/android/server/SystemServer.java SystemServer类中提供的run 方法中,在启动service之前,会加载本地动态库System.loadLibrary(“android_servers”)初始化本地 Native servic

null 999

在 ABAP 中把变量一次写对:深入理解 FINAL 内联声明与不可变变量

摘要:ABAP中的FINAL声明操作符用于定义不可变变量,强调"当前上下文中的唯一写位置",能有效防止变量被意外修改,提升代码健壮性和可读性。官方建议优先在单次赋值的场景使用FINAL替代DATA。其核心规则包括:1)写位置唯一但可多次执行(如循环内);2)不创建块级作用域;3)对引用变量仅约束引用本身而非对象内容。典型适用场景包括:结果值只读、输入快照保存和中间结果保护。例外情况如游标变量不适用,因需多次写操作。正确使用FINAL可显著降低代码维护风险。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1048

【深度学习|语义分割之UNet】如何使用ResNet50 作为 U-Net 网络的骨干网络(backbone)并使用预训练的 ResNet50 模型。附代码及解读。

【深度学习|语义分割之UNet】如何使用ResNet50 作为 U-Net 网络的骨干网络(backbone)并使用预训练的 ResNet50 模型。附代码及解读。

985小水博的摸鱼日常 3091

SensorService启动

SensorService启动 SystemServer进程启动SensorService 系统启动system_server进程,SystemServer.java 负责启动 startSensorService() frameworks/base/services/java/com/android/server/SystemServer.java system_server进程启动 new SystemServer().run() private void run() { /

许浑的博客 2995

YOLO模型部署RK3588多核NPU并行加速完整教程:基于线程池的高性能AI推理实现

本教程详细介绍了如何在RK3588平台上实现多核NPU并行加速的AI推理方案。RK3588搭载3个独立NPU核心,总算力达6TOPS,支持单核、双核和三核三种工作模式。文章深入解析了NPU硬件架构特点,包括核心独立处理能力、内存带宽分配及多核心协作机制,并提供了C++代码示例展示核心负载均衡、任务调度和内存优化策略。通过线程池技术可以有效利用多核NPU并行计算能力,显著提升AI推理性能,特别适合高并发场景。教程还包含内存子系统的瓶颈分析和性能预估方法,为开发者提供完整的优化思路。

LXY_LOVE36的博客 798

Android GMS认证 CTS测试中 CtsSensorTestCases#android.hardware.cts.SingleSensorTests#testAccelerometer_1hz

CtsSensorTestCases#android.hardware.cts.SingleSensorTests#testAccelerometer_1hz测试失败: junit.framework.AssertionFailedError: VerifySensorOperation | sensor='LSM6DS3 Accelerometer', samplingPeriod=10000...

u010047204的专栏 2576

【NVMEM子系统】二、NVMEM驱动框架

该子系统整体架构不算太大,还是比较容易去理解的,下面我们一起去一探究竟!,该子系统主要用于实现EEPROMEfuse等非易失存储器的统一管理。在早期,像EEPROM驱动是存放于目录下,由于没有做到好的抽象,每次需要去访问相应内存空间,都需要去复制几乎一样的代码,去注册sysfs,这是一个相当大的抽象泄露。NVMEM子系统就是为了解决以往的抽象泄露问题。

Donge's Blog 1715

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

CTS Sensor Batching Test

这个刚开始把手机放到一个平面上测试,发现测试不通过: 02-17 12:40:43 I/20160202154441: android.hardware.cts.SensorTest#testBatchAndFlush FAIL  junit.framework.AssertionFailedError: WaitForEvents | sensor='Memsic MXC622X 3

wangjicong_215的博客 2900

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

SensorService流程分析

SensorService是用来管理底层sensor的服务; 首先来看下它的启动,在SystemServer中的run()中有: // Initialize native services. System.loadLibrary("android_servers"); nativeInit();static void android_server_SystemServer_na

Kent的博客 2670

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

android 7.1 屏蔽按压两次电源键(KEYCODE_POWER)打开相机

平台 RK3288 + Android7.1 需求 Android 支持通过快速按下电源键两次启动摄像头, 在新的需求中, 需要屏蔽此功能. 修改 frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java private void interceptPowerKeyDown(KeyEvent event, boolean interactive) { // Hold a

ansondroider的博客 2310

Sensor流程(一)

1.APP层(注册sensor流程) 1.1 SensorManager.registerListenerImpl 1)如果没注册过则new SensorEventQueue,在SensorEventQueue构造中会new Receiver,用来接收数据(后续分析) 2)将要注册的sensor add进与linstener绑定的SensorEventQueue中。 1.2 SensorEventQueue.addSensor 1)加入到mActiveSensors中 1.3 BaseEventQ

二叉树 2238

Sensor系列二 HAL层分析

一、HAL层入口          hal层主要是调用驱动接口,获取sensor驱动中传输上来的数据,提供给上层接口,屏蔽底层的细节, 具有承上启下的作用,将android系统分成了用户空间和内核空间两部分,其中硬件抽象层(HAL)运行在用户 空间,而sensor的hal程序运行在内核空间。        ./vendor/mediatek/proprietary/hardware/s

frank_zyp的博客 6132

sensor----HAL分析

sensor----framework(一)的后面,我们跟进到了mSensorDevice->activate ,下面我们就来具体看看这个怎么样链接到HAL,DRIVER里面去的。如何使能一个SENOSR的。 step 1: \frameworks\native\services\sensorservice\SensorDevice.cpp   SensorDevice::SensorD

liyanfei123456的博客 1365
上一篇: Composite sensors复合式传感器
下一篇: 一个关于驱动加载的时序问题
YasinLeeX
博客等级 码龄19年 380粉丝 310原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值