2nd pass at changing the error/reject/abort status reporting to improve BTL test compliance. ReadProperty fully done for core and demo objects. Will tackle other services next.
This commit is contained in:
@@ -37,6 +37,24 @@
|
||||
#include "bacdef.h"
|
||||
|
||||
/** @file abort.c Abort Encoding/Decoding */
|
||||
/* Helper function to avoid needing additional entries in service data structures
|
||||
* when passing back abort status.
|
||||
* Convert from error code to abort code - assumes value is in range
|
||||
* ERROR_CODE_RESERVED1 to ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED
|
||||
* anything outside this range gets converted to ABORT_REASON_OTHER.
|
||||
* Will need reworking if it is required to return proprietary abort codes.
|
||||
*/
|
||||
|
||||
BACNET_ABORT_REASON abort_convert_error_code(
|
||||
BACNET_ERROR_CODE error_code)
|
||||
{
|
||||
BACNET_ABORT_REASON abort_code = ABORT_REASON_OTHER;
|
||||
|
||||
if((error_code > ERROR_CODE_RESERVED1) && (error_code <= ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED))
|
||||
abort_code = (BACNET_ABORT_REASON)(error_code - ERROR_CODE_RESERVED1);
|
||||
|
||||
return(abort_code);
|
||||
}
|
||||
|
||||
/* encode service */
|
||||
int abort_encode_apdu(
|
||||
|
||||
@@ -38,6 +38,25 @@
|
||||
|
||||
/** @file reject.c Encode/Decode Reject APDUs */
|
||||
|
||||
/* Helper function to avoid needing additional entries in service data structures
|
||||
* when passing back reject status.
|
||||
* Convert from error code to reject code - assumes value is in range
|
||||
* ERROR_CODE_REJECT_BUFFER_OVERFLOW to ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE
|
||||
* anything outside this range gets converted to REJECT_REASON_OTHER.
|
||||
* Will need reworking if it is required to return proprietary reject codes.
|
||||
*/
|
||||
|
||||
BACNET_REJECT_REASON reject_convert_error_code(
|
||||
BACNET_ERROR_CODE error_code)
|
||||
{
|
||||
BACNET_REJECT_REASON reject_code = REJECT_REASON_OTHER;
|
||||
|
||||
if((error_code > ERROR_CODE_NETWORK_DOWN) && (error_code <= ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE))
|
||||
reject_code = (BACNET_REJECT_REASON)(error_code - ERROR_CODE_NETWORK_DOWN);
|
||||
|
||||
return(reject_code);
|
||||
}
|
||||
|
||||
/* encode service */
|
||||
int reject_encode_apdu(
|
||||
uint8_t * apdu,
|
||||
|
||||
+10
-10
@@ -92,14 +92,14 @@ int rp_decode_service_request(
|
||||
/* Must have at least 2 tags, an object id and a property identifier
|
||||
* of at least 1 byte in length to have any chance of parsing */
|
||||
if(apdu_len < 7) {
|
||||
rpdata->error_code = REJECT_REASON_MISSING_REQUIRED_PARAMETER;
|
||||
return -1;
|
||||
rpdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
|
||||
/* Tag 0: Object ID */
|
||||
if (!decode_is_context_tag(&apdu[len++], 0)) {
|
||||
rpdata->error_code = REJECT_REASON_INVALID_TAG;
|
||||
return -1;
|
||||
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len += decode_object_id(&apdu[len], &type, &rpdata->object_instance);
|
||||
rpdata->object_type = (BACNET_OBJECT_TYPE) type;
|
||||
@@ -108,8 +108,8 @@ int rp_decode_service_request(
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value_type);
|
||||
if (tag_number != 1) {
|
||||
rpdata->error_code = REJECT_REASON_INVALID_TAG;
|
||||
return -1;
|
||||
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len += decode_enumerated(&apdu[len], len_value_type, &property);
|
||||
rpdata->object_property = (BACNET_PROPERTY_ID) property;
|
||||
@@ -123,8 +123,8 @@ int rp_decode_service_request(
|
||||
decode_unsigned(&apdu[len], len_value_type, &array_value);
|
||||
rpdata->array_index = array_value;
|
||||
} else {
|
||||
rpdata->error_code = REJECT_REASON_INVALID_TAG;
|
||||
return -1;
|
||||
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
} else
|
||||
rpdata->array_index = BACNET_ARRAY_ALL;
|
||||
@@ -132,8 +132,8 @@ int rp_decode_service_request(
|
||||
|
||||
if(len < apdu_len) {
|
||||
/* If something left over now, we have an invalid request */
|
||||
rpdata->error_code = REJECT_REASON_TOO_MANY_ARGUMENTS;
|
||||
return -1;
|
||||
rpdata->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
|
||||
return (int) len;
|
||||
|
||||
Reference in New Issue
Block a user