Skip to content

Commit 2d50013

Browse files
committed
Updated parser and field presenter for edt signals.
Found a workaround to plot esc signal 4 Added basic ESC plot functionality updated project files Implemented array fiels propagation over empty fields Fixed bad FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U decoding Removed tabs on changed files Fixed some more review findings Updated DSHOT_STATUS_N_ERPM_FRACTION_18 graph ranges Reverted changes in package.json and yarn.lock Improved wording and graph ranges Updated concatenations to template literals If a field contain array values always use the last field for graph Added DSHOT motor events to graph Fixed review findings Added demag events to graph Changed speciffic Bluejay wording by general esc one Fixed sonarcloud false positive Updated debug modes to match the ones in bf master Added debug mode to match edt_events Betaflight branch Removed duplicated BARO graph config Fixed review findings Using let instead of var Refactored if to meet sonarcloud advise
1 parent b8cade7 commit 2d50013

File tree

7 files changed

+370
-139
lines changed

7 files changed

+370
-139
lines changed

js/flightlog.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,39 @@ function FlightLog(logData) {
296296
return numMotors;
297297
};
298298

299+
/*
300+
* Propagates array data fiels over empty fields
301+
* Debug fields can be arrays with data, so it fills data gaps when no arrays are stored
302+
*/
303+
function propagateArrayFields(chunks)
304+
{
305+
var currentFrame;
306+
307+
for (let k = 0; k < chunks.length; k++)
308+
{
309+
let previousFrame = 0;
310+
311+
for (let j = 0; j < chunks[k].frames.length; j++)
312+
{
313+
currentFrame = chunks[k].frames[j];
314+
if (previousFrame == 0)
315+
{
316+
previousFrame = currentFrame;
317+
}
318+
319+
for (let i = 0; i < currentFrame.length; i++)
320+
{
321+
if (!Array.isArray(currentFrame[i]) && Array.isArray(previousFrame[i]))
322+
{
323+
currentFrame[i] = previousFrame[i];
324+
}
325+
}
326+
327+
previousFrame = chunks[k].frames[j];
328+
}
329+
}
330+
}
331+
299332
/**
300333
* Get the raw chunks in the range [startIndex...endIndex] (inclusive)
301334
*
@@ -504,6 +537,7 @@ function FlightLog(logData) {
504537
}
505538

506539
injectComputedFields(resultChunks, resultChunks);
540+
propagateArrayFields(resultChunks);
507541

508542
return resultChunks;
509543
}

js/flightlog_fielddefs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,13 @@ let
361361
"MAG_CALIB",
362362
"MAG_TASK_RATE",
363363
"EZLANDING",
364+
"DSHOT_STATUS_N_TEMPERATURE",
365+
"DSHOT_STATUS_N_VOLTAGE",
366+
"DSHOT_STATUS_N_CURRENT",
367+
"DSHOT_STATUS_N_DEBUG1",
368+
"DSHOT_STATUS_N_DEBUG2",
369+
"DSHOT_STATUS_N_STRESS_LVL",
370+
"DSHOT_STATUS_N_ERPM_FRACTION_18",
364371
]),
365372

366373
SUPER_EXPO_YAW = makeReadOnly([

js/flightlog_fields_presenter.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,55 @@ function FlightLogFieldPresenter() {
11141114
'debug[2]': 'Upper Limit',
11151115
'debug[3]': 'EZ Land Limit',
11161116
},
1117+
'DSHOT_STATUS_N_TEMPERATURE' : {
1118+
'debug[all]': 'ESC Status & Temperature',
1119+
'debug[0]': 'ESC1',
1120+
'debug[1]': 'ESC2',
1121+
'debug[2]': 'ESC3',
1122+
'debug[3]': 'ESC4',
1123+
},
1124+
'DSHOT_STATUS_N_VOLTAGE' : {
1125+
'debug[all]': 'ESC Status & Voltage',
1126+
'debug[0]': 'ESC1',
1127+
'debug[1]': 'ESC2',
1128+
'debug[2]': 'ESC3',
1129+
'debug[3]': 'ESC4',
1130+
},
1131+
'DSHOT_STATUS_N_CURRENT' : {
1132+
'debug[all]': 'ESC Status & Current',
1133+
'debug[0]': 'ESC1',
1134+
'debug[1]': 'ESC2',
1135+
'debug[2]': 'ESC3',
1136+
'debug[3]': 'ESC4',
1137+
},
1138+
'DSHOT_STATUS_N_DEBUG1' : {
1139+
'debug[all]': 'ESC Status & Debug1',
1140+
'debug[0]': 'ESC1',
1141+
'debug[1]': 'ESC2',
1142+
'debug[2]': 'ESC3',
1143+
'debug[3]': 'ESC4',
1144+
},
1145+
'DSHOT_STATUS_N_DEBUG2' : {
1146+
'debug[all]': 'ESC Status & Debug2',
1147+
'debug[0]': 'ESC1',
1148+
'debug[1]': 'ESC2',
1149+
'debug[2]': 'ESC3',
1150+
'debug[3]': 'ESC4',
1151+
},
1152+
'DSHOT_STATUS_N_STRESS_LVL' : {
1153+
'debug[all]': 'ESC Status & Stress Level',
1154+
'debug[0]': 'ESC1',
1155+
'debug[1]': 'ESC2',
1156+
'debug[2]': 'ESC3',
1157+
'debug[3]': 'ESC4',
1158+
},
1159+
'DSHOT_STATUS_N_ERPM_FRACTION_18' : {
1160+
'debug[all]': 'ESC Status & RPM',
1161+
'debug[0]': 'ESC1',
1162+
'debug[1]': 'ESC2',
1163+
'debug[2]': 'ESC3',
1164+
'debug[3]': 'ESC4',
1165+
},
11171166
};
11181167

11191168
let DEBUG_FRIENDLY_FIELD_NAMES = null;
@@ -1879,7 +1928,24 @@ function FlightLogFieldPresenter() {
18791928
return value.toFixed(0);
18801929
case 'DSHOT_TELEMETRY_COUNTS':
18811930
return value.toFixed(0);
1931+
case 'DSHOT_STATUS_N_TEMPERATURE':
1932+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}ºC` : '---';
1933+
case 'DSHOT_STATUS_N_VOLTAGE':
1934+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}V` : '---';
1935+
case 'DSHOT_STATUS_N_CURRENT':
1936+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}A` : '---';
1937+
case 'DSHOT_STATUS_N_DEBUG1':
1938+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}` : '---';
1939+
case 'DSHOT_STATUS_N_DEBUG2':
1940+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}` : '---';
1941+
case 'DSHOT_STATUS_N_STRESS_LVL':
1942+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}sTrs` : '---';
1943+
case 'DSHOT_STATUS_N_ERPM_FRACTION_18':
1944+
var rpm = (value[4] * 200 / flightLog.getSysConfig().motor_poles).toFixed();
1945+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${rpm}Rpm` : '---';
1946+
18821947
}
1948+
18831949
return value.toFixed(0);
18841950
}
18851951
return "";

js/flightlog_parser.js

Lines changed: 82 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,23 @@ var FlightLogParser = function(logData) {
5858
//Predict that this field is minthrottle
5959
FLIGHT_LOG_FIELD_PREDICTOR_MINMOTOR = 11,
6060

61+
//Predict that this field is dshot status and other data
62+
FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_VOLTAGE = 12,
63+
FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_ERPM_FRACTION_18 = 13,
64+
6165
//Home coord predictors appear in pairs (two copies of FLIGHT_LOG_FIELD_PREDICTOR_HOME_COORD). Rewrite the second
6266
//one we see to this to make parsing easier
6367
FLIGHT_LOG_FIELD_PREDICTOR_HOME_COORD_1 = 256,
6468

65-
FLIGHT_LOG_FIELD_ENCODING_SIGNED_VB = 0, // Signed variable-byte
66-
FLIGHT_LOG_FIELD_ENCODING_UNSIGNED_VB = 1, // Unsigned variable-byte
67-
FLIGHT_LOG_FIELD_ENCODING_NEG_14BIT = 3, // Unsigned variable-byte but we negate the value before storing, value is 14 bits
68-
FLIGHT_LOG_FIELD_ENCODING_TAG8_8SVB = 6,
69-
FLIGHT_LOG_FIELD_ENCODING_TAG2_3S32 = 7,
70-
FLIGHT_LOG_FIELD_ENCODING_TAG8_4S16 = 8,
71-
FLIGHT_LOG_FIELD_ENCODING_NULL = 9, // Nothing is written to the file, take value to be zero
72-
FLIGHT_LOG_FIELD_ENCODING_TAG2_3SVARIABLE = 10,
69+
FLIGHT_LOG_FIELD_ENCODING_SIGNED_VB = 0, // Signed variable-byte
70+
FLIGHT_LOG_FIELD_ENCODING_UNSIGNED_VB = 1, // Unsigned variable-byte
71+
FLIGHT_LOG_FIELD_ENCODING_NEG_14BIT = 3, // Unsigned variable-byte but we negate the value before storing, value is 14 bits
72+
FLIGHT_LOG_FIELD_ENCODING_TAG8_8SVB = 6,
73+
FLIGHT_LOG_FIELD_ENCODING_TAG2_3S32 = 7,
74+
FLIGHT_LOG_FIELD_ENCODING_TAG8_4S16 = 8,
75+
FLIGHT_LOG_FIELD_ENCODING_NULL = 9, // Nothing is written to the file, take value to be zero
76+
FLIGHT_LOG_FIELD_ENCODING_TAG2_3SVARIABLE = 10,
77+
FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U = 11, // 1 flagBit, 1 flagBit, 1 flagBit, 1 gapBit, 4 unsignedIntBit, 8 unsignedIntBit
7378

7479
FLIGHT_LOG_EVENT_LOG_END = 255,
7580

@@ -530,9 +535,9 @@ var FlightLogParser = function(logData) {
530535
function translateFieldName(fieldName) {
531536
var translation = translationValues[fieldName];
532537
if (typeof translation !== 'undefined') {
533-
return translation;
538+
return translation;
534539
} else {
535-
return fieldName;
540+
return fieldName;
536541
}
537542
}
538543

@@ -602,14 +607,14 @@ var FlightLogParser = function(logData) {
602607
case "Cleanflight":
603608
that.sysConfig.firmwareType = FIRMWARE_TYPE_CLEANFLIGHT;
604609
$('html').removeClass('isBaseF');
605-
$('html').addClass('isCF');
610+
$('html').addClass('isCF');
606611
$('html').removeClass('isBF');
607612
$('html').removeClass('isINAV');
608613
break;
609614
default:
610615
that.sysConfig.firmwareType = FIRMWARE_TYPE_BASEFLIGHT;
611616
$('html').addClass('isBaseF');
612-
$('html').removeClass('isCF');
617+
$('html').removeClass('isCF');
613618
$('html').removeClass('isBF');
614619
$('html').removeClass('isINAV');
615620
}
@@ -946,7 +951,7 @@ var FlightLogParser = function(logData) {
946951
$('html').addClass('isINAV');
947952
} else {
948953

949-
// Cleanflight 1.x and others
954+
// Cleanflight 1.x and others
950955
that.sysConfig.firmwareVersion = '0.0.0';
951956
that.sysConfig.firmware = 0.0;
952957
that.sysConfig.firmwarePatch = 0;
@@ -1109,6 +1114,34 @@ var FlightLogParser = function(logData) {
11091114
% that.sysConfig.frameIntervalPDenom < that.sysConfig.frameIntervalPNum;
11101115
}
11111116

1117+
/**
1118+
* Debug data interpretation depends on the chosen debug mode encodings and other parameters could need to be fixed
1119+
*/
1120+
function assimilateDebugMode(sysConfig, frameDef) {
1121+
console.log("Debug mode is " + DEBUG_MODE[sysConfig.debug_mode] + ":" + sysConfig.debug_mode);
1122+
1123+
if (DEBUG_MODE[sysConfig.debug_mode].startsWith("DSHOT_STATUS_N_")) {
1124+
for (let k = 0; k < frameDef.name.length; k++) {
1125+
if (frameDef.name[k].startsWith("debug")) {
1126+
// Assimilate encoding depending on debug mode
1127+
frameDef.encoding[k] = FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U;
1128+
1129+
// Assimilate predictor depending on debug mode
1130+
switch (DEBUG_MODE[sysConfig.debug_mode]) {
1131+
case "DSHOT_STATUS_N_VOLTAGE":
1132+
frameDef.predictor[k] = FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_VOLTAGE;
1133+
break;
1134+
case "DSHOT_STATUS_N_ERPM_FRACTION_18":
1135+
frameDef.predictor[k] = FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_ERPM_FRACTION_18;
1136+
break;
1137+
default:
1138+
break;
1139+
}
1140+
}
1141+
}
1142+
}
1143+
}
1144+
11121145
/**
11131146
* Attempt to parse the frame of into the supplied `current` buffer using the encoding/predictor
11141147
* definitions from `frameDefs`. The previous frame values are used for predictions.
@@ -1123,8 +1156,8 @@ var FlightLogParser = function(logData) {
11231156
predictor = frameDef.predictor,
11241157
encoding = frameDef.encoding,
11251158
values = new Array(8),
1126-
i, j, groupCount;
1127-
1159+
i, j, groupCount, updateCurrent;
1160+
11281161
i = 0;
11291162
while (i < frameDef.count) {
11301163
var
@@ -1138,6 +1171,10 @@ var FlightLogParser = function(logData) {
11381171

11391172
i++;
11401173
} else {
1174+
// Update current by default
1175+
updateCurrent = true;
1176+
1177+
// Decode
11411178
switch (encoding[i]) {
11421179
case FLIGHT_LOG_FIELD_ENCODING_SIGNED_VB:
11431180
value = stream.readSignedVB();
@@ -1158,7 +1195,7 @@ var FlightLogParser = function(logData) {
11581195
for (j = 0; j < 4; j++, i++)
11591196
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11601197

1161-
continue;
1198+
updateCurrent = false;
11621199
break;
11631200
case FLIGHT_LOG_FIELD_ENCODING_TAG2_3S32:
11641201
stream.readTag2_3S32(values);
@@ -1167,7 +1204,7 @@ var FlightLogParser = function(logData) {
11671204
for (j = 0; j < 3; j++, i++)
11681205
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11691206

1170-
continue;
1207+
updateCurrent = false;
11711208
break;
11721209
case FLIGHT_LOG_FIELD_ENCODING_TAG2_3SVARIABLE:
11731210
stream.readTag2_3SVariable(values);
@@ -1176,7 +1213,7 @@ var FlightLogParser = function(logData) {
11761213
for (j = 0; j < 3; j++, i++)
11771214
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11781215

1179-
continue;
1216+
updateCurrent = false;
11801217
break;
11811218
case FLIGHT_LOG_FIELD_ENCODING_TAG8_8SVB:
11821219
//How many fields are in this encoded group? Check the subsequent field encodings:
@@ -1191,7 +1228,20 @@ var FlightLogParser = function(logData) {
11911228
for (j = 0; j < groupCount; j++, i++)
11921229
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11931230

1194-
continue;
1231+
updateCurrent = false;
1232+
break;
1233+
case FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U:
1234+
value = stream.readSignedVB();
1235+
1236+
current[i] = new Array(5);
1237+
current[i][0] = ((value & 0x8000) != 0) ? 1 : 0;
1238+
current[i][1] = ((value & 0x4000) != 0) ? 1 : 0;
1239+
current[i][2] = ((value & 0x2000) != 0) ? 1 : 0;
1240+
current[i][3] = (value >> 8) & 0x000F;
1241+
current[i][4] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value & 0x00FF, current, previous, previous2);
1242+
i++;
1243+
1244+
updateCurrent = false;
11951245
break;
11961246
case FLIGHT_LOG_FIELD_ENCODING_NULL:
11971247
//Nothing to read
@@ -1204,8 +1254,11 @@ var FlightLogParser = function(logData) {
12041254
throw "Unsupported field encoding " + encoding[i];
12051255
}
12061256

1207-
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value, current, previous, previous2);
1208-
i++;
1257+
// Updates current when it is not updated by the decoder path`
1258+
if (updateCurrent) {
1259+
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value, current, previous, previous2);
1260+
i++;
1261+
}
12091262
}
12101263
}
12111264
}
@@ -1366,6 +1419,12 @@ var FlightLogParser = function(logData) {
13661419
if (mainHistory[1])
13671420
value += mainHistory[1][FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME];
13681421
break;
1422+
case FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_VOLTAGE:
1423+
value /= 4;
1424+
break;
1425+
case FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_ERPM_FRACTION_18:
1426+
value *= 18;
1427+
break;
13691428
default:
13701429
throw "Unsupported field predictor " + predictor;
13711430
}
@@ -1703,6 +1762,8 @@ var FlightLogParser = function(logData) {
17031762
} else {
17041763
lastSlow = [];
17051764
}
1765+
1766+
assimilateDebugMode(that.sysConfig, this.frameDefs.I);
17061767
};
17071768

17081769
/**

js/graph_config.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ GraphConfig.load = function(config) {
996996
default:
997997
return getCurveForMinMaxFields(fieldName);
998998
}
999+
9991000
case 'GPS_DOP':
10001001
switch (fieldName) {
10011002
case 'debug[0]': // Number of Satellites (now this is in normal GPS data, maybe gpsTrust?)
@@ -1135,7 +1136,33 @@ GraphConfig.load = function(config) {
11351136
default:
11361137
return getCurveForMinMaxFields(fieldName);
11371138
}
1138-
}
1139+
case 'DSHOT_STATUS_N_TEMPERATURE':
1140+
case 'DSHOT_STATUS_N_CURRENT':
1141+
case 'DSHOT_STATUS_N_DEBUG1':
1142+
case 'DSHOT_STATUS_N_DEBUG2':
1143+
case 'DSHOT_STATUS_N_STRESS_LVL':
1144+
return {
1145+
offset: 0,
1146+
power: 1.0,
1147+
inputRange: 400,
1148+
outputRange: 1.0,
1149+
};
1150+
case 'DSHOT_STATUS_N_VOLTAGE':
1151+
return {
1152+
offset: 0,
1153+
power: 1.0,
1154+
inputRange: 255,
1155+
outputRange: 1.0,
1156+
};
1157+
case 'DSHOT_STATUS_N_ERPM_FRACTION_18':
1158+
return {
1159+
offset: 0,
1160+
power: 1.0,
1161+
inputRange: 4000,
1162+
outputRange: 1.0,
1163+
};
1164+
1165+
}
11391166
}
11401167
// if not found above then
11411168
// Scale and center the field based on the whole-log observed ranges for that field

0 commit comments

Comments
 (0)