3-phase PV router
Loading...
Searching...
No Matches
TeleInfo Namespace Reference

The telemetry frame of the IoT output. More...

Functions

template<typename Source>
char * frameLine (uint8_t step, char *dst)
 Writes the line of a step.
 
template<typename Source>
constexpr uint8_t frameSteps ()
 The number of steps of a frame: one per line, invalid temperatures included (they write nothing).
 
char * line (char *dst, const char *tag, int16_t value, uint8_t index=0)
 Writes the line of a signed value.
 
constexpr uint8_t lineSize (uint8_t tagLength, uint8_t valueLength)
 The size of a line: LF, tag, TAB, value, TAB, checksum and CR.
 
char * lineUnsigned (char *dst, const char *tag, uint16_t value, uint8_t index=0)
 Writes the line of an unsigned value (above 32767, line() would wrap).
 
char * writeDigits (char *dst, uint16_t value)
 Writes the decimal digits of a 16-bit value.
 
template<typename Source>
bool writeFrameStep (const uint8_t step, char *const text, uint8_t &length)
 Writes a step of the frame: one line, STX before the first one, ETX after the last.
 
char * writeLine (char *dst, const char *tag, uint8_t index, uint16_t magnitude, bool negative)
 Writes a whole line: LF, tag and index, TAB, value, TAB, checksum and CR.
 

Variables

constexpr char CR { 0x0D }
 
constexpr char ETX { 0x03 }
 
constexpr char LF { 0x0A }
 
constexpr uint8_t MAX_STEP_LENGTH { 1 + lineSize(4, 6) }
 The most a step writes: STX or ETX, and the longest line, a 4-character tag ("S_MC") with a signed 16-bit value (-32768).
 
constexpr char STX { 0x02 }
 
constexpr char TAB { 0x09 }
 

Detailed Description

The telemetry frame of the IoT output.

Function Documentation

◆ frameLine()

template<typename Source>
char * TeleInfo::frameLine ( uint8_t step,
char * dst )

Writes the line of a step.

Parameters
stepThe index of the step.
dstWhere to write.
Returns
The end of the line, dst for an invalid temperature (no line).

Definition at line 199 of file teleinfo.h.

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

◆ frameSteps()

template<typename Source>
uint8_t TeleInfo::frameSteps ( )
constexpr

The number of steps of a frame: one per line, invalid temperatures included (they write nothing).

Definition at line 167 of file teleinfo.h.

Here is the caller graph for this function:

◆ line()

char * TeleInfo::line ( char * dst,
const char * tag,
int16_t value,
uint8_t index = 0 )
inline

Writes the line of a signed value.

Parameters
dstWhere to write, room for lineSize() bytes.
tagThe tag.
valueThe value.
indexAppended to the tag as a digit (1-9), none when 0.
Returns
The end of the line.

Definition at line 142 of file teleinfo.h.

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

◆ lineSize()

uint8_t TeleInfo::lineSize ( uint8_t tagLength,
uint8_t valueLength )
constexpr

The size of a line: LF, tag, TAB, value, TAB, checksum and CR.

Parameters
tagLengthThe length of the tag, its index included.
valueLengthThe length of the value, its sign included.
Returns
The size of the line in bytes.

Definition at line 51 of file teleinfo.h.

Here is the caller graph for this function:

◆ lineUnsigned()

char * TeleInfo::lineUnsigned ( char * dst,
const char * tag,
uint16_t value,
uint8_t index = 0 )
inline

Writes the line of an unsigned value (above 32767, line() would wrap).

Parameters
dstWhere to write, room for lineSize() bytes.
tagThe tag.
valueThe value.
indexAppended to the tag as a digit (1-9), none when 0.
Returns
The end of the line.

Definition at line 157 of file teleinfo.h.

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

◆ writeDigits()

char * TeleInfo::writeDigits ( char * dst,
uint16_t value )
inline

Writes the decimal digits of a 16-bit value.

