Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RomanLut/inav-configurator
Browse files Browse the repository at this point in the history
…into submit-serial-receiver
  • Loading branch information
RomanLut committed Apr 28, 2024
2 parents 53b5788 + 8a372de commit d49b859
Show file tree
Hide file tree
Showing 38 changed files with 303 additions and 516 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
cache: 'npm'
# Workaround due to a bug in node-gyp: https://github.com/electron/rebuild/issues/1116
- name: Install Setuptools
run: pip install setuptools
run: python3 -m pip install --break-system-packages setuptools
- name: Install deps
uses: nick-fields/retry@v2
with:
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ everything, the hardware is not working, or you have any other _support_ problem

## Installation

Depending on the target operating system, _INAV Configurator_ is distributed as a _standalone_ application or Chrome App.
_INAV Configurator_ is distributed as a _standalone_ application.

### Windows

1. Visit [release page](https://github.com/iNavFlight/inav-configurator/releases)
2. Download Configurator for Windows platform (win32 or win64 is present)
2. Download Configurator for Windows platform (ia32 or win64 is present)
3. Install
* Extract ZIP archive and run the INAV Configurator app from the unpacked folder
* OR just use the setup program `INAV Configurator.msi`
* OR just use the setup program `INAV-Configurator_win32_arch_x.y.z.msi`, **arch** is your computer architecture (ia32 (32bit) or x64 (64bit)), **x.y.z** is the INAV Configurator version number.

4. Configurator is not signed, so you have to allow Windows to run untrusted applications. There might be a monit for it during the first run

### Linux

1. Visit [release page](https://github.com/iNavFlight/inav-configurator/releases)
2. Download Configurator for Linux platform (linux32 and linux64 are present)
* **.rpm** is the Fedora installation file. Just download and install using `sudo dnf localinstall /path/to/INAV-Configurator_linux64-x.y.z-x86_64.rpm` or open it with a package manager (e.g. via Files)
* **.deb** is the Debian/Ubuntu installation file. Just download and install using `sudo apt install /path/to/INAV-Configurator_linux64_x.y.z.deb` or open it with a package manager (e.g. via the File Manager)
2. Download Configurator for Linux platform (only linux64 is present)
* **.rpm** is the Fedora installation file. Just download and install using `sudo dnf localinstall /path/to/INAV-Configurator_linux_x64-x.y.z.rpm` or open it with a package manager (e.g. via Files)
* **.deb** is the Debian/Ubuntu installation file. Just download and install using `sudo apt install /path/to/INAV-Configurator_linux_x64_x.y.z.deb` or open it with a package manager (e.g. via the File Manager)
* **.zip** is a universal archive. Download and continue with these instructions to install
3. Change to the directory containing the downloaded **zip** file
4. download [this](https://raw.githubusercontent.com/iNavFlight/inav-configurator/master/assets/linux/inav-configurator.desktop) file to the same directory. Its filename should be `inav-configurator.desktop`.
5. Extract **zip** archive
```
unzip INAV-Configurator_linuxNN_x.y.z.tar.gz -d /tmp/
unzip INAV-Configurator_linux_arch_x.y.z.zip -d /tmp/
```
**NN** is the bits of your OS. **x.y.z** is the INAV Configurator version number.
**arch** is your computer architecture (x64, armv7l, ...), **x.y.z** is the INAV Configurator version number.

6. If this is the first time installing INAV Configurator, create a home for its files
```
Expand Down Expand Up @@ -93,21 +93,27 @@ Options:

See [Electron Forge CLI Documentation](https://www.electronforge.io/cli#options-2) for details

Note: Not all architectures are available for all platforms. For example, ia32 (32bit) support is not available for Linux.
Tested architectures:
- Windows: x64 and ia32
- Linux: x64 and armv7l
- MacOS: x64 and arm64

To build the setup program for windows, you have to install [WiX Toolset V3](https://github.com/wixtoolset/wix3/releases) and add the `bin` folder to you `PATH`, e.g.
```C:\Program Files (x86)\WiX Toolset v3.14\bin```

To build deb and rpm packages for Linux, you have to install the following packages:
- Ubuntu/Debian: `dpkg, fakeroot, rpmbuild, build-essential, libudev-dev`
- Ubuntu/Debian: `dpkg, fakeroot, rpm, build-essential, libudev-dev`
- OpenSuse/Fedora: `dpkg, fakeroot, rpmbuild, systemd-devel, devel-basis (zypper install -t pattern devel_basis), zip`

Example (note the double -- ):
``` npm run make -- --arch="x64" ```
```npm run make -- --arch="x64"```

### Running with debug | Inspector

To be able to open Inspector, set envorinment variable `NODE_ENV` to `develpoment` or set the flag directly when run `npm start`:

```NODE_ENV=development npm start```
```NODE_ENV=development npm start``` or ```$env:NODE_ENV="development" | npm start``` for Windows PowerShell

Or use vscode and start a debug session `Debug Configurator` (Just hit F5!)

Expand Down
3 changes: 2 additions & 1 deletion forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ module.exports = {
name: '@electron-forge/maker-dmg',
config: {
name: "INAV Configurator",
background: "./assets/osx/dmg-background.png"
background: "./assets/osx/dmg-background.png",
icon: "./images/inav.icns"
}
},
{
Expand Down
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,6 @@ <h2 class="groundstation-telemetry__header" data-i18n="gsTelemetry"></h2>
<div>
<span id="hardware-roundtrip"> </span>
</div>
<div>
<span id="drop-rate"> </span>
</div>
<div>
<span data-i18n="statusbar_arming_flags"></span> <span class="arming-flags">-</span>
</div>
Expand Down
4 changes: 3 additions & 1 deletion js/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ class Connection {
getTimeout() {
if (this._bitrate >= 57600) {
return 3000;
} else {
} if (this._bitrate >= 19200) {
return 4000;
} else {
return 6000;
}
}
}
Expand Down
23 changes: 16 additions & 7 deletions js/connection/connectionSerial.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class ConnectionSerial extends Connection {
super._type = ConnectionType.Serial;
}

connectImplementation(path, options, callback) {
connectImplementation(path, options, callback) {
try {
this._serialport = new SerialPortStream({binding, path: path, baudRate: options.bitrate, autoOpen: true}, () => {
if (callback) {
callback({
connectionId: ++this._connectionId,
bitrate: options.bitrate
bitrate: options.bitrate
});
}
});
Expand All @@ -50,12 +50,12 @@ class ConnectionSerial extends Connection {
this.abort();
console.log("Serial error: " + error);
this._onReceiveErrorListeners.forEach(listener => {
listener(error);
listener(error);
});
});
}

disconnectImplementation(callback) {
disconnectImplementation(callback) {
if (this._serialport && this._serialport.isOpen) {
this._serialport.close(error => {
if (error) {
Expand All @@ -68,7 +68,7 @@ class ConnectionSerial extends Connection {
callback(true);
}
}

sendImplementation(data, callback) {
if (this._serialport && this._serialport.isOpen) {
this._serialport.write(Buffer.from(data), error => {
Expand Down Expand Up @@ -105,14 +105,23 @@ class ConnectionSerial extends Connection {
this._onReceiveErrorListeners = this._onReceiveErrorListeners.filter(listener => listener !== callback);
}

static async getDevices(callback) {
static async getDevices(callback) {
SerialPort.list().then((ports, error) => {
var devices = [];
if (error) {
GUI.log("Unable to list serial ports.");
} else {
ports.forEach(port => {
devices.push(port.path);
if (GUI.operating_system == 'Linux') {
/* Limit to: USB serial, RFCOMM (BT), 6 legacy devices */
if (port.pnpId ||
port.path.match(/rfcomm\d*/) ||
port.path.match(/ttyS[0-5]$/)) {
devices.push(port.path);
}
} else {
devices.push(port.path);
}
});
}
if (callback)
Expand Down
11 changes: 9 additions & 2 deletions js/gui.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';
const { dialog } = require("@electron/remote");


const CONFIGURATOR = require('./data_storage');
const Switchery = require('./libraries/switchery/switchery')
const MSP = require('./msp');
const FC = require('./fc');
const interval = require('./intervals');
const mspBalancedInterval = require('./msp_balanced_interval');
const { scaleRangeInt } = require('./helpers');
const i18n = require('./localization');

Expand Down Expand Up @@ -92,7 +93,6 @@ GUI_control.prototype.tab_switch_cleanup = function (callback) {
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive

interval.killAll(['global_data_refresh', 'msp-load-update', 'ltm-connection-check']);
mspBalancedInterval.flush();

if (this.active_tab) {
TABS[this.active_tab].cleanup(callback);
Expand Down Expand Up @@ -529,6 +529,13 @@ GUI_control.prototype.update_dataflash_global = function () {
}
};

/**
* Don't use alert() in Electron, it has a nasty bug: https://github.com/electron/electron/issues/31917
*/
GUI_control.prototype.alert = function(message) {
dialog.showMessageBoxSync({ message: message, icon: "./images/inav_icon_128.png" });
}

// initialize object into GUI variable
var GUI = new GUI_control();

Expand Down
26 changes: 24 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const { app, BrowserWindow, ipcMain, Menu, MenuItem } = require('electron');
const windowStateKeeper = require('electron-window-state');
const path = require('path');
const Store = require('electron-store');
Expand Down Expand Up @@ -53,6 +53,10 @@ function createDeviceChooser() {
}

app.on('ready', () => {
createWindow();
});

function createWindow() {

let mainWindowState = windowStateKeeper({
defaultWidth: 800,
Expand All @@ -72,6 +76,24 @@ app.on('ready', () => {
},
});

mainWindow.webContents.on('context-menu', (_, props) => {
const menu = new Menu() ;
menu.append(new MenuItem({ label: "Undo", role: "undo", accelerator: 'CmdOrCtrl+Z', visible: props.isEditable }));
menu.append(new MenuItem({ label: "Redo", role: "redo", accelerator: 'CmdOrCtrl+Y', visible: props.isEditable }));
menu.append(new MenuItem({ type: "separator", visible: props.isEditable }));
menu.append(new MenuItem({ label: 'Cut', role: 'cut', accelerator: 'CmdOrCtrl+X', visible: props.isEditable && props.selectionText }));
menu.append(new MenuItem({ label: 'Copy', role: 'copy', accelerator: 'CmdOrCtrl+C', visible: props.selectionText }));
menu.append(new MenuItem({ label: 'Paste', role: 'paste', accelerator: 'CmdOrCtrl+V', visible: props.isEditable }));
menu.append(new MenuItem({ label: "Select all", role: 'selectAll', accelerator: 'CmdOrCtrl+A', visible: props.isEditable}));

menu.items.forEach(item => {
if (item.visible) {
menu.popup();
return;
}
});
});

mainWindow.webContents.on('select-bluetooth-device', (event, deviceList, callback) => {
event.preventDefault();
selectBluetoothCallback = callback;
Expand Down Expand Up @@ -147,7 +169,7 @@ app.on('ready', () => {
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
}
});
};

app.on('window-all-closed', () => {

Expand Down
8 changes: 7 additions & 1 deletion js/msp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const MSPCodes = require('./msp/MSPCodes')
const mspQueue = require('./serial_queue');
const eventFrequencyAnalyzer = require('./eventFrequencyAnalyzer');
const timeout = require('./timeouts');

/**
*
Expand Down Expand Up @@ -265,7 +267,9 @@ var MSP = {
/*
* Free port
*/
mspQueue.freeHardLock();
timeout.add('delayedFreeHardLock', function() {
mspQueue.freeHardLock();
}, 10);

// Reset variables
this.message_length_received = 0;
Expand Down Expand Up @@ -301,6 +305,8 @@ var MSP = {
var checksum;
var ii;

eventFrequencyAnalyzer.put('MPS ' + code);

if (!protocolVersion) {
protocolVersion = this.protocolVersion;
}
Expand Down
Loading

0 comments on commit d49b859

Please sign in to comment.