12 #include <hal/Types.h>
13 #include <wpi/StringRef.h>
14 #include <wpi/Twine.h>
15 #include <wpi/deprecated.h>
17 #include "frc/ErrorBase.h"
45 kStopBits_OnePointFive = 15,
50 kFlowControl_None = 0,
51 kFlowControl_XonXoff = 1,
52 kFlowControl_RtsCts = 2,
53 kFlowControl_DtrDsr = 4
56 enum WriteBufferMode { kFlushOnAccess = 1, kFlushWhenFull = 2 };
58 enum Port { kOnboard = 0, kMXP = 1, kUSB = 2, kUSB1 = 2, kUSB2 = 3 };
71 SerialPort(
int baudRate, Port port = kOnboard,
int dataBits = 8,
72 Parity parity = kParity_None, StopBits stopBits = kStopBits_One);
90 int dataBits = 8, Parity parity = kParity_None,
91 StopBits stopBits = kStopBits_One);
135 int Read(
char* buffer,
int count);
144 int Write(
const char* buffer,
int count);
220 hal::Handle<HAL_SerialPortHandle> m_portHandle;
int Read(char *buffer, int count)
Read raw bytes out of the buffer.
Driver for the RS-232 serial port on the roboRIO.
Definition: SerialPort.h:33
void SetTimeout(double timeout)
Configure the timeout of the serial port.
void Flush()
Force the output buffer to be written to the port.
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.
int Write(const char *buffer, int count)
Write raw bytes to the buffer.
void EnableTermination(char terminator='\n')
Enable termination and specify the termination character.
void SetWriteBufferSize(int size)
Specify the size of the output buffer.
Base class for most objects.
Definition: ErrorBase.h:104
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
int GetBytesReceived()
Get the number of bytes currently available to read from the serial port.
void DisableTermination()
Disable termination behavior.
void Reset()
Reset the serial port driver to a known state.
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
void SetFlowControl(FlowControl flowControl)
Set the type of flow control to enable on this port.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
void SetReadBufferSize(int size)
Specify the size of the input buffer.
void SetWriteBufferMode(WriteBufferMode mode)
Specify the flushing behavior of the output buffer.