Professional Documents
Culture Documents
Context Tagging Within BACnet®
Context Tagging Within BACnet®
By Duffy O’Craven
A
t the bits and bytes level, data in BACnet packets on the wire offset, int tagval)
{
obey some very specific rules so the receiver can glean the int len = pif_get_
byte(offset-1)&0x07;
intent of the sender. Most of these rules are simple, and the code unsigned long value =
get_bac unsigned(offset,
for any BACnet protocol stack thoroughly exercises most cases. len);
// get_bac_unsigned()
However, the occurrence of certain conditions could execute incor-
internally handles all
rect code. This article sheds light on one such situation. length cases
}
Actually, a special case exists in the
Those of you who envision data octets specification, in clauses 20.2.1.2 and
on the wire in BACnet are probably famil- 20.2.1.3.1, ever since its earliest days,
iar with an arrangement such as: specifying a different arrangement for con-
text-specific tag numbers 15 or higher:
B8 B A C n e t ® To d a y | A S u p p l e m e n t t o A S H R A E J o u r n a l November 2005
Standing Standards Project Committee Some BACnet protocol encoders and
135, BACnet®—A Data Communication decoders can be expected to have errors
Protocol for Building Automation and in their implementations, regarding a
Control Networks (WG-OS) advocates context tag number 15 or higher.
declaring six additional context tagged Nonetheless, this rather innocuous and
choices in the BACnetPropertyStates superfluous change in the standard may
production in Clause 21 for data types be the best time to bring that to light,
used in properties within the standard. rather than awaiting the day some other
In this case an additional intervening Three of these properties’ data types were amendment to extend a complex pro-
byte exists between the L/V/T octet and overlooked in the original declaration of duction such as BACnetEventParameter
the start of Extended Length or start of the BACnetPropertyStates production, and or BACnetNotificationParameters also
data. offset-1 and offset do not three others are property data types added eventually forces the use of a context tag
have the same relationship, and the call in addenda to the standard since 1995: number 15 or higher.
to get_bac_unsigned() will fail to • action [15] BACnetAction; All of this is very rigorous, very pre-
decode the content correctly. The code • maintenance [16] BACnetMainte- dictable—unless you don’t see it coming
excerpt shown above didn’t see it coming nance; and aren’t prepared for it. For example,
and isn’t prepared for it. • notify-type [17] BACnetNotifyType; to correctly code the previous situation,
Many implementations of BACnet en- • silenced-state [18] BACnetSilenced- simply make the modification shown in
coders and decoders have probably been State; bold:
developed without any cognizance of this • life-safety-operation [19] BAC- v o i d s h o w _ h e a d
arrangement. Programmers had no reason netLifeSafetyOperation; and unsigned(unsigned int
to write the code for these special cases. • file-access-method [20] BACnetFile- offset, int tagval)
No instances of context-specific tag num- AccessMethod.
{
ber 15 or higher are declared anywhere in This would be the first occurrence in
the BACnet specification. Until now. the standard of a production in Clause int len = pif_get_
A proposal recently considered by the 21 declaring a context tag number 15 byte(offset-1)&0x07;
Objects and Services working group of or higher. See Context Tagging, Page B46