diff --git a/js/msp.js b/js/msp.js index 663d3c2b0b..3853c07294 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 4eb7ff1669..37b370b255 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