-
Notifications
You must be signed in to change notification settings - Fork 5
[RSDK-12844] Add do command error responses #68
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
Changes from all commits
6a9069f
58c4bd1
fceebd5
3d62656
5b529d5
ea35697
0a28dc3
ec1dd55
a37301e
c0a70b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1471,6 +1471,9 @@ vsdk::Camera::image_collection Orbbec::get_images(std::vector<std::string> filte | |
| } | ||
|
|
||
| vsdk::ProtoStruct Orbbec::do_command(const vsdk::ProtoStruct& command) { | ||
| if (command.empty()) { | ||
| return vsdk::ProtoStruct{{"error", std::string("empty command")}}; | ||
| } | ||
| bool call_get_properties = false; | ||
| try { | ||
| constexpr char firmware_key[] = "update_firmware"; | ||
|
|
@@ -1484,7 +1487,8 @@ vsdk::ProtoStruct Orbbec::do_command(const vsdk::ProtoStruct& command) { | |
| const std::lock_guard<std::mutex> lock(devices_by_serial_mu()); | ||
| auto search = devices_by_serial().find(serial_number); | ||
| if (search == devices_by_serial().end()) { | ||
| throw std::invalid_argument("device is not connected"); | ||
| VIAM_RESOURCE_LOG(error) << "[do_command] device is not connected"; | ||
| return vsdk::ProtoStruct{{"error", std::string("device is not connected")}}; | ||
| } | ||
|
|
||
| std::unique_ptr<ViamOBDevice>& dev = search->second; | ||
|
|
@@ -1573,6 +1577,9 @@ vsdk::ProtoStruct Orbbec::do_command(const vsdk::ProtoStruct& command) { | |
| return device_control::createModuleConfig<ViamOBDevice, ob::VideoStreamProfile>(dev); | ||
| } else if (key == "call_get_properties") { | ||
| call_get_properties = true; | ||
| } else { | ||
| VIAM_RESOURCE_LOG(error) << "[do_command] unknown command: " << key; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check for empty command at the top to avoid unhelpful log here in that case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a nit, not blocking
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great call done |
||
| return vsdk::ProtoStruct{{"error", "unknown command: " + key}}; | ||
| } | ||
| } | ||
| } // unlock devices_by_serial_mu_ | ||
|
|
@@ -1601,6 +1608,7 @@ vsdk::ProtoStruct Orbbec::do_command(const vsdk::ProtoStruct& command) { | |
| } | ||
| } catch (const std::exception& e) { | ||
| VIAM_RESOURCE_LOG(error) << service_name << ": exception caught: " << e.what(); | ||
| return vsdk::ProtoStruct{{"error", std::string(e.what())}}; | ||
| } | ||
| return vsdk::ProtoStruct{}; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not within the scope of your PR changes so feel free to ignore but this function has lots of repeated code from
setDevicePropertyand should just call it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh like there's pre-existing code that should be DRY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes