RPM should return UNKNOWN_OBJECT for non-existent objects (#337)
* Return UNKNOWN_OBJECT for invalid object IDs * Don't terminate RPM for UNKNOWN_OBJECT * Review changes
This commit is contained in:
@@ -130,7 +130,16 @@ static int RPM_Encode_Property(
|
|||||||
rpdata.array_index = rpmdata->array_index;
|
rpdata.array_index = rpmdata->array_index;
|
||||||
rpdata.application_data = &Temp_Buf[0];
|
rpdata.application_data = &Temp_Buf[0];
|
||||||
rpdata.application_data_len = sizeof(Temp_Buf);
|
rpdata.application_data_len = sizeof(Temp_Buf);
|
||||||
len = Device_Read_Property(&rpdata);
|
|
||||||
|
if ((rpmdata->object_property == PROP_ALL) ||
|
||||||
|
(rpmdata->object_property == PROP_REQUIRED) ||
|
||||||
|
(rpmdata->object_property == PROP_OPTIONAL)) {
|
||||||
|
/* special properties only get ERROR encoding */
|
||||||
|
len = BACNET_STATUS_ERROR;
|
||||||
|
} else {
|
||||||
|
len = Device_Read_Property(&rpdata);
|
||||||
|
}
|
||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
if ((len == BACNET_STATUS_ABORT) || (len == BACNET_STATUS_REJECT)) {
|
if ((len == BACNET_STATUS_ABORT) || (len == BACNET_STATUS_REJECT)) {
|
||||||
rpmdata->error_code = rpdata.error_code;
|
rpmdata->error_code = rpdata.error_code;
|
||||||
@@ -301,7 +310,26 @@ void handler_read_property_multiple(uint8_t *service_request,
|
|||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
BACNET_PROPERTY_ID special_object_property;
|
BACNET_PROPERTY_ID special_object_property;
|
||||||
|
|
||||||
if (rpmdata.array_index != BACNET_ARRAY_ALL) {
|
if (!Device_Valid_Object_Id(rpmdata.object_type,
|
||||||
|
rpmdata.object_instance)) {
|
||||||
|
len = RPM_Encode_Property(
|
||||||
|
&Handler_Transmit_Buffer[npdu_len],
|
||||||
|
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
|
||||||
|
if (len > 0) {
|
||||||
|
apdu_len += len;
|
||||||
|
} else {
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr,
|
||||||
|
"RPM: Too full for property!\r\n");
|
||||||
|
#endif
|
||||||
|
error = len;
|
||||||
|
/* The berror flag ensures that
|
||||||
|
both loops will be broken! */
|
||||||
|
berror = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (rpmdata.array_index != BACNET_ARRAY_ALL) {
|
||||||
|
|
||||||
/* No array index options for this special property.
|
/* No array index options for this special property.
|
||||||
Encode error for this object property response */
|
Encode error for this object property response */
|
||||||
len = rpm_ack_encode_apdu_object_property(
|
len = rpm_ack_encode_apdu_object_property(
|
||||||
@@ -361,7 +389,27 @@ void handler_read_property_multiple(uint8_t *service_request,
|
|||||||
response on OPTIONAL when empty. */
|
response on OPTIONAL when empty. */
|
||||||
/* If no optional properties are supported then
|
/* If no optional properties are supported then
|
||||||
an empty 'List of Results' shall be returned
|
an empty 'List of Results' shall be returned
|
||||||
for the specified property.*/
|
for the specified property, except if the
|
||||||
|
object does not exist. */
|
||||||
|
if (!Device_Valid_Object_Id(rpmdata.object_type,
|
||||||
|
rpmdata.object_instance)) {
|
||||||
|
len = RPM_Encode_Property(
|
||||||
|
&Handler_Transmit_Buffer[npdu_len],
|
||||||
|
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
|
||||||
|
if (len > 0) {
|
||||||
|
apdu_len += len;
|
||||||
|
} else {
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr,
|
||||||
|
"RPM: Too full for property!\r\n");
|
||||||
|
#endif
|
||||||
|
error = len;
|
||||||
|
/* The berror flag ensures that
|
||||||
|
both loops will be broken! */
|
||||||
|
berror = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (index = 0; index < property_count;
|
for (index = 0; index < property_count;
|
||||||
index++) {
|
index++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user