Send 'serial0-output-line' messages if necessary
This commit is contained in:
parent
c553ee846f
commit
4fad44504d
|
@ -22,7 +22,7 @@ function SerialAdapter(element, bus)
|
|||
this.destroy();
|
||||
this.bus = bus;
|
||||
|
||||
bus.register("serial0-output", function(chr)
|
||||
bus.register("serial0-output-char", function(chr)
|
||||
{
|
||||
this.show_char(chr);
|
||||
}, this);
|
||||
|
|
17
src/uart.js
17
src/uart.js
|
@ -55,6 +55,8 @@ function UART(cpu, port, bus)
|
|||
|
||||
this.input = new ByteQueue(4096);
|
||||
|
||||
this.current_line = "";
|
||||
|
||||
if(port === 0x3E8 || port === 0x3F8)
|
||||
{
|
||||
this.irq = 4;
|
||||
|
@ -96,7 +98,20 @@ function UART(cpu, port, bus)
|
|||
return;
|
||||
}
|
||||
|
||||
this.bus.send("serial0-output", String.fromCharCode(out_byte));
|
||||
var char = String.fromCharCode(out_byte);
|
||||
|
||||
this.bus.send("serial0-output-char", char);
|
||||
|
||||
if(this.bus.should_send("serial0-output-line"))
|
||||
{
|
||||
this.current_line += char;
|
||||
|
||||
if(char === "\n")
|
||||
{
|
||||
this.bus.send("serial0-output-line", this.current_line);
|
||||
this.current_line = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
io.register_write(port | 1, this, function(out_byte)
|
||||
|
|
Loading…
Reference in a new issue