58 catch (std::exception &) {
59 fprintf(stderr,
"Error when closing serial port in destructor.\n");
88 if (buffer.size() > 0) {
90 return write(&(buf[0]), static_cast<int>(buffer.size()));
118 std::string retString;
119 unsigned int numRead = 0;
120 unsigned int thisRead = 0;
121 static const unsigned int BUFSIZE = 256;
122 unsigned char buf[BUFSIZE];
123 unsigned int needed = BUFSIZE - 1;
126 needed = (
std::min)(count - numRead, BUFSIZE - 1);
130 retString.append(&(buf[0]), &(buf[0]) + thisRead);
133 }
while (thisRead != 0 &&
134 (static_cast<int>(numRead) < count || count == -1));
139 struct timeval &timeout)
150 struct timeval &timeout)
152 if (count == std::numeric_limits<int>::max()) {
158 return std::string(&(buf[0]), &(buf[0]) + ret);
int vrpn_write_characters(int comm, const unsigned char *buffer, size_t bytes)
Write the buffer to the serial port.
int vrpn_close_commport(int comm)
int vrpn_open_commport(const char *portname, long baud, int charsize, vrpn_SER_PARITY parity, bool rts_flow)
Open a serial port, given its name and baud rate.
int write(std::string const &buffer)
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
void flush_input_buffer()
Throw out any characters within the input buffer.
void drain_output_buffer()
Wait until all of the characters in the output buffer are sent, then return.
vrpn_SerialPort()
Construct without opening.
void flush_output_buffer()
Throw out any characters (do not send) within the output buffer.
int vrpn_drain_output_buffer(int comm)
Wait until all of the characters in the output buffer are sent, then return.
int vrpn_set_rts(int comm)
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
int vrpn_clear_rts(int comm)
int vrpn_flush_output_buffer(int comm)
Throw out any characters (do not send) within the output buffer.
~vrpn_SerialPort()
Destructor - closes port if open.
int read_available_characters(unsigned char *buffer, int count)
void open(const char *portname, long baud, int charsize=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE)
std::vector< unsigned char > DynamicBufferType
void close()
Close the serial port.