Secure ReadProperty decoding and BACnetActionCommand (#702)

* Refactored and secured BACnetActionCommand codec into bacaction.c module for command object and added to bacapp module encode/decode with define for enabling and pseudo application tag for internal use.

* Simplified bacapp_data_len() and moved into bacdcode module as bacnet_enclosed_data_len() function.

* Secured ReadProperty-REQUEST and -ACK decoding.

* Removed deprecated Keylist_Key() functions from usage.

* Removed pseudo application datatypes from bacapp_data_decode() which only uses primitive application tag encoded values.

* Defined INT_MAX when it is not already defined by compiler or libc.

* Deprecated bacapp_decode_application_data_len() and bacapp_decode_context_data_len() as they are no longer used in any code in the library.

* Added BACnetScale to bacapp module. Improved complex property value decoding. Refactored bacapp_decode_known_property() function.

* Refactored and improved the bacapp_snprintf() function for printing EPICS.

* Fixed Lighting Output WriteProperty to handle known property decoding.
This commit is contained in:
Steve Karg
2024-07-25 17:12:08 -05:00
committed by GitHub
parent 923eaf2313
commit 4326128e72
191 changed files with 3856 additions and 2099 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(
bacnet-stack
@@ -144,6 +144,8 @@ add_library(${PROJECT_NAME}
src/bacnet/awf.h
src/bacnet/bacaddr.c
src/bacnet/bacaddr.h
src/bacnet/bacaction.c
src/bacnet/bacaction.h
src/bacnet/bacapp.c
src/bacnet/bacapp.h
src/bacnet/bacdcode.c
+3
View File
@@ -370,6 +370,9 @@ CPPCHECK_OPTIONS += --template=gcc
CPPCHECK_OPTIONS += --inline-suppr
CPPCHECK_OPTIONS += --suppress=selfAssignment
CPPCHECK_OPTIONS += --suppress=integerOverflow
CPPCHECK_OPTIONS += -DBACNET_STACK_DEPRECATED
#CPPCHECK_OPTIONS += -I./src
#CPPCHECK_OPTIONS += --enable=information --check-config
CPPCHECK_OPTIONS += --error-exitcode=1
.PHONY: cppcheck
cppcheck:
+6 -23
View File
@@ -529,7 +529,6 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
BACNET_APPLICATION_DATA_VALUE *value, *old_value;
bool print_brace = false;
KEY object_list_element;
bool isSequence = false; /* Ie, will need bracketing braces {} */
if (rpm_property == NULL) {
fprintf(stdout, " -- Null Property data \n");
@@ -635,10 +634,6 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
assert(value->tag ==
BACNET_APPLICATION_TAG_OBJECT_ID); /* Something
not right
here */
break;
}
/* Store the object list so we can interrogate
@@ -665,27 +660,12 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
}
} else if (rpm_property->propertyIdentifier ==
PROP_SUBORDINATE_LIST) {
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
assert(value->tag ==
BACNET_APPLICATION_TAG_OBJECT_ID); /* Something
not right
here */
if (value->tag !=
BACNET_APPLICATION_TAG_DEVICE_OBJECT_REFERENCE) {
break;
}
/* TODO: handle Sequence of { Device ObjID, Object ID }, */
isSequence = true;
}
/* If the object is a Sequence, it needs its own bracketing
* braces */
if (isSequence) {
fprintf(stdout, "{");
}
bacapp_print_value(stdout, &object_value);
if (isSequence) {
fprintf(stdout, "}");
}
if ((Walked_List_Index < Walked_List_Length) ||
(value->next != NULL)) {
/* There are more. */
@@ -1787,13 +1767,16 @@ int main(int argc, char *argv[])
do {
Object_List_Index++;
if (Object_List_Index < Keylist_Count(Object_List)) {
nextKey = Keylist_Key(Object_List, Object_List_Index);
if (Keylist_Index_Key(Object_List, Object_List_Index, &nextKey)) {
myObject.type = KEY_DECODE_TYPE(nextKey);
myObject.instance = KEY_DECODE_ID(nextKey);
/* Don't re-list the Device Object among its objects */
if (myObject.type == OBJECT_DEVICE) {
continue;
}
} else {
continue;
}
/* Closing brace for the previous Object */
printf(" }, \n");
/* Opening brace for the new Object */
+1
View File
@@ -139,6 +139,7 @@ set(BACNET_PROJECT_SOURCE
${LIBRARY_BACNET_BASIC}/sys/mstimer.c
# BACnet core modules
${LIBRARY_BACNET_CORE}/abort.c
${LIBRARY_BACNET_CORE}/bacaction.c
${LIBRARY_BACNET_CORE}/bacaddr.c
${LIBRARY_BACNET_CORE}/bacapp.c
${LIBRARY_BACNET_CORE}/bacdcode.c
+1
View File
@@ -102,6 +102,7 @@ DEMOSRC = ai.c \
$(BACNET_BASIC)/service/s_ihave.c
CORESRC = $(BACNET_CORE)/abort.c \
$(BACNET_CORE)/bacaction.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacdcode.c \
+1
View File
@@ -121,6 +121,7 @@ BASICSRC = $(BACNET_BASIC)/service/h_dcc.c \
CORESRC = \
$(BACNET_CORE)/datalink/crc.c \
$(BACNET_CORE)/abort.c \
$(BACNET_CORE)/bacaction.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacdcode.c \
+1
View File
@@ -165,6 +165,7 @@ set(BACNET_PROJECT_SOURCE
${LIBRARY_BACNET_BASIC}/sys/mstimer.c
# BACnet core library
${LIBRARY_BACNET_CORE}/abort.c
${LIBRARY_BACNET_CORE}/bacaction.c
${LIBRARY_BACNET_CORE}/bacaddr.c
${LIBRARY_BACNET_CORE}/bacapp.c
${LIBRARY_BACNET_CORE}/bacdcode.c
+1
View File
@@ -54,6 +54,7 @@ BASIC_SRC = \
BACNET_SRC = \
$(BACNET_CORE)/abort.c \
$(BACNET_CORE)/bacaction.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacdcode.c \
+1
View File
@@ -181,6 +181,7 @@ set(BACNET_PROJECT_SOURCE
${LIBRARY_BACNET_BASIC}/sys/mstimer.c
${LIBRARY_BACNET_CORE}/abort.c
${LIBRARY_BACNET_CORE}/bacaction.c
${LIBRARY_BACNET_CORE}/bacaddr.c
${LIBRARY_BACNET_CORE}/bacapp.c
${LIBRARY_BACNET_CORE}/bacdcode.c
+1
View File
@@ -63,6 +63,7 @@ BASIC_SRC = \
BACNET_SRC = \
$(BACNET_CORE)/abort.c \
$(BACNET_CORE)/bacaction.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacdcode.c \
+3
View File
@@ -1052,6 +1052,9 @@
<file>
<name>$PROJ_DIR$\..\..\src\bacnet\abort.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\src\bacnet\bacaction.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\src\bacnet\bacaddr.c</name>
</file>
@@ -168,6 +168,7 @@
<ClCompile Include="..\..\..\..\src\bacnet\basic\service\h_apdu.c" />
<ClCompile Include="..\..\..\..\src\bacnet\arf.c" />
<ClCompile Include="..\..\..\..\src\bacnet\awf.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacaction.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacaddr.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacapp.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacdevobjpropref.c" />
@@ -33,6 +33,9 @@
<ClCompile Include="..\..\..\..\src\bacnet\awf.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\bacnet\bacaction.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\bacnet\bacaddr.c">
<Filter>Source Files</Filter>
</ClCompile>
@@ -28,6 +28,7 @@
<ClCompile Include="..\..\..\..\src\bacnet\authentication_factor_format.c" />
<ClCompile Include="..\..\..\..\src\bacnet\awf.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacaddr.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacaction.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacapp.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacdcode.c" />
<ClCompile Include="..\..\..\..\src\bacnet\bacdest.c" />
@@ -212,6 +213,7 @@
<ClInclude Include="..\..\..\..\src\bacnet\authentication_factor_format.h" />
<ClInclude Include="..\..\..\..\src\bacnet\awf.h" />
<ClInclude Include="..\..\..\..\src\bacnet\bacaddr.h" />
<ClInclude Include="..\..\..\..\src\bacnet\bacaction.h" />
<ClInclude Include="..\..\..\..\src\bacnet\bacapp.h" />
<ClInclude Include="..\..\..\..\src\bacnet\bacdcode.h" />
<ClInclude Include="..\..\..\..\src\bacnet\bacdef.h" />
@@ -78,6 +78,9 @@
<ClCompile Include="..\..\..\..\src\bacnet\bacaddr.c">
<Filter>Source Files\src\bacnet</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\bacnet\bacaction.c">
<Filter>Source Files\src\bacnet</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\bacnet\bacapp.c">
<Filter>Source Files\src\bacnet</Filter>
</ClCompile>
@@ -626,6 +629,9 @@
<ClInclude Include="..\..\..\..\src\bacnet\bacaddr.h">
<Filter>Source Files\src\bacnet</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\bacnet\bacaction.h">
<Filter>Source Files\src\bacnet</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\src\bacnet\bacapp.h">
<Filter>Source Files\src\bacnet</Filter>
</ClInclude>
+1
View File
@@ -78,6 +78,7 @@ BASICSRC = $(BACNET_BASIC)/tsm/tsm.c \
# core BACnet stack files
CORESRC = \
$(BACNET_CORE)/abort.c \
$(BACNET_CORE)/bacaction.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacdcode.c \
+4
View File
@@ -759,6 +759,10 @@
<SubType>compile</SubType>
<Link>bacnet-stack\h_apdu.c</Link>
</Compile>
<Compile Include="..\..\src\bacnet\bacaction.c">
<SubType>compile</SubType>
<Link>bacnet-stack\bacaddr.c</Link>
</Compile>
<Compile Include="..\..\src\bacnet\bacaddr.c">
<SubType>compile</SubType>
<Link>bacnet-stack\bacaddr.c</Link>
+568
View File
@@ -0,0 +1,568 @@
/**
* @file
* @brief BACnetActionCommand codec used by Command objects
* @author Steve Karg <skarg@users.sourceforge.net>
* @date 2024
* @copyright SPDX-License-Identifier: MIT
*/
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacaction.h"
#include "bacnet/bacdcode.h"
/**
* @brief Encode property value according to the application tag
* @param apdu - Pointer to the buffer to encode to, or NULL for length
* @param value - Pointer to the property value to encode from
* @return number of bytes encoded
*/
int bacnet_action_property_value_encode(
uint8_t *apdu, BACNET_ACTION_PROPERTY_VALUE *value)
{
int apdu_len = 0; /* total length of the apdu, return value */
if (!value) {
return 0;
}
switch (value->tag) {
#if defined(BACACTION_NULL)
case BACNET_APPLICATION_TAG_NULL:
if (apdu) {
apdu[0] = value->tag;
}
apdu_len++;
break;
#endif
#if defined(BACACTION_BOOLEAN)
case BACNET_APPLICATION_TAG_BOOLEAN:
apdu_len = encode_application_boolean(apdu, value->type.Boolean);
break;
#endif
#if defined(BACACTION_UNSIGNED)
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
apdu_len =
encode_application_unsigned(apdu, value->type.Unsigned_Int);
break;
#endif
#if defined(BACACTION_SIGNED)
case BACNET_APPLICATION_TAG_SIGNED_INT:
apdu_len = encode_application_signed(apdu, value->type.Signed_Int);
break;
#endif
#if defined(BACACTION_REAL)
case BACNET_APPLICATION_TAG_REAL:
apdu_len = encode_application_real(apdu, value->type.Real);
break;
#endif
#if defined(BACACTION_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
apdu_len = encode_application_double(apdu, value->type.Double);
break;
#endif
#if defined(BACACTION_ENUMERATED)
case BACNET_APPLICATION_TAG_ENUMERATED:
apdu_len =
encode_application_enumerated(apdu, value->type.Enumerated);
break;
#endif
default:
break;
}
return apdu_len;
}
/**
* @brief Decode property value from the application buffer
* @param apdu - Pointer to the buffer to decode from
* @param apdu_size Size of the buffer to decode from
* @param value - Pointer to the property value to decode to
* @return number of bytes encoded
*/
int bacnet_action_property_value_decode(
uint8_t *apdu, uint32_t apdu_size, BACNET_ACTION_PROPERTY_VALUE *value)
{
int len = 0;
int apdu_len = 0;
BACNET_TAG tag = { 0 };
if (!value) {
return 0;
}
if (!apdu) {
return 0;
}
len = bacnet_tag_decode(apdu, apdu_size, &tag);
if ((len > 0) && tag.application) {
if (value) {
value->tag = tag.number;
}
switch (tag.number) {
#if defined(BACACTION_NULL)
case BACNET_APPLICATION_TAG_NULL:
apdu_len = len;
break;
#endif
#if defined(BACACTION_BOOLEAN)
case BACNET_APPLICATION_TAG_BOOLEAN:
apdu_len = bacnet_boolean_application_decode(
apdu, apdu_size, &value->type.Boolean);
break;
#endif
#if defined(BACACTION_UNSIGNED)
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
apdu_len = bacnet_unsigned_application_decode(
apdu, apdu_size, &value->type.Unsigned_Int);
break;
#endif
#if defined(BACACTION_SIGNED)
case BACNET_APPLICATION_TAG_SIGNED_INT:
apdu_len = bacnet_signed_application_decode(
apdu, apdu_size, &value->type.Signed_Int);
break;
#endif
#if defined(BACACTION_REAL)
case BACNET_APPLICATION_TAG_REAL:
apdu_len = bacnet_real_application_decode(
apdu, apdu_size, &value->type.Real);
break;
#endif
#if defined(BACACTION_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
apdu_len = bacnet_double_application_decode(
apdu, apdu_size, &value->type.Double);
break;
#endif
#if defined(BACACTION_ENUMERATED)
case BACNET_APPLICATION_TAG_ENUMERATED:
apdu_len = bacnet_enumerated_application_decode(
apdu, apdu_size, &value->type.Enumerated);
break;
#endif
default:
break;
}
}
return apdu_len;
}
/**
* @brief Compare two BACnetActionPropertyValue complex datatypes
* @param value1 [in] The first structure to compare
* @param value2 [in] The second structure to compare
* @return true if the two structures are the same
*/
bool bacnet_action_property_value_same(
BACNET_ACTION_PROPERTY_VALUE *value1, BACNET_ACTION_PROPERTY_VALUE *value2)
{
bool status = false; /*return value */
if ((value1 == NULL) || (value2 == NULL)) {
return false;
}
/* does the tag match? */
if (value1->tag == value2->tag) {
status = true;
}
if (status) {
/* second test for same-ness */
status = false;
/* does the value match? */
switch (value1->tag) {
#if defined(BACACTION_NULL)
case BACNET_APPLICATION_TAG_NULL:
status = true;
break;
#endif
#if defined(BACACTION_BOOLEAN)
case BACNET_APPLICATION_TAG_BOOLEAN:
if (value1->type.Boolean == value2->type.Boolean) {
status = true;
}
break;
#endif
#if defined(BACACTION_UNSIGNED)
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
if (value1->type.Unsigned_Int == value2->type.Unsigned_Int) {
status = true;
}
break;
#endif
#if defined(BACACTION_SIGNED)
case BACNET_APPLICATION_TAG_SIGNED_INT:
if (value1->type.Signed_Int == value2->type.Signed_Int) {
status = true;
}
break;
#endif
#if defined(BACACTION_REAL)
case BACNET_APPLICATION_TAG_REAL:
if (!islessgreater(value1->type.Real, value2->type.Real)) {
status = true;
}
break;
#endif
#if defined(BACACTION_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
if (!islessgreater(value1->type.Double, value2->type.Double)) {
status = true;
}
break;
#endif
#if defined(BACACTION_ENUMERATED)
case BACNET_APPLICATION_TAG_ENUMERATED:
if (value1->type.Enumerated == value2->type.Enumerated) {
status = true;
}
break;
#endif
case BACNET_APPLICATION_TAG_EMPTYLIST:
status = true;
break;
default:
status = false;
break;
}
}
return status;
}
/**
* @brief Encode the BACnetActionCommand complex datatype
*
* BACnetActionCommand ::= SEQUENCE {
* deviceIdentifier [0] BACnetObjectIdentifier OPTIONAL,
* objectIdentifier [1] BACnetObjectIdentifier,
* propertyIdentifier [2] BACnetPropertyIdentifier,
* propertyArrayIndex [3] Unsigned OPTIONAL,
* --used only with array datatype
* propertyValue [4] ABSTRACT-SYNTAX.&Type,
* priority [5] Unsigned (1..16) OPTIONAL,
* --used only when property is commandable
* postDelay [6] Unsigned OPTIONAL,
* quitOnFailure [7] BOOLEAN,
* writeSuccessful [8] BOOLEAN
* }
*
* @param apdu [out] The APDU buffer to encode into, or NULL for length
* @param entry [in] The BACNET_ACTION_LIST structure to encode
* @return The length of the encoded data, or BACNET_STATUS_REJECT on error
*/
int bacnet_action_command_encode(uint8_t *apdu, BACNET_ACTION_LIST *entry)
{
int len = 0;
int apdu_len = 0;
if (!entry) {
return BACNET_STATUS_REJECT;
}
/* deviceIdentifier [0] BACnetObjectIdentifier OPTIONAL */
if (entry->Device_Id.instance <= BACNET_MAX_INSTANCE) {
len = encode_context_object_id(
apdu, 0, entry->Device_Id.type, entry->Device_Id.instance);
apdu_len += len;
if (apdu) {
apdu += len;
}
} else {
return BACNET_STATUS_REJECT;
}
/* objectIdentifier [1] BACnetObjectIdentifier */
len = encode_context_object_id(
apdu, 1, entry->Object_Id.type, entry->Object_Id.instance);
apdu_len += len;
if (apdu) {
apdu += len;
}
/* propertyIdentifier [2] BACnetPropertyIdentifier */
len = encode_context_enumerated(apdu, 2, entry->Property_Identifier);
apdu_len += len;
if (apdu) {
apdu += len;
}
/* propertyArrayIndex [3] Unsigned OPTIONAL */
if (entry->Property_Array_Index != BACNET_ARRAY_ALL) {
len = encode_context_unsigned(apdu, 3, entry->Property_Array_Index);
apdu_len += len;
if (apdu) {
apdu += len;
}
}
/* propertyValue [4] ABSTRACT-SYNTAX.&Type */
len = encode_opening_tag(apdu, 4);
apdu_len += len;
if (apdu) {
apdu += len;
}
len = bacnet_action_property_value_encode(apdu, &entry->Value);
apdu_len += len;
if (apdu) {
apdu += len;
}
len = encode_closing_tag(apdu, 4);
apdu_len += len;
if (apdu) {
apdu += len;
}
/* priority [5] Unsigned (1..16) OPTIONAL */
if (entry->Priority != BACNET_NO_PRIORITY) {
len = encode_context_unsigned(apdu, 5, entry->Priority);
apdu_len += len;
if (apdu) {
apdu += len;
}
}
/* postDelay [6] Unsigned OPTIONAL */
if (entry->Post_Delay != UINT32_MAX) {
len = encode_context_unsigned(apdu, 6, entry->Post_Delay);
apdu_len += len;
if (apdu) {
apdu += len;
}
}
/* quitOnFailure [7] BOOLEAN */
len = encode_context_boolean(apdu, 7, entry->Quit_On_Failure);
apdu_len += len;
if (apdu) {
apdu += len;
}
/* writeSuccessful [8] BOOLEAN */
len = encode_context_boolean(apdu, 8, entry->Write_Successful);
apdu_len += len;
return apdu_len;
}
/**
* @brief Decode the BACnetActionCommand complex datatype
* @param apdu [in] The APDU buffer to decode
* @param apdu_size [in] The size of the APDU buffer
* @param tag [in] The BACNET_APPLICATION_TAG of the value
* @param entry [out] The BACNET_ACTION_LIST structure to fill
* @return The length of the decoded data, or BACNET_STATUS_ERROR on error
*/
int bacnet_action_command_decode(
uint8_t *apdu, size_t apdu_size, BACNET_ACTION_LIST *entry)
{
int len = 0;
int apdu_len = 0;
int data_len = 0;
uint32_t instance = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE; /* for decoding */
uint32_t property = 0; /* for decoding */
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
bool boolean_value = false;
if (!apdu) {
return BACNET_STATUS_ERROR;
}
/* deviceIdentifier [0] BACnetObjectIdentifier OPTIONAL */
len = bacnet_object_id_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 0, &type, &instance);
if (len > 0) {
if (instance > BACNET_MAX_INSTANCE) {
return BACNET_STATUS_ERROR;
}
apdu_len += len;
if (entry) {
entry->Device_Id.type = type;
entry->Device_Id.instance = instance;
}
} else if (len == 0) {
/* wrong tag - optional - skip apdu_len increment */
if (entry) {
entry->Device_Id.type = OBJECT_DEVICE;
entry->Device_Id.instance = BACNET_MAX_INSTANCE;
}
} else {
return BACNET_STATUS_ERROR;
}
/* objectIdentifier [1] BACnetObjectIdentifier */
len = bacnet_object_id_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 1, &type, &instance);
if (len > 0) {
if (instance > BACNET_MAX_INSTANCE) {
return BACNET_STATUS_ERROR;
}
apdu_len += len;
if (entry) {
entry->Object_Id.type = type;
entry->Object_Id.instance = instance;
}
} else {
return BACNET_STATUS_ERROR;
}
/* propertyIdentifier [2] BACnetPropertyIdentifier */
len = bacnet_enumerated_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 2, &property);
if (len > 0) {
apdu_len += len;
if (entry) {
entry->Property_Identifier = (BACNET_PROPERTY_ID)property;
}
} else {
return BACNET_STATUS_ERROR;
}
/* propertyArrayIndex [3] Unsigned OPTIONAL */
len = bacnet_unsigned_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 3, &unsigned_value);
if (len > 0) {
apdu_len += len;
if (entry) {
entry->Property_Array_Index = unsigned_value;
}
} else {
/* wrong tag or malformed - optional - skip apdu_len increment */
if (entry) {
entry->Property_Array_Index = BACNET_ARRAY_ALL;
}
}
/* propertyValue [4] ABSTRACT-SYNTAX.&Type */
if (!bacnet_is_opening_tag_number(
&apdu[apdu_len], apdu_size - apdu_len, 4, &len)) {
return BACNET_STATUS_ERROR;
}
/* determine the length of the data blob */
data_len =
bacnet_enclosed_data_length(&apdu[apdu_len], apdu_size - apdu_len);
if (data_len == BACNET_STATUS_ERROR) {
return BACNET_STATUS_ERROR;
}
/* count the opening tag number length */
apdu_len += len;
/* decode data from the APDU */
if (data_len > MAX_APDU) {
/* not enough size in application_data to store the data chunk */
return BACNET_STATUS_ERROR;
}
if (entry) {
len = bacnet_action_property_value_decode(
&apdu[apdu_len], data_len, &entry->Value);
if (len < 0) {
/* signal internal error */
entry->Value.tag = BACNET_APPLICATION_TAG_ERROR;
}
}
/* add on the data length */
apdu_len += data_len;
/* closing */
if (!bacnet_is_closing_tag_number(
&apdu[apdu_len], apdu_size - apdu_len, 4, &len)) {
return BACNET_STATUS_ERROR;
}
/* count the closing tag number length */
apdu_len += len;
/* priority [5] Unsigned (1..16) OPTIONAL */
len = bacnet_unsigned_context_decode(
&apdu[apdu_len], apdu_len - apdu_size, 5, &unsigned_value);
if (len > 0) {
apdu_len += len;
if ((unsigned_value >= BACNET_MIN_PRIORITY) &&
(unsigned_value <= BACNET_MAX_PRIORITY)) {
if (entry) {
entry->Priority = (uint8_t)unsigned_value;
}
} else {
return BACNET_STATUS_ERROR;
}
} else {
/* wrong tag or malformed - optional - skip apdu_len increment */
if (entry) {
entry->Priority = BACNET_NO_PRIORITY;
}
}
/* postDelay [6] Unsigned OPTIONAL */
len = bacnet_unsigned_context_decode(
&apdu[apdu_len], apdu_len - apdu_size, 6, &unsigned_value);
if (len > 0) {
apdu_len += len;
if (entry) {
entry->Post_Delay = (uint8_t)unsigned_value;
}
} else {
/* wrong tag or malformed - optional - skip apdu_len increment */
if (entry) {
entry->Post_Delay = UINT32_MAX;
}
}
/* quitOnFailure [7] BOOLEAN */
len = bacnet_boolean_context_decode(
&apdu[apdu_len], apdu_len - apdu_size, 7, &boolean_value);
if (len > 0) {
apdu_len += len;
if (entry) {
entry->Quit_On_Failure = boolean_value;
}
} else {
return BACNET_STATUS_ERROR;
}
/* writeSuccessful [8] BOOLEAN */
len = bacnet_boolean_context_decode(
&apdu[apdu_len], apdu_len - apdu_size, 8, &boolean_value);
if (len > 0) {
apdu_len += len;
if (entry) {
entry->Write_Successful = boolean_value;
}
} else {
return BACNET_STATUS_ERROR;
}
return apdu_len;
}
/**
* @brief Compare two BACnetActionCommand complex datatypes
* @param entry1 [in] The first BACNET_ACTION_LIST structure to compare
* @param entry2 [in] The second BACNET_ACTION_LIST structure to compare
* @return True if the two structures are the same, else False
*/
bool bacnet_action_command_same(
BACNET_ACTION_LIST *entry1, BACNET_ACTION_LIST *entry2)
{
if (!entry1 || !entry2) {
return false;
}
if (entry1->Device_Id.type != entry2->Device_Id.type) {
return false;
}
if (entry1->Device_Id.instance != entry2->Device_Id.instance) {
return false;
}
if (entry1->Object_Id.type != entry2->Object_Id.type) {
return false;
}
if (entry1->Object_Id.instance != entry2->Object_Id.instance) {
return false;
}
if (entry1->Property_Identifier != entry2->Property_Identifier) {
return false;
}
if (entry1->Property_Array_Index != entry2->Property_Array_Index) {
return false;
}
if (!bacnet_action_property_value_same(&entry1->Value, &entry2->Value)) {
return false;
}
if (entry1->Priority != entry2->Priority) {
return false;
}
if (entry1->Post_Delay != entry2->Post_Delay) {
return false;
}
if (entry1->Quit_On_Failure != entry2->Quit_On_Failure) {
return false;
}
if (entry1->Write_Successful != entry2->Write_Successful) {
return false;
}
return true;
}
+108
View File
@@ -0,0 +1,108 @@
/**
* @file
* @brief API for BACnetActionCommand codec used by Command objects
* @author Steve Karg <skarg@users.sourceforge.net>
* @date 2024
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_ACTION_H
#define BACNET_ACTION_H
#include <stdbool.h>
#include <stdint.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
#include "bacnet/bactimevalue.h"
/* BACNET_ACTION_VALUE encodes and decodes the Property Value
in the Action Command. Choose the datatypes that your
application supports, or add additional. */
#if !( \
defined(BACACTION_ALL) || defined(BACACTION_NULL) || \
defined(BACACTION_BOOLEAN) || defined(BACACTION_UNSIGNED) || \
defined(BACACTION_SIGNED) || defined(BACACTION_REAL) || \
defined(BACACTION_DOUBLE) || defined(BACACTION_OCTET_STRING) || \
defined(BACACTION_ENUMERATED))
#define BACACTION_ALL
#endif
#if defined(BACACTION_ALL)
#define BACACTION_NULL
#define BACACTION_BOOLEAN
#define BACACTION_UNSIGNED
#define BACACTION_SIGNED
#define BACACTION_REAL
#define BACACTION_DOUBLE
#define BACACTION_ENUMERATED
#endif
typedef struct BACnetActionPropertyValue {
uint8_t tag;
union {
#if defined(BACACTION_NULL)
/* NULL - not needed because it is encoded in the tag alone */
#endif
#if defined(BACACTION_BOOLEAN)
bool Boolean;
#endif
#if defined(BACACTION_UNSIGNED)
BACNET_UNSIGNED_INTEGER Unsigned_Int;
#endif
#if defined(BACACTION_SIGNED)
int32_t Signed_Int;
#endif
#if defined(BACACTION_REAL)
float Real;
#endif
#if defined(BACACTION_DOUBLE)
double Double;
#endif
#if defined(BACACTION_ENUMERATED)
uint32_t Enumerated;
#endif
} type;
/* simple linked list if needed */
struct BACnetActionPropertyValue *next;
} BACNET_ACTION_PROPERTY_VALUE;
typedef struct bacnet_action_list {
BACNET_OBJECT_ID Device_Id; /* Optional */
BACNET_OBJECT_ID Object_Id;
BACNET_PROPERTY_ID Property_Identifier;
uint32_t Property_Array_Index; /* Conditional */
BACNET_ACTION_PROPERTY_VALUE Value;
uint8_t Priority; /* Conditional */
uint32_t Post_Delay; /* Optional */
bool Quit_On_Failure;
bool Write_Successful;
struct bacnet_action_list *next;
} BACNET_ACTION_LIST;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
int bacnet_action_property_value_encode(
uint8_t *apdu, BACNET_ACTION_PROPERTY_VALUE *value);
BACNET_STACK_EXPORT
int bacnet_action_property_value_decode(
uint8_t *apdu, uint32_t apdu_size, BACNET_ACTION_PROPERTY_VALUE *value);
BACNET_STACK_EXPORT
bool bacnet_action_property_value_same(
BACNET_ACTION_PROPERTY_VALUE *value1, BACNET_ACTION_PROPERTY_VALUE *value2);
BACNET_STACK_EXPORT
int bacnet_action_command_encode(uint8_t *apdu, BACNET_ACTION_LIST *entry);
BACNET_STACK_EXPORT
int bacnet_action_command_decode(
uint8_t *apdu, size_t apdu_size, BACNET_ACTION_LIST *entry);
BACNET_STACK_EXPORT
bool bacnet_action_command_same(
BACNET_ACTION_LIST *entry1, BACNET_ACTION_LIST *entry2);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+1604 -1143
View File
File diff suppressed because it is too large Load Diff
+49 -5
View File
@@ -8,12 +8,14 @@
#ifndef BACNET_APP_H
#define BACNET_APP_H
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacaction.h"
#include "bacnet/bacdest.h"
#include "bacnet/bacint.h"
#include "bacnet/bacstr.h"
@@ -32,6 +34,19 @@
#endif
#endif
/** BACnetScale ::= CHOICE {
float-scale [0] REAL,
integer-scale [1] INTEGER
}
*/
typedef struct BACnetScale {
bool float_scale;
union {
float real_scale;
int32_t integer_scale;
} type;
} BACNET_SCALE;
struct BACnet_Application_Data_Value;
typedef struct BACnet_Application_Data_Value {
bool context_specific; /* true if context specific data */
@@ -125,6 +140,12 @@ typedef struct BACnet_Application_Data_Value {
#endif
#if defined (BACAPP_FDT_ENTRY)
BACNET_FDT_ENTRY FDT_Entry;
#endif
#if defined (BACAPP_ACTION_COMMAND)
BACNET_ACTION_LIST Action_Command;
#endif
#if defined (BACAPP_SCALE)
BACNET_SCALE Scale;
#endif
} type;
/* simple linked list if needed */
@@ -203,6 +224,12 @@ extern "C" {
uint8_t * apdu,
BACNET_APPLICATION_DATA_VALUE * value);
BACNET_STACK_EXPORT
int bacapp_encode_known_property(
uint8_t *apdu,
BACNET_APPLICATION_DATA_VALUE *value,
BACNET_OBJECT_TYPE object_type,
BACNET_PROPERTY_ID property);
BACNET_STACK_EXPORT
int bacapp_data_decode(
uint8_t * apdu,
uint32_t apdu_size,
@@ -241,6 +268,7 @@ extern "C" {
BACNET_APPLICATION_DATA_VALUE * value,
BACNET_PROPERTY_ID property);
BACNET_STACK_DEPRECATED("Use bacapp_encode_known_property() instead")
BACNET_STACK_EXPORT
int bacapp_encode_context_data(
uint8_t * apdu,
@@ -253,17 +281,25 @@ extern "C" {
uint8_t context_tag_number,
BACNET_APPLICATION_DATA_VALUE * value);
BACNET_STACK_DEPRECATED("Use bacapp_known_property_tag() instead")
BACNET_STACK_EXPORT
BACNET_APPLICATION_TAG bacapp_context_tag_type(
BACNET_PROPERTY_ID property,
uint8_t tag_number);
BACNET_STACK_DEPRECATED("Use bacapp_encode_known_property() instead")
BACNET_STACK_EXPORT
int bacapp_decode_generic_property(
uint8_t * apdu,
int max_apdu_len,
BACNET_APPLICATION_DATA_VALUE * value,
BACNET_PROPERTY_ID prop);
BACNET_STACK_EXPORT
int bacapp_decode_application_tag_value(
uint8_t *apdu,
size_t apdu_size,
BACNET_APPLICATION_TAG tag,
BACNET_APPLICATION_DATA_VALUE *value);
BACNET_STACK_EXPORT
int bacapp_decode_known_property(uint8_t *apdu,
int max_apdu_len,
@@ -281,24 +317,27 @@ extern "C" {
BACNET_APPLICATION_DATA_VALUE * dest_value,
BACNET_APPLICATION_DATA_VALUE * src_value);
/* returns the length of data between an opening tag and a closing tag.
Expects that the first octet contain the opening tag.
Include a value property identifier for context specific data
such as the value received in a WriteProperty request */
BACNET_STACK_DEPRECATED("Use bacnet_enclosed_data_length() instead")
BACNET_STACK_EXPORT
int bacapp_data_len(
uint8_t * apdu,
unsigned max_apdu_len,
BACNET_PROPERTY_ID property);
BACNET_STACK_DEPRECATED("Use bacnet_application_data_length() instead")
BACNET_STACK_EXPORT
int bacapp_decode_data_len(
uint8_t * apdu,
uint8_t tag_data_type,
uint32_t len_value_type);
BACNET_STACK_DEPRECATED("Use bacnet_enclosed_data_length() instead")
BACNET_STACK_EXPORT
int bacapp_decode_application_data_len(
uint8_t * apdu,
unsigned max_apdu_len);
BACNET_STACK_DEPRECATED("Use bacnet_enclosed_data_length() instead")
BACNET_STACK_EXPORT
int bacapp_decode_context_data_len(
uint8_t * apdu,
@@ -306,6 +345,11 @@ extern "C" {
BACNET_PROPERTY_ID property);
BACNET_STACK_EXPORT
int bacapp_snprintf(
char *buffer,
size_t count,
const char *format, ...);
BACNET_STACK_EXPORT
int bacapp_snprintf_shift(
int len,
char **buf,
+131
View File
@@ -756,6 +756,137 @@ int bacnet_tag_number_and_value_decode(
return len;
}
/**
* @brief Determine the data length from the application tag number
* @param tag_number application tag number to be evaluated.
* @param len_value_type Length of the data in bytes.
* @return datalength for the given tag, or INT_MAX if out of range.
*/
int bacnet_application_data_length(
uint8_t tag_number, uint32_t len_value_type)
{
int len = 0;
switch (tag_number) {
case BACNET_APPLICATION_TAG_NULL:
break;
case BACNET_APPLICATION_TAG_BOOLEAN:
break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
case BACNET_APPLICATION_TAG_SIGNED_INT:
case BACNET_APPLICATION_TAG_REAL:
case BACNET_APPLICATION_TAG_DOUBLE:
case BACNET_APPLICATION_TAG_OCTET_STRING:
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
case BACNET_APPLICATION_TAG_BIT_STRING:
case BACNET_APPLICATION_TAG_ENUMERATED:
case BACNET_APPLICATION_TAG_DATE:
case BACNET_APPLICATION_TAG_TIME:
case BACNET_APPLICATION_TAG_OBJECT_ID:
len = INT_MAX;
if (len_value_type < INT_MAX) {
len = (int)len_value_type;
}
break;
default:
break;
}
return len;
}
/**
* @brief Returns the length of data between an opening tag and a closing tag.
* @note Expects that the first octet contain the opening tag.
* @param apdu Pointer to the APDU buffer
* @param apdu_size Bytes valid in the buffer
* @param property ID of the property to get the length for.
* @return length of data between an opening tag and a closing tag 0..N,
* or BACNET_STATUS_ERROR.
*/
int bacnet_enclosed_data_length(
uint8_t *apdu, size_t apdu_size)
{
int len = 0;
int total_len = 0;
int apdu_len = 0;
BACNET_TAG tag = { 0 };
uint8_t opening_tag_number = 0;
uint8_t opening_tag_number_counter = 0;
bool total_len_enable = false;
if (!apdu) {
return BACNET_STATUS_ERROR;
}
if (apdu_size <= apdu_len) {
/* error: exceeding our buffer limit */
return BACNET_STATUS_ERROR;
}
if (!bacnet_is_opening_tag(apdu, apdu_size)) {
/* error: opening tag is missing */
return BACNET_STATUS_ERROR;
}
do {
len = bacnet_tag_decode(apdu, apdu_size - apdu_len, &tag);
if (len == 0) {
return BACNET_STATUS_ERROR;
}
if (tag.opening) {
if (opening_tag_number_counter == 0) {
opening_tag_number = tag.number;
opening_tag_number_counter = 1;
total_len_enable = false;
} else if (tag.number == opening_tag_number) {
total_len_enable = true;
opening_tag_number_counter++;
} else {
total_len_enable = true;
}
} else if (tag.closing) {
if (tag.number == opening_tag_number) {
if (opening_tag_number_counter > 0) {
opening_tag_number_counter--;
}
}
total_len_enable = true;
} else if (tag.context) {
if (tag.len_value_type > INT_MAX) {
/* error: length is out of range */
return BACNET_STATUS_ERROR;
}
len += tag.len_value_type;
total_len_enable = true;
} else {
if (tag.len_value_type > INT_MAX) {
/* error: length is out of range */
return BACNET_STATUS_ERROR;
}
/* application tagged data */
len += bacnet_application_data_length(tag.number,
tag.len_value_type);
total_len_enable = true;
}
if (opening_tag_number_counter > 0) {
if (len > 0) {
if (total_len_enable) {
total_len += len;
}
} else {
/* error: len is not incrementing */
return BACNET_STATUS_ERROR;
}
apdu_len += len;
if (apdu_size <= apdu_len) {
/* error: exceeding our buffer limit */
return BACNET_STATUS_ERROR;
}
apdu += len;
}
} while (opening_tag_number_counter > 0);
return total_len;
}
/**
* @brief Returns true if the tag is context specific
* and matches, as defined in clause 20.2.1.3.2 Constructed
+7
View File
@@ -84,6 +84,13 @@ BACNET_STACK_EXPORT
bool bacnet_is_closing_tag_number(
uint8_t *apdu, uint32_t apdu_size, uint8_t tag_number, int *tag_length);
BACNET_STACK_EXPORT
int bacnet_application_data_length(
uint8_t tag_number, uint32_t len_value_type);
BACNET_STACK_EXPORT
int bacnet_enclosed_data_length(
uint8_t *apdu, size_t apdu_size);
BACNET_STACK_DEPRECATED("Use bacnet_tag_decode() instead")
BACNET_STACK_EXPORT
int bacnet_tag_number_and_value_decode(
+1
View File
@@ -10,6 +10,7 @@
#include <stddef.h>
#include <stdint.h>
#include <limits.h>
/* config is always first to allow developers to override */
#include "bacnet/config.h"
/* BACnet Stack core enumerations */
+6 -2
View File
@@ -1557,7 +1557,7 @@ typedef enum {
BACNET_APPLICATION_TAG_RESERVE3 = 15,
MAX_BACNET_APPLICATION_TAG = 16,
/* Extra stuff - complex tagged data - not specifically enumerated */
/* Complex tagged constructed data types - not specifically enumerated */
/* Means : "nothing", an empty list, not even a null character */
BACNET_APPLICATION_TAG_EMPTYLIST,
@@ -1602,7 +1602,11 @@ typedef enum {
/* BACnetBDTEntry */
BACNET_APPLICATION_TAG_BDT_ENTRY,
/* BACnetFDTEntry */
BACNET_APPLICATION_TAG_FDT_ENTRY
BACNET_APPLICATION_TAG_FDT_ENTRY,
/* BACnetActionCommand */
BACNET_APPLICATION_TAG_ACTION_COMMAND,
/* BACnetScale */
BACNET_APPLICATION_TAG_SCALE
} BACNET_APPLICATION_TAG;
/* note: these are not the real values, */
+28 -42
View File
@@ -6,6 +6,8 @@
* @date 2004
* @copyright SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -393,6 +395,31 @@ bool characterstring_init(BACNET_CHARACTER_STRING *char_string,
return status;
}
/**
* @brief Return the length of a string, within a maximum length
* @note The strnlen function is non-standard and not available in
* all libc implementations. This function is a workaround for that.
* @details The strnlen function computes the smaller of the number
* of characters in the array pointed to by s, not including any
* terminating null character, or the value of the maxlen argument.
* The strnlen function examines no more than maxlen bytes of the
* array pointed to by s.
* @param s - string to check
* @param maxlen - maximum length to check
* @return The strnlen function returns the number of bytes that
* precede the first null character in the array pointed to by s,
* if s contains a null character within the first maxlen characters;
* otherwise, it returns maxlen.
*/
size_t characterstring_strnlen(const char *str, size_t maxlen)
{
char* p = memchr(str, 0, maxlen);
if (p == NULL) {
return maxlen;
}
return (p - str);
}
/**
* Initialize a BACnet characater string.
* Returns false if the string exceeds capacity.
@@ -408,7 +435,7 @@ bool characterstring_init_ansi_safe(
BACNET_CHARACTER_STRING *char_string, const char *value, size_t tmax)
{
return characterstring_init(char_string, CHARACTER_ANSI_X34, value,
value ? bacnet_strnlen(value, tmax) : 0);
value ? characterstring_strnlen(value, tmax) : 0);
}
/**
@@ -1191,44 +1218,3 @@ bool octetstring_value_same(
return false;
}
#endif
/**
* @brief Compare two strings ignoring case
* @param s1 - first string
* @param s2 - second string
* @return 0 if the strings are equal, otherwise non-zero
*/
int bacnet_stricmp(const char *s1, const char *s2)
{
unsigned char c1, c2;
do {
c1 = (unsigned char)*s1;
c2 = (unsigned char)*s2;
c1 = (unsigned char)tolower(c1);
c2 = (unsigned char)tolower(c2);
s1++;
s2++;
} while ((c1 == c2) && (c1 != '\0'));
return (int)c1 - c2;
}
/**
* @brief non-standard strnlen function
* @param s - string to check
* @param maxlen - maximum length to check
* @return length of string, up to maxlen
*/
size_t bacnet_strnlen(const char *s, size_t maxlen)
{
size_t len;
for (len = 0; len < maxlen; len++, s++) {
if (!*s) {
break;
}
}
return len;
}
+6 -6
View File
@@ -8,7 +8,6 @@
*/
#ifndef BACNET_STRING_H
#define BACNET_STRING_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
@@ -100,10 +99,16 @@ extern "C" {
bool characterstring_init_ansi(
BACNET_CHARACTER_STRING * char_string,
const char *value);
BACNET_STACK_EXPORT
size_t characterstring_strnlen(
const char *str,
size_t maxlen);
BACNET_STACK_EXPORT
bool characterstring_init_ansi_safe(
BACNET_CHARACTER_STRING * char_string,
const char *value,
size_t tmax);
BACNET_STACK_EXPORT
bool characterstring_copy(
BACNET_CHARACTER_STRING * dest,
BACNET_CHARACTER_STRING * src);
@@ -215,11 +220,6 @@ extern "C" {
BACNET_OCTET_STRING * octet_string1,
BACNET_OCTET_STRING * octet_string2);
BACNET_STACK_EXPORT
int bacnet_stricmp(const char *s1, const char *s2);
BACNET_STACK_EXPORT
size_t bacnet_strnlen(const char *s, size_t maxlen);
#ifdef __cplusplus
}
#endif /* __cplusplus */
+4
View File
@@ -138,8 +138,12 @@ INDTEXT_DATA bacnet_application_tag_names[] = { { BACNET_APPLICATION_TAG_NULL,
"BACnetReadAccessSpecification" },
{ BACNET_APPLICATION_TAG_LIGHTING_COMMAND, "BACnetLightingCommand" },
{ BACNET_APPLICATION_TAG_HOST_N_PORT, "BACnetHostNPort" },
{ BACNET_APPLICATION_TAG_XY_COLOR, "BACnetxyColor" },
{ BACNET_APPLICATION_TAG_COLOR_COMMAND, "BACnetColorCommand" },
{ BACNET_APPLICATION_TAG_BDT_ENTRY, "BACnetBDTEntry" },
{ BACNET_APPLICATION_TAG_FDT_ENTRY, "BACnetFDTEntry" },
{ BACNET_APPLICATION_TAG_ACTION_COMMAND, "BACnetActionCommand" },
{ BACNET_APPLICATION_TAG_SCALE, "BACnetScale" },
{ 0, NULL } };
const char *bactext_application_tag_name(unsigned index)
+8 -4
View File
@@ -151,13 +151,17 @@ unsigned Binary_Input_Count(void)
/**
* @brief Determines the object instance-number for a given 0..N index
* of Binary Input objects where N is Binary_Input_Count().
* @param index - 0..MAX_BINARY_INPUTS value
* @return object instance-number for the given index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Binary_Input_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+9 -8
View File
@@ -116,17 +116,18 @@ unsigned BitString_Value_Count(void)
}
/**
* We simply have 0-n object instances. Yours might be
* more complex, and then you need to return the index
* that correlates to the correct instance number
*
* @param index Object index
*
* @return Index in the object table.
* @brief Determines the object instance-number for a given 0..N index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t BitString_Value_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+7 -3
View File
@@ -154,12 +154,16 @@ unsigned Binary_Value_Count(void)
/**
* @brief Determines the object instance-number for a given 0..N index
* of objects where N is the count.
* @param index - 0..count value
* @return object instance-number for the given index
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Binary_Value_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+89 -358
View File
@@ -21,316 +21,34 @@
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacaction.h"
#include "bacnet/bacdcode.h"
#include "bacnet/bactext.h"
#include "bacnet/lighting.h"
#include "bacnet/proplist.h"
#include "bacnet/timestamp.h"
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/services.h"
/* me!*/
#include "bacnet/basic/object/command.h"
/*
BACnetActionCommand ::= SEQUENCE {
deviceIdentifier [0] BACnetObjectIdentifier OPTIONAL,
objectIdentifier [1] BACnetObjectIdentifier,
propertyIdentifier [2] BACnetPropertyIdentifier,
propertyArrayIndex [3] Unsigned OPTIONAL,
--used only with array datatype
propertyValue [4] ABSTRACT-SYNTAX.&Type,
priority [5] Unsigned (1..16) OPTIONAL,
--used only when property is commandable
postDelay [6] Unsigned OPTIONAL,
quitOnFailure [7] BOOLEAN,
writeSuccessful [8] BOOLEAN
}
*/
int cl_encode_apdu(uint8_t *apdu, BACNET_ACTION_LIST *bcl)
{
int len = 0;
int apdu_len = 0;
if (bcl->Device_Id.instance <= BACNET_MAX_INSTANCE) {
len = encode_context_object_id(
&apdu[apdu_len], 0, bcl->Device_Id.type, bcl->Device_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
/* TODO: Check for object type and instance limits */
len = encode_context_object_id(
&apdu[apdu_len], 1, bcl->Object_Id.type, bcl->Object_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 2, bcl->Property_Identifier);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
if (bcl->Property_Array_Index != BACNET_ARRAY_ALL) {
len = encode_context_unsigned(
&apdu[apdu_len], 3, bcl->Property_Array_Index);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
/* BACnet Testing Observed Incident oi00108
Command Action not correctly formatted
Revealed by BACnet Test Client v1.8.16 (
www.bac-test.com/bacnet-test-client-download ) BITS: BIT00031 BC
135.1: 9.20.1.7 BC 135.1: 9.20.1.9 Any discussions can be directed to
edward@bac-test.com Please feel free to remove this comment when my
changes have been reviewed by all interested parties. Say 6 months ->
September 2016 */
len = encode_opening_tag(&apdu[apdu_len], 4);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len = bacapp_encode_application_data(&apdu[apdu_len], &bcl->Value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 4);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
if (bcl->Priority != BACNET_NO_PRIORITY) {
len = encode_context_unsigned(&apdu[apdu_len], 5, bcl->Priority);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
if (bcl->Post_Delay != 0xFFFFFFFFU) {
len = encode_context_unsigned(&apdu[apdu_len], 6, bcl->Post_Delay);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
len = encode_context_boolean(&apdu[apdu_len], 7, bcl->Quit_On_Failure);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len = encode_context_boolean(&apdu[apdu_len], 8, bcl->Write_Successful);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
return apdu_len;
}
int cl_decode_apdu(uint8_t *apdu,
unsigned apdu_len,
BACNET_APPLICATION_TAG tag,
BACNET_ACTION_LIST *bcl)
{
int len = 0;
int dec_len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint32_t enum_value = 0;
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
if (decode_is_context_tag(&apdu[dec_len], 0)) {
/* Tag 0: Device ID */
dec_len++;
len = decode_object_id(
&apdu[dec_len], &bcl->Device_Id.type, &bcl->Device_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
}
if (!decode_is_context_tag(&apdu[dec_len++], 1)) {
return BACNET_STATUS_REJECT;
}
len = decode_object_id(
&apdu[dec_len], &bcl->Object_Id.type, &bcl->Object_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
if (tag_number != 2) {
return BACNET_STATUS_REJECT;
}
len = decode_enumerated(&apdu[dec_len], len_value_type, &enum_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Property_Identifier = enum_value;
dec_len += len;
if (decode_is_context_tag(&apdu[dec_len], 3)) {
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
dec_len += len;
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Property_Array_Index = unsigned_value;
dec_len += len;
} else {
bcl->Property_Array_Index = BACNET_ARRAY_ALL;
}
if (!decode_is_context_tag(&apdu[dec_len], 4)) {
return BACNET_STATUS_REJECT;
}
bcl->Value.context_specific = true;
bcl->Value.context_tag = 4;
bcl->Value.tag = tag;
switch (tag) {
case BACNET_APPLICATION_TAG_NULL:
len = 1;
break;
case BACNET_APPLICATION_TAG_BOOLEAN:
len = decode_context_boolean2(
&apdu[dec_len], 4, &bcl->Value.type.Boolean);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
len = decode_context_unsigned(&apdu[dec_len], 4, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Value.type.Unsigned_Int = unsigned_value;
break;
case BACNET_APPLICATION_TAG_SIGNED_INT:
len = decode_context_signed(
&apdu[dec_len], 4, &bcl->Value.type.Signed_Int);
break;
case BACNET_APPLICATION_TAG_REAL:
len = decode_context_real(&apdu[dec_len], 4, &bcl->Value.type.Real);
break;
case BACNET_APPLICATION_TAG_DOUBLE:
len = decode_context_double(
&apdu[dec_len], 4, &bcl->Value.type.Double);
break;
case BACNET_APPLICATION_TAG_OCTET_STRING:
len = decode_context_octet_string(
&apdu[dec_len], 4, &bcl->Value.type.Octet_String);
break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
len = decode_context_character_string(
&apdu[dec_len], 4, &bcl->Value.type.Character_String);
break;
case BACNET_APPLICATION_TAG_BIT_STRING:
len = decode_context_bitstring(
&apdu[dec_len], 4, &bcl->Value.type.Bit_String);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
break;
case BACNET_APPLICATION_TAG_ENUMERATED:
len = decode_context_enumerated(
&apdu[dec_len], 4, &bcl->Value.type.Enumerated);
break;
case BACNET_APPLICATION_TAG_DATE:
len = decode_context_date(&apdu[dec_len], 4, &bcl->Value.type.Date);
break;
case BACNET_APPLICATION_TAG_TIME:
len = decode_context_bacnet_time(
&apdu[dec_len], 4, &bcl->Value.type.Time);
break;
case BACNET_APPLICATION_TAG_OBJECT_ID:
len = decode_context_object_id(&apdu[dec_len], 4,
&bcl->Value.type.Object_Id.type,
&bcl->Value.type.Object_Id.instance);
break;
#if defined(BACAPP_TYPES_EXTRA)
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
len = lighting_command_decode(&apdu[dec_len], apdu_len - dec_len,
&bcl->Value.type.Lighting_Command);
break;
#endif
default:
return BACNET_STATUS_REJECT;
}
if (len > 0) {
dec_len += len;
}
if (decode_is_context_tag(&apdu[dec_len], 5)) {
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
dec_len += len;
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Priority = (uint8_t)unsigned_value;
dec_len += len;
} else {
bcl->Priority = BACNET_NO_PRIORITY;
}
if (decode_is_context_tag(&apdu[dec_len], 6)) {
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
dec_len += len;
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Post_Delay = unsigned_value;
dec_len += len;
} else {
bcl->Post_Delay = 0xFFFFFFFFU;
}
if (!decode_is_context_tag(&apdu[dec_len], 7)) {
return BACNET_STATUS_REJECT;
}
len = decode_context_boolean2(&apdu[dec_len], 7, &bcl->Quit_On_Failure);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
if (!decode_is_context_tag(&apdu[dec_len], 8)) {
return BACNET_STATUS_REJECT;
}
len = decode_context_boolean2(&apdu[dec_len], 8, &bcl->Write_Successful);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
if (dec_len < apdu_len) {
return BACNET_STATUS_REJECT;
}
return dec_len;
}
COMMAND_DESCR Command_Descr[MAX_COMMANDS];
static COMMAND_DESCR Command_Descr[MAX_COMMANDS];
/* clang-format off */
/* These arrays are used by the ReadPropertyMultiple handler */
static const int Command_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_IN_PROCESS,
PROP_ALL_WRITES_SUCCESSFUL, PROP_ACTION, -1 };
static const int Command_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME,
PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE,
PROP_IN_PROCESS,
PROP_ALL_WRITES_SUCCESSFUL,
PROP_ACTION,
-1 };
static const int Command_Properties_Optional[] = { PROP_DESCRIPTION, -1 };
static const int Command_Properties_Optional[] = { -1 };
static const int Command_Properties_Proprietary[] = { -1 };
/* clang-format on */
/**
* Returns the list of required, optional, and proprietary properties.
@@ -584,14 +302,78 @@ bool Command_Object_Name(
index = Command_Instance_To_Index(object_instance);
if (index < MAX_COMMANDS) {
snprintf(text, sizeof(text), "COMMAND %lu",
(unsigned long)object_instance);
snprintf(
text, sizeof(text), "COMMAND %lu", (unsigned long)object_instance);
status = characterstring_init_ansi(object_name, text);
}
return status;
}
/**
* @brief For a given object instance-number, returns the object data
* @param object_instance [in] BACnet network port object instance number
* @return pointer to the object data
*/
static COMMAND_DESCR *Object_Data(uint32_t object_instance)
{
unsigned int index = Command_Instance_To_Index(object_instance);
if (index < MAX_COMMANDS) {
return &Command_Descr[index];
}
return NULL;
}
BACNET_ACTION_LIST * Command_Action_List_Entry(
uint32_t instance, unsigned index)
{
COMMAND_DESCR *pObject;
BACNET_ACTION_LIST *pAction = NULL;
pObject = Object_Data(instance);
if (pObject && (index < MAX_COMMAND_ACTIONS)) {
pAction = &pObject->Action[index];
}
return pAction;
}
/**
* @brief For a given object instance-number, returns the number of actions
*/
unsigned Command_Action_List_Count(
uint32_t instance)
{
(void)instance;
return MAX_COMMAND_ACTIONS;
}
/**
* @brief Encode a BACnetARRAY property element
* @param object_instance [in] BACnet network port object instance number
* @param index [in] array index requested:
* 0 to N for individual array members
* @param apdu [out] Buffer in which the APDU contents are built, or NULL to
* return the length of buffer if it had been built
* @return The length of the apdu encoded or
* BACNET_STATUS_ERROR for ERROR_CODE_INVALID_ARRAY_INDEX
*/
static int Command_Action_List_Encode(
uint32_t object_instance, BACNET_ARRAY_INDEX index, uint8_t *apdu)
{
int apdu_len = BACNET_STATUS_ERROR;
COMMAND_DESCR *pObject;
pObject = Object_Data(object_instance);
if (pObject && (index < MAX_COMMAND_ACTIONS)) {
apdu_len = bacnet_action_command_encode(
apdu, &pObject->Action[index]);
}
return apdu_len;
}
/**
* ReadProperty handler for this object. For the given ReadProperty
* data, the application_data is loaded or the error flags are set.
@@ -605,26 +387,16 @@ bool Command_Object_Name(
int Command_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = 0; /* return value */
int len = 0;
BACNET_CHARACTER_STRING char_string;
unsigned object_index = 0;
uint8_t *apdu = NULL;
uint16_t apdu_max = 0;
COMMAND_DESCR *CurrentCommand;
int apdu_size = 0;
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
apdu_max = rpdata->application_data_len;
object_index = Command_Instance_To_Index(rpdata->object_instance);
if (object_index < MAX_COMMANDS) {
CurrentCommand = &Command_Descr[object_index];
} else {
return false;
}
apdu = rpdata->application_data;
apdu_size = rpdata->application_data_len;
switch ((int)rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER:
apdu_len = encode_application_object_id(
@@ -632,7 +404,6 @@ int Command_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
break;
case PROP_OBJECT_NAME:
case PROP_DESCRIPTION:
Command_Object_Name(rpdata->object_instance, &char_string);
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
@@ -651,60 +422,20 @@ int Command_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
&apdu[0], Command_In_Process(rpdata->object_instance));
break;
case PROP_ALL_WRITES_SUCCESSFUL:
apdu_len = encode_application_boolean(&apdu[0],
apdu_len = encode_application_boolean(
&apdu[0],
Command_All_Writes_Successful(rpdata->object_instance));
break;
case PROP_ACTION:
/* TODO */
if (rpdata->array_index == 0) {
apdu_len =
encode_application_unsigned(&apdu[0], MAX_COMMAND_ACTIONS);
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
int i;
for (i = 0; i < MAX_COMMAND_ACTIONS; i++) {
BACNET_ACTION_LIST *Curr_CL_Member =
&CurrentCommand->Action[0];
/* another loop, for additional actions in the list */
for (; Curr_CL_Member != NULL;
Curr_CL_Member = Curr_CL_Member->next) {
len = cl_encode_apdu(
&apdu[apdu_len], &CurrentCommand->Action[0]);
apdu_len += len;
/* assume the next one is of the same length, which need
* not be the case */
if ((i != MAX_COMMAND_ACTIONS - 1) &&
(apdu_len + len) >= apdu_max) {
apdu_len = bacnet_array_encode(rpdata->object_instance,
rpdata->array_index, Command_Action_List_Encode,
MAX_COMMAND_ACTIONS, apdu, apdu_size);
if (apdu_len == BACNET_STATUS_ABORT) {
rpdata->error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
apdu_len = BACNET_STATUS_ABORT;
break;
}
}
}
} else {
if (rpdata->array_index < MAX_COMMAND_ACTIONS) {
BACNET_ACTION_LIST *Curr_CL_Member =
&CurrentCommand->Action[rpdata->array_index];
/* another loop, for additional actions in the list */
for (; Curr_CL_Member != NULL;
Curr_CL_Member = Curr_CL_Member->next) {
len = cl_encode_apdu(
&apdu[apdu_len], &CurrentCommand->Action[0]);
apdu_len += len;
/* assume the next one is of the same length, which need
* not be the case */
if ((apdu_len + len) >= apdu_max) {
rpdata->error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
apdu_len = BACNET_STATUS_ABORT;
break;
}
}
} else {
} else if (apdu_len == BACNET_STATUS_ERROR) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
apdu_len = BACNET_STATUS_ERROR;
}
}
break;
default:
+8 -23
View File
@@ -12,6 +12,7 @@
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacaction.h"
#include "bacnet/rp.h"
#include "bacnet/wp.h"
@@ -27,29 +28,6 @@
extern "C" {
#endif /* __cplusplus */
typedef struct bacnet_action_list {
BACNET_OBJECT_ID Device_Id; /* Optional */
BACNET_OBJECT_ID Object_Id;
BACNET_PROPERTY_ID Property_Identifier;
uint32_t Property_Array_Index; /* Conditional */
BACNET_APPLICATION_DATA_VALUE Value;
uint8_t Priority; /* Conditional */
uint32_t Post_Delay; /* Optional */
bool Quit_On_Failure;
bool Write_Successful;
struct bacnet_action_list *next;
} BACNET_ACTION_LIST;
int cl_encode_apdu(
uint8_t * apdu,
BACNET_ACTION_LIST * bcl);
int cl_decode_apdu(
uint8_t * apdu,
unsigned apdu_len,
BACNET_APPLICATION_TAG tag,
BACNET_ACTION_LIST * bcl);
typedef struct command_descr {
uint32_t Present_Value;
bool In_Process;
@@ -144,6 +122,13 @@ extern "C" {
uint32_t instance,
float value);
BACNET_STACK_EXPORT
BACNET_ACTION_LIST * Command_Action_List_Entry(
uint32_t instance, unsigned index);
BACNET_STACK_EXPORT
unsigned Command_Action_List_Count(
uint32_t instance);
/* note: header of Intrinsic_Reporting function is required
even when INTRINSIC_REPORTING is not defined */
BACNET_STACK_EXPORT
+345 -108
View File
@@ -188,33 +188,6 @@ unsigned Lighting_Output_Instance_To_Index(uint32_t object_instance)
return Keylist_Index(Object_List, object_instance);
}
/**
* For a given object instance-number, determines the present-value
*
* @param object_instance - object-instance number of the object
*
* @return present-value of the object
*/
float Lighting_Output_Present_Value(uint32_t object_instance)
{
float value = 0.0;
unsigned p = 0;
struct object_data *pObject;
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
value = pObject->Relinquish_Default;
for (p = 0; p < BACNET_MAX_PRIORITY; p++) {
if (BIT_CHECK(pObject->Priority_Active_Bits, p)) {
value = pObject->Priority_Array[p];
break;
}
}
}
return value;
}
/**
* @brief Get the priority-array active status for the specific priority
* @param object [in] BACnet object instance
@@ -236,6 +209,27 @@ Priority_Array_Active(struct object_data *pObject, BACNET_ARRAY_INDEX priority)
return active;
}
/**
* @brief Get the priority-array value for the specific priority
* @param object [in] BACnet object instance
* @param priority [in] array index requested:
* 0 to N for individual array members
* @return The priority-array value for the specific priority
*/
static float
Priority_Array_Value(struct object_data *pObject, BACNET_ARRAY_INDEX priority)
{
float real_value = 0.0;
if (priority < BACNET_MAX_PRIORITY) {
if (BIT_CHECK(pObject->Priority_Active_Bits, priority)) {
real_value = pObject->Priority_Array[priority];
}
}
return real_value;
}
/**
* @brief Get the value of the next highest non-NULL priority, including
* Relinquish_Default
@@ -262,24 +256,23 @@ static float Priority_Array_Next_Value(
}
/**
* @brief Get the priority-array value for the specific priority
* @param object [in] BACnet object instance
* @param priority [in] array index requested:
* 0 to N for individual array members
* @return The priority-array value for the specific priority
* For a given object instance-number, determines the present-value
*
* @param object_instance - object-instance number of the object
*
* @return present-value of the object
*/
static float
Priority_Array_Value(struct object_data *pObject, BACNET_ARRAY_INDEX priority)
float Lighting_Output_Present_Value(uint32_t object_instance)
{
float real_value = 0.0;
float value = 0.0;
struct object_data *pObject;
if (priority < BACNET_MAX_PRIORITY) {
if (BIT_CHECK(pObject->Priority_Active_Bits, priority)) {
real_value = pObject->Priority_Array[priority];
}
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
value = Priority_Array_Next_Value(pObject, 0);
}
return real_value;
return value;
}
/**
@@ -437,6 +430,181 @@ bool Lighting_Output_Present_Value_Set(
return status;
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Warn(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(Priority_Array_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur
if any of the following conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN;
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Warn_Off(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(Priority_Array_Next_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur and
the value 0.0% written at the specified
priority immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The Present_Value is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN_OFF;
} else {
Present_Value_Set(pObject, 0.0, priority);
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Warn_Relinquish(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(Priority_Array_Next_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur,
and the value at the specified priority shall be
relinquished immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority
is 0.0% or NULL, or
(c) The value of the next highest non-NULL
priority, including Relinquish_Default,
is greater than 0.0%, or
(d) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN_RELINQUISH;
} else {
Present_Value_Relinquish(pObject, priority);
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
* @param value [in] BACnet lighting value
* @param fade_time [in] BACnet lighting fade time
*/
static void
Lighting_Command_Fade_To(struct object_data *pObject,
unsigned priority, float value, uint32_t fade_time)
{
unsigned current_priority;
if (!pObject) {
return;
}
Present_Value_Set(pObject, value, priority);
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.fade_time = fade_time;
pObject->Lighting_Command.operation = BACNET_LIGHTS_FADE_TO;
pObject->Lighting_Command.target_level = value;
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
* @param value [in] BACnet lighting value
* @param ramp_rate [in] BACnet lighting ramp rate
*/
static void
Lighting_Command_Ramp_To(struct object_data *pObject,
unsigned priority, float value, float ramp_rate)
{
unsigned current_priority;
if (!pObject) {
return;
}
Present_Value_Set(pObject, value, priority);
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.ramp_rate = ramp_rate;
pObject->Lighting_Command.operation = BACNET_LIGHTS_RAMP_TO;
pObject->Lighting_Command.target_level = value;
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
* @param operation [in] BACnet lighting operation
* @param step_increment [in] BACnet lighting step increment value
*/
static void Lighting_Command_Step(
struct object_data *pObject,
unsigned priority,
BACNET_LIGHTING_OPERATION operation,
float step_increment)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.operation = operation;
pObject->Lighting_Command.fade_time = 0;
pObject->Lighting_Command.ramp_rate = 0.0f;
pObject->Lighting_Command.step_increment = step_increment;
}
}
/**
* For a given object instance-number, writes the present-value
*
@@ -475,73 +643,17 @@ static bool Lighting_Output_Present_Value_Write(
if (!islessgreater(value, -1.0)) {
/* Provides the same functionality as the
WARN lighting command. */
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(
Priority_Array_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur
if any of the following conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN;
}
Lighting_Command_Warn(pObject, priority);
status = true;
} else if (!islessgreater(value, -2.0)) {
/* Provides the same functionality as the
WARN_RELINQUISH lighting command. */
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(
Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(
Priority_Array_Next_Value(pObject, priority - 1),
0.0))) {
/* The blink-warn notification shall not occur,
and the value at the specified priority shall be
relinquished immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority
is 0.0% or NULL, or
(c) The value of the next highest non-NULL
priority, including Relinquish_Default,
is greater than 0.0%, or
(d) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation =
BACNET_LIGHTS_WARN_RELINQUISH;
} else {
Present_Value_Relinquish(pObject, priority);
}
Lighting_Command_Warn_Relinquish(pObject, priority);
status = true;
} else if (!islessgreater(value, -3.0)) {
/* Provides the same functionality as the
WARN_OFF lighting command. */
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(
Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(
Priority_Array_Next_Value(pObject, priority - 1),
0.0))) {
/* The blink-warn notification shall not occur and
the value 0.0% written at the specified
priority immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The Present_Value is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation =
BACNET_LIGHTS_WARN_OFF;
} else {
Present_Value_Set(pObject, 0.0, priority);
}
Lighting_Command_Warn_Off(pObject, priority);
status = true;
} else if (
isgreaterequal(value, 0.0) && islessequal(value, 100.0)) {
@@ -799,9 +911,131 @@ bool Lighting_Output_Lighting_Command_Set(
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
/* FIXME: check lighting command member values */
status = lighting_command_copy(&pObject->Lighting_Command, value);
/* FIXME: set all the other values, and get the light levels moving */
}
return status;
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Stop(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.operation = BACNET_LIGHTS_STOP;
}
}
/**
* For a given object instance-number, writes the present-value
*
* @param object_instance - object-instance number of the object
* @param value - property value to write
* @param priority - priority-array index value 1..16
* @param error_class - the BACnet error class
* @param error_code - BACnet Error code
*
* @return true if values are within range and present-value is set.
*/
static bool Lighting_Output_Lighting_Command_Write(
uint32_t object_instance,
BACNET_LIGHTING_COMMAND *value,
uint8_t priority,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
bool status = false;
struct object_data *pObject;
if (!value) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
if (priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
object. */
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
return status;
}
if ((priority < BACNET_MIN_PRIORITY) ||
(priority > BACNET_MAX_PRIORITY)) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
if (value->operation >= MAX_BACNET_LIGHTING_OPERATION) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
switch (value->operation) {
case BACNET_LIGHTS_NONE:
status = true;
break;
case BACNET_LIGHTS_FADE_TO:
Lighting_Command_Fade_To(pObject, priority,
value->target_level, value->fade_time);
status = true;
break;
case BACNET_LIGHTS_RAMP_TO:
Lighting_Command_Ramp_To(pObject, priority,
value->target_level, value->ramp_rate);
status = true;
break;
case BACNET_LIGHTS_STEP_UP:
case BACNET_LIGHTS_STEP_DOWN:
case BACNET_LIGHTS_STEP_ON:
case BACNET_LIGHTS_STEP_OFF:
Lighting_Command_Step(pObject,priority,
value->operation,value->step_increment);
status = true;
break;
case BACNET_LIGHTS_WARN:
/* Provides the same functionality as the
WARN lighting command. */
Lighting_Command_Warn(pObject, priority);
status = true;
break;
case BACNET_LIGHTS_WARN_OFF:
/* Provides the same functionality as the
WARN_OFF lighting command. */
Lighting_Command_Warn_Off(pObject, priority);
status = true;
break;
case BACNET_LIGHTS_WARN_RELINQUISH:
/* Provides the same functionality as the
WARN_RELINQUISH lighting command. */
Lighting_Command_Warn_Relinquish(pObject, priority);
status = true;
break;
case BACNET_LIGHTS_STOP:
Lighting_Command_Stop(pObject, priority);
status = true;
break;
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
break;
}
} else {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
}
return status;
@@ -1866,9 +2100,11 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_APPLICATION_DATA_VALUE value;
/* decode the some of the request */
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
len = bacapp_decode_known_property(
wp_data->application_data, wp_data->application_data_len, &value,
wp_data->object_type, wp_data->object_property);
/* note: len < application_data_len means there is more data,
such as an array or list */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1905,8 +2141,10 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
if (status) {
status = Lighting_Output_Lighting_Command_Set(
wp_data->object_instance, &value.type.Lighting_Command);
status = Lighting_Output_Lighting_Command_Write(
wp_data->object_instance, &value.type.Lighting_Command,
wp_data->priority,
&wp_data->error_class, &wp_data->error_code);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -1997,8 +2235,7 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/**
* Handles the timing for a single Lighting Output object Fade
*
* @param pLight - Lighting Output object
* @param pCommand - BACNET_LIGHTING_COMMAND of the Lighting Output object
* @param object_instance - Lighting Output object
* @param milliseconds - number of milliseconds elapsed since previously
* called. Works best when called about every 10 milliseconds.
*/
+8 -4
View File
@@ -101,13 +101,17 @@ unsigned Multistate_Input_Instance_To_Index(uint32_t object_instance)
/**
* @brief Determines the object instance-number for a given 0..N index
* of Multistate Input objects where N is Multistate_Input_Count().
* @param index - 0..Multistate_Input_Count() value
* @return object instance-number for the given index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Multistate_Input_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+8 -4
View File
@@ -103,13 +103,17 @@ unsigned Multistate_Value_Instance_To_Index(uint32_t object_instance)
/**
* @brief Determines the object instance-number for a given 0..N index
* of Multistate Input objects where N is Multistate_Value_Count().
* @param index - 0..Multistate_Value_Count() value
* @return object instance-number for the given index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Multistate_Value_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+77 -57
View File
@@ -2898,7 +2898,75 @@ static bool Network_Port_FD_BBMD_Address_Write(
#endif
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
return status;
}
/**
* @brief Write the FD Subscription Lifetime
* @param object_instance [in] BACnet network port object instance number
* @param value [in] BACnet IP address and port
* @param error_class [out] BACnet error class
* @param error_code [out] BACnet error code
* @return true if the value was written
*/
static bool Network_Port_FD_Subscription_Lifetime_Write(
uint32_t object_instance,
BACNET_UNSIGNED_INTEGER value,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
bool status = false;
uint16_t lifetime = 0;
if (!error_class || !error_code) {
return status;
}
if (value > UINT16_MAX) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
lifetime = (uint16_t)value;
switch (Network_Port_Type(object_instance)) {
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
case PORT_TYPE_BIP:
if (Network_Port_BIP_Mode(object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status = Network_Port_Remote_BBMD_BIP_Lifetime_Set(
object_instance, lifetime);
if (!status) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
case PORT_TYPE_BIP6:
if (Network_Port_BIP6_Mode(object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status = Network_Port_Remote_BBMD_BIP6_Lifetime_Set(
object_instance, lifetime);
if (!status) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
@@ -3379,13 +3447,13 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
return false;
}
/* decode the some of the request */
#if !defined(BACAPP_COMPLEX_TYPES)
#if defined(BACAPP_COMPLEX_TYPES)
len = bacapp_decode_known_property(
wp_data->application_data, wp_data->application_data_len, &value,
wp_data->object_type, wp_data->object_property);
#else
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
#else
len = bacapp_decode_generic_property(
wp_data->application_data, wp_data->application_data_len, &value,
wp_data->object_property);
#endif
if (len < 0) {
/* error while decoding - a value larger than we can handle */
@@ -3462,61 +3530,13 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_FD_SUBSCRIPTION_LIFETIME:
if (write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
if (value.type.Unsigned_Int <= 65535) {
switch (Network_Port_Type(wp_data->object_instance)) {
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
case PORT_TYPE_BIP:
if (Network_Port_BIP_Mode(
wp_data->object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status =
Network_Port_Remote_BBMD_BIP_Lifetime_Set(
wp_data->object_instance,
value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
case PORT_TYPE_BIP6:
if (Network_Port_BIP6_Mode(
wp_data->object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status =
Network_Port_Remote_BBMD_BIP6_Lifetime_Set(
wp_data->object_instance,
value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
default:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_INVALID_ARRAY_INDEX;
break;
}
status = Network_Port_FD_Subscription_Lifetime_Write(
wp_data->object_instance, value.type.Unsigned_Int,
&wp_data->error_class, &wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
}
break;
#endif
default:
+5 -1
View File
@@ -31,7 +31,11 @@ int objects_device_count(void)
uint32_t objects_device_id(int index)
{
return Keylist_Key(Device_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Device_List, index, &instance);
return instance;
}
OBJECT_DEVICE_T *objects_device_data(int index)
+1 -2
View File
@@ -112,8 +112,7 @@ int rpm_ack_decode_service_request(
apdu_len -= len;
apdu += len;
if (apdu_len && decode_is_opening_tag_number(apdu, 4)) {
data_len = bacapp_data_len(apdu, (unsigned)apdu_len,
rpm_property->propertyIdentifier);
data_len = bacnet_enclosed_data_length(apdu, apdu_len);
/* propertyValue */
decoded_len++;
apdu_len--;
+6
View File
@@ -10,8 +10,14 @@
#ifndef BACNET_SYS_PLATFORM_H
#define BACNET_SYS_PLATFORM_H
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#ifndef INT_MAX
#define INT_MAX (~0U >> 1U)
#endif
#ifndef islessgreater
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
#endif
+7 -1
View File
@@ -160,6 +160,8 @@
defined(BACAPP_DESTINATION) || \
defined(BACAPP_BDT_ENTRY) || \
defined(BACAPP_FDT_ENTRY) || \
defined(BACAPP_ACTION_COMMAND) || \
defined(BACAPP_SCALE) || \
defined(BACAPP_TYPES_EXTRA))
#define BACAPP_ALL
#endif
@@ -202,6 +204,8 @@
#define BACAPP_DESTINATION
#define BACAPP_BDT_ENTRY
#define BACAPP_FDT_ENTRY
#define BACAPP_ACTION_COMMAND
#define BACAPP_SCALE
#endif
#if defined(BACAPP_DOUBLE) || \
@@ -219,7 +223,9 @@
defined(BACAPP_OBJECT_PROPERTY_REFERENCE) || \
defined(BACAPP_DESTINATION) || \
defined(BACAPP_BDT_ENTRY) || \
defined(BACAPP_FDT_ENTRY)
defined(BACAPP_FDT_ENTRY) || \
defined(BACAPP_ACTION_COMMAND) || \
defined(BACAPP_SCALE)
#define BACAPP_COMPLEX_TYPES
#endif
+1 -3
View File
@@ -208,7 +208,6 @@ int cov_notify_decode_service_request(
BACNET_UNSIGNED_INTEGER decoded_value = 0;
BACNET_OBJECT_TYPE decoded_type = OBJECT_NONE;
uint32_t decoded_instance = 0;
BACNET_PROPERTY_ID property_identifier = PROP_ALL;
BACNET_PROPERTY_VALUE *value = NULL;
/* subscriber-process-identifier [0] Unsigned32 */
@@ -292,8 +291,7 @@ int cov_notify_decode_service_request(
/* this len function needs to start at the opening tag
to match opening/closing tags like a stack.
However, it returns the len between the tags. */
value_len = bacapp_data_len(&apdu[len], apdu_size - len,
(BACNET_PROPERTY_ID)property_identifier);
value_len = bacnet_enclosed_data_length(&apdu[len], apdu_size - len);
len += value_len;
/* add the opening tag length to the totals */
len += tag_len;
+2 -2
View File
@@ -7,7 +7,7 @@
*/
#include <stdbool.h>
#include <string.h>
#include "bacnet/bacstr.h"
#include "bacnet/bacdef.h"
#include "bacnet/indtext.h"
/**
@@ -56,7 +56,7 @@ bool indtext_by_istring(
if (data_list && search_name) {
while (data_list->pString) {
if (bacnet_stricmp(data_list->pString, search_name) == 0) {
if (strcasecmp(data_list->pString, search_name) == 0) {
index = data_list->index;
found = true;
break;
+130 -105
View File
@@ -120,73 +120,88 @@ int rp_encode_apdu(
/** Decode the service request only
*
* @param apdu Pointer to the buffer for encoding.
* @param apdu_len Count of valid bytes in the buffer.
* @param apdu_size Count of valid bytes in the buffer.
* @param rpdata Pointer to the property data to be encoded.
*
* @return Bytes decoded or zero on error.
* @return number of bytes decoded, or #BACNET_STATUS_REJECT
*/
int rp_decode_service_request(
uint8_t *apdu, unsigned apdu_len, BACNET_READ_PROPERTY_DATA *rpdata)
uint8_t *apdu, unsigned apdu_size, BACNET_READ_PROPERTY_DATA *data)
{
unsigned len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
int len = 0;
int apdu_len = 0;
uint32_t instance = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE; /* for decoding */
uint32_t property = 0; /* for decoding */
BACNET_UNSIGNED_INTEGER unsigned_value = 0; /* for decoding */
/* check for value pointers */
if (rpdata) {
/* Must have at least 2 tags, an object id and a property identifier
* of at least 1 byte in length to have any chance of parsing */
if (apdu_len < 7) {
rpdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
if (!apdu) {
if (data) {
data->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
}
return BACNET_STATUS_REJECT;
}
/* Tag 0: Object ID */
if (!decode_is_context_tag(&apdu[len++], 0)) {
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
/* object-identifier [0] BACnetObjectIdentifier */
len = bacnet_object_id_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 0, &type, &instance);
if (len > 0) {
if (instance > BACNET_MAX_INSTANCE) {
if (data) {
data->error_code = ERROR_CODE_REJECT_PARAMETER_OUT_OF_RANGE;
}
return BACNET_STATUS_REJECT;
}
len += decode_object_id(&apdu[len], &type, &rpdata->object_instance);
rpdata->object_type = type;
/* Tag 1: Property ID */
len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type);
if (tag_number != 1) {
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
return BACNET_STATUS_REJECT;
}
len += decode_enumerated(&apdu[len], len_value_type, &property);
rpdata->object_property = (BACNET_PROPERTY_ID)property;
/* Tag 2: Optional Array Index */
if (len < apdu_len) {
len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type);
if ((tag_number == 2) && (len < apdu_len)) {
len += decode_unsigned(
&apdu[len], len_value_type, &unsigned_value);
rpdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value;
} else {
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
return BACNET_STATUS_REJECT;
apdu_len += len;
if (data) {
data->object_type = type;
data->object_instance = instance;
}
} else {
rpdata->array_index = BACNET_ARRAY_ALL;
if (data) {
data->error_code = ERROR_CODE_REJECT_INVALID_TAG;
}
return BACNET_STATUS_REJECT;
}
/* property-identifier [1] BACnetPropertyIdentifier */
len = bacnet_enumerated_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 1, &property);
if (len > 0) {
apdu_len += len;
if (data) {
data->object_property = (BACNET_PROPERTY_ID)property;
}
} else {
if (data) {
data->error_code = ERROR_CODE_REJECT_INVALID_TAG;
}
return BACNET_STATUS_REJECT;
}
/* property-array-index [2] Unsigned OPTIONAL */
len = bacnet_unsigned_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 2, &unsigned_value);
if (len > 0) {
apdu_len += len;
if (data) {
data->array_index = unsigned_value;
}
} else {
/* wrong tag - skip apdu_len increment and go to next field */
if (data) {
data->array_index = BACNET_ARRAY_ALL;
}
}
if (len < apdu_len) {
if (apdu_len < apdu_size) {
/* If something left over now, we have an invalid request */
if (rpdata) {
rpdata->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS;
if (data) {
data->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS;
}
return BACNET_STATUS_REJECT;
}
return (int)len;
return apdu_len;
}
/**
* @brief Encode APDU for ReadProperty-ACK
*
@@ -345,7 +360,7 @@ int rp_ack_encode_apdu_object_property_end(uint8_t *apdu)
/** Encode the acknowledge.
*
* @param apdu Pointer to the buffer for encoding.
* @param apdu Pointer to the buffer for encoding, or NULL for length
* @param invoke_id Invoke Id
* @param rpdata Pointer to the property data to be encoded.
*
@@ -389,85 +404,95 @@ int rp_ack_encode_apdu(
* the application_data field points into the apdu buffer (is not allocated).
*
* @param apdu [in] The apdu portion of the ACK reply.
* @param apdu_len [in] The total length of the apdu.
* @param apdu_size [in] The total length of the apdu.
* @param rpdata [out] The structure holding the partially decoded result.
* @return Number of decoded bytes (could be less than apdu_len),
* or -1 on decoding error.
*/
int rp_ack_decode_service_request(uint8_t *apdu,
int apdu_len, /* total length of the apdu */
BACNET_READ_PROPERTY_DATA *rpdata)
int apdu_size,
BACNET_READ_PROPERTY_DATA *data)
{
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
int tag_len = 0; /* length of tag decode */
int len = 0; /* total length of decodes */
BACNET_OBJECT_TYPE object_type = OBJECT_NONE; /* object type */
int apdu_len = 0; /* return value */
int len = 0;
uint32_t instance = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE; /* for decoding */
uint32_t property = 0; /* for decoding */
BACNET_UNSIGNED_INTEGER unsigned_value = 0; /* for decoding */
int data_len = 0;
/* Check basics. */
if (apdu && (apdu_len >= 8 /*minimum*/)) {
/* Tag 0: Object ID */
if (!decode_is_context_tag(&apdu[0], 0)) {
return -1;
if (!apdu) {
return -BACNET_STATUS_ERROR;
}
len = 1;
len += decode_object_id(
&apdu[len], &object_type, &rpdata->object_instance);
rpdata->object_type = object_type;
/* Tag 1: Property ID */
if (len >= apdu_len) {
return -1;
/* object-identifier [0] BACnetObjectIdentifier */
len = bacnet_object_id_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 0, &type, &instance);
if (len > 0) {
if (instance > BACNET_MAX_INSTANCE) {
return BACNET_STATUS_ERROR;
}
len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type);
if (tag_number != 1) {
return -1;
apdu_len += len;
if (data) {
data->object_type = type;
data->object_instance = instance;
}
if (len >= apdu_len) {
return -1;
}
len += decode_enumerated(&apdu[len], len_value_type, &property);
rpdata->object_property = (BACNET_PROPERTY_ID)property;
/* Tag 2: Optional Array Index */
if (len >= apdu_len) {
return -1;
}
tag_len = decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type);
if (tag_number == 2) {
len += tag_len;
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
rpdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value;
} else {
rpdata->array_index = BACNET_ARRAY_ALL;
return BACNET_STATUS_ERROR;
}
/* Tag 3: opening context tag */
if (len >= apdu_len) {
return -1;
/* property-identifier [1] BACnetPropertyIdentifier */
len = bacnet_enumerated_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 1, &property);
if (len > 0) {
apdu_len += len;
if (data) {
data->object_property = (BACNET_PROPERTY_ID)property;
}
if (decode_is_opening_tag_number(&apdu[len], 3)) {
/* a tag number of 3 is not extended so only one octet */
len++;
} else {
return BACNET_STATUS_ERROR;
}
/* property-array-index [2] Unsigned OPTIONAL */
len = bacnet_unsigned_context_decode(
&apdu[apdu_len], apdu_size - apdu_len, 2, &unsigned_value);
if (len > 0) {
apdu_len += len;
if (data) {
data->array_index = unsigned_value;
}
} else {
/* wrong tag - skip apdu_len increment and go to next field */
if (data) {
data->array_index = BACNET_ARRAY_ALL;
}
}
/* property-value [3] ABSTRACT-SYNTAX.&Type */
if (!bacnet_is_opening_tag_number(
&apdu[apdu_len], apdu_size - apdu_len, 3, &len)) {
return BACNET_STATUS_ERROR;
}
/* determine the length of the data blob */
data_len = bacnet_enclosed_data_length(&apdu[apdu_len],
apdu_size - apdu_len);
if (data_len == BACNET_STATUS_ERROR) {
return BACNET_STATUS_ERROR;
}
/* count the opening tag number length */
apdu_len += len;
if (data_len > MAX_APDU) {
/* not enough size in application_data to store the data chunk */
return BACNET_STATUS_ERROR;
} else if (data) {
/* don't decode the application tag number or its data here */
rpdata->application_data = &apdu[len];
/* Just to ensure we do not create a wrapped over value here. */
if (len < apdu_len) {
rpdata->application_data_len =
apdu_len - len - 1 /*closing tag */;
} else {
rpdata->application_data_len = 0;
data->application_data = &apdu[apdu_len];
data->application_data_len = data_len;
}
/* len includes the data and the closing tag */
len = apdu_len;
} else {
return -1;
}
} else {
return -1;
apdu_len += data_len;
if (!bacnet_is_closing_tag_number(
&apdu[apdu_len], apdu_size - apdu_len, 3, &len)) {
return BACNET_STATUS_ERROR;
}
/* count the closing tag number length */
apdu_len += len;
return len;
return apdu_len;
}
#endif
+1 -1
View File
@@ -692,7 +692,7 @@ void rpm_ack_object_property_process(
apdu += len;
if (bacnet_is_opening_tag_number(apdu, apdu_len, 4, &len)) {
application_data_len =
bacapp_data_len(apdu, apdu_len, rp_data->object_property);
bacnet_enclosed_data_length(apdu, apdu_len);
/* propertyValue */
apdu_len -= len;
apdu += len;
+1 -2
View File
@@ -245,8 +245,7 @@ int wp_decode_service_request(
return BACNET_STATUS_ERROR;
}
/* determine the length of the data blob */
imax = bacapp_data_len(
&apdu[apdu_len], apdu_size - apdu_len, (BACNET_PROPERTY_ID)property);
imax = bacnet_enclosed_data_length(&apdu[apdu_len], apdu_size - apdu_len);
if (imax == BACNET_STATUS_ERROR) {
return BACNET_STATUS_ERROR;
}
+1 -3
View File
@@ -133,10 +133,8 @@ int wpm_decode_object_property(
/* tag 2 - Property Value */
if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) {
len--;
imax = bacapp_data_len(&apdu[len], (unsigned)(apdu_len - len),
wp_data->object_property);
imax = bacnet_enclosed_data_length(&apdu[len], apdu_len - len);
len++;
if (imax != BACNET_STATUS_ERROR) {
/* copy application data, check max length */
if (imax > (apdu_len - len)) {
-2
View File
@@ -29,8 +29,6 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wno-unused-variable)
add_compile_options(-Wno-unused-function)
add_compile_options(-Wno-unused-parameter)
# FIXME: zephyr ztest has a strnlen hack in platform.h which triggers this warning
add_compile_options(-Wno-redundant-decls)
add_link_options(-fprofile-arcs -ftest-coverage)
endif()
+1
View File
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/bacaddr.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacdcode.c
${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c
+1
View File
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/bacapp.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacdest.c
${SRC_DIR}/bacnet/bacdcode.c
+115 -68
View File
@@ -16,44 +16,15 @@
#include <bacnet/bactext.h>
static const BACNET_APPLICATION_TAG tag_list[] = {
BACNET_APPLICATION_TAG_NULL,
#if defined(BACAPP_BOOLEAN)
BACNET_APPLICATION_TAG_BOOLEAN,
#endif
#if defined(BACAPP_UNSIGNED)
BACNET_APPLICATION_TAG_UNSIGNED_INT,
#endif
#if defined(BACAPP_SIGNED)
BACNET_APPLICATION_TAG_SIGNED_INT,
#endif
#if defined(BACAPP_REAL)
BACNET_APPLICATION_TAG_REAL,
#endif
#if defined(BACAPP_DOUBLE)
BACNET_APPLICATION_TAG_DOUBLE,
#endif
#if defined(BACAPP_OCTET_STRING)
/* primitive tags */
BACNET_APPLICATION_TAG_NULL, BACNET_APPLICATION_TAG_BOOLEAN,
BACNET_APPLICATION_TAG_UNSIGNED_INT, BACNET_APPLICATION_TAG_SIGNED_INT,
BACNET_APPLICATION_TAG_REAL, BACNET_APPLICATION_TAG_DOUBLE,
BACNET_APPLICATION_TAG_OCTET_STRING,
#endif
#if defined(BACAPP_CHARACTER_STRING)
BACNET_APPLICATION_TAG_CHARACTER_STRING,
#endif
#if defined(BACAPP_BIT_STRING)
BACNET_APPLICATION_TAG_BIT_STRING,
#endif
#if defined(BACAPP_ENUMERATED)
BACNET_APPLICATION_TAG_ENUMERATED,
#endif
#if defined(BACAPP_DATE)
BACNET_APPLICATION_TAG_DATE,
#endif
#if defined(BACAPP_TIME)
BACNET_APPLICATION_TAG_TIME,
#endif
#if defined(BACAPP_OBJECT_ID)
BACNET_APPLICATION_TAG_OBJECT_ID,
#endif
#if defined(BACAPP_TYPES_EXTRA)
BACNET_APPLICATION_TAG_CHARACTER_STRING, BACNET_APPLICATION_TAG_BIT_STRING,
BACNET_APPLICATION_TAG_ENUMERATED, BACNET_APPLICATION_TAG_DATE,
BACNET_APPLICATION_TAG_TIME, BACNET_APPLICATION_TAG_OBJECT_ID,
/* non-primitive tags */
BACNET_APPLICATION_TAG_EMPTYLIST,
/* BACnetWeeknday */
/* BACNET_APPLICATION_TAG_WEEKNDAY, --> not implemented! */
@@ -96,8 +67,11 @@ static const BACNET_APPLICATION_TAG tag_list[] = {
/* BACnetBDTEntry */
BACNET_APPLICATION_TAG_BDT_ENTRY,
/* BACnetFDTEntry */
BACNET_APPLICATION_TAG_FDT_ENTRY
#endif
BACNET_APPLICATION_TAG_FDT_ENTRY,
/* BACnetActionCommand */
BACNET_APPLICATION_TAG_ACTION_COMMAND,
/* BACnetScale */
BACNET_APPLICATION_TAG_SCALE
};
/**
@@ -138,7 +112,7 @@ static void test_bacapp_decode_data_len(void)
zassert_equal(
bacapp_decode_data_len(apdu, UINT8_MAX, sizeof(apdu)), 0, NULL);
expected_value = (int)(~0U >> 1); /* INT_MAX is not universally defined */
expected_value = INT_MAX;
zassert_equal(
bacapp_decode_data_len(
apdu, BACNET_APPLICATION_TAG_UNSIGNED_INT, UINT32_MAX),
@@ -250,7 +224,7 @@ static void test_bacapp_copy(void)
zassert_equal(dest_value.tag, src_value.tag, NULL);
zassert_equal(dest_value.next, src_value.next, NULL);
for (i = 0; i < sizeof(tag_list) / sizeof(tag_list[0]); ++i) {
for (i = 0; i < ARRAY_SIZE(tag_list); ++i) {
BACNET_APPLICATION_TAG tag = tag_list[i];
bool result;
bool expected_result = true;
@@ -739,8 +713,7 @@ static void testBACnetApplicationDataLength(void)
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(
&apdu[0], apdu_len, PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES);
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
/* 2. application tagged data, one element */
@@ -754,7 +727,7 @@ static void testBACnetApplicationDataLength(void)
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_OBJECT_IDENTIFIER);
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
/* 3. application tagged data, multiple elements */
@@ -813,7 +786,7 @@ static void testBACnetApplicationDataLength(void)
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_PRIORITY_ARRAY);
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
/* 4. complex datatype - one element */
@@ -844,7 +817,7 @@ static void testBACnetApplicationDataLength(void)
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_START_TIME);
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
/* 5. complex datatype - multiple elements */
@@ -860,7 +833,7 @@ static void testBACnetApplicationDataLength(void)
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_REQUESTED_SHED_LEVEL);
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
/* 7. context opening & closing tag */
@@ -877,7 +850,7 @@ static void testBACnetApplicationDataLength(void)
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacapp_data_len(&apdu[0], apdu_len, PROP_WEEKLY_SCHEDULE);
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
}
@@ -891,16 +864,20 @@ verifyBACnetApplicationDataValue(BACNET_APPLICATION_DATA_VALUE *value)
int apdu_len = 0;
int null_len = 0;
int test_len = 0;
int len = 0;
bool status = false;
BACNET_APPLICATION_DATA_VALUE test_value = { 0 };
/* 1. test that encode length matches NULL */
apdu_len = bacapp_encode_application_data(&apdu[0], value);
zassert_true(apdu_len > 0, NULL);
null_len = bacapp_encode_application_data(NULL, value);
zassert_equal(apdu_len, null_len, NULL);
/* 2. test that value decoded from buffer matches incoming value */
test_len = bacapp_decode_application_data(&apdu[0], apdu_len, &test_value);
zassert_true(test_len != BACNET_STATUS_ERROR, NULL);
status = bacapp_same_value(value, &test_value);
/* 3. test that decoded buffer matches encoded buffer */
while (apdu_len) {
apdu_len--;
test_len =
@@ -916,6 +893,20 @@ verifyBACnetApplicationDataValue(BACNET_APPLICATION_DATA_VALUE *value)
apdu_len, test_len, null_len);
}
}
/* 4. test bacnet_enclosed_data_length() matches APDU buffer length */
apdu_len = 0;
test_len = 0;
len = encode_opening_tag(&apdu[0], 3);
apdu_len += len;
len = bacapp_encode_application_data(&apdu[apdu_len], value);
test_len += len;
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
zassert_equal(null_len, len, NULL);
return status;
}
@@ -931,25 +922,43 @@ static void verifyBACnetComplexDataValue(
uint8_t apdu[480] = { 0 };
int apdu_len = 0;
int null_len = 0;
int test_len = 0;
int len = 0;
BACNET_APPLICATION_DATA_VALUE test_value = { 0 };
bool status = false;
/* 1. test that encode length matches NULL */
apdu_len = bacapp_encode_application_data(&apdu[0], value);
zassert_true(apdu_len > 0, NULL);
null_len = bacapp_encode_application_data(NULL, value);
zassert_equal(apdu_len, null_len, "encoded length=%d", apdu_len);
apdu_len =
bacapp_decode_known_property(&apdu[0], apdu_len, &test_value,
object_type, prop);
zassert_true(apdu_len != BACNET_STATUS_ERROR, "decoded length=%d", apdu_len);
/* 2. test that value decoded from buffer matches incoming value */
apdu_len = bacapp_decode_known_property(
&apdu[0], apdu_len, &test_value, object_type, prop);
zassert_true(
apdu_len != BACNET_STATUS_ERROR, "decoded length=%d", apdu_len);
zassert_true(apdu_len > 0, "decoded length=%d", apdu_len);
status = bacapp_same_value(value, &test_value);
if (!status) {
null_len = 0;
}
zassert_true(status, "bacapp: same-value of tag=%s[%u]\n",
zassert_true(
status, "bacapp: same-value of tag=%s[%u]\n",
bactext_application_tag_name(value->tag), value->tag);
/* 3. test bacnet_enclosed_data_length() matches APDU buffer length */
apdu_len = 0;
test_len = 0;
len = encode_opening_tag(&apdu[0], 3);
apdu_len += len;
len = bacapp_encode_application_data(&apdu[apdu_len], value);
test_len += len;
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacnet_enclosed_data_length(&apdu[0], apdu_len);
zassert_equal(test_len, len, NULL);
zassert_equal(null_len, len, NULL);
}
/**
@@ -1205,17 +1214,17 @@ static void testBACnetApplicationData(void)
status = bacapp_parse_application_data(
BACNET_APPLICATION_TAG_HOST_N_PORT, "192.168.1.1:47808", &value);
zassert_true(status, NULL);
verifyBACnetComplexDataValue(&value, OBJECT_NETWORK_PORT,
PROP_FD_BBMD_ADDRESS);
verifyBACnetComplexDataValue(&value, OBJECT_NETWORK_PORT,
PROP_BACNET_IP_GLOBAL_ADDRESS);
verifyBACnetComplexDataValue(
&value, OBJECT_NETWORK_PORT, PROP_FD_BBMD_ADDRESS);
verifyBACnetComplexDataValue(
&value, OBJECT_NETWORK_PORT, PROP_BACNET_IP_GLOBAL_ADDRESS);
status = bacapp_parse_application_data(
BACNET_APPLICATION_TAG_BDT_ENTRY, "192.168.1.1:47808,255.255.255.255",
&value);
zassert_true(status, NULL);
verifyBACnetComplexDataValue(&value, OBJECT_NETWORK_PORT,
PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE);
verifyBACnetComplexDataValue(
&value, OBJECT_NETWORK_PORT, PROP_BBMD_BROADCAST_DISTRIBUTION_TABLE);
return;
}
@@ -1224,30 +1233,68 @@ static void testBACnetApplicationData(void)
* @brief Test
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(bacapp_tests, test_bacapp_context_data)
ZTEST(bacapp_tests, test_bacapp_data)
#else
static void test_bacapp_context_data(void)
static void test_bacapp_data(void)
#endif
{
const uint8_t context_tag_number = 1;
uint8_t apdu[480] = { 0 };
BACNET_APPLICATION_DATA_VALUE value = { 0 };
int apdu_len, null_len;
int apdu_len, null_len, test_len, len;
unsigned i = 0;
for (i = 0; i < sizeof(tag_list) / sizeof(tag_list[0]); i++) {
for (i = 0; i < ARRAY_SIZE(tag_list); i++) {
/* 1. test encoding matches for NULL and APDU buffer */
BACNET_APPLICATION_TAG tag = tag_list[i];
value.tag = tag;
null_len =
bacapp_encode_context_data_value(NULL, context_tag_number, &value);
bacapp_encode_application_data(NULL, &value);
apdu_len =
bacapp_encode_context_data_value(apdu, context_tag_number, &value);
bacapp_encode_application_data(apdu, &value);
if (apdu_len != null_len) {
printf(
"bacapp: NULL len=%d != APDU len=%d for tag=%s", null_len,
apdu_len, bactext_application_tag_name(tag));
}
zassert_equal(apdu_len, null_len, NULL);
/* 2. test bacnet_enclosed_data_length() matches APDU buffer or NULL */
apdu_len = 0;
test_len = 0;
len = encode_opening_tag(apdu, 3);
apdu_len += len;
len = bacapp_encode_application_data(
&apdu[apdu_len], &value);
test_len += len;
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacnet_enclosed_data_length(apdu, apdu_len);
zassert_equal(test_len, len, NULL);
zassert_equal(null_len, len, NULL);
/* 3. application tagged */
null_len = bacapp_encode_application_data(NULL, &value);
apdu_len = bacapp_encode_application_data(apdu, &value);
if (apdu_len != null_len) {
printf(
"bacapp: NULL len=%d != APDU len=%d for tag=%s", null_len,
apdu_len, bactext_application_tag_name(tag));
}
zassert_equal(apdu_len, null_len, NULL);
/* 4. test bacnet_enclosed_data_length() matches APDU buffer or NULL */
apdu_len = 0;
test_len = 0;
len = encode_opening_tag(apdu, 3);
apdu_len += len;
len = bacapp_encode_application_data(&apdu[apdu_len], &value);
test_len += len;
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* verify the length of the data inside the opening/closing tags */
len = bacnet_enclosed_data_length(apdu, apdu_len);
zassert_equal(test_len, len, NULL);
zassert_equal(null_len, len, NULL);
}
}
@@ -1301,7 +1348,7 @@ void test_main(void)
ztest_unit_test(testBACnetApplicationData),
ztest_unit_test(testBACnetApplicationDataLength),
ztest_unit_test(testBACnetApplicationData_Safe),
ztest_unit_test(test_bacapp_context_data),
ztest_unit_test(test_bacapp_data),
ztest_unit_test(test_bacapp_sprintf_data));
ztest_run_test_suite(bacapp_tests);
+1
View File
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/bacdest.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -39,6 +39,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/bacdevobjpropref.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
+1
View File
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/bactimevalue.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/binding/address.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/acc.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/assigned_access_rights.c
${SRC_DIR}/bacnet/authentication_factor.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/access_door.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/access_point.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/basic/object/access_rights.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/access_rule.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/access_user.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/authentication_factor.c
${SRC_DIR}/bacnet/assigned_access_rights.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/ai.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacdcode.c
${SRC_DIR}/bacnet/bacdest.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/ao.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/av.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -37,6 +37,7 @@ add_executable(${PROJECT_NAME}
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/arf.c
${SRC_DIR}/bacnet/awf.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -37,6 +37,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/bi.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/bitstring_value.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/blo.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/bo.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -37,6 +37,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/bv.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/calendar.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/channel.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/color_object.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/color_temperature.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/command.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
+25 -1
View File
@@ -27,12 +27,36 @@ static void test_object_command(void)
bool status = false;
unsigned count = 0;
uint32_t object_instance = 0;
const int skip_fail_property_list[] = { PROP_ACTION, -1 };
const int skip_fail_property_list[] = { -1 };
BACNET_ACTION_LIST *pAction;
Command_Init();
count = Command_Count();
zassert_true(count > 0, NULL);
object_instance = Command_Index_To_Instance(0);
status = Command_Valid_Instance(object_instance);
zassert_true(status, NULL);
count = Command_Action_List_Count(object_instance);
zassert_true(count > 0, NULL);
/* configure the instance property values */
pAction = Command_Action_List_Entry(object_instance, 0);
zassert_not_null(pAction, NULL);
pAction->Device_Id.type = OBJECT_DEVICE;
pAction->Device_Id.instance = 4194303;
pAction->Object_Id.type = OBJECT_ANALOG_INPUT;
pAction->Object_Id.instance = 4194303;
pAction->Property_Identifier = PROP_PRESENT_VALUE;
pAction->Property_Array_Index = BACNET_ARRAY_ALL;
pAction->Priority = 16;
pAction->Value.tag = BACNET_APPLICATION_TAG_REAL;
pAction->Value.type.Real = 3.14159;
pAction->Post_Delay = 0;
pAction->Quit_On_Failure = false;
pAction->Write_Successful = false;
pAction->next = NULL;
Command_In_Process_Set(object_instance, false);
Command_All_Writes_Successful_Set(object_instance, false);
/* perform a general test for RP/WP */
bacnet_object_properties_read_write_test(
OBJECT_COMMAND, object_instance, Command_Property_Lists,
Command_Read_Property, Command_Write_Property, skip_fail_property_list);
@@ -37,6 +37,7 @@ add_executable(${PROJECT_NAME}
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/authentication_factor.c
${SRC_DIR}/bacnet/authentication_factor_format.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/csv.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/basic/object/device.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/abort.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/iv.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/lc.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/lo.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -33,6 +33,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/lsp.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/lsz.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/ms-input.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/mso.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/msv.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/nc.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/netport.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/osv.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/piv.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/schedule.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -36,6 +36,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/structured_view.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/time_value.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
@@ -35,6 +35,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/basic/object/trendlog.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
+1
View File
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/cov.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
+1
View File
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/create_object.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
+1
View File
@@ -34,6 +34,7 @@ add_executable(${PROJECT_NAME}
# File(s) under test
${SRC_DIR}/bacnet/delete_object.c
# Support files and stubs (pathname alphabetical)
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bacaddr.c
${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdcode.c
+1
View File
@@ -49,6 +49,7 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/timestamp.c
# Dependencies of bacapp.c
${SRC_DIR}/bacnet/bacaction.c
${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/weeklyschedule.c

Some files were not shown because too many files have changed in this diff Show More