Skip to content

Resolved issue of log records count and actual log rate computing #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 10 additions & 12 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 @@ -1790,22 +1792,18 @@ export function FlightLogParser(logData) {
if (frameAccepted) {
//Update statistics for this frame type
frameTypeStats.bytes += lastFrameSize;
frameTypeStats.sizeCount[lastFrameSize]++;
frameTypeStats.validCount++;
++frameTypeStats.sizeCount[lastFrameSize];
++frameTypeStats.validCount;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer postfix increments over using prefix increment operators

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment

Copy link
Contributor Author

@demvlad demvlad Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer postfix increments over using prefix increment operators

A habit... This has not matter in this case, but for one code style - Ok, one moment.

} else {
frameTypeStats.desyncCount = frameTypeStats.desyncCount ? ++frameTypeStats.desyncCount : 1;
++frameTypeStats.desyncCount;
}
} else {
//The previous frame was corrupt

//We need to resynchronise before we can deliver another main frame:
mainStreamIsValid = false;
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);
++frameTypeStats.corruptCount;
++this.stats.totalCorruptFrames;

/*
* Start the search for a frame beginning after the first byte of the previous corrupt frame.
Expand Down