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

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

Private Member Functions

uint8_t calculateChecksum (uint8_t startPos, uint8_t endPos) const
 Calculates the checksum for a portion of the buffer.
 
void writeTag (const char *tag, uint8_t index)
 Writes a tag to the buffer.
 

Private Attributes

char buffer [calcBufferSize()] {}
 
uint8_t bufferPos { 0 }
 

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.

Definition at line 142 of file teleinfo.h.

Member Function Documentation

◆ calculateChecksum()

uint8_t TeleInfo::calculateChecksum ( uint8_t startPos,
uint8_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 160 of file teleinfo.h.

Here is the caller graph for this function:

◆ endFrame()

void TeleInfo::endFrame ( )
inline

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

Definition at line 227 of file teleinfo.h.

Here is the caller graph for this function:

◆ 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 207 of file teleinfo.h.

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

◆ startFrame()

void TeleInfo::startFrame ( )
inline

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

Definition at line 196 of file teleinfo.h.

Here is the caller graph for this function:

◆ writeTag()

void TeleInfo::writeTag ( const char * tag,
uint8_t index )
inlineprivate

Writes a tag to the buffer.

Parameters
tagThe tag to write.

Definition at line 178 of file teleinfo.h.

Here is the caller graph for this function:

Member Data Documentation

◆ buffer

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

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

Definition at line 151 of file teleinfo.h.

◆ bufferPos

uint8_t TeleInfo::bufferPos { 0 }
private

Current position in the buffer.

Definition at line 152 of file teleinfo.h.

◆ CR

const char TeleInfo::CR { 0x0D }
staticprivate

Carriage Return character.

Definition at line 148 of file teleinfo.h.

◆ ETX

const char TeleInfo::ETX { 0x03 }
staticprivate

End of Frame character.

Definition at line 146 of file teleinfo.h.

◆ LF

const char TeleInfo::LF { 0x0A }
staticprivate

Line Feed character.

Definition at line 147 of file teleinfo.h.

◆ STX

const char TeleInfo::STX { 0x02 }
staticprivate

Start of Frame character.

Definition at line 145 of file teleinfo.h.

◆ TAB

const char TeleInfo::TAB { 0x09 }
staticprivate

Tab character.

Definition at line 149 of file teleinfo.h.


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