Changed BACnet enumerations API to use uint32_t rather than int.
This commit is contained in:
@@ -50,7 +50,7 @@ static int rpm_ack_decode_service_request(
|
|||||||
BACNET_READ_ACCESS_DATA * read_access_data)
|
BACNET_READ_ACCESS_DATA * read_access_data)
|
||||||
{
|
{
|
||||||
int decoded_len = 0; /* return value */
|
int decoded_len = 0; /* return value */
|
||||||
int error_value = 0; /* decoded error value */
|
uint32_t error_value = 0; /* decoded error value */
|
||||||
int len = 0; /* number of bytes returned from decoding */
|
int len = 0; /* number of bytes returned from decoding */
|
||||||
uint8_t tag_number = 0; /* decoded tag number */
|
uint8_t tag_number = 0; /* decoded tag number */
|
||||||
uint32_t len_value = 0; /* decoded length value */
|
uint32_t len_value = 0; /* decoded length value */
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ typedef struct BACnet_Application_Data_Value {
|
|||||||
BACNET_BIT_STRING Bit_String;
|
BACNET_BIT_STRING Bit_String;
|
||||||
#endif
|
#endif
|
||||||
#if defined (BACAPP_ENUMERATED)
|
#if defined (BACAPP_ENUMERATED)
|
||||||
int Enumerated;
|
uint32_t Enumerated;
|
||||||
#endif
|
#endif
|
||||||
#if defined (BACAPP_DATE)
|
#if defined (BACAPP_DATE)
|
||||||
BACNET_DATE Date;
|
BACNET_DATE Date;
|
||||||
|
|||||||
@@ -288,21 +288,21 @@ extern "C" {
|
|||||||
int decode_enumerated(
|
int decode_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint32_t len_value,
|
uint32_t len_value,
|
||||||
int *value);
|
uint32_t *value);
|
||||||
int decode_context_enumerated(
|
int decode_context_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_value,
|
uint8_t tag_value,
|
||||||
int *value);
|
uint32_t *value);
|
||||||
int encode_bacnet_enumerated(
|
int encode_bacnet_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int value);
|
uint32_t value);
|
||||||
int encode_application_enumerated(
|
int encode_application_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int value);
|
uint32_t value);
|
||||||
int encode_context_enumerated(
|
int encode_context_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int tag_number,
|
int tag_number,
|
||||||
int value);
|
uint32_t value);
|
||||||
|
|
||||||
/* from clause 20.2.13 Encoding of a Time Value */
|
/* from clause 20.2.13 Encoding of a Time Value */
|
||||||
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
||||||
|
|||||||
@@ -323,8 +323,8 @@ void apdu_handler(
|
|||||||
uint16_t len = 0; /* counts where we are in PDU */
|
uint16_t len = 0; /* counts where we are in PDU */
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
int error_code = 0;
|
uint32_t error_code = 0;
|
||||||
int error_class = 0;
|
uint32_t error_class = 0;
|
||||||
uint8_t reason = 0;
|
uint8_t reason = 0;
|
||||||
bool server = false;
|
bool server = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1149,7 +1149,7 @@ int encode_application_unsigned(
|
|||||||
int decode_enumerated(
|
int decode_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint32_t len_value,
|
uint32_t len_value,
|
||||||
int *value)
|
uint32_t *value)
|
||||||
{
|
{
|
||||||
uint32_t unsigned_value = 0;
|
uint32_t unsigned_value = 0;
|
||||||
int len;
|
int len;
|
||||||
@@ -1165,7 +1165,7 @@ int decode_enumerated(
|
|||||||
int decode_context_enumerated(
|
int decode_context_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_value,
|
uint8_t tag_value,
|
||||||
int *value)
|
uint32_t *value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
uint8_t tag_number;
|
uint8_t tag_number;
|
||||||
@@ -1186,7 +1186,7 @@ int decode_context_enumerated(
|
|||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
int encode_bacnet_enumerated(
|
int encode_bacnet_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int value)
|
uint32_t value)
|
||||||
{
|
{
|
||||||
return encode_bacnet_unsigned(apdu, value);
|
return encode_bacnet_unsigned(apdu, value);
|
||||||
}
|
}
|
||||||
@@ -1196,7 +1196,7 @@ int encode_bacnet_enumerated(
|
|||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
int encode_application_enumerated(
|
int encode_application_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int value)
|
uint32_t value)
|
||||||
{
|
{
|
||||||
int len = 0; /* return value */
|
int len = 0; /* return value */
|
||||||
|
|
||||||
@@ -1213,7 +1213,7 @@ int encode_application_enumerated(
|
|||||||
int encode_context_enumerated(
|
int encode_context_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int tag_number,
|
int tag_number,
|
||||||
int value)
|
uint32_t value)
|
||||||
{
|
{
|
||||||
int len = 0; /* return value */
|
int len = 0; /* return value */
|
||||||
|
|
||||||
@@ -1782,8 +1782,8 @@ void testBACDCodeEnumerated(
|
|||||||
{
|
{
|
||||||
uint8_t array[5] = { 0 };
|
uint8_t array[5] = { 0 };
|
||||||
uint8_t encoded_array[5] = { 0 };
|
uint8_t encoded_array[5] = { 0 };
|
||||||
int value = 1;
|
uint32_t value = 1;
|
||||||
int decoded_value = 0;
|
uint32_t decoded_value = 0;
|
||||||
int i = 0, apdu_len = 0;
|
int i = 0, apdu_len = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
uint8_t apdu[MAX_APDU] = { 0 };
|
uint8_t apdu[MAX_APDU] = { 0 };
|
||||||
@@ -2380,8 +2380,8 @@ void testEnumeratedContextDecodes(
|
|||||||
int outLen2;
|
int outLen2;
|
||||||
|
|
||||||
/* 32 bit number */
|
/* 32 bit number */
|
||||||
int32_t in = 0xdeadbeef;
|
uint32_t in = 0xdeadbeef;
|
||||||
int32_t out;
|
uint32_t out;
|
||||||
|
|
||||||
outLen2 = decode_context_enumerated(apdu, 9, &out);
|
outLen2 = decode_context_enumerated(apdu, 9, &out);
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ int bacerror_decode_error_class_and_code(
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int decoded_value = 0;
|
uint32_t decoded_value = 0;
|
||||||
|
|
||||||
if (apdu_len) {
|
if (apdu_len) {
|
||||||
/* error class */
|
/* error class */
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ int cov_notify_decode_service_request(
|
|||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0; /* for decoding */
|
uint32_t decoded_value = 0; /* for decoding */
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
@@ -520,7 +520,7 @@ int cov_subscribe_property_decode_service_request(
|
|||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0; /* for decoding */
|
uint32_t decoded_value = 0; /* for decoding */
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
/* tag 0 - subscriberProcessIdentifier */
|
/* tag 0 - subscriberProcessIdentifier */
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ int dcc_decode_service_request(
|
|||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int value = 0;
|
|
||||||
uint32_t value32 = 0;
|
uint32_t value32 = 0;
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
@@ -192,9 +191,9 @@ int dcc_decode_service_request(
|
|||||||
len +=
|
len +=
|
||||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||||
&len_value_type);
|
&len_value_type);
|
||||||
len += decode_enumerated(&apdu[len], len_value_type, &value);
|
len += decode_enumerated(&apdu[len], len_value_type, &value32);
|
||||||
if (enable_disable)
|
if (enable_disable)
|
||||||
*enable_disable = (BACNET_COMMUNICATION_ENABLE_DISABLE) value;
|
*enable_disable = (BACNET_COMMUNICATION_ENABLE_DISABLE) value32;
|
||||||
/* Tag 2: password --optional-- */
|
/* Tag 2: password --optional-- */
|
||||||
if (len < apdu_len) {
|
if (len < apdu_len) {
|
||||||
if (!decode_is_context_tag(&apdu[len], 2))
|
if (!decode_is_context_tag(&apdu[len], 2))
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ int iam_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0;
|
uint32_t decoded_value = 0;
|
||||||
int decoded_integer = 0;
|
|
||||||
|
|
||||||
/* OBJECT ID - object id */
|
/* OBJECT ID - object id */
|
||||||
len =
|
len =
|
||||||
@@ -115,12 +114,12 @@ int iam_decode_service_request(
|
|||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED)
|
if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED)
|
||||||
return -1;
|
return -1;
|
||||||
len = decode_enumerated(&apdu[apdu_len], len_value, &decoded_integer);
|
len = decode_enumerated(&apdu[apdu_len], len_value, &decoded_value);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
if (decoded_integer >= MAX_BACNET_SEGMENTATION)
|
if (decoded_value >= MAX_BACNET_SEGMENTATION)
|
||||||
return -1;
|
return -1;
|
||||||
if (pSegmentation)
|
if (pSegmentation)
|
||||||
*pSegmentation = decoded_integer;
|
*pSegmentation = decoded_value;
|
||||||
/* Vendor ID - unsigned16 */
|
/* Vendor ID - unsigned16 */
|
||||||
len =
|
len =
|
||||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value);
|
decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ int rd_decode_service_request(
|
|||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int value = 0;
|
uint32_t value = 0;
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
if (apdu_len) {
|
if (apdu_len) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ int rp_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
uint32_t array_value = 0; /* for decoding */
|
uint32_t array_value = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
@@ -215,7 +215,7 @@ int rp_ack_decode_service_request(
|
|||||||
int tag_len = 0; /* length of tag decode */
|
int tag_len = 0; /* length of tag decode */
|
||||||
int len = 0; /* total length of decodes */
|
int len = 0; /* total length of decodes */
|
||||||
uint16_t object = 0; /* object type */
|
uint16_t object = 0; /* object type */
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
uint32_t array_value = 0; /* for decoding */
|
uint32_t array_value = 0; /* for decoding */
|
||||||
|
|
||||||
/* FIXME: check apdu_len against the len during decode */
|
/* FIXME: check apdu_len against the len during decode */
|
||||||
@@ -247,9 +247,12 @@ int rp_ack_decode_service_request(
|
|||||||
len++;
|
len++;
|
||||||
/* don't decode the application tag number or its data here */
|
/* don't decode the application tag number or its data here */
|
||||||
rpdata->application_data = &apdu[len];
|
rpdata->application_data = &apdu[len];
|
||||||
rpdata->application_data_len = apdu_len - len - 1 /*closing tag */ ;
|
rpdata->application_data_len = apdu_len - len - 1 /*closing tag */;
|
||||||
} else
|
/* len includes the data and the closing tag */
|
||||||
|
len = apdu_len;
|
||||||
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@@ -328,7 +331,7 @@ void testReadPropertyAck(
|
|||||||
BACNET_READ_PROPERTY_DATA test_data;
|
BACNET_READ_PROPERTY_DATA test_data;
|
||||||
BACNET_OBJECT_TYPE object_type = OBJECT_DEVICE;
|
BACNET_OBJECT_TYPE object_type = OBJECT_DEVICE;
|
||||||
uint32_t object_instance = 0;
|
uint32_t object_instance = 0;
|
||||||
int object = 0;
|
uint32_t object = 0;
|
||||||
|
|
||||||
rpdata.object_type = OBJECT_DEVICE;
|
rpdata.object_type = OBJECT_DEVICE;
|
||||||
rpdata.object_instance = 1;
|
rpdata.object_instance = 1;
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ int rpm_decode_object_property(
|
|||||||
unsigned option_len = 0;
|
unsigned option_len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
uint32_t array_value = 0; /* for decoding */
|
uint32_t array_value = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for valid pointers */
|
/* check for valid pointers */
|
||||||
@@ -430,7 +430,7 @@ int rpm_ack_decode_object_property(
|
|||||||
unsigned tag_len = 0;
|
unsigned tag_len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
uint32_t array_value = 0; /* for decoding */
|
uint32_t array_value = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for valid pointers */
|
/* check for valid pointers */
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ int wp_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
uint32_t property = 0; /* for decoding */
|
||||||
uint32_t unsigned_value = 0;
|
uint32_t unsigned_value = 0;
|
||||||
int i = 0; /* loop counter */
|
int i = 0; /* loop counter */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user