mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 12:55:13 +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:
commit
353b5f7e36
8 changed files with 76 additions and 1 deletions
|
@ -125,6 +125,10 @@ sources.receiverJs = [
|
||||||
'./tabs/receiver_msp.js'
|
'./tabs/receiver_msp.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
sources.debugTraceJs = [
|
||||||
|
'./js/debug_trace.js'
|
||||||
|
];
|
||||||
|
|
||||||
sources.hexParserJs = [
|
sources.hexParserJs = [
|
||||||
'./js/workers/hex_parser.js',
|
'./js/workers/hex_parser.js',
|
||||||
];
|
];
|
||||||
|
@ -136,6 +140,7 @@ var output = {
|
||||||
mapJs: 'map.js',
|
mapJs: 'map.js',
|
||||||
receiverCss: 'receiver-msp.css',
|
receiverCss: 'receiver-msp.css',
|
||||||
receiverJs: 'receiver-msp.js',
|
receiverJs: 'receiver-msp.js',
|
||||||
|
debugTraceJs: 'debug-trace.js',
|
||||||
hexParserJs: 'hex_parser.js',
|
hexParserJs: 'hex_parser.js',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
9
js/debug_trace.js
Normal file
9
js/debug_trace.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
function debugTraceOnLoad()
|
||||||
|
{
|
||||||
|
var output = document.getElementById('debug-trace');
|
||||||
|
setInterval(function() {
|
||||||
|
output.innerText = getDebugTrace();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onload = debugTraceOnLoad;
|
3
js/fc.js
3
js/fc.js
|
@ -47,7 +47,8 @@ var CONFIG,
|
||||||
CALIBRATION_DATA,
|
CALIBRATION_DATA,
|
||||||
POSITION_ESTIMATOR,
|
POSITION_ESTIMATOR,
|
||||||
RTH_AND_LAND_CONFIG,
|
RTH_AND_LAND_CONFIG,
|
||||||
FW_CONFIG;
|
FW_CONFIG,
|
||||||
|
DEBUG_TRACE;
|
||||||
|
|
||||||
var FC = {
|
var FC = {
|
||||||
MAX_SERVO_RATE: 125,
|
MAX_SERVO_RATE: 125,
|
||||||
|
|
|
@ -47,6 +47,12 @@ var mspHelper = (function (gui) {
|
||||||
'IRC_TRAMP': 12
|
'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
|
* @param {MSP} dataHandler
|
||||||
|
@ -440,6 +446,19 @@ var mspHelper = (function (gui) {
|
||||||
console.log('Settings Saved in EEPROM');
|
console.log('Settings Saved in EEPROM');
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSP_DEBUGMSG:
|
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;
|
break;
|
||||||
case MSPCodes.MSP_DEBUG:
|
case MSPCodes.MSP_DEBUG:
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
|
|
|
@ -167,3 +167,13 @@
|
||||||
.tab-sensors .legend .item:nth-child(4) {
|
.tab-sensors .legend .item:nth-child(4) {
|
||||||
fill: #4DA74D;
|
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
9
tabs/debug_trace.html
Normal 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>
|
|
@ -19,6 +19,8 @@
|
||||||
type="checkbox" name="accel_on" />Accelerometer</label> <label><input type="checkbox"
|
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
|
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>
|
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>
|
</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);
|
GUI.content_ready(callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue