diff --git a/src/device/device.cc b/src/device/device.cc index e6a2542..cc4d2b8 100644 --- a/src/device/device.cc +++ b/src/device/device.cc @@ -252,7 +252,7 @@ MotionIntrinsics Device::GetMotionIntrinsics(bool *ok) const { return *motion_intrinsics_; } else { *ok = false; - LOG(WARNING) << "Motion intrinsics not found"; + VLOG(2) << "Motion intrinsics not found"; return {}; } } @@ -263,7 +263,7 @@ Extrinsics Device::GetMotionExtrinsics(const Stream &from, bool *ok) const { return motion_from_extrinsics_.at(from); } catch (const std::out_of_range &e) { *ok = false; - LOG(WARNING) << "Motion extrinsics from " << from << " not found"; + VLOG(2) << "Motion extrinsics from " << from << " not found"; return {}; } } @@ -580,7 +580,7 @@ void Device::ReadAllInfos() { VLOG(2) << "Motion extrinsics left to imu: {" << GetMotionExtrinsics(Stream::LEFT) << "}"; } else { - LOG(WARNING) << "Motion intrinsics & extrinsics not exist"; + VLOG(2) << "Motion intrinsics & extrinsics not exist"; } } diff --git a/src/internal/streams.cc b/src/internal/streams.cc index 4b049e3..97ae970 100644 --- a/src/internal/streams.cc +++ b/src/internal/streams.cc @@ -50,9 +50,9 @@ bool unpack_stereo_img_data( // << ", checksum=0x" << std::hex << static_cast(img_packet.checksum); if (img_packet.header != 0x3B) { - LOG(WARNING) << "Image packet header must be 0x3B, but 0x" << std::hex - << std::uppercase << std::setw(2) << std::setfill('0') - << static_cast(img_packet.header) << " now"; + VLOG(2) << "Image packet header must be 0x3B, but 0x" << std::hex + << std::uppercase << std::setw(2) << std::setfill('0') + << static_cast(img_packet.header) << " now"; return false; } @@ -61,11 +61,11 @@ bool unpack_stereo_img_data( checksum = (checksum ^ packet[i]); } if (img_packet.checksum != checksum) { - LOG(WARNING) << "Image packet checksum should be 0x" << std::hex - << std::uppercase << std::setw(2) << std::setfill('0') - << static_cast(img_packet.checksum) << ", but 0x" - << std::setw(2) << std::setfill('0') - << static_cast(checksum) << " now"; + VLOG(2) << "Image packet checksum should be 0x" << std::hex + << std::uppercase << std::setw(2) << std::setfill('0') + << static_cast(img_packet.checksum) << ", but 0x" + << std::setw(2) << std::setfill('0') << static_cast(checksum) + << " now"; return false; } @@ -160,7 +160,7 @@ bool Streams::PushStream(const Capabilities &capability, const void *data) { } else { // discard left DiscardStreamData(Stream::LEFT); - LOG(WARNING) << "Image packet is unaccepted, frame dropped"; + VLOG(2) << "Image packet is unaccepted, frame dropped"; pushed = false; } } break; diff --git a/src/uvc/uvc-v4l2.cc b/src/uvc/uvc-v4l2.cc index a064552..06fc8fc 100755 --- a/src/uvc/uvc-v4l2.cc +++ b/src/uvc/uvc-v4l2.cc @@ -41,6 +41,10 @@ namespace uvc { LOG(severity) << str << " error " << errno << ", " << strerror(errno); \ } while (0) +#define NO_DATA_MAX_COUNT 200 + +int no_data_count = 0; + /* class device_error : public std::exception { public: @@ -194,6 +198,7 @@ struct device { ~device() { VLOG(2) << __func__; stop_streaming(); + no_data_count = 0; if (fd != -1 && close(fd) < 0) { LOG_ERROR(WARNING, "close"); } @@ -386,6 +391,14 @@ struct device { throw_error("VIDIOC_QBUF"); }); } + + no_data_count = 0; + } else { + no_data_count++; + } + + if (no_data_count > NO_DATA_MAX_COUNT) { + throw_error("v4l2 get stream time out!"); } }