0

I am using System.IO.BACnet library for my C# BACNet client.

I am trying to send to server "ReadPropertyMultiple" request, however I am unable to read non-array BACNet properties, since the System.IO.BACnet.BacnetClient.ReadPropertyMultipleRequest requires list of System.IO.BACnet.BacnetPropertyReference(s) ...

public bool ReadPropertyMultipleRequest(BacnetAddress address, BacnetObjectId objectId, IList<BacnetPropertyReference> propertyIdAndArrayIndex, out IList<BacnetReadAccessResult> values, byte invokeId = 0);

.. and the System.IO.BACnet.BacnetPropertyReference requires propertyArrayIndex ..

public struct BacnetPropertyReference
{
    public uint propertyIdentifier;
    public uint propertyArrayIndex;

    public BacnetPropertyReference(uint id, uint arrayIndex);

    public BacnetPropertyIds GetPropertyId();
    public override string ToString();
}

.. which, when not set, defaults to 0. This causes, that after request with this list is sent, all properties are requested with propertyArrayIndex: 0, which fail for non-array object properties.

Example:

Request:

enter image description here

Response:

enter image description here

What is the right way to not add the propertyArrayIndex into request and thus be able to read non-array properties with ReadPropertyMultiple request?

user10099
  • 1,345
  • 2
  • 17
  • 23

2 Answers2

1

If you request array-index "0" you should (in theory) receive the number of (following) elements, and not the full list of values (/remaining elements containing values).

Can't you use (the) 'Read-Property' (service) for non-array items (?).

DennisVM-D2i
  • 416
  • 3
  • 8
  • Yes, Read-Property would work, but there are cases where I need to use ReadPropertyMultiple for non-array items. Anyway I have found a solution - it's setting propertyArrayIndex=uint.MaxValue :) That way the library does not include the array index in request. – user10099 Apr 25 '22 at 20:13
0

The solution is to set propertyArrayIndex = uint.MaxValue.

For example:

BacnetPropertyReference reff = new BacnetPropertyReference((uint) BacnetPropertyIds.PROP_PRESENT_VALUE, uint.MaxValue);
user10099
  • 1,345
  • 2
  • 17
  • 23