|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.wpi.first.wpilibj.SerialPort
public class SerialPort
Driver for the RS-232 serial port on the cRIO. The current implementation uses the VISA formatted I/O mode. This means that all traffic goes through the formatted buffers. This allows the intermingled use of print(), readString(), and the raw buffer accessors read() and write(). More information can be found in the NI-VISA User Manual here: http://www.ni.com/pdf/manuals/370423a.pdf and the NI-VISA Programmer's Reference Manual here: http://www.ni.com/pdf/manuals/370132c.pdf
Nested Class Summary | |
---|---|
static class |
SerialPort.FlowControl
Represents what type of flow control to use for serial communication |
static class |
SerialPort.Parity
Represents the parity to use for serial communications |
static class |
SerialPort.StopBits
Represents the number of stop bits to use for Serial Communication |
static class |
SerialPort.WriteBufferMode
Represents which type of buffer mode to use when writing to a serial port |
Constructor Summary | |
---|---|
SerialPort(int baudRate)
Create an instance of a Serial Port class. |
|
SerialPort(int baudRate,
int dataBits)
Create an instance of a Serial Port class. |
|
SerialPort(int baudRate,
int dataBits,
SerialPort.Parity parity)
Create an instance of a Serial Port class. |
|
SerialPort(int baudRate,
int dataBits,
SerialPort.Parity parity,
SerialPort.StopBits stopBits)
Create an instance of a Serial Port class. |
Method Summary | |
---|---|
void |
disableTermination()
Disable termination behavior. |
void |
enableTermination()
Enable termination and specify the termination character. |
void |
enableTermination(char terminator)
Enable termination and specify the termination character. |
void |
flush()
Force the output buffer to be written to the port. |
void |
free()
Destructor. |
int |
getBytesReceived()
Get the number of bytes currently available to read from the serial port. |
void |
print(java.lang.String write)
Deprecated. use write(string.getBytes()) instead |
byte[] |
read(int count)
Read raw bytes out of the buffer. |
java.lang.String |
readString()
Read a string out of the buffer. |
java.lang.String |
readString(int count)
Read a string out of the buffer. |
void |
reset()
Reset the serial port driver to a known state. |
void |
setFlowControl(SerialPort.FlowControl flowControl)
Set the type of flow control to enable on this port. |
void |
setTimeout(double timeout)
Configure the timeout of the serial port. |
void |
setWriteBufferMode(SerialPort.WriteBufferMode mode)
Specify the flushing behavior of the output buffer. |
int |
write(byte[] buffer,
int count)
Write raw bytes to the buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SerialPort(int baudRate, int dataBits, SerialPort.Parity parity, SerialPort.StopBits stopBits) throws VisaException
baudRate
- The baud rate to configure the serial port. The cRIO-9074 supports up to 230400 Baud.dataBits
- The number of data bits per transfer. Valid values are between 5 and 8 bits.parity
- Select the type of parity checking to use.stopBits
- The number of stop bits to use as defined by the enum StopBits.
VisaException
public SerialPort(int baudRate, int dataBits, SerialPort.Parity parity) throws VisaException
baudRate
- The baud rate to configure the serial port. The cRIO-9074 supports up to 230400 Baud.dataBits
- The number of data bits per transfer. Valid values are between 5 and 8 bits.parity
- Select the type of parity checking to use.
VisaException
public SerialPort(int baudRate, int dataBits) throws VisaException
baudRate
- The baud rate to configure the serial port. The cRIO-9074 supports up to 230400 Baud.dataBits
- The number of data bits per transfer. Valid values are between 5 and 8 bits.
VisaException
public SerialPort(int baudRate) throws VisaException
baudRate
- The baud rate to configure the serial port. The cRIO-9074 supports up to 230400 Baud.
VisaException
Method Detail |
---|
public void free()
public void setFlowControl(SerialPort.FlowControl flowControl) throws VisaException
flowControl
-
VisaException
public void enableTermination(char terminator) throws VisaException
terminator
- The character to use for termination.
VisaException
public void enableTermination() throws VisaException
VisaException
public void disableTermination() throws VisaException
VisaException
public int getBytesReceived() throws VisaException
VisaException
public void print(java.lang.String write) throws VisaException
write
- A string to write
VisaException
public java.lang.String readString() throws VisaException
VisaException
public java.lang.String readString(int count) throws VisaException
count
- the number of characters to read into the string
VisaException
public byte[] read(int count) throws VisaException
count
- The maximum number of bytes to read.
VisaException
public int write(byte[] buffer, int count) throws VisaException
buffer
- the buffer to read the bytes from.count
- The maximum number of bytes to write.
VisaException
public void setTimeout(double timeout) throws VisaException
timeout
- The number of seconds to to wait for I/O.
VisaException
public void setWriteBufferMode(SerialPort.WriteBufferMode mode) throws VisaException
mode
- The write buffer mode.
VisaException
public void flush() throws VisaException
VisaException
public void reset() throws VisaException
VisaException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |