AsyncUDPClient.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
35 #ifndef SICK_SAFETYSCANNERS_COMMUNICATION_ASYNCUDPCLIENT_H
36 #define SICK_SAFETYSCANNERS_COMMUNICATION_ASYNCUDPCLIENT_H
37 
38 #include <ros/ros.h>
39 
40 #include <functional>
41 #include <iostream>
42 
43 #include <boost/array.hpp>
44 #include <boost/asio.hpp>
45 #include <boost/cstdint.hpp>
46 #include <boost/function.hpp>
47 
49 
50 
51 namespace sick {
52 namespace communication {
53 
58 {
59 public:
63  typedef boost::function<void(const sick::datastructure::PacketBuffer&)> PacketHandler;
64 
72  AsyncUDPClient(PacketHandler packet_handler,
73  boost::asio::io_service& io_service,
74  const uint16_t& local_port = 0);
75 
79  virtual ~AsyncUDPClient();
80 
84  void runService();
85 
90  unsigned short get_local_port();
91 
92 private:
94 
95  PacketHandler m_packet_handler;
96 
97  std::shared_ptr<boost::asio::io_service::work> m_io_work_ptr;
98  boost::asio::io_service& m_io_service;
99  std::shared_ptr<boost::asio::ip::udp::socket> m_socket_ptr;
100  boost::asio::ip::udp::endpoint m_remote_endpoint;
101 
102  void startReceive();
103  void handleReceive(const boost::system::error_code& error, const std::size_t& bytes_transferred);
104 
105 
106  AsyncUDPClient(AsyncUDPClient&); // block default copy constructor
107 };
108 } // namespace communication
109 } // namespace sick
110 
111 #endif // SICK_SAFETYSCANNERS_COMMUNICATION_ASYNCUDPCLIENT_H
boost::array< uint8_t, MAXSIZE > ArrayBuffer
Typedef for an arraybuffer which can be read from the sensor.
Definition: PacketBuffer.h:67
AsyncUDPClient(PacketHandler packet_handler, boost::asio::io_service &io_service, const uint16_t &local_port=0)
Constructor of the asynchronous udp client.
An asynchronous udp client.
void handleReceive(const boost::system::error_code &error, const std::size_t &bytes_transferred)
boost::asio::ip::udp::endpoint m_remote_endpoint
void runService()
Start the listening loop for the udp data packets.
std::shared_ptr< boost::asio::ip::udp::socket > m_socket_ptr
boost::asio::io_service & m_io_service
datastructure::PacketBuffer::ArrayBuffer m_recv_buffer
boost::function< void(const sick::datastructure::PacketBuffer &)> PacketHandler
Typedef to a reference to a function. Will be used to process the incoming packets.
virtual ~AsyncUDPClient()
The destructor of the asynchronous udp client.
std::shared_ptr< boost::asio::io_service::work > m_io_work_ptr
unsigned short get_local_port()
Returns the actual port assigned to the local machine.


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Thu May 9 2019 02:41:08