Skip to content

Commit

Permalink
more troubleshooting, still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
raleighlittles committed Mar 3, 2024
1 parent 7a104b8 commit 1b0d11c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ <h2> Step #2 </h2>
</div>

<!-- to be able to change the progress bar later, the id needs to be on the INNER element, not the outer -->
<div class="progress mt-4 mb-4" role="progressbar" aria-label="Example with label"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<div class="progress mt-4 mb-4" role="progressbar" aria-label="Example with label" aria-valuenow="0"
aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar" id="programmingProgressBar" style="width: 0%"></div>
</div>

Expand Down Expand Up @@ -81,18 +81,18 @@ <h3> Debug Log </h3>
debugLogElement.innerText += newLogEntry;

}


function updateProgressBar(value_num, value_denom) {

let progressBarElement = document.getElementById("programmingProgressBar");

let newPercentage = `${Math.round( (value_num / value_denom) * 100, 2)}%`;
let newPercentage = `${Math.round((value_num / value_denom) * 100, 2)}%`;

progressBarElement.style.width = newPercentage;
}


async function uploadFirmwareToDevice(usbDevice, firmwareFileAsBytes) {

const uint16Max = 65536;
Expand All @@ -103,7 +103,7 @@ <h3> Debug Log </h3>
const firmwareFileLen = firmwareFileAsBytes.byteLength;

let fileByteIdx = 0;

let wValue = 0;

let lowerTransactionIdx = 0x14; // 20d
Expand All @@ -127,7 +127,7 @@ <h3> Debug Log </h3>

console.log(transactionData);

await usbDevice.controlTransferOut({requestType: "standard", recipient: "device", request: 0x0, value: wValue, index: currTransactionIdx}, transactionData);
await usbDevice.controlTransferOut({ requestType: "standard", recipient: "device", request: 0x0, value: wValue, index: currTransactionIdx }, transactionData);

//console.log("Transferred", pktSize, "bytes. Value=", wValue, "index=", currTransactionIdx);

Expand All @@ -137,7 +137,7 @@ <h3> Debug Log </h3>
if (wValue > uint16Max - pktSize) {
// Can't perform the addition because it would overflow
// How much would it overflow by? That's the new value
wValue = ( wValue - (uint16Max - pktSize) );
wValue = (wValue - (uint16Max - pktSize));
} else {
// Regular case, no overflow
wValue += pktSize;
Expand All @@ -151,7 +151,7 @@ <h3> Debug Log </h3>
// now send footer packet

let footerData = Array([0x5B]).buffer;
await usbDevice.controlTransferOut({requestType: "standard", recipient: "device", request: 0x0, value: 0x2200, index: 0x8018}, footerData);
await usbDevice.controlTransferOut({ requestType: "standard", recipient: "device", request: 0x0, value: 0x2200, index: 0x8018 }, footerData);

} // end function

Expand Down Expand Up @@ -190,6 +190,8 @@ <h3> Debug Log </h3>

var fileByteArray = [];

reader.readAsArrayBuffer(this.files[0]);

reader.onloadend = function (evt) {

if (evt.target.readyState = FileReader.DONE) {
Expand All @@ -198,7 +200,7 @@ <h3> Debug Log </h3>

var array = new Uint8Array(arrayBuffer);

for (var i = 0 ; i < array.length; i++) {
for (var i = 0; i < array.length; i++) {
fileByteArray.push(array[i]);
}

Expand All @@ -208,18 +210,16 @@ <h3> Debug Log </h3>
//debugLogElement.innerText += msg;
updateDebugLog(msg);

console.log("array", array);
console.log("array", array.buffer);

console.log("fileByteArray", fileByteArray);
//console.log("fileByteArray", fileByteArray);

uploadFirmwareToDevice(usbDevice, fileByteArray).then(() => console.log("finished uploading firmware!"));
}
}

reader.readAsArrayBuffer(this.files[0]);

}); // end change file event listener
</script>
</body>

</html>
</html>

0 comments on commit 1b0d11c

Please sign in to comment.