system/uorb: add a new uorb topic ENG

Add a new uorb topic for ENG sensor

Signed-off-by: liucheng5 <liucheng5@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
liucheng5 2024-11-04 17:26:05 +08:00 committed by Matteo Golin
parent b0b90ac728
commit 58326d39dc
3 changed files with 82 additions and 1 deletions

41
system/uorb/sensor/eng.c Normal file
View file

@ -0,0 +1,41 @@
/****************************************************************************
* apps/system/uorb/sensor/eng.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <sensor/eng.h>
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef CONFIG_DEBUG_UORB
static const char sensor_eng_format[] =
"timestamp:%" PRIu64 ",eng0:%hf,eng1:%hf,eng2:%hf,eng3:%hf,"
"status:0x%" PRIx32 "";
#endif
/****************************************************************************
* Public Data
****************************************************************************/
ORB_DEFINE(sensor_eng, struct sensor_eng, sensor_eng_format);

38
system/uorb/sensor/eng.h Normal file
View file

@ -0,0 +1,38 @@
/****************************************************************************
* apps/system/uorb/sensor/eng.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __APPS_SYSTEM_UORB_SENSOR_ENG_H
#define __APPS_SYSTEM_UORB_SENSOR_ENG_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <uORB/uORB.h>
/****************************************************************************
* Public Data
****************************************************************************/
/* register this as object request broker structure */
ORB_DECLARE(sensor_eng);
#endif

View file

@ -38,6 +38,7 @@
#include <sensor/co2.h>
#include <sensor/dust.h>
#include <sensor/ecg.h>
#include <sensor/eng.h>
#include <sensor/force.h>
#include <sensor/gas.h>
#include <sensor/gnss.h>
@ -87,6 +88,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
ORB_ID(sensor_device_orientation),
ORB_ID(sensor_dust),
ORB_ID(sensor_ecg),
ORB_ID(sensor_eng),
ORB_ID(sensor_force),
ORB_ID(sensor_gas),
ORB_ID(sensor_glance_gesture),
@ -157,7 +159,7 @@ FAR const struct orb_metadata *orb_get_meta(FAR const char *name)
int fd;
int i;
/* Fisrt search built-in topics */
/* First search built-in topics */
for (i = 0; g_sensor_list[i]; i++)
{