From 7832ba11dbd1ad898601ee92b6f9bc58a319c35d Mon Sep 17 00:00:00 2001 From: skarg Date: Sat, 11 Sep 2010 13:38:16 +0000 Subject: [PATCH] Changed Object List in various ports to return Segementation Not Supported abort when it is too large to return in a single APDU. --- bacnet-stack/ports/at91sam7s/device.c | 6 +++--- bacnet-stack/ports/atmega168/device.c | 11 ++++++----- bacnet-stack/ports/atmega168/h_rp.c | 2 +- bacnet-stack/ports/atmega8/device.c | 10 +++++----- bacnet-stack/ports/atmega8/h_rp.c | 2 +- bacnet-stack/ports/bdk-atxx4-mstp/device.c | 6 +++--- bacnet-stack/ports/pic18f6720/device.c | 12 ++++++------ bacnet-stack/ports/pic18f6720/h_rp.c | 2 +- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/bacnet-stack/ports/at91sam7s/device.c b/bacnet-stack/ports/at91sam7s/device.c index 73885b88..df8ffbab 100644 --- a/bacnet-stack/ports/at91sam7s/device.c +++ b/bacnet-stack/ports/at91sam7s/device.c @@ -698,10 +698,10 @@ int Device_Read_Property_Local( /* assume next one is the same size as this one */ /* can we all fit into the APDU? */ if ((apdu_len + len) >= MAX_APDU) { - rpdata->error_class = ERROR_CLASS_SERVICES; + /* Abort response */ rpdata->error_code = - ERROR_CODE_NO_SPACE_FOR_OBJECT; - apdu_len = BACNET_STATUS_ERROR; + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; + apdu_len = BACNET_STATUS_ABORT; break; } } else { diff --git a/bacnet-stack/ports/atmega168/device.c b/bacnet-stack/ports/atmega168/device.c index 0b7af579..04b58adf 100644 --- a/bacnet-stack/ports/atmega168/device.c +++ b/bacnet-stack/ports/atmega168/device.c @@ -276,9 +276,10 @@ int Device_Encode_Property_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; + /* Abort response */ + *error_code = + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; + apdu_len = BACNET_STATUS_ABORT; break; } } @@ -291,7 +292,7 @@ int Device_Encode_Property_APDU( else { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_INVALID_ARRAY_INDEX; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; } } break; @@ -344,7 +345,7 @@ int Device_Encode_Property_APDU( (array_index != BACNET_ARRAY_ALL)) { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; } return apdu_len; diff --git a/bacnet-stack/ports/atmega168/h_rp.c b/bacnet-stack/ports/atmega168/h_rp.c index a1457c0f..494891fb 100644 --- a/bacnet-stack/ports/atmega168/h_rp.c +++ b/bacnet-stack/ports/atmega168/h_rp.c @@ -141,7 +141,7 @@ void handler_read_property( } else { switch (property_len) { /* BACnet APDU too small to fit data, so proper response is Abort */ - case -2: + case BACNET_STATUS_ABORT: len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, diff --git a/bacnet-stack/ports/atmega8/device.c b/bacnet-stack/ports/atmega8/device.c index c41ed3e6..b7287534 100644 --- a/bacnet-stack/ports/atmega8/device.c +++ b/bacnet-stack/ports/atmega8/device.c @@ -286,9 +286,9 @@ int Device_Encode_Property_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; + *error_code = + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; + apdu_len = BACNET_STATUS_ABORT; break; } } @@ -301,7 +301,7 @@ int Device_Encode_Property_APDU( else { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_INVALID_ARRAY_INDEX; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; } } break; @@ -335,7 +335,7 @@ int Device_Encode_Property_APDU( (array_index != BACNET_ARRAY_ALL)) { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; } return apdu_len; diff --git a/bacnet-stack/ports/atmega8/h_rp.c b/bacnet-stack/ports/atmega8/h_rp.c index 1222b3fc..52c0d325 100644 --- a/bacnet-stack/ports/atmega8/h_rp.c +++ b/bacnet-stack/ports/atmega8/h_rp.c @@ -149,7 +149,7 @@ void handler_read_property( } else { switch (property_len) { /* BACnet APDU too small to fit data, so proper response is Abort */ - case -2: + case BACNET_STATUS_ABORT: len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/device.c b/bacnet-stack/ports/bdk-atxx4-mstp/device.c index 81321f7e..855c7fa7 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/device.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/device.c @@ -706,10 +706,10 @@ int Device_Read_Property_Local( /* assume next one is the same size as this one */ /* can we all fit into the APDU? */ if ((apdu_len + len) >= MAX_APDU) { - rpdata->error_class = ERROR_CLASS_SERVICES; + /* Abort response */ rpdata->error_code = - ERROR_CODE_NO_SPACE_FOR_OBJECT; - apdu_len = BACNET_STATUS_ERROR; + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; + apdu_len = BACNET_STATUS_ABORT; break; } } else { diff --git a/bacnet-stack/ports/pic18f6720/device.c b/bacnet-stack/ports/pic18f6720/device.c index 8f995980..68f24f80 100644 --- a/bacnet-stack/ports/pic18f6720/device.c +++ b/bacnet-stack/ports/pic18f6720/device.c @@ -378,16 +378,16 @@ int Device_Encode_Property_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; + *error_code = + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; + apdu_len = BACNET_STATUS_ABORT; break; } } else { /* error: internal error? */ *error_class = ERROR_CLASS_SERVICES; *error_code = ERROR_CODE_OTHER; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; break; } } @@ -400,7 +400,7 @@ int Device_Encode_Property_APDU( else { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_INVALID_ARRAY_INDEX; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; } } break; @@ -475,7 +475,7 @@ int Device_Encode_Property_APDU( (array_index != BACNET_ARRAY_ALL)) { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; - apdu_len = -1; + apdu_len = BACNET_STATUS_ERROR; } return apdu_len; diff --git a/bacnet-stack/ports/pic18f6720/h_rp.c b/bacnet-stack/ports/pic18f6720/h_rp.c index 1d5a4cda..0acdabfb 100644 --- a/bacnet-stack/ports/pic18f6720/h_rp.c +++ b/bacnet-stack/ports/pic18f6720/h_rp.c @@ -183,7 +183,7 @@ void handler_read_property( break; } if (error) { - if (len == -2) { + if (len == BACNET_STATUS_ABORT) { /* BACnet APDU too small to fit data, so proper response is Abort */ len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],