Skip to content

Commit 1a542a3

Browse files
author
SzabolcsGergely
committed
Merge remote-tracking branch 'origin/crash_dump' into HEAD
2 parents 62c276f + de15c27 commit 1a542a3

File tree

6 files changed

+69
-2
lines changed

6 files changed

+69
-2
lines changed

cmake/Depthai/DepthaiDeviceSideConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")
33

44
# "full commit hash of device side binary"
5-
set(DEPTHAI_DEVICE_SIDE_COMMIT "78ba554b106d7eb2baca2f7a2770ed1f312811aa")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "143e162f9adb251d0875d91ed6835ce52663ef54")
66

77
# "version if applicable"
88
set(DEPTHAI_DEVICE_SIDE_VERSION "")

examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,6 @@ dai_add_example(apriltag_rgb AprilTag/apriltag_rgb.cpp ON)
359359
# DetectionParser
360360
dai_add_example(detection_parser NeuralNetwork/detection_parser.cpp ON)
361361
target_compile_definitions(detection_parser PRIVATE BLOB_PATH="${mobilenet_blob}")
362+
363+
# DetectionParser
364+
dai_add_example(crash_report CrashReport/crash_report.cpp OFF)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <fstream>
2+
#include <iostream>
3+
4+
// Includes common necessary includes for development using depthai library
5+
#include "depthai/depthai.hpp"
6+
7+
static bool fileExists(dai::Path path) {
8+
std::ifstream file(path);
9+
return file.is_open();
10+
}
11+
12+
int main() {
13+
using namespace std;
14+
15+
// Connect to device and start pipeline
16+
dai::Device device;
17+
if(device.hasCrashDump()) {
18+
auto crashDump = device.getCrashDump();
19+
std::string commitHash = crashDump.depthaiCommitHash;
20+
std::string deviceId = crashDump.deviceId;
21+
22+
auto json = crashDump.serializeToJson();
23+
24+
for(int i = 0;; i++) {
25+
dai::Path destPath = "crashDump_" + to_string(i) + "_" + deviceId + "_" + commitHash + ".json";
26+
if(fileExists(destPath)) continue;
27+
28+
std::ofstream ob(destPath);
29+
ob << std::setw(4) << json << std::endl;
30+
31+
std::cout << "Crash dump found on your device!" << std::endl;
32+
std::cout << "Saved to " << std::string(destPath) << std::endl;
33+
std::cout << "Please report to developers!" << std::endl;
34+
break;
35+
}
36+
} else {
37+
std::cout << "There was no crash dump found on your device!" << std::endl;
38+
}
39+
40+
return 0;
41+
}

include/depthai/device/DeviceBase.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "depthai-shared/common/CpuUsage.hpp"
3131
#include "depthai-shared/common/MemoryInfo.hpp"
3232
#include "depthai-shared/device/BoardConfig.hpp"
33+
#include "depthai-shared/device/CrashDump.hpp"
3334
#include "depthai-shared/log/LogLevel.hpp"
3435
#include "depthai-shared/log/LogMessage.hpp"
3536

@@ -450,6 +451,16 @@ class DeviceBase {
450451
*/
451452
std::vector<std::tuple<std::string, int, int>> getIrDrivers();
452453

454+
/**
455+
* Retrieves crash dump for debugging.
456+
*/
457+
dai::CrashDump getCrashDump();
458+
459+
/**
460+
* Retrieves whether the is crash dump stored on device or not.
461+
*/
462+
bool hasCrashDump();
463+
453464
/**
454465
* Add a callback for device logging. The callback will be called from a separate thread with the LogMessage being passed.
455466
*

src/device/DeviceBase.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "depthai-bootloader-shared/Bootloader.hpp"
88
#include "depthai-bootloader-shared/XLinkConstants.hpp"
99
#include "depthai-shared/datatype/RawImgFrame.hpp"
10+
#include "depthai-shared/device/CrashDump.hpp"
1011
#include "depthai-shared/log/LogConstants.hpp"
1112
#include "depthai-shared/log/LogLevel.hpp"
1213
#include "depthai-shared/log/LogMessage.hpp"
@@ -965,6 +966,17 @@ std::vector<std::tuple<std::string, int, int>> DeviceBase::getIrDrivers() {
965966
return pimpl->rpcClient->call("getIrDrivers");
966967
}
967968

969+
dai::CrashDump DeviceBase::getCrashDump() {
970+
checkClosed();
971+
972+
return pimpl->rpcClient->call("getCrashDump").as<dai::CrashDump>();
973+
}
974+
975+
bool DeviceBase::hasCrashDump() {
976+
dai::CrashDump crashDump = getCrashDump();
977+
return !crashDump.crashReports.empty();
978+
}
979+
968980
int DeviceBase::addLogCallback(std::function<void(LogMessage)> callback) {
969981
checkClosed();
970982

0 commit comments

Comments
 (0)