mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 17:25:14 +03:00
[SITl] Fix serial selection and executable name on Linux
This commit is contained in:
parent
4ecf58a20b
commit
d689e3d3d6
2 changed files with 44 additions and 39 deletions
79
js/sitl.js
79
js/sitl.js
|
@ -49,15 +49,15 @@ var Ser2TCP = {
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function(comPort, serialPortOptions, ipAddress, tcpPort, callback) {
|
start: function(comPort, serialPortOptions, ipAddress, tcpPort, callback) {
|
||||||
|
|
||||||
if (this.isRunning)
|
if (this.isRunning)
|
||||||
this.stop();
|
this.stop();
|
||||||
|
|
||||||
var path;
|
var path;
|
||||||
if (GUI.operating_system == 'Windows') {
|
if (GUI.operating_system == 'Windows') {
|
||||||
path = './resources/sitl/windows/Ser2TCP.exe'
|
path = './resources/sitl/windows/Ser2TCP.exe'
|
||||||
} else if (GUI.operating_system == 'Linux') {
|
} else if (GUI.operating_system == 'Linux') {
|
||||||
path = './resources/sitl/linux/ser2TCP'
|
path = './resources/sitl/linux/Ser2TCP'
|
||||||
chmod(path, 0o755, (err) => {
|
chmod(path, 0o755, (err) => {
|
||||||
if (err)
|
if (err)
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -69,7 +69,7 @@ var Ser2TCP = {
|
||||||
var protocoll = serialRXProtocolls.find(proto => {
|
var protocoll = serialRXProtocolls.find(proto => {
|
||||||
return proto.name == serialPortOptions.protocollName;
|
return proto.name == serialPortOptions.protocollName;
|
||||||
});
|
});
|
||||||
|
|
||||||
var args = [];
|
var args = [];
|
||||||
if (protocoll && protocoll.name != "manual") {
|
if (protocoll && protocoll.name != "manual") {
|
||||||
args.push(`--comport=${comPort}`)
|
args.push(`--comport=${comPort}`)
|
||||||
|
@ -85,15 +85,15 @@ var Ser2TCP = {
|
||||||
args.push(`--parity=${serialPortOptions.parity}`)
|
args.push(`--parity=${serialPortOptions.parity}`)
|
||||||
args.push(`--ip=${ipAddress}`);
|
args.push(`--ip=${ipAddress}`);
|
||||||
args.push(`--tcpport=${tcpPort}`);
|
args.push(`--tcpport=${tcpPort}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = undefined;
|
var opts = undefined;
|
||||||
if (GUI.operating_system == 'Linux')
|
if (GUI.operating_system == 'Linux')
|
||||||
opts = { useShell: true };
|
opts = { useShell: true };
|
||||||
|
|
||||||
this.process = spawn(path, args, opts);
|
this.process = spawn(path, args, opts);
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
|
|
||||||
this.process.stdout.on('data', (data) => {
|
this.process.stdout.on('data', (data) => {
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(data);
|
callback(data);
|
||||||
|
@ -109,7 +109,7 @@ var Ser2TCP = {
|
||||||
callback(error);
|
callback(error);
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.process.on('exit', () => {
|
this.process.on('exit', () => {
|
||||||
if (this.isRunning)
|
if (this.isRunning)
|
||||||
this.spawn(path, args, callback);
|
this.spawn(path, args, callback);
|
||||||
|
@ -119,27 +119,32 @@ var Ser2TCP = {
|
||||||
stop: function() {
|
stop: function() {
|
||||||
if (this.isRunning) {
|
if (this.isRunning) {
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
this.process.kill();
|
this.process.kill();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getDevices: function(callback) {
|
getDevices: function(callback) {
|
||||||
chrome.serial.getDevices((devices_array) => {
|
chrome.serial.getDevices((devices_array) => {
|
||||||
var devices = [];
|
var devices = [];
|
||||||
devices_array.forEach((device) => {
|
devices_array.forEach((device) => {
|
||||||
|
|
||||||
if (GUI.operating_system == 'Windows') {
|
if (GUI.operating_system == 'Windows') {
|
||||||
var m = device.path.match(/COM\d?\d/g)
|
var m = device.path.match(/COM\d?\d/g)
|
||||||
if (m)
|
if (m)
|
||||||
devices.push(m[0]);
|
devices.push(m[0]);
|
||||||
} else
|
} else {
|
||||||
devices.push(device.displayName);
|
if (device.displayName != null) {
|
||||||
|
var m = device.path.match(/\/dev\/.*/)
|
||||||
|
if (m)
|
||||||
|
devices.push(m[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
callback(devices);
|
callback(devices);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
pollSerialPorts: function(callback) {
|
pollSerialPorts: function(callback) {
|
||||||
this.getDevices(devices => {
|
this.getDevices(devices => {
|
||||||
if (!this.arraysEqual(this.portsList, devices)) {
|
if (!this.arraysEqual(this.portsList, devices)) {
|
||||||
this.portsList = devices;
|
this.portsList = devices;
|
||||||
|
@ -149,7 +154,7 @@ var Ser2TCP = {
|
||||||
|
|
||||||
});
|
});
|
||||||
if (!this.stopPolling) {
|
if (!this.stopPolling) {
|
||||||
setTimeout(() => { this.pollSerialPorts(callback) }, 250);
|
setTimeout(() => { this.pollSerialPorts(callback) }, 250);
|
||||||
} else {
|
} else {
|
||||||
this.stopPolling = false;
|
this.stopPolling = false;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +173,7 @@ var Ser2TCP = {
|
||||||
if (a === b) return true;
|
if (a === b) return true;
|
||||||
if (a == null || b == null) return false;
|
if (a == null || b == null) return false;
|
||||||
if (a.length !== b.length) return false;
|
if (a.length !== b.length) return false;
|
||||||
|
|
||||||
for (var i = 0; i < a.length; ++i) {
|
for (var i = 0; i < a.length; ++i) {
|
||||||
if (a[i] !== b[i]) return false;
|
if (a[i] !== b[i]) return false;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +182,7 @@ var Ser2TCP = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var SITLProcess = {
|
var SITLProcess = {
|
||||||
|
|
||||||
spawn : null,
|
spawn : null,
|
||||||
isRunning: false,
|
isRunning: false,
|
||||||
process: null,
|
process: null,
|
||||||
|
@ -194,7 +199,7 @@ var SITLProcess = {
|
||||||
|
|
||||||
if (this.isRunning)
|
if (this.isRunning)
|
||||||
this.stop();
|
this.stop();
|
||||||
|
|
||||||
var sitlExePath, eepromPath;
|
var sitlExePath, eepromPath;
|
||||||
if (GUI.operating_system == 'Windows') {
|
if (GUI.operating_system == 'Windows') {
|
||||||
sitlExePath = './resources/sitl/windows/inav_SITL.exe'
|
sitlExePath = './resources/sitl/windows/inav_SITL.exe'
|
||||||
|
@ -209,36 +214,36 @@ var SITLProcess = {
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = [];
|
var args = [];
|
||||||
args.push(`--path=${eepromPath}`);
|
args.push(`--path=${eepromPath}`);
|
||||||
|
|
||||||
if (sim) {
|
if (sim) {
|
||||||
args.push(`--sim=${sim}`);
|
args.push(`--sim=${sim}`);
|
||||||
if (useIMU)
|
if (useIMU)
|
||||||
args.push("--useimu")
|
args.push("--useimu")
|
||||||
|
|
||||||
if (simIp)
|
if (simIp)
|
||||||
args.push(`--simip=${simIp}`);
|
args.push(`--simip=${simIp}`);
|
||||||
|
|
||||||
if (simPort)
|
if (simPort)
|
||||||
args.push(`--simport=${simPort}`);
|
args.push(`--simport=${simPort}`);
|
||||||
|
|
||||||
if (channelMap)
|
if (channelMap)
|
||||||
args.push(`--chanmap=${channelMap}`)
|
args.push(`--chanmap=${channelMap}`)
|
||||||
}
|
}
|
||||||
this.spawn(sitlExePath, args, callback);
|
this.spawn(sitlExePath, args, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
spawn: function(path, args, callback) {
|
spawn: function(path, args, callback) {
|
||||||
|
|
||||||
var opts = undefined;
|
var opts = undefined;
|
||||||
if (GUI.operating_system == 'Linux')
|
if (GUI.operating_system == 'Linux')
|
||||||
opts = { useShell: true };
|
opts = { useShell: true };
|
||||||
|
|
||||||
this.process = spawn(path, args, opts);
|
this.process = spawn(path, args, opts);
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
|
|
||||||
this.process.stdout.on('data', (data) => {
|
this.process.stdout.on('data', (data) => {
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(data);
|
callback(data);
|
||||||
|
@ -259,7 +264,7 @@ var SITLProcess = {
|
||||||
stop: function() {
|
stop: function() {
|
||||||
if (this.isRunning) {
|
if (this.isRunning) {
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
this.process.kill();
|
this.process.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "inav-configurator",
|
"name": "inav-configurator",
|
||||||
"version": "6.0.0",
|
"version": "6.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "inav-configurator",
|
"name": "inav-configurator",
|
||||||
"version": "6.0.0",
|
"version": "6.1.0",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"archiver": "^2.0.3",
|
"archiver": "^2.0.3",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue