diff --git a/src/mynteye/device/channel/channels.cc b/src/mynteye/device/channel/channels.cc index e789bdf..34af9fc 100644 --- a/src/mynteye/device/channel/channels.cc +++ b/src/mynteye/device/channel/channels.cc @@ -111,6 +111,7 @@ Channels::Channels(const std::shared_ptr &device, : device_(device), adapter_(adapter), is_imu_tracking_(false), + is_imu_proto2_(false), imu_track_stop_(false), imu_sn_(0), imu_callback_(nullptr), @@ -378,8 +379,7 @@ void Channels::SetImuCallback(imu_callback_t callback) { } void Channels::DoImuTrack() { - if (dev_info_->firmware_version >= Version(2, 0) && - strstr(dev_info_->name.c_str(), "S2") != nullptr ) { + if (IsImuProc2()) { return DoImuTrack2(); } else { return DoImuTrack1(); @@ -499,8 +499,7 @@ void Channels::StartImuTracking(imu_callback_t callback) { << ", sleep " << (IMU_TRACK_PERIOD - time_elapsed_ms) << " ms"; } }; - if (dev_info_->firmware_version >= Version(2, 0) && - strstr(dev_info_->name.c_str(), "S2") != nullptr ) { + if (IsImuProc2()) { while (!imu_track_stop_) { auto &&time_beg = times::now(); DoImuTrack2(); @@ -588,6 +587,9 @@ bool Channels::GetFiles( << "The firmware not support getting device info, you could " "upgrade to latest"; dev_info_ = std::make_shared(*info); + is_imu_proto2_ = dev_info_ && + dev_info_->firmware_version >= Version(2, 0) && + strstr(dev_info_->name.c_str(), "S2") != nullptr; } break; case FID_IMG_PARAMS: { if (file_size > 0) { diff --git a/src/mynteye/device/channel/channels.h b/src/mynteye/device/channel/channels.h index d0ab377..20c6e38 100644 --- a/src/mynteye/device/channel/channels.h +++ b/src/mynteye/device/channel/channels.h @@ -89,6 +89,7 @@ class MYNTEYE_API Channels { device_info_t *info, img_params_t *img_params, imu_params_t *imu_params); bool SetFiles( device_info_t *info, img_params_t *img_params, imu_params_t *imu_params); + inline bool IsImuProc2() const { return is_imu_proto2_; } private: bool PuControlRange( @@ -132,6 +133,7 @@ class MYNTEYE_API Channels { std::map control_infos_; bool is_imu_tracking_; + bool is_imu_proto2_; std::thread imu_track_thread_; volatile bool imu_track_stop_;