Skip to content

Commit

Permalink
Merge pull request #8018 from nohayassin/DSO_16069
Browse files Browse the repository at this point in the history
FW update exception fix
  • Loading branch information
ev-mp authored Mar 24, 2021
2 parents 011d869 + f947976 commit d7a1a78
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/fw-update-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ namespace rs2
if (_is_signed)
{
log("Requesting to switch to recovery mode");

// in order to update device to DFU state, it will be disconnected then switches to DFU state
// if querying devices is called while device still switching to DFU state, an exception will be thrown
// to prevent that, a blocking is added to make sure device is updated before continue to next step of querying device
upd.enter_update_state();
// Allow time for the device to disconnect before calling "query_devices"
std::this_thread::sleep_for(std::chrono::seconds(2));
Expand Down
14 changes: 14 additions & 0 deletions src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,26 @@ namespace librealsense
{
// Stop all data streaming/exchange pipes with HW
stop_activity();
using namespace std;
using namespace std::chrono;

try {
LOG_INFO("entering to update state, device disconnect is expected");
command cmd(ds::DFU);
cmd.param1 = 1;
_hw_monitor->send(cmd);
std::vector<uint8_t> gvd_buff(HW_MONITOR_BUFFER_SIZE);
for (auto i = 0; i < 50; i++)
{
_hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD);
this_thread::sleep_for(milliseconds(50));
}
throw std::runtime_error("Device still connected!");

}
catch (std::exception& e)
{
LOG_WARNING(e.what());
}
catch (...) {
// The set command returns a failure because switching to DFU resets the device while the command is running.
Expand Down
13 changes: 13 additions & 0 deletions src/ivcam/sr300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,24 @@ namespace librealsense
{
// Stop all data streaming/exchange pipes with HW
stop_activity();
using namespace std;
using namespace std::chrono;

try {
command cmd(ivcam::GoToDFU);
cmd.param1 = 1;
_hw_monitor->send(cmd);
std::vector<uint8_t> gvd_buff(HW_MONITOR_BUFFER_SIZE);
for (auto i = 0; i < 50; i++)
{
_hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD);
this_thread::sleep_for(milliseconds(50));
}
throw std::runtime_error("Device still connected!");
}
catch (std::exception& e)
{
LOG_WARNING(e.what());
}
catch (...) {
// The set command returns a failure because switching to DFU resets the device while the command is running.
Expand Down
14 changes: 14 additions & 0 deletions src/l500/l500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,26 @@ namespace librealsense
{
// Stop all data streaming/exchange pipes with HW
stop_activity();
using namespace std;
using namespace std::chrono;

try {
LOG_INFO("entering to update state, device disconnect is expected");
command cmd(ivcam2::DFU);
cmd.param1 = 1;
_hw_monitor->send(cmd);
std::vector<uint8_t> gvd_buff(HW_MONITOR_BUFFER_SIZE);
for (auto i = 0; i < 50; i++)
{

_hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), GVD);
this_thread::sleep_for(milliseconds(50));
}
throw std::runtime_error("Device still connected!");

}
catch (std::exception& e) {
LOG_WARNING(e.what());
}
catch (...) {
// The set command returns a failure because switching to DFU resets the device while the command is running.
Expand Down

0 comments on commit d7a1a78

Please sign in to comment.