Skip to content

Commit 3172578

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
1 parent 5be4a3d commit 3172578

9 files changed

+1352
-1037
lines changed

js/flightlog.js

+30
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,35 @@ function FlightLog(logData) {
303303
return numMotors;
304304
};
305305

306+
/*
307+
* Propagates array data fiels over empty fields
308+
* Debug fields can be arrays with data, so it fills data gaps when no arrays are stored
309+
*/
310+
function propagateArrayFields(chunks)
311+
{
312+
var k, j, i, previousFrame = 0, currentFrame;
313+
314+
for (k = 0; k < chunks.length; k++)
315+
{
316+
for (j = 0; j < chunks[k].frames.length; j++)
317+
{
318+
currentFrame = chunks[k].frames[j];
319+
if (previousFrame == 0)
320+
previousFrame = currentFrame;
321+
322+
for (i = 0; i < currentFrame.length; i++)
323+
{
324+
if (!Array.isArray(currentFrame[i]) && Array.isArray(previousFrame[i]))
325+
{
326+
currentFrame[i] = previousFrame[i];
327+
}
328+
}
329+
330+
previousFrame = chunks[k].frames[j];
331+
}
332+
}
333+
}
334+
306335
/**
307336
* Get the raw chunks in the range [startIndex...endIndex] (inclusive)
308337
*
@@ -511,6 +540,7 @@ function FlightLog(logData) {
511540
}
512541

513542
injectComputedFields(resultChunks, resultChunks);
543+
propagateArrayFields(resultChunks);
514544

515545
return resultChunks;
516546
}

js/flightlog_fielddefs.js

+9
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ let
349349
"ATTITUDE",
350350
"VTX_MSP",
351351
"GPS_DOP",
352+
"ANGLEMODE",
353+
"FAILSAFE",
354+
"DSHOT_STATUS_N_TEMPERATURE",
355+
"DSHOT_STATUS_N_VOLTAGE",
356+
"DSHOT_STATUS_N_CURRENT",
357+
"DSHOT_STATUS_N_DEBUG1",
358+
"DSHOT_STATUS_N_DEBUG2",
359+
"DSHOT_STATUS_N_DEMAG_METRIC",
360+
"DSHOT_STATUS_N_ERPM_FRACTION_18",
352361
]),
353362

354363
SUPER_EXPO_YAW = makeReadOnly([

js/flightlog_fields_presenter.js

+97
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,69 @@ function FlightLogFieldPresenter() {
690690
'debug[2]': 'hDOP (horizontal - 2D)',
691691
'debug[3]': 'vDOP (vertical - 1D)',
692692
},
693+
'ANGLEMODE' : {
694+
'debug[all]': 'ANGLEMODE',
695+
'debug[0]': 'ANGLEMODE1',
696+
'debug[1]': 'ANGLEMODE2',
697+
'debug[2]': 'ANGLEMODE3',
698+
'debug[3]': 'ANGLEMODE4',
699+
},
700+
'FAILSAFE' : {
701+
'debug[all]': 'GPS Dilution of Precision',
702+
'debug[0]': 'Number of Satellites',
703+
'debug[1]': 'pDOP (positional - 3D)',
704+
'debug[2]': 'hDOP (horizontal - 2D)',
705+
'debug[3]': 'vDOP (vertical - 1D)',
706+
},
707+
'DSHOT_STATUS_N_TEMPERATURE' : {
708+
'debug[all]': 'ESC Status & Temperature',
709+
'debug[0]': 'ESC0',
710+
'debug[1]': 'ESC1',
711+
'debug[2]': 'ESC2',
712+
'debug[3]': 'ESC3',
713+
},
714+
'DSHOT_STATUS_N_VOLTAGE' : {
715+
'debug[all]': 'ESC Status & Voltage',
716+
'debug[0]': 'ESC0',
717+
'debug[1]': 'ESC1',
718+
'debug[2]': 'ESC2',
719+
'debug[3]': 'ESC3',
720+
},
721+
'DSHOT_STATUS_N_CURRENT' : {
722+
'debug[all]': 'ESC Status & Current',
723+
'debug[0]': 'ESC0',
724+
'debug[1]': 'ESC1',
725+
'debug[2]': 'ESC2',
726+
'debug[3]': 'ESC3',
727+
},
728+
'DSHOT_STATUS_N_DEBUG1' : {
729+
'debug[all]': 'ESC Status & Debug1',
730+
'debug[0]': 'ESC0',
731+
'debug[1]': 'ESC1',
732+
'debug[2]': 'ESC2',
733+
'debug[3]': 'ESC3',
734+
},
735+
'DSHOT_STATUS_N_DEBUG2' : {
736+
'debug[all]': 'ESC Status & Debug2',
737+
'debug[0]': 'ESC0',
738+
'debug[1]': 'ESC1',
739+
'debug[2]': 'ESC2',
740+
'debug[3]': 'ESC3',
741+
},
742+
'DSHOT_STATUS_N_DEMAG_METRIC' : {
743+
'debug[all]': 'ESC Status & Demag metric',
744+
'debug[0]': 'ESC0',
745+
'debug[1]': 'ESC1',
746+
'debug[2]': 'ESC2',
747+
'debug[3]': 'ESC3',
748+
},
749+
'DSHOT_STATUS_N_ERPM_FRACTION_18' : {
750+
'debug[all]': 'ESC Status & RPM',
751+
'debug[0]': 'ESC0',
752+
'debug[1]': 'ESC1',
753+
'debug[2]': 'ESC2',
754+
'debug[3]': 'ESC3',
755+
},
693756
};
694757

695758
let DEBUG_FRIENDLY_FIELD_NAMES = null;
@@ -1354,7 +1417,41 @@ function FlightLogFieldPresenter() {
13541417
default:
13551418
return (value / 100).toFixed(2);
13561419
}
1420+
case 'ANGLEMODE':
1421+
switch (fieldName) {
1422+
case 'debug[0]': // packetCounter
1423+
case 'debug[1]': // isCrsfPortConfig
1424+
case 'debug[2]': // isLowPowerDisarmed
1425+
case 'debug[3]': // mspTelemetryDescriptor
1426+
default:
1427+
return value.toFixed(0);
1428+
}
1429+
case 'FAILSAFE':
1430+
switch (fieldName) {
1431+
case 'debug[0]': // packetCounter
1432+
case 'debug[1]': // isCrsfPortConfig
1433+
case 'debug[2]': // isLowPowerDisarmed
1434+
case 'debug[3]': // mspTelemetryDescriptor
1435+
default:
1436+
return value.toFixed(0);
1437+
}
1438+
case 'DSHOT_STATUS_N_TEMPERATURE':
1439+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + value[4] + "ºC" : "---";
1440+
case 'DSHOT_STATUS_N_VOLTAGE':
1441+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + value[4] + "V" : "---";
1442+
case 'DSHOT_STATUS_N_CURRENT':
1443+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + value[4] + "A" : "---";
1444+
case 'DSHOT_STATUS_N_DEBUG1':
1445+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + value[4] : "---";
1446+
case 'DSHOT_STATUS_N_DEBUG2':
1447+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + value[4] : "---";
1448+
case 'DSHOT_STATUS_N_DEMAG_METRIC':
1449+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + value[4] + "M" : "---";
1450+
case 'DSHOT_STATUS_N_ERPM_FRACTION_18':
1451+
return (value[0] != null) ? "X" + value[0] + " D" + value[1] + " S" + value[2] + " MAX_DEMAG:" + value[3] + " " + (value[4] * 200 / flightLog.getSysConfig().motor_poles).toFixed() + "RPM" : "---";
1452+
13571453
}
1454+
13581455
return value.toFixed(0);
13591456
}
13601457
return "";

js/flightlog_parser.js

+74-14
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

@@ -513,9 +518,9 @@ var FlightLogParser = function(logData) {
513518
function translateFieldName(fieldName) {
514519
var translation = translationValues[fieldName];
515520
if (typeof translation !== 'undefined') {
516-
return translation;
521+
return translation;
517522
} else {
518-
return fieldName;
523+
return fieldName;
519524
}
520525
}
521526

@@ -585,14 +590,14 @@ var FlightLogParser = function(logData) {
585590
case "Cleanflight":
586591
that.sysConfig.firmwareType = FIRMWARE_TYPE_CLEANFLIGHT;
587592
$('html').removeClass('isBaseF');
588-
$('html').addClass('isCF');
593+
$('html').addClass('isCF');
589594
$('html').removeClass('isBF');
590595
$('html').removeClass('isINAV');
591596
break;
592597
default:
593598
that.sysConfig.firmwareType = FIRMWARE_TYPE_BASEFLIGHT;
594599
$('html').addClass('isBaseF');
595-
$('html').removeClass('isCF');
600+
$('html').removeClass('isCF');
596601
$('html').removeClass('isBF');
597602
$('html').removeClass('isINAV');
598603
}
@@ -919,7 +924,7 @@ var FlightLogParser = function(logData) {
919924
$('html').addClass('isINAV');
920925
} else {
921926

922-
// Cleanflight 1.x and others
927+
// Cleanflight 1.x and others
923928
that.sysConfig.firmwareVersion = '0.0.0';
924929
that.sysConfig.firmware = 0.0;
925930
that.sysConfig.firmwarePatch = 0;
@@ -1080,6 +1085,40 @@ var FlightLogParser = function(logData) {
10801085
% that.sysConfig.frameIntervalPDenom < that.sysConfig.frameIntervalPNum;
10811086
}
10821087

1088+
/**
1089+
* Debug data interpretation depends on the chosen debug mode encodings and other parameters could need to be fixed
1090+
*/
1091+
function assimilateDebugMode(sysConfig, frameDef)
1092+
{
1093+
var k;
1094+
1095+
console.log("Debug mode is " + DEBUG_MODE[sysConfig.debug_mode] + ":" + sysConfig.debug_mode);
1096+
1097+
if (DEBUG_MODE[sysConfig.debug_mode].startsWith("DSHOT_STATUS_N_"))
1098+
{
1099+
for (k = 0; k < frameDef.name.length; k++)
1100+
{
1101+
if (frameDef.name[k].startsWith("debug")) {
1102+
// Assimilate encoding depending on debug mode
1103+
frameDef.encoding[k] = FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U;
1104+
1105+
// Assimilate predictor depending on debug mode
1106+
switch (DEBUG_MODE[sysConfig.debug_mode])
1107+
{
1108+
case "DSHOT_STATUS_N_VOLTAGE":
1109+
frameDef.predictor[k] = FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_VOLTAGE;
1110+
break;
1111+
case "DSHOT_STATUS_N_ERPM_FRACTION_18":
1112+
frameDef.predictor[k] = FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_ERPM_FRACTION_18;
1113+
break;
1114+
default:
1115+
break;
1116+
}
1117+
}
1118+
}
1119+
}
1120+
}
1121+
10831122
/**
10841123
* Attempt to parse the frame of into the supplied `current` buffer using the encoding/predictor
10851124
* definitions from `frameDefs`. The previous frame values are used for predictions.
@@ -1095,7 +1134,7 @@ var FlightLogParser = function(logData) {
10951134
encoding = frameDef.encoding,
10961135
values = new Array(8),
10971136
i, j, groupCount;
1098-
1137+
10991138
i = 0;
11001139
while (i < frameDef.count) {
11011140
var
@@ -1164,6 +1203,19 @@ var FlightLogParser = function(logData) {
11641203

11651204
continue;
11661205
break;
1206+
case FLIGHT_LOG_FIELD_ENCODING_PACK_1F_1F_1F_1G_4U_8U:
1207+
value = stream.readSignedVB();
1208+
1209+
current[i] = new Array(5);
1210+
current[i][0] = ((value & 0x8000) != 0) ? 1 : 0;
1211+
current[i][1] = ((value & 0x4000) != 0) ? 1 : 0;
1212+
current[i][2] = ((value & 0x2000) != 0) ? 1 : 0;
1213+
current[i][3] = (value >> 8) & 0x000F;
1214+
current[i][4] = applyPrediction(i, raw ? FLIGHT_LOG_FIELD_PREDICTOR_0 : predictor[i], value & 0x00FF, current, previous, previous2);
1215+
i++;
1216+
1217+
continue;
1218+
break;
11671219
case FLIGHT_LOG_FIELD_ENCODING_NULL:
11681220
//Nothing to read
11691221
value = 0;
@@ -1337,6 +1389,12 @@ var FlightLogParser = function(logData) {
13371389
if (mainHistory[1])
13381390
value += mainHistory[1][FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME];
13391391
break;
1392+
case FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_VOLTAGE:
1393+
value /= 4;
1394+
break;
1395+
case FLIGHT_LOG_FIELD_PREDICTOR_DSHOT_STATUS_N_ERPM_FRACTION_18:
1396+
value *= 18;
1397+
break;
13401398
default:
13411399
throw "Unsupported field predictor " + predictor;
13421400
}
@@ -1674,6 +1732,8 @@ var FlightLogParser = function(logData) {
16741732
} else {
16751733
lastSlow = [];
16761734
}
1735+
1736+
assimilateDebugMode(that.sysConfig, this.frameDefs.I);
16771737
};
16781738

16791739
/**

0 commit comments

Comments
 (0)