Browse Source

Don't print control characters in terminal

Fabian 3 years ago
parent
commit
fe6872d55b
2 changed files with 3 additions and 2 deletions
  1. 2 1
      src/uart.js
  2. 1 1
      tests/qemu/run.js

+ 2 - 1
src/uart.js

@@ -323,7 +323,8 @@ UART.prototype.write_data = function(out_byte)
 
     if(char === "\n")
     {
-        dbg_log("SERIAL: " + String.fromCharCode.apply("", this.current_line).trimRight());
+        const line = String.fromCharCode.apply("", this.current_line).trimRight().replace(/[\x00-\x08\x0b-\x1f\x7f\x80-\xff]/g, "");
+        dbg_log("SERIAL: " + line);
         this.bus.send("serial0-output-line", String.fromCharCode.apply("", this.current_line));
         this.current_line = [];
     }

+ 1 - 1
tests/qemu/run.js

@@ -42,7 +42,7 @@ emulator.add_listener("serial0-output-char", function(chr)
         console.error("Serial: %s", line);
         line = "";
     }
-    else
+    else if(chr >= " " && chr <= "~")
     {
         line += chr;
     }