Working burn % tracking for stm32

This commit is contained in:
Josh Stewart 2024-06-12 09:30:00 +10:00
parent 67df821a4b
commit 5e19016891
1 changed files with 8 additions and 7 deletions

15
main.js
View File

@ -272,21 +272,22 @@ ipcMain.on("uploadFW_stm32", (e, args) => {
if(process.platform == "win32") { executableName = executableName + '.exe'; } //This must come after the configName line above if(process.platform == "win32") { executableName = executableName + '.exe'; } //This must come after the configName line above
console.log(executableName); console.log(executableName);
dfuutilErr = "Executing Cmd: "+ executableName;
const child = execFile(executableName, execArgs); const child = execFile(executableName, execArgs);
child.stdout.on('data', (data) => { child.stderr.on('data', (data) => {
console.log(`dfu-util stdout:\n${data}`); console.log(`dfu-util stderr:\n${data}`);
}); });
child.stderr.on('data', (data) => { child.stdout.on('data', (data) => {
console.log(`dfu-util stderr: ${data}`); console.log(`dfu-util stdout: ${data}`);
console.log("Data Length: "+data.length);
dfuutilErr = dfuutilErr + data; dfuutilErr = dfuutilErr + data;
//Check if avrdude has started the actual burn yet, and if so, track the '#' characters that it prints. Each '#' represents 1% of the total burn process (50 for write and 50 for read) //Check if avrdude has started the actual burn yet, and if so, track the '#' characters that it prints. Each '#' represents 1% of the total burn process (50 for write and 50 for read)
if (burnStarted == true) if (burnStarted == true)
{ {
if(data=="#") { burnPercent += 1; } e.sender.send( "upload percent", (4*(data.split("=").length - 1)) );
e.sender.send( "upload percent", burnPercent );
} }
else else
{ {
@ -313,7 +314,7 @@ ipcMain.on("uploadFW_stm32", (e, args) => {
{ {
console.log(`dfu-util process exited with code ${code}`); console.log(`dfu-util process exited with code ${code}`);
e.sender.send( "upload error", dfuutilErr ) e.sender.send( "upload error", dfuutilErr )
teensyLoaderErr = ""; dfuutilErr = "";
} }
else else
{ {