3-phase PV router
Loading...
Searching...
No Matches
debug.h File Reference

The text output: informational messages (info) and debug messages (debug) More...

#include <Arduino.h>
#include "config.h"
#include "serial_output.h"
Include dependency graph for debug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename... Args>
void debug (const Args &... args)
 Print a debug message, as Serial.print() does (only with ENABLE_DEBUG).
 
template<typename... Args>
void debugln (const Args &... args)
 Print a debug message and a line end, as Serial.println() does (only with ENABLE_DEBUG).
 
void info (const __FlashStringHelper *text)
 Print a text in flash, F("..."): info() out of line.
 
template<typename... Args>
void info (const Args &... args)
 Print an informational message, as Serial.print() does.
 
void infoln (const __FlashStringHelper *text)
 Print a text in flash, F("..."), and a line end: infoln() out of line.
 
template<typename... Args>
void infoln (const Args &... args)
 Print an informational message and a line end, as Serial.println() does.
 
void infolnDecimals (const int32_t value, const uint8_t decimals)
 Print a value given as an integer with a fixed number of decimals, and a line end.
 
void infolnDecimals_P (const int32_t *value, const uint8_t decimals)
 Same as infolnDecimals(), with the value read from PROGMEM.
 
template<typename... Args>
void status (const Args &... args)
 Print a status message, as Serial.print() does (human-readable output only).
 
template<typename... Args>
void statusln (const Args &... args)
 Print a status message and a line end, as Serial.println() does (human-readable output only).
 

Variables

constexpr bool STATUS_OUTPUT_ENABLED { SERIAL_OUTPUT_TYPE == SerialOutputType::HumanReadable }
 Whether the status changes are printed while running: in human-readable output only.
 

Detailed Description

The text output: informational messages (info) and debug messages (debug)

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)
Version
0.1
Date
2026-11-21

In the IoT and JSON modes, the serial port carries data for another device (mk2Wifi...).

  • info(), infoln(): the startup configuration, in every output mode: without it, no way to know what the router runs with. In IoT output, it is printed at 9600 baud 8N1, the default of serial monitors, before setup() switches to the 7E1 of the telemetry: the mk2pvrouter ESPHome component drops everything until its first frame. In JSON output, its lines come before the first JSON line.
  • status(), statusln(): status changes while running, in human-readable output only.
  • debug(), debugln(): debug messages at startup, as info(), only with ENABLE_DEBUG.

The arguments are those of Serial.print() / Serial.println(). A datalog output still in progress is written first, so a message never lands in the middle of a datalog line or telemetry frame (see serial_output.h). When a message is off, the call compiles to nothing, provided its arguments have no side effects.

The templates are always inlined: out of line, GCC keeps a copy per argument type, about 20 bytes more in all. A text in flash, F("..."), the most common message by far, goes to an overload that is not inlined instead: one call per message, rather than complete() and Serial.print() at each of them.

Note
Reads SERIAL_OUTPUT_TYPE and ENABLE_DEBUG from config.h, which it includes.

Definition in file debug.h.

Function Documentation

◆ debug()

template<typename... Args>
void debug ( const Args &... args)
inline

Print a debug message, as Serial.print() does (only with ENABLE_DEBUG).

Definition at line 143 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ debugln()

template<typename... Args>
void debugln ( const Args &... args)
inline

Print a debug message and a line end, as Serial.println() does (only with ENABLE_DEBUG).

Definition at line 155 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ info() [1/2]

void info ( const __FlashStringHelper * text)
inline

Print a text in flash, F("..."): info() out of line.

Chosen over the template for F("...") (a non-template function wins an equal match), also through status() and debug().

Definition at line 79 of file debug.h.

Here is the call graph for this function:

◆ info() [2/2]

template<typename... Args>
void info ( const Args &... args)
inline

Print an informational message, as Serial.print() does.

Definition at line 57 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ infoln() [1/2]

void infoln ( const __FlashStringHelper * text)
inline

Print a text in flash, F("..."), and a line end: infoln() out of line.

Definition at line 88 of file debug.h.

Here is the call graph for this function:

◆ infoln() [2/2]

template<typename... Args>
void infoln ( const Args &... args)
inline

Print an informational message and a line end, as Serial.println() does.

Definition at line 67 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ infolnDecimals()

void infolnDecimals ( const int32_t value,
const uint8_t decimals )
inline

Print a value given as an integer with a fixed number of decimals, and a line end.

For float constants converted at compile time (SerialOutput::toDecimals()): printed without the float code of Print.

Definition at line 100 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ infolnDecimals_P()

void infolnDecimals_P ( const int32_t * value,
const uint8_t decimals )
inline

Same as infolnDecimals(), with the value read from PROGMEM.

Definition at line 110 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ status()

template<typename... Args>
void status ( const Args &... args)
inline

Print a status message, as Serial.print() does (human-readable output only).

Definition at line 119 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ statusln()

template<typename... Args>
void statusln ( const Args &... args)
inline

Print a status message and a line end, as Serial.println() does (human-readable output only).

Definition at line 131 of file debug.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ STATUS_OUTPUT_ENABLED

bool STATUS_OUTPUT_ENABLED { SERIAL_OUTPUT_TYPE == SerialOutputType::HumanReadable }
inlineconstexpr

Whether the status changes are printed while running: in human-readable output only.

Definition at line 51 of file debug.h.