From 65169163b07a50cb4ed8e451a036752390a22e17 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Mon, 17 Dec 2018 20:48:11 -0500 Subject: [PATCH] Add MSP_REBOOT_MSC_UTC reboot type to reboot into mass storage using UTC timestamps The FAT filesystem is not timezone aware so timestamps are expected to be in the user's local time. However Linux implementations seem to expect the timestamps to be in UTC and then apply the user's computer timezone offset. Adds an alternate reboot method used when the platform is "Linux" that prevents mass storage mode from adjusting the time to local time and instead uses UTC. --- src/js/msp/MSPHelper.js | 5 +++-- src/js/tabs/onboard_logging.js | 12 +++++++++++- src/js/tabs/setup.js | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 42793544..62ba2d11 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -31,7 +31,8 @@ function MspHelper () { self.REBOOT_TYPES = { FIRMWARE: 0, BOOTLOADER: 1, - MSC: 2 + MSC: 2, + MSC_UTC: 3 }; } @@ -647,7 +648,7 @@ MspHelper.prototype.process_data = function(dataHandler) { case MSPCodes.MSP_SET_REBOOT: if (semver.gte(CONFIG.apiVersion, "1.40.0")) { var rebootType = data.read8(); - if (rebootType === self.REBOOT_TYPES.MSC) { + if ((rebootType === self.REBOOT_TYPES.MSC) || (rebootType === self.REBOOT_TYPES.MSC_UTC)) { if (data.read8() === 0) { console.log('Storage device not ready.'); diff --git a/src/js/tabs/onboard_logging.js b/src/js/tabs/onboard_logging.js index 79f0ad71..3d48853e 100644 --- a/src/js/tabs/onboard_logging.js +++ b/src/js/tabs/onboard_logging.js @@ -156,7 +156,17 @@ TABS.onboard_logging.initialize = function (callback) { analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'RebootMsc'); var buffer = []; - buffer.push(2); + if (semver.gte(CONFIG.apiVersion, "1.41.0")) { + if (GUI.operating_system === "Linux") { + // Reboot into MSC using UTC time offset instead of user timezone + // Linux seems to expect that the FAT file system timestamps are UTC based + buffer.push(mspHelper.REBOOT_TYPES.MSC_UTC); + } else { + buffer.push(mspHelper.REBOOT_TYPES.MSC); + } + } else { + buffer.push(mspHelper.REBOOT_TYPES.MSC); + } MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); }); } diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index c3f6663f..e5ed7287 100755 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -70,7 +70,7 @@ TABS.setup.initialize = function (callback) { $('a.rebootBootloader').click(function () { var buffer = []; - buffer.push(1); + buffer.push(mspHelper.REBOOT_TYPES.BOOTLOADER); MSP.send_message(MSPCodes.MSP_SET_REBOOT, buffer, false); }); } else {