mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
drivers/sensors/fakesensor: Add baro sensor type
Add a function `fakesensor_read_baro` that allows barometric data to be read and published by fakesensor Signed-off-by: Angus Jull <angusjull1@gmail.com>
This commit is contained in:
committed by
Mateusz Szafoni
parent
3eddfe51fa
commit
c7d72bc95c
@@ -197,6 +197,20 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
|
|||||||
sizeof(struct sensor_gyro));
|
sizeof(struct sensor_gyro));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void fakesensor_read_baro(FAR struct fakesensor_s *sensor,
|
||||||
|
uint64_t event_timestamp)
|
||||||
|
{
|
||||||
|
struct sensor_baro baro;
|
||||||
|
char raw[50];
|
||||||
|
|
||||||
|
fakesensor_read_csv_line(&sensor->data, raw, sizeof(raw),
|
||||||
|
sensor->raw_start);
|
||||||
|
sscanf(raw, "%f,%f\n", &baro.pressure, &baro.temperature);
|
||||||
|
baro.timestamp = event_timestamp;
|
||||||
|
sensor->lower.push_event(sensor->lower.priv, &baro,
|
||||||
|
sizeof(struct sensor_baro));
|
||||||
|
}
|
||||||
|
|
||||||
static inline void fakesensor_read_gnss(FAR struct fakesensor_s *sensor)
|
static inline void fakesensor_read_gnss(FAR struct fakesensor_s *sensor)
|
||||||
{
|
{
|
||||||
char raw[150];
|
char raw[150];
|
||||||
@@ -295,6 +309,10 @@ void fakesensor_push_event(FAR struct fakesensor_s *sensor,
|
|||||||
fakesensor_read_gyro(sensor, event_timestamp);
|
fakesensor_read_gyro(sensor, event_timestamp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SENSOR_TYPE_BAROMETER:
|
||||||
|
fakesensor_read_baro(sensor, event_timestamp);
|
||||||
|
break;
|
||||||
|
|
||||||
case SENSOR_TYPE_GNSS:
|
case SENSOR_TYPE_GNSS:
|
||||||
case SENSOR_TYPE_GNSS_SATELLITE:
|
case SENSOR_TYPE_GNSS_SATELLITE:
|
||||||
fakesensor_read_gnss(sensor);
|
fakesensor_read_gnss(sensor);
|
||||||
|
|||||||
Reference in New Issue
Block a user