mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-23 00:05:19 +03:00
Merge remote-tracking branch 'origin/master' into mmosca-update-stil-binaries
This commit is contained in:
commit
f378366914
6 changed files with 975 additions and 336 deletions
|
@ -169,7 +169,7 @@ function createWindow() {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
mainWindow.webContents.openDevTools();
|
mainWindow.webContents.openDevTools();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
|
||||||
|
|
150
js/sitl.js
150
js/sitl.js
|
@ -8,42 +8,46 @@ const { chmod, rm } = require('node:fs');
|
||||||
const { GUI } = require('./gui');
|
const { GUI } = require('./gui');
|
||||||
|
|
||||||
const serialRXProtocolls = [
|
const serialRXProtocolls = [
|
||||||
|
{
|
||||||
|
name : "Flight Controller Proxy",
|
||||||
|
baudRate: 115200,
|
||||||
|
stopBits: "One",
|
||||||
|
parity: "None"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name : "SBus",
|
name : "SBus",
|
||||||
baudrate: 100000,
|
baudRate: 100000,
|
||||||
stopBits: "Two",
|
stopBits: "Two",
|
||||||
parity: "Even"
|
parity: "Even"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : "SBus Fast",
|
name : "SBus Fast",
|
||||||
baudrate: 200000,
|
baudRate: 200000,
|
||||||
stopBits: "Two",
|
stopBits: "Two",
|
||||||
parity: "Even"
|
parity: "Even"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : "Crossfire/Ghost",
|
name : "Crossfire/Ghost",
|
||||||
baudrate: 420000,
|
baudRate: 420000,
|
||||||
stopBits: "One",
|
stopBits: "One",
|
||||||
parity: "None"
|
parity: "None"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : "FPort/IBus/Spektrum/SRXL2/SUMD",
|
name : "FPort/IBus/Spektrum/SRXL2/SUMD",
|
||||||
baudrate: 115200,
|
baudRate: 115200,
|
||||||
stopBits: "One",
|
stopBits: "One",
|
||||||
parity: "None"
|
parity: "None"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : "JETI EX Bus",
|
name : "JETI EX Bus",
|
||||||
baudrate: 125000,
|
baudRate: 125000,
|
||||||
stopBits: "One",
|
stopBits: "One",
|
||||||
parity: "None"
|
parity: "None"
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
var Ser2TCP = {
|
var SitlSerialPortUtils = {
|
||||||
|
|
||||||
isRunning: false,
|
|
||||||
process: null,
|
|
||||||
portsList: [],
|
portsList: [],
|
||||||
stopPolling: false,
|
stopPolling: false,
|
||||||
|
|
||||||
|
@ -51,108 +55,26 @@ var Ser2TCP = {
|
||||||
return serialRXProtocolls;
|
return serialRXProtocolls;
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function(comPort, serialPortOptions, ipAddress, tcpPort, callback) {
|
|
||||||
|
|
||||||
if (this.isRunning)
|
|
||||||
this.stop();
|
|
||||||
|
|
||||||
var path;
|
|
||||||
if (GUI.operating_system == 'Windows') {
|
|
||||||
path = './../resources/sitl/windows/Ser2TCP.exe'
|
|
||||||
} else if (GUI.operating_system == 'Linux') {
|
|
||||||
path = './../resources/sitl/linux/Ser2TCP'
|
|
||||||
chmod(path, 0o755, (err) => {
|
|
||||||
if (err)
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
} else if (GUI.operating_system == 'MacOS') {
|
|
||||||
path = './../resources/sitl/macos/Ser2TCP'
|
|
||||||
chmod(path, 0o755, (err) => {
|
|
||||||
if (err)
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert(GUI.operating_system);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var protocoll = serialRXProtocolls.find(proto => {
|
|
||||||
return proto.name == serialPortOptions.protocollName;
|
|
||||||
});
|
|
||||||
|
|
||||||
var args = [];
|
|
||||||
if (protocoll && protocoll.name != "manual") {
|
|
||||||
args.push(`--comport=${comPort}`)
|
|
||||||
args.push(`--baudrate=${protocoll.baudrate}`);
|
|
||||||
args.push(`--stopbits=${protocoll.stopBits}`)
|
|
||||||
args.push(`--parity=${protocoll.parity}`)
|
|
||||||
args.push(`--ip=${ipAddress}`);
|
|
||||||
args.push(`--tcpport=${tcpPort}`);
|
|
||||||
} else {
|
|
||||||
args.push(`--comport=${comPort}`)
|
|
||||||
args.push(`--baudrate${proserialPortOptionstocoll.baudrate}`);
|
|
||||||
args.push(`--stopbits=${protserialPortOptionsocoll.stopBits}`)
|
|
||||||
args.push(`--parity=${serialPortOptions.parity}`)
|
|
||||||
args.push(`--ip=${ipAddress}`);
|
|
||||||
args.push(`--tcpport=${tcpPort}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
var opts = undefined;
|
|
||||||
if (GUI.operating_system == 'Linux')
|
|
||||||
opts = { useShell: true };
|
|
||||||
|
|
||||||
this.process = spawn(path, args, opts);
|
|
||||||
this.isRunning = true;
|
|
||||||
|
|
||||||
this.process.stdout.on('data', (data) => {
|
|
||||||
if (callback)
|
|
||||||
callback(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.process.stderr.on('data', (data) => {
|
|
||||||
if (callback)
|
|
||||||
callback(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.process.on('error', (error) => {
|
|
||||||
if (callback)
|
|
||||||
callback(error);
|
|
||||||
this.isRunning = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.process.on('exit', () => {
|
|
||||||
if (this.isRunning)
|
|
||||||
this.spawn(path, args, callback);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
stop: function() {
|
|
||||||
if (this.isRunning) {
|
|
||||||
this.isRunning = false;
|
|
||||||
this.process.kill();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getDevices: function(callback) {
|
getDevices: function(callback) {
|
||||||
SerialPort.list().then((ports, error) => {
|
SerialPort.list().then((ports, error) => {
|
||||||
var devices = [];
|
var devices = [];
|
||||||
if (error) {
|
if (error) {
|
||||||
GUI.log("Unable to list serial ports.");
|
GUI.log("Unable to list serial ports.");
|
||||||
} else {
|
} else {
|
||||||
ports.forEach((device) => {
|
ports.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 {
|
||||||
/* Limit to: USB serial, RFCOMM (BT), 6 legacy devices */
|
/* Limit to: USB serial, RFCOMM (BT), 6 legacy devices */
|
||||||
if (device.pnpId ||
|
if (device.pnpId ||
|
||||||
device.path.match(/rfcomm\d*/) ||
|
device.path.match(/rfcomm\d*/) ||
|
||||||
device.path.match(/ttyS[0-5]$/)) {
|
device.path.match(/ttyS[0-5]$/)) {
|
||||||
devices.push(device.path);
|
devices.push(device.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
callback(devices);
|
callback(devices);
|
||||||
});
|
});
|
||||||
|
@ -209,7 +131,7 @@ var SITLProcess = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function(eepromFileName, sim, useIMU, simIp, simPort, channelMap, callback) {
|
start: function(eepromFileName, sim, useIMU, simIp, simPort, channelMap, serialPortOptions, callback) {
|
||||||
|
|
||||||
if (this.isRunning)
|
if (this.isRunning)
|
||||||
this.stop();
|
this.stop();
|
||||||
|
@ -232,7 +154,7 @@ var SITLProcess = {
|
||||||
if (err)
|
if (err)
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
alert(GUI.operating_system);
|
alert(GUI.operating_system);
|
||||||
return;
|
return;
|
||||||
|
@ -255,6 +177,32 @@ var SITLProcess = {
|
||||||
if (channelMap)
|
if (channelMap)
|
||||||
args.push(`--chanmap=${channelMap}`)
|
args.push(`--chanmap=${channelMap}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serialPortOptions != null) {
|
||||||
|
var protocoll = serialRXProtocolls.find(proto => {
|
||||||
|
return proto.name == serialPortOptions.protocollName;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (protocoll && protocoll.name != "manual") {
|
||||||
|
args.push(`--serialport=${serialPortOptions.serialPort}`)
|
||||||
|
args.push(`--baudrate=${protocoll.baudRate}`);
|
||||||
|
args.push(`--stopbits=${protocoll.stopBits}`)
|
||||||
|
args.push(`--parity=${protocoll.parity}`)
|
||||||
|
if ( protocoll.name == "Flight Controller Proxy") {
|
||||||
|
args.push(`--fcproxy`);
|
||||||
|
} else {
|
||||||
|
args.push(`--serialuart=${serialPortOptions.serialUart}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
args.push(`--serialport=${serialPortOptions.serialPort}`)
|
||||||
|
args.push(`--baudrate=${serialPortOptions.baudRate}`);
|
||||||
|
args.push(`--stopbits=${serialPortOptions.stopBits}`)
|
||||||
|
args.push(`--parity=${serialPortOptions.parity}`)
|
||||||
|
args.push(`--serialuart=${serialPortOptions.serialUart}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback( sitlExePath + " " + args.join(" ") + "\n");
|
||||||
this.spawn(sitlExePath, args, callback);
|
this.spawn(sitlExePath, args, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -292,4 +240,4 @@ var SITLProcess = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = { Ser2TCP, SITLProcess };
|
module.exports = { SITLProcess, SitlSerialPortUtils };
|
||||||
|
|
|
@ -238,20 +238,20 @@
|
||||||
"sitlStdProfileCantOverwritten": {
|
"sitlStdProfileCantOverwritten": {
|
||||||
"message": "SITL standard profile can't be overwritten. Please create a new one."
|
"message": "SITL standard profile can't be overwritten. Please create a new one."
|
||||||
},
|
},
|
||||||
"sitlSerialToTCP": {
|
"serialReceiver": {
|
||||||
"message": "Serial to TCP (UART)"
|
"message": "Serial receiver"
|
||||||
},
|
},
|
||||||
"sitlSerialProtocoll": {
|
"sitlSerialProtocoll": {
|
||||||
"message": "Preset for RX Protocoll"
|
"message": "Serial port settings preset for RX Protocol of connected receiver"
|
||||||
},
|
},
|
||||||
"sitlSerialStopbits": {
|
"sitlSerialStopbits": {
|
||||||
"message": "Stopbits"
|
"message": "Stopbits"
|
||||||
},
|
},
|
||||||
"sitlSerialPort": {
|
"sitlSerialPort": {
|
||||||
"message": "Serial port"
|
"message": "Serial receiver/Proxy FC is connectected to host's serial port"
|
||||||
},
|
},
|
||||||
"sitlSerialTCPPort": {
|
"sitlSerialUART": {
|
||||||
"message": "TCP port"
|
"message": "Serial receiver is configured on SITL's UART"
|
||||||
},
|
},
|
||||||
"sitlSerialParity": {
|
"sitlSerialParity": {
|
||||||
"message": "Parity"
|
"message": "Parity"
|
||||||
|
@ -277,8 +277,8 @@
|
||||||
"sitlPortHelp": {
|
"sitlPortHelp": {
|
||||||
"message": "Port number of the interface of the simulator. Note: The RealFlight port is fixed and cannot be changed."
|
"message": "Port number of the interface of the simulator. Note: The RealFlight port is fixed and cannot be changed."
|
||||||
},
|
},
|
||||||
"sitlSer2TcpHelp": {
|
"sitlSerialReceiverHelp": {
|
||||||
"message": "Devices with a UART interface can be used with SITL via a serial to USB interface. Especially intended for serial receivers to use the full number of channels. "
|
"message": "Use receiver (SBUS/CRSF/etc.) connected to host using USB-to-UART adapter or proxy Flight Controller."
|
||||||
},
|
},
|
||||||
"auxiliaryAcroEnabled": {
|
"auxiliaryAcroEnabled": {
|
||||||
"message": "ACRO"
|
"message": "ACRO"
|
||||||
|
|
936
package-lock.json
generated
936
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -88,13 +88,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="config-section gui_box grey">
|
<div class="config-section gui_box grey">
|
||||||
<div class="gui_box_titlebar">
|
<div class="gui_box_titlebar">
|
||||||
<div class="spacer_box_title" data-i18n="sitlSerialToTCP"></div>
|
<div class="spacer_box_title" data-i18n="serialReceiver"></div>
|
||||||
<div class="helpicon cf_tip" data-i18n_title="sitlSer2TcpHelp"></div>
|
<div class="helpicon cf_tip" data-i18n_title="sitlSerialReceiverHelp"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="spacer_box">
|
<div class="spacer_box">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" id="serialTcpEnable" class="toggle" data-live="true">
|
<input type="checkbox" id="serialReceiverEnable" class="toggle" data-live="true">
|
||||||
<label for="serialTcpEnable"><span data-i18n="sitlSerialTcpEnable"></span></label>
|
<label for="serialReceiverEnable"><span data-i18n="sitlSerialReceiverEnable"></span></label>
|
||||||
</div>
|
</div>
|
||||||
<span id="serialTcpOptions">
|
<span id="serialTcpOptions">
|
||||||
<div class="select">
|
<div class="select">
|
||||||
|
@ -102,32 +102,31 @@
|
||||||
<label for="sitlSerialPort"> <span data-i18n="sitlSerialPort"></span></label>
|
<label for="sitlSerialPort"> <span data-i18n="sitlSerialPort"></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select id="serialTCPPort">
|
<select id="sitlSerialUART">
|
||||||
<option value="5760">5760 (UART1)</option>
|
<option value="1">UART1</option>
|
||||||
<option value="5761">5761 (UART2)</option>
|
<option value="2">UART2</option>
|
||||||
<option value="5762">5762 (UART3)</option>
|
<option value="3">UART3</option>
|
||||||
<option value="5763">5763 (UART4)</option>
|
<option value="4">UART4</option>
|
||||||
<option value="5764">5764 (UART5)</option>
|
<option value="5">UART5</option>
|
||||||
<option value="5765">5765 (UART6)</option>
|
<option value="6">UART6</option>
|
||||||
<option value="5766">5766 (UART7)</option>
|
<option value="7">UART7</option>
|
||||||
<option value="5767">5767 (UART8)</option>
|
<option value="8">UART8</option>
|
||||||
</select>
|
</select>
|
||||||
<label for="serialTCPPort"> <span data-i18n="sitlSerialTCPPort"></span></label>
|
<label for="sitlSerialUART"> <span data-i18n="sitlSerialUART"></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select id="serialProtocoll"></select>
|
<select id="serialProtocoll"></select>
|
||||||
<label for="serialProtocoll"> <span data-i18n="sitlSerialProtocoll"></span></label>
|
<label for="serialProtocoll"> <span data-i18n="sitlSerialProtocoll"></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="number">
|
<div class="number">
|
||||||
<input type="number" id="sitlBaud" class="sitlBaud" data-setting-multiplier="1" step="1" min="1" max="256000" />
|
<input type="number" id="sitlBaud" class="sitlBaud" data-setting-multiplier="1" step="1" min="1" max="921600" />
|
||||||
<label for="sitlBaud" class="sitlNumber"><span data-i18n="configurationGPSBaudrate"></span></label>
|
<label for="sitlBaud" class="sitlNumber"><span data-i18n="configurationGPSBaudrate"></span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select id="serialStopbits">
|
<select id="serialStopbits">
|
||||||
<option value="None">0</option>
|
<option value="None">None</option>
|
||||||
<option value="One">1</option>
|
<option value="One">One</option>
|
||||||
<option value="OnePointFive">1.5</option>
|
<option value="Two">Two</option>
|
||||||
<option value="Two">2</option>
|
|
||||||
</select>
|
</select>
|
||||||
<label for="serialStopbits"> <span data-i18n="sitlSerialStopbits"></span></label>
|
<label for="serialStopbits"> <span data-i18n="sitlSerialStopbits"></span></label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -135,9 +134,7 @@
|
||||||
<select id="serialParity">
|
<select id="serialParity">
|
||||||
<option value="None">None</option>
|
<option value="None">None</option>
|
||||||
<option value="Even">Even</option>
|
<option value="Even">Even</option>
|
||||||
<option value="Mark">Mark</option>
|
|
||||||
<option value="Odd">Odd</option>
|
<option value="Odd">Odd</option>
|
||||||
<option value="Space">Space</option>
|
|
||||||
</select>
|
</select>
|
||||||
<label for="serialParity"> <span data-i18n="sitlSerialParity"></span></label>
|
<label for="serialParity"> <span data-i18n="sitlSerialParity"></span></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
168
tabs/sitl.js
168
tabs/sitl.js
|
@ -3,7 +3,7 @@ const path = require('path');
|
||||||
|
|
||||||
const { GUI, TABS } = require('./../js/gui');
|
const { GUI, TABS } = require('./../js/gui');
|
||||||
const i18n = require('./../js/localization');
|
const i18n = require('./../js/localization');
|
||||||
const { Ser2TCP, SITLProcess } = require('./../js/sitl');
|
const { SITLProcess, SitlSerialPortUtils } = require('./../js/sitl');
|
||||||
const Store = require('electron-store');
|
const Store = require('electron-store');
|
||||||
const store = new Store();
|
const store = new Store();
|
||||||
|
|
||||||
|
@ -28,21 +28,39 @@ const simulators = [
|
||||||
|
|
||||||
const stdProfiles = [
|
const stdProfiles = [
|
||||||
{
|
{
|
||||||
name: "[Standard] X-Plane",
|
name: "[Standard] Confgurator",
|
||||||
sim: "X-Plane",
|
sim: "X-Plane",
|
||||||
eepromFileName: "standard-x-plane.bin",
|
eepromFileName: "standard-configurator.bin",
|
||||||
isStdProfile: true,
|
isStdProfile: true,
|
||||||
simEnabeld: true,
|
simEnabled: false,
|
||||||
port: 49001,
|
port: 49001,
|
||||||
ip: "127.0.0.1",
|
ip: "127.0.0.1",
|
||||||
useImu: false,
|
useImu: false,
|
||||||
channelMap: [ 1, 15, 13, 16],
|
channelMap: [ 1, 15, 13, 16],
|
||||||
useSerialTcp: true,
|
useSerialReceiver: true,
|
||||||
comPort: "",
|
serialPort: "",
|
||||||
tcpPort: 5762,
|
serialUart: 3,
|
||||||
serialProtocol: "SBus",
|
serialProtocol: "SBus",
|
||||||
baudrate: false,
|
baudRate: false,
|
||||||
stopbits: false,
|
stopBits: false,
|
||||||
|
parity: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "[Standard] X-Plane",
|
||||||
|
sim: "X-Plane",
|
||||||
|
eepromFileName: "standard-x-plane.bin",
|
||||||
|
isStdProfile: true,
|
||||||
|
simEnabled: true,
|
||||||
|
port: 49001,
|
||||||
|
ip: "127.0.0.1",
|
||||||
|
useImu: false,
|
||||||
|
channelMap: [ 1, 15, 13, 16],
|
||||||
|
useSerialReceiver: true,
|
||||||
|
serialPort: "",
|
||||||
|
serialUart: 3,
|
||||||
|
serialProtocol: "SBus",
|
||||||
|
baudRate: false,
|
||||||
|
stopBits: false,
|
||||||
parity: false
|
parity: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -50,19 +68,18 @@ const stdProfiles = [
|
||||||
sim: "RealFlight",
|
sim: "RealFlight",
|
||||||
eepromFileName: "standard-realflight.bin",
|
eepromFileName: "standard-realflight.bin",
|
||||||
isStdProfile: true,
|
isStdProfile: true,
|
||||||
simEnabeld: true,
|
simEnabled: true,
|
||||||
port: 49001,
|
port: 49001,
|
||||||
ip: "127.0.0.1",
|
ip: "127.0.0.1",
|
||||||
useImu: false,
|
useImu: false,
|
||||||
channelMap: [ 1, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
channelMap: [ 1, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
useSerialTcp: true,
|
useSerialReceiver: true,
|
||||||
comPort: "",
|
serialPort: "",
|
||||||
tcpPort: 5762,
|
serialUart: 3,
|
||||||
serialProtocol: "SBus",
|
serialProtocol: "SBus",
|
||||||
baudrate: false,
|
baudRate: false,
|
||||||
stopbits: false,
|
stopBits: false,
|
||||||
parity: false
|
parity: false
|
||||||
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -80,7 +97,7 @@ TABS.sitl.initialize = (callback) => {
|
||||||
|
|
||||||
var currentSim, currentProfile, profiles;
|
var currentSim, currentProfile, profiles;
|
||||||
var mapping = new Array(28).fill(0);
|
var mapping = new Array(28).fill(0);
|
||||||
var serialProtocolls = Ser2TCP.getProtocolls();
|
var serialProtocolls = SitlSerialPortUtils.getProtocolls();
|
||||||
var sim_e = $('#simulator');
|
var sim_e = $('#simulator');
|
||||||
var enableSim_e = $('#sitlEnableSim');
|
var enableSim_e = $('#sitlEnableSim');
|
||||||
var port_e = $('#simPort');
|
var port_e = $('#simPort');
|
||||||
|
@ -91,13 +108,12 @@ TABS.sitl.initialize = (callback) => {
|
||||||
var profileNewBtn_e = $('#sitlProfileNew');
|
var profileNewBtn_e = $('#sitlProfileNew');
|
||||||
var profileDeleteBtn_e = $('#sitlProfileDelete');
|
var profileDeleteBtn_e = $('#sitlProfileDelete');
|
||||||
var serialPorts_e = $('#sitlSerialPort');
|
var serialPorts_e = $('#sitlSerialPort');
|
||||||
var serialTcpEnable = $('#serialTcpEnable')
|
var serialReceiverEnable_e = $('#serialReceiverEnable');
|
||||||
var tcpPort_e = $('#serialTCPPort');
|
var serialUart_e = $('#sitlSerialUART');
|
||||||
var protocollPreset_e = $('#serialProtocoll');
|
var protocollPreset_e = $('#serialProtocoll');
|
||||||
var baudRate_e = $('#sitlBaud');
|
var baudRate_e = $('#sitlBaud');
|
||||||
var stopBits_e = $('#serialStopbits');
|
var stopBits_e = $('#serialStopbits');
|
||||||
var parity_e = $('#serialParity');
|
var parity_e = $('#serialParity');
|
||||||
var serialTcpEable_e = $('#serialTcpEnable');
|
|
||||||
|
|
||||||
if (SITLProcess.isRunning) {
|
if (SITLProcess.isRunning) {
|
||||||
$('.sitlStart').addClass('disabled');
|
$('.sitlStart').addClass('disabled');
|
||||||
|
@ -122,8 +138,8 @@ TABS.sitl.initialize = (callback) => {
|
||||||
initElements(true);
|
initElements(true);
|
||||||
|
|
||||||
|
|
||||||
Ser2TCP.resetPortsList();
|
SitlSerialPortUtils.resetPortsList();
|
||||||
Ser2TCP.pollSerialPorts(ports => {
|
SitlSerialPortUtils.pollSerialPorts(ports => {
|
||||||
serialPorts_e.find('*').remove();
|
serialPorts_e.find('*').remove();
|
||||||
ports.forEach(port => {
|
ports.forEach(port => {
|
||||||
serialPorts_e.append(`<option value="${port}">${port}</option>`)
|
serialPorts_e.append(`<option value="${port}">${port}</option>`)
|
||||||
|
@ -132,7 +148,8 @@ TABS.sitl.initialize = (callback) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
enableSim_e.on('change', () => {
|
enableSim_e.on('change', () => {
|
||||||
currentProfile.simEnabeld = enableSim_e.is(':checked');
|
currentProfile.simEnabled = enableSim_e.is(':checked');
|
||||||
|
updateSim();
|
||||||
});
|
});
|
||||||
|
|
||||||
sim_e.on('change', () => {
|
sim_e.on('change', () => {
|
||||||
|
@ -198,36 +215,37 @@ TABS.sitl.initialize = (callback) => {
|
||||||
}
|
}
|
||||||
channelMap = channelMap.substring(0, channelMap.length - 1);
|
channelMap = channelMap.substring(0, channelMap.length - 1);
|
||||||
|
|
||||||
var serialOptions;
|
var serialOptions = null;
|
||||||
var selectedProtocoll = protocollPreset_e.find(':selected').val();
|
if ( serialReceiverEnable_e.is(':checked') && !!serialPorts_e.val()) {
|
||||||
if (selectedProtocoll == "manual") {
|
var selectedProtocoll = protocollPreset_e.find(':selected').val();
|
||||||
serialOptions = {
|
if (selectedProtocoll == "manual") {
|
||||||
protocollName: "manual",
|
serialOptions = {
|
||||||
bitrate: currentProfile.baudrate,
|
protocollName: "manual",
|
||||||
stopBits: currentProfile.stopBits,
|
baudRate: baudRate_e.val() || currentProfile.baudRate || "115200",
|
||||||
parityBit: currentProfile.parity
|
stopBits: stopBits_e.val() || currentProfile.stopBits || "One",
|
||||||
}
|
parity: parity_e.val() || currentProfile.parity || "None",
|
||||||
} else {;
|
serialPort: serialPorts_e.val() || currentProfile.serialPort || "",
|
||||||
serialOptions = {
|
serialUart: serialUart_e.val() || currentProfile.serialUart || -1
|
||||||
protocollName: selectedProtocoll
|
}
|
||||||
|
} else {;
|
||||||
|
serialOptions = {
|
||||||
|
protocollName: selectedProtocoll || "SBus",
|
||||||
|
serialPort: serialPorts_e.val() || currentProfile.serialPort || "" ,
|
||||||
|
serialUart: serialUart_e.val() || currentProfile.serialUart || -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appendLog("\n");
|
||||||
|
|
||||||
SITLProcess.start(currentProfile.eepromFileName, sim, useImu_e.is(':checked'), simIp, simPort, channelMap, result => {
|
SITLProcess.start(currentProfile.eepromFileName, sim, useImu_e.is(':checked'), simIp, simPort, channelMap, serialOptions,result => {
|
||||||
|
appendLog(result);
|
||||||
appendLog(result);
|
|
||||||
if (serialTcpEnable.is(':checked') && result == `[SIM] Connection with ${currentProfile.sim} successfully established.\n`) {
|
|
||||||
Ser2TCP.start(serialPorts_e.val(), serialOptions, currentProfile.ip, currentProfile.tcpPort, result => {
|
|
||||||
appendLog(`[Serial2TCP] ${result}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.sitlStop').on('click', ()=> {
|
$('.sitlStop').on('click', ()=> {
|
||||||
$('.sitlStop').addClass('disabled');
|
$('.sitlStop').addClass('disabled');
|
||||||
$('.sitlStart').removeClass('disabled');
|
$('.sitlStart').removeClass('disabled');
|
||||||
Ser2TCP.stop();
|
|
||||||
SITLProcess.stop();
|
SITLProcess.stop();
|
||||||
appendLog(i18n.getMessage('sitlStopped'));
|
appendLog(i18n.getMessage('sitlStopped'));
|
||||||
});
|
});
|
||||||
|
@ -250,17 +268,18 @@ TABS.sitl.initialize = (callback) => {
|
||||||
name: name,
|
name: name,
|
||||||
sim: "RealFlight",
|
sim: "RealFlight",
|
||||||
isStdProfile: false,
|
isStdProfile: false,
|
||||||
simEnabeld: true,
|
simEnabled: false,
|
||||||
eepromFileName: eerpromName,
|
eepromFileName: eerpromName,
|
||||||
port: 49001,
|
port: 49001,
|
||||||
ip: "127.0.0.1",
|
ip: "127.0.0.1",
|
||||||
useImu: false,
|
useImu: false,
|
||||||
channelMap: [ 1, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
channelMap: [ 1, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
useSerialTcp: true,
|
useSerialReceiver: true,
|
||||||
tcpPort: 5762,
|
serialPort: serialPorts_e.val(),
|
||||||
|
serialUart: 3,
|
||||||
serialProtocol: "SBus",
|
serialProtocol: "SBus",
|
||||||
baudrate: false,
|
baudRate: false,
|
||||||
stopbits: false,
|
stopBits: false,
|
||||||
parity: false
|
parity: false
|
||||||
}
|
}
|
||||||
profiles.push(profile);
|
profiles.push(profile);
|
||||||
|
@ -289,8 +308,8 @@ TABS.sitl.initialize = (callback) => {
|
||||||
saveProfiles();
|
saveProfiles();
|
||||||
});
|
});
|
||||||
|
|
||||||
serialTcpEable_e.on('change', () => {
|
serialReceiverEnable_e.on('change', () => {
|
||||||
currentProfile.useSerialTcp = serialTcpEable_e.is(':checked');
|
currentProfile.useSerialReceiver = serialReceiverEnable_e.is(':checked');
|
||||||
});
|
});
|
||||||
|
|
||||||
protocollPreset_e.on('change', () => {
|
protocollPreset_e.on('change', () => {
|
||||||
|
@ -302,36 +321,34 @@ TABS.sitl.initialize = (callback) => {
|
||||||
|
|
||||||
if (selectedProtocoll != 'manual'){
|
if (selectedProtocoll != 'manual'){
|
||||||
baudRate_e.prop('disabled', true);
|
baudRate_e.prop('disabled', true);
|
||||||
baudRate_e.val(protocoll.baudrate);
|
baudRate_e.val(protocoll.baudRate);
|
||||||
stopBits_e.prop('disabled', true);
|
stopBits_e.prop('disabled', true);
|
||||||
stopBits_e.val(protocoll.stopBits);
|
stopBits_e.val(protocoll.stopBits);
|
||||||
parity_e.prop('disabled', true);
|
parity_e.prop('disabled', true);
|
||||||
parity_e.val(protocoll.parity);
|
parity_e.val(protocoll.parity);
|
||||||
|
serialUart_e.prop('disabled', selectedProtocoll == "Flight Controller Proxy");
|
||||||
} else {
|
} else {
|
||||||
baudRate_e.prop('disabled', false);
|
baudRate_e.prop('disabled', false);
|
||||||
baudRate_e.val('');
|
|
||||||
stopBits_e.prop('disabled', false);
|
stopBits_e.prop('disabled', false);
|
||||||
stopBits_e.val('');
|
|
||||||
parity_e.prop('disabled', false);
|
parity_e.prop('disabled', false);
|
||||||
parity_e.val('');
|
serialUart_e.prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentProfile.serialProtocol = selectedProtocoll;
|
currentProfile.serialProtocol = selectedProtocoll;
|
||||||
});
|
});
|
||||||
|
|
||||||
serialPorts_e.on('change', () => {
|
serialPorts_e.on('change', () => {
|
||||||
currentProfile.comPort = serialPorts_e.val();
|
currentProfile.serialPort = serialPorts_e.val();
|
||||||
});
|
});
|
||||||
|
|
||||||
tcpPort_e.on('change', () => {
|
serialUart_e.on('change', () => {
|
||||||
currentProfile.tcpPort = parseInt(tcpPort_e.val());
|
currentProfile.serialUart = parseInt(serialUart_e.val());
|
||||||
});
|
});
|
||||||
|
|
||||||
baudRate_e.on('change', () => {
|
baudRate_e.on('change', () => {
|
||||||
var baud = parseInt(baudRate_e.val());
|
var baud = parseInt(baudRate_e.val());
|
||||||
if (baud != NaN)
|
if (baud != NaN)
|
||||||
currentProfile.baudrate = baud
|
currentProfile.baudRate = baud
|
||||||
});
|
});
|
||||||
|
|
||||||
stopBits_e.on('change', () => {
|
stopBits_e.on('change', () => {
|
||||||
|
@ -397,9 +414,12 @@ TABS.sitl.initialize = (callback) => {
|
||||||
} else {
|
} else {
|
||||||
port_e.val(currentProfile.port);
|
port_e.val(currentProfile.port);
|
||||||
}
|
}
|
||||||
port_e.prop('disabled', simulator.isPortFixed);
|
sim_e.prop('disabled', !currentProfile.simEnabled);
|
||||||
|
simIp_e.prop('disabled', !currentProfile.simEnabled);
|
||||||
|
port_e.prop('disabled', simulator.isPortFixed || !currentProfile.simEnabled);
|
||||||
|
useImu_e.prop('disabled', !currentProfile.simEnabled);
|
||||||
|
|
||||||
renderChanMapTable();
|
renderChanMapTable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -412,39 +432,35 @@ TABS.sitl.initialize = (callback) => {
|
||||||
});
|
});
|
||||||
currentProfile = profiles[selectedIndex];
|
currentProfile = profiles[selectedIndex];
|
||||||
|
|
||||||
if (currentProfile.isStdProfile) {
|
|
||||||
currentProfile = structuredClone(stdProfiles.find((profile) => {
|
|
||||||
return profile.sim == currentProfile.sim;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
protocollPreset_e.val(currentProfile.serialProtocol);
|
protocollPreset_e.val(currentProfile.serialProtocol);
|
||||||
if (currentProfile.serialProtocol == "manual")
|
if (currentProfile.serialProtocol == "manual")
|
||||||
{
|
{
|
||||||
baudRate_e.val(currentProfile.baudrate);
|
baudRate_e.val(currentProfile.baudRate);
|
||||||
baudRate_e.prop('disabled', false);
|
baudRate_e.prop('disabled', false);
|
||||||
stopBits_e.val(currentProfile.stopBits);
|
stopBits_e.val(currentProfile.stopBits);
|
||||||
stopBits_e.prop('disabled', false);
|
stopBits_e.prop('disabled', false);
|
||||||
parity_e.val(currentProfile.parity);
|
parity_e.val(currentProfile.parity);
|
||||||
parity_e.prop('disabled', false);
|
parity_e.prop('disabled', false);
|
||||||
|
serialUart_e.prop('disabled', false);
|
||||||
} else {
|
} else {
|
||||||
var protocoll = serialProtocolls.find(protocoll => {
|
var protocoll = serialProtocolls.find(protocoll => {
|
||||||
return protocoll.name == currentProfile.serialProtocol;
|
return protocoll.name == currentProfile.serialProtocol;
|
||||||
});
|
});
|
||||||
baudRate_e.prop('disabled', true);
|
baudRate_e.prop('disabled', true);
|
||||||
baudRate_e.val(protocoll.baudrate);
|
baudRate_e.val(protocoll.baudRate);
|
||||||
stopBits_e.prop('disabled', true);
|
stopBits_e.prop('disabled', true);
|
||||||
stopBits_e.val(protocoll.stopBits);
|
stopBits_e.val(protocoll.stopBits);
|
||||||
parity_e.prop('disabled', true);
|
parity_e.prop('disabled', true);
|
||||||
parity_e.val(protocoll.parity);
|
parity_e.val(protocoll.parity);
|
||||||
|
serialUart_e.prop('disabled', currentProfile.serialProtocol == "Flight Controller Proxy");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentProfile.comPort != "")
|
if (currentProfile.serialPort != "")
|
||||||
serialPorts_e.val(currentProfile.comPort);
|
serialPorts_e.val(currentProfile.serialPort);
|
||||||
|
|
||||||
enableSim_e.prop('checked', currentProfile.simEnabeld).trigger('change');
|
enableSim_e.prop('checked', currentProfile.simEnabled).trigger('change');
|
||||||
serialTcpEable_e.prop('checked', currentProfile.useSerialTcp).trigger('change');
|
serialReceiverEnable_e.prop('checked', currentProfile.useSerialReceiver).trigger('change');
|
||||||
tcpPort_e.val(currentProfile.tcpPort);
|
serialUart_e.val(currentProfile.serialUart);
|
||||||
mapping = currentProfile.channelMap;
|
mapping = currentProfile.channelMap;
|
||||||
sim_e.val(currentProfile.sim);
|
sim_e.val(currentProfile.sim);
|
||||||
updateSim();
|
updateSim();
|
||||||
|
@ -510,7 +526,7 @@ TABS.sitl.initialize = (callback) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
TABS.sitl.cleanup = (callback) => {
|
TABS.sitl.cleanup = (callback) => {
|
||||||
Ser2TCP.stopPollSerialPorts();
|
SitlSerialPortUtils.stopPollSerialPorts();
|
||||||
if (callback)
|
if (callback)
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue