Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
logger_sd_chibios module

Log on a SD card, either text or binary data.

Based on ChibiOS HAL and Threads. If board allows it (ex: Apogee), the log file is automatically closed on power down. Files are written on a FAT file system using the FatFS library and can be accessed by using the autopilot as a mass storage (plug USB while the board is running).

Example for airframe file

Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!

<module name="logger_sd_chibios">
b'<define name="SDLOG_START_DELAY" value="30" unit="s" />\n '
b'<define name="SDLOG_AUTO_FLUSH_PERIOD" value="10" unit="s" />\n '
b'<define name="SDLOG_CONTIGUOUS_STORAGE_MEM" value="50" unit="Mo" />\n '
b'<define name="SDLOG_PREFLIGHT_ERROR" value="FALSE" />\n '
b'<configure name="SDLOG_SDIO" value="SDCDx" />\n '
b'<configure name="SDLOG_LED" value="none|num" />\n '
</module>

Module configuration options

Configure Options

  • name: SDLOG_SDIO value: SDCDx
    Description: The SDC device which the SD card is connected to. Default: SDCD1
  • name: SDLOG_LED value: none|num
    Description: LED number or 'none' to disable. Default: none

Define Options

  • name: SDLOG_START_DELAY value: 30
    Description: Set the delay in seconds before starting the logger. This delay can be used to get plug USB cable and get data without starting a new log. Default: 30s
  • name: SDLOG_AUTO_FLUSH_PERIOD value: 10
    Description: Data flush period. Shorter period may decrease performances. Default: 10s
  • name: SDLOG_CONTIGUOUS_STORAGE_MEM value: 50
    Description: Try to reserve a given contiguous mass storage memory. Default: 50Mo
  • name: SDLOG_PREFLIGHT_ERROR value: FALSE
    Description: If set to TRUE, the autopilot will not arm if the SDLogger is not running. Default: FALSE

Module functions

Init Functions

These initialization functions are called once on startup.

Datalink Functions

Whenever the specified datalink message is received, the corresponing handler function is called.

  • on message INFO_MSG_UP call logger_log_msg_up(buf)

Files

Header Files

The following headers are automatically included in modules.h

Source Files

Raw logger_sd_chibios.xml file:

<!DOCTYPE module SYSTEM "module.dtd">
<module name="logger_sd_chibios" dir="loggers" task="core">
<doc>
<description>
Log on a SD card, either text or binary data.
Based on ChibiOS HAL and Threads.
If board allows it (ex: Apogee), the log file is automatically closed on power down.
Files are written on a FAT file system using the FatFS library and can be accessed
by using the autopilot as a mass storage (plug USB while the board is running).
</description>
<configure name="SDLOG_SDIO" value="SDCDx" description="The SDC device which the SD card is connected to. Default: SDCD1"/>
<configure name="SDLOG_LED" value="none|num" description="LED number or 'none' to disable. Default: none"/>
<define name="SDLOG_START_DELAY" value="30" unit="s" description="Set the delay in seconds before starting the logger. This delay can be used to get plug USB cable and get data without starting a new log. Default: 30s"/>
<define name="SDLOG_AUTO_FLUSH_PERIOD" value="10" unit="s" description="Data flush period. Shorter period may decrease performances. Default: 10s"/>
<define name="SDLOG_CONTIGUOUS_STORAGE_MEM" value="50" unit="Mo" description="Try to reserve a given contiguous mass storage memory. Default: 50Mo"/>
<define name="SDLOG_PREFLIGHT_ERROR" value="FALSE" description="If set to TRUE, the autopilot will not arm if the SDLogger is not running. Default: FALSE"/>
</doc>
<settings>
<dl_settings>
<dl_settings name="USB storage">
<dl_setting max="1" min="0" step="1" var="usb_storage_status" shortname="USB Storage" handler="enable_usb_storage" header="loggers/sdlog_chibios/usbStorage" values="OFF|ON"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>tlsf</depends>
</dep>
<header>
<file name="sdlog_chibios.h" />
</header>
<init fun="sdlog_chibios_init()"/>
<datalink message="INFO_MSG_UP" fun="logger_log_msg_up(buf)"/>
<makefile target="ap">
<!-- LED -->
<configure name="SDLOG_LED" default="none"/>
<define name="SDLOG_LED" value="$(SDLOG_LED)" cond="ifneq ($(SDLOG_LED),none)"/>
<!-- SDMMC device -->
<configure name="SDLOG_SDIO" default="SDCD1" case="upper"/>
<define name="SDLOG_SDIO" value="$(SDLOG_SDIO_UPPER)"/>
<define name="FATFS_HAL_DEVICE" value="$(SDLOG_SDIO_UPPER)"/>
<define name="USE_$(SDLOG_SDIO_UPPER)"/>
<!-- Files -->
<file name="sdlog_chibios.c"/>
<file name="sdlog_chibios/sdLog.c"/>
<file name="sdlog_chibios/msg_queue.c"/>
<file name="sdlog_chibios/sdLog.c"/>
<file name="sdlog_chibios/printf.c"/>
<file name="sdlog_chibios/usb_msd.c"/>
<file name="sdlog_chibios/usbStorage.c"/>
<file_arch name="sdio_arch.c" dir="mcu_periph"/>
<!-- Configuration -->
<configure name="SDLOG_USE_RTC" default="TRUE"/>
<configure name="USE_FATFS" value="TRUE"/>
<define name="HAL_USE_RTC" value="TRUE" cond="ifeq (,$(findstring $(SDLOG_USE_RTC),0 FALSE))"/>
<define name="HAL_USE_SDC" value="TRUE"/>
<define name="HAL_USE_USB" value="TRUE"/>
</makefile>
</module>