Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FW update exception fix #8018

Merged
merged 4 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();

if (!check_for([this, serial, &dfu]() {
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 @@ -123,12 +123,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!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reword with "Device failed to switch to DFU within the predefined time"


}
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 @@ -435,12 +435,26 @@ namespace librealsense
{
// Stop all data streaming/exchange pipes with HW
stop_activity();
using namespace std;
using namespace std::chrono;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case use of explicit std::this_thread... std::chrono:millisec(..) is preferred


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