public class UART
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
protected class |
UART.UARTInputStream
internal class that provides an InputStream interface to
a UART
|
protected class |
UART.UARTOutputStream
internal class that provides an OutputStream interface to
a UART
|
Modifier and Type | Field and Description |
---|---|
protected java.io.InputStream |
inputStream |
protected java.io.OutputStream |
outputStream |
protected UARTPort |
port |
Constructor and Description |
---|
UART(Port port)
Create a UART device attached to the specified port.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.io.InputStream |
getInputStream()
Return the InputStream associated with this device.
|
java.io.OutputStream |
getOutputStream()
Return the OutputStream associated with this device.
|
int |
read(byte[] buffer,
int offset,
int len)
Read bytes from the device.
|
void |
setBitRate(int rate)
Set the bit rate to be used by the UART
|
int |
write(byte[] buffer,
int offset,
int len)
Write bytes to the device.
|
protected UARTPort port
protected java.io.InputStream inputStream
protected java.io.OutputStream outputStream
public UART(Port port)
port
- public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void setBitRate(int rate)
rate
- public int read(byte[] buffer, int offset, int len)
buffer
- buffer to read the bytes intooffset
- first position that bytes will be read intolen
- maximum number of bytes to readpublic int write(byte[] buffer, int offset, int len)
buffer
- buffer to write fromoffset
- offset of first byte to be writtenlen
- number of bytes to try and writepublic java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()