diff --git a/bacnet-stack/demo/handler/h_rp.c b/bacnet-stack/demo/handler/h_rp.c index 96dedf41..a8027332 100644 --- a/bacnet-stack/demo/handler/h_rp.c +++ b/bacnet-stack/demo/handler/h_rp.c @@ -109,7 +109,7 @@ void handler_read_property( data.array_index, &error_class, &error_code); - if (len > 0) + if (len >= 0) { // encode the APDU portion of the packet data.application_data = &Temp_Buf[0]; @@ -138,7 +138,7 @@ void handler_read_property( data.array_index, &error_class, &error_code); - if (len > 0) + if (len >= 0) { // encode the APDU portion of the packet data.application_data = &Temp_Buf[0]; @@ -167,7 +167,7 @@ void handler_read_property( data.array_index, &error_class, &error_code); - if (len > 0) + if (len >= 0) { // encode the APDU portion of the packet data.application_data = &Temp_Buf[0]; @@ -197,7 +197,7 @@ void handler_read_property( data.array_index, &error_class, &error_code); - if (len > 0) + if (len >= 0) { // encode the APDU portion of the packet data.application_data = &Temp_Buf[0]; diff --git a/bacnet-stack/demo/object/ai.c b/bacnet-stack/demo/object/ai.c index c351c69e..38c6f1a7 100644 --- a/bacnet-stack/demo/object/ai.c +++ b/bacnet-stack/demo/object/ai.c @@ -61,6 +61,7 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index) return index; } +/* return apdu length, or -1 on error */ int Analog_Input_Encode_Property_APDU( uint8_t *apdu, uint32_t object_instance, @@ -115,6 +116,7 @@ int Analog_Input_Encode_Property_APDU( default: *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; break; } @@ -147,7 +149,7 @@ void testAnalogInput(Test * pTest) BACNET_ARRAY_ALL, &error_class, &error_code); - ct_test(pTest, len != 0); + ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); len = decode_object_id(&apdu[len], diff --git a/bacnet-stack/demo/object/ao.c b/bacnet-stack/demo/object/ao.c index edd056ff..85126f28 100644 --- a/bacnet-stack/demo/object/ao.c +++ b/bacnet-stack/demo/object/ao.c @@ -141,6 +141,7 @@ static float Analog_Output_Present_Value(uint32_t object_instance) return value; } +/* return apdu len, or -1 on error */ int Analog_Output_Encode_Property_APDU( uint8_t *apdu, uint32_t object_instance, @@ -223,7 +224,7 @@ int Analog_Output_Encode_Property_APDU( { *error_class = ERROR_CLASS_SERVICES; *error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT; - apdu_len = 0; + apdu_len = -1; break; } } @@ -245,6 +246,7 @@ int Analog_Output_Encode_Property_APDU( { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_INVALID_ARRAY_INDEX; + apdu_len = -1; } } @@ -256,6 +258,7 @@ int Analog_Output_Encode_Property_APDU( default: *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; break; } diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index bad1a68b..71442acf 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -144,6 +144,7 @@ static unsigned bacfile_file_size(uint32_t object_instance) return file_size; } +/* return the number of bytes used, or -1 on error */ int bacfile_encode_property_apdu( uint8_t *apdu, uint32_t object_instance, @@ -215,6 +216,7 @@ int bacfile_encode_property_apdu( default: *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; break; } diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index a34a3ffd..fc2d1bf2 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -379,7 +379,7 @@ bool Device_Object_List_Identifier(unsigned array_index, return status; } -// return the length of the apdu encoded +// return the length of the apdu encoded or -1 for error int Device_Encode_Property_APDU( uint8_t *apdu, BACNET_PROPERTY_ID property, @@ -514,7 +514,7 @@ int Device_Encode_Property_APDU( { *error_class = ERROR_CLASS_SERVICES; *error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT; - apdu_len = 0; + apdu_len = -1; break; } } @@ -523,7 +523,7 @@ int Device_Encode_Property_APDU( // error: internal error? *error_class = ERROR_CLASS_SERVICES; *error_code = ERROR_CODE_OTHER; - apdu_len = 0; + apdu_len = -1; break; } } @@ -536,6 +536,7 @@ int Device_Encode_Property_APDU( { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_INVALID_ARRAY_INDEX; + apdu_len = -1; } } break; @@ -554,13 +555,12 @@ int Device_Encode_Property_APDU( apdu_len = encode_tagged_unsigned(&apdu[0], Number_Of_APDU_Retries); break; case PROP_DEVICE_ADDRESS_BINDING: - apdu_len += encode_opening_tag(&apdu[0], 3); - /* put the list here, if it exists */ - apdu_len += encode_closing_tag(&apdu[apdu_len], 3); + /* encode the list here, if it exists */ break; default: *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; break; }