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 #pragma once
00036
00037 namespace rp { namespace standalone{ namespace rplidar {
00038
00039 class TCPChannelDevice :public ChannelDevice
00040 {
00041 public:
00042 rp::net::StreamSocket * _binded_socket;
00043 TCPChannelDevice():_binded_socket(rp::net::StreamSocket::CreateSocket()){}
00044
00045 bool bind(const char * ipStr, uint32_t port)
00046 {
00047 rp::net::SocketAddress socket(ipStr, port);
00048 return IS_OK(_binded_socket->connect(socket));
00049 }
00050 void close()
00051 {
00052 _binded_socket->dispose();
00053 _binded_socket = NULL;
00054 }
00055 bool waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL)
00056 {
00057 if(returned_size)
00058 *returned_size = data_count;
00059 return (_binded_socket->waitforData(timeout) == RESULT_OK);
00060 }
00061 int senddata(const _u8 * data, size_t size)
00062 {
00063 return _binded_socket->send(data, size) ;
00064 }
00065 int recvdata(unsigned char * data, size_t size)
00066 {
00067 size_t lenRec = 0;
00068 _binded_socket->recv(data, size, lenRec);
00069 return lenRec;
00070 }
00071 };
00072
00073
00074 class RPlidarDriverTCP : public RPlidarDriverImplCommon
00075 {
00076 public:
00077
00078 RPlidarDriverTCP();
00079 virtual ~RPlidarDriverTCP();
00080 virtual u_result connect(const char * ipStr, _u32 port, _u32 flag = 0);
00081 virtual void disconnect();
00082 };
00083
00084
00085 }}}