Fixed compile warnings and BACnet priority array decoding (#712)
* Fixed network port warning for unused static function. * Fixed BACnetPriorityArray decoding in bacapp module * Fixed epics print of BACnetDateTime complex data.
This commit is contained in:
+70
-22
@@ -1035,9 +1035,8 @@ int bacapp_decode_generic_property(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BACAPP_COMPLEX_TYPES)
|
||||
/**
|
||||
* @brief Decode BACnetPriorityValue complex data
|
||||
* @brief Decode BACnetPriorityValue complex data - one element only
|
||||
*
|
||||
* BACnetPriorityValue ::= CHOICE {
|
||||
* null NULL,
|
||||
@@ -1067,36 +1066,63 @@ static int decode_priority_array_value(
|
||||
uint8_t *apdu,
|
||||
unsigned apdu_size,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID property)
|
||||
BACNET_OBJECT_TYPE object_type)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
#if defined(BACAPP_COMPLEX_TYPES)
|
||||
BACNET_APPLICATION_TAG tag = MAX_BACNET_APPLICATION_TAG;
|
||||
|
||||
if (bacnet_is_opening_tag_number(apdu, apdu_size, 0, &len)) {
|
||||
/* Contextual Abstract-syntax & type */
|
||||
/* constructed-value [0] ABSTRACT-SYNTAX.&Type */
|
||||
apdu_len += len;
|
||||
len = bacapp_decode_known_property(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, value, object_type,
|
||||
property);
|
||||
/* adjust application tag for complex types */
|
||||
if (object_type == OBJECT_COLOR) {
|
||||
/* Properties using BACnetxyColor */
|
||||
tag = BACNET_APPLICATION_TAG_XY_COLOR;
|
||||
} else if (
|
||||
(object_type == OBJECT_DATETIME_PATTERN_VALUE) ||
|
||||
(object_type == OBJECT_DATETIME_VALUE)) {
|
||||
/* Properties using BACnetDateTime */
|
||||
tag = BACNET_APPLICATION_TAG_DATETIME;
|
||||
}
|
||||
if (tag != MAX_BACNET_APPLICATION_TAG) {
|
||||
len = bacapp_decode_application_tag_value(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag, value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
}
|
||||
if (!bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 0, &len)) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
} else {
|
||||
apdu_len = bacapp_decode_known_property(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, value, object_type,
|
||||
property);
|
||||
} else if (bacnet_is_opening_tag_number(apdu, apdu_size, 1, &len)) {
|
||||
/* datetime [1] BACnetDateTime */
|
||||
apdu_len += len;
|
||||
/* adjust application tag for complex types */
|
||||
tag = BACNET_APPLICATION_TAG_DATETIME;
|
||||
len = bacapp_decode_application_tag_value(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag, value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (!bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 1, &len)) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
apdu_len = bacapp_decode_application_data(apdu, apdu_size, value);
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Determine a pseudo application tag for a known property
|
||||
@@ -1601,7 +1627,7 @@ int bacapp_decode_known_property(
|
||||
tagged values, but sometimes encoded as abstract syntax or complex
|
||||
data values */
|
||||
apdu_len = decode_priority_array_value(
|
||||
apdu, apdu_size, value, object_type, PROP_PRESENT_VALUE);
|
||||
apdu, apdu_size, value, object_type);
|
||||
} else {
|
||||
/* Complex or primitive value?
|
||||
Lookup the complex values using their object type and property */
|
||||
@@ -2235,6 +2261,34 @@ static int bacapp_snprintf_object_id(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (BACAPP_DATETIME)
|
||||
/**
|
||||
* @brief Print a value to a string for EPICS
|
||||
* @param str - destination string, or NULL for length only
|
||||
* @param str_len - length of the destination string, or 0 for length only
|
||||
* @param value - value to print
|
||||
* @return number of characters written
|
||||
*/
|
||||
static int
|
||||
bacapp_snprintf_datetime(char *str, size_t str_len, BACNET_DATE_TIME *value)
|
||||
{
|
||||
int ret_val = 0;
|
||||
int slen = 0;
|
||||
|
||||
slen = bacapp_snprintf(str, str_len, "{");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf_date(str, str_len, &value->date);
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf(str, str_len, "-");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf_time(str, str_len, &value->time);
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
ret_val += bacapp_snprintf(str, str_len, "}");
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BACAPP_DATERANGE) || defined(BACAPP_CALENDAR_ENTRY)
|
||||
/**
|
||||
* @brief Print a value to a string for EPICS
|
||||
@@ -3082,14 +3136,8 @@ int bacapp_snprintf_value(
|
||||
#endif
|
||||
#if defined(BACAPP_DATETIME)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
slen = bacapp_snprintf_date(
|
||||
str, str_len, &value->type.Date_Time.date);
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf(str, str_len, "-");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf_time(
|
||||
str, str_len, &value->type.Date_Time.time);
|
||||
ret_val += slen;
|
||||
ret_val = bacapp_snprintf_datetime(
|
||||
str, str_len, &value->type.Date_Time);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATERANGE)
|
||||
|
||||
@@ -1176,8 +1176,6 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
unsigned int object_index = 0;
|
||||
int len = 0;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
/* build here in case of error in time half of datetime */
|
||||
BACNET_DATE start_date;
|
||||
|
||||
debug_printf("Load_Control_Write_Property(wp_data=%p)\n", wp_data);
|
||||
if (wp_data == NULL) {
|
||||
|
||||
@@ -2904,7 +2904,9 @@ static bool Network_Port_FD_BBMD_Address_Write(
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BBMD_CLIENT_ENABLED)
|
||||
/**
|
||||
* @brief Write the FD Subscription Lifetime
|
||||
* @param object_instance [in] BACnet network port object instance number
|
||||
@@ -3525,9 +3527,11 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
#else
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case PROP_FD_SUBSCRIPTION_LIFETIME:
|
||||
#if (BBMD_CLIENT_ENABLED)
|
||||
if (write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
status = Network_Port_FD_Subscription_Lifetime_Write(
|
||||
@@ -3537,8 +3541,11 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
break;
|
||||
#else
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
if (Property_List_Member(
|
||||
wp_data->object_instance, wp_data->object_property)) {
|
||||
|
||||
Reference in New Issue
Block a user