mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[sdlog] add SD logging for some meteo sensors on compatible boards
- airspeed ets - himidity sht - temperature temod close #1498
This commit is contained in:
committed by
Gautier Hattenberger
parent
2922e87b37
commit
525b441c1f
@@ -25,6 +25,7 @@
|
||||
<define name="AIRSPEED_ETS_SYNC_SEND" description="flag to transmit the data as it is acquired"/>
|
||||
<define name="USE_AIRSPEED_ETS" value="TRUE|FALSE" description="set airspeed in state interface"/>
|
||||
<define name="AIRSPEED_ETS_3RD_PARTY_MODE" description="read raw value for sensor in third-party mode"/>
|
||||
<define name="AIRSPEED_ETS_SDLOG" value="TRUE|FALSE" description="start logging to SD card"/>
|
||||
</doc>
|
||||
|
||||
<header>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</description>
|
||||
<define name="SHT_DAT_GPIO" value="port,pin" description="data GPIO (e.g.: GPIOA,GPIO8)"/>
|
||||
<define name="SHT_SCK_GPIO" value="port,pin" description="clock GPIO (e.g.: GPIOA,GPIO9)"/>
|
||||
<define name="SHT_SDLOG" value="TRUE|FALSE" description="start logging to SD card"/>
|
||||
</doc>
|
||||
<header>
|
||||
<file name="humid_sht.h"/>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<description>Hygrosens TEMOD-I2C-Rx temperature sensor</description>
|
||||
<configure name="TEMOD_I2C_DEV" value="i2cX" description="select i2c peripheral to use (default i2c0)"/>
|
||||
<define name="TEMOD_TYPE" value="type" description="device type (default TEMOD_I2C_R1)"/>
|
||||
<define name="TEMOD_SDLOG" value="TRUE|FALSE" description="start logging to SD card"/>
|
||||
</doc>
|
||||
<header>
|
||||
<file name="temp_temod.h"/>
|
||||
|
||||
@@ -35,6 +35,14 @@
|
||||
#include "subsystems/datalink/downlink.h"
|
||||
#include "humid_sht.h"
|
||||
|
||||
// sd-log
|
||||
#if SHT_SDLOG
|
||||
#include "sdLog.h"
|
||||
#include "subsystems/chibios-libopencm3/chibios_sdlog.h"
|
||||
#include "subsystems/gps.h"
|
||||
bool_t log_sht_started;
|
||||
#endif
|
||||
|
||||
//#include "led.h"
|
||||
|
||||
#define noACK 0
|
||||
@@ -299,6 +307,11 @@ void humid_sht_init(void)
|
||||
|
||||
humid_sht_available = FALSE;
|
||||
humid_sht_status = SHT_IDLE;
|
||||
|
||||
#if SHT_SDLOG
|
||||
log_sht_started = FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void humid_sht_periodic(void)
|
||||
@@ -338,6 +351,21 @@ void humid_sht_periodic(void)
|
||||
humid_sht_status = SHT_MEASURING_HUMID;
|
||||
DOWNLINK_SEND_SHT_STATUS(DefaultChannel, DefaultDevice, &humidsht, &tempsht, &fhumidsht, &ftempsht);
|
||||
humid_sht_available = FALSE;
|
||||
|
||||
#if SHT_SDLOG
|
||||
if (pprzLogFile != -1) {
|
||||
if (!log_sht_started) {
|
||||
sdLogWriteLog(pprzLogFile, "SHT75: Humid(pct) Temp(degC) H(usec) GPS_fix TOW(ms) Week Lat(1e7rad) Lon(1e7rad) HMSL(mm) gpseed(cm/s) course(1e7rad) climb(cm/s)\n");
|
||||
log_sht_started = TRUE;
|
||||
}
|
||||
sdLogWriteLog(pprzLogFile, "sht75: %9.4f %9.4f %d %d %d %d %d %d %d %d %d\n",
|
||||
fhumidsht, ftempsht,
|
||||
gps.fix, gps.tow, gps.week,
|
||||
gps.lla_pos.lat, gps.lla_pos.lon, gps.hmsl,
|
||||
gps.gspeed, gps.course, -gps.ned_vel.z);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,14 @@
|
||||
#include "messages.h"
|
||||
#include "subsystems/datalink/downlink.h"
|
||||
|
||||
// sd-log
|
||||
#if TEMP_TEMOD_SDLOG
|
||||
#include "sdLog.h"
|
||||
#include "subsystems/chibios-libopencm3/chibios_sdlog.h"
|
||||
#include "subsystems/gps.h"
|
||||
bool_t log_temod_started;
|
||||
#endif
|
||||
|
||||
float ftmd_temperature;
|
||||
struct i2c_transaction tmd_trans;
|
||||
|
||||
@@ -50,11 +58,16 @@ struct i2c_transaction tmd_trans;
|
||||
void temod_init(void)
|
||||
{
|
||||
tmd_trans.status = I2CTransDone;
|
||||
|
||||
#if TEMP_TEMOD_SDLOG
|
||||
log_temod_started = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void temod_periodic(void)
|
||||
{
|
||||
i2c_receive(&TEMOD_I2C_DEV, &tmd_trans, TEMOD_SLAVE_ADDR, 2);
|
||||
|
||||
}
|
||||
|
||||
void temod_event(void)
|
||||
@@ -72,6 +85,24 @@ void temod_event(void)
|
||||
|
||||
DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &tmd_temperature, &ftmd_temperature);
|
||||
tmd_trans.status = I2CTransDone;
|
||||
|
||||
|
||||
#if TEMP_TEMOD_SDLOG
|
||||
if (pprzLogFile != -1) {
|
||||
if (!log_temod_started) {
|
||||
sdLogWriteLog(pprzLogFile, "TEMOD: Temp(degC) H(usec) GPS_fix TOW(ms) Week Lat(1e7rad) Lon(1e7rad) HMSL(mm) gpseed(cm/s) course(1e7rad) climb(cm/s)\n");
|
||||
log_temod_started = TRUE;
|
||||
}
|
||||
else {
|
||||
sdLogWriteLog(pprzLogFile, "temod: %9.4f %d %d %d %d %d %d %d %d %d\n",
|
||||
ftmd_temperature,
|
||||
gps.fix, gps.tow, gps.week,
|
||||
gps.lla_pos.lat, gps.lla_pos.lon, gps.hmsl,
|
||||
gps.gspeed, gps.course, -gps.ned_vel.z);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,13 @@ PRINT_CONFIG_VAR(AIRSPEED_ETS_I2C_DEV)
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(AIRSPEED_ETS_START_DELAY)
|
||||
|
||||
#if AIRSPEED_ETS_SDLOG
|
||||
#include "sdLog.h"
|
||||
#include "subsystems/chibios-libopencm3/chibios_sdlog.h"
|
||||
#include "subsystems/gps.h"
|
||||
bool_t log_airspeed_ets_started;
|
||||
#endif
|
||||
|
||||
|
||||
// Global variables
|
||||
uint16_t airspeed_ets_raw;
|
||||
@@ -123,6 +130,10 @@ void airspeed_ets_init(void)
|
||||
|
||||
airspeed_ets_delay_done = FALSE;
|
||||
SysTimeTimerStart(airspeed_ets_delay_time);
|
||||
|
||||
#if AIRSPEED_ETS_SDLOG
|
||||
log_airspeed_ets_started = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void airspeed_ets_read_periodic(void)
|
||||
@@ -221,6 +232,23 @@ void airspeed_ets_read_event(void)
|
||||
airspeed_ets = 0.0;
|
||||
}
|
||||
|
||||
|
||||
#if AIRSPEED_ETS_SDLOG
|
||||
if (pprzLogFile != -1) {
|
||||
if (!log_airspeed_ets_started) {
|
||||
sdLogWriteLog(pprzLogFile, "AIRSPEED_ETS: raw offset airspeed(m/s) GPS_fix TOW(ms) Week Lat(1e7rad) Lon(1e7rad) HMSL(mm) gpseed(cm/s) course(1e7rad) climb(cm/s)\n");
|
||||
log_airspeed_ets_started = TRUE;
|
||||
}
|
||||
sdLogWriteLog(pprzLogFile, "airspeed_ets: %d %d %8.4f %d %d %d %d %d %d %d %d %d\n",
|
||||
airspeed_ets_raw, airspeed_ets_offset, airspeed_ets,
|
||||
gps.fix, gps.tow, gps.week,
|
||||
gps.lla_pos.lat, gps.lla_pos.lon, gps.hmsl,
|
||||
gps.gspeed, gps.course, -gps.ned_vel.z);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Transaction has been read
|
||||
airspeed_ets_i2c_trans.status = I2CTransDone;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user