mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 04:45:18 +03:00
Add support for viewing trace output via MSP from the sensors tab
Use an additional window to show the debug trace, so the configurator can be used at the same time the user is viewing the output.
This commit is contained in:
parent
302c79aeb3
commit
b98d7a8f3b
6 changed files with 70 additions and 1 deletions
3
js/fc.js
3
js/fc.js
|
@ -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,
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -167,3 +167,14 @@
|
|||
.tab-sensors .legend .item:nth-child(4) {
|
||||
fill: #4DA74D;
|
||||
}
|
||||
|
||||
.tab-sensors a.debug-trace {
|
||||
float: right;
|
||||
margin-right: 1em;
|
||||
font-size: 90%;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.tab-sensors a.debug-trace::hover {
|
||||
text-decoration: underline;
|
||||
}
|
16
tabs/debug_trace.html
Normal file
16
tabs/debug_trace.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Debug Trace</title>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
var output = document.getElementById('debug-trace');
|
||||
setInterval(function() {
|
||||
output.innerText = getDebugTrace();
|
||||
}, 100);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<pre><code id="debug-trace"></code></pre>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue