1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35: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

View file

@ -125,6 +125,10 @@ sources.receiverJs = [
'./tabs/receiver_msp.js'
];
sources.debugTraceJs = [
'./js/debug_trace.js'
];
sources.hexParserJs = [
'./js/workers/hex_parser.js',
];
@ -136,6 +140,7 @@ var output = {
mapJs: 'map.js',
receiverCss: 'receiver-msp.css',
receiverJs: 'receiver-msp.js',
debugTraceJs: 'debug-trace.js',
hexParserJs: 'hex_parser.js',
};

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++)

View file

@ -167,3 +167,13 @@
.tab-sensors .legend .item:nth-child(4) {
fill: #4DA74D;
}
.tab-sensors a.debug-trace {
float: right;
margin-right: 1em;
font-size: 90%;
}
.tab-sensors a.debug-trace:hover {
text-decoration: underline;
}

9
tabs/debug_trace.html Normal file
View file

@ -0,0 +1,9 @@
<html>
<head>
<title>Debug Trace</title>
<script type="text/javascript" src="/build/debug-trace.js"></script>
</head>
<body>
<pre><code id="debug-trace"></code></pre>
</body>
</html>

View file

@ -19,6 +19,8 @@
type="checkbox" name="accel_on" />Accelerometer</label> <label><input type="checkbox"
name="mag_on" />Magnetometer</label> <label><input type="checkbox" name="baro_on" />Barometer</label> <label><input
type="checkbox" name="sonar_on" />Sonar</label> <label><input type="checkbox" name="debug_on" />Debug</label>
<a class="debug-trace" href="javascript:void(0);">Open Debug Trace</a>
</div>
</div>
</div>

View file

@ -482,6 +482,26 @@ TABS.sensors.initialize = function (callback) {
}
});
$("a.debug-trace").click(function () {
var windowWidth = 500;
var windowHeight = 510;
chrome.app.window.create("/tabs/debug_trace.html", {
id: "debug_trace",
innerBounds: {
minWidth: windowWidth, minHeight: windowHeight,
width: windowWidth, height: windowHeight,
},
alwaysOnTop: true
}, function (createdWindow) {
createdWindow.contentWindow.getDebugTrace = function () { return DEBUG_TRACE || ''; };
return true;
});
return false;
});
GUI.content_ready(callback);
});
};