mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
parent
2e1327f2cd
commit
f352c4edbe
2 changed files with 33 additions and 3 deletions
|
@ -17,8 +17,40 @@ function start_app() {
|
|||
|
||||
// save connectionId in separate variable before app_window is destroyed
|
||||
var connectionId = app_window.serial.connectionId;
|
||||
var valid_connection = app_window.configuration_received;
|
||||
var mincommand = app_window.MISC.mincommand;
|
||||
|
||||
if (connectionId > 0) {
|
||||
if (connectionId > 0 && valid_connection) {
|
||||
// code below is handmade MSP message (without pretty JS wrapper), it behaves exactly like MSP.send_message
|
||||
// reset motors to default (mincommand)
|
||||
var bufferOut = new ArrayBuffer(22);
|
||||
var bufView = new Uint8Array(bufferOut);
|
||||
var checksum = 0;
|
||||
|
||||
bufView[0] = 36; // $
|
||||
bufView[1] = 77; // M
|
||||
bufView[2] = 60; // <
|
||||
bufView[3] = 16; // data length
|
||||
bufView[4] = 214; // MSP_SET_MOTOR
|
||||
|
||||
checksum = bufView[3] ^ bufView[4];
|
||||
|
||||
for (var i = 0; i < 16; i += 2) {
|
||||
bufView[i + 5] = mincommand & 0x00FF;
|
||||
bufView[i + 6] = mincommand >> 8;
|
||||
|
||||
checksum ^= bufView[i + 5];
|
||||
checksum ^= bufView[i + 6];
|
||||
}
|
||||
|
||||
bufView[5 + 16] = checksum;
|
||||
|
||||
chrome.serial.send(connectionId, bufferOut, function(sendInfo) {
|
||||
chrome.serial.disconnect(connectionId, function(result) {
|
||||
console.log('SERIAL: Connection closed - ' + result);
|
||||
});
|
||||
});
|
||||
} else if (connectionId > 0) {
|
||||
chrome.serial.disconnect(connectionId, function(result) {
|
||||
console.log('SERIAL: Connection closed - ' + result);
|
||||
});
|
||||
|
|
|
@ -265,7 +265,6 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
|||
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
||||
});
|
||||
break;
|
||||
|
||||
case 'firmware_flasher':
|
||||
// this.interval_remove('factory_mode');
|
||||
PortHandler.flush_callbacks();
|
||||
|
@ -275,7 +274,6 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
|||
|
||||
if (callback) callback();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (callback) callback();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue