Check whether avrdude is already running before starting another instance
This commit is contained in:
parent
f7ee5a1e0a
commit
ee932ce5e3
6
main.js
6
main.js
|
@ -8,6 +8,7 @@ const {execFile} = require('child_process');
|
||||||
let win
|
let win
|
||||||
|
|
||||||
var avrdudeErr = "";
|
var avrdudeErr = "";
|
||||||
|
var avrdudeIsRunning = false;
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
|
@ -57,6 +58,9 @@ ipcMain.on('download', (e, args) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('uploadFW', (e, args) => {
|
ipcMain.on('uploadFW', (e, args) => {
|
||||||
|
|
||||||
|
if(avrdudeIsRunning == true) { return; }
|
||||||
|
avrdudeIsRunning = true; //Indicate that an avrdude process has started
|
||||||
var platform;
|
var platform;
|
||||||
|
|
||||||
var burnStarted = false;
|
var burnStarted = false;
|
||||||
|
@ -107,9 +111,11 @@ ipcMain.on('uploadFW', (e, args) => {
|
||||||
child.on('error', (err) => {
|
child.on('error', (err) => {
|
||||||
console.log('Failed to start subprocess.');
|
console.log('Failed to start subprocess.');
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
avrdudeIsRunning = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('close', (code) => {
|
child.on('close', (code) => {
|
||||||
|
avrdudeIsRunning = false;
|
||||||
if (code !== 0)
|
if (code !== 0)
|
||||||
{
|
{
|
||||||
console.log(`avrdude process exited with code ${code}`);
|
console.log(`avrdude process exited with code ${code}`);
|
||||||
|
|
Loading…
Reference in New Issue