target_sensor_enumerator.cpp
Go to the documentation of this file.
1 /*
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2019, Analog Devices, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
35 #include <algorithm>
36 #include <fstream>
37 
38 #ifdef USE_GLOG
39 #include <glog/logging.h>
40 #else
41 #include <aditof/log.h>
42 #endif
43 
44 using namespace aditof;
45 
47  std::vector<std::shared_ptr<DepthSensorInterface>> &depthSensors) {
48 
49  depthSensors.clear();
50 
51  for (const auto &sInfo : m_sensorsInfo) {
52  switch (sInfo.sensorType) {
53  case SensorType::SENSOR_ADSD3500: {
54  auto sensor = std::make_shared<Adsd3500Sensor>(
55  sInfo.driverPath, sInfo.subDevPath, sInfo.captureDev);
56  depthSensors.emplace_back(sensor);
57 
58  auto &interruptNotifier = Adsd3500InterruptNotifier::getInstance();
59  interruptNotifier.enableInterrupts(); // TO DO: refactor this!
60 
61  break;
62  }
63  }
64  }
65 
66  return Status::OK;
67 }
68 
70  const std::string &component) const {
71  std::string versionsFilePath = "/boot/sw-versions";
72  std::ifstream fid;
73  std::string line;
75 
76  fid.open(versionsFilePath);
77  if (fid.is_open()) {
78  while (fid) {
79  std::getline(fid, line);
80  if (!line.compare(0, component.length(), component)) {
81  version = line.substr(component.length());
82  version.erase(std::remove(version.begin(), version.end(), '\t'),
83  version.end());
84  break;
85  }
86  }
87  fid.close();
88  } else {
89  LOG(ERROR) << "Failed to open file" << versionsFilePath;
90  }
91 
92  return version;
93 }
94 
97 
98  uBootVersion = getVersionOfComponent("u-boot");
99  if (uBootVersion.empty()) {
100  LOG(ERROR) << "Could not find version for u-boot";
102  }
103 
104  return aditof::Status::OK;
105 }
106 
109 
110  kernelVersion = getVersionOfComponent("kernel");
111  if (kernelVersion.empty()) {
112  LOG(ERROR) << "Could not find version for u-boot";
114  }
115 
116  return aditof::Status::OK;
117 }
118 
121 
122  sdVersion = getVersionOfComponent("sd_img_ver");
123  if (sdVersion.empty()) {
124  LOG(ERROR) << "Could not find version for u-boot";
126  }
127 
128  return aditof::Status::OK;
129 }
Adsd3500InterruptNotifier::getInstance
static Adsd3500InterruptNotifier & getInstance()
Definition: adsd3500_interrupt_notifier.cpp:24
ERROR
const int ERROR
Definition: log_severity.h:60
TargetSensorEnumerator::getKernelVersion
virtual aditof::Status getKernelVersion(std::string &kernelVersion) const override
Get the kernel version that is installed on the embedded system that the camera is attached to.
Definition: target_sensor_enumerator.cpp:108
log.h
TargetSensorEnumerator::getUbootVersion
virtual aditof::Status getUbootVersion(std::string &uBootVersion) const override
Get the U-Boot version that is installed on the embedded system that the camera is attached to.
Definition: target_sensor_enumerator.cpp:96
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
aditof
Namespace aditof.
Definition: adsd_errs.h:40
TargetSensorEnumerator::getVersionOfComponent
std::string getVersionOfComponent(const std::string &component) const
Definition: target_sensor_enumerator.cpp:69
adsd3500_sensor.h
aditof::Status::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Invalid arguments provided.
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
LOG
#define LOG(x)
Definition: sdk/include/aditof/log.h:72
TargetSensorEnumerator::getDepthSensors
virtual aditof::Status getDepthSensors(std::vector< std::shared_ptr< aditof::DepthSensorInterface >> &depthSensors) override
Definition: target_sensor_enumerator.cpp:46
TargetSensorEnumerator::getSdVersion
virtual aditof::Status getSdVersion(std::string &sdVersion) const override
Get the SD card image version on the embedded system that the camera is attached to.
Definition: target_sensor_enumerator.cpp:120
aditof::Status::OK
@ OK
Success.
adsd3500_interrupt_notifier.h
target_sensor_enumerator.h
version
static struct @0 version


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:59