APIs description

Doxygen complete API documentation

Doxygen documentation Link to doxygen API documentation

Available classes

SDIO_CONF

struct SDIO_CONF

Configuration class for SDIO.

This class represents the configuration for SDIO (Secure Digital Input/Output). It provides parameters such as clock frequency, pin assignments, mountpoint, and format behavior.

streamLogger

class streamLogger

Class representing a stream logger.

The streamLogger class provides functionality for logging and printing timestamped data and events to different hardware interfaces such as serial, SD card… It supports logging for multiple protocols like mavlink, protobuf. Variables added are logged to binary *.binDM files. Events and debug informations are logged as text files. At startup, a new folder is added to the SD card and all files created during the session are stored in this folder. The class also provides methods to read and write JSON files.

Public Types

enum class INTERFACE : uint8_t

Enumeration representing different hardware interfaces.

Values:

enumerator INTERFACE_SERIAL

Serial interface

enumerator INTERFACE_SD

SD card interface

enumerator INTERFACE_CAN

CAN interface

enumerator INTERFACE_WIFI

WiFi interface

enumerator INTERFACE_BLE

Bluetooth Low Energy interface

Public Functions

inline explicit streamLogger(timerTool *timerToolObject, const SDIO_CONF &sdioConf = SDIO_CONF(), Print *serialMonitor = &Serial, uint8_t nbErrorsThreshold = 5, float flushTimerThreshold = FLUSH_TIMER_THRESHOLD_S)

Constructs a streamLogger object.

Parameters:
  • timerToolObject – Pointer to a timerTool object.

  • sdioConf – SDIO configuration object (default: SDIO_CONF()).

  • serialMonitor – Pointer to a Print object for serial monitoring (default: &Serial).

  • nbErrorsThreshold – Number of errors threshold (default: 5).

  • flushTimerThresholdUs – Flush timer value in useconds (default: 10000000).

bool formatCard()

Formats the card.

Returns:

true if the card is successfully formatted, false otherwise.

bool begin()

Initializes the stream logger.

This method initializes SD card SDIO communication, create a new folder, au do a speed measurement for read/write.

Returns:

true if the stream logger is successfully initialized, false otherwise.

inline bool isLoggerReady() const

Indicate if the logger is ready to log.

Returns:

true if the logger is ready to log, false otherwise.

void errorsHandler(bool sdLogError, String typeError)

Handles errors and logs them if necessary.

Parameters:
  • sdLogError – Flag indicating whether to log the error to an SD card.

  • typeError – The type of error that occurred.

uint8_t benchCard()

Performs the benchmarking of the card.

This function measures the performance, print it and write it in the log file.

Returns:

The benchmark result as a uint8_t value (enum)

std::vector<std::string> getRootDirs()

Get the root directories.

This function returns a vector of strings representing the root directories.

Returns:

std::vector<std::string> The root directories.

bool createNewRootDir()

Creates a new root directory.

Returns:

true if the root directory was successfully created, false otherwise.

bool addVariable(const uint8_t *VariableAdress, String Name)

Adds a variable to the logger.

This function adds a variable to the logger by specifying its address and name. Variable type is handled by function overloading

Parameters:
  • VariableAddress – The address of the variable to be added.

  • Name – The name of the variable.

Returns:

True if the variable was successfully added, false otherwise.

bool writeProtobufHeader(const std::vector<String> &names)

Adds protobuf Frames names to the protobuf header field.

Parameters:

names – The names of the protobuf frames names to add.

Returns:

true if the message names were successfully added, false otherwise.

bool writeMavlinkHeaderAndId(const std::vector<String> &names, const std::vector<uint32_t> &ids)

Adds Mavlink Frames names and ID to the mavlink header field.

Parameters:
  • names – The names of the mavlink frames names to add.

  • ids – The ids of the mavlink frames names to add.

Returns:

true if the message names were successfully added, false otherwise.

bool printHeaderMonitor(bool addInUlog = false)

Debug function that prints the header in the Serial monitor and in the ulog file.

Parameters:

addInUlog – Flag indicating whether to add the header in the ulog.

Returns:

True if the header was printed successfully, false otherwise.

bool printTypesMonitor(bool addInUlog = false)

Debug function that prints the types in the Serial monitor and in the ulog file.

Parameters:

addInUlog – Flag indicating whether to add the types in the ulog.

Returns:

True if the types were printed successfully, false otherwise.

void updateLogBuffer()

Updates the log buffer.

This function loops on all the added variables and update the log ring buffer with the updated values.

inline void setWriteLogTask(void *taskHandle, uint32_t sizeThreshold = LOGGER_FRAME_WRITE_LOG_THRESHOLD)

Set the Write Log Task object.

If using multicore/multitask processor, it can be interesting to write/flush the logs on another thread/core task to avoid slowing down the main task.

Note

As the task notification is often RTOS dependant, the triggerWrite() function has to be implemented for each RTOS.

Warning

If a task handle is provided (not NULL), the writing task will not be triggered at each update of (ulog, log, protobuf, mavlink) buffer. The library will automatically trigger the task following the sizeThreshold provided in the configuration.

Parameters:
  • taskHandle – The writing task handle

  • sizeThreshold – The size threshold to trigger the writing task

void printCrashReport(CrashReportClass CrashReport)

Write the crash report to ulog file.

This function write the last crash to the ulog text file if crash report is available

Parameters:

CrashReport – The crash report to be printed.

bool writeLog()

Transfer ring buffer to sd card buffer and ensure data is flushed regularly.

Parameters:

updateTimestamp – Flag indicating whether to update the timestamp of the log entry. Default is true.

bool flushLog()

Flushes the sd card buffer to the sd card (data will be written)

Returns:

true if the flush was successful, false otherwise.

bool close()

