1
0
Fork 0
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:
Marcelo Bezerra 2024-04-29 12:52:07 +02:00
commit f378366914
6 changed files with 975 additions and 336 deletions

View file

@ -169,7 +169,7 @@ function createWindow() {
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
}
}
};
app.on('window-all-closed', () => {

View file

@ -8,42 +8,46 @@ const { chmod, rm } = require('node:fs');
const { GUI } = require('./gui');
const serialRXProtocolls = [
{
name : "Flight Controller Proxy",
baudRate: 115200,
stopBits: "One",
parity: "None"
},
{
name : "SBus",
baudrate: 100000,
baudRate: 100000,
stopBits: "Two",
parity: "Even"
},
{
name : "SBus Fast",
baudrate: 200000,
baudRate: 200000,
stopBits: "Two",
parity: "Even"
},
{
name : "Crossfire/Ghost",
baudrate: 420000,
baudRate: 420000,
stopBits: "One",
parity: "None"
},
{
name : "FPort/IBus/Spektrum/SRXL2/SUMD",
baudrate: 115200,
baudRate: 115200,
stopBits: "One",
parity: "None"
},
{
name : "JETI EX Bus",
baudrate: 125000,
baudRate: 125000,
stopBits: "One",
parity: "None"
},
];
var Ser2TCP = {
var SitlSerialPortUtils = {
isRunning: false,
process: null,
portsList: [],
stopPolling: false,
@ -51,108 +55,26 @@ var Ser2TCP = {
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) {
SerialPort.list().then((ports, error) => {
var devices = [];
if (error) {
GUI.log("Unable to list serial ports.");
} else {
} else {
ports.forEach((device) => {
if (GUI.operating_system == 'Windows') {
var m = device.path.match(/COM\d?\d/g)
if (GUI.operating_system == 'Windows') {
var m = device.path.match(/COM\d?\d/g)
if (m)
devices.push(m[0]);
} else {
devices.push(m[0]);
} else {
/* Limit to: USB serial, RFCOMM (BT), 6 legacy devices */
if (device.pnpId ||
device.path.match(/rfcomm\d*/) ||
device.path.match(/ttyS[0-5]$/)) {
devices.push(device.path);
}
}
});
}
}
});
}
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)
this.stop();
@ -232,7 +154,7 @@ var SITLProcess = {
if (err)
console.log(err);
});
} else {
alert(GUI.operating_system);
return;
@ -255,6 +177,32 @@ var SITLProcess = {
if (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);
},
@ -292,4 +240,4 @@ var SITLProcess = {
}
};
module.exports = { Ser2TCP, SITLProcess };
module.exports = { SITLProcess, SitlSerialPortUtils };

View file

@ -238,20 +238,20 @@
"sitlStdProfileCantOverwritten": {
"message": "SITL standard profile can't be overwritten. Please create a new one."
},
"sitlSerialToTCP": {
"message": "Serial to TCP (UART)"
"serialReceiver": {
"message": "Serial receiver"
},
"sitlSerialProtocoll": {
"message": "Preset for RX Protocoll"
"message": "Serial port settings preset for RX Protocol of connected receiver"
},
"sitlSerialStopbits": {
"message": "Stopbits"
},
"sitlSerialPort": {
"message": "Serial port"
"message": "Serial receiver/Proxy FC is connectected to host's serial port"
},
"sitlSerialTCPPort": {
"message": "TCP port"
"sitlSerialUART": {
"message": "Serial receiver is configured on SITL's UART"
},
"sitlSerialParity": {
"message": "Parity"
@ -277,8 +277,8 @@
"sitlPortHelp": {
"message": "Port number of the interface of the simulator. Note: The RealFlight port is fixed and cannot be changed."
},
"sitlSer2TcpHelp": {
"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. "
"sitlSerialReceiverHelp": {
"message": "Use receiver (SBUS/CRSF/etc.) connected to host using USB-to-UART adapter or proxy Flight Controller."
},
"auxiliaryAcroEnabled": {
"message": "ACRO"

936
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -88,13 +88,13 @@
</div>
<div class="config-section gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="sitlSerialToTCP"></div>
<div class="helpicon cf_tip" data-i18n_title="sitlSer2TcpHelp"></div>
<div class="spacer_box_title" data-i18n="serialReceiver"></div>
<div class="helpicon cf_tip" data-i18n_title="sitlSerialReceiverHelp"></div>
</div>
<div class="spacer_box">
<div class="checkbox">
<input type="checkbox" id="serialTcpEnable" class="toggle" data-live="true">
<label for="serialTcpEnable"><span data-i18n="sitlSerialTcpEnable"></span></label>
<input type="checkbox" id="serialReceiverEnable" class="toggle" data-live="true">
<label for="serialReceiverEnable"><span data-i18n="sitlSerialReceiverEnable"></span></label>
</div>
<span id="serialTcpOptions">
<div class="select">
@ -102,32 +102,31 @@
<label for="sitlSerialPort"> <span data-i18n="sitlSerialPort"></span></label>
</div>
<div class="select">
<select id="serialTCPPort">
<option value="5760">5760 (UART1)</option>
<option value="5761">5761 (UART2)</option>
<option value="5762">5762 (UART3)</option>
<option value="5763">5763 (UART4)</option>
<option value="5764">5764 (UART5)</option>
<option value="5765">5765 (UART6)</option>
<option value="5766">5766 (UART7)</option>
<option value="5767">5767 (UART8)</option>
<select id="sitlSerialUART">
<option value="1">UART1</option>
<option value="2">UART2</option>
<option value="3">UART3</option>
<option value="4">UART4</option>
<option value="5">UART5</option>
<option value="6">UART6</option>
<option value="7">UART7</option>
<option value="8">UART8</option>
</select>
<label for="serialTCPPort"> <span data-i18n="sitlSerialTCPPort"></span></label>
<label for="sitlSerialUART"> <span data-i18n="sitlSerialUART"></span></label>
</div>
<div class="select">
<select id="serialProtocoll"></select>
<label for="serialProtocoll"> <span data-i18n="sitlSerialProtocoll"></span></label>
</div>
<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>
</div>
<div class="select">
<select id="serialStopbits">
<option value="None">0</option>
<option value="One">1</option>
<option value="OnePointFive">1.5</option>
<option value="Two">2</option>
<option value="None">None</option>
<option value="One">One</option>
<option value="Two">Two</option>
</select>
<label for="serialStopbits"> <span data-i18n="sitlSerialStopbits"></span></label>
</div>
@ -135,9 +134,7 @@
<select id="serialParity">
<option value="None">None</option>
<option value="Even">Even</option>
<option value="Mark">Mark</option>
<option value="Odd">Odd</option>
<option value="Space">Space</option>
</select>
<label for="serialParity"> <span data-i18n="sitlSerialParity"></span></label>
</div>

View file

@ -3,7 +3,7 @@ const path = require('path');
const { GUI, TABS } = require('./../js/gui');
const i18n = require('./../js/localization');
const { Ser2TCP, SITLProcess } = require('./../js/sitl');
const { SITLProcess, SitlSerialPortUtils } = require('./../js/sitl');
const Store = require('electron-store');
const store = new Store();
@ -28,21 +28,39 @@ const simulators = [
const stdProfiles = [
{
name: "[Standard] X-Plane",
name: "[Standard] Confgurator",
sim: "X-Plane",
eepromFileName: "standard-x-plane.bin",
eepromFileName: "standard-configurator.bin",
isStdProfile: true,
simEnabeld: true,
simEnabled: false,
port: 49001,
ip: "127.0.0.1",
useImu: false,
channelMap: [ 1, 15, 13, 16],
useSerialTcp: true,
comPort: "",
tcpPort: 5762,
useSerialReceiver: true,
serialPort: "",
serialUart: 3,
serialProtocol: "SBus",
baudrate: false,
stopbits: false,
baudRate: 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
},
{
@ -50,19 +68,18 @@ const stdProfiles = [
sim: "RealFlight",
eepromFileName: "standard-realflight.bin",
isStdProfile: true,
simEnabeld: true,
simEnabled: true,
port: 49001,
ip: "127.0.0.1",
useImu: false,
channelMap: [ 1, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
useSerialTcp: true,
comPort: "",
tcpPort: 5762,
useSerialReceiver: true,
serialPort: "",
serialUart: 3,
serialProtocol: "SBus",
baudrate: false,
stopbits: false,
baudRate: false,
stopBits: false,
parity: false
}
];
@ -80,7 +97,7 @@ TABS.sitl.initialize = (callback) => {
var currentSim, currentProfile, profiles;
var mapping = new Array(28).fill(0);
var serialProtocolls = Ser2TCP.getProtocolls();
var serialProtocolls = SitlSerialPortUtils.getProtocolls();
var sim_e = $('#simulator');
var enableSim_e = $('#sitlEnableSim');
var port_e = $('#simPort');
@ -91,13 +108,12 @@ TABS.sitl.initialize = (callback) => {
var profileNewBtn_e = $('#sitlProfileNew');
var profileDeleteBtn_e = $('#sitlProfileDelete');
var serialPorts_e = $('#sitlSerialPort');
var serialTcpEnable = $('#serialTcpEnable')
var tcpPort_e = $('#serialTCPPort');
var serialReceiverEnable_e = $('#serialReceiverEnable');
var serialUart_e = $('#sitlSerialUART');
var protocollPreset_e = $('#serialProtocoll');
var baudRate_e = $('#sitlBaud');
var stopBits_e = $('#serialStopbits');
var parity_e = $('#serialParity');
var serialTcpEable_e = $('#serialTcpEnable');
if (SITLProcess.isRunning) {
$('.sitlStart').addClass('disabled');
@ -122,8 +138,8 @@ TABS.sitl.initialize = (callback) => {
initElements(true);
Ser2TCP.resetPortsList();
Ser2TCP.pollSerialPorts(ports => {
SitlSerialPortUtils.resetPortsList();
SitlSerialPortUtils.pollSerialPorts(ports => {
serialPorts_e.find('*').remove();
ports.forEach(port => {
serialPorts_e.append(`<option value="${port}">${port}</option>`)
@ -132,7 +148,8 @@ TABS.sitl.initialize = (callback) => {
});
enableSim_e.on('change', () => {
currentProfile.simEnabeld = enableSim_e.is(':checked');
currentProfile.simEnabled = enableSim_e.is(':checked');
updateSim();
});
sim_e.on('change', () => {
@ -198,36 +215,37 @@ TABS.sitl.initialize = (callback) => {
}
channelMap = channelMap.substring(0, channelMap.length - 1);
var serialOptions;
var selectedProtocoll = protocollPreset_e.find(':selected').val();
if (selectedProtocoll == "manual") {
serialOptions = {
protocollName: "manual",
bitrate: currentProfile.baudrate,
stopBits: currentProfile.stopBits,
parityBit: currentProfile.parity
}
} else {;
serialOptions = {
protocollName: selectedProtocoll
var serialOptions = null;
if ( serialReceiverEnable_e.is(':checked') && !!serialPorts_e.val()) {
var selectedProtocoll = protocollPreset_e.find(':selected').val();
if (selectedProtocoll == "manual") {
serialOptions = {
protocollName: "manual",
baudRate: baudRate_e.val() || currentProfile.baudRate || "115200",
stopBits: stopBits_e.val() || currentProfile.stopBits || "One",
parity: parity_e.val() || currentProfile.parity || "None",
serialPort: serialPorts_e.val() || currentProfile.serialPort || "",
serialUart: serialUart_e.val() || currentProfile.serialUart || -1
}
} 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 => {
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}`);
});
}
SITLProcess.start(currentProfile.eepromFileName, sim, useImu_e.is(':checked'), simIp, simPort, channelMap, serialOptions,result => {
appendLog(result);
});
});
$('.sitlStop').on('click', ()=> {
$('.sitlStop').addClass('disabled');
$('.sitlStart').removeClass('disabled');
Ser2TCP.stop();
SITLProcess.stop();
appendLog(i18n.getMessage('sitlStopped'));
});
@ -250,17 +268,18 @@ TABS.sitl.initialize = (callback) => {
name: name,
sim: "RealFlight",
isStdProfile: false,
simEnabeld: true,
simEnabled: false,
eepromFileName: eerpromName,
port: 49001,
ip: "127.0.0.1",
useImu: false,
channelMap: [ 1, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0],
useSerialTcp: true,
tcpPort: 5762,
useSerialReceiver: true,
serialPort: serialPorts_e.val(),
serialUart: 3,
serialProtocol: "SBus",
baudrate: false,
stopbits: false,
baudRate: false,
stopBits: false,
parity: false
}
profiles.push(profile);
@ -289,8 +308,8 @@ TABS.sitl.initialize = (callback) => {
saveProfiles();
});
serialTcpEable_e.on('change', () => {
currentProfile.useSerialTcp = serialTcpEable_e.is(':checked');
serialReceiverEnable_e.on('change', () => {
currentProfile.useSerialReceiver = serialReceiverEnable_e.is(':checked');
});
protocollPreset_e.on('change', () => {
@ -302,36 +321,34 @@ TABS.sitl.initialize = (callback) => {
if (selectedProtocoll != 'manual'){
baudRate_e.prop('disabled', true);
baudRate_e.val(protocoll.baudrate);
baudRate_e.val(protocoll.baudRate);
stopBits_e.prop('disabled', true);
stopBits_e.val(protocoll.stopBits);
parity_e.prop('disabled', true);
parity_e.val(protocoll.parity);
serialUart_e.prop('disabled', selectedProtocoll == "Flight Controller Proxy");
} else {
baudRate_e.prop('disabled', false);
baudRate_e.val('');
stopBits_e.prop('disabled', false);
stopBits_e.val('');
parity_e.prop('disabled', false);
parity_e.val('');
serialUart_e.prop('disabled', false);
}
currentProfile.serialProtocol = selectedProtocoll;
});
serialPorts_e.on('change', () => {
currentProfile.comPort = serialPorts_e.val();
currentProfile.serialPort = serialPorts_e.val();
});
tcpPort_e.on('change', () => {
currentProfile.tcpPort = parseInt(tcpPort_e.val());
serialUart_e.on('change', () => {
currentProfile.serialUart = parseInt(serialUart_e.val());
});
baudRate_e.on('change', () => {
var baud = parseInt(baudRate_e.val());
if (baud != NaN)
currentProfile.baudrate = baud
currentProfile.baudRate = baud
});
stopBits_e.on('change', () => {
@ -397,9 +414,12 @@ TABS.sitl.initialize = (callback) => {
} else {
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;
}
});
@ -412,39 +432,35 @@ TABS.sitl.initialize = (callback) => {
});
currentProfile = profiles[selectedIndex];
if (currentProfile.isStdProfile) {
currentProfile = structuredClone(stdProfiles.find((profile) => {
return profile.sim == currentProfile.sim;
}));
}
protocollPreset_e.val(currentProfile.serialProtocol);
if (currentProfile.serialProtocol == "manual")
{
baudRate_e.val(currentProfile.baudrate);
baudRate_e.val(currentProfile.baudRate);
baudRate_e.prop('disabled', false);
stopBits_e.val(currentProfile.stopBits);
stopBits_e.prop('disabled', false);
parity_e.val(currentProfile.parity);
parity_e.prop('disabled', false);
serialUart_e.prop('disabled', false);
} else {
var protocoll = serialProtocolls.find(protocoll => {
return protocoll.name == currentProfile.serialProtocol;
});
baudRate_e.prop('disabled', true);
baudRate_e.val(protocoll.baudrate);
baudRate_e.val(protocoll.baudRate);
stopBits_e.prop('disabled', true);
stopBits_e.val(protocoll.stopBits);
parity_e.prop('disabled', true);
parity_e.val(protocoll.parity);
serialUart_e.prop('disabled', currentProfile.serialProtocol == "Flight Controller Proxy");
}
if (currentProfile.comPort != "")
serialPorts_e.val(currentProfile.comPort);
if (currentProfile.serialPort != "")
serialPorts_e.val(currentProfile.serialPort);
enableSim_e.prop('checked', currentProfile.simEnabeld).trigger('change');
serialTcpEable_e.prop('checked', currentProfile.useSerialTcp).trigger('change');
tcpPort_e.val(currentProfile.tcpPort);
enableSim_e.prop('checked', currentProfile.simEnabled).trigger('change');
serialReceiverEnable_e.prop('checked', currentProfile.useSerialReceiver).trigger('change');
serialUart_e.val(currentProfile.serialUart);
mapping = currentProfile.channelMap;
sim_e.val(currentProfile.sim);
updateSim();
@ -510,7 +526,7 @@ TABS.sitl.initialize = (callback) => {
};
TABS.sitl.cleanup = (callback) => {
Ser2TCP.stopPollSerialPorts();
SitlSerialPortUtils.stopPollSerialPorts();
if (callback)
callback();
};