firmware_logger_device.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
5 #include <string>
6 
7 namespace librealsense
8 {
11  std::shared_ptr<hw_monitor> hardware_monitor,
12  const command& fw_logs_command, const command& flash_logs_command) :
13  device(ctx, group),
14  _hw_monitor(hardware_monitor),
15  _fw_logs(),
16  _flash_logs(),
17  _flash_logs_initialized(false),
18  _parser(nullptr),
19  _fw_logs_command(fw_logs_command),
20  _flash_logs_command(flash_logs_command) { }
21 
23  {
24  bool result = false;
25  if (_fw_logs.empty())
26  {
28  }
29 
30  if (!_fw_logs.empty())
31  {
33  data = _fw_logs.front();
34  _fw_logs.pop();
35  binary_data = data;
36  result = true;
37  }
38  return result;
39  }
40 
42  {
43  return (unsigned int)_fw_logs.size();
44  }
45 
47  {
48  auto res = _hw_monitor->send(_fw_logs_command);
49  if (res.empty())
50  {
51  return;
52  }
53 
54  auto beginOfLogIterator = res.begin();
55  // convert bytes to fw_logs_binary_data
56  for (int i = 0; i < res.size() / fw_logs::BINARY_DATA_SIZE; ++i)
57  {
58  auto endOfLogIterator = beginOfLogIterator + fw_logs::BINARY_DATA_SIZE;
59  std::vector<uint8_t> resultsForOneLog;
60  resultsForOneLog.insert(resultsForOneLog.begin(), beginOfLogIterator, endOfLogIterator);
61  fw_logs::fw_logs_binary_data binary_data{ resultsForOneLog };
62  _fw_logs.push(binary_data);
63  beginOfLogIterator = endOfLogIterator;
64  }
65  }
66 
68  {
69  auto res = _hw_monitor->send(_flash_logs_command);
70 
71  if (res.empty())
72  {
73  LOG_INFO("Getting Flash logs failed!");
74  return;
75  }
76 
77  //erasing header
78  int size_of_flash_logs_header = 27;
79  res.erase(res.begin(), res.begin() + size_of_flash_logs_header);
80 
81  auto beginOfLogIterator = res.begin();
82  // convert bytes to flash_logs_binary_data
83  for (int i = 0; i < res.size() / fw_logs::BINARY_DATA_SIZE && *beginOfLogIterator == 160; ++i)
84  {
85  auto endOfLogIterator = beginOfLogIterator + fw_logs::BINARY_DATA_SIZE;
86  std::vector<uint8_t> resultsForOneLog;
87  resultsForOneLog.insert(resultsForOneLog.begin(), beginOfLogIterator, endOfLogIterator);
88  fw_logs::fw_logs_binary_data binary_data{ resultsForOneLog };
89  _flash_logs.push(binary_data);
90  beginOfLogIterator = endOfLogIterator;
91  }
92 
94  }
95 
97  {
98  bool result = false;
100  {
102  }
103 
104  if (!_flash_logs.empty())
105  {
107  data = _flash_logs.front();
108  _flash_logs.pop();
109  binary_data = data;
110  result = true;
111  }
112  return result;
113  }
114 
116  {
117  _parser = new fw_logs::fw_logs_parser(xml_content);
118 
119  return (_parser != nullptr);
120  }
121 
123  fw_logs::fw_log_data* parsed_msg)
124  {
125  bool result = false;
126  if (_parser && parsed_msg && fw_log_msg)
127  {
128  *parsed_msg = _parser->parse_fw_log(fw_log_msg);
129  result = true;
130  }
131 
132  return result;
133  }
134 
135 }
bool parse_log(const fw_logs::fw_logs_binary_data *fw_log_msg, fw_logs::fw_log_data *parsed_msg) override
bool get_fw_log(fw_logs::fw_logs_binary_data &binary_data) override
static const int BINARY_DATA_SIZE
std::queue< fw_logs::fw_logs_binary_data > _flash_logs
GLsizei const GLchar *const * string
bool init_parser(std::string xml_content) override
unsigned int get_number_of_fw_logs() const override
fw_log_data parse_fw_log(const fw_logs_binary_data *fw_log_msg)
GLboolean GLuint group
Definition: glext.h:5688
std::shared_ptr< hw_monitor > _hw_monitor
LOG_INFO("Log message using LOG_INFO()")
firmware_logger_device(std::shared_ptr< context > ctx, const platform::backend_device_group group, std::shared_ptr< hw_monitor > hardware_monitor, const command &fw_logs_command, const command &flash_logs_command)
int i
GLuint res
Definition: glext.h:8856
GLboolean * data
bool get_flash_log(fw_logs::fw_logs_binary_data &binary_data) override
GLuint64EXT * result
Definition: glext.h:10921
std::queue< fw_logs::fw_logs_binary_data > _fw_logs


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:14