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:
parent
3eddfe51fa
commit
c7d72bc95c
1 changed files with 18 additions and 0 deletions
|
|
@ -197,6 +197,20 @@ static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
|
|||
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)
|
||||
{
|
||||
char raw[150];
|
||||
|
|
@ -295,6 +309,10 @@ void fakesensor_push_event(FAR struct fakesensor_s *sensor,
|
|||
fakesensor_read_gyro(sensor, event_timestamp);
|
||||
break;
|
||||
|
||||
case SENSOR_TYPE_BAROMETER:
|
||||
fakesensor_read_baro(sensor, event_timestamp);
|
||||
break;
|
||||
|
||||
case SENSOR_TYPE_GNSS:
|
||||
case SENSOR_TYPE_GNSS_SATELLITE:
|
||||
fakesensor_read_gnss(sensor);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue