Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
sick_scan::ColaTransmitter Class Reference

#include <cola_transmitter.h>

Classes

class  ColaResponseContainer
 

Public Member Functions

virtual bool close (void)
 
 ColaTransmitter (const std::string &server_adress="192.168.0.1", int tcp_port=2111, double default_receive_timeout=1)
 
virtual bool connect (void)
 
virtual bool receive (std::vector< uint8_t > &telegram, double timeout, ROS::Time &receive_timestamp)
 
virtual bool send (const std::vector< uint8_t > &data, ROS::Time &send_timestamp)
 
virtual bool startReceiverThread (void)
 
virtual bool stopReceiverThread (void)
 
virtual bool waitPopResponse (std::vector< uint8_t > &telegram, double timeout, ROS::Time &receive_timestamp)
 
virtual ~ColaTransmitter ()
 

Static Public Member Functions

static bool receive (boost::asio::ip::tcp::socket &socket, std::vector< uint8_t > &telegram, double timeout, ROS::Time &receive_timestamp)
 
static bool send (boost::asio::ip::tcp::socket &socket, const std::vector< uint8_t > &data, ROS::Time &send_timestamp)
 

Protected Member Functions

void runReceiverThreadCb (void)
 

Static Protected Member Functions

static bool dataEndWithETX (const std::vector< uint8_t > &data, const std::vector< uint8_t > &etx)
 

Protected Attributes

boost::asio::io_service m_ioservice
 boost io service for tcp connections More...
 
double m_receive_timeout
 default timeout in seconds for receive functions More...
 
boost::thread * m_receiver_thread
 thread to receive responses from localization server More...
 
bool m_receiver_thread_running
 true: m_receiver_thread is running, otherwise false More...
 
sick_scan::FifoBuffer< ColaResponseContainer, boost::mutex > m_response_fifo
 fifo buffer for receiver thread for responses from localization server More...
 
std::string m_server_adress
 ip adress of the localization controller, default: 192.168.0.1 More...
 
int m_tcp_port
 tcp port of the localization controller, default: 2111 for command requests and 2112 for command responses More...
 
sick_scan::ClientSocket m_tcp_socket
 tcp socket connected to the localization controller More...
 

Detailed Description

Class sick_scan::ColaTransmitter connects to the localization controller and sends or receives cola telegrams. Base class for ColaSender and ColaReceiver.

Definition at line 68 of file cola_transmitter.h.

Constructor & Destructor Documentation

◆ ColaTransmitter()

sick_scan::ColaTransmitter::ColaTransmitter ( const std::string &  server_adress = "192.168.0.1",
int  tcp_port = 2111,
double  default_receive_timeout = 1 
)

Constructor.

Parameters
[in]server_adressip adress of the localization controller, default: 192.168.0.1
[in]tcp_porttcp port for command requests, default: 2111 for command requests and 2112 for command responses
[in]default_receive_timeoutdefault timeout in seconds for receive functions

Definition at line 74 of file cola_transmitter.cpp.

◆ ~ColaTransmitter()

sick_scan::ColaTransmitter::~ColaTransmitter ( )
virtual

Destructor, closes all tcp connections.

Definition at line 84 of file cola_transmitter.cpp.

Member Function Documentation

◆ close()

bool sick_scan::ColaTransmitter::close ( void  )
virtual

Closes the tcp connection to the localization server.

Returns
always true

Definition at line 104 of file cola_transmitter.cpp.

◆ connect()

bool sick_scan::ColaTransmitter::connect ( void  )
virtual

Connects to the localization server.

Returns
true on success, false on failure (localization server unknown or unreachable)

Definition at line 95 of file cola_transmitter.cpp.

◆ dataEndWithETX()

bool sick_scan::ColaTransmitter::dataEndWithETX ( const std::vector< uint8_t > &  data,
const std::vector< uint8_t > &  etx 
)
staticprotected

Returns true, if data end with etx, i.e. the trailing (etx.size()) byte in data are identical to etx.

Parameters
[in]datadata received
[in]etxETX tag (binary or ascii)
Returns
true if data end with etx, false otherwise

Definition at line 237 of file cola_transmitter.cpp.

◆ receive() [1/2]

bool sick_scan::ColaTransmitter::receive ( boost::asio::ip::tcp::socket &  socket,
std::vector< uint8_t > &  telegram,
double  timeout,
ROS::Time &  receive_timestamp 
)
static

Receive a cola telegram from a socket.

Parameters
[in]socketsocket to read from
[out]telegramtelegram received (Cola-Binary or Cola-Ascii)
[in]timeouttimeout in seconds
[out]receive_timestampreceive timestamp in seconds (ros timestamp immediately after first response byte received)
Returns
true on success, false on failure (connection error or timeout)

Receive a cola telegram from a socket.

Parameters
[in]socketsocket to read from
[out]telegramtelegram received (Cola-Binary or Cola-Ascii)
[in]timeouttimeout in seconds
[out]receive_timestampreceive timestamp in seconds (ros timestamp immediately after first response byte received)
Returns
true on success, false on failure

Definition at line 179 of file cola_transmitter.cpp.

◆ receive() [2/2]

bool sick_scan::ColaTransmitter::receive ( std::vector< uint8_t > &  telegram,
double  timeout,
ROS::Time &  receive_timestamp 
)
virtual

Receive a cola telegram from the localization server.

Parameters
[out]telegramtelegram received (Cola-Binary or Cola-Ascii)
[in]timeouttimeout in seconds
[out]receive_timestampreceive timestamp in seconds (ros timestamp immediately after first response byte received)
Returns
true on success, false on failure (connection error or timeout)

Receive a cola telegram from the localization server.

Parameters
[out]telegramtelegram received (Cola-Binary or Cola-Ascii)
[in]timeouttimeout in seconds
[out]receive_timestampreceive timestamp in seconds (ros timestamp immediately after first response byte received)
Returns
true on success, false on failure

Definition at line 166 of file cola_transmitter.cpp.

◆ runReceiverThreadCb()

void sick_scan::ColaTransmitter::runReceiverThreadCb ( void  )
protected

Thread callback, receives response telegrams from localization server and pushes them to m_response_fifo.

Definition at line 311 of file cola_transmitter.cpp.

◆ send() [1/2]

bool sick_scan::ColaTransmitter::send ( boost::asio::ip::tcp::socket &  socket,
const std::vector< uint8_t > &  data,
ROS::Time &  send_timestamp 
)
static

Send data to the localization server.

Parameters
[in]socketsocket to write to
[in]datadata to be send
[out]send_timestampsend timestamp in seconds (ros timestamp immediately before tcp send)
Returns
true on success, false on failure

Definition at line 137 of file cola_transmitter.cpp.

◆ send() [2/2]

bool sick_scan::ColaTransmitter::send ( const std::vector< uint8_t > &  data,
ROS::Time &  send_timestamp 
)
virtual

Send data to the localization server.

Parameters
[in]datadata to be send
[out]send_timestampsend timestamp in seconds (ros timestamp immediately before tcp send)
Returns
true on success, false on failure

Definition at line 125 of file cola_transmitter.cpp.

◆ startReceiverThread()

bool sick_scan::ColaTransmitter::startReceiverThread ( void  )
virtual

Starts a thread to receive response telegrams from the localization server. The receiver thread pushes responses to a fifo buffer, which can be popped by waitPopResponse().

Returns
always true

Definition at line 254 of file cola_transmitter.cpp.

◆ stopReceiverThread()

bool sick_scan::ColaTransmitter::stopReceiverThread ( void  )
virtual

Stops the thread to receive response telegrams from the localization server (if a thread has been started by startReceiverThread=.

Returns
always true

Definition at line 266 of file cola_transmitter.cpp.

◆ waitPopResponse()

bool sick_scan::ColaTransmitter::waitPopResponse ( std::vector< uint8_t > &  telegram,
double  timeout,
ROS::Time &  receive_timestamp 
)
virtual

Returns a response telegram from the localization server. This function waits with timout, until the receiver thread received a response telegram from the localization server. Note: The receiver thread must have been started by startReceiverThread(), otherwise waitPopResponse() will fail after timout.

Parameters
[out]telegramtelegram received (Cola-Binary or Cola-Ascii)
[in]timeouttimeout in seconds
[out]receive_timestampreceive timestamp in seconds (ros timestamp immediately after first response byte received)
Returns
true on success, false on failure (connection error or timeout)

Definition at line 288 of file cola_transmitter.cpp.

Member Data Documentation

◆ m_ioservice

boost::asio::io_service sick_scan::ColaTransmitter::m_ioservice
protected

boost io service for tcp connections

Definition at line 192 of file cola_transmitter.h.

◆ m_receive_timeout

double sick_scan::ColaTransmitter::m_receive_timeout
protected

default timeout in seconds for receive functions

Definition at line 194 of file cola_transmitter.h.

◆ m_receiver_thread

boost::thread* sick_scan::ColaTransmitter::m_receiver_thread
protected

thread to receive responses from localization server

Definition at line 196 of file cola_transmitter.h.

◆ m_receiver_thread_running

bool sick_scan::ColaTransmitter::m_receiver_thread_running
protected

true: m_receiver_thread is running, otherwise false

Definition at line 195 of file cola_transmitter.h.

◆ m_response_fifo

sick_scan::FifoBuffer<ColaResponseContainer, boost::mutex> sick_scan::ColaTransmitter::m_response_fifo
protected

fifo buffer for receiver thread for responses from localization server

Definition at line 197 of file cola_transmitter.h.

◆ m_server_adress

std::string sick_scan::ColaTransmitter::m_server_adress
protected

ip adress of the localization controller, default: 192.168.0.1

Definition at line 190 of file cola_transmitter.h.

◆ m_tcp_port

int sick_scan::ColaTransmitter::m_tcp_port
protected

tcp port of the localization controller, default: 2111 for command requests and 2112 for command responses

Definition at line 191 of file cola_transmitter.h.

◆ m_tcp_socket

sick_scan::ClientSocket sick_scan::ColaTransmitter::m_tcp_socket
protected

tcp socket connected to the localization controller

Definition at line 193 of file cola_transmitter.h.


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


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19