feat(api): version check
This commit is contained in:
parent
23d77d0de3
commit
262f64715d
|
@ -14,7 +14,7 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(mynteye VERSION 2.3.0 LANGUAGES C CXX)
|
||||
project(mynteye VERSION 2.3.1 LANGUAGES C CXX)
|
||||
|
||||
include(cmake/Common.cmake)
|
||||
|
||||
|
@ -220,6 +220,7 @@ if(WITH_API)
|
|||
src/mynteye/api/processor/rectify_processor_ocv.cc
|
||||
src/mynteye/api/config.cc
|
||||
src/mynteye/api/correspondence.cc
|
||||
src/mynteye/api/version_checker.cc
|
||||
)
|
||||
if(WITH_CAM_MODELS)
|
||||
list(APPEND MYNTEYE_SRCS
|
||||
|
|
|
@ -122,6 +122,8 @@ enum class Info : std::uint8_t {
|
|||
IMU_TYPE,
|
||||
/** Nominal baseline */
|
||||
NOMINAL_BASELINE,
|
||||
/** SDK version*/
|
||||
SDK_VERSION,
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "mynteye/api/dl.h"
|
||||
#include "mynteye/api/plugin.h"
|
||||
#include "mynteye/api/synthetic.h"
|
||||
#include "mynteye/api/version_checker.h"
|
||||
#include "mynteye/device/device.h"
|
||||
#include "mynteye/device/utils.h"
|
||||
|
||||
|
@ -222,7 +223,10 @@ API::~API() {
|
|||
std::shared_ptr<API> API::Create(int argc, char *argv[]) {
|
||||
auto &&device = device::select();
|
||||
if (!device) return nullptr;
|
||||
return Create(argc, argv, device);
|
||||
auto api = Create(argc, argv, device);
|
||||
if (api && checkFirmwareVersion(api))
|
||||
return api;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(
|
||||
|
@ -261,7 +265,7 @@ std::shared_ptr<API> API::Create(const std::shared_ptr<Device> &device) {
|
|||
}
|
||||
} else {
|
||||
LOG(ERROR) <<"no device!";
|
||||
api = std::make_shared<API>(device, CalibrationModel::UNKNOW);
|
||||
return nullptr;
|
||||
}
|
||||
return api;
|
||||
}
|
||||
|
@ -324,6 +328,22 @@ std::shared_ptr<DeviceInfo> API::GetInfo() const {
|
|||
}
|
||||
|
||||
std::string API::GetInfo(const Info &info) const {
|
||||
if (info == Info::SDK_VERSION) {
|
||||
std::string info_path =
|
||||
utils::get_sdk_install_dir();
|
||||
info_path.append(MYNTEYE_OS_SEP "share" \
|
||||
MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info");
|
||||
|
||||
cv::FileStorage fs(info_path, cv::FileStorage::READ);
|
||||
if (!fs.isOpened()) {
|
||||
LOG(WARNING) << "build.info not found: " << info_path;
|
||||
return "null";
|
||||
}
|
||||
std::string vs_main = fs["MYNTEYE_VERSION"];
|
||||
int vs_tweak = fs["MYNTEYE_VERSION_TWEAK"];
|
||||
return vs_main + std::string(".") + std::to_string(vs_tweak);
|
||||
}
|
||||
|
||||
return device_->GetInfo(info);
|
||||
}
|
||||
|
||||
|
|
48
src/mynteye/api/version_checker.cc
Normal file
48
src/mynteye/api/version_checker.cc
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "mynteye/api/version_checker.h"
|
||||
#include "mynteye/device/utils.h"
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/types.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
typedef struct {
|
||||
const std::string device_type;
|
||||
const std::string sdk_version;
|
||||
const std::string firmware_version;
|
||||
}firmware_version_match_table_unit;
|
||||
|
||||
/** firmware/sdk version matched table */
|
||||
static const firmware_version_match_table_unit FSVM_TABLE[] ={
|
||||
{"MYNT-EYE-S1030", "2.3.1.0", "2.0.0"},
|
||||
{"MYNT-EYE-S1030", "2.3.1.0", "2.0.0"},
|
||||
{}
|
||||
};
|
||||
|
||||
bool checkFirmwareVersion(const std::shared_ptr<API> api) {
|
||||
LOG(INFO) << "SDK version: " << api->GetInfo(Info::SDK_VERSION);
|
||||
LOG(INFO) << "Device name: " << api->GetInfo(Info::DEVICE_NAME);
|
||||
LOG(INFO) << "Serial number: " << api->GetInfo(Info::SERIAL_NUMBER);
|
||||
LOG(INFO) << "Firmware version: " << api->GetInfo(Info::FIRMWARE_VERSION);
|
||||
LOG(INFO) << "Hardware version: " << api->GetInfo(Info::HARDWARE_VERSION);
|
||||
LOG(INFO) << "Spec version: " << api->GetInfo(Info::SPEC_VERSION);
|
||||
LOG(INFO) << "Lens type: " << api->GetInfo(Info::LENS_TYPE);
|
||||
LOG(INFO) << "IMU type: " << api->GetInfo(Info::IMU_TYPE);
|
||||
LOG(INFO) << "Nominal baseline: " << api->GetInfo(Info::NOMINAL_BASELINE);
|
||||
return true;
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
25
src/mynteye/api/version_checker.h
Normal file
25
src/mynteye/api/version_checker.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef MYNTEYE_API_VERSION_CHECKER_H_
|
||||
#define MYNTEYE_API_VERSION_CHECKER_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "mynteye/api/api.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
bool checkFirmwareVersion(const std::shared_ptr<API> api);
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_API_VERSION_CHECKER_H_
|
|
@ -644,7 +644,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
|||
is_published_[stream] = false;
|
||||
}
|
||||
api_->Start(Source::VIDEO_STREAMING);
|
||||
} else if (sum_c > sum) {
|
||||
} else {
|
||||
if ((camera_publishers_[Stream::LEFT].getNumSubscribers() > 0 ||
|
||||
mono_publishers_[Stream::LEFT].getNumSubscribers() > 0) &&
|
||||
!is_published_[Stream::LEFT]) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user