mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 20:35:19 +03:00
adding new serial object utilizing new serial api
This commit is contained in:
parent
5da72e6f0c
commit
9caa5e251e
2 changed files with 47 additions and 0 deletions
46
js/serial.js
Normal file
46
js/serial.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
var serial = {
|
||||
connectionId: -1,
|
||||
|
||||
connect: function(path, options, callback) {
|
||||
var self = this;
|
||||
|
||||
chrome.serial.connect(path, options, function(connectionInfo) {
|
||||
self.connectionId = connectionInfo.connectionId;
|
||||
callback(connectionInfo);
|
||||
});
|
||||
},
|
||||
disconnect: function(callback) {
|
||||
var self = this;
|
||||
|
||||
chrome.serial.disconnect(this.connectionId, function(result) {
|
||||
self.connectionId = -1;
|
||||
callback(result);
|
||||
});
|
||||
},
|
||||
getDevices: function(callback) {
|
||||
chrome.serial.getDevices(function(devices_array) {
|
||||
var devices = [];
|
||||
devices_array.forEach(function(device) {
|
||||
devices.push(device.path);
|
||||
});
|
||||
|
||||
callback(devices);
|
||||
});
|
||||
},
|
||||
setControlSignals: function(signals, callback) {
|
||||
chrome.serial.setControlSignals(this.connectionId, signals, callback);
|
||||
},
|
||||
send: function(data, callback) {
|
||||
chrome.serial.send(this.connectionId, data, callback);
|
||||
},
|
||||
onReceive: {
|
||||
listeners_: chrome.serial.onReceive.listeners_,
|
||||
|
||||
addListener: function(function_reference) {
|
||||
chrome.serial.onReceive.addListener(function_reference);
|
||||
},
|
||||
removeListener: function(function_reference) {
|
||||
chrome.serial.onReceive.removeListener(function_reference);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -11,6 +11,7 @@
|
|||
<script type="text/javascript" src="./js/libraries/google-analytics-bundle.js"></script>
|
||||
<script type="text/javascript" src="./js/libraries/flotr2.min.js"></script>
|
||||
<script type="text/javascript" src="./js/libraries/jquery-2.0.3.min.js"></script>
|
||||
<script type="text/javascript" src="./js/serial.js"></script>
|
||||
<script type="text/javascript" src="./js/gui.js"></script>
|
||||
<script type="text/javascript" src="./js/serial_backend.js"></script>
|
||||
<script type="text/javascript" src="./js/msp.js"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue