sensor:Add sensor gas log output.

Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
likun17 2023-12-01 14:27:36 +08:00 committed by Xiang Xiao
parent d0e15a7450
commit 027ded4d4e
3 changed files with 89 additions and 0 deletions

49
system/uorb/sensor/gas.c Normal file
View File

@ -0,0 +1,49 @@
/****************************************************************************
* apps/system/uorb/sensor/gas.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/gas.h>
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef CONFIG_DEBUG_UORB
static void print_sensor_gas_message(FAR const struct orb_metadata *meta,
FAR const void *buffer)
{
FAR const struct sensor_gas *message = buffer;
const orb_abstime now = orb_absolute_time();
uorbinfo_raw("%s:\ttimestamp: %" PRIu64 " (%" PRIu64 " us ago) "
"value: %.4f",
meta->o_name, message->timestamp, now - message->timestamp,
message->gas_resistance);
}
#endif
/****************************************************************************
* Public Data
****************************************************************************/
ORB_DEFINE(sensor_gas, struct sensor_gas, print_sensor_gas_message);

38
system/uorb/sensor/gas.h Normal file
View File

@ -0,0 +1,38 @@
/****************************************************************************
* apps/system/uorb/sensor/gas.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_GAS_H
#define __APPS_SYSTEM_UORB_SENSOR_GAS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <uORB/uORB.h>
/****************************************************************************
* Public Data
****************************************************************************/
/* register this as object request broker structure */
ORB_DECLARE(sensor_gas);
#endif

View File

@ -38,6 +38,7 @@
#include <sensor/dust.h>
#include <sensor/ecg.h>
#include <sensor/force.h>
#include <sensor/gas.h>
#include <sensor/gps.h>
#include <sensor/gyro.h>
#include <sensor/gesture.h>
@ -80,6 +81,7 @@ static FAR const struct orb_metadata *g_sensor_list[] =
ORB_ID(sensor_dust),
ORB_ID(sensor_ecg),
ORB_ID(sensor_force),
ORB_ID(sensor_gas),
ORB_ID(sensor_gps),
ORB_ID(sensor_gps_satellite),
ORB_ID(sensor_gyro),