Goby3  3.0.1
2021.08.17
goby::util::SerialClient Class Reference

provides a basic client for line by line text based communications over a 8N1 tty (such as an RS-232 serial link) without flow control More...

#include <goby/util/linebasedcomms/serial_client.h>

Inheritance diagram for goby::util::SerialClient:
goby::util::LineBasedInterface

Public Member Functions

 SerialClient (std::string name="", unsigned baud=9600, const std::string &delimiter="\r\n")
 create a serial client More...
 
 ~SerialClient () override
 
void set_name (const std::string &name)
 set serial port name, e.g. "/dev/ttyS0" More...
 
void set_baud (unsigned baud)
 baud rate, e.g. 4800 More...
 
std::string name () const
 serial port name, e.g. "/dev/ttyS0" More...
 
unsigned baud () const
 baud rate, e.g. 4800 More...
 
std::string local_endpoint () override
 our serial port, e.g. "/dev/ttyUSB1" More...
 
std::string remote_endpoint () override
 who knows where the serial port goes?! (empty string) More...
 
void send_command (const middleware::protobuf::SerialCommand &command)
 
const middleware::protobuf::SerialStatusread_status ()
 
- Public Member Functions inherited from goby::util::LineBasedInterface
 LineBasedInterface (const std::string &delimiter)
 
virtual ~LineBasedInterface ()
 
void start ()
 
void close ()
 
bool active ()
 
void sleep (int sec)
 
bool readline (std::string *s, AccessOrder order=OLDEST_FIRST)
 returns string line (including delimiter) More...
 
bool readline (protobuf::Datagram *msg, AccessOrder order=OLDEST_FIRST)
 
void write (const std::string &s)
 
void write (const protobuf::Datagram &msg)
 
void clear ()
 
void set_delimiter (const std::string &s)
 
std::string delimiter () const
 

Additional Inherited Members

- Public Types inherited from goby::util::LineBasedInterface
enum  AccessOrder { NEWEST_FIRST, OLDEST_FIRST }
 
- Protected Member Functions inherited from goby::util::LineBasedInterface
void set_active (bool active)
 
std::string & delimiter ()
 
std::deque< goby::util::protobuf::Datagram > & in ()
 
goby::middleware::InterThreadTransporterinterthread ()
 
int index ()
 
goby::middleware::DynamicGroupin_group ()
 
goby::middleware::DynamicGroupout_group ()
 
bool io_thread_ready ()
 

Detailed Description

provides a basic client for line by line text based communications over a 8N1 tty (such as an RS-232 serial link) without flow control

Definition at line 45 of file serial_client.h.

Constructor & Destructor Documentation

◆ SerialClient()

goby::util::SerialClient::SerialClient ( std::string  name = "",
unsigned  baud = 9600,
const std::string &  delimiter = "\r\n" 
)

create a serial client

Parameters
namename of the serial connection (e.g. "/dev/ttyS0")
baudbaud rate of the serial connection (e.g. 9600)
delimiterstring used to split lines

◆ ~SerialClient()

goby::util::SerialClient::~SerialClient ( )
override

Member Function Documentation

◆ baud()

unsigned goby::util::SerialClient::baud ( ) const
inline

baud rate, e.g. 4800

Definition at line 67 of file serial_client.h.

◆ local_endpoint()

std::string goby::util::SerialClient::local_endpoint ( )
inlineoverridevirtual

our serial port, e.g. "/dev/ttyUSB1"

Implements goby::util::LineBasedInterface.

Definition at line 70 of file serial_client.h.

◆ name()

std::string goby::util::SerialClient::name ( ) const
inline

serial port name, e.g. "/dev/ttyS0"

Definition at line 64 of file serial_client.h.

◆ read_status()

const middleware::protobuf::SerialStatus& goby::util::SerialClient::read_status ( )
inline

Definition at line 75 of file serial_client.h.

◆ remote_endpoint()

std::string goby::util::SerialClient::remote_endpoint ( )
inlineoverridevirtual

who knows where the serial port goes?! (empty string)

Reimplemented from goby::util::LineBasedInterface.

Definition at line 72 of file serial_client.h.

◆ send_command()

void goby::util::SerialClient::send_command ( const middleware::protobuf::SerialCommand command)

◆ set_baud()

void goby::util::SerialClient::set_baud ( unsigned  baud)
inline

baud rate, e.g. 4800

Definition at line 61 of file serial_client.h.

◆ set_name()

void goby::util::SerialClient::set_name ( const std::string &  name)
inline

set serial port name, e.g. "/dev/ttyS0"

Definition at line 59 of file serial_client.h.


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