1-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 144 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 239 of file teleinfo.h.

References buffer, bufferPos, and ETX.

◆ __attribute__() [2/3]

TeleInfo::__attribute__ ( (always_inline) )
inline

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

Definition at line 208 of file teleinfo.h.

References buffer, bufferPos, and STX.

◆ __attribute__() [3/3]

TeleInfo::__attribute__ ( (always_inline) ) const
private

Writes a tag to the buffer.

Parameters
tagThe tag to write.

References index.

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

References buffer.

Referenced by send().

Here is the caller graph for this function:

◆ if()

TeleInfo::if ( index ! = 0)
inlineprivate

Definition at line 196 of file teleinfo.h.

References buffer, bufferPos, and index.

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

References buffer, bufferPos, calculateChecksum(), CR, index, LF, and TAB.

Referenced by sendTelemetryData().

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

◆ buffer [2/3]

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

Definition at line 201 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 153 of file teleinfo.h.

Referenced by __attribute__(), __attribute__(), calculateChecksum(), if(), and send().

◆ bufferPos

size_t TeleInfo::bufferPos { 0 }
private

Current position in the buffer.

Definition at line 154 of file teleinfo.h.

Referenced by __attribute__(), __attribute__(), if(), and send().

◆ CR

const char TeleInfo::CR { 0x0D }
staticprivate

Carriage Return character.

Definition at line 150 of file teleinfo.h.

Referenced by send().

◆ ETX

const char TeleInfo::ETX { 0x03 }
staticprivate

End of Frame character.

Definition at line 148 of file teleinfo.h.

Referenced by __attribute__().

◆ index

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

Definition at line 190 of file teleinfo.h.

Referenced by __attribute__(), if(), and send().

◆ LF

const char TeleInfo::LF { 0x0A }
staticprivate

Line Feed character.

Definition at line 149 of file teleinfo.h.

Referenced by send().

◆ STX

const char TeleInfo::STX { 0x02 }
staticprivate

Start of Frame character.

Definition at line 147 of file teleinfo.h.

Referenced by __attribute__().

◆ TAB

const char TeleInfo::TAB { 0x09 }
staticprivate

Tab character.

Definition at line 151 of file teleinfo.h.

Referenced by send().


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