Basic but working upload code
This commit is contained in:
parent
a81eccdbe0
commit
2670022d8d
66
index.html
66
index.html
|
@ -41,76 +41,22 @@
|
|||
<center><img src="assets/speeduino logo_white.png" width="235"/></center>
|
||||
<!--<h1>Firmware Loader</h1>-->
|
||||
<p>Available Firmwares:
|
||||
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20"></select>
|
||||
<ul class="actions">
|
||||
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" onClick="refreshDetailsLink();" ></select>
|
||||
<ul class="actions">
|
||||
<li><input type='button' value="View Firmware Details" onclick="downloadFW();" /></li>
|
||||
<li><input type='button' value="Download" onclick="downloadFW();" /></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</p>
|
||||
<div id="error"></div>
|
||||
<div id="ports"></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
var request = require('request');
|
||||
request.get('http://speeduino.com/fw/versions', function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
|
||||
var lines = body.split('\n');
|
||||
// Continue with your processing here.
|
||||
select = document.getElementById('versionsSelect');
|
||||
for(var i = 0;i < lines.length;i++)
|
||||
{
|
||||
var newOption = document.createElement('option');
|
||||
newOption.value = lines[i];
|
||||
newOption.innerHTML = lines[i];
|
||||
select.appendChild(newOption);
|
||||
}
|
||||
select.selectedIndex = 0;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</section>
|
||||
|
||||
<!-- Firmware details -->
|
||||
<section id="details" class="wrapper style1-alt spotlights">
|
||||
<section>
|
||||
<a href="#" class="image"><img src="images/pic01.jpg" alt="" data-position="center center" /></a>
|
||||
<div class="content">
|
||||
<div class="inner">
|
||||
<h2>Sed ipsum dolor</h2>
|
||||
<p>Phasellus convallis elit id ullamcorper pulvinar. Duis aliquam turpis mauris, eu ultricies erat malesuada quis. Aliquam dapibus.</p>
|
||||
<ul class="actions">
|
||||
<li><a href="#" class="button">Learn more</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<a href="#" class="image"><img src="images/pic02.jpg" alt="" data-position="top center" /></a>
|
||||
<div class="content">
|
||||
<div class="inner">
|
||||
<h2>Feugiat consequat</h2>
|
||||
<p>Phasellus convallis elit id ullamcorper pulvinar. Duis aliquam turpis mauris, eu ultricies erat malesuada quis. Aliquam dapibus.</p>
|
||||
<ul class="actions">
|
||||
<li><a href="#" class="button">Learn more</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<a href="#" class="image"><img src="images/pic03.jpg" alt="" data-position="25% 25%" /></a>
|
||||
<div class="content">
|
||||
<div class="inner">
|
||||
<h2>Ultricies aliquam</h2>
|
||||
<p>Phasellus convallis elit id ullamcorper pulvinar. Duis aliquam turpis mauris, eu ultricies erat malesuada quis. Aliquam dapibus.</p>
|
||||
<ul class="actions">
|
||||
<li><a href="#" class="button">Learn more</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<iframe id="detailsFrame"> </iframe>
|
||||
</section>
|
||||
|
||||
<!-- Choose Port -->
|
||||
|
@ -121,7 +67,7 @@
|
|||
<select name="ports" class="select" id="portsSelect" size="10" width="20"></select>
|
||||
<ul class="actions">
|
||||
<li><input type='button' value="Refresh" onclick="refreshSerialPorts();" /></li>
|
||||
<li><input type='button' value="Install" onclick="downloadFW();" /></li>
|
||||
<li><input type='button' value="Install" onclick="uploadFW();" /></li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
|
|
45
main.js
45
main.js
|
@ -1,6 +1,7 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const {download} = require('electron-dl')
|
||||
const exec = require('child_process').exec;
|
||||
const {spawn} = require('child_process');
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -53,5 +54,49 @@ ipcMain.on('download', (e, args) => {
|
|||
.catch(console.error);
|
||||
});
|
||||
|
||||
ipcMain.on('uploadFW', (e, args) => {
|
||||
var platform;
|
||||
|
||||
if(platform.os == "win32") { platform = "avrdude-win32-x86"; }
|
||||
else if(platform.os == "darwin") { platform = "avrdude-darwin-x86"; }
|
||||
else if(platform.os == "linux") { platform = "avrdude-darwin-x86"; }
|
||||
|
||||
var executableName = "./bin/" + platform + "/avrdude";
|
||||
var configName = executableName + ".conf";
|
||||
var hexFile = 'flash:w:' + args.firmwareFile + ':i';
|
||||
|
||||
var execArgs = ['-v', '-patmega2560', '-C', configName, '-cwiring', '-b 115200', '-P', args.port, '-D', '-U', hexFile];
|
||||
|
||||
/*
|
||||
exec("./bin/avrdude-darwin-x86/avrdude -v -p atmega2560 -C ./bin/avrdude-darwin-x86/avrdude.conf -c wiring -b 115200 -P /dev/cu.usbmodem14201 -D -U flash:w:/Users/josh/Downloads/201810.hex:i", (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(`exec error: ${err}`);
|
||||
return;
|
||||
}
|
||||
console.log(`Upload Output: ${stdout}`);
|
||||
});
|
||||
*/
|
||||
|
||||
const child = spawn(executableName, execArgs);
|
||||
|
||||
child.stdout.on('data', (data) => {
|
||||
console.log(`child stdout:\n${data}`);
|
||||
});
|
||||
|
||||
child.stderr.on('data', (data) => {
|
||||
console.log(`avrdude stderr: ${data}`);
|
||||
});
|
||||
|
||||
child.on('error', (err) => {
|
||||
console.log('Failed to start subprocess.');
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
if (code !== 0) {
|
||||
console.log(`grep process exited with code ${code}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
44
renderer.js
44
renderer.js
|
@ -1,5 +1,5 @@
|
|||
const serialport = require('serialport')
|
||||
const ipcRenderer = require("electron")
|
||||
const {ipcRenderer} = require("electron")
|
||||
|
||||
function refreshSerialPorts()
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ function refreshSerialPorts()
|
|||
}
|
||||
|
||||
//Load the current serial values
|
||||
for(var i = 0;i < ports.length;i++)
|
||||
for(var i = 0; i < ports.length; i++)
|
||||
{
|
||||
var newOption = document.createElement('option');
|
||||
newOption.value = ports[i].comName;
|
||||
|
@ -36,6 +36,36 @@ function refreshSerialPorts()
|
|||
})
|
||||
}
|
||||
|
||||
function refreshDetailsLink()
|
||||
{
|
||||
var selectElement = document.getElementById('versionsSelect');
|
||||
var url = "https://github.com/noisymime/speeduino/releases/tag/" + selectElement.options[selectElement.selectedIndex].value
|
||||
|
||||
var frameElement = document.getElementById('detailsFrame');
|
||||
frameElement.setAttribute("src", url);
|
||||
}
|
||||
|
||||
function refreshAvailableFirmwares()
|
||||
{
|
||||
var request = require('request');
|
||||
request.get('http://speeduino.com/fw/versions', function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
|
||||
var lines = body.split('\n');
|
||||
// Continue with your processing here.
|
||||
select = document.getElementById('versionsSelect');
|
||||
for(var i = 0;i < lines.length;i++)
|
||||
{
|
||||
var newOption = document.createElement('option');
|
||||
newOption.value = lines[i];
|
||||
newOption.innerHTML = lines[i];
|
||||
select.appendChild(newOption);
|
||||
}
|
||||
select.selectedIndex = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function downloadFW()
|
||||
{
|
||||
var e = document.getElementById('versionsSelect');
|
||||
|
@ -56,9 +86,15 @@ function downloadFW()
|
|||
});
|
||||
}
|
||||
|
||||
function uploadtoBoard()
|
||||
function uploadFW()
|
||||
{
|
||||
"avrdude -v -p atmega2560 -C ./bin/avrdude-darwin-x86/avrdude.conf -c wiring -b 115200 -P /dev/cu.usbmodem14201 -D -U flash:w:/Users/josh/Downloads/201810.hex:i"
|
||||
//"avrdude -v -p atmega2560 -C ./bin/avrdude-darwin-x86/avrdude.conf -c wiring -b 115200 -P /dev/cu.usbmodem14201 -D -U flash:w:/Users/josh/Downloads/201810.hex:i"
|
||||
//Download the Hex file
|
||||
ipcRenderer.send("uploadFW", {
|
||||
port: "/dev/cu.usbmodem14201",
|
||||
firmwareFile: "/Users/josh/Downloads/201810.hex"
|
||||
});
|
||||
}
|
||||
|
||||
refreshSerialPorts();
|
||||
refreshAvailableFirmwares();
|
||||
|
|
Loading…
Reference in New Issue