3

I'm implementing a generic BACnet decoder and came across the following question, of which I can't seem to find the answer within the BACnet standard. The chapter "20.2.1.3.2 Constructed Data" does not answer my question, or I might not fully understand it.

Let's assume I have a List (SEQUENCE OF) with elements of type Record (SEQUENCE). Said record has 4 fields, identified by context tag, where field 0 and 1 are optional. I further assume that the order, in which those fields are serialized, can be arbitrary (because they're identified by their context tags). The data could look like that (number indicates field / column): [{ "3", "0", 2" }, {"1", "2", "3"}]

Over the wire, the only "structure information" I assume I get are the open / close tags for the list. That means:

Open Tag List
  ctxTagColumn3, valueColumn3,
  ctxTagColumn0, valueColumn0,
  ctxTagColumn2, valueColumn2,
  ctxTagColumn1, valueColumn1,
  ctxTagColumn2, valueColumn2,
  ctxTagColumn3, valueColumn3
Close Tag List

How do I know, after I've read the last column data ("2") of my first list item, that I must begin decoding the second item, starting with a value for column "1"?

Which of my assumptions is wrong?

Thank you and kind regards

Pascal

Pascal
  • 105
  • 4

2 Answers2

0

The order of elements of a SEQUENCE is always known and shall not be arbitrarily by definition. Further, not all conceivable combinations are possible to encode. Regarding BACnet, all type definitions shall be decodable universally.

Daniel
  • 459
  • 6
  • 16
0

Assuming I understand you correctly; the "order" cannot be "arbitrary"; i.e.:

SEQUENCE = *ordered* collection of variables of **different** types

SEQUENCE OF = *ordered* collection of variables of **same** type

The tag-number for the item (SD) context-tag will be different (/possibly an incremented value/maybe +1) from the containing (PD) context-tag; so you could check for that, or better still if the tag-number value is <= 5 (/'length' value) then it's a SD context-tag for one of your items, rather than a (/the closing) PD context tag (/'type' value) delimiting the end of your items.

DennisVM-D2i
  • 416
  • 3
  • 8