Working local file uploads
Needs lots of error checking, but should be functional. Only tested on Macos
This commit is contained in:
parent
ce49bec4a3
commit
c66df2bdc2
|
@ -45,12 +45,12 @@
|
||||||
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" onClick="refreshBasetunes();"></select>
|
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" onClick="refreshBasetunes();"></select>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li><input type='button' id="btnChoosePort" value="Choose Port" /></li>
|
<li><input type='button' id="btnChoosePort" value="Choose Port" /></li>
|
||||||
<li><input type='button' id="btnSelectLocal" value="Use Local Firmware" /></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<p>Other actions:</p>
|
<p>Other actions:</p>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li><input type='button' id="btnDetails" value="View Firmware Notes" /></li>
|
<li><input type='button' id="btnDetails" value="View Firmware Notes" /></li>
|
||||||
<li><input type='button' value="Get Base Tune" id="btnBasetune" /></li>
|
<li><input type='button' value="Get Base Tune" id="btnBasetune" /></li>
|
||||||
|
<li><input type='button' id="btnSelectLocal" value="Use Local Firmware" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<div id="error"></div>
|
<div id="error"></div>
|
||||||
|
|
4
main.js
4
main.js
|
@ -142,8 +142,8 @@ ipcMain.on('installWinDrivers', (e, args) => {
|
||||||
ipcMain.on('selectLocalFirmware', (e, args) => {
|
ipcMain.on('selectLocalFirmware', (e, args) => {
|
||||||
localFirmware = dialog.showOpenDialogSync({
|
localFirmware = dialog.showOpenDialogSync({
|
||||||
properties: ['openFile'],
|
properties: ['openFile'],
|
||||||
title: "Select hex file",
|
title: "Select firmware file",
|
||||||
filters: [{ name: 'Firmware hex', extensions: ['hex'] }] })
|
filters: [{ name: 'Firmware binary', extensions: ['hex', 'bin'] }] })
|
||||||
|
|
||||||
if(localFirmware != undefined)
|
if(localFirmware != undefined)
|
||||||
{
|
{
|
||||||
|
|
136
renderer.js
136
renderer.js
|
@ -4,6 +4,8 @@ const {ipcRenderer} = require("electron")
|
||||||
const { shell } = require('electron')
|
const { shell } = require('electron')
|
||||||
|
|
||||||
var basetuneList = [];
|
var basetuneList = [];
|
||||||
|
var useLocalTune = false;
|
||||||
|
var localTuneFile = "";
|
||||||
|
|
||||||
function getTeensyVersion(id)
|
function getTeensyVersion(id)
|
||||||
{
|
{
|
||||||
|
@ -411,6 +413,7 @@ function refreshBasetunesDescription()
|
||||||
ipcRenderer.on("add local hex", (event, filename, state) =>
|
ipcRenderer.on("add local hex", (event, filename, state) =>
|
||||||
{
|
{
|
||||||
//Check if Local option already exists
|
//Check if Local option already exists
|
||||||
|
/*
|
||||||
var lastOption = document.getElementById('versionsSelect').lastElementChild
|
var lastOption = document.getElementById('versionsSelect').lastElementChild
|
||||||
if(lastOption.innerHTML == "Local")
|
if(lastOption.innerHTML == "Local")
|
||||||
{
|
{
|
||||||
|
@ -425,6 +428,11 @@ ipcRenderer.on("add local hex", (event, filename, state) =>
|
||||||
var select = document.getElementById('versionsSelect');
|
var select = document.getElementById('versionsSelect');
|
||||||
select.appendChild(newOption);
|
select.appendChild(newOption);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
useLocalTune = true;
|
||||||
|
localTuneFile = filename;
|
||||||
|
document.getElementById('versionsSelect').disabled = true;
|
||||||
|
//console.log("Local hex file selected: " + filename);
|
||||||
|
|
||||||
//Jump to the port selection screen
|
//Jump to the port selection screen
|
||||||
$("[href='#port']").trigger('click');
|
$("[href='#port']").trigger('click');
|
||||||
|
@ -474,7 +482,7 @@ function downloadHex(board, localFile="")
|
||||||
function downloadIni()
|
function downloadIni()
|
||||||
{
|
{
|
||||||
var e = document.getElementById('versionsSelect');
|
var e = document.getElementById('versionsSelect');
|
||||||
if(e.options[e.selectedIndex].innerHTML == "Local")
|
if(useLocalTune)
|
||||||
{
|
{
|
||||||
console.log("Local version selected, not downloading ini");
|
console.log("Local version selected, not downloading ini");
|
||||||
return;
|
return;
|
||||||
|
@ -520,6 +528,62 @@ function installDrivers()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadComplete(file)
|
||||||
|
{
|
||||||
|
//Lookup what platform we're using
|
||||||
|
var portSelect = document.getElementById('portsSelect');
|
||||||
|
var uploadBoard = portSelect.options[portSelect.selectedIndex].getAttribute("board");
|
||||||
|
var extension = file.substr(file.length - 3);
|
||||||
|
if(extension == "ini")
|
||||||
|
{
|
||||||
|
statusText.innerHTML = "Downloading firmware"
|
||||||
|
document.getElementById('iniFileText').style.display = "block"
|
||||||
|
document.getElementById('iniFileLocation').innerHTML = file
|
||||||
|
downloadHex(uploadBoard);
|
||||||
|
}
|
||||||
|
else if(extension == "hex" || extension == "bin")
|
||||||
|
{
|
||||||
|
console.log("Uploading da file!!");
|
||||||
|
statusText.innerHTML = "Beginning upload..."
|
||||||
|
|
||||||
|
//Retrieve the select serial port
|
||||||
|
var e = document.getElementById('portsSelect');
|
||||||
|
uploadPort = e.options[e.selectedIndex].value;
|
||||||
|
|
||||||
|
console.log("Using port: " + uploadPort);
|
||||||
|
|
||||||
|
//Show the sponsor banner
|
||||||
|
document.getElementById('sponsorbox').style.display = "block"
|
||||||
|
|
||||||
|
//Begin the upload
|
||||||
|
if(uploadBoard.includes("TEENSY"))
|
||||||
|
{
|
||||||
|
console.log("Uploading using Teensy_loader")
|
||||||
|
ipcRenderer.send("uploadFW_teensy", {
|
||||||
|
port: uploadPort,
|
||||||
|
firmwareFile: file,
|
||||||
|
board: uploadBoard
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if(uploadBoard.includes("STM32F407"))
|
||||||
|
{
|
||||||
|
console.log("Uploading using DFU Util")
|
||||||
|
ipcRenderer.send("uploadFW_stm32", {
|
||||||
|
port: uploadPort,
|
||||||
|
firmwareFile: file,
|
||||||
|
board: uploadBoard
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ipcRenderer.send("uploadFW", {
|
||||||
|
port: uploadPort,
|
||||||
|
firmwareFile: file
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function uploadFW()
|
function uploadFW()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -534,10 +598,6 @@ function uploadFW()
|
||||||
spinner.classList.remove('fa-times');
|
spinner.classList.remove('fa-times');
|
||||||
spinner.classList.add('fa-spinner');
|
spinner.classList.add('fa-spinner');
|
||||||
|
|
||||||
//Lookup what platform we're using
|
|
||||||
var portSelect = document.getElementById('portsSelect');
|
|
||||||
var uploadBoard = portSelect.options[portSelect.selectedIndex].getAttribute("board");
|
|
||||||
|
|
||||||
//Hide the terminal section incase it was there from a previous burn attempt
|
//Hide the terminal section incase it was there from a previous burn attempt
|
||||||
document.getElementById('terminalSection').style.display = "none";
|
document.getElementById('terminalSection').style.display = "none";
|
||||||
//Same for the ini location link
|
//Same for the ini location link
|
||||||
|
@ -545,61 +605,23 @@ function uploadFW()
|
||||||
|
|
||||||
var statusText = document.getElementById('statusText');
|
var statusText = document.getElementById('statusText');
|
||||||
var burnPercentText = document.getElementById('burnPercent');
|
var burnPercentText = document.getElementById('burnPercent');
|
||||||
statusText.innerHTML = "Downloading INI file"
|
|
||||||
downloadIni();
|
|
||||||
|
if(useLocalTune)
|
||||||
|
{
|
||||||
|
//ipcRenderer.send("download complete", { file: localTuneFile, state: "complete" });
|
||||||
|
downloadComplete(localTuneFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statusText.innerHTML = "Downloading INI file"
|
||||||
|
downloadIni();
|
||||||
|
}
|
||||||
|
|
||||||
ipcRenderer.on("download complete", (event, file, state) => {
|
ipcRenderer.on("download complete", (event, file, state) => {
|
||||||
console.log("Saved file: " + file); // Full file path
|
console.log("Saved file: " + file); // Full file path
|
||||||
|
downloadComplete(file);
|
||||||
var extension = file.substr(file.length - 3);
|
|
||||||
if(extension == "ini")
|
|
||||||
{
|
|
||||||
statusText.innerHTML = "Downloading firmware"
|
|
||||||
document.getElementById('iniFileText').style.display = "block"
|
|
||||||
document.getElementById('iniFileLocation').innerHTML = file
|
|
||||||
downloadHex(uploadBoard);
|
|
||||||
}
|
|
||||||
else if(extension == "hex" || extension == "bin")
|
|
||||||
{
|
|
||||||
console.log("Uploading da file!!");
|
|
||||||
statusText.innerHTML = "Beginning upload..."
|
|
||||||
|
|
||||||
//Retrieve the select serial port
|
|
||||||
var e = document.getElementById('portsSelect');
|
|
||||||
uploadPort = e.options[e.selectedIndex].value;
|
|
||||||
|
|
||||||
console.log("Using port: " + uploadPort);
|
|
||||||
|
|
||||||
//Show the sponsor banner
|
|
||||||
document.getElementById('sponsorbox').style.display = "block"
|
|
||||||
|
|
||||||
//Begin the upload
|
|
||||||
if(uploadBoard.includes("TEENSY"))
|
|
||||||
{
|
|
||||||
console.log("Uploading using Teensy_loader")
|
|
||||||
ipcRenderer.send("uploadFW_teensy", {
|
|
||||||
port: uploadPort,
|
|
||||||
firmwareFile: file,
|
|
||||||
board: uploadBoard
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if(uploadBoard.includes("STM32F407"))
|
|
||||||
{
|
|
||||||
console.log("Uploading using DFU Util")
|
|
||||||
ipcRenderer.send("uploadFW_stm32", {
|
|
||||||
port: uploadPort,
|
|
||||||
firmwareFile: file,
|
|
||||||
board: uploadBoard
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ipcRenderer.send("uploadFW", {
|
|
||||||
port: uploadPort,
|
|
||||||
firmwareFile: file
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on("upload completed", (event, code) => {
|
ipcRenderer.on("upload completed", (event, code) => {
|
||||||
|
|
Loading…
Reference in New Issue