172 int Read(
char* buffer,
int count);
181 int Write(
const char* buffer,
int count);
Driver for the RS-232 serial port on the roboRIO.
Definition SerialPort.h:28
SerialPort(SerialPort &&rhs)=default
void Flush()
Force the output buffer to be written to the port.
SerialPort(int baudRate, std::string_view portName, Port port=kOnboard, int dataBits=8, Parity parity=kParity_None, StopBits stopBits=kStopBits_One)
Create an instance of a Serial Port class.
void EnableTermination(char terminator='\n')
Enable termination and specify the termination character.
void SetReadBufferSize(int size)
Specify the size of the input buffer.
StopBits
Represents the number of stop bits to use for Serial Communication.
Definition SerialPort.h:65
@ kStopBits_OnePointFive
One and a half stop bits.
Definition SerialPort.h:69
@ kStopBits_One
One stop bit.
Definition SerialPort.h:67
@ kStopBits_Two
Two stop bits.
Definition SerialPort.h:71
void SetWriteBufferSize(int size)
Specify the size of the output buffer.
SerialPort & operator=(SerialPort &&rhs)=default
SerialPort(int baudRate, Port port=kOnboard, int dataBits=8, Parity parity=kParity_None, StopBits stopBits=kStopBits_One)
Create an instance of a Serial Port class.
void DisableTermination()
Disable termination behavior.
void SetWriteBufferMode(WriteBufferMode mode)
Specify the flushing behavior of the output buffer.
int Write(const char *buffer, int count)
Write raw bytes to the buffer.
int Write(std::string_view buffer)
Write raw bytes to the buffer.
void SetTimeout(units::second_t timeout)
Configure the timeout of the serial port.
FlowControl
Represents what type of flow control to use for serial communication.
Definition SerialPort.h:77
@ kFlowControl_XonXoff
XON/XOFF flow control.
Definition SerialPort.h:81
@ kFlowControl_DtrDsr
DTS/DSR flow control.
Definition SerialPort.h:85
@ kFlowControl_RtsCts
RTS/CTS flow control.
Definition SerialPort.h:83
@ kFlowControl_None
No flow control.
Definition SerialPort.h:79
Port
Serial port.
Definition SerialPort.h:33
@ kOnboard
Onboard serial port on the roboRIO.
Definition SerialPort.h:35
@ kUSB2
USB serial port 2.
Definition SerialPort.h:43
@ kMXP
MXP (roboRIO MXP) serial port.
Definition SerialPort.h:37
@ kUSB
USB serial port (same as kUSB1).
Definition SerialPort.h:39
@ kUSB1
USB serial port 1.
Definition SerialPort.h:41
void Reset()
Reset the serial port driver to a known state.
Parity
Represents the parity to use for serial communications.
Definition SerialPort.h:49
@ kParity_Space
Parity bit always off.
Definition SerialPort.h:59
@ kParity_None
No parity.
Definition SerialPort.h:51
@ kParity_Mark
Parity bit always on.
Definition SerialPort.h:57
@ kParity_Even
Even parity.
Definition SerialPort.h:55
@ kParity_Odd
Odd parity.
Definition SerialPort.h:53
WriteBufferMode
Represents which type of buffer mode to use when writing to a serial port.
Definition SerialPort.h:91
@ kFlushWhenFull
Flush the buffer when it is full.
Definition SerialPort.h:95
@ kFlushOnAccess
Flush the buffer on each access.
Definition SerialPort.h:93
int GetBytesReceived()
Get the number of bytes currently available to read from the serial port.
int Read(char *buffer, int count)
Read raw bytes out of the buffer.
void SetFlowControl(FlowControl flowControl)
Set the type of flow control to enable on this port.
A move-only C++ wrapper around a HAL handle.
Definition Types.h:96