Check whether avrdude is already running before starting another instance

This commit is contained in:
Josh Stewart 2019-01-04 23:19:17 +11:00
parent f7ee5a1e0a
commit ee932ce5e3
1 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,7 @@ const {execFile} = require('child_process');
let win
var avrdudeErr = "";
var avrdudeIsRunning = false;
function createWindow () {
// Create the browser window.
@ -57,6 +58,9 @@ ipcMain.on('download', (e, args) => {
});
ipcMain.on('uploadFW', (e, args) => {
if(avrdudeIsRunning == true) { return; }
avrdudeIsRunning = true; //Indicate that an avrdude process has started
var platform;
var burnStarted = false;
@ -107,9 +111,11 @@ ipcMain.on('uploadFW', (e, args) => {
child.on('error', (err) => {
console.log('Failed to start subprocess.');
console.log(err);
avrdudeIsRunning = false;
});
child.on('close', (code) => {
avrdudeIsRunning = false;
if (code !== 0)
{
console.log(`avrdude process exited with code ${code}`);