|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--stamp.core.VirtualPeripheral | +--stamp.core.Uart
A virtual peripheral UART. Each instance of this class provides
asynchronous serial communication in a single direction. For full-duplex
communications create two Uart
objects, one for each direction.
The Uart class uses 256 byte buffers for both transmit and receive. The buffer size is not configurable. If a handshaking pin is specified for a receive Uart then the peer will be signalled to stop transmitting when there are 16 bytes still free in the buffer.
Field Summary | |
static int |
dirReceive
The value to be using in the direction parameter to create a receiver. |
static int |
dirTransmit
The value to be using in the direction parameter to create a transmitter. |
static boolean |
dontInvert
The value for dataInvert and hsInvert to indicate that inverted logic should not be used. |
static boolean |
invert
The value for dataInvert and hsInvert to indicate that inverted logic should be used. |
static int |
speed1200
The speed value for 1200 baud. |
static int |
speed14400
The speed value for 14400 baud. |
static int |
speed19200
The speed value for 19200 baud. |
static int |
speed2400
The speed value for 2400 baud. |
static int |
speed28800
The speed value for 28800 baud. |
static int |
speed38400
The speed value for 38400 baud. |
static int |
speed4800
The speed value for 4800 baud. |
static int |
speed57600
The speed value for 57600 baud. |
static int |
speed600
The speed value for 600 baud. |
static int |
speed7200
The speed value for 7200 baud. |
static int |
speed9600
The speed value for 9600 baud. |
static int |
stop1
Value to generate 1 stop bit. |
static int |
stop2
Value to generate 2 stop bits. |
static int |
stop3
Value to generate 3 stop bits. |
static int |
stop4
Value to generate 4 stop bits. |
static int |
stop5
Value to generate 5 stop bits. |
static int |
stop6
Value to generate 6 stop bits. |
static int |
stop7
Value to generate 7 stop bits. |
static int |
stop8
Value to generate 8 stop bits. |
Constructor Summary | |
Uart(int direction,
int dataPin,
boolean dataInvert,
int hsPin,
boolean hsInvert,
int baudRate,
int stopBits)
Creates and initialises a new Uart for simplex communication using hardware (RTS/CTS) handshaking. |
|
Uart(int direction,
int dataPin,
boolean dataInvert,
int baudRate,
int stopBits)
Creates and initialises a new Uart for simplex communication using no handshaking. |
|
Uart(int direction,
int dataPin,
boolean dataInvert,
int hsPin,
int baudRate,
int stopBits)
Creates and initialises a new Uart for simplex communication using hardware (RTS/CTS) handshaking. |
Method Summary | |
boolean |
byteAvailable()
Test whether any bytes are available in the receive buffer. |
int |
receiveByte()
Receives a byte from a receive Uart. |
void |
restart(int direction,
int dataPin,
boolean dataInvert,
int hsPin,
boolean hsInvert,
int baudRate,
int stopBits)
Reinitialises a Uart for simplex communication using hardware (RTS/CTS) handshaking. |
void |
restart(int direction,
int dataPin,
boolean dataInvert,
int baudRate,
int stopBits)
Reinitialises the Uart for simplex communication using no handshaking. |
void |
restart(int direction,
int dataPin,
boolean dataInvert,
int hsPin,
int baudRate,
int stopBits)
Reinitialises the Uart for simplex communication using hardware (RTS/CTS) handshaking. |
boolean |
sendBufferEmpty()
Check space in the transmit buffer. |
boolean |
sendBufferFull()
Check for space in the transmit buffer. |
void |
sendByte(int data)
Adds a byte to the transmit buffer. |
void |
sendString(String data)
Transmits a String. |
void |
setDirection(int direction)
Change transmission direction. |
void |
start()
Starts the Uart running. |
void |
stop()
Stops the Uart. |
Methods inherited from class java.lang.Object |
equals |
Field Detail |
public static final int dirReceive
public static final int dirTransmit
public static final int speed600
public static final int speed1200
public static final int speed2400
public static final int speed4800
public static final int speed7200
public static final int speed9600
public static final int speed14400
public static final int speed19200
public static final int speed28800
public static final int speed38400
public static final int speed57600
public static final boolean invert
public static final boolean dontInvert
public static final int stop1
public static final int stop2
public static final int stop3
public static final int stop4
public static final int stop5
public static final int stop6
public static final int stop7
public static final int stop8
Constructor Detail |
public Uart(int direction, int dataPin, boolean dataInvert, int baudRate, int stopBits)
start()
method so the Uart will begin working immediately.direction
- whether the Uart is to be used transmit or receive mode. Valid
options are Uart.dirTransmit
and
Uart.dirReceive
.dataPin
- the Javelin Stamp I/O pin to use for sending or receiving data.dataInvert
- whether the data should be inverted or not. Valid options are
Uart.invert
and Uart.dontInvert
.baudRate
- the baud rate to use.stopBits
- the number of stop bits to use. Valid values are between
Uart.stop1
and Uart.stop8
.public Uart(int direction, int dataPin, boolean dataInvert, int hsPin, int baudRate, int stopBits)
start()
method so the Uart will begin working immediately.direction
- whether the Uart is to be used transmit or receive mode. Valid
options are Uart.dirTransmit
and
Uart.dirReceive
.dataPin
- the Javelin Stamp I/O pin to use for sending or receiving data.dataInvert
- whether the data should be inverted or not. Valid options are
Uart.invert
and Uart.dontInvert
.hsPin
- the pin to use for hardware handshaking.baudRate
- the baud rate to use.stopBits
- the number of stop bits to use. Valid values are between
Uart.stop1
and Uart.stop8
.public Uart(int direction, int dataPin, boolean dataInvert, int hsPin, boolean hsInvert, int baudRate, int stopBits)
start()
method so the Uart will begin working immediately.direction
- whether the Uart is to be used transmit or receive mode. Valid
options are Uart.dirTransmit
and
Uart.dirReceive
.dataPin
- the Javelin Stamp I/O pin to use for sending or receiving data.dataInvert
- whether the data should be inverted or not. Valid options are
Uart.invert
and Uart.dontInvert
.hsPin
- the pin to use for hardware handshaking.hsInvert
- whether the logic of the handshaking pin should be inverted or
not.baudRate
- the baud rate to use.stopBits
- the number of stop bits to use. Valid values are between
Uart.stop1
and Uart.stop8
.Method Detail |
public void start()
stop()
then
start()
will start it again with the same set of parameters.public void stop()
public void setDirection(int direction)
direction
- new directionpublic void restart(int direction, int dataPin, boolean dataInvert, int baudRate, int stopBits)
direction
- whether the Uart is to be used transmit or receive mode. Valid
options are Uart.dirTransmit
and
Uart.dirReceive
.dataPin
- the Javelin Stamp I/O pin to use for sending or receiving data.dataInvert
- whether the data should be inverted or not. Valid options are
Uart.invert
and Uart.dontInvert
.baudRate
- the baud rate to use.stopBits
- the number of stop bits to use. Valid values are between
Uart.stop1
and Uart.stop8
.public void restart(int direction, int dataPin, boolean dataInvert, int hsPin, int baudRate, int stopBits)
direction
- whether the Uart is to be used transmit or receive mode. Valid
options are Uart.dirTransmit
and
Uart.dirReceive
.dataPin
- the Javelin Stamp I/O pin to use for sending or receiving data.dataInvert
- whether the data should be inverted or not. Valid options are
Uart.invert
and Uart.dontInvert
.hsPin
- the pin to use for hardware handshaking.baudRate
- the baud rate to use.stopBits
- the number of stop bits to use. Valid values are between
Uart.stop1
and Uart.stop8
.public void restart(int direction, int dataPin, boolean dataInvert, int hsPin, boolean hsInvert, int baudRate, int stopBits)
direction
- whether the Uart is to be used transmit or receive mode. Valid
options are Uart.dirTransmit
and
Uart.dirReceive
.dataPin
- the Javelin Stamp I/O pin to use for sending or receiving data.dataInvert
- whether the data should be inverted or not. Valid options are
Uart.invert
and Uart.dontInvert
.hsPin
- the pin to use for hardware handshakinghsInvert
- whether the logic of the handshaking pin should be inverted or
not.baudRate
- the baud rate to use.stopBits
- the number of stop bits to use. Valid values are between
Uart.stop1
and Uart.stop8
.public boolean sendBufferFull()
public boolean sendBufferEmpty()
public void sendByte(int data)
sendByte()
will block until there is room in the buffer.data
- the data to transmit. Only the low 8 bits of the parameter
are used.public void sendString(String data)
data
- the string to transmit.public int receiveByte()
public boolean byteAvailable()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |