Просмотр исходного кода

Errors and restores UI if port is already open. Fixes #12

Andrew Chalkley 9 лет назад
Родитель
Сommit
1a95261cf1
2 измененных файлов с 8 добавлено и 2 удалено
  1. 1 1
      back-end/rom_comm.js
  2. 7 1
      front-end/js/app.js

+ 1 - 1
back-end/rom_comm.js

@@ -83,7 +83,7 @@ class RomComm extends EventEmitter {
     }
 
     bindPort() {
-        this._port.on('error', error => log.error("PORT ERROR", error));
+        this._port.on('error', (error) => log.error("PORT ERROR", error));
         this.in = new slip.SlipDecoder();
         this.out = new slip.SlipEncoder();
         this._port.pipe(this.in);

+ 7 - 1
front-end/js/app.js

@@ -202,16 +202,22 @@ function flashWithManifest(manifest) {
                     log.info("Flashed to latest Espruino build!", result);
                 });
         }).catch((error) => {
+            esp.close();
             new Notification("An error occured during flashing.");
             isFlashing = false;
             log.error("Oh noes!", error);
+            restoreUI();
         });
-    }).on("entry", (progress) => {
+    })
+    .on("error", onError)
+    .on("entry", (progress) => {
         //For the download/extract progress. The other half is flashing.
         const extractPercent = Math.round((correctStepNumber++/numberOfSteps) * 50);
         updateProgressBar(extractPercent, svg);
         appStatus.textContent = progress.display;
     });
+    
+    
 }
 
 function cloneSVGNode(node) {