Parameters
dstWhere to write.
valueThe value.
Returns
The end of what was written.

Definition at line 69 of file teleinfo.h.

Here is the caller graph for this function:

◆ writeFrameStep()

template<typename Source>
bool TeleInfo::writeFrameStep ( const uint8_t step,
char *const text,
uint8_t & length )

Writes a step of the frame: one line, STX before the first one, ETX after the last.

The lines, in this order:

  • "P": the power at the grid connection, in W (import > 0);
  • with several phases, "Pn" then "Vn" for each phase, the last phase first: the phase's power in W, and its RMS voltage in hundredths of V;
  • with relay diversion, "R": the relays' average power, in W, then "R1" to "Rn": each relay's state (1 ON, 0 OFF), Rn first;
  • "D1" to "Dn": each load's ON time over the datalog period, in %, Dn first;
  • with temperature sensing, "T1" to "Tn": each valid temperature, in hundredths of °C;
  • "N": the number of seconds without diverted energy;
  • with dual tariff, "TA": the tariff (0 high/on-peak, 1 low/off-peak);
  • "S": the number of sample sets over the datalog period;
  • "S_MC": the lowest number of sample sets in a mains cycle.

The data source is a type with these members:

  • static constexpr bool RELAY_DIVERSION, DUAL_TARIFF;
  • static constexpr uint8_t PHASE_COUNT, RELAY_COUNT, LOAD_COUNT, TEMP_COUNT;
  • static int16_t power(), phasePower(uint8_t idx), relayAverage(), loadOnPercent(uint8_t idx), temperature(uint8_t idx);
  • static uint16_t phaseVoltage(uint8_t idx), absenceCount(), sampleSets();
  • static bool relayOn(uint8_t idx), temperatureValid(uint8_t idx), offPeak();
  • static uint8_t lowestSampleSetsPerCycle().

Every value of a frame must stay that of the same datalog period until its last step.

Parameters
stepThe index of the step, from 0.
textWhere to write, room for MAX_STEP_LENGTH characters.
[out]lengthThe number of characters written (0 for an invalid temperature).
Returns
false at the last step.

Definition at line 304 of file teleinfo.h.

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

◆ writeLine()

char * TeleInfo::writeLine ( char * dst,
const char * tag,
uint8_t index,
uint16_t magnitude,
bool negative )
inline

Writes a whole line: LF, tag and index, TAB, value, TAB, checksum and CR.

The checksum is summed over the line once written: about 15 bytes, once per datalog period, in the main loop.

Parameters
dstWhere to write, room for lineSize() bytes.
tagThe tag, at most 4 characters with the index.
indexAppended to the tag as a digit (1-9), none when 0.
magnitudeThe magnitude of the value.
negativeWhether the value is negative.
Returns
The end of the line.

Definition at line 100 of file teleinfo.h.

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

Variable Documentation

◆ CR

char TeleInfo::CR { 0x0D }
inlineconstexpr

Carriage Return character.

Definition at line 41 of file teleinfo.h.

◆ ETX

char TeleInfo::ETX { 0x03 }
inlineconstexpr

End of Frame character.

Definition at line 39 of file teleinfo.h.

◆ LF

char TeleInfo::LF { 0x0A }
inlineconstexpr

Line Feed character.

Definition at line 40 of file teleinfo.h.

◆ MAX_STEP_LENGTH

uint8_t TeleInfo::MAX_STEP_LENGTH { 1 + lineSize(4, 6) }
inlineconstexpr

The most a step writes: STX or ETX, and the longest line, a 4-character tag ("S_MC") with a signed 16-bit value (-32768).

Definition at line 60 of file teleinfo.h.

◆ STX

char TeleInfo::STX { 0x02 }
inlineconstexpr

Start of Frame character.

Definition at line 38 of file teleinfo.h.

◆ TAB

char TeleInfo::TAB { 0x09 }
inlineconstexpr

Tab character.

Definition at line 42 of file teleinfo.h.