sensortest: support new gps struct and more sensor type.

Signed-off-by: buyuer <dingddding@163.com>
This commit is contained in:
丁欣童 2021-11-17 10:16:36 +08:00 committed by Xiang Xiao
parent b345298232
commit 0f58795f10

View File

@ -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)