You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/17 14:59:53 UTC

[incubator-nuttx-apps] branch master updated: sensortest: support new gps struct and more sensor type.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f58795  sensortest: support new gps struct and more sensor type.
0f58795 is described below

commit 0f58795f10187f19daa06639c0c9f263923ab8c4
Author: 丁欣童 <di...@xiaomi.com>
AuthorDate: Wed Nov 17 10:16:36 2021 +0800

    sensortest: support new gps struct and more sensor type.
    
    Signed-off-by: buyuer <di...@163.com>
---
 testing/sensortest/sensortest.c | 46 +++++++++++++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/testing/sensortest/sensortest.c b/testing/sensortest/sensortest.c
index c3e5ee1..55f5aa7 100644
--- a/testing/sensortest/sensortest.c
+++ b/testing/sensortest/sensortest.c
@@ -61,7 +61,11 @@ static void print_valf3(FAR const char *buffer, FAR const char *name);
 static void print_valf2(FAR const char *buffer, FAR const char *name);
 static void print_valf(FAR const char *buffer, FAR const char *name);
 static void print_valb(FAR const char *buffer, FAR const char *name);
+static void print_vali2(FAR const char *buffer, FAR const char *name);
+static void print_valu(FAR const char *buffer, FAR const char *name);
 static void print_gps(FAR const char *buffer, FAR const char *name);
+static void print_gps_satellite(FAR const char *buffer,
+                                FAR const char *name);
 
 /****************************************************************************
  * Private Data
@@ -95,6 +99,12 @@ static const struct sensor_info g_sensor_info[] =
   {print_valf,  sizeof(struct sensor_event_dust),  "dust"},
   {print_valf,  sizeof(struct sensor_event_hrate), "hrate"},
   {print_valf,  sizeof(struct sensor_event_hbeat), "hbeat"},
+  {print_valf,  sizeof(struct sensor_event_ecg),   "ecg"},
+  {print_valu,  sizeof(struct sensor_event_ppg),   "ppg"},
+  {print_valf2, sizeof(struct sensor_event_impd),  "impd"},
+  {print_vali2, sizeof(struct sensor_event_ots),   "ots"},
+  {print_gps_satellite,  sizeof(struct sensor_event_gps_satellite),
+                                                   "gps_satellite"}
 };
 
 /****************************************************************************
@@ -117,6 +127,13 @@ static void print_valb(const char *buffer, const char *name)
          name, event->timestamp, event->hall);
 }
 
+static void print_vali2(const char *buffer, const char *name)
+{
+  struct sensor_event_ots *event = (struct sensor_event_ots *)buffer;
+  printf("%s: timestamp:%" PRIu64 " value1:% " PRIi32 " value2:% " PRIi32
+         "\n", name, event->timestamp, event->x, event->y);
+}
+
 static void print_valf(const char *buffer, const char *name)
 {
   struct sensor_event_prox *event = (struct sensor_event_prox *)buffer;
@@ -138,16 +155,33 @@ static void print_valf3(const char *buffer, const char *name)
          name, event->timestamp, event->r, event->g, event->b);
 }
 
+static void print_valu(const char *buffer, const char *name)
+{
+  struct sensor_event_ppg *event = (struct sensor_event_ppg *)buffer;
+  printf("%s: timestamp:%" PRIu64 " value:%u\n",
+         name, event->timestamp, event->ppg);
+}
+
 static void print_gps(const char *buffer, const char *name)
 {
   struct sensor_event_gps *event = (struct sensor_event_gps *)buffer;
 
-  printf("%s: year: %d month: %d day: %d hour: %d min: %d sec: %d "
-         "msec: %d\n", name, event->year, event->month, event->day,
-         event->hour, event->min, event->sec, event->msec);
-  printf("%s: yaw: %.4f height: %.4f speed: %.4f latitude: %.4f "
-         "longitude: %.4f\n", name, event->yaw, event->height, event->speed,
-         event->latitude, event->longitude);
+  printf("%s: timestamp: %llu time_utc: %llu latitude: %f longitude: %f "
+         "altitude: %f altitude_ellipsoid: %f eph: %f epv: %f "
+         "hdop: %f vdop: %f ground_speed: %f course: %f satellites_used:"
+         " %u\n", name, event->timestamp, event->time_utc, event->latitude,
+         event->longitude, event->altitude, event->altitude_ellipsoid,
+         event->eph, event->epv, event->hdop, event->vdop,
+         event->ground_speed, event->course, event->satellites_used);
+}
+
+static void print_gps_satellite(FAR const char *buffer, FAR const char *name)
+{
+  FAR struct sensor_event_gps_satellite *event =
+        (struct sensor_event_gps_satellite *)buffer;
+
+  printf("%s: timestamp: %llu count: %u satellites: %u", name,
+         event->timestamp, event->count, event->satellites);
 }
 
 static void usage(void)