mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
adding method to empty send buffer, limits
This commit is contained in:
parent
c7dae0f5e3
commit
c389a71ece
3 changed files with 18 additions and 4 deletions
|
@ -204,7 +204,8 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
break;
|
break;
|
||||||
case 'sensors':
|
case 'sensors':
|
||||||
GUI.interval_kill_all(['port-update', 'port_usage', 'serial_read']);
|
GUI.interval_kill_all(['port-update', 'port_usage']);
|
||||||
|
serial.empty_output_buffer();
|
||||||
|
|
||||||
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
// sensor data tab uses scrollbars, emptying the content before loading another tab
|
||||||
// prevents scrollbar exposure to any of the tabs while new content is loaded in
|
// prevents scrollbar exposure to any of the tabs while new content is loaded in
|
||||||
|
|
17
js/serial.js
17
js/serial.js
|
@ -59,11 +59,20 @@ var serial = {
|
||||||
self.transmitting = true;
|
self.transmitting = true;
|
||||||
|
|
||||||
var sending = function() {
|
var sending = function() {
|
||||||
chrome.serial.send(self.connectionId, self.output_buffer[0].data, function(sendInfo) {
|
// store inside separate variables in case array gets destroyed
|
||||||
self.output_buffer[0].callback(sendInfo);
|
var data = self.output_buffer[0].data;
|
||||||
|
var callback = self.output_buffer[0].callback;
|
||||||
|
|
||||||
|
chrome.serial.send(self.connectionId, data, function(sendInfo) {
|
||||||
|
callback(sendInfo);
|
||||||
self.output_buffer.shift();
|
self.output_buffer.shift();
|
||||||
|
|
||||||
if (self.output_buffer.length) {
|
if (self.output_buffer.length) {
|
||||||
|
// keep the buffer withing reasonable limits
|
||||||
|
while (self.output_buffer.length > 500) {
|
||||||
|
self.output_buffer.pop();
|
||||||
|
}
|
||||||
|
|
||||||
sending();
|
sending();
|
||||||
} else {
|
} else {
|
||||||
self.transmitting = false;
|
self.transmitting = false;
|
||||||
|
@ -83,5 +92,9 @@ var serial = {
|
||||||
removeListener: function(function_reference) {
|
removeListener: function(function_reference) {
|
||||||
chrome.serial.onReceive.removeListener(function_reference);
|
chrome.serial.onReceive.removeListener(function_reference);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
empty_output_buffer: function() {
|
||||||
|
this.output_buffer = [];
|
||||||
|
this.transmitting = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -209,7 +209,7 @@ function tab_initialize_sensors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// timer initialization
|
// timer initialization
|
||||||
GUI.interval_kill_all(['port-update', 'port_usage', 'serial_read']);
|
GUI.interval_kill_all(['port-update', 'port_usage']);
|
||||||
|
|
||||||
// data pulling timers
|
// data pulling timers
|
||||||
GUI.interval_add('status_pull', function() {
|
GUI.interval_add('status_pull', function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue