mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-17 05:15:20 +03:00
Retrieve and display MSP API Version from new MSP_API_VERSION command.
Requires latest firmware.
This commit is contained in:
parent
f64b558d5c
commit
2733f4832e
4 changed files with 33 additions and 14 deletions
|
@ -75,7 +75,7 @@
|
||||||
"serialPortClosedFail": {
|
"serialPortClosedFail": {
|
||||||
"message": "<span style=\"color: red\">Failed</span> to close serial port"
|
"message": "<span style=\"color: red\">Failed</span> to close serial port"
|
||||||
},
|
},
|
||||||
|
|
||||||
"noConfigurationReceived": {
|
"noConfigurationReceived": {
|
||||||
"message": "No configuration received within <span style=\"color: red\">10 seconds</span>, communication <span style=\"color: red\">failed</span>"
|
"message": "No configuration received within <span style=\"color: red\">10 seconds</span>, communication <span style=\"color: red\">failed</span>"
|
||||||
},
|
},
|
||||||
|
@ -85,6 +85,9 @@
|
||||||
"firmwareVersion": {
|
"firmwareVersion": {
|
||||||
"message": "Firmware Version: <strong>$1</strong>"
|
"message": "Firmware Version: <strong>$1</strong>"
|
||||||
},
|
},
|
||||||
|
"apiVersionReceived": {
|
||||||
|
"message": "MultiWii API version <span style=\"color: green\">received</span> - <strong>$1</strong>"
|
||||||
|
},
|
||||||
"uniqueDeviceIdReceived": {
|
"uniqueDeviceIdReceived": {
|
||||||
"message": "Unique device ID <span style=\"color: green\">received</span> - <strong>0x$1</strong>"
|
"message": "Unique device ID <span style=\"color: green\">received</span> - <strong>0x$1</strong>"
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,6 +10,9 @@ var CONFIGURATOR = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var CONFIG = {
|
var CONFIG = {
|
||||||
|
apiVersion: 0,
|
||||||
|
flightControllerIdentifier: '',
|
||||||
|
flightControllerVersion: '',
|
||||||
version: 0,
|
version: 0,
|
||||||
multiType: 0,
|
multiType: 0,
|
||||||
msp_version: 0,
|
msp_version: 0,
|
||||||
|
|
10
js/msp.js
10
js/msp.js
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
// MSP_codes needs to be re-integrated inside MSP object
|
// MSP_codes needs to be re-integrated inside MSP object
|
||||||
var MSP_codes = {
|
var MSP_codes = {
|
||||||
|
MSP_API_VERSION: 1,
|
||||||
|
|
||||||
// MSP commands for Cleanflight original features
|
// MSP commands for Cleanflight original features
|
||||||
MSP_CHANNEL_FORWARDING: 32,
|
MSP_CHANNEL_FORWARDING: 32,
|
||||||
|
@ -169,6 +170,15 @@ MSP.process_data = function(code, message_buffer, message_length) {
|
||||||
var data = new DataView(message_buffer, 0); // DataView (allowing us to view arrayBuffer as struct/union)
|
var data = new DataView(message_buffer, 0); // DataView (allowing us to view arrayBuffer as struct/union)
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case MSP_codes.MSP_API_VERSION:
|
||||||
|
CONFIG.apiVersion = data.getUint8(1) + '.' + data.getUint8(2);
|
||||||
|
var identifier = '';
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
identifier += String.fromCharCode(data.getUint8(3 + i));
|
||||||
|
}
|
||||||
|
CONFIG.flightControllerIdentifier = identifier;
|
||||||
|
CONFIG.flightControllerVersion = data.getUint8(7) + '.' + data.getUint8(8) + '.' + data.getUint8(9);
|
||||||
|
break;
|
||||||
case MSP_codes.MSP_IDENT:
|
case MSP_codes.MSP_IDENT:
|
||||||
CONFIG.version = parseFloat((data.getUint8(0) / 100).toFixed(2));
|
CONFIG.version = parseFloat((data.getUint8(0) / 100).toFixed(2));
|
||||||
CONFIG.multiType = data.getUint8(1);
|
CONFIG.multiType = data.getUint8(1);
|
||||||
|
|
|
@ -136,22 +136,25 @@ function onOpen(openInfo) {
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
// request configuration data
|
// request configuration data
|
||||||
MSP.send_message(MSP_codes.MSP_UID, false, false, function () {
|
MSP.send_message(MSP_codes.MSP_API_VERSION, false, false, function () {
|
||||||
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
GUI.log(chrome.i18n.getMessage('apiVersionReceived', [CONFIG.apiVersion]));
|
||||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
MSP.send_message(MSP_codes.MSP_UID, false, false, function () {
|
||||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
||||||
|
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function () {
|
||||||
|
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||||
|
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVersion', [CONFIG.version]));
|
GUI.log(chrome.i18n.getMessage('firmwareVersion', [CONFIG.version]));
|
||||||
|
|
||||||
if (CONFIG.version >= CONFIGURATOR.firmwareVersionAccepted) {
|
if (CONFIG.version >= CONFIGURATOR.firmwareVersionAccepted) {
|
||||||
CONFIGURATOR.connectionValid = true;
|
CONFIGURATOR.connectionValid = true;
|
||||||
|
|
||||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||||
$('#tabs li a:first').click();
|
$('#tabs li a:first').click();
|
||||||
} else {
|
} else {
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.firmwareVersionAccepted]));
|
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.firmwareVersionAccepted]));
|
||||||
$('div#port-picker a.connect').click(); // disconnect
|
$('div#port-picker a.connect').click(); // disconnect
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue