Bugfix/property array element zero size (#908)
* Changed BACnetARRAY index validation into ReadProperty, ReadPropertyMultiple, WriteProperty, and WritePropertyMultiple handlers. * Changed the basic and example objects after refactoring BACnetARRAY index validation into ReadProperty, ReadPropertyMultiple, WriteProperty, and WritePropertyMultiple handlers. * Added BACnet application decoder that understands that an array element of zero is an unsigned integer tagged value. Fixes RP and RPM apps when reading the array element zero of arrays.
This commit is contained in:
@@ -50,6 +50,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -54,6 +54,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -51,6 +51,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -51,6 +51,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
@@ -59,6 +60,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/channel_value.c
|
||||
${SRC_DIR}/bacnet/secure_connect.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -51,6 +51,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -55,6 +55,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -57,6 +57,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
|
||||
@@ -93,16 +93,6 @@ static void test_BitString_Value_Object(void)
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(wpdata.error_class, ERROR_CLASS_PROPERTY, NULL);
|
||||
zassert_equal(wpdata.error_code, ERROR_CODE_WRITE_ACCESS_DENIED, NULL);
|
||||
/* WP to property using priority array */
|
||||
wpdata.object_property = PROP_PRESENT_VALUE;
|
||||
value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
wpdata.array_index = 0;
|
||||
wpdata.application_data_len =
|
||||
bacapp_encode_application_data(wpdata.application_data, &value);
|
||||
status = BitString_Value_Write_Property(&wpdata);
|
||||
zassert_false(status, NULL);
|
||||
zassert_equal(wpdata.error_class, ERROR_CLASS_PROPERTY, NULL);
|
||||
zassert_equal(wpdata.error_code, ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY, NULL);
|
||||
/* no application data */
|
||||
wpdata.application_data_len = 0;
|
||||
status = BitString_Value_Write_Property(&wpdata);
|
||||
|
||||
@@ -56,6 +56,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -56,6 +56,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
|
||||
@@ -56,6 +56,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
|
||||
@@ -57,6 +57,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -52,6 +52,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -57,6 +57,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/list_element.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -568,17 +568,15 @@ static void test_network_port_sc_status_encode_decode(void)
|
||||
object_value.object_property = rpdata.object_property =
|
||||
PROP_SC_FAILED_CONNECTION_REQUESTS;
|
||||
|
||||
// count (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 0;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len == -1, NULL);
|
||||
|
||||
// context (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 1;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len == -1, NULL);
|
||||
|
||||
// all context
|
||||
if (property_list_bacnet_array_member(
|
||||
rpdata.object_type, rpdata.object_property)) {
|
||||
object_value.array_index = rpdata.array_index = 0;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
object_value.array_index = rpdata.array_index = 1;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
}
|
||||
object_value.array_index = rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len > 0, NULL);
|
||||
@@ -618,15 +616,17 @@ static void test_network_port_sc_status_encode_decode(void)
|
||||
object_value.object_property = rpdata.object_property =
|
||||
PROP_SC_HUB_FUNCTION_CONNECTION_STATUS;
|
||||
|
||||
// count (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 0;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len == -1, NULL);
|
||||
if (property_list_bacnet_array_member(
|
||||
rpdata.object_type, rpdata.object_property)) {
|
||||
object_value.array_index = rpdata.array_index = 0;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
|
||||
// context (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 1;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len == -1, NULL);
|
||||
// context (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 1;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
}
|
||||
|
||||
len = bacapp_snprintf_value(NULL, 0, &object_value);
|
||||
zassert_true((len > 0) && (len < sizeof(str) - 1), NULL);
|
||||
@@ -707,17 +707,15 @@ static void test_network_port_sc_status_encode_decode(void)
|
||||
object_value.object_property = rpdata.object_property =
|
||||
PROP_SC_DIRECT_CONNECT_CONNECTION_STATUS;
|
||||
|
||||
// count (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 0;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len == -1, NULL);
|
||||
|
||||
// context (error: property is not BacArray)
|
||||
object_value.array_index = rpdata.array_index = 1;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len == -1, NULL);
|
||||
|
||||
// all context
|
||||
if (property_list_bacnet_array_member(
|
||||
rpdata.object_type, rpdata.object_property)) {
|
||||
object_value.array_index = rpdata.array_index = 0;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
object_value.array_index = rpdata.array_index = 1;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
}
|
||||
object_value.array_index = rpdata.array_index = BACNET_ARRAY_ALL;
|
||||
len = Network_Port_Read_Property(&rpdata);
|
||||
zassert_true(len > 0, NULL);
|
||||
|
||||
@@ -51,6 +51,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -51,6 +51,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
|
||||
@@ -48,16 +48,16 @@ bool bacnet_object_property_write_test(
|
||||
wp_data->object_type, wp_data->object_property);
|
||||
is_list = property_list_bacnet_list_member(
|
||||
wp_data->object_type, wp_data->object_property);
|
||||
if (!is_array && !is_list) {
|
||||
if (is_array) {
|
||||
wp_data->array_index = 0;
|
||||
status = write_property(wp_data);
|
||||
zassert_equal(status, false, NULL);
|
||||
zassert_equal(wp_data->error_class, ERROR_CLASS_PROPERTY, NULL);
|
||||
zassert_equal(
|
||||
wp_data->error_code, ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY,
|
||||
"property=%s error_code=%s",
|
||||
bactext_property_name(wp_data->object_property),
|
||||
bactext_error_code_name(wp_data->error_code));
|
||||
if (!status) {
|
||||
zassert_not_equal(
|
||||
wp_data->error_code, ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY,
|
||||
"property=%s array_index=0: error code=%s.\n",
|
||||
bactext_property_name(wp_data->object_property),
|
||||
bactext_error_code_name(wp_data->error_code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,21 +174,13 @@ int bacnet_object_property_read_test(
|
||||
rpdata->object_type, rpdata->object_property);
|
||||
is_list = property_list_bacnet_list_member(
|
||||
rpdata->object_type, rpdata->object_property);
|
||||
if (!is_array && !is_list) {
|
||||
if (is_array) {
|
||||
/* test an array index that must be implemented */
|
||||
rpdata->array_index = 0;
|
||||
read_len = read_property(rpdata);
|
||||
zassert_equal(
|
||||
read_len, BACNET_STATUS_ERROR, "property '%s': is not an array!\n",
|
||||
bactext_property_name(rpdata->object_property));
|
||||
zassert_equal(read_len, BACNET_STATUS_ERROR, NULL);
|
||||
zassert_equal(
|
||||
rpdata->error_class, ERROR_CLASS_PROPERTY,
|
||||
"property '%s': error class is %s\n",
|
||||
bactext_property_name(rpdata->object_property),
|
||||
bactext_error_class_name(rpdata->error_class));
|
||||
zassert_equal(
|
||||
rpdata->error_code, ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY,
|
||||
"property '%s': error code is %s\n",
|
||||
zassert_not_equal(
|
||||
read_len, BACNET_STATUS_ERROR,
|
||||
"property '%s' array_index=0: error code is %s.\n",
|
||||
bactext_property_name(rpdata->object_property),
|
||||
bactext_error_code_name(rpdata->error_code));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user