1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-23 08:15:19 +03:00

Merge pull request #339 from iNavFlight/agh_trace_msp

Add support for viewing trace output via MSP from the sensors tab
This commit is contained in:
Konstantin Sharlaimov 2018-02-13 17:49:36 +10:00 committed by GitHub
commit 353b5f7e36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 1 deletions

9
js/debug_trace.js Normal file
View file

@ -0,0 +1,9 @@
function debugTraceOnLoad()
{
var output = document.getElementById('debug-trace');
setInterval(function() {
output.innerText = getDebugTrace();
}, 100);
}
window.onload = debugTraceOnLoad;

View file

@ -47,7 +47,8 @@ var CONFIG,
CALIBRATION_DATA,
POSITION_ESTIMATOR,
RTH_AND_LAND_CONFIG,
FW_CONFIG;
FW_CONFIG,
DEBUG_TRACE;
var FC = {
MAX_SERVO_RATE: 125,

View file

@ -47,6 +47,12 @@ var mspHelper = (function (gui) {
'IRC_TRAMP': 12
};
// Required for MSP_DEBUGMSG because console.log() doesn't allow omitting
// the newline at the end, so we keep the pending message here until we find a
// '\0', then print it. Messages sent by MSP_DEBUGMSG are guaranteed to
// always finish with a '\0'.
var debugMsgBuffer = '';
/**
*
* @param {MSP} dataHandler
@ -440,6 +446,19 @@ var mspHelper = (function (gui) {
console.log('Settings Saved in EEPROM');
break;
case MSPCodes.MSP_DEBUGMSG:
for (var ii = 0; ii < data.byteLength; ii++) {
var c = data.readU8();
if (c == 0) {
// End of message
if (debugMsgBuffer.length > 1) {
console.log('[DEBUG] ' + debugMsgBuffer);
DEBUG_TRACE = (DEBUG_TRACE || '') + debugMsgBuffer;
}
debugMsgBuffer = '';
continue;
}
debugMsgBuffer += String.fromCharCode(c);
}
break;
case MSPCodes.MSP_DEBUG:
for (i = 0; i < 4; i++)