Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
serial::Serial Class Reference

#include <serial.h>

Classes

class  SerialImpl
 
class  Timeout
 

Public Member Functions

size_t available ()
 
void close ()
 
void flush ()
 
void flushInput ()
 
void flushOutput ()
 
uint32_t getBaudrate () const
 
bytesize_t getBytesize () const
 
bool getCD ()
 
bool getCTS ()
 
bool getDSR ()
 
flowcontrol_t getFlowcontrol () const
 
parity_t getParity () const
 
std::string getPort () const
 
bool getRI ()
 
stopbits_t getStopbits () const
 
Timeout getTimeout () const
 
bool isOpen () const
 
void open ()
 
Serialoperator= (const Serial &)=delete
 
std::string read (size_t size=1)
 
size_t read (std::string &buffer, size_t size=1)
 
size_t read (std::vector< uint8_t > &buffer, size_t size=1)
 
size_t read (uint8_t *buffer, size_t size)
 
std::string readline (size_t size=65536, const std::string &eol="\n")
 
size_t readline (std::string &line, size_t size=65536, const std::string &eol="\n")
 
std::vector< std::string > readlines (size_t size=65536, const std::string &eol="\n")
 
void sendBreak (int duration)
 
 Serial (const Serial &)=delete
 
 Serial (const std::string &port_name="", uint32_t baudrate=9600, Timeout timeout=Timeout(), bytesize_t bytesize=eightbits, parity_t parity=parity_none, stopbits_t stopbits=stopbits_one, flowcontrol_t flowcontrol=flowcontrol_none)
 
void setBaudrate (uint32_t baudrate)
 
void setBreak (bool level=true)
 
void setBytesize (bytesize_t bytesize)
 
void setDTR (bool level=true)
 
void setFlowcontrol (flowcontrol_t flowcontrol)
 
void setParity (parity_t parity)
 
void setPort (const std::string &port_name)
 
void setRTS (bool level=true)
 
void setStopbits (stopbits_t stopbits)
 
void setTimeout (const Timeout &timeout)
 
void setTimeout (uint32_t inter_byte, uint32_t read_constant, uint32_t read_multiplier, uint32_t write_constant, uint32_t write_multiplier)
 
void waitByteTimes (size_t count)
 
void waitForModemChanges ()
 
bool waitReadable ()
 
bool waitWritable ()
 
size_t write (const std::string &data)
 
size_t write (const std::vector< uint8_t > &data)
 
size_t write (const uint8_t *data, size_t size)
 
virtual ~Serial ()
 

Private Member Functions

size_t readline_ (std::string &line, size_t size=65536, const std::string &eol="\n")
 

Private Attributes

std::unique_ptr< SerialImplpimpl_
 
std::mutex read_mutex_
 
std::mutex write_mutex_
 

Detailed Description

Definition at line 97 of file serial.h.

Constructor & Destructor Documentation

◆ Serial() [1/2]

Serial::Serial ( const std::string &  port_name = "",
uint32_t  baudrate = 9600,
Serial::Timeout  timeout = Timeout(),
bytesize_t  bytesize = eightbits,
parity_t  parity = parity_none,
stopbits_t  stopbits = stopbits_one,
flowcontrol_t  flowcontrol = flowcontrol_none 
)
explicit

Definition at line 27 of file serial.cpp.

◆ ~Serial()

Serial::~Serial ( )
virtual

Definition at line 33 of file serial.cpp.

◆ Serial() [2/2]

serial::Serial::Serial ( const Serial )
delete

Member Function Documentation

◆ available()

size_t Serial::available ( )

Definition at line 49 of file serial.cpp.

◆ close()

void Serial::close ( )

Definition at line 41 of file serial.cpp.

◆ flush()

void Serial::flush ( )

Definition at line 218 of file serial.cpp.

◆ flushInput()

void Serial::flushInput ( )

Definition at line 224 of file serial.cpp.

◆ flushOutput()

void Serial::flushOutput ( )

Definition at line 229 of file serial.cpp.

◆ getBaudrate()

uint32_t Serial::getBaudrate ( ) const

Definition at line 182 of file serial.cpp.

◆ getBytesize()

bytesize_t Serial::getBytesize ( ) const

Definition at line 190 of file serial.cpp.

◆ getCD()

bool Serial::getCD ( )

Definition at line 266 of file serial.cpp.

◆ getCTS()

bool Serial::getCTS ( )

Definition at line 254 of file serial.cpp.

◆ getDSR()

bool Serial::getDSR ( )

Definition at line 258 of file serial.cpp.

◆ getFlowcontrol()

flowcontrol_t Serial::getFlowcontrol ( ) const

Definition at line 214 of file serial.cpp.

◆ getParity()

parity_t Serial::getParity ( ) const

Definition at line 198 of file serial.cpp.

◆ getPort()

std::string Serial::getPort ( ) const

Definition at line 162 of file serial.cpp.

◆ getRI()

bool Serial::getRI ( )

Definition at line 262 of file serial.cpp.

