Ver Fonte

Merge branch 'progress' of github.com:thingsSDK/flasher.js into progress

Andrew Chalkley há 9 anos atrás
pai
commit
82c84c2700
1 ficheiros alterados com 4 adições e 3 exclusões
  1. 4 3
      back-end/rom_comm.js

+ 4 - 3
back-end/rom_comm.js

@@ -323,8 +323,7 @@ class RomComm extends EventEmitter {
             details.currentIndex = index;
             details.currentAddress = spec.address;
             details.currentSize = spec.buffer.length;
-            return this.flashAddress(Number.parseInt(spec.address), spec.buffer)
-                .then(() => details.flashedBytes += details.currentSize);
+            return this.flashAddress(Number.parseInt(spec.address), spec.buffer);
         });
         return promiseChain(promiseFunctions);
     }
@@ -361,7 +360,8 @@ class RomComm extends EventEmitter {
                         requests.push(Buffer.concat([new Buffer(buffer), block]));
                     }
                     let promiseFunctions = requests.map((req, index) => () => {
-                        this.reportBlockProgress(req.length, index, requests.length);
+                        // 16 is the header
+                        this.reportBlockProgress(req.length - 16, index, requests.length);
                         return this.sendCommand(commands.FLASH_DOWNLOAD_DATA, req);
                     });
                     return promiseChain(promiseFunctions);
@@ -370,6 +370,7 @@ class RomComm extends EventEmitter {
     }
 
     reportBlockProgress(length, index, total) {
+        this.state.details.flashedBytes += length;
         this.state.details.blockSize = length;
         this.state.details.blockIndex = index;
         this.state.details.totalBlocks = total;