diff --git a/js/stm32.js b/js/stm32.js index 9e770f5598..c66197b850 100644 --- a/js/stm32.js +++ b/js/stm32.js @@ -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. + + // debug variables + this.serial_bytes_send; + this.serial_bytes_received; }; // string = string .. duh @@ -144,6 +148,9 @@ STM32_protocol.prototype.initialize = function() { self.verify_hex = []; + self.serial_bytes_send = 0; + self.serial_bytes_received = 0; + self.upload_time_start = microtime(); self.steps_executed = 0; @@ -189,6 +196,8 @@ STM32_protocol.prototype.read = function() { for (var i = 0; i < data.length; 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 // callback = function that will be executed after received bytes = bytes_to_read STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) { + var self = this; + var bufferOut = new ArrayBuffer(Array.length); var bufferView = new Uint8Array(bufferOut); @@ -218,7 +229,11 @@ STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) { this.read_callback = callback; // 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 @@ -564,8 +579,8 @@ STM32_protocol.prototype.upload_procedure = function(step) { GUI.interval_remove('firmware_uploader_read'); // stop reading serial 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('Script finished after: ' + self.steps_executed + ' steps'); + console.log('Transfered: ' + self.serial_bytes_send + ' bytes, Received: ' + self.serial_bytes_received + ' bytes'); + console.log('Script finished after: ' + (microtime() - self.upload_time_start).toFixed(4) + ' seconds, ' + self.steps_executed + ' steps'); // close connection chrome.serial.close(connectionId, function(result) {