Skip to content

Commit ad3c11e

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
1 parent 2e2d887 commit ad3c11e

7 files changed

+388
-139
lines changed

js/flightlog.js

+30
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,35 @@ 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 k, j, i, previousFrame = 0, currentFrame;
306+
307+
for (k = 0; k < chunks.length; k++)
308+
{
309+
for (j = 0; j < chunks[k].frames.length; j++)
310+
{
311+
currentFrame = chunks[k].frames[j];
312+
if (previousFrame == 0)
313+
previousFrame = currentFrame;
314+
315+
for (i = 0; i < currentFrame.length; i++)
316+
{
317+
if (!Array.isArray(currentFrame[i]) && Array.isArray(previousFrame[i]))
318+
{
319+
currentFrame[i] = previousFrame[i];
320+
}
321+
}
322+
323+
previousFrame = chunks[k].frames[j];
324+
}
325+
}
326+
}
327+
299328
/**
300329
* Get the raw chunks in the range [startIndex...endIndex] (inclusive)
301330
*
@@ -504,6 +533,7 @@ function FlightLog(logData) {
504533
}
505534

506535
injectComputedFields(resultChunks, resultChunks);
536+
propagateArrayFields(resultChunks);
507537

508538
return resultChunks;
509539
}

js/flightlog_fielddefs.js

+7
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ let
360360
"RC_STATS",
361361
"MAG_CALIB",
362362
"MAG_TASK_RATE",
363+
"DSHOT_STATUS_N_TEMPERATURE",
364+
"DSHOT_STATUS_N_VOLTAGE",
365+
"DSHOT_STATUS_N_CURRENT",
366+
"DSHOT_STATUS_N_DEBUG1",
367+
"DSHOT_STATUS_N_DEBUG2",
368+
"DSHOT_STATUS_N_STRESS_LVL",
369+
"DSHOT_STATUS_N_ERPM_FRACTION_18",
363370
]),
364371

365372
SUPER_EXPO_YAW = makeReadOnly([

js/flightlog_fields_presenter.js

+66
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,55 @@ function FlightLogFieldPresenter() {
11071107
'debug[5]': 'Read State',
11081108
'debug[6]': 'Task Time (Us)',
11091109
},
1110+
'DSHOT_STATUS_N_TEMPERATURE' : {
1111+
'debug[all]': 'ESC Status & Temperature',
1112+
'debug[0]': 'ESC1',
1113+
'debug[1]': 'ESC2',
1114+
'debug[2]': 'ESC3',
1115+
'debug[3]': 'ESC4',
1116+
},
1117+
'DSHOT_STATUS_N_VOLTAGE' : {
1118+
'debug[all]': 'ESC Status & Voltage',
1119+
'debug[0]': 'ESC1',
1120+
'debug[1]': 'ESC2',
1121+
'debug[2]': 'ESC3',
1122+
'debug[3]': 'ESC4',
1123+
},
1124+
'DSHOT_STATUS_N_CURRENT' : {
1125+
'debug[all]': 'ESC Status & Current',
1126+
'debug[0]': 'ESC1',
1127+
'debug[1]': 'ESC2',
1128+
'debug[2]': 'ESC3',
1129+
'debug[3]': 'ESC4',
1130+
},
1131+
'DSHOT_STATUS_N_DEBUG1' : {
1132+
'debug[all]': 'ESC Status & Debug1',
1133+
'debug[0]': 'ESC1',
1134+
'debug[1]': 'ESC2',
1135+
'debug[2]': 'ESC3',
1136+
'debug[3]': 'ESC4',
1137+
},
1138+
'DSHOT_STATUS_N_DEBUG2' : {
1139+
'debug[all]': 'ESC Status & Debug2',
1140+
'debug[0]': 'ESC1',
1141+
'debug[1]': 'ESC2',
1142+
'debug[2]': 'ESC3',
1143+
'debug[3]': 'ESC4',
1144+
},
1145+
'DSHOT_STATUS_N_STRESS_LVL' : {
1146+
'debug[all]': 'ESC Status & Stress Level',
1147+
'debug[0]': 'ESC1',
1148+
'debug[1]': 'ESC2',
1149+
'debug[2]': 'ESC3',
1150+
'debug[3]': 'ESC4',
1151+
},
1152+
'DSHOT_STATUS_N_ERPM_FRACTION_18' : {
1153+
'debug[all]': 'ESC Status & RPM',
1154+
'debug[0]': 'ESC1',
1155+
'debug[1]': 'ESC2',
1156+
'debug[2]': 'ESC3',
1157+
'debug[3]': 'ESC4',
1158+
},
11101159
};
11111160

11121161
let DEBUG_FRIENDLY_FIELD_NAMES = null;
@@ -1872,7 +1921,24 @@ function FlightLogFieldPresenter() {
18721921
return value.toFixed(0);
18731922
case 'DSHOT_TELEMETRY_COUNTS':
18741923
return value.toFixed(0);
1924+
case 'DSHOT_STATUS_N_TEMPERATURE':
1925+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}ºC` : '---';
1926+
case 'DSHOT_STATUS_N_VOLTAGE':
1927+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}V` : '---';
1928+
case 'DSHOT_STATUS_N_CURRENT':
1929+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}A` : '---';
1930+
case 'DSHOT_STATUS_N_DEBUG1':
1931+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}` : '---';
1932+
case 'DSHOT_STATUS_N_DEBUG2':
1933+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}` : '---';
1934+
case 'DSHOT_STATUS_N_STRESS_LVL':
1935+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${value[4]}sTrs` : '---';
1936+
case 'DSHOT_STATUS_N_ERPM_FRACTION_18':
1937+
var rpm = (value[4] * 200 / flightLog.getSysConfig().motor_poles).toFixed();
1938+
return (value[0] != null) ? `A${value[0]} W${value[1]} E${value[2]} STRESS:${value[3]} ${rpm}Rpm` : '---';
1939+
18751940
}
1941+
18761942
return value.toFixed(0);
18771943
}
18781944
return "";

js/flightlog_parser.js

+82-21
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

@@ -528,9 +533,9 @@ var FlightLogParser = function(logData) {
528533
function translateFieldName(fieldName) {
529534
var translation = translationValues[fieldName];
530535
if (typeof translation !== 'undefined') {
531-
return translation;
536+
return translation;
532537
} else {
533-
return fieldName;
538+
return fieldName;
534539
}
535540
}
536541

@@ -600,14 +605,14 @@ var FlightLogParser = function(logData) {
600605
case "Cleanflight":
601606
that.sysConfig.firmwareType = FIRMWARE_TYPE_CLEANFLIGHT;
602607
$('html').removeClass('isBaseF');
603-
$('html').addClass('isCF');
608+
$('html').addClass('isCF');
604609
$('html').removeClass('isBF');
605610
$('html').removeClass('isINAV');
606611
break;
607612
default:
608613
that.sysConfig.firmwareType = FIRMWARE_TYPE_BASEFLIGHT;
609614
$('html').addClass('isBaseF');
610-
$('html').removeClass('isCF');
615+
$('html').removeClass('isCF');
611616
$('html').removeClass('isBF');
612617
$('html').removeClass('isINAV');
613618
}
@@ -943,7 +948,7 @@ var FlightLogParser = function(logData) {
943948
$('html').addClass('isINAV');
944949
} else {
945950

946-
// Cleanflight 1.x and others
951+
// Cleanflight 1.x and others
947952
that.sysConfig.firmwareVersion = '0.0.0';
948953
that.sysConfig.firmware = 0.0;
949954
that.sysConfig.firmwarePatch = 0;
@@ -1106,6 +1111,34 @@ var FlightLogParser = function(logData) {
11061111
% that.sysConfig.frameIntervalPDenom < that.sysConfig.frameIntervalPNum;
11071112
}
11081113

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

11361169
i++;
11371170
} else {
1171+
// Update current by default
1172+
updateCurrent = true;
1173+
1174+
// Decode
11381175
switch (encoding[i]) {
11391176
case FLIGHT_LOG_FIELD_ENCODING_SIGNED_VB:
11401177
value = stream.readSignedVB();
@@ -1155,7 +1192,7 @@ var FlightLogParser = function(logData) {
11551192
for (j = 0; j < 4; j++, i++)
11561193
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11571194

1158-
continue;
1195+
updateCurrent = false;
11591196
break;
11601197
case FLIGHT_LOG_FIELD_ENCODING_TAG2_3S32:
11611198
stream.readTag2_3S32(values);
@@ -1164,7 +1201,7 @@ var FlightLogParser = function(logData) {
11641201
for (j = 0; j < 3; j++, i++)
11651202
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11661203

1167-
continue;
1204+
updateCurrent = false;
11681205
break;
11691206
case FLIGHT_LOG_FIELD_ENCODING_TAG2_3SVARIABLE:
11701207
stream.readTag2_3SVariable(values);
@@ -1173,7 +1210,7 @@ var FlightLogParser = function(logData) {
11731210
for (j = 0; j < 3; j++, i++)
11741211
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11751212

1176-
continue;
1213+
updateCurrent = false;
11771214
break;
11781215
case FLIGHT_LOG_FIELD_ENCODING_TAG8_8SVB:
11791216
//How many fields are in this encoded group? Check the subsequent field encodings:
@@ -1188,7 +1225,20 @@ var FlightLogParser = function(logData) {
11881225
for (j = 0; j < groupCount; j++, i++)
11891226
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], values[j], current, previous, previous2);
11901227

1191-
continue;
1228+
updateCurrent = false;
1229+
break;
1230+
case FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U:
1231+
value = stream.readSignedVB();
1232+
1233+
current[i] = new Array(5);
1234+
current[i][0] = ((value & 0x8000) != 0) ? 1 : 0;
1235+
current[i][1] = ((value & 0x4000) != 0) ? 1 : 0;
1236+
current[i][2] = ((value & 0x2000) != 0) ? 1 : 0;
1237+
current[i][3] = (value >> 8) & 0x000F;
1238+
current[i][4] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value & 0x00FF, current, previous, previous2);
1239+
i++;
1240+
1241+
updateCurrent = false;
11921242
break;
11931243
case FLIGHT_LOG_FIELD_ENCODING_NULL:
11941244
//Nothing to read
@@ -1201,8 +1251,11 @@ var FlightLogParser = function(logData) {
12011251
throw "Unsupported field encoding " + encoding[i];
12021252
}
12031253

1204-
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value, current, previous, previous2);
1205-
i++;
1254+
// Updates current when it is not updated by the decoder path`
1255+
if (updateCurrent) {
1256+
current[i] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value, current, previous, previous2);
1257+
i++;
1258+
}
12061259
}
12071260
}
12081261
}
@@ -1363,6 +1416,12 @@ var FlightLogParser = function(logData) {
13631416
if (mainHistory[1])
13641417
value += mainHistory[1][FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME];
13651418
break;
1419+
case FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_VOLTAGE:
1420+
value /= 4;
1421+
break;
1422+
case FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_ERPM_FRACTION_18:
1423+
value *= 18;
1424+
break;
13661425
default:
13671426
throw "Unsupported field predictor " + predictor;
13681427
}
@@ -1700,6 +1759,8 @@ var FlightLogParser = function(logData) {
17001759
} else {
17011760
lastSlow = [];
17021761
}
1762+
1763+
assimilateDebugMode(that.sysConfig, this.frameDefs.I);
17031764
};
17041765

17051766
/**

0 commit comments

Comments
 (0)