adding more debug functionality

10.3.x-maintenance
cTn 2013-12-06 19:02:31 +01:00
parent a81cdb6d9d
commit 89f6b1bf71
1 changed files with 18 additions and 3 deletions

View File

@ -40,6 +40,10 @@ var STM32_protocol = function() {
}; };
// Erase (x043) and Extended Erase (0x44) are exclusive. A device may support either the Erase command or the Extended Erase command but not both. // Erase (x043) and Extended Erase (0x44) are exclusive. A device may support either the Erase command or the Extended Erase command but not both.
// debug variables
this.serial_bytes_send;
this.serial_bytes_received;
}; };
// string = string .. duh // string = string .. duh
@ -144,6 +148,9 @@ STM32_protocol.prototype.initialize = function() {
self.verify_hex = []; self.verify_hex = [];
self.serial_bytes_send = 0;
self.serial_bytes_received = 0;
self.upload_time_start = microtime(); self.upload_time_start = microtime();
self.steps_executed = 0; self.steps_executed = 0;
@ -189,6 +196,8 @@ STM32_protocol.prototype.read = function() {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
self.receive_buffer.push(data[i]); self.receive_buffer.push(data[i]);
} }
self.serial_bytes_received += data.length;
} }
}); });
@ -207,6 +216,8 @@ STM32_protocol.prototype.read = function() {
// bytes_to_read = received bytes necessary to trigger read_callback // bytes_to_read = received bytes necessary to trigger read_callback
// callback = function that will be executed after received bytes = bytes_to_read // callback = function that will be executed after received bytes = bytes_to_read
STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) { STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) {
var self = this;
var bufferOut = new ArrayBuffer(Array.length); var bufferOut = new ArrayBuffer(Array.length);
var bufferView = new Uint8Array(bufferOut); var bufferView = new Uint8Array(bufferOut);
@ -218,7 +229,11 @@ STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) {
this.read_callback = callback; this.read_callback = callback;
// send over the actual data // send over the actual data
chrome.serial.write(connectionId, bufferOut, function(writeInfo) {}); chrome.serial.write(connectionId, bufferOut, function(writeInfo) {
if (writeInfo.bytesWritten > 0) {
self.serial_bytes_send += writeInfo.bytesWritten;
}
});
}; };
// val = single byte to be verified // val = single byte to be verified
@ -564,8 +579,8 @@ STM32_protocol.prototype.upload_procedure = function(step) {
GUI.interval_remove('firmware_uploader_read'); // stop reading serial GUI.interval_remove('firmware_uploader_read'); // stop reading serial
GUI.interval_remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now) GUI.interval_remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now)
console.log('Script finished after: ' + (microtime() - self.upload_time_start).toFixed(4) + ' seconds'); console.log('Transfered: ' + self.serial_bytes_send + ' bytes, Received: ' + self.serial_bytes_received + ' bytes');
console.log('Script finished after: ' + self.steps_executed + ' steps'); console.log('Script finished after: ' + (microtime() - self.upload_time_start).toFixed(4) + ' seconds, ' + self.steps_executed + ' steps');
// close connection // close connection
chrome.serial.close(connectionId, function(result) { chrome.serial.close(connectionId, function(result) {