Refactor/write property object name (#504)
* refactor WriteProperty of object-name property rules into device object. * remove dependence on device object inside some dynamic objects * improve device object unit test coverage --------- Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
+12
-8
@@ -31,6 +31,7 @@
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "bacnet/bacenum.h"
|
||||
#include "bacnet/bacdcode.h"
|
||||
@@ -268,6 +269,7 @@ int wp_decode_service_request(
|
||||
* requested data and space for the reply, or error response.
|
||||
* @param value - #BACNET_APPLICATION_DATA_VALUE data, for the tag
|
||||
* @param expected_tag - the tag that is expected for this property value
|
||||
* @return true if the expected tag matches the value tag
|
||||
*/
|
||||
bool write_property_type_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
@@ -292,11 +294,12 @@ bool write_property_type_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
* @param wp_data - #BACNET_WRITE_PROPERTY_DATA data, including
|
||||
* requested data and space for the reply, or error response.
|
||||
* @param value - #BACNET_APPLICATION_DATA_VALUE data, for the tag
|
||||
* @param expected_tag - the tag that is expected for this property value
|
||||
* @param len_max - max length accepted for a character string, or 0=unchecked
|
||||
* @return true if the character string value is valid
|
||||
*/
|
||||
bool write_property_string_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
int len_max)
|
||||
size_t len_max)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
@@ -315,8 +318,8 @@ bool write_property_string_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else if (characterstring_length(&value->type.Character_String) >
|
||||
(uint16_t)len_max) {
|
||||
} else if ((len_max > 0) && (characterstring_length(
|
||||
&value->type.Character_String) > len_max)) {
|
||||
if (wp_data) {
|
||||
wp_data->error_class = ERROR_CLASS_RESOURCES;
|
||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||
@@ -347,19 +350,20 @@ bool write_property_string_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
* @param wp_data - #BACNET_WRITE_PROPERTY_DATA data, including
|
||||
* requested data and space for the reply, or error response.
|
||||
* @param value - #BACNET_APPLICATION_DATA_VALUE data, for the tag
|
||||
* @param expected_tag - the tag that is expected for this property value
|
||||
* @param len_max - max length accepted for a character string, or 0=unchecked
|
||||
* @return true if the character string value is valid
|
||||
*/
|
||||
bool write_property_empty_string_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
int len_max)
|
||||
size_t len_max)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
if (value && (value->tag == BACNET_APPLICATION_TAG_CHARACTER_STRING)) {
|
||||
if (characterstring_encoding(&value->type.Character_String) ==
|
||||
CHARACTER_ANSI_X34) {
|
||||
if (characterstring_length(&value->type.Character_String) >
|
||||
(uint16_t)len_max) {
|
||||
if ((len_max > 0) && (characterstring_length(
|
||||
&value->type.Character_String) > len_max)) {
|
||||
if (wp_data) {
|
||||
wp_data->error_class = ERROR_CLASS_RESOURCES;
|
||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||
|
||||
Reference in New Issue
Block a user