Fix WritePropertyMultiple decoder to support multiple objects per request#158
Open
imurasawa wants to merge 3 commits into
Open
Fix WritePropertyMultiple decoder to support multiple objects per request#158imurasawa wants to merge 3 commits into
imurasawa wants to merge 3 commits into
Conversation
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.
Fix WritePropertyMultiple decoder to support multiple objects per request
Summary
DecodeWritePropertyMultipleinSerialize/Services.cswas only decoding a single object,despite the BACnet specification defining WritePropertyMultiple as a
SEQUENCE OF WriteAccessSpecifications— meaning a single request can target multiple objects.This PR fixes the decoder and updates the delegate signature in
BACnetClient.cs,following the same design as ReadPropertyMultiple (RPM), which delegates to
ASN1.decode_read_access_specification. WPM now delegates to the newly addedASN1.decode_write_access_specification, making the two implementations fully symmetric.Background
In a production environment, a commercial BMS client sent WritePropertyMultiple requests
containing multiple objects to a BACnet server built with this library. The server failed
to process them.
The issue was isolated using the
bacwpmtool frombacnet-stack:Reject: Unrecognized ServiceWriteProperty Acknowledged!(SimpleAck)Root Cause
The BACnet specification (ASHRAE 135) defines the WritePropertyMultiple request PDU as a
SEQUENCE OF WriteAccessSpecifications, allowing multiple objects in a single request.The existing
DecodeWritePropertyMultipledecoded only the first object and ignoredany subsequent ones, causing the request to be rejected.
Changes
Design
Mirrors the RPM design: just as
DecodeReadPropertyMultipledelegates toASN1.decode_read_access_specification,DecodeWritePropertyMultiplenow delegates tothe newly added
ASN1.decode_write_access_specification.This follows the design philosophy of the original
bacnet-stack.Files changed (4 files)
1.
Base/BacnetWriteAccessSpecification.cs(new file)A new struct symmetric to
BacnetReadAccessSpecification:2.
Serialize/ASN1.csAdded
decode_write_access_specificationimmediately afterdecode_read_access_specification,using the same variable names (
p_ref,propertyIdAndValues) and code style.3.
Serialize/Services.csReplaced the single-object decoder with a while loop, symmetric to
DecodeReadPropertyMultiple:4.
BACnetClient.csUpdated the
WritePropertyMultipleRequestHandlerdelegate signature:The signature of
WritePropertyMultipleRequestHandlerhas changed.Any code subscribing to
OnWritePropertyMultipleRequestmust be updated:Test Environment
bacwpmfrombacnet-stackNotes
Dependency on #157:
This fix was verified on Linux (Raspberry Pi 4). On Linux, WPM packets only reach
the server after the UDP socket fix in #157. The decoding bug itself is OS-independent
and affects Windows as well.
Note on BACnetClient.cs diff:
BACnetClient.cswas also normalized from CRLF to LF (as mentioned in #157).To see only the functional changes, compare against
imurasawa:fix/normalize-line-endingsbranch.