Closes the file.

Returns:

true if the stream logger is successfully closed, false otherwise.

template<typename Type>
inline void printUlog(bool print_In_Monitor, bool print_In_File, const Type &message, bool useTimeStamp = true)

Prints the given message to the serial monitor and/or a file.

This function prints the given message to the serial monitor and/or a file, depending on the specified options. If print_In_Monitor is set to true, the message will be printed to the serial monitor. If print_In_File is set to true, the message will be printed to the ulog text file. The message parameter represents the message to be printed. The useTimeStamp parameter determines whether a timestamp should be added to the message. By default, a timestamp is added to the message.

Template Parameters:

Type – The type of the message.

Parameters:
  • print_In_Monitor – Whether to print the message to the serial monitor.

  • print_In_File – Whether to print the message to a file.

  • message – The message to be printed.

  • useTimeStamp – Whether to add a timestamp to the message (default is true).

inline void printUlog(bool print_In_Monitor, bool print_In_File, String message, bool useTimeStamp = true)

Prints the specified message to the Ulog.

Note

This function is the implementation of the printUlog function for the String type.

Parameters:
  • print_In_Monitor – Whether to print the message in the monitor.

  • print_In_File – Whether to print the message in a file.

  • message – The message to be printed.

  • useTimeStamp – Whether to add a timestamp to the message (default is true).

template<typename Type>
inline void printlnUlog(bool print_In_Monitor, bool print_In_File, Type message, bool useTimeStamp = true)

Prints a message to the serial monitor and/or a file and adds a newline character at the end.

This function prints the specified message to the serial monitor and/or a file, with an optional timestamp. The message can be printed to the serial monitor, a file, or both, depending on the provided parameters. If the message is printed to a file, it is also added to a ring buffer for later retrieval.

Template Parameters:

Type – The type of the message to be printed.

Parameters:
  • print_In_Monitor – Whether to print the message to the serial monitor.

  • print_In_File – Whether to print the message to a file.

  • message – The message to be printed.

  • useTimeStamp – Whether to add a timestamp to the message (default is true).

inline void printlnUlog(bool print_In_Monitor, bool print_In_File, String message, bool useTimeStamp = true)

Prints a message to the ulog text file and adds a newline character at the end.

Note

This function is the implementation of the printlnUlog function for the String type.

Parameters:
  • print_In_Monitor – Whether to print the message in the monitor.

  • print_In_File – Whether to print the message in a file.

  • message – The message to be printed.

  • useTimeStamp – Whether to add a timestamp to the message (default is true).

inline String getLocalDirName()

Returns the local directory name (the one created at the beginning of the session)

Returns:

The local directory name as a string.

inline jsonTools &getJsonTools()

Returns the reference to the jsonTools object used by the streamLogger.

Returns:

A reference to the jsonTools object.

void updateProtobufProtocolLogBuffer(const uint8_t *buffer, size_t size, EVENT_TYPE type, RX_TX direction)

Update protobuf LoggerFrame and append it to ring buffer depending on its type.

Parameters:
  • buffer – is the buffer to write to the protobuf LoggerFrame

  • size – is the size of the buffer

  • type – is the type of the buffer (PROTOBUF, MAVLINK)

  • direction – is the direction of the buffer (RX, TX)

abstractProtocolLogger

Warning

doxygenclass: Cannot find class “streamLogger::abstractProtocolLogger” in doxygen xml output for project “libDM_stream_logger” from directory: ./doxyfiles/xml

jsonTools

class jsonTools

The jsonTools class provides functionality for reading, updating, printing, and writing JSON documents.

Public Functions

inline explicit jsonTools(streamLogger *logger)

Constructs a jsonTools object with the specified streamLogger object.

Parameters:

logger – A pointer to the streamLogger object.

~jsonTools() = default

Destructor for the jsonTools object.

bool readJsonFile(String filePath)

Reads a JSON file from the specified file path.

Parameters:

filePath – The path of the JSON file to read.

Returns:

True if the JSON file was successfully read, false otherwise.

bool updateJsonFromStringVector(const std::vector<String> &buffer)

Updates the JSON document using a vector of strings.

Parameters:

buffer – The vector of strings containing the JSON data.

Returns:

True if the JSON document was successfully updated, false otherwise.

void printJsonDoc()

Prints the JSON document.

This function uses the member variable mJsonDoc.

void printJsonDoc(DynamicJsonDocument &jsonDoc)

Prints the specified JSON document.

Parameters:

jsonDoc – The JSON document to print.

bool writeJsonDoc(streamLogger::INTERFACE interface, String filePath)

Writes the JSON document to a file.

This function uses the member variable mJsonDoc.

Parameters:
  • interface – The interface to use for writing the JSON document.

  • filePath – The path of the file to write the JSON document to.

Returns:

True if the JSON document was successfully written to the file, false otherwise.

bool writeJsonDoc(streamLogger::INTERFACE interface, String filePath, DynamicJsonDocument &jsonDoc)

Writes the specified JSON document to a file.

Parameters:
  • interface – The interface to use for writing the JSON document.

  • filePath – The path of the file to write the JSON document to.

  • jsonDoc – The JSON document to write.

Returns:

True if the JSON document was successfully written to the file, false otherwise.

inline DynamicJsonDocument &getJsonDocument()

Returns a reference to the JSON document.

The JSON document can be modified by the user.

Returns:

A reference to the JSON document.

mavlinkLogger

Warning

doxygenclass: Cannot find class “streamLogger::mavlinkLogger” in doxygen xml output for project “libDM_stream_logger” from directory: ./doxyfiles/xml

protobufLogger

Warning

doxygenclass: Cannot find class “streamLogger::protobufLogger” in doxygen xml output for project “libDM_stream_logger” from directory: ./doxyfiles/xml