From 21af65567c86c60cdd75401b9eae268b49bc2be7 Mon Sep 17 00:00:00 2001 From: cTn Date: Sun, 26 Jan 2014 18:24:46 +0100 Subject: [PATCH] created MSP disconnect cleanup routine --- js/msp.js | 17 ++++++++++++++++- js/serial_backend.js | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/js/msp.js b/js/msp.js index 663d3c2b..3853c072 100644 --- a/js/msp.js +++ b/js/msp.js @@ -65,7 +65,22 @@ var MSP = { message_checksum: 0, callbacks: [], - packet_error: 0 + packet_error: 0, + + disconnect_cleanup: function() { + this.state = 0; // reset packet state for "clean" initial entry (this is only required if user hot-disconnects) + this.packet_error = 0; // reset CRC packet error counter for next session + + /* + // kill all "raw" MSP timers + for (var i = 0; i < this.callbacks.length; i++) { + clearInterval(this.callbacks[i].timer); + } + */ + + // drop references + this.callbacks = []; + } }; function MSP_char_read(readInfo) { diff --git a/js/serial_backend.js b/js/serial_backend.js index 4eb7ff16..37b370b2 100644 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -143,8 +143,7 @@ $(document).ready(function() { $('.software-version').html('0.0'); $('span.cycle-time').html('0'); - MSP.state = 0; // reset packet state for "clean" initial entry (this is only required if user hot-disconnects) - MSP.packet_error = 0; // reset CRC packet error counter for next session + MSP.disconnect_cleanup(); configuration_received = false; // reset valid config received variable (used to block tabs while not connected properly) // unlock port select & baud