35 #ifndef SICK_SAFETYSCANNERS_COMMUNICATION_ASYNCTCPCLIENT_H 36 #define SICK_SAFETYSCANNERS_COMMUNICATION_ASYNCTCPCLIENT_H 44 #include <boost/array.hpp> 45 #include <boost/asio.hpp> 46 #include <boost/cstdint.hpp> 47 #include <boost/function.hpp> 48 #include <boost/thread/condition.hpp> 49 #include <boost/thread/mutex.hpp> 54 namespace communication {
69 typedef boost::function<void(const sick::datastructure::PacketBuffer&)>
PacketHandler;
80 boost::asio::io_service& io_service,
81 const boost::asio::ip::address_v4& server_ip,
82 const uint16_t& server_port);
134 void handleReceive(
const boost::system::error_code& error,
const std::size_t& bytes_transferred);
140 const std::size_t& bytes_transferred);
145 #endif // SICK_SAFETYSCANNERS_COMMUNICATION_ASYNCTCPCLIENT_H boost::array< uint8_t, MAXSIZE > ArrayBuffer
Typedef for an arraybuffer which can be read from the sensor.
boost::mutex m_connect_mutex
boost::function< void(const sick::datastructure::PacketBuffer &)> PacketHandler
Typedef to a function referencing a packet handler. This can be passed to the class and therefore be ...
void initiateReceive()
Initiates the listening for a message from the server.
datastructure::PacketBuffer::ArrayBuffer m_recv_buffer
void doSendAndReceive(const std::vector< uint8_t > &sendBuffer)
Start a cycle of sensing a command and waiting got the return.
void handleReceive(const boost::system::error_code &error, const std::size_t &bytes_transferred)
void doConnect()
Establishes a connection from the host to the sensor.
AsyncTCPClient(const PacketHandler &packet_handler, boost::asio::io_service &io_service, const boost::asio::ip::address_v4 &server_ip, const uint16_t &server_port)
Constructor of the asynchronous tcp client.
boost::condition m_connect_condition
void handleSendAndReceive(const boost::system::error_code &error, const std::size_t &bytes_transferred)
boost::asio::io_service & m_io_service
std::thread m_service_thread
virtual ~AsyncTCPClient()
The destructor of the asynchronous tcp client.
void doDisconnect()
Disconnects the host from the sensor.
boost::asio::ip::tcp::endpoint m_remote_endpoint
std::shared_ptr< boost::asio::ip::tcp::socket > m_socket_ptr
boost::mutex m_socket_mutex
void setPacketHandler(const PacketHandler &packet_handler)
Sets the packet handler function.
A asynchronous tcp client.
std::shared_ptr< boost::asio::io_service::work > m_io_work_ptr
PacketHandler m_packet_handler