49 std::function<
void(
const std::vector<uint8_t>&)> receive_callback):
50 m_socket(socket.sensor_socket),
53 m_incoming_buffer(max_mtu, 0),
54 m_receive_callback(receive_callback)
79 struct timeval tv = {0, 200000};
82 const int result = select(1, &read_set, NULL, NULL, &tv);
84 const int result = select(
m_socket + 1, &read_set, NULL, NULL, &tv);
99 #if defined(WIN32) && !defined(__MINGW64__)
100 #pragma warning (push)
101 #pragma warning (disable : 4267)
103 const int bytes_read = recvfrom(
m_socket,
107 #if defined(WIN32) && !defined(__MINGW64__)
108 #pragma warning (pop)
122 catch (
const std::exception& e)
125 CRL_DEBUG(
"exception while decoding packet: %s\n", e.what());
140 #if defined(WIN32) && !defined(__MINGW64__)
141 #pragma warning (push)
142 #pragma warning (disable : 4267)
145 const auto ret = sendto(socket.
sensor_socket, (
char*) data.data(), data.size(), 0,
146 (
struct sockaddr *) raw_address,
147 sizeof(*raw_address));
148 #if defined(WIN32) && !defined(__MINGW64__)
149 #pragma warning (pop)
152 if (
static_cast<size_t>(ret) != data.size())
154 CRL_EXCEPTION(
"error sending data to sensor, %d/%d bytes written: %s",
155 ret, data.size(), strerror(errno));