Skip to content

Commit

Permalink
Resolved issue of log records count and actual log rate computing (#755)
Browse files Browse the repository at this point in the history
* improve field statistic and log rows count calculate

* SonarCloud issue improvement

* code style improvement
  • Loading branch information
demvlad authored Jun 5, 2024
1 parent 0e341d4 commit 07f5961
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,7 @@ export function FlightLog(logData) {

this.getCurrentLogRowsCount = function () {
const stats = this.getStats(this.getLogIndex());
const countI = stats.frame['I'] ? stats.frame['I'].totalCount : 0;
const countP = stats.frame['P'] ? stats.frame['P'].totalCount : 0;
return countI + countP;
return stats.frame['I'].validCount + stats.frame['P'].validCount;
};
}

Expand Down
14 changes: 6 additions & 8 deletions src/flightlog_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ export function FlightLogParser(logData) {
mainHistory[0] = mainHistoryRing[2];
else
mainHistory[0] = mainHistoryRing[0];
return mainStreamIsValid;
}

/**
Expand Down Expand Up @@ -1251,7 +1252,7 @@ export function FlightLogParser(logData) {
that.onFrameReady(gpsHomeIsValid, lastGPS, frameType, frameStart, frameEnd - frameStart);
}

return true;
return gpsHomeIsValid;
}

function completeSlowFrame(frameType, frameStart, frameEnd, raw) {
Expand All @@ -1260,6 +1261,7 @@ export function FlightLogParser(logData) {
if (that.onFrameReady) {
that.onFrameReady(true, lastSlow, frameType, frameStart, frameEnd - frameStart);
}
return true;
}

function completeInterframe(frameType, frameStart, frameEnd, raw) {
Expand Down Expand Up @@ -1300,6 +1302,7 @@ export function FlightLogParser(logData) {
else
mainHistory[0] = mainHistoryRing[0];
}
return mainStreamIsValid;
}

/**
Expand Down Expand Up @@ -1773,13 +1776,12 @@ export function FlightLogParser(logData) {
sizeCount: new Int32Array(256), /* int32 arrays are zero-filled, handy! */
validCount: 0,
corruptCount: 0,
desyncCount: 0,
field: [],
totalCount: 0
};
}

frameTypeStats = this.stats.frame[lastFrameType.marker];
frameTypeStats.totalCount++;
// If we see what looks like the beginning of a new frame, assume that the previous frame was valid:
if (lastFrameSize <= FLIGHT_LOG_MAX_FRAME_LENGTH && looksLikeFrameCompleted) {
var frameAccepted = true;
Expand All @@ -1793,7 +1795,7 @@ export function FlightLogParser(logData) {
frameTypeStats.sizeCount[lastFrameSize]++;
frameTypeStats.validCount++;
} else {
frameTypeStats.desyncCount = frameTypeStats.desyncCount ? ++frameTypeStats.desyncCount : 1;
frameTypeStats.desyncCount++;
}
} else {
//The previous frame was corrupt
Expand All @@ -1803,10 +1805,6 @@ export function FlightLogParser(logData) {
frameTypeStats.corruptCount++;
this.stats.totalCorruptFrames++;

//Let the caller know there was a corrupt frame (don't give them a pointer to the frame data because it is totally worthless)
if (this.onFrameReady)
this.onFrameReady(false, null, lastFrameType.marker, frameStart, lastFrameSize);

/*
* Start the search for a frame beginning after the first byte of the previous corrupt frame.
* This way we can find the start of the next frame after the corrupt frame if the corrupt frame
Expand Down

0 comments on commit 07f5961

Please sign in to comment.