12 #include "ErrorBase.h"
13 #include "llvm/StringRef.h"
40 kStopBits_OnePointFive = 15,
44 kFlowControl_None = 0,
45 kFlowControl_XonXoff = 1,
46 kFlowControl_RtsCts = 2,
47 kFlowControl_DtrDsr = 4
49 enum WriteBufferMode { kFlushOnAccess = 1, kFlushWhenFull = 2 };
50 enum Port { kOnboard = 0, kMXP = 1, kUSB = 2, kUSB1 = 2, kUSB2 = 3 };
52 SerialPort(
int baudRate, Port port = kOnboard,
int dataBits = 8,
53 Parity parity = kParity_None, StopBits stopBits = kStopBits_One);
63 int Read(
char* buffer,
int count);
64 int Write(
const char* buffer,
int count);
65 int Write(llvm::StringRef buffer);
74 int m_resourceManagerHandle = 0;
76 bool m_consoleModeEnabled =
false;
void SetWriteBufferSize(int size)
Specify the size of the output buffer.
Definition: SerialPort.cpp:207
void Reset()
Reset the serial port driver to a known state.
Definition: SerialPort.cpp:248
void Flush()
Force the output buffer to be written to the port.
Definition: SerialPort.cpp:237
void SetTimeout(double timeout)
Configure the timeout of the serial port.
Definition: SerialPort.cpp:174
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.
Definition: SerialPort.cpp:29
void SetFlowControl(FlowControl flowControl)
Set the type of flow control to enable on this port.
Definition: SerialPort.cpp:78
Driver for the RS-232 serial port on the roboRIO.
Definition: SerialPort.h:29
void SetReadBufferSize(int size)
Specify the size of the input buffer.
Definition: SerialPort.cpp:192
int Write(const char *buffer, int count)
Write raw bytes to the buffer.
Definition: SerialPort.cpp:145
void DisableTermination()
Disable termination behavior.
Definition: SerialPort.cpp:104
Base class for most objects.
Definition: ErrorBase.h:72
int GetBytesReceived()
Get the number of bytes currently available to read from the serial port.
Definition: SerialPort.cpp:115
~SerialPort()
Destructor.
Definition: SerialPort.cpp:67
void SetWriteBufferMode(WriteBufferMode mode)
Specify the flushing behavior of the output buffer.
Definition: SerialPort.cpp:225
void EnableTermination(char terminator= '\n')
Enable termination and specify the termination character.
Definition: SerialPort.cpp:94
int Read(char *buffer, int count)
Read raw bytes out of the buffer.
Definition: SerialPort.cpp:130