Repository navigation
fix(opcua): send the ConditionId clause an empty BrowsePath, not a null one - #777
Closed
mfaferek93 wants to merge 2 commits into
Closed
mfaferek93 wants to merge 2 commits into
mfaferek93 wants to merge 2 commits into
Conversation
…ll one The ConditionId select clause has no BrowsePath. It went out as a null array (length -1), and a Siemens S7-1500 answers that with a null ConditionId, so every native alarm was dropped as a non-condition event. It now goes out as an empty array (length 0).
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the change to send empty rather than null ConditionId browse paths.
No open issues 🎉
What changed in this PR
Fixes OPC UA alarm subscriptions so the ConditionId clause sends an empty BrowsePath rather than a null array, addressing Siemens S7-1500 alarms being dropped because of null ConditionIds.
Changes:
- Uses
UA_EMPTY_ARRAY_SENTINELfor empty event-filter browse paths. - Exposes the filter builder in the
detailnamespace for testing. - Adds a binary encode/decode regression test that distinguishes empty arrays from null arrays.
| File | Description |
|---|---|
src/ros2_medkit_plugins/ros2_medkit_opcua/test/test_opcua_client.cpp |
Verifies the ConditionId BrowsePath remains empty, not null, after serialization. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/opcua_client.cpp |
Sets the empty-array sentinel and updates the filter-builder namespace and call site. |
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/opcua_client.hpp |
Declares the filter builder in detail for test access. |
Review effort: Balanced
The scan lambda runs on the sweep's worker threads. Two first probes could both see the string empty and assign it at once, which ThreadSanitizer reports as a race. A mutex around the check and the assignment fixes it.
Collaborator
Author
|
Superseded by #783, which carries this change as its own commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The event filter the OPC UA plugin sends with every Alarms & Conditions subscription has a ConditionId select clause with no BrowsePath (
ConditionType,AttributeId=NodeId). The plugin leftbrowsePathas a NULL pointer, which open62541 encodes as a null array (length -1).A Siemens S7-1500 answers a null BrowsePath with a null ConditionId. The plugin drops every event with a null ConditionId as a non-condition event, so no native
Program_Alarmever became a fault:The clause now carries an empty array (length 0).
Changes
make_event_filtersetsbrowsePathtoUA_EMPTY_ARRAY_SENTINELwhen the path is empty. It moves to adetailnamespace so a test can call it.EventFilterTest.ConditionIdClauseSendsEmptyNotNullBrowsePath: encodes the clause, decodes it and checks it decodes as an empty array, not a null one.Testing
browsePathdecodes as NULL) and passes with the fix.colcon test --packages-select ros2_medkit_opcua: passes (Release), including thetest_alarm_serverintegration tests.sanitizer-tsanred: a data race in the testDiscoverEndpoint.TheScanIsAnnouncedBeforeTheSweepRuns, a test already on main. Its scan lambda runs on the sweep's worker threads, and two first probes could both see the shared string empty and assign it at once. The race only shows when two probes overlap, so it is rare. A short sleep between the check and the assignment makes it show on every run. The second commit puts a mutex around the check and the assignment. With the same sleep, 10 of 10 runs are clean. Without the sleep,ctest -LE linterforros2_medkit_opcuain a TSan build (RelWithDebInfo, the CI suppressions, timeouts x3) passes 21/21 with no race report.