From b9358083d95b31bf7ef57dce91875e3c76607749 Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 15 Jul 2018 23:39:18 +1200 Subject: [PATCH 1/2] Added buttons for reboot into boot loader and MSC modes. --- locales/en/messages.json | 23 ++++++++++++++++++++++- src/js/main.js | 14 +++++++++++++- src/js/msp/MSPHelper.js | 23 ++++++++++++++++++++++- src/js/tabs/setup.js | 24 +++++++++++++++++++++++- src/main.html | 10 ++++++++++ src/tabs/setup.html | 12 ++++++++++++ 6 files changed, 102 insertions(+), 4 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index ef0fa052..acf7a1a8 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -9,12 +9,21 @@ "error": { "message": "Error: {{errorMessage}}" }, + "errorTitle": { + "message": "Error" + }, "warningTitle": { "message": "Warning" }, "noticeTitle": { "message": "Notice" }, + "operationNotSupported": { + "message": "This operation is not supported by your hardware." + }, + "storageDeviceNotReady": { + "message": "The storage device is not ready. In the case of a microSD card, make sure it is properly recognised by your flight controller." + }, "options_title": { "message": "Application Options" }, @@ -598,8 +607,20 @@ "initialSetupButtonRestore": { "message": "Restore" }, + "initialSetupButtonRebootBootloader": { + "message": "Activate Boot Loader / DFU" + }, + "initialSetupButtonRebootMsc": { + "message": "Activate Mass Storage Device Mode" + }, "initialSetupBackupRestoreText": { - "message": "Backup your configuration in case of an accident, CLI settings are not included - See 'dump' cli command" + "message": "Backup your configuration in case of an accident, CLI settings are not included - use the command 'diff all' in CLI for this." + }, + "initialSetupRebootBootloaderText": { + "message": "Reboot into boot loader / DFU mode." + }, + "initialSetupRebootMscText": { + "message": "Reboot into mass storage device (MSC) mode. Once activated, the onboard flash or SD card on your flight controller will be recognised as a storage device by your computer, and allow you to download your log files. Eject and power cycel your flight controller to leave mass storage device mode." }, "initialSetupBackupSuccess": { "message": "Backup saved successfully" diff --git a/src/js/main.js b/src/js/main.js index 326921c2..9ebe303a 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -642,4 +642,16 @@ function openNewWindowsInExternalBrowser() { } catch (ex) { console.log("require does not exist, maybe inside chrome"); } -} \ No newline at end of file +} + +function showErrorDialog(message) { + var dialog = $('.dialogError')[0]; + + $('.dialogError-content').html(message); + + $('.dialogError-closebtn').click(function() { + dialog.close(); + }); + + dialog.showModal(); +} diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index b82c5c76..ba13a314 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -27,6 +27,12 @@ function MspHelper () { 'RUNCAM_DEVICE_CONTROL': 14, // support communitate with RunCam Device 'LIDAR_TF': 15 }; + + self.REBOOT_TYPES = { + FIRMWARE: 0, + BOOTLOADER: 1, + MSC: 2 + }; } MspHelper.prototype.reorderPwmProtocols = function (protocol) { @@ -617,6 +623,17 @@ MspHelper.prototype.process_data = function(dataHandler) { break; case MSPCodes.MSP_SET_REBOOT: + if (semver.gte(CONFIG.apiVersion, "1.40.0")) { + var rebootType = data.read8(); + if (rebootType === self.REBOOT_TYPES.MSC) { + if (data.read8() === 0) { + console.log('Storage device not ready.'); + + showErrorDialog(i18n.getMessage('storageDeviceNotReady')); + break; + } + } + } console.log('Reboot request accepted'); break; @@ -1185,6 +1202,11 @@ MspHelper.prototype.process_data = function(dataHandler) { console.log('Unknown code detected: ' + code); } else { console.log('FC reports unsupported message error: ' + code); + + switch (code) { + case MSPCodes.MSP_SET_REBOOT: + showErrorDialog(i18n.getMessage('operationNotSupported')); + } } } // trigger callbacks, cleanup/remove callback after trigger @@ -1207,7 +1229,6 @@ MspHelper.prototype.process_data = function(dataHandler) { } } - /** * Encode the request body for the MSP request with the given code and return it as an array of bytes. */ diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 686b0698..6682c6db 100755 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -59,9 +59,31 @@ TABS.setup.initialize = function (callback) { self.initializeInstruments(); - $('#arming-disable-flag-row').attr('title', i18n.getMessage('initialSetupArmingDisableFlagsTooltip')); + if (semver.gte(CONFIG.apiVersion, "1.40.0")) { + if (isExpertModeEnabled()) { + $('.initialSetupRebootBootloader').show(); + } else { + $('.initialSetupRebootBootloader').hide(); + } + + $('a.rebootBootloader').click(function () { + var buffer = []; + buffer.push(1); + MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); + }); + + $('a.rebootMsc').click(function () { + var buffer = []; + buffer.push(2); + MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); + }); + } else { + $('.initialSetupRebootBootloader').hide(); + $('.initialSetupRebootMsc').hide(); + } + // UI Hooks $('a.calibrateAccel').click(function () { var self = $(this); diff --git a/src/main.html b/src/main.html index cdd9775b..94b1652e 100755 --- a/src/main.html +++ b/src/main.html @@ -323,5 +323,15 @@ + +

+
+
+
+
+ +
+
+ diff --git a/src/tabs/setup.html b/src/tabs/setup.html index e531d071..c8d03858 100644 --- a/src/tabs/setup.html +++ b/src/tabs/setup.html @@ -46,6 +46,12 @@ +
+ +
+
+ +
@@ -61,6 +67,12 @@
+
+ +
+
+ +
From 3caf2d8ff55ee4cc2e975b9f62eb763b8adeb08f Mon Sep 17 00:00:00 2001 From: mikeller Date: Wed, 18 Jul 2018 01:00:12 +1200 Subject: [PATCH 2/2] Moved MSC button to blackbox tab. --- locales/en/messages.json | 18 ++++++++++++------ src/css/tabs/onboard_logging.css | 18 +++++++++++++++++- src/js/tabs/onboard_logging.js | 26 ++++++++++++++++++++++++++ src/js/tabs/setup.js | 7 ------- src/tabs/onboard_logging.html | 17 +++++++++++++++++ src/tabs/setup.html | 6 ------ 6 files changed, 72 insertions(+), 20 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index acf7a1a8..c29bba7b 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -610,18 +610,12 @@ "initialSetupButtonRebootBootloader": { "message": "Activate Boot Loader / DFU" }, - "initialSetupButtonRebootMsc": { - "message": "Activate Mass Storage Device Mode" - }, "initialSetupBackupRestoreText": { "message": "Backup your configuration in case of an accident, CLI settings are not included - use the command 'diff all' in CLI for this." }, "initialSetupRebootBootloaderText": { "message": "Reboot into boot loader / DFU mode." }, - "initialSetupRebootMscText": { - "message": "Reboot into mass storage device (MSC) mode. Once activated, the onboard flash or SD card on your flight controller will be recognised as a storage device by your computer, and allow you to download your log files. Eject and power cycel your flight controller to leave mass storage device mode." - }, "initialSetupBackupSuccess": { "message": "Backup saved successfully" }, @@ -3597,6 +3591,18 @@ "onboardLoggingOnboardSDCard": { "message": "Onboard SD card" }, + "onboardLoggingMsc": { + "message": "Mass Storage Mode" + }, + "onboardLoggingMscNote": { + "message": "Reboot into mass storage device (MSC) mode. Once activated, the onboard flash or SD card on your flight controller will be recognised as a storage device by your computer, and allow you to download your log files. Eject and power cycel your flight controller to leave mass storage device mode." + }, + "onboardLoggingRebootMscText": { + "message": "Activate Mass Storage Device Mode" + }, + "onboardLoggingMscNotReady": { + "message": "Mass storage mode can not be activated because the storage device is not ready." + }, "dialogConfirmResetTitle": { "message": "Confirm" }, diff --git a/src/css/tabs/onboard_logging.css b/src/css/tabs/onboard_logging.css index 87d48452..11e5b431 100644 --- a/src/css/tabs/onboard_logging.css +++ b/src/css/tabs/onboard_logging.css @@ -206,6 +206,22 @@ display: none; } +.require-msc-supported { + display: none; +} + +.tab-onboard_logging.msc-supported .require-msc-supported { + display: block; +} + +.require-msc-not-ready { + display: none; +} + +.tab-onboard_logging.msc-not-ready .require-msc-not-ready { + display: block; +} + @media only screen and (max-width: 1055px) , only screen and (max-device-width: 1055px) { .tab-onboard_logging table thead tr:first-child { font-size: 12px; @@ -300,4 +316,4 @@ pointer-events: none; text-shadow: none; opacity: 0.5; -} \ No newline at end of file +} diff --git a/src/js/tabs/onboard_logging.js b/src/js/tabs/onboard_logging.js index 68dc1d12..688ab7ca 100644 --- a/src/js/tabs/onboard_logging.js +++ b/src/js/tabs/onboard_logging.js @@ -145,6 +145,20 @@ TABS.onboard_logging.initialize = function (callback) { $("div.blackboxRate").show(); } }).change(); + + if (semver.gte(CONFIG.apiVersion, "1.40.0")) { + if (SDCARD.supported || DATAFLASH.supported) { + + $(".tab-onboard_logging") + .toggleClass("msc-supported", true); + + $('a.onboardLoggingRebootMsc').click(function () { + var buffer = []; + buffer.push(2); + MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); + }); + } + } update_html(); @@ -296,6 +310,18 @@ TABS.onboard_logging.initialize = function (callback) { .toggleClass("sdcard-error", SDCARD.state === MSP.SDCARD_STATE_FATAL) .toggleClass("sdcard-initializing", SDCARD.state === MSP.SDCARD_STATE_CARD_INIT || SDCARD.state === MSP.SDCARD_STATE_FS_INIT) .toggleClass("sdcard-ready", SDCARD.state === MSP.SDCARD_STATE_READY); + + if (semver.gte(CONFIG.apiVersion, "1.40.0")) { + var mscIsReady = (DATAFLASH.totalSize > 0) || (SDCARD.state === MSP.SDCARD_STATE_READY); + $(".tab-onboard_logging") + .toggleClass("msc-not-ready", !mscIsReady); + + if (!mscIsReady) { + $('a.onboardLoggingRebootMsc').addClass('disabled'); + } else { + $('a.onboardLoggingRebootMsc').removeClass('disabled'); + } + } switch (SDCARD.state) { case MSP.SDCARD_STATE_NOT_PRESENT: diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 6682c6db..c3f6663f 100755 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -73,15 +73,8 @@ TABS.setup.initialize = function (callback) { buffer.push(1); MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); }); - - $('a.rebootMsc').click(function () { - var buffer = []; - buffer.push(2); - MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); - }); } else { $('.initialSetupRebootBootloader').hide(); - $('.initialSetupRebootMsc').hide(); } // UI Hooks diff --git a/src/tabs/onboard_logging.html b/src/tabs/onboard_logging.html index 2a70b0b5..ca85163b 100644 --- a/src/tabs/onboard_logging.html +++ b/src/tabs/onboard_logging.html @@ -133,6 +133,23 @@ +
+
+
+
+
+
+
+

+ +
+ +
+
+ +

+
+
diff --git a/src/tabs/setup.html b/src/tabs/setup.html index c8d03858..1e93dbd8 100644 --- a/src/tabs/setup.html +++ b/src/tabs/setup.html @@ -49,9 +49,6 @@
-
- -
@@ -70,9 +67,6 @@
-
- -