Skip to content

Commit

Permalink
Accounting for dataset error for X header in debug line
Browse files Browse the repository at this point in the history
  • Loading branch information
lains committed May 15, 2024
1 parent 6d002e6 commit e9d159a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions inc/domain/TicProcessingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct TicProcessingContext {
TIC::Unframer& ticUnframer; /*!< The encapsulated TIC frame delimiter handler */
unsigned int lostTicBytes; /*!< How many TIC bytes were lost due to forwarding queue overflow? */
unsigned int serialRxOverflowCount; /*!< How many times we didnot read fast enough the serial buffer and bytes where thus lost due to incoming serial buffer overflow */
unsigned int datasetsWithErrors; /*!< How many times did we fail to decode a dataset due to format errors */
TicEvaluatedPower instantaneousPower; /*!< A place to store the instantaneous power measurement */
unsigned int lastParsedFrameNb; /*!< The ID of the last received TIC frame */
unsigned int lastDisplayedPowerFrameNb; /*!< The ID of the last TIC frame for which the instantanous power was displayed on the screen */
Expand Down
1 change: 1 addition & 0 deletions src/domain/TicProcessingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TicProcessingContext::TicProcessingContext(Stm32SerialDriver& ticSerial, TIC::Un
ticUnframer(ticUnframer),
lostTicBytes(0),
serialRxOverflowCount(0),
datasetsWithErrors(0),
instantaneousPower(),
lastParsedFrameNb(static_cast<unsigned int>(-1)),
displayTimeMs(0),
Expand Down
12 changes: 9 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ int main(void) {
return ticContext->currentTime.time;
};
ticParser.setCurrentTimeGetter(currentTimeGetter, static_cast<void*>(&ticContext));
auto increaseDatasetErrorCount = [](void* context) {
TicProcessingContext* ticContext = static_cast<TicProcessingContext*>(context);
ticContext->datasetsWithErrors++;
Stm32DebugOutput::get().send("Dataset error\n");
};
ticParser.invokeOnDatasetError(increaseDatasetErrorCount, static_cast<void*>(&ticContext));

powerHistory.setContext(&ticContext);

Expand Down Expand Up @@ -305,9 +311,9 @@ int main(void) {

pos++;

unsigned int serialRxOverflowCount = ticContext.serialRxOverflowCount;
statusLine[pos++]=(serialRxOverflowCount / 10) % 10 + '0';
statusLine[pos++]=(serialRxOverflowCount / 1) % 10 + '0';
unsigned int errors = ticContext.serialRxOverflowCount + ticContext.datasetsWithErrors;
statusLine[pos++]=(errors / 10) % 10 + '0';
statusLine[pos++]=(errors / 1) % 10 + '0';
pos++; // 'X'

pos++;
Expand Down

0 comments on commit e9d159a

Please sign in to comment.