@@ -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 /**
0 commit comments