diff --git a/src/browser/serial.js b/src/browser/serial.js index 0f049b5b..f0371b91 100644 --- a/src/browser/serial.js +++ b/src/browser/serial.js @@ -234,16 +234,17 @@ export function SerialAdapterXtermJS(element, bus) }); term.write("This is the serial console. Whatever you type or paste here will be sent to COM1"); - const on_data_disposable = term["onData"](function(data) { - for(let i = 0; i < data.length; i++) + const utf8_encoder = new TextEncoder(); + const on_data_disposable = term["onData"](function(data_str) { + for(const utf8_byte of utf8_encoder.encode(data_str)) { - bus.send("serial0-input", data.charCodeAt(i)); + bus.send("serial0-input", utf8_byte); } }); - bus.register("serial0-output-byte", function(byte) + bus.register("serial0-output-byte", function(utf8_byte) { - term.write(Uint8Array.of(byte)); + term.write(Uint8Array.of(utf8_byte)); }, this); this.destroy = function() { diff --git a/src/browser/starter.js b/src/browser/starter.js index 8aec8fad..87b66859 100644 --- a/src/browser/starter.js +++ b/src/browser/starter.js @@ -289,16 +289,15 @@ V86.prototype.continue_init = async function(emulator, options) settings.screen = this.screen_adapter; settings.screen_options = screen_options; - if(options.serial_container) - { - this.serial_adapter = new SerialAdapter(options.serial_container, this.bus); - //this.recording_adapter = new SerialRecordingAdapter(this.bus); - } - if(options.serial_container_xtermjs) { this.serial_adapter = new SerialAdapterXtermJS(options.serial_container_xtermjs, this.bus); } + else if(options.serial_container) + { + this.serial_adapter = new SerialAdapter(options.serial_container, this.bus); + //this.recording_adapter = new SerialRecordingAdapter(this.bus); + } if(!options.disable_speaker) {