Skip to content

Commit 5d76631

Browse files
committed
Added EEPROM clear functionality
1 parent f19964a commit 5d76631

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
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 "602822fe9eaca68a72c666497dc4979b29291b3e")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "4de7b641f775805b2e0ecac098b7c728874090e8")
66

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

include/depthai/device/DeviceBase.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,24 @@ class DeviceBase {
543543
*/
544544
void flashFactoryCalibration(CalibrationHandler calibrationHandler);
545545

546+
/**
547+
* Destructive action, deletes User area EEPROM contents
548+
* Requires PROTECTED permissions
549+
*
550+
* @throws std::runtime_exception if failed to flash the calibration
551+
* @return True on successful flash, false on failure
552+
*/
553+
void flashEepromClear();
554+
555+
/**
556+
* Destructive action, deletes Factory area EEPROM contents
557+
* Requires FACTORY PROTECTED permissions
558+
*
559+
* @throws std::runtime_exception if failed to flash the calibration
560+
* @return True on successful flash, false on failure
561+
*/
562+
void flashFactoryEepromClear();
563+
546564
/**
547565
* Fetches the EEPROM data from Factory area and loads it into CalibrationHandler object
548566
*

src/device/DeviceBase.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,42 @@ std::vector<std::uint8_t> DeviceBase::readFactoryCalibrationRaw() {
10541054
return eepromDataRaw;
10551055
}
10561056

1057+
void DeviceBase::flashEepromClear() {
1058+
bool factoryPermissions = false;
1059+
bool protectedPermissions = false;
1060+
getFlashingPermissions(factoryPermissions, protectedPermissions);
1061+
spdlog::debug("Clearing User EEPROM contents. Factory permissions {}, Protected permissions {}", factoryPermissions, protectedPermissions);
1062+
1063+
if(!protectedPermissions) {
1064+
throw std::runtime_error("Calling EEPROM clear API is not allowed in current configuration");
1065+
}
1066+
1067+
bool success;
1068+
std::string errorMsg;
1069+
std::tie(success, errorMsg) = pimpl->rpcClient->call("eepromClear", protectedPermissions, factoryPermissions).as<std::tuple<bool, std::string>>();
1070+
if(!success) {
1071+
throw std::runtime_error(errorMsg);
1072+
}
1073+
}
1074+
1075+
void DeviceBase::flashFactoryEepromClear() {
1076+
bool factoryPermissions = false;
1077+
bool protectedPermissions = false;
1078+
getFlashingPermissions(factoryPermissions, protectedPermissions);
1079+
spdlog::debug("Clearing User EEPROM contents. Factory permissions {}, Protected permissions {}", factoryPermissions, protectedPermissions);
1080+
1081+
if(!protectedPermissions || !factoryPermissions) {
1082+
throw std::runtime_error("Calling factory EEPROM clear API is not allowed in current configuration");
1083+
}
1084+
1085+
bool success;
1086+
std::string errorMsg;
1087+
std::tie(success, errorMsg) = pimpl->rpcClient->call("eepromFactoryClear", protectedPermissions, factoryPermissions).as<std::tuple<bool, std::string>>();
1088+
if(!success) {
1089+
throw std::runtime_error(errorMsg);
1090+
}
1091+
}
1092+
10571093
bool DeviceBase::startPipeline() {
10581094
// Deprecated
10591095
return true;

0 commit comments

Comments
 (0)