@@ -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