Working firmware details retrieve

This commit is contained in:
Josh Stewart 2019-01-02 14:47:18 +11:00
parent f1f6d7572c
commit cfcc1a3406
5 changed files with 46 additions and 49 deletions

View File

@ -41,10 +41,10 @@
<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" onClick="refreshDetailsLink();" ></select>
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" ></select>
<ul class="actions">
<li><input type='button' value="View Firmware Details" onclick="downloadFW();" /></li>
<li><input type='button' value="Download" onclick="downloadFW();" /></li>
<li><input type='button' value="View Firmware Notes" onclick="refreshDetails();" /></li>
<li><input type='button' value="Choose Port" onclick="downloadFW();" /></li>
</ul>
</p>
<div id="error"></div>
@ -57,9 +57,8 @@
<!-- Firmware details -->
<section id="details" class="wrapper style1-alt spotlights">
<div class="inner">
<h1>Firmware Details</h1>
<h2>Work In Progress</h2>
<iframe id="detailsFrame"> </iframe>
<h1>Firmware Notes</h1>
<div id="detailsText"></div>
</div>
</section>
@ -83,42 +82,12 @@
<section id="progress" class="wrapper style3 fade-up">
<div class="inner">
<h2>Progress</h2>
<p>Phasellus convallis elit id ullamcorper pulvinar. Duis aliquam turpis mauris, eu ultricies erat malesuada quis. Aliquam dapibus, lacus eget hendrerit bibendum, urna est aliquam sem, sit amet imperdiet est velit quis lorem.</p>
<div class="features">
<section>
<span class="icon major fa-code"></span>
<h3>Lorem ipsum amet</h3>
<p>Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.</p>
<span class="icon major fa-spinner"></span>
<h3>Current Action:</h3>
<p><div id="statusText"></div></p>
</section>
<section>
<span class="icon major fa-lock"></span>
<h3>Aliquam sed nullam</h3>
<p>Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.</p>
</section>
<section>
<span class="icon major fa-cog"></span>
<h3>Sed erat ullam corper</h3>
<p>Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.</p>
</section>
<section>
<span class="icon major fa-desktop"></span>
<h3>Veroeros quis lorem</h3>
<p>Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.</p>
</section>
<section>
<span class="icon major fa-chain"></span>
<h3>Urna quis bibendum</h3>
<p>Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.</p>
</section>
<section>
<span class="icon major fa-diamond"></span>
<h3>Aliquam urna dapibus</h3>
<p>Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.</p>
</section>
</div>
<ul class="actions">
<li><a href="#" class="button">Learn more</a></li>
</ul>
</div>
</section>

View File

@ -57,18 +57,17 @@ ipcMain.on('download', (e, args) => {
ipcMain.on('uploadFW', (e, args) => {
var platform;
if(args.os == "win32") { platform = "avrdude-windows"; }
else if(args.os == "darwin") { platform = "avrdude-darwin-x86"; }
else if(args.os == "linux") { platform = "avrdude-linux_i686"; }
if(process.platform == "win32") { platform = "avrdude-windows"; }
else if(process.platform == "darwin") { platform = "avrdude-darwin-x86"; }
else if(process.platform == "linux") { platform = "avrdude-linux_i686"; }
var executableName = "./bin/" + platform + "/avrdude";
var configName = executableName + ".conf";
if(args.os == "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
var hexFile = 'flash:w:' + args.firmwareFile + ':i';
var execArgs = ['-v', '-patmega2560', '-C', configName, '-cwiring', '-b 115200', '-P', args.port, '-D', '-U', hexFile];
console.log(process.platform);
/*
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) => {

5
package-lock.json generated
View File

@ -1507,6 +1507,11 @@
"integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=",
"dev": true
},
"marked": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.6.0.tgz",
"integrity": "sha512-HduzIW2xApSXKXJSpCipSxKyvMbwRRa/TwMbepmlZziKdH8548WSoDP4SxzulEKjlo8BE39l+2fwJZuRKOln6g=="
},
"meow": {
"version": "3.7.0",
"resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz",

View File

@ -28,6 +28,7 @@
},
"dependencies": {
"electron-dl": "^1.12.0",
"marked": "^0.6.0",
"request": "^2.88.0",
"serialport": "^7.1.1"
}

View File

@ -36,13 +36,34 @@ function refreshSerialPorts()
})
}
function refreshDetailsLink()
function refreshDetails()
{
var selectElement = document.getElementById('versionsSelect');
var url = "https://github.com/noisymime/speeduino/releases/tag/" + selectElement.options[selectElement.selectedIndex].value
var url = "https://api.github.com/repos/noisymime/speeduino/releases/tags/" + selectElement.options[selectElement.selectedIndex].value;
var frameElement = document.getElementById('detailsFrame');
frameElement.setAttribute("src", url);
var request = require('request');
const options = {
url: url,
headers: {
'User-Agent': 'request'
}
};
request.get(options, function (error, response, body) {
if (!error ) {
console.log(body);
var result = JSON.parse(body);
// Continue with your processing here.
textField = document.getElementById('detailsText');
//Need to convert the Markdown that comes from Github to HTML
var myMarked = require('marked');
textField.innerHTML = myMarked(result.body);
}
});
}
function refreshAvailableFirmwares()
@ -88,7 +109,9 @@ function downloadFW()
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"
var statusText = document.getElementById('statusText');
statusText.innerHTML = "Beginning Download"
//Download the Hex file
ipcRenderer.send("uploadFW", {
port: "/dev/cu.usbmodem14201",