memcpy(pos, &gps_pos, sizeof(*pos));
}
-int gps_log(void)
+int gps_log(uint8_t to_stdout)
{
uint32_t ms;
uint8_t flags, prio;
(double)gps_pos.sea_altitude / 100.);
- if (sd_log_enabled()) {
+ if (!to_stdout && sd_log_enabled()) {
if (sd_log_write(buf, len) != len) {
printf_P(PSTR("error writing to file\n"));
return -1;
}
}
- else {
+ else if (to_stdout) {
printf_P(PSTR("%s"), buf);
}
} __attribute__ ((packed));
int gps_venus_init(void);
-int gps_log(void);
+
+/* log gps position stdout (if stdout is 1) or on sdcard (if 0) */
+int gps_log(uint8_t to_stdout);
/* does not lock intr, must be done by user */
void gps_get_pos(struct gps_pos *pos);
}
-int imu_log(void)
+
+int imu_log(uint8_t to_stdout)
{
char buf[128];
int16_t len;
imu.gx, imu.gy, imu.gz,
imu.ax, imu.ay, imu.az,
imu.mx, imu.my, imu.mz);
- if (sd_log_write(buf, len) != len) {
- printf_P(PSTR("error writing to file\n"));
- return -1;
+ if (!to_stdout && sd_log_enabled()) {
+ if (sd_log_write(buf, len) != len) {
+ printf_P(PSTR("error writing to file\n"));
+ return -1;
+ }
+ }
+ else if (to_stdout) {
+ printf_P(PSTR("%s"), buf);
}
return 0;
/* initialize the IMU */
void imu_init(void);
-/* if sd log file is opened, log the status of IMU on the sdcard */
-int imu_log(void);
+/* log imu status on stdout (if stdout is 1) or on sdcard (if 0) */
+int imu_log(uint8_t to_stdout);
/* return a filled imu_info structure corresponding to the latest axes read in
* the timer callback. Does not lock irq, so it's up to the user to do that. */
LED2_OFF();
}
-/* XXX */
-int sd_main(void);
-
int main(void)
{
DDRB = 0x18 /* LEDs */;
printf_P(PSTR("\r\n"));
rdline_newline(&imuboard.rdl, imuboard.prompt);
- //sd_main();
imu_init();
gps_venus_init();
imuboard.flags |= IMUBOARD_F_BOOT_OK;
while (1) {
- //imu_log();
- //gps_log();
+ imu_log(0);
+ gps_log(0);
cmdline_poll();
}