◆ getStopbits()

stopbits_t Serial::getStopbits ( ) const

Definition at line 206 of file serial.cpp.

◆ getTimeout()

Serial::Timeout Serial::getTimeout ( ) const

Definition at line 174 of file serial.cpp.

◆ isOpen()

bool Serial::isOpen ( ) const

Definition at line 45 of file serial.cpp.

◆ open()

void Serial::open ( )

Definition at line 37 of file serial.cpp.

◆ operator=()

Serial& serial::Serial::operator= ( const Serial )
delete

◆ read() [1/4]

std::string Serial::read ( size_t  size = 1)

Definition at line 86 of file serial.cpp.

◆ read() [2/4]

size_t Serial::read ( std::string &  buffer,
size_t  size = 1 
)

Definition at line 78 of file serial.cpp.

◆ read() [3/4]

size_t Serial::read ( std::vector< uint8_t > &  buffer,
size_t  size = 1 
)

Definition at line 70 of file serial.cpp.

◆ read() [4/4]

size_t Serial::read ( uint8_t *  buffer,
size_t  size 
)

Definition at line 65 of file serial.cpp.

◆ readline() [1/2]

std::string Serial::readline ( size_t  size = 65536,
const std::string &  eol = "\n" 
)

Definition at line 115 of file serial.cpp.

◆ readline() [2/2]

size_t Serial::readline ( std::string &  line,
size_t  size = 65536,
const std::string &  eol = "\n" 
)

Definition at line 110 of file serial.cpp.

◆ readline_()

size_t Serial::readline_ ( std::string &  line,
size_t  size = 65536,
const std::string &  eol = "\n" 
)
private

Definition at line 92 of file serial.cpp.

◆ readlines()

std::vector< std::string > Serial::readlines ( size_t  size = 65536,
const std::string &  eol = "\n" 
)

Definition at line 122 of file serial.cpp.

◆ sendBreak()

void Serial::sendBreak ( int  duration)

Definition at line 234 of file serial.cpp.

◆ setBaudrate()

void Serial::setBaudrate ( uint32_t  baudrate)

Definition at line 178 of file serial.cpp.

◆ setBreak()

void Serial::setBreak ( bool  level = true)

Definition at line 238 of file serial.cpp.

◆ setBytesize()

void Serial::setBytesize ( bytesize_t  bytesize)

Definition at line 186 of file serial.cpp.

◆ setDTR()

void Serial::setDTR ( bool  level = true)

Definition at line 246 of file serial.cpp.

◆ setFlowcontrol()

void Serial::setFlowcontrol ( flowcontrol_t  flowcontrol)

Definition at line 210 of file serial.cpp.

◆ setParity()

void Serial::setParity ( parity_t  parity)

Definition at line 194 of file serial.cpp.

◆ setPort()

void Serial::setPort ( const std::string &  port_name)

Definition at line 149 of file serial.cpp.

◆ setRTS()

void Serial::setRTS ( bool  level = true)

Definition at line 242 of file serial.cpp.

◆ setStopbits()

void Serial::setStopbits ( stopbits_t  stopbits)

Definition at line 202 of file serial.cpp.

◆ setTimeout() [1/2]

void Serial::setTimeout ( const Timeout timeout)

Definition at line 166 of file serial.cpp.

◆ setTimeout() [2/2]

void Serial::setTimeout ( uint32_t  inter_byte,
uint32_t  read_constant,
uint32_t  read_multiplier,
uint32_t  write_constant,
uint32_t  write_multiplier 
)

Definition at line 170 of file serial.cpp.

◆ waitByteTimes()

void Serial::waitByteTimes ( size_t  count)

Definition at line 61 of file serial.cpp.

◆ waitForModemChanges()

void Serial::waitForModemChanges ( )

Definition at line 250 of file serial.cpp.

◆ waitReadable()

bool Serial::waitReadable ( )

Definition at line 53 of file serial.cpp.

◆ waitWritable()

bool Serial::waitWritable ( )

Definition at line 57 of file serial.cpp.

◆ write() [1/3]

size_t Serial::write ( const std::string &  data)

Definition at line 134 of file serial.cpp.

◆ write() [2/3]

size_t Serial::write ( const std::vector< uint8_t > &  data)

Definition at line 139 of file serial.cpp.

◆ write() [3/3]

size_t Serial::write ( const uint8_t *  data,
size_t  size 
)

Definition at line 144 of file serial.cpp.

Member Data Documentation

◆ pimpl_

std::unique_ptr<SerialImpl> serial::Serial::pimpl_
private

Definition at line 576 of file serial.h.

◆ read_mutex_

std::mutex serial::Serial::read_mutex_
private

Definition at line 578 of file serial.h.

◆ write_mutex_

std::mutex serial::Serial::write_mutex_
private

Definition at line 579 of file serial.h.


The documentation for this class was generated from the following files:


qb_device_driver
Author(s): qbrobotics®
autogenerated on Thu Apr 27 2023 02:36:32