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:
@@ -11,6 +11,7 @@
|
||||
#include "bacnet/bacdef.h"
|
||||
/* BACnet Stack API */
|
||||
#include "bacnet/bacdcode.h"
|
||||
#include "bacnet/proplist.h"
|
||||
#include "bacnet/rp.h"
|
||||
|
||||
#if BACNET_SVC_RP_A
|
||||
@@ -360,6 +361,28 @@ int rp_ack_encode_apdu_object_property_end(uint8_t *apdu)
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Validate the array indices for the given property
|
||||
* @param data - ReadProperty data, including requested data and
|
||||
* data for the reply, or error response.
|
||||
* @return true if the property is an array and the array indices are used.
|
||||
*/
|
||||
bool read_property_bacnet_array_valid(BACNET_READ_PROPERTY_DATA *data)
|
||||
{
|
||||
bool is_array;
|
||||
|
||||
/* only array properties can have array options */
|
||||
is_array = property_list_bacnet_array_member(
|
||||
data->object_type, data->object_property);
|
||||
if ((!is_array) && (data->array_index != BACNET_ARRAY_ALL)) {
|
||||
data->error_class = ERROR_CLASS_PROPERTY;
|
||||
data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Encode the acknowledge.
|
||||
*
|
||||
* @param apdu Pointer to the buffer for encoding, or NULL for length
|
||||
|
||||
Reference in New Issue
Block a user