Goby3  3.1.5a
2024.05.23
goby::middleware::io::TCPClientThreadCOBS< packet_in_group, packet_out_group, publish_layer, subscribe_layer, Config, ThreadType, use_indexed_groups > Class Template Reference

Reads/Writes strings from/to a TCP connection using a Consistent Overhead Byte Stuffing (COBS) binary protocol. More...

#include <goby/middleware/io/cobs/tcp_client.h>

Inheritance diagram for goby::middleware::io::TCPClientThreadCOBS< packet_in_group, packet_out_group, publish_layer, subscribe_layer, Config, ThreadType, use_indexed_groups >:
goby::middleware::io::detail::TCPClientThread< packet_in_group, packet_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::TCPClientConfig, goby::middleware::SimpleThread, false > goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups > goby::middleware::SimpleThread< goby::middleware::protobuf::TCPClientConfig > goby::middleware::io::detail::IOPublishTransporter< IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups >, line_in_group, publish_layer, use_indexed_groups > goby::middleware::io::detail::IOSubscribeTransporter< IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups >, line_out_group, subscribe_layer, use_indexed_groups > goby::middleware::Thread< goby::middleware::protobuf::TCPClientConfig, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > > goby::middleware::coroner::Thread< SimpleThread< goby::middleware::protobuf::TCPClientConfig > >

Public Member Functions

 TCPClientThreadCOBS (const goby::middleware::protobuf::TCPClientConfig &config, int index=-1)
 Constructs the thread. More...
 
 ~TCPClientThreadCOBS ()
 
- Public Member Functions inherited from goby::middleware::io::detail::TCPClientThread< packet_in_group, packet_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::TCPClientConfig, goby::middleware::SimpleThread, false >
 TCPClientThread (const goby::middleware::protobuf::TCPClientConfig &config, int index=-1)
 Constructs the thread. More...
 
 ~TCPClientThread () override
 
- Public Member Functions inherited from goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups >
 IOThread (const goby::middleware::protobuf::TCPClientConfig &config, int index, std::string glog_group="i/o")
 Constructs the thread. More...
 
void initialize () override
 
void finalize () override
 
virtual ~IOThread ()
 
- Public Member Functions inherited from goby::middleware::SimpleThread< goby::middleware::protobuf::TCPClientConfig >
 SimpleThread (const goby::middleware::protobuf::TCPClientConfig &cfg, double loop_freq_hertz=0, int index=-1)
 Construct a thread with a given configuration, optionally a loop frequency and/or index. More...
 
 SimpleThread (const goby::middleware::protobuf::TCPClientConfig &cfg, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 Construct a thread with a given configuration, a loop frequency (using boost::units) and optionally an index. More...
 
InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > & intervehicle ()
 Access the transporter on the intervehicle layer (which wraps interprocess and interthread) More...
 
InterProcessForwarder< InterThreadTransporter > & interprocess ()
 Access the transporter on the interprocess layer (which wraps interthread) More...
 
InterThreadTransporterinterthread ()
 Access the transporter on the interthread layer (this is the innermost transporter) More...
 
- Public Member Functions inherited from goby::middleware::Thread< goby::middleware::protobuf::TCPClientConfig, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > >
 Thread (const goby::middleware::protobuf::TCPClientConfig &cfg, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > *transporter, int index)
 Construct a thread with a given configuration, underlying transporter, and index (for multiple instantiations), but without any loop() frequency. More...
 
 Thread (const goby::middleware::protobuf::TCPClientConfig &cfg, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > *transporter, double loop_freq_hertz=0, int index=-1)
 Construct a thread with all possible metadata (using double to specify frequency in Hertz) More...
 
 Thread (const goby::middleware::protobuf::TCPClientConfig &cfg, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > *transporter, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 Construct a thread with all possible metadata (using boost::units to specify frequency) More...
 
virtual ~Thread ()
 
void run (std::atomic< bool > &alive)
 Run the thread until the boolean reference passed is set false. This call blocks, and should be run in a std::thread by the caller. More...
 
int index () const
 
std::type_index type_index ()
 
void set_type_index (std::type_index type_i)
 
std::string name ()
 
void set_name (const std::string &name)
 
int uid ()
 
void set_uid (int uid)
 

Friends

template<class Thread >
void cobs_async_write (Thread *this_thread, std::shared_ptr< const goby::middleware::protobuf::IOData > io_msg)
 
template<class Thread , class ThreadBase >
void cobs_async_read (Thread *this_thread, std::shared_ptr< ThreadBase > self)
 

Additional Inherited Members

- Public Types inherited from goby::middleware::Thread< goby::middleware::protobuf::TCPClientConfig, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > >
using Transporter = InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > >
 
- Static Public Attributes inherited from goby::middleware::Thread< goby::middleware::protobuf::TCPClientConfig, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > >
static constexpr goby::middleware::Group shutdown_group_
 
static constexpr goby::middleware::Group joinable_group_
 
- Protected Member Functions inherited from goby::middleware::io::detail::TCPClientThread< packet_in_group, packet_out_group, PubSubLayer::INTERPROCESS, PubSubLayer::INTERTHREAD, goby::middleware::protobuf::TCPClientConfig, goby::middleware::SimpleThread, false >
void insert_endpoints (std::shared_ptr< goby::middleware::protobuf::IOData > &io_msg)
 
- Protected Member Functions inherited from goby::middleware::io::detail::IOThread< line_in_group, line_out_group, publish_layer, subscribe_layer, goby::middleware::protobuf::TCPClientConfig, boost::asio::ip::tcp::socket, goby::middleware::SimpleThread, use_indexed_groups >
void write (std::shared_ptr< const goby::middleware::protobuf::IOData > io_msg)
 
void handle_read_success (std::size_t bytes_transferred, const std::string &bytes)
 
void handle_read_success (std::size_t bytes_transferred, std::shared_ptr< goby::middleware::protobuf::IOData > io_msg)
 
void handle_write_success (std::size_t bytes_transferred)
 
void handle_read_error (const boost::system::error_code &ec)
 
void handle_write_error (const boost::system::error_code &ec)
 
boost::asio::ip::tcp::socket & mutable_socket ()
 Access the (mutable) socket (or serial_port) object. More...
 
boost::asio::io_contextmutable_io ()
 
bool socket_is_open ()
 Does the socket exist and is it open? More...
 
const std::string & glog_group ()
 
- Protected Member Functions inherited from goby::middleware::Thread< goby::middleware::protobuf::TCPClientConfig, InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > >
 Thread (const goby::middleware::protobuf::TCPClientConfig &cfg, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 
void set_transporter (InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > *transporter)
 
double loop_frequency_hertz () const
 
decltype(loop_frequency_) loop_frequency () const
 
double loop_max_frequency () const
 
void run_once ()
 
InterVehicleForwarder< InterProcessForwarder< InterThreadTransporter > > & transporter () const
 
const goby::middleware::protobuf::TCPClientConfigcfg () const
 
void thread_health (goby::middleware::protobuf::ThreadHealth &health)
 
virtual void health (goby::middleware::protobuf::ThreadHealth &health)
 Called when HealthRequest is made by goby_coroner. More...
 
void thread_quit ()
 
bool alive ()
 
- Protected Member Functions inherited from goby::middleware::coroner::Thread< SimpleThread< goby::middleware::protobuf::TCPClientConfig > >
void subscribe_coroner ()
 

Detailed Description

template<const goby::middleware::Group & packet_in_group, const goby::middleware::Group & packet_out_group, PubSubLayer publish_layer = PubSubLayer::INTERPROCESS, PubSubLayer subscribe_layer = PubSubLayer::INTERTHREAD, typename Config = goby::middleware::protobuf::TCPClientConfig, template< class > class ThreadType = goby::middleware::SimpleThread, bool use_indexed_groups = false>
class goby::middleware::io::TCPClientThreadCOBS< packet_in_group, packet_out_group, publish_layer, subscribe_layer, Config, ThreadType, use_indexed_groups >

Reads/Writes strings from/to a TCP connection using a Consistent Overhead Byte Stuffing (COBS) binary protocol.

Template Parameters
packet_in_groupgoby::middleware::Group to publish to after receiving data from the TCP socket
packet_out_groupgoby::middleware::Group to subcribe to for data to send to the TCP socket

Definition at line 74 of file tcp_client.h.

Constructor & Destructor Documentation

◆ TCPClientThreadCOBS()

template<const goby::middleware::Group & packet_in_group, const goby::middleware::Group & packet_out_group, PubSubLayer publish_layer = PubSubLayer::INTERPROCESS, PubSubLayer subscribe_layer = PubSubLayer::INTERTHREAD, typename Config = goby::middleware::protobuf::TCPClientConfig, template< class > class ThreadType = goby::middleware::SimpleThread, bool use_indexed_groups = false>
goby::middleware::io::TCPClientThreadCOBS< packet_in_group, packet_out_group, publish_layer, subscribe_layer, Config, ThreadType, use_indexed_groups >::TCPClientThreadCOBS ( const goby::middleware::protobuf::TCPClientConfig config,
int  index = -1 
)
inline

Constructs the thread.

Parameters
configA reference to the Protocol Buffers config read by the main application at launch
indexThread index for multiple instances in a given application (-1 indicates a single instance)

Definition at line 85 of file tcp_client.h.

◆ ~TCPClientThreadCOBS()

template<const goby::middleware::Group & packet_in_group, const goby::middleware::Group & packet_out_group, PubSubLayer publish_layer = PubSubLayer::INTERPROCESS, PubSubLayer subscribe_layer = PubSubLayer::INTERTHREAD, typename Config = goby::middleware::protobuf::TCPClientConfig, template< class > class ThreadType = goby::middleware::SimpleThread, bool use_indexed_groups = false>
goby::middleware::io::TCPClientThreadCOBS< packet_in_group, packet_out_group, publish_layer, subscribe_layer, Config, ThreadType, use_indexed_groups >::~TCPClientThreadCOBS ( )
inline

Definition at line 90 of file tcp_client.h.

Friends And Related Function Documentation

◆ cobs_async_read

template<const goby::middleware::Group & packet_in_group, const goby::middleware::Group & packet_out_group, PubSubLayer publish_layer = PubSubLayer::INTERPROCESS, PubSubLayer subscribe_layer = PubSubLayer::INTERTHREAD, typename Config = goby::middleware::protobuf::TCPClientConfig, template< class > class ThreadType = goby::middleware::SimpleThread, bool use_indexed_groups = false>
template<class Thread , class ThreadBase >
void cobs_async_read ( Thread this_thread,
std::shared_ptr< ThreadBase >  self = std::shared_ptr<ThreadBase>() 
)
friend

Definition at line 90 of file common.h.

◆ cobs_async_write

template<const goby::middleware::Group & packet_in_group, const goby::middleware::Group & packet_out_group, PubSubLayer publish_layer = PubSubLayer::INTERPROCESS, PubSubLayer subscribe_layer = PubSubLayer::INTERTHREAD, typename Config = goby::middleware::protobuf::TCPClientConfig, template< class > class ThreadType = goby::middleware::SimpleThread, bool use_indexed_groups = false>
template<class Thread >
void cobs_async_write ( Thread this_thread,
std::shared_ptr< const goby::middleware::protobuf::IOData io_msg 
)
friend

Definition at line 44 of file common.h.


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