From 45c631b133bc970f2dec0cb3618b07dfec7aec55 Mon Sep 17 00:00:00 2001 From: petermcs Date: Thu, 21 Jan 2010 21:51:20 +0000 Subject: [PATCH] Fixed up error return so that we report not having a particular instance of an object differently to not supporting that object type at all. --- bacnet-stack/demo/handler/h_rp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bacnet-stack/demo/handler/h_rp.c b/bacnet-stack/demo/handler/h_rp.c index 0c667e96..8b821764 100644 --- a/bacnet-stack/demo/handler/h_rp.c +++ b/bacnet-stack/demo/handler/h_rp.c @@ -78,11 +78,20 @@ int Encode_Property_APDU( object_rp = Read_Property[object_type]; object_valid = Valid_Instance[object_type]; } - if (object_rp && object_valid && object_valid(object_instance)) { - apdu_len = - object_rp(&apdu[0], object_instance, property, array_index, - error_class, error_code); + if (object_rp && object_valid) { + /* There are handlers for this type of object */ + if(object_valid(object_instance)) { + apdu_len = + object_rp(&apdu[0], object_instance, property, array_index, + error_class, error_code); + } else { + /* The specified object instance is not valid */ + *error_class = ERROR_CLASS_OBJECT; + *error_code = ERROR_CODE_UNKNOWN_OBJECT; + } + } else { + /* We don't support this object type */ *error_class = ERROR_CLASS_OBJECT; *error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE; }