Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef SICK_TIM3XX_COMMON_TCP_H
00036 #define SICK_TIM3XX_COMMON_TCP_H
00037
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040 #include <string.h>
00041
00042 #include <sick_tim3xx/sick_tim3xx_common.h>
00043 #include <boost/asio.hpp>
00044
00045 namespace sick_tim3xx
00046 {
00047
00048 class SickTim3xxCommonTcp : public SickTim3xxCommon
00049 {
00050 public:
00051 SickTim3xxCommonTcp(const std::string & hostname, AbstractParser* parser);
00052 virtual ~SickTim3xxCommonTcp();
00053
00054 protected:
00055 virtual int init_device();
00056 virtual int close_device();
00057
00059 virtual int sendSOPASCommand(const char* request, std::vector<unsigned char> * reply);
00060
00062
00067 virtual int get_datagram(unsigned char* receiveBuffer, int bufferSize, int* actual_length);
00068
00069
00070 int readWithTimeout(size_t timeout_ms, char *buffer, int buffer_size, int *bytes_read = 0, bool *exception_occured = 0);
00071 void handleRead(boost::system::error_code error, size_t bytes_transfered);
00072 void checkDeadline();
00073
00074 private:
00075 boost::asio::io_service io_service_;
00076 boost::asio::ip::tcp::socket socket_;
00077 boost::asio::deadline_timer deadline_;
00078 boost::asio::streambuf input_buffer_;
00079 boost::system::error_code ec_;
00080 size_t bytes_transfered_;
00081
00082 std::string hostname_;
00083 };
00084
00085 inline void SickTim3xxCommonTcp::handleRead(boost::system::error_code error, size_t bytes_transfered)
00086 {
00087 ec_ = error;
00088 bytes_transfered_ += bytes_transfered;
00089 }
00090
00091 }
00092 #endif
00093