nachos.machine
Interface SerialConsole

All Known Implementing Classes:
StandardConsole

public interface SerialConsole

A serial console can be used to send and receive characters. Only one character may be sent at a time, and only one character may be received at a time.


Method Summary
 int readByte()
          Return the next unsigned byte received (in the range 0 through 255).
 void setInterruptHandlers(Runnable receiveInterruptHandler, Runnable sendInterruptHandler)
          Set this console's receive and send interrupt handlers.
 void writeByte(int value)
          Send another byte.
 

Method Detail

setInterruptHandlers

void setInterruptHandlers(Runnable receiveInterruptHandler,
                          Runnable sendInterruptHandler)
Set this console's receive and send interrupt handlers.

The receive interrupt handler is called every time another byte arrives and can be read using readByte().

The send interrupt handler is called every time a byte sent with writeByte() is finished being sent. This means that another byte can be sent.

Parameters:
receiveInterruptHandler - the callback to call when a byte arrives.
sendInterruptHandler - the callback to call when another byte can be sent.

readByte

int readByte()
Return the next unsigned byte received (in the range 0 through 255).

Returns:
the next byte read, or -1 if no byte is available.

writeByte

void writeByte(int value)
Send another byte. If a byte is already being sent, the result is not defined.

Parameters:
value - the byte to be sent (the upper 24 bits are ignored).