diff --git a/bacnet-stack/demo/handler/h_rp.c b/bacnet-stack/demo/handler/h_rp.c index 2118d468..390fa3f1 100644 --- a/bacnet-stack/demo/handler/h_rp.c +++ b/bacnet-stack/demo/handler/h_rp.c @@ -314,9 +314,20 @@ void handler_read_property(uint8_t * service_request, } } if (error) { - len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code); + switch (len) { + /* BACnet APDU too small to fit data, so proper response is Abort */ + case -2: + len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, + ABORT_REASON_SEGMENTATION_NOT_SUPPORTED); + break; + case -1: + default: + len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, + SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code); + break; + } #if PRINT_ENABLED fprintf(stderr, "Sending Read Property Error!\n"); #endif diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index bcf16991..401989f1 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -548,7 +548,8 @@ char *Device_Valid_Object_Id(int object_type, uint32_t object_instance) return name; } -/* return the length of the apdu encoded or -1 for error */ +/* return the length of the apdu encoded or -1 for error or + -2 for abort message */ int Device_Encode_Property_APDU(uint8_t * apdu, BACNET_PROPERTY_ID property, int32_t array_index, @@ -704,9 +705,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu, /* assume next one is the same size as this one */ /* can we all fit into the APDU? */ if ((apdu_len + len) >= MAX_APDU) { - *error_class = ERROR_CLASS_SERVICES; - *error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT; - apdu_len = -1; + /* reject message */ + apdu_len = -2; break; } } else { diff --git a/bacnet-stack/ports/pic18/device.c b/bacnet-stack/ports/pic18/device.c index 4ac6d6bf..376f7dca 100644 --- a/bacnet-stack/ports/pic18/device.c +++ b/bacnet-stack/ports/pic18/device.c @@ -157,7 +157,8 @@ bool Device_Object_List_Identifier(unsigned array_index, return status; } -/* return the length of the apdu encoded or -1 for error */ +/* return the length of the apdu encoded or -1 for error or + -2 for abort */ int Device_Encode_Property_APDU(uint8_t * apdu, BACNET_PROPERTY_ID property, int32_t array_index, @@ -265,9 +266,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu, /* assume next one is the same size as this one */ /* can we all fit into the APDU? */ if ((apdu_len + len) >= MAX_APDU) { - *error_class = ERROR_CLASS_SERVICES; - *error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT; - apdu_len = -1; + apdu_len = -2; break; } } else {