32static void appendLine(
char* expected,
const char* tagAndValue)
35 for (
const char* p = tagAndValue; *p; ++p)
40 const char line[]{
'\n',
'\0' };
41 strcat(expected, line);
42 strcat(expected, tagAndValue);
43 const char end[]{
'\t',
static_cast< char >((sum & 0x3F) + 0x20),
'\r',
'\0' };
44 strcat(expected, end);
74 TEST_ASSERT_EQUAL_STRING(
expectedLine(
"T1\t-5500"), text);
77 TEST_ASSERT_EQUAL_STRING(
expectedLine(
"S\t64000"), text);
80 TEST_ASSERT_EQUAL_STRING(
expectedLine(
"V2\t46000"), text);
86 TEST_ASSERT_EQUAL_STRING(
expectedLine(
"P\t-32768"), text);
93template< u
int8_t PHASES >
109 return static_cast< int16_t
>(400 + idx);
113 return static_cast< uint16_t
>(46000 + idx);
125 return idx == 0 ? 100 : 37;
172template<
typename Source >
183 out.
write(text, length);
193 char expected[240]{
'\x02' };
210 const char etx[]{
'\x03',
'\0' };
211 strcat(expected, etx);
213 TEST_ASSERT_EQUAL_STRING(expected, out.
text);
222 char expected[240]{
'\x02' };
233 const char etx[]{
'\x03',
'\0' };
234 strcat(expected, etx);
236 TEST_ASSERT_EQUAL_STRING(expected, out.
text);
244 Serial.println(
"Starting TeleInfo embedded tests...");
256 Serial.println(
"All TeleInfo tests completed!");
size_t write(uint8_t c) override
void test_lineSize_calculation(void)
void test_frame_three_phases(void)
static void appendLine(char *expected, const char *tagAndValue)
static void streamFrame(FramePrint &out)
static const char * expectedLine(const char *tagAndValue)
void test_frame_single_phase(void)
void test_teleinfo_line_contents(void)
Stops the MCU once an embedded test suite has run.
constexpr uint8_t MAX_STEP_LENGTH
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).
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.
constexpr uint8_t MAX_STEP_LENGTH
The most a step writes: STX or ETX, and the longest line, a 4-character tag ("S_MC") with a signed 16...
constexpr uint8_t lineSize(uint8_t tagLength, uint8_t valueLength)
The size of a line: LF, tag, TAB, value, TAB, checksum and CR.
char * line(char *dst, const char *tag, int16_t value, uint8_t index=0)
Writes the line of a signed value.
static Streamed streamFrame()
Non-blocking serial output of the datalog.
A data source of writeFrameStep(): 2 loads, 1 relay, 2 temperature sensors (the 2nd invalid).
static uint8_t lowestSampleSetsPerCycle()
static constexpr uint8_t TEMP_COUNT
static int16_t phasePower(uint8_t idx)
static int16_t temperature(uint8_t)
static constexpr uint8_t PHASE_COUNT
static uint16_t sampleSets()
static int16_t relayAverage()
static bool temperatureValid(uint8_t idx)
static bool relayOn(uint8_t)
static constexpr bool RELAY_DIVERSION
static uint16_t absenceCount()
static int16_t loadOnPercent(uint8_t idx)
static constexpr uint8_t LOAD_COUNT
static constexpr bool DUAL_TARIFF
static constexpr uint8_t RELAY_COUNT
static uint16_t phaseVoltage(uint8_t idx)
The telemetry frame of the IoT output, written a line at a time.