[sd logger] Version 2.0 release, direct SPI logging, UART download

This commit is contained in:
Bart Slinger
2015-10-27 14:13:39 +01:00
parent 7b65866e0c
commit ec15491b9a
12 changed files with 1650 additions and 8 deletions
+8
View File
@@ -36,6 +36,13 @@ paparazzi.sublime-workspace
# JetBrains (PyCharm, etc) IDE project files
.idea
# QtCreator IDE
*.creator
*.creator.user
*.config
*.files
*.includes
# Vagrant VM files
/.vagrant
@@ -126,6 +133,7 @@ paparazzi.sublime-workspace
/sw/logalizer/openlog2tlm
/sw/logalizer/ahrs2fg
/sw/logalizer/disp3d
/sw/logalizer/sdlogger_download
# /sw/simulator/
/sw/simulator/gaia
File diff suppressed because it is too large Load Diff
+11
View File
@@ -87,6 +87,17 @@
settings_modules="modules/geo_mag.xml modules/air_data.xml modules/video_thread.xml modules/video_rtp_stream.xml"
gui_color="red"
/>
<aircraft
name="Helisa"
ac_id="114"
airframe="airframes/TUDelft/airframes/walkera_genius_v2.xml"
radio="radios/FlyElectricRx31_DX6.xml"
telemetry="telemetry/rotorcraft_with_logger.xml"
flight_plan="flight_plans/rotorcraft_basic.xml"
settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/control/stabilization_rate.xml [settings/superbitrf.xml]"
settings_modules="modules/gps_ubx_ucenter.xml modules/logger_sd_spi_direct.xml"
gui_color="#063982530000"
/>
<aircraft
name="MAVTec3_Chris"
ac_id="33"
+65
View File
@@ -0,0 +1,65 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="logger_sd_spi_direct" dir="loggers">
<doc>
<description>Direct SPI SD Logger that saves pprzlog messages to SD Card.</description>
<configure name="SDLOGGER_DIRECT_SPI" value="SPI1|SPI2|SPI3|SPI4|SPI5|SPI6" description="Port to which the SD Card is connected."/>
<configure name="SDLOGGER_DIRECT_SPI_SLAVE" value="SPI_SLAVE1|SPI_SLAVE2|SPI_SLAVE3|SPI_SLAVE4|SPI_SLAVE5|SPI_SLAVE6" description="Port to which the SD Card is connected."/>
<configure name="LOGGER_CONTROL_SWITCH" value="RADIO_AUX2"/>
<configure name="LOGGER_LED" value="none"/>
</doc>
<settings>
<dl_settings NAME="sdlogger">
<dl_settings NAME="SD Logger">
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.status" min="0" max="20" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdcard1.status" min="0" max="40" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.last_completed" min="0" max="42" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.next_available_address" min="16384" max="4294967295" step="1" />
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.command" min="1" max="42" step="1" />
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.download_address" min="0" max="4294967295" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.download_length" min="0" max="4294967295" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.download_id" min="0" max="255" step="1"/>
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="sdlogger_spi_direct.h"/>
</header>
<init fun="sdlogger_spi_direct_init()"/>
<periodic fun="sdlogger_spi_direct_periodic()" freq="512" start="sdlogger_spi_direct_start()" stop="sdlogger_spi_direct_stop()" autorun="TRUE"/>
<datalink message="SETTING" fun="sdlogger_spi_direct_command()"/>
<makefile>
<raw>
SDLOGGER_DIRECT_SPI ?= spi2
SDLOGGER_DIRECT_SPI_LOWER=$(shell echo $(SDLOGGER_DIRECT_SPI) | tr A-Z a-z)
SDLOGGER_DIRECT_SPI_UPPER=$(shell echo $(SDLOGGER_DIRECT_SPI) | tr a-z A-Z)
SDLOGGER_DIRECT_SPI_SLAVE ?= spi_slave2
SDLOGGER_DIRECT_SPI_SLAVE_LOWER=$(shell echo $(SDLOGGER_DIRECT_SPI_SLAVE) | tr A-Z a-z)
SDLOGGER_DIRECT_SPI_SLAVE_UPPER=$(shell echo $(SDLOGGER_DIRECT_SPI_SLAVE) | tr a-z A-Z)
LOGGER_CONTROL_SWITCH ?= RADIO_AUX2
LOGGER_LED ?= none
ifneq ($(LOGGER_LED),none)
ap.CFLAGS += -DLOGGER_LED=$(LOGGER_LED)
endif
ap.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprzlog_transport.c
</raw>
<file name="sdcard_spi.c" dir="peripherals"/>
<file name="sdlogger_spi_direct.c"/>
</makefile>
<makefile target="ap">
<define name="USE_SDLOGGER_SPI_DIRECT" value="1" />
<define name="SPI_MASTER" value="1" />
<define name="USE_$(SDLOGGER_DIRECT_SPI_UPPER)" value="1" />
<define name="SDLOGGER_SPI_LINK_DEVICE" value="$(SDLOGGER_DIRECT_SPI_LOWER)" />
<define name="USE_$(SDLOGGER_DIRECT_SPI_SLAVE_UPPER)" value="1" />
<define name="SDLOGGER_SPI_LINK_SLAVE_NUMBER" value="$(SDLOGGER_DIRECT_SPI_SLAVE_UPPER)" />
<define name="SDLOGGER_CONTROL_SWITCH" value="$(LOGGER_CONTROL_SWITCH)"/>
</makefile>
</module>
+160
View File
@@ -0,0 +1,160 @@
<?xml version="1.0"?>
<!DOCTYPE telemetry SYSTEM "telemetry.dtd">
<telemetry>
<process name="Main">
<mode name="default" key_press="d">
<message name="AUTOPILOT_VERSION" period="11.1"/>
<message name="DL_VALUE" period="1.1"/>
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="ROTORCRAFT_FP" period="0.25"/>
<message name="ALIVE" period="2.1"/>
<message name="INS_REF" period="5.1"/>
<message name="ROTORCRAFT_NAV_STATUS" period="1.6"/>
<message name="WP_MOVED" period="1.3"/>
<message name="ROTORCRAFT_CAM" period="1."/>
<message name="GPS_INT" period=".25"/>
<message name="INS" period=".25"/>
<message name="I2C_ERRORS" period="4.1"/>
<message name="UART_ERRORS" period="3.1"/>
<message name="SUPERBITRF" period="3"/>
<message name="ENERGY" period="2.5"/>
<message name="DATALINK_REPORT" period="5.1"/>
<message name="STATE_FILTER_STATUS" period="3.2"/>
<message name="AIR_DATA" period="1.3"/>
<message name="SURVEY" period="2.5"/>
<message name="OPTIC_FLOW_EST" period="0.25"/>
<message name="VECTORNAV_INFO" period="0.5"/>
</mode>
<mode name="ppm">
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="ROTORCRAFT_CMD" period=".05"/>
<message name="PPM" period="0.5"/>
<message name="RC" period="0.5"/>
<message name="ROTORCRAFT_RADIO_CONTROL" period="0.5"/>
<message name="ROTORCRAFT_STATUS" period="1"/>
<message name="ACTUATORS_BEBOP" period="0.2"/>
</mode>
<mode name="raw_sensors">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="IMU_ACCEL_RAW" period=".05"/>
<message name="IMU_GYRO_RAW" period=".05"/>
<message name="IMU_MAG_RAW" period=".05"/>
<message name="BARO_RAW" period=".1"/>
<message name="ARDRONE_NAVDATA" period=".05"/>
</mode>
<mode name="scaled_sensors">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="IMU_GYRO_SCALED" period=".075"/>
<message name="IMU_ACCEL_SCALED" period=".075"/>
<message name="IMU_MAG_SCALED" period=".1"/>
</mode>
<mode name="ahrs">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="FILTER_ALIGNER" period="2.2"/>
<message name="FILTER" period=".5"/>
<message name="GEO_MAG" period="5."/>
<message name="AHRS_GYRO_BIAS_INT" period="0.08"/>
<message name="AHRS_QUAT_INT" period=".25"/>
<message name="AHRS_EULER_INT" period=".1"/>
<!-- <message name="AHRS_RMAT_INT" period=".5"/> -->
</mode>
<mode name="rate_loop">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="RATE_LOOP" period=".02"/>
</mode>
<mode name="attitude_setpoint_viz" key_press="v">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="0.9"/>
<message name="ROTORCRAFT_RADIO_CONTROL" period="0.1"/>
<message name="AHRS_REF_QUAT" period="0.05"/>
</mode>
<mode name="attitude_loop" key_press="a">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="0.9"/>
<message name="STAB_ATTITUDE" period=".03"/>
<message name="STAB_ATTITUDE_REF" period=".03"/>
<message name="STAB_ATTITUDE_INDI" period=".25"/>
</mode>
<mode name="vert_loop" key_press="v">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="0.9"/>
<message name="VFF" period=".05"/>
<message name="VFF_EXTENDED" period=".05"/>
<message name="VERT_LOOP" period=".05"/>
<message name="INS_Z" period=".05"/>
<message name="INS" period=".11"/>
<message name="INS_REF" period="5.1"/>
</mode>
<mode name="h_loop" key_press="h">
<message name="ALIVE" period="0.9"/>
<message name="HOVER_LOOP" period="0.062"/>
<message name="GUIDANCE_H_REF" period="0.062"/>
<message name="STAB_ATTITUDE" period="0.4"/>
<!--<message name="STAB_ATTITUDE_REF" period="0.4"/>-->
<message name="ROTORCRAFT_FP" period="0.8"/>
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="ROTORCRAFT_NAV_STATUS" period="1.6"/>
<message name="INS_REF" period="5.1"/>
<!-- HFF messages are only sent if USE_HFF -->
<message name="HFF" period=".05"/>
<message name="HFF_GPS" period=".03"/>
<message name="HFF_DBG" period=".2"/>
</mode>
<mode name="aligner">
<message name="ALIVE" period="0.9"/>
<message name="FILTER_ALIGNER" period="0.02"/>
</mode>
<mode name="tune_hover">
<message name="DL_VALUE" period="1.1"/>
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="ALIVE" period="2.1"/>
<message name="GUIDANCE_H_INT" period="0.05"/>
<message name="ROTORCRAFT_TUNE_HOVER" period=".1"/>
<!-- <message name="GPS_INT" period=".20"/> -->
<!--<message name="INS2" period=".05"/>
<message name="INS3" period=".20"/>-->
<message name="INS_REF" period="5.1"/>
</mode>
<mode name="empty"></mode>
</process>
<process name="Logger">
<mode name="default">
<message name="ROTORCRAFT_STATUS" period="1.2"/>
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="IMU_GYRO_SCALED" period=".002"/>
<message name="IMU_ACCEL_SCALED" period=".002"/>
<message name="IMU_MAG_SCALED" period=".1"/>
</mode>
</process>
</telemetry>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,90 @@
/*
* Copyright (C) Bart Slinger
*
* This file is part of paparazzi
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/
/**
* @file "modules/loggers/sdlogger_spi_direct.h"
* @author Bart Slinger
* SPI SD Logger that saves pprzlog messages to SD Card.
*/
#ifndef SDLOGGER_SPI_H
#define SDLOGGER_SPI_H
#define SDLOGGER_BUFFER_SIZE 128
#include "std.h"
#include "mcu_periph/link_device.h"
#include "subsystems/radio_control.h"
#include "subsystems/datalink/pprzlog_transport.h"
#include "subsystems/datalink/telemetry.h"
#include "peripherals/sdcard_spi.h"
#include "mcu_periph/uart.h"
#include "led.h"
#include "generated/periodic_telemetry.h"
enum SDLoggerStatus {
SDLogger_UnInit,
SDLogger_Error,
SDLogger_Initializing,
SDLogger_RetreivingIndex,
SDLogger_Ready,
SDLogger_Logging,
SDLogger_LoggingFinalBlock,
SDLogger_StoppedLogging,
SDLogger_GettingIndexForUpdate,
SDLogger_UpdatingIndex,
SDLogger_GettingIndexForDownload,
SDLogger_Downloading
};
struct sdlogger_spi_periph{
enum SDLoggerStatus status;
uint32_t next_available_address;
uint8_t last_completed;
uint16_t sdcard_buf_idx;
uint8_t buffer[SDLOGGER_BUFFER_SIZE];
uint8_t idx;
uint32_t log_len;
uint8_t command;
uint8_t download_id;
uint32_t download_address;
uint32_t download_length;
struct link_device device;
};
extern struct sdlogger_spi_periph sdlogger_spi;
extern void sdlogger_spi_direct_init(void);
extern void sdlogger_spi_direct_periodic(void);
extern void sdlogger_spi_direct_start(void);
extern void sdlogger_spi_direct_stop(void);
extern void sdlogger_spi_direct_index_received(void);
extern void sdlogger_spi_direct_multiwrite_written(void);
extern void sdlogger_spi_direct_command(void);
extern bool_t sdlogger_spi_direct_check_free_space(struct sdlogger_spi_periph *p, uint8_t len);
extern void sdlogger_spi_direct_put_byte(struct sdlogger_spi_periph *p, uint8_t data);
extern void sdlogger_spi_direct_send_message(void *p);
extern int sdlogger_spi_direct_char_available(void *p);
extern uint8_t sdlogger_spi_direct_get_byte(void *p);
#endif
+13 -4
View File
@@ -35,6 +35,11 @@
* The following resource was used as implementation reference: http://elm-chan.org/docs/mmc/mmc_e.html
* The initialization procedure is implemented according to the following diagram. Only the branches for SD ver.2 are currently included.
* \image html airborne/sdinit.png
*
* Developed using Test Driven Development.
* Test code available at:
* https://github.com/bartslinger/paparazzi-unittest
*
* @todo CRC checksums are not implemented. Fake values of 0xFF are used and they are ignored by the card.
*/
@@ -380,8 +385,8 @@ void sdcard_spi_spicallback(struct spi_transaction *t)
/* Data block received in buffer, process data */
case SDCard_ReadingDataBlock:
sdcard1.status = SDCard_Idle;
if (sdcard1.read_callback != NULL) {
sdcard1.read_callback();
if (sdcard1.external_callback != NULL) {
sdcard1.external_callback();
}
break;
@@ -408,6 +413,9 @@ void sdcard_spi_spicallback(struct spi_transaction *t)
case SDCard_MultiWriteWriting:
if ((sdcard1.input_buf[SD_BLOCK_SIZE + 3] & 0x0F) == 0x05 /* Data accepted */) {
sdcard1.status = SDCard_MultiWriteBusy;
if(sdcard1.external_callback != NULL) {
sdcard1.external_callback();
}
} else {
sdcard1.status = SDCard_Error;
}
@@ -576,7 +584,7 @@ void sdcard_spi_read_block(struct SDCard *sdcard, uint32_t addr, SDCardCallback
}
/* Set function to be called after the read action has finished. */
sdcard->read_callback = callback;
sdcard->external_callback = callback;
/* Send command 17 (read block) to the SDCard */
sdcard_spi_send_cmd(sdcard, 17, addr);
@@ -611,7 +619,7 @@ void sdcard_spi_multiwrite_start(struct SDCard *sdcard, uint32_t addr)
* Use only after sdcard_spi_multiwrite_start().
* @param sdcard Pointer to the SDCard.
*/
void sdcard_spi_multiwrite_next(struct SDCard *sdcard)
void sdcard_spi_multiwrite_next(struct SDCard *sdcard, SDCardCallback callback)
{
/* Can only write next block if card is in multiwrite mode and not currently busy */
if (sdcard->status != SDCard_MultiWriteIdle) {
@@ -627,6 +635,7 @@ void sdcard_spi_multiwrite_next(struct SDCard *sdcard)
/* Set the callback */
sdcard->spi_t.after_cb = &sdcard_spi_spicallback;
sdcard->external_callback = callback;
/* Submit the spi transaction */
spi_submit(sdcard->spi_p, &sdcard->spi_t);
+2 -2
View File
@@ -96,7 +96,7 @@ struct SDCard {
uint8_t response_counter; /**< Response counter used at various locations */
uint32_t timeout_counter; /**< Timeout counter used for initialization checks with ACMD41 */
enum SDCardType card_type; /**< Type of SDCard */
SDCardCallback read_callback; /**< Callback to call when read operation finishes */
SDCardCallback external_callback; /**< Callback to call when external operation finishes */
};
extern struct SDCard sdcard1;
@@ -107,7 +107,7 @@ extern void sdcard_spi_periodic(struct SDCard *sdcard);
extern void sdcard_spi_write_block(struct SDCard *sdcard, uint32_t addr);
extern void sdcard_spi_read_block(struct SDCard *sdcard, uint32_t addr, SDCardCallback callback);
extern void sdcard_spi_multiwrite_start(struct SDCard *sdcard, uint32_t addr);
extern void sdcard_spi_multiwrite_next(struct SDCard *sdcard);
extern void sdcard_spi_multiwrite_next(struct SDCard *sdcard, SDCardCallback callback);
extern void sdcard_spi_multiwrite_stop(struct SDCard *sdcard);
#endif // SDCARD_H_
+5 -2
View File
@@ -30,7 +30,7 @@ LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz
XPKG = -package pprz.xlib
XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib
all: play plotter logplotter sd2log plotprofile openlog2tlm
all: play plotter logplotter sd2log plotprofile openlog2tlm sdlogger_download
play : log_file.cmo play_core.cmo play.cmo $(LIBPPRZCMA)
@echo OL $@
@@ -52,6 +52,9 @@ sd2log : sd2log.cmo $(LIBPPRZCMA)
@echo OL $@
$(Q)$(OCAMLC) $(INCLUDES) -o $@ $(LINKPKG) $^
sdlogger_download: sdlogger_download.c
@echo CC $@
$(Q)$(CC) $(CFLAGS) -std=gnu99 -Wno-unused-result -o $@ $^
# Target for bytecode executable (if ocamlopt is not available)
# plot : log_file.cmo gtk_export.cmo export.cmo plot.cmo
@@ -135,7 +138,7 @@ ctrlstick: ctrlstick.c
clean:
$(Q)rm -f *.opt *.out *~ core *.o *.bak .depend *.cm* play ahrs2fg logplotter plotter gtk_export.ml openlog2tlm disp3d plotprofile tmclient ffjoystick ctrlstick sd2log
$(Q)rm -f *.opt *.out *~ core *.o *.bak .depend *.cm* play ahrs2fg logplotter plotter gtk_export.ml openlog2tlm disp3d plotprofile tmclient ffjoystick ctrlstick sd2log sdlogger_download
.PHONY: all clean
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import sys
from os import path, getenv
# if PAPARAZZI_SRC not set, then assume the tree containing this
# file is a reasonable substitute
PPRZ_SRC = getenv("PAPARAZZI_SRC", path.normpath(path.join(path.dirname(path.abspath(__file__)), '../../../../')))
sys.path.append(PPRZ_SRC + "/sw/lib/python")
from settings_xml_parse import PaparazziACSettings
if __name__ == '__main__':
ac_id = int(sys.argv[1])
command_name = sys.argv[2]
settings = PaparazziACSettings(ac_id)
print settings.name_lookup[command_name].index