From 58326d39dcc1886b39f695cb4b5d36db07593ecd Mon Sep 17 00:00:00 2001 From: liucheng5 Date: Mon, 4 Nov 2024 17:26:05 +0800 Subject: [PATCH] system/uorb: add a new uorb topic ENG Add a new uorb topic for ENG sensor Signed-off-by: liucheng5 Signed-off-by: likun17 --- system/uorb/sensor/eng.c | 41 +++++++++++++++++++++++++++++++++++++ system/uorb/sensor/eng.h | 38 ++++++++++++++++++++++++++++++++++ system/uorb/sensor/topics.c | 4 +++- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 system/uorb/sensor/eng.c create mode 100644 system/uorb/sensor/eng.h diff --git a/system/uorb/sensor/eng.c b/system/uorb/sensor/eng.c new file mode 100644 index 000000000..afc712aec --- /dev/null +++ b/system/uorb/sensor/eng.c @@ -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 + +/**************************************************************************** + * 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); diff --git a/system/uorb/sensor/eng.h b/system/uorb/sensor/eng.h new file mode 100644 index 000000000..099c13290 --- /dev/null +++ b/system/uorb/sensor/eng.h @@ -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 + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* register this as object request broker structure */ + +ORB_DECLARE(sensor_eng); + +#endif diff --git a/system/uorb/sensor/topics.c b/system/uorb/sensor/topics.c index 02666a5f0..48619627f 100644 --- a/system/uorb/sensor/topics.c +++ b/system/uorb/sensor/topics.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -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++) {