#include <TCPDevice.hpp>
Public Types | |
typedef boost::function< void(TCONMsgPtr)> | FunctorType |
typedef std::map< int, FunctorType > | HandlerMap |
Public Member Functions | |
void | registerHandlers (const HandlerMap &map) |
void | send (TCONMsgPtr message) |
TCPDevice (const std::string &address, uint32_t port, uint8_t device=Nodes::USBL, uint8_t app_class=TCPRequest::atAMNAV, uint8_t priority=129) | |
~TCPDevice () | |
Private Types | |
enum | { Sync, Header, Data } |
enum | { ringBufferSize = 7 } |
Private Member Functions | |
void | _setup () |
void | onData (const boost::system::error_code &error, std::size_t bytes_transferred) |
void | onHeader (StreamPtr data, const boost::system::error_code &error, std::size_t bytes_transferred) |
void | onSync (const boost::system::error_code &error, std::size_t bytes_transferred) |
void | registerDevice (bool register=true) |
void | start_receive (uint8_t state) |
Private Attributes | |
std::string | address |
uint8_t | app_class |
uint8_t | device |
HandlerMap | handlers |
boost::asio::streambuf | input |
boost::asio::io_service | io |
uint32_t | port |
uint8_t | priority |
std::vector< uint8_t > | ringBuffer |
boost::thread | service |
boost::asio::ip::tcp::socket | socket |
typedef boost::function<void (TCONMsgPtr)> labust::tritech::TCPDevice::FunctorType |
The functor typedef.
Definition at line 118 of file TCPDevice.hpp.
typedef std::map<int,FunctorType> labust::tritech::TCPDevice::HandlerMap |
The handler typedef.
Definition at line 122 of file TCPDevice.hpp.
anonymous enum [private] |
Definition at line 112 of file TCPDevice.hpp.
anonymous enum [private] |
Definition at line 113 of file TCPDevice.hpp.
TCPDevice::TCPDevice | ( | const std::string & | address, |
uint32_t | port, | ||
uint8_t | device = Nodes::USBL , |
||
uint8_t | app_class = TCPRequest::atAMNAV , |
||
uint8_t | priority = 129 |
||
) |
Default constructor with specified portname and baud rate.
Definition at line 52 of file TCPDevice.cpp.
Generic destructor.
Definition at line 69 of file TCPDevice.cpp.
void TCPDevice::_setup | ( | ) | [private] |
Setup the TCP/IP connection.
Added on 17.06.2013. to avoid waiting for seanet to start.
Definition at line 80 of file TCPDevice.cpp.
void labust::tritech::TCPDevice::onData | ( | const boost::system::error_code & | error, |
std::size_t | bytes_transferred | ||
) | [private] |
Handle data message.
void TCPDevice::onHeader | ( | StreamPtr | data, |
const boost::system::error_code & | error, | ||
std::size_t | bytes_transferred | ||
) | [private] |
Handle next incoming header.
Definition at line 229 of file TCPDevice.cpp.
void TCPDevice::onSync | ( | const boost::system::error_code & | error, |
std::size_t | bytes_transferred | ||
) | [private] |
Handles synchronization.
Definition at line 164 of file TCPDevice.cpp.
void TCPDevice::registerDevice | ( | bool | register = true | ) | [private] |
Register the device at TCP/IP.
Definition at line 114 of file TCPDevice.cpp.
void labust::tritech::TCPDevice::registerHandlers | ( | const HandlerMap & | map | ) | [inline] |
The method registers the handler.
Definition at line 143 of file TCPDevice.hpp.
void TCPDevice::send | ( | TCONMsgPtr | message | ) |
The method sends the buffer content to the device.
Definition at line 312 of file TCPDevice.cpp.
void TCPDevice::start_receive | ( | uint8_t | state | ) | [private] |
Start async_reads based on current state.
Definition at line 147 of file TCPDevice.cpp.
std::string labust::tritech::TCPDevice::address [private] |
The remote host address.
Definition at line 185 of file TCPDevice.hpp.
uint8_t labust::tritech::TCPDevice::app_class [private] |
Definition at line 209 of file TCPDevice.hpp.
uint8_t labust::tritech::TCPDevice::device [private] |
Device registarion.
Definition at line 209 of file TCPDevice.hpp.
The handler map.
Definition at line 205 of file TCPDevice.hpp.
boost::asio::streambuf labust::tritech::TCPDevice::input [private] |
The input buffer.
Definition at line 193 of file TCPDevice.hpp.
boost::asio::io_service labust::tritech::TCPDevice::io [private] |
IO service
Definition at line 177 of file TCPDevice.hpp.
uint32_t labust::tritech::TCPDevice::port [private] |
The remote port.
Definition at line 189 of file TCPDevice.hpp.
uint8_t labust::tritech::TCPDevice::priority [private] |
Definition at line 209 of file TCPDevice.hpp.
The header ring buffer.
Definition at line 197 of file TCPDevice.hpp.
boost::thread labust::tritech::TCPDevice::service [private] |
The runner thread.
Definition at line 201 of file TCPDevice.hpp.
boost::asio::ip::tcp::socket labust::tritech::TCPDevice::socket [private] |
Serial port.
Definition at line 181 of file TCPDevice.hpp.