[RSDK-12844] Add do command error responses#68
Conversation
4790f83 to
1193e1b
Compare
a7af649 to
62636be
Compare
first_run.sh used 'cd $(dirname $0)' then 'sudo ./install_udev_rules.sh', which could fail if sudo resets the working directory. install_udev_rules.sh set CURR_DIR but never used it, instead using 'cp ./99-obsensor-libusb.rules' which fails when cwd isn't the script's directory. Both scripts now resolve and use absolute paths.
62636be to
dbe28e5
Compare
…kaging Switches meta.json build command from 'make build' to 'make module.tar.gz' which uses Conan's deploy() method for tarball creation. Removes the manual staging/packaging from bin/build.sh since it's now redundant.
dbe28e5 to
ea35697
Compare
first_run.sh
Outdated
| OS=$(uname) | ||
|
|
||
| if [[ "$OS" == 'Linux' ]]; then | ||
| cd $(dirname $0) |
| } 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.
Should we also check for empty command at the top to avoid unhelpful log here in that case?
|
These changes look great but it doesn't appear to address the issue described in the ticket you linked, which is that if you send a set_device_property property such as: you don't get notified that the property is not supported by the astra2. |
| } else if (key == "call_get_properties") { | ||
| call_get_properties = true; | ||
| } else { | ||
| VIAM_RESOURCE_LOG(error) << "[do_command] unknown command: " << key; |
…setDeviceProperties
Previously, when a user sent a property name that didn't match any
supported property on the device, both setDeviceProperty and
setDeviceProperties would silently return empty {} with no error.
Fix setDeviceProperty to return an error dict when the property name
is not found in the device's supported properties.
Fix setDeviceProperties to check, after iterating supported properties,
whether any user-supplied property names weren't found, and return an
error for them.
great callout, added code and tested (updated desc) |
| if (seen_properties.count(name) == 0) { | ||
| return {{"error", "property not supported: " + name}}; | ||
| } | ||
| } |
There was a problem hiding this comment.
this is not within the scope of your PR changes so feel free to ignore but this function has lots of repeated code from setDeviceProperty and should just call it.
There was a problem hiding this comment.
oh like there's pre-existing code that should be DRY?
Summary
RSDK-12844
do_commandhad six silent failure paths that returned an empty{}to the caller with no indication anything went wrong:do_command({})acquired locks, looked up the device, iterated zero times, and returned{}throw std::invalid_argumentwas caught by the outer catch, which logged the error but fell through to return{}{}set_device_property) — property name not in the device's supported list silently returned{}set_device_properties) — same silent{}for the plural/batch variant{}instead of propagating the errorThis PR fixes all six to return
{"error": "<message>"}, consistent with the pattern already used bydump_pcl_filesand thedevice_controlhelpers.Manual Tests
Platform: linux/amd64, Framework Laptop
Module:
viam:orbbec:astra2built from this branch viaviam module reload-localMachine: sean-framework (part ID
08852a48-cafb-47fc-a747-14982036c715)Device: Orbbec Astra 2 (serial AARY14100X5, USB 3.0)
viam-server: local, connected via Python SDK (viam-sdk)
Test 1 — Happy path (baseline)
✅
get_device_inforeturns device metadata (serial, firmware, hardware version, etc.) with no "error" key.✅
get_orbbec_sdk_versionreturns{"version": "2.4.8", "stage_version": "open-source-beta"}with no "error" key.✅
get_device_propertiesreturns 51 properties — normal operation unaffected.Test 2 — Unknown command key (new else branch)
✅ Returns
{"error": "unknown command: bogus_command"}. Before this PR: returned{}.Test 3 — Device not connected (replaced throw with error return)
Started module with Astra2 plugged in, confirmed
orbbec-1working viaget_device_info, then physically unplugged the USB cable. After ~20s:✅ Returns
{"error": "device is not connected"}. Before this PR: exception caught by outer catch → returned{}.Test 4 — Outer catch returns error (injected exception)
Injected
throw std::runtime_error("test: simulated exception for outer catch")into theget_orbbec_sdk_versionhandler to force an exception that reaches the outer catch. Built and deployed (not committed):✅ Returns
{"error": "test: simulated exception for outer catch"}. Before this PR: exception logged but returned{}.Test 5 — Unsupported property name via
set_device_property✅ Returns
{"error": "property not supported: OB_PROP_COLOR_GAMMA_INT"}. Before this PR: returned{}.Test 6 — Unsupported property name via
set_device_properties(plural)✅ Returns
{"error": "property not supported: OB_PROP_COLOR_GAMMA_INT"}. Before this PR: returned{}.PR Process
Number of LGTM-ers (required): 2
Note
Driven by me, executed by OpenClaw.