12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /*************************
- sick 511 雷达 tcp协议连接控制板
- *************************/
- #pragma once
- #include "Laser.h"
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <mutex>
- #define LASER_DATA_TIME_OUT 10000
- class CTcpLaser :
- public CLaser
- {
- public:
- CTcpLaser(int id, Automatic::stLaserCalibParam laser_param);
- ~CTcpLaser();
- virtual bool Connect();
- virtual void Disconnect();
- virtual bool Start();
- virtual bool Stop();
- protected:
- virtual bool RecvData(CBinaryData& data);
- virtual DATA_type Data2PointXYZ(CBinaryData* pData, std::vector<CPoint3D>& points);
- private:
- bool Send(char* sendbuf, int len); // 发送指令
- int Recv(char* recvbuf, int len); // 接收数据
- static int FindHead(char* buf, int b_len);
- static int FindTail(char* buf, int b_len);
- private:
- bool GetData(CBinaryData* pData, std::vector<float>& distance,
- float& freq, float& start_angle);
- long Str0x2Long(const char* data, int len);
- private:
- #pragma region udp相关变量
- int m_socket;
- //WSADATA m_wsd;
- struct sockaddr_in m_send_addr;
- std::mutex m_mutex;
- clock_t m_last_data_time;
- #pragma endregion
- };
|