FwLogsThread.java
Go to the documentation of this file.
1 package com.intel.realsense.camera;
2 
3 import android.util.Log;
4 
12 
13 public class FwLogsThread extends Thread{
14  private static final String TAG = "librs_fwLogsThread";
16  private volatile boolean mAreFwLogsRequested;
18  private boolean mIsParsingFileInitialized = false;
19  private boolean mAllFlashLogsAlreadyPulled = false;
20 
21  @Override
22  public void run() {
23  mAreFwLogsRequested = true;
24  try(RsContext ctx = new RsContext()) {
25  try (DeviceList devices = ctx.queryDevices()) {
26  if (devices.getDeviceCount() > 0) {
27  // only device 0 is taken care of, as the camera app is supposed to work only with one device
28  try (Device device = devices.createDevice(0)) {
29  if (device != null) {
30  try (final FwLogger fwLoggerDevice = device.as(Extension.FW_LOGGER)) {
31  mFwLoggerDevice = fwLoggerDevice;
32  if (mFwLogsParsingFilePath != "")
33  mIsParsingFileInitialized = mFwLoggerDevice.initParser(mFwLogsParsingFilePath);
34  while (mAreFwLogsRequested) {
35  String logReceived = "";
36  try (FwLogMsg logMsg = mFwLoggerDevice.getFwLog()) {
37  if (mFwLoggerDevice.getFwLogPullingStatus()) {
38  if (mIsParsingFileInitialized) {
39  try (FwLogParsedMsg parsedMsg = mFwLoggerDevice.parseFwLog(logMsg)) {
40  logReceived = parsedMsg.getTimestamp() + " - " +
41  parsedMsg.getSeverity() + " " +
42  parsedMsg.getFileName() + " " +
43  parsedMsg.getLine() + " " +
44  parsedMsg.getThreadName() + " " +
45  parsedMsg.getMessage();
46  Log.d(TAG, logReceived);
47  }
48  } else {
49  logReceived = logMsg.getTimestamp() + " " +
50  logMsg.getSeverityStr() + " ";
51  int logMsgSize = logMsg.getSize();
52  byte[] buffer = new byte[logMsgSize];
53  buffer = logMsg.getData(buffer);
54  for (byte b : buffer) {
55  logReceived += String.format("%02X", b) + " ";
56  }
57  Log.d(TAG, logReceived);
58  }
59  }
60  }
61  }
62  }
63  }
64  }
65  }
66  }
67  }
68  }
69 
70  public void init(String fw_logging_file_path)
71  {
72  mFwLogsParsingFilePath = fw_logging_file_path;
73  }
74 
75 
76  public void stopLogging()
77  {
78  mAreFwLogsRequested = false;
79  }
80 
81  public void getFwLogsFromFlash()
82  {
83  if(!mAllFlashLogsAlreadyPulled){
84  try(RsContext ctx = new RsContext()){
85  try(DeviceList devices = ctx.queryDevices()) {
86  if (devices.getDeviceCount() > 0) {
87  // only device 0 is taken care of, as the camera app is supposed to work only with one device
88  try (Device device = devices.createDevice(0)) {
89  if(device != null) {
90  try(final FwLogger fwLoggerDevice = device.as(Extension.FW_LOGGER)){
91  mFwLoggerDevice = fwLoggerDevice;
92  if (mFwLogsParsingFilePath != "")
93  mIsParsingFileInitialized = mFwLoggerDevice.initParser(mFwLogsParsingFilePath);
94  Log.d(TAG, "-------------------flash logs retrieval--------------------");
95  while (true) {
96  String logReceived = "";
97  try (FwLogMsg logMsg = mFwLoggerDevice.getFwLogsFromFlash()) {
98  if (mFwLoggerDevice.getFwLogPullingStatus()) {
99  if (mIsParsingFileInitialized) {
100  try (FwLogParsedMsg parsedMsg = mFwLoggerDevice.parseFwLog(logMsg)) {
101  logReceived = parsedMsg.getTimestamp() + " - " +
102  parsedMsg.getSeverity() + " " +
103  parsedMsg.getFileName() + " " +
104  parsedMsg.getLine() + " " +
105  parsedMsg.getThreadName() + " " +
106  parsedMsg.getMessage();
107  Log.d(TAG, logReceived);
108  }
109  } else {
110  logReceived = logMsg.getTimestamp() + " " +
111  logMsg.getSeverityStr() + " ";
112  int logMsgSize = logMsg.getSize();
113  byte[] buffer = new byte[logMsgSize];
114  buffer = logMsg.getData(buffer);
115  for (byte b : buffer) {
116  logReceived += String.format("%02X", b) + " ";
117  }
118  Log.d(TAG, logReceived);
119  }
120  }
121  else {
122  Log.d(TAG, "No more fw logs in flash");
123  mAllFlashLogsAlreadyPulled = true;
124  break;
125  }
126  }
127  }
128  Log.d(TAG, "-------------------flash logs finished--------------------");
129  }
130  }
131  }
132  }
133  }
134  }
135  }
136  else {
137  Log.d(TAG, "Flash logs already pulled");
138  }
139  }
140 }
GLboolean GLboolean GLboolean b
::rosgraph_msgs::Log_< std::allocator< void > > Log
Definition: Log.h:88
FwLogParsedMsg parseFwLog(FwLogMsg msg)
Definition: FwLogger.java:53
GLenum GLfloat * buffer
::std_msgs::String_< std::allocator< void > > String
Definition: String.h:47
boolean initParser(String xml_path)
Definition: FwLogger.java:18
devices
Definition: test-fg.py:9
unsigned char byte
Definition: src/types.h:52
void init(String fw_logging_file_path)
auto device
Definition: pyrs_net.cpp:17
Definition: threads.c:40


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