1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 12:25:13 +03:00

Merge branch 'master' of https://github.com/RomanLut/inav-configurator into submit-serial-receiver

This commit is contained in:
Roman Lut 2024-04-28 19:40:18 +02:00
commit 53b578823c
189 changed files with 24203 additions and 15239 deletions

View file

@ -1,9 +1,12 @@
'use strict'
const path = require('path');
const { app } = require('@electron/remote');
const { SerialPort } = require('serialport');
const { spawn } = require('node:child_process');
const pathMod = require('path');
const { chmod, rm } = require('node:fs');
const { GUI } = require('./gui');
const serialRXProtocolls = [
{
name : "Flight Controller Proxy",
@ -53,22 +56,25 @@ var SitlSerialPortUtils = {
},
getDevices: function(callback) {
chrome.serial.getDevices((devices_array) => {
SerialPort.list().then((ports, error) => {
var devices = [];
devices_array.forEach((device) => {
if (error) {
GUI.log("Unable to list serial ports.");
} else {
ports.forEach((device) => {
if (GUI.operating_system == 'Windows') {
var m = device.path.match(/COM\d?\d/g)
if (m)
devices.push(m[0]);
} else {
if (device.displayName != null) {
var m = device.path.match(/\/dev\/.*/)
var m = device.path.match(/\/dev\/.*/)
if (m)
devices.push(m[0]);
}
}
}
});
}
callback(devices);
});
},
@ -117,7 +123,7 @@ var SITLProcess = {
process: null,
deleteEepromFile(filename) {
rm(`${nw.App.dataPath}/${filename}`, error => {
rm(`${app.getPath('userData')}/${filename}`, error => {
if (error) {
GUI.log(`Unable to reset Demo mode: ${error.message}`);
}
@ -131,16 +137,25 @@ var SITLProcess = {
var sitlExePath, eepromPath;
if (GUI.operating_system == 'Windows') {
sitlExePath = './resources/sitl/windows/inav_SITL.exe'
eepromPath = `${nw.App.dataPath}\\${eepromFileName}`
sitlExePath = path.join(__dirname, './../resources/sitl/windows/inav_SITL.exe');
eepromPath = `${app.getPath('userData')}\\${eepromFileName}`
} else if (GUI.operating_system == 'Linux') {
sitlExePath = './resources/sitl/linux/inav_SITL';
eepromPath = `${nw.App.dataPath}/${eepromFileName}`
sitlExePath = path.join(__dirname, './../resources/sitl/linux/inav_SITL');
eepromPath = `${app.getPath('userData')}/${eepromFileName}`
chmod(sitlExePath, 0o755, err => {
if (err)
console.log(err);
});
} else if (GUI.operating_system == 'MacOS') {
sitlExePath = path.join(__dirname, './../resources/sitl/macos/inav_SITL');
eepromPath = `${app.getPath('userData')}/${eepromFileName}`
chmod(sitlExePath, 0o755, err => {
if (err)
console.log(err);
});
} else {
alert(GUI.operating_system);
return;
}
@ -223,3 +238,5 @@ var SITLProcess = {
}
}
};
module.exports = { SITLProcess };