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

A class for managing and sending telemetry information in a structured frame format. More...

#include <teleinfo.h>

Public Member Functions

 __attribute__ ((always_inline)) void endFrame()
 Finalizes the frame by adding the end character and sending the buffer over Serial.
 
 __attribute__ ((always_inline)) void startFrame()
 Initializes a new frame by resetting the buffer and adding the start character.
 
void send (const char *tag, int16_t value, uint8_t index=0)
 Sends a telemetry value as an integer.
 

Private Member Functions

 __attribute__ ((always_inline)) void writeTag(const char *tag
 Writes a tag to the buffer.
 
uint8_t calculateChecksum (size_t startPos, size_t endPos) const
 Calculates the checksum for a portion of the buffer.
 
 if (index !=0)
 

Private Attributes

while ptr buffer [bufferPos++] = *ptr++
 
 buffer [bufferPos++] = TAB
 
char buffer [calcBufferSize()] {}
 
size_t bufferPos { 0 }
 
uint8_t index
 

Static Private Attributes

static const char CR { 0x0D }
 
static const char ETX { 0x03 }
 
static const char LF { 0x0A }
 
static const char STX { 0x02 }
 
static const char TAB { 0x09 }
 

Detailed Description

A class for managing and sending telemetry information in a structured frame format.

The TeleInfo class is responsible for creating and sending telemetry frames that include various data points such as power, voltage, temperature, and relay states. The frames are formatted with tags, values, and checksums to ensure data integrity.

  • Frame Structure: Each frame starts with a Start-of-Text (STX) character and ends with an End-of-Text (ETX) character. Data points are added as lines, each containing a tag, value, and checksum.
  • Checksum Calculation: A checksum is calculated for each line to ensure data integrity.
  • Conditional Features: The class supports optional features such as relay diversion and temperature sensing, which are included or excluded at compile time based on configuration constants.
  • Buffer Management: A buffer is used to store the frame data before sending it over the Serial interface.
  • Serial Configuration: Uses Serial with 9600 baud, 7 data bits, 1 stop bit, and even parity.

Definition at line 154 of file teleinfo.h.

Member Function Documentation

◆ __attribute__() [1/3]

TeleInfo::__attribute__ ( (always_inline) )
inline

Finalizes the frame by adding the end character and sending the buffer over Serial.

Definition at line 249 of file teleinfo.h.

◆ __attribute__() [2/3]

TeleInfo::__attribute__ ( (always_inline) )
inline

Initializes a new frame by resetting the buffer and adding the start character.

Definition at line 218 of file teleinfo.h.

◆ __attribute__() [3/3]

TeleInfo::__attribute__ ( (always_inline) ) const
private

Writes a tag to the buffer.

Parameters
tagThe tag to write.

◆ calculateChecksum()

uint8_t TeleInfo::calculateChecksum ( size_t startPos,
size_t endPos ) const
inlinenodiscardprivate

Calculates the checksum for a portion of the buffer.

Parameters
startPosThe starting position in the buffer.
endPosThe ending position in the buffer.
Returns
The calculated checksum as a single byte.

Definition at line 172 of file teleinfo.h.

Here is the caller graph for this function:

◆ if()

TeleInfo::if ( index ! = 0)
inlineprivate

Definition at line 206 of file teleinfo.h.

◆ send()

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

Sends a telemetry value as an integer.

Parameters
tagThe tag associated with the value.
valueThe integer value to send.

Definition at line 229 of file teleinfo.h.

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

Member Data Documentation

◆ buffer [1/3]

while ptr TeleInfo::buffer[bufferPos++] = *ptr++
private

Definition at line 203 of file teleinfo.h.

◆ buffer [2/3]

TeleInfo::buffer[bufferPos++] = TAB
private

Definition at line 211 of file teleinfo.h.

◆ buffer [3/3]

char TeleInfo::buffer[calcBufferSize()] {}
private

Buffer to store the frame data. Adjust size as needed.

Definition at line 163 of file teleinfo.h.

◆ bufferPos

size_t TeleInfo::bufferPos { 0 }
private

Current position in the buffer.

Definition at line 164 of file teleinfo.h.

◆ CR

const char TeleInfo::CR { 0x0D }
staticprivate

Carriage Return character.

Definition at line 160 of file teleinfo.h.

◆ ETX

const char TeleInfo::ETX { 0x03 }
staticprivate

End of Frame character.

Definition at line 158 of file teleinfo.h.

◆ index

uint8_t TeleInfo::index
private
Initial value:
{
auto* ptr{ tag }

Definition at line 200 of file teleinfo.h.

◆ LF

const char TeleInfo::LF { 0x0A }
staticprivate

Line Feed character.

Definition at line 159 of file teleinfo.h.

◆ STX

const char TeleInfo::STX { 0x02 }
staticprivate

Start of Frame character.

Definition at line 157 of file teleinfo.h.

◆ TAB

const char TeleInfo::TAB { 0x09 }
staticprivate

Tab character.

Definition at line 161 of file teleinfo.h.


The documentation for this class was generated from the following file: