Indented using indent script.
This commit is contained in:
+92
-87
@@ -149,8 +149,7 @@ struct Address_Cache_Entry *address_remove_oldest(
|
||||
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->
|
||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
ulTime = pMatch->TimeToLive;
|
||||
@@ -169,10 +168,9 @@ struct Address_Cache_Entry *address_remove_oldest(
|
||||
/* Second pass - try in use and un bound as last resort */
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->
|
||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
BAC_ADDR_STATIC)) ==
|
||||
((uint8_t)(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
||||
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
ulTime = pMatch->TimeToLive;
|
||||
pCandidate = pMatch;
|
||||
@@ -242,7 +240,7 @@ void address_file_init(
|
||||
}
|
||||
}
|
||||
address_add((uint32_t) device_id, max_apdu, &src);
|
||||
address_set_device_TTL((uint32_t)device_id, 0, true); /* Mark as static entry */
|
||||
address_set_device_TTL((uint32_t) device_id, 0, true); /* Mark as static entry */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -498,10 +496,10 @@ bool address_bind_request(
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_RESERVED)) == 0) {
|
||||
/* In use and awaiting binding */
|
||||
pMatch->Flags = (uint8_t)(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ);
|
||||
pMatch->Flags = (uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ);
|
||||
pMatch->device_id = device_id;
|
||||
/* No point in leaving bind requests in for long haul */
|
||||
pMatch->TimeToLive = BAC_ADDR_SHORT_TIME;
|
||||
pMatch->TimeToLive = BAC_ADDR_SHORT_TIME;
|
||||
/* now would be a good time to do a Who-Is request */
|
||||
return (false);
|
||||
}
|
||||
@@ -511,7 +509,7 @@ bool address_bind_request(
|
||||
/* No free entries, See if we can squeeze it in by dropping an existing one */
|
||||
pMatch = address_remove_oldest();
|
||||
if (pMatch != NULL) {
|
||||
pMatch->Flags = (uint8_t)(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ);
|
||||
pMatch->Flags = (uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ);
|
||||
pMatch->device_id = device_id;
|
||||
/* No point in leaving bind requests in for long haul */
|
||||
pMatch->TimeToLive = BAC_ADDR_SHORT_TIME;
|
||||
@@ -537,7 +535,7 @@ void address_add_binding(
|
||||
/* Clear bind request flag in case it was set */
|
||||
pMatch->Flags &= ~BAC_ADDR_BIND_REQ;
|
||||
/* Only update TTL if not static */
|
||||
if ((pMatch->Flags & BAC_ADDR_STATIC) == 0) {
|
||||
if ((pMatch->Flags & BAC_ADDR_STATIC) == 0) {
|
||||
/* and set it on a long fuse */
|
||||
pMatch->TimeToLive = BAC_ADDR_LONG_TIME;
|
||||
}
|
||||
@@ -580,7 +578,8 @@ unsigned address_count(
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
/* Only count bound entries */
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == BAC_ADDR_IN_USE)
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) ==
|
||||
BAC_ADDR_IN_USE)
|
||||
count++;
|
||||
|
||||
pMatch++;
|
||||
@@ -660,47 +659,47 @@ int address_list_encode(
|
||||
* oct string to give 17 bytes (the minimum possible is 5 + 2 + 3 = 10). *
|
||||
****************************************************************************/
|
||||
|
||||
#define ACACHE_MAX_ENC 17 /* Maximum size of encoded cache entry, see above */
|
||||
#define ACACHE_MAX_ENC 17 /* Maximum size of encoded cache entry, see above */
|
||||
|
||||
int rr_address_list_encode(
|
||||
uint8_t *apdu,
|
||||
BACNET_READ_RANGE_DATA *pRequest)
|
||||
uint8_t * apdu,
|
||||
BACNET_READ_RANGE_DATA * pRequest)
|
||||
{
|
||||
int iLen = 0;
|
||||
int32_t iTemp = 0;
|
||||
struct Address_Cache_Entry *pMatch = NULL;
|
||||
struct Address_Cache_Entry *pMatch = NULL;
|
||||
BACNET_OCTET_STRING MAC_Address;
|
||||
uint32_t uiTotal = 0; /* Number of bound entries in the cache */
|
||||
uint32_t uiIndex = 0; /* Current entry number */
|
||||
uint32_t uiFirst = 0; /* Entry number we started encoding from */
|
||||
uint32_t uiLast = 0; /* Entry number we finished encoding on */
|
||||
uint32_t uiTarget = 0; /* Last entry we are required to encode */
|
||||
uint32_t uiRemaining = 0; /* Amount of unused space in packet */
|
||||
|
||||
uint32_t uiTotal = 0; /* Number of bound entries in the cache */
|
||||
uint32_t uiIndex = 0; /* Current entry number */
|
||||
uint32_t uiFirst = 0; /* Entry number we started encoding from */
|
||||
uint32_t uiLast = 0; /* Entry number we finished encoding on */
|
||||
uint32_t uiTarget = 0; /* Last entry we are required to encode */
|
||||
uint32_t uiRemaining = 0; /* Amount of unused space in packet */
|
||||
|
||||
/* Initialise result flags to all false */
|
||||
bitstring_init(&pRequest->ResultFlags);
|
||||
bitstring_init(&pRequest->ResultFlags);
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, false);
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, false);
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, false);
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, false);
|
||||
/* See how much space we have */
|
||||
uiRemaining = (uint32_t)(MAX_APDU - pRequest->Overhead);
|
||||
uiRemaining = (uint32_t) (MAX_APDU - pRequest->Overhead);
|
||||
|
||||
pRequest->ItemCount = 0; /* Start out with nothing */
|
||||
uiTotal = address_count(); /* What do we have to work with here ? */
|
||||
if(uiTotal == 0) /* Bail out now if nowt */
|
||||
return(0);
|
||||
if (uiTotal == 0) /* Bail out now if nowt */
|
||||
return (0);
|
||||
|
||||
if(pRequest->RequestType == RR_READ_ALL) {
|
||||
if (pRequest->RequestType == RR_READ_ALL) {
|
||||
/*
|
||||
* Read all the array or as much as will fit in the buffer by selecting
|
||||
* a range that covers the whole list and falling through to the next
|
||||
* section of code
|
||||
*/
|
||||
pRequest->Count = uiTotal; /* Full list */
|
||||
pRequest->Range.RefIndex = 1; /* Starting at the beginning */
|
||||
}
|
||||
pRequest->Count = uiTotal; /* Full list */
|
||||
pRequest->Range.RefIndex = 1; /* Starting at the beginning */
|
||||
}
|
||||
|
||||
if(pRequest->Count < 0) { /* negative count means work from index backwards */
|
||||
if (pRequest->Count < 0) { /* negative count means work from index backwards */
|
||||
/*
|
||||
* Convert from end index/negative count to
|
||||
* start index/positive count and then process as
|
||||
@@ -713,91 +712,97 @@ int rr_address_list_encode(
|
||||
* try to optimise the code unless you understand all the
|
||||
* implications of the data type conversions!
|
||||
*/
|
||||
|
||||
iTemp = pRequest->Range.RefIndex; /* pull out and convert to signed */
|
||||
iTemp += pRequest->Count + 1; /* Adjust backwards, remember count is -ve */
|
||||
if(iTemp < 1) { /* if count is too much, return from 1 to start index */
|
||||
|
||||
iTemp = pRequest->Range.RefIndex; /* pull out and convert to signed */
|
||||
iTemp += pRequest->Count + 1; /* Adjust backwards, remember count is -ve */
|
||||
if (iTemp < 1) { /* if count is too much, return from 1 to start index */
|
||||
pRequest->Count = pRequest->Range.RefIndex;
|
||||
pRequest->Range.RefIndex = 1;
|
||||
}
|
||||
else { /* Otherwise adjust the start index and make count +ve */
|
||||
} else { /* Otherwise adjust the start index and make count +ve */
|
||||
pRequest->Range.RefIndex = iTemp;
|
||||
pRequest->Count = -pRequest->Count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* From here on in we only have a starting point and a positive count */
|
||||
|
||||
if(pRequest->Range.RefIndex > uiTotal) /* Nothing to return as we are past the end of the list */
|
||||
return(0);
|
||||
|
||||
uiTarget = pRequest->Range.RefIndex + pRequest->Count - 1; /* Index of last required entry */
|
||||
if(uiTarget > uiTotal) /* Capped at end of list if necessary */
|
||||
|
||||
if (pRequest->Range.RefIndex > uiTotal) /* Nothing to return as we are past the end of the list */
|
||||
return (0);
|
||||
|
||||
uiTarget = pRequest->Range.RefIndex + pRequest->Count - 1; /* Index of last required entry */
|
||||
if (uiTarget > uiTotal) /* Capped at end of list if necessary */
|
||||
uiTarget = uiTotal;
|
||||
|
||||
pMatch = Address_Cache;
|
||||
|
||||
pMatch = Address_Cache;
|
||||
uiIndex = 1;
|
||||
while((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) != BAC_ADDR_IN_USE) /* Find first bound entry */
|
||||
while ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) != BAC_ADDR_IN_USE) /* Find first bound entry */
|
||||
pMatch++;
|
||||
|
||||
|
||||
/* Seek to start position */
|
||||
while(uiIndex != pRequest->Range.RefIndex) {
|
||||
if((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == BAC_ADDR_IN_USE) { /* Only count bound entries */
|
||||
while (uiIndex != pRequest->Range.RefIndex) {
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == BAC_ADDR_IN_USE) { /* Only count bound entries */
|
||||
pMatch++;
|
||||
uiIndex++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
pMatch++;
|
||||
}
|
||||
|
||||
uiFirst = uiIndex; /* Record where we started from */
|
||||
while(uiIndex <= uiTarget) {
|
||||
if(uiRemaining < ACACHE_MAX_ENC) {
|
||||
|
||||
uiFirst = uiIndex; /* Record where we started from */
|
||||
while (uiIndex <= uiTarget) {
|
||||
if (uiRemaining < ACACHE_MAX_ENC) {
|
||||
/*
|
||||
* Can't fit any more in! We just set the result flag to say there
|
||||
* was more and drop out of the loop early
|
||||
*/
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, true);
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS,
|
||||
true);
|
||||
break;
|
||||
}
|
||||
|
||||
iTemp = (int32_t)encode_application_object_id(&apdu[iLen],
|
||||
OBJECT_DEVICE,
|
||||
}
|
||||
|
||||
iTemp =
|
||||
(int32_t) encode_application_object_id(&apdu[iLen], OBJECT_DEVICE,
|
||||
pMatch->device_id);
|
||||
iTemp += encode_application_unsigned(&apdu[iLen + iTemp],
|
||||
iTemp +=
|
||||
encode_application_unsigned(&apdu[iLen + iTemp],
|
||||
pMatch->address.net);
|
||||
|
||||
|
||||
/* pick the appropriate type of entry from the cache */
|
||||
|
||||
if(pMatch->address.len != 0) {
|
||||
octetstring_init(&MAC_Address, pMatch->address.adr, pMatch->address.len);
|
||||
iTemp += encode_application_octet_string(&apdu[iLen + iTemp], &MAC_Address);
|
||||
|
||||
if (pMatch->address.len != 0) {
|
||||
octetstring_init(&MAC_Address, pMatch->address.adr,
|
||||
pMatch->address.len);
|
||||
iTemp +=
|
||||
encode_application_octet_string(&apdu[iLen + iTemp],
|
||||
&MAC_Address);
|
||||
} else {
|
||||
octetstring_init(&MAC_Address, pMatch->address.mac,
|
||||
pMatch->address.mac_len);
|
||||
iTemp +=
|
||||
encode_application_octet_string(&apdu[iLen + iTemp],
|
||||
&MAC_Address);
|
||||
}
|
||||
else {
|
||||
octetstring_init(&MAC_Address, pMatch->address.mac, pMatch->address.mac_len);
|
||||
iTemp += encode_application_octet_string(&apdu[iLen + iTemp], &MAC_Address);
|
||||
}
|
||||
|
||||
uiRemaining -= iTemp; /* Reduce the remaining space */
|
||||
iLen += iTemp; /* and increase the length consumed */
|
||||
|
||||
|
||||
uiRemaining -= iTemp; /* Reduce the remaining space */
|
||||
iLen += iTemp; /* and increase the length consumed */
|
||||
|
||||
uiLast = uiIndex; /* Record the last entry encoded */
|
||||
uiIndex++; /* and get ready for next one */
|
||||
uiIndex++; /* and get ready for next one */
|
||||
pMatch++;
|
||||
pRequest->ItemCount++; /* Chalk up another one for the response count */
|
||||
|
||||
while((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) != BAC_ADDR_IN_USE) /* Find next bound entry */
|
||||
|
||||
while ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) != BAC_ADDR_IN_USE) /* Find next bound entry */
|
||||
pMatch++;
|
||||
}
|
||||
|
||||
|
||||
/* Set remaining result flags if necessary */
|
||||
if(uiFirst == 1)
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, true);
|
||||
|
||||
if(uiLast == uiTotal)
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
||||
|
||||
return(iLen);
|
||||
if (uiFirst == 1)
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM,
|
||||
true);
|
||||
|
||||
if (uiLast == uiTotal)
|
||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
||||
|
||||
return (iLen);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -126,10 +126,10 @@ int alarm_ack_decode_service_request(
|
||||
int len = 0;
|
||||
int section_len;
|
||||
uint32_t enumValue;
|
||||
|
||||
|
||||
/* unused parameter */
|
||||
apdu_len = apdu_len;
|
||||
|
||||
|
||||
if (-1 == (section_len =
|
||||
decode_context_unsigned(&apdu[len], 0,
|
||||
&data->ackProcessIdentifier))) {
|
||||
@@ -149,7 +149,7 @@ int alarm_ack_decode_service_request(
|
||||
decode_context_enumerated(&apdu[len], 2, &enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
data->eventStateAcked = (BACNET_EVENT_STATE)enumValue;
|
||||
data->eventStateAcked = (BACNET_EVENT_STATE) enumValue;
|
||||
len += section_len;
|
||||
|
||||
if (-1 == (section_len =
|
||||
|
||||
@@ -178,8 +178,8 @@ bool apdu_service_supported(
|
||||
*/
|
||||
bool apdu_service_supported_to_index(
|
||||
BACNET_SERVICES_SUPPORTED service_supported,
|
||||
size_t *index,
|
||||
bool *bIsConfirmed )
|
||||
size_t * index,
|
||||
bool * bIsConfirmed)
|
||||
{
|
||||
int i = 0;
|
||||
bool found = false;
|
||||
|
||||
+43
-41
@@ -517,7 +517,7 @@ BACNET_APPLICATION_TAG bacapp_context_tag_type(
|
||||
}
|
||||
break;
|
||||
case PROP_LIST_OF_GROUP_MEMBERS:
|
||||
/* Sequence of ReadAccessSpecification */
|
||||
/* Sequence of ReadAccessSpecification */
|
||||
switch (tag_number) {
|
||||
case 0:
|
||||
tag = BACNET_APPLICATION_TAG_OBJECT_ID;
|
||||
@@ -542,31 +542,31 @@ BACNET_APPLICATION_TAG bacapp_context_tag_type(
|
||||
break;
|
||||
case PROP_LOG_DEVICE_OBJECT_PROPERTY:
|
||||
switch (tag_number) {
|
||||
case 0: /* Object ID */
|
||||
case 3: /* Device ID */
|
||||
tag = BACNET_APPLICATION_TAG_OBJECT_ID;
|
||||
case 0: /* Object ID */
|
||||
case 3: /* Device ID */
|
||||
tag = BACNET_APPLICATION_TAG_OBJECT_ID;
|
||||
break;
|
||||
case 1: /* Property ID */
|
||||
case 1: /* Property ID */
|
||||
tag = BACNET_APPLICATION_TAG_ENUMERATED;
|
||||
break;
|
||||
case 2: /* Array index */
|
||||
case 2: /* Array index */
|
||||
tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PROP_SUBORDINATE_LIST:
|
||||
/* BACnetARRAY[N] of BACnetDeviceObjectReference */
|
||||
switch (tag_number) {
|
||||
case 0: /* Optional Device ID */
|
||||
case 1: /* Object ID */
|
||||
tag = BACNET_APPLICATION_TAG_OBJECT_ID;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PROP_SUBORDINATE_LIST:
|
||||
/* BACnetARRAY[N] of BACnetDeviceObjectReference */
|
||||
switch (tag_number) {
|
||||
case 0: /* Optional Device ID */
|
||||
case 1: /* Object ID */
|
||||
tag = BACNET_APPLICATION_TAG_OBJECT_ID;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -837,10 +837,11 @@ bool bacapp_print_value(
|
||||
fprintf(stream, "%s", value->type.Boolean ? "TRUE" : "FALSE");
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
fprintf(stream, "%lu", (unsigned long)value->type.Unsigned_Int);
|
||||
fprintf(stream, "%lu",
|
||||
(unsigned long) value->type.Unsigned_Int);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||
fprintf(stream, "%ld", (long)value->type.Signed_Int);
|
||||
fprintf(stream, "%ld", (long) value->type.Signed_Int);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
fprintf(stream, "%f", (double) value->type.Real);
|
||||
@@ -890,14 +891,14 @@ bool bacapp_print_value(
|
||||
case PROP_OBJECT_TYPE:
|
||||
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_object_type_name(value->type.
|
||||
Enumerated));
|
||||
bactext_object_type_name(value->
|
||||
type.Enumerated));
|
||||
} else if (value->type.Enumerated < 128) {
|
||||
fprintf(stream, "reserved %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
(unsigned long) value->type.Enumerated);
|
||||
} else {
|
||||
fprintf(stream, "proprietary %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
(unsigned long) value->type.Enumerated);
|
||||
}
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -907,22 +908,22 @@ bool bacapp_print_value(
|
||||
case PROP_UNITS:
|
||||
if (value->type.Enumerated < 256) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_engineering_unit_name(value->
|
||||
type.Enumerated));
|
||||
bactext_engineering_unit_name(value->type.
|
||||
Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "proprietary %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
(unsigned long) value->type.Enumerated);
|
||||
}
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_polarity_name(value->
|
||||
type.Enumerated));
|
||||
bactext_binary_polarity_name(value->type.
|
||||
Enumerated));
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_present_value_name(value->
|
||||
type.Enumerated));
|
||||
bactext_binary_present_value_name(value->type.
|
||||
Enumerated));
|
||||
break;
|
||||
case PROP_RELIABILITY:
|
||||
fprintf(stream, "%s",
|
||||
@@ -930,8 +931,8 @@ bool bacapp_print_value(
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
fprintf(stream, "%s",
|
||||
bactext_device_status_name(value->
|
||||
type.Enumerated));
|
||||
bactext_device_status_name(value->type.
|
||||
Enumerated));
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
fprintf(stream, "%s",
|
||||
@@ -942,7 +943,8 @@ bool bacapp_print_value(
|
||||
bactext_node_type_name(value->type.Enumerated));
|
||||
break;
|
||||
default:
|
||||
fprintf(stream, "%lu", (unsigned long)value->type.Enumerated);
|
||||
fprintf(stream, "%lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -988,15 +990,15 @@ bool bacapp_print_value(
|
||||
if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
fprintf(stream, "(%s, %lu)",
|
||||
bactext_object_type_name(value->type.Object_Id.type),
|
||||
(unsigned long)value->type.Object_Id.instance);
|
||||
(unsigned long) value->type.Object_Id.instance);
|
||||
} else if (value->type.Object_Id.type < 128) {
|
||||
fprintf(stream, "(reserved %u, %lu)",
|
||||
(unsigned)value->type.Object_Id.type,
|
||||
(unsigned long)value->type.Object_Id.instance);
|
||||
(unsigned) value->type.Object_Id.type,
|
||||
(unsigned long) value->type.Object_Id.instance);
|
||||
} else {
|
||||
fprintf(stream, "(proprietary %u, %lu)",
|
||||
(unsigned)value->type.Object_Id.type,
|
||||
(unsigned long)value->type.Object_Id.instance);
|
||||
(unsigned) value->type.Object_Id.type,
|
||||
(unsigned long) value->type.Object_Id.instance);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1294,15 +1296,15 @@ void testBACnetApplicationData_Safe(
|
||||
|
||||
case BACNET_APPLICATION_TAG_OCTET_STRING:
|
||||
{
|
||||
uint8_t test_octet[5] = {"Karg"};
|
||||
uint8_t test_octet[5] = { "Karg" };
|
||||
octetstring_init(&input_value[i].type.Octet_String,
|
||||
test_octet, sizeof(test_octet));
|
||||
}
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||
characterstring_init_ansi(&input_value[i].type.
|
||||
Character_String, "Hello There!");
|
||||
characterstring_init_ansi(&input_value[i].
|
||||
type.Character_String, "Hello There!");
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||
|
||||
@@ -1190,7 +1190,7 @@ int encode_context_unsigned(
|
||||
len = 4;
|
||||
}
|
||||
|
||||
len = encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
|
||||
len = encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
|
||||
len += encode_bacnet_unsigned(&apdu[len], value);
|
||||
|
||||
return len;
|
||||
@@ -1563,7 +1563,7 @@ int decode_bacnet_time_safe(
|
||||
btime->hundredths = 0;
|
||||
btime->min = 0;
|
||||
btime->sec = 0;
|
||||
return (int)len_value;
|
||||
return (int) len_value;
|
||||
} else {
|
||||
return decode_bacnet_time(apdu, btime);
|
||||
}
|
||||
@@ -1696,7 +1696,7 @@ int decode_date_safe(
|
||||
bdate->month = 0;
|
||||
bdate->wday = 0;
|
||||
bdate->year = 0;
|
||||
return (int)len_value;
|
||||
return (int) len_value;
|
||||
} else {
|
||||
return decode_date(apdu, bdate);
|
||||
}
|
||||
@@ -2010,7 +2010,8 @@ void testBACDCodeUnsignedValue(
|
||||
len = decode_unsigned(&array[len], len_value, &decoded_value);
|
||||
ct_test(pTest, decoded_value == value);
|
||||
if (decoded_value != value) {
|
||||
printf("value=%lu decoded_value=%lu\n", (unsigned long)value, (unsigned long)decoded_value);
|
||||
printf("value=%lu decoded_value=%lu\n", (unsigned long) value,
|
||||
(unsigned long) decoded_value);
|
||||
print_apdu(&array[0], sizeof(array));
|
||||
}
|
||||
encode_application_unsigned(&encoded_array[0], decoded_value);
|
||||
@@ -2078,14 +2079,16 @@ void testBACDCodeSignedValue(
|
||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
ct_test(pTest, decoded_value == value);
|
||||
if (decoded_value != value) {
|
||||
printf("value=%ld decoded_value=%ld\n", (long)value, (long)decoded_value);
|
||||
printf("value=%ld decoded_value=%ld\n", (long) value,
|
||||
(long) decoded_value);
|
||||
print_apdu(&array[0], sizeof(array));
|
||||
}
|
||||
encode_application_signed(&encoded_array[0], decoded_value);
|
||||
diff = memcmp(&array[0], &encoded_array[0], sizeof(array));
|
||||
ct_test(pTest, diff == 0);
|
||||
if (diff) {
|
||||
printf("value=%ld decoded_value=%ld\n", (long)value, (long)decoded_value);
|
||||
printf("value=%ld decoded_value=%ld\n", (long) value,
|
||||
(long) decoded_value);
|
||||
print_apdu(&array[0], sizeof(array));
|
||||
print_apdu(&encoded_array[0], sizeof(array));
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ int bacapp_encode_device_obj_property_ref(
|
||||
|
||||
/* Likewise, device id is optional so see if needed
|
||||
* (set type to non device to omit */
|
||||
|
||||
if(value->deviceIndentifier.type == OBJECT_DEVICE) {
|
||||
|
||||
if (value->deviceIndentifier.type == OBJECT_DEVICE) {
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 3,
|
||||
(int) value->deviceIndentifier.type,
|
||||
@@ -206,7 +206,7 @@ int bacapp_encode_device_obj_ref(
|
||||
/* Device id is optional so see if needed
|
||||
* (set type to non device to omit */
|
||||
|
||||
if(value->deviceIndentifier.type == OBJECT_DEVICE) {
|
||||
if (value->deviceIndentifier.type == OBJECT_DEVICE) {
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 0,
|
||||
(int) value->deviceIndentifier.type,
|
||||
@@ -264,8 +264,7 @@ int bacapp_decode_context_device_obj_ref(
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||
len++;
|
||||
section_length =
|
||||
bacapp_decode_device_obj_ref(&apdu[len], value);
|
||||
section_length = bacapp_decode_device_obj_ref(&apdu[len], value);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
@@ -330,8 +329,8 @@ void testDevIdPropRef(
|
||||
void testDevIdRef(
|
||||
Test * pTest)
|
||||
{
|
||||
BACNET_DEVICE_OBJECT_REFERENCE inData;
|
||||
BACNET_DEVICE_OBJECT_REFERENCE outData;
|
||||
BACNET_DEVICE_OBJECT_REFERENCE inData;
|
||||
BACNET_DEVICE_OBJECT_REFERENCE outData;
|
||||
uint8_t buffer[MAX_APDU];
|
||||
int inLen;
|
||||
int outLen;
|
||||
|
||||
@@ -86,7 +86,7 @@ int decode_real_safe(
|
||||
{
|
||||
if (len_value != 4) {
|
||||
*real_value = 0.0f;
|
||||
return (int)len_value;
|
||||
return (int) len_value;
|
||||
} else {
|
||||
return decode_real(apdu, real_value);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ int decode_double_safe(
|
||||
{
|
||||
if (len_value != 8) {
|
||||
*double_value = 0.0;
|
||||
return (int)len_value;
|
||||
return (int) len_value;
|
||||
} else {
|
||||
return decode_double(apdu, double_value);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ bool bitstring_same(
|
||||
if (bitstring1 && bitstring1) {
|
||||
if ((bitstring1->bits_used == bitstring2->bits_used) &&
|
||||
(bitstring1->bits_used / 8 <= MAX_BITSTRING_BYTES)) {
|
||||
bytes_used = (int)(bitstring1->bits_used / 8);
|
||||
bytes_used = (int) (bitstring1->bits_used / 8);
|
||||
compare_mask = 0xFF >> (8 - (bitstring1->bits_used % 8));
|
||||
|
||||
for (i = 0; i < bytes_used; i++) {
|
||||
|
||||
@@ -348,7 +348,7 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
{PROP_FILE_TYPE, "file-type"}
|
||||
,
|
||||
{PROP_FIRMWARE_REVISION, "firmware-revision"}
|
||||
, /* VTS wants "revision", not "version" */
|
||||
, /* VTS wants "revision", not "version" */
|
||||
{PROP_HIGH_LIMIT, "high-limit"}
|
||||
,
|
||||
{PROP_INACTIVE_TEXT, "inactive-text"}
|
||||
|
||||
@@ -677,8 +677,8 @@ static void bvlc_bdt_forward_npdu(
|
||||
mask in the BDT entry and logically ORing it with the
|
||||
BBMD address of the same entry. */
|
||||
bip_dest.sin_addr.s_addr =
|
||||
htonl(((~BBMD_Table[i].broadcast_mask.
|
||||
s_addr) | BBMD_Table[i].dest_address.s_addr));
|
||||
htonl(((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
|
||||
dest_address.s_addr));
|
||||
bip_dest.sin_port = htons(BBMD_Table[i].dest_port);
|
||||
/* don't send to my broadcast address and same port */
|
||||
if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr()))
|
||||
|
||||
@@ -412,8 +412,8 @@ bool datetime_wildcard_present(
|
||||
if (bdatetime) {
|
||||
if ((bdatetime->date.year == (1900 + 0xFF)) ||
|
||||
(bdatetime->date.month > 12) || (bdatetime->date.day > 31) ||
|
||||
(bdatetime->time.hour == 0xFF) ||
|
||||
(bdatetime->time.min == 0xFF) || (bdatetime->time.sec == 0xFF) ||
|
||||
(bdatetime->time.hour == 0xFF) || (bdatetime->time.min == 0xFF) ||
|
||||
(bdatetime->time.sec == 0xFF) ||
|
||||
(bdatetime->time.hundredths == 0xFF)) {
|
||||
wildcard_present = true;
|
||||
}
|
||||
@@ -421,6 +421,7 @@ bool datetime_wildcard_present(
|
||||
|
||||
return wildcard_present;
|
||||
}
|
||||
|
||||
void datetime_date_wildcard_set(
|
||||
BACNET_DATE * bdate)
|
||||
{
|
||||
|
||||
+142
-147
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 0,
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.referencedBitString);
|
||||
&data->notificationParams.changeOfBitstring.
|
||||
referencedBitString);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.statusFlags);
|
||||
&data->notificationParams.changeOfBitstring.
|
||||
statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfState.statusFlags);
|
||||
&data->notificationParams.changeOfState.
|
||||
statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 1);
|
||||
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
|
||||
case CHANGE_OF_VALUE_REAL:
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 1,
|
||||
data->notificationParams.
|
||||
changeOfValue.newValue.changeValue);
|
||||
data->notificationParams.changeOfValue.
|
||||
newValue.changeValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len],
|
||||
0,
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changedBits);
|
||||
&data->notificationParams.changeOfValue.
|
||||
newValue.changedBits);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfValue.statusFlags);
|
||||
&data->notificationParams.changeOfValue.
|
||||
statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 2);
|
||||
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 0,
|
||||
data->notificationParams.
|
||||
floatingLimit.referenceValue);
|
||||
data->notificationParams.floatingLimit.
|
||||
referenceValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.
|
||||
floatingLimit.statusFlags);
|
||||
&data->notificationParams.floatingLimit.
|
||||
statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 2,
|
||||
data->notificationParams.
|
||||
floatingLimit.setPointValue);
|
||||
data->notificationParams.floatingLimit.
|
||||
setPointValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 0,
|
||||
data->notificationParams.
|
||||
outOfRange.exceedingValue);
|
||||
data->notificationParams.outOfRange.
|
||||
exceedingValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.newState);
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
newState);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 1,
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.newMode);
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
newMode);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 2,
|
||||
&data->notificationParams.
|
||||
changeOfLifeSafety.statusFlags);
|
||||
&data->notificationParams.changeOfLifeSafety.
|
||||
statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 3,
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.operationExpected);
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 8);
|
||||
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu
|
||||
[apdu_len], 0,
|
||||
&data->notificationParams.
|
||||
bufferReady.bufferProperty);
|
||||
&data->notificationParams.bufferReady.
|
||||
bufferProperty);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 1,
|
||||
data->notificationParams.
|
||||
bufferReady.previousNotification);
|
||||
data->notificationParams.bufferReady.
|
||||
previousNotification);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.
|
||||
bufferReady.currentNotification);
|
||||
data->notificationParams.bufferReady.
|
||||
currentNotification);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 10);
|
||||
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 0,
|
||||
data->notificationParams.
|
||||
unsignedRange.exceedingValue);
|
||||
data->notificationParams.unsignedRange.
|
||||
exceedingValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.
|
||||
unsignedRange.statusFlags);
|
||||
&data->notificationParams.unsignedRange.
|
||||
statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.
|
||||
unsignedRange.exceededLimit);
|
||||
data->notificationParams.unsignedRange.
|
||||
exceededLimit);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 11);
|
||||
@@ -559,10 +559,10 @@ int event_notify_decode_service_request(
|
||||
len += section_length;
|
||||
}
|
||||
break;
|
||||
/* In cases other than alarm and event
|
||||
there's no data, so do not return an error
|
||||
but continue normally */
|
||||
case NOTIFY_ACK_NOTIFICATION:
|
||||
/* In cases other than alarm and event
|
||||
there's no data, so do not return an error
|
||||
but continue normally */
|
||||
case NOTIFY_ACK_NOTIFICATION:
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -595,18 +595,16 @@ int event_notify_decode_service_request(
|
||||
case EVENT_CHANGE_OF_BITSTRING:
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 0,
|
||||
&data->
|
||||
notificationParams.changeOfBitstring.
|
||||
referencedBitString))) {
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.referencedBitString))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->
|
||||
notificationParams.changeOfBitstring.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -617,16 +615,16 @@ int event_notify_decode_service_request(
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_property_state(&apdu
|
||||
[len], 0,
|
||||
&data->notificationParams.
|
||||
changeOfState.newState))) {
|
||||
&data->notificationParams.changeOfState.
|
||||
newState))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfState.statusFlags))) {
|
||||
&data->notificationParams.changeOfState.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -644,9 +642,8 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 0,
|
||||
&data->
|
||||
notificationParams.changeOfValue.
|
||||
newValue.changedBits))) {
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changedBits))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -657,9 +654,8 @@ int event_notify_decode_service_request(
|
||||
CHANGE_OF_VALUE_REAL)) {
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 1,
|
||||
&data->
|
||||
notificationParams.changeOfValue.
|
||||
newValue.changeValue))) {
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changeValue))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -677,8 +673,8 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfValue.statusFlags))) {
|
||||
&data->notificationParams.changeOfValue.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -687,31 +683,31 @@ int event_notify_decode_service_request(
|
||||
case EVENT_FLOATING_LIMIT:
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
floatingLimit.referenceValue))) {
|
||||
&data->notificationParams.floatingLimit.
|
||||
referenceValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
floatingLimit.statusFlags))) {
|
||||
&data->notificationParams.floatingLimit.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
floatingLimit.setPointValue))) {
|
||||
&data->notificationParams.floatingLimit.
|
||||
setPointValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 3,
|
||||
&data->notificationParams.
|
||||
floatingLimit.errorLimit))) {
|
||||
&data->notificationParams.floatingLimit.
|
||||
errorLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -720,31 +716,31 @@ int event_notify_decode_service_request(
|
||||
case EVENT_OUT_OF_RANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
outOfRange.exceedingValue))) {
|
||||
&data->notificationParams.outOfRange.
|
||||
exceedingValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
outOfRange.statusFlags))) {
|
||||
&data->notificationParams.outOfRange.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
outOfRange.deadband))) {
|
||||
&data->notificationParams.outOfRange.
|
||||
deadband))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 3,
|
||||
&data->notificationParams.
|
||||
outOfRange.exceededLimit))) {
|
||||
&data->notificationParams.outOfRange.
|
||||
exceededLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -772,9 +768,8 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 2,
|
||||
&data->
|
||||
notificationParams.changeOfLifeSafety.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
changeOfLifeSafety.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -784,8 +779,8 @@ int event_notify_decode_service_request(
|
||||
&value))) {
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.operationExpected =
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected =
|
||||
(BACNET_LIFE_SAFETY_OPERATION) value;
|
||||
len += section_length;
|
||||
break;
|
||||
@@ -794,24 +789,24 @@ int event_notify_decode_service_request(
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_device_obj_property_ref
|
||||
(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
bufferReady.bufferProperty))) {
|
||||
&data->notificationParams.bufferReady.
|
||||
bufferProperty))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
bufferReady.previousNotification))) {
|
||||
&data->notificationParams.bufferReady.
|
||||
previousNotification))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
bufferReady.currentNotification))) {
|
||||
&data->notificationParams.bufferReady.
|
||||
currentNotification))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -820,24 +815,24 @@ int event_notify_decode_service_request(
|
||||
case EVENT_UNSIGNED_RANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
unsignedRange.exceedingValue))) {
|
||||
&data->notificationParams.unsignedRange.
|
||||
exceedingValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
unsignedRange.statusFlags))) {
|
||||
&data->notificationParams.unsignedRange.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
unsignedRange.exceededLimit))) {
|
||||
&data->notificationParams.unsignedRange.
|
||||
exceededLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -858,10 +853,10 @@ int event_notify_decode_service_request(
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
/* In cases other than alarm and event
|
||||
there's no data, so do not return an error
|
||||
but continue normally */
|
||||
case NOTIFY_ACK_NOTIFICATION:
|
||||
/* In cases other than alarm and event
|
||||
there's no data, so do not return an error
|
||||
but continue normally */
|
||||
case NOTIFY_ACK_NOTIFICATION:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1096,16 +1091,16 @@ void testEventEventState(
|
||||
|
||||
data.eventType = EVENT_CHANGE_OF_BITSTRING;
|
||||
|
||||
bitstring_init(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 2, true);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 2, false);
|
||||
bitstring_init(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 2, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 2, false);
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
|
||||
|
||||
@@ -1191,16 +1186,16 @@ void testEventEventState(
|
||||
|
||||
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 2, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 3, false);
|
||||
bitstring_init(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 2, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 3, false);
|
||||
|
||||
memset(buffer, 0, MAX_APDU);
|
||||
inLen = event_notify_encode_service_request(&buffer[0], &data);
|
||||
@@ -1440,12 +1435,12 @@ void testEventEventState(
|
||||
data.notificationParams.bufferReady.currentNotification = 2345;
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
|
||||
OBJECT_DEVICE;
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.instance = 500;
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance = 500;
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
|
||||
OBJECT_ANALOG_INPUT;
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance = 100;
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance = 100;
|
||||
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
|
||||
PROP_PRESENT_VALUE;
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
|
||||
@@ -1470,34 +1465,34 @@ void testEventEventState(
|
||||
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type);
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.instance ==
|
||||
propertyIdentifier ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.
|
||||
bufferProperty.propertyIdentifier ==
|
||||
data2.notificationParams.bufferReady.
|
||||
bufferProperty.propertyIdentifier);
|
||||
propertyIdentifier);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
|
||||
|
||||
+13
-12
@@ -58,7 +58,7 @@ int getevent_encode_apdu(
|
||||
if (lastReceivedObjectIdentifier) {
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 0,
|
||||
(int)lastReceivedObjectIdentifier->type,
|
||||
(int) lastReceivedObjectIdentifier->type,
|
||||
lastReceivedObjectIdentifier->instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ int getevent_ack_encode_apdu_data(
|
||||
/* Tag 0: objectIdentifier */
|
||||
apdu_len +=
|
||||
encode_context_object_id(&apdu[apdu_len], 0,
|
||||
(int)event_data->objectIdentifier.type,
|
||||
(int) event_data->objectIdentifier.type,
|
||||
event_data->objectIdentifier.instance);
|
||||
/* Tag 1: eventState */
|
||||
apdu_len +=
|
||||
@@ -262,8 +262,7 @@ int getevent_ack_decode_service_request(
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value);
|
||||
len +=
|
||||
decode_enumerated(&apdu[len], len_value, &enum_value);
|
||||
len += decode_enumerated(&apdu[len], len_value, &enum_value);
|
||||
event_data->notifyType = enum_value;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -314,10 +313,10 @@ int getevent_ack_decode_service_request(
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value);
|
||||
if (len_value == 1)
|
||||
*moreEvents = decode_context_boolean(&apdu[len++]);
|
||||
else
|
||||
*moreEvents = false;
|
||||
if (len_value == 1)
|
||||
*moreEvents = decode_context_boolean(&apdu[len++]);
|
||||
else
|
||||
*moreEvents = false;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -430,13 +429,15 @@ void testGetEventInformationAck(
|
||||
ct_test(pTest, len != 0);
|
||||
ct_test(pTest, len != -1);
|
||||
apdu_len = len;
|
||||
len = getevent_ack_encode_apdu_data(&apdu[apdu_len],
|
||||
sizeof(apdu)-apdu_len, &event_data);
|
||||
len =
|
||||
getevent_ack_encode_apdu_data(&apdu[apdu_len], sizeof(apdu) - apdu_len,
|
||||
&event_data);
|
||||
ct_test(pTest, len != 0);
|
||||
ct_test(pTest, len != -1);
|
||||
apdu_len += len;
|
||||
len = getevent_ack_encode_apdu_end(&apdu[apdu_len],
|
||||
sizeof(apdu)-apdu_len, moreEvents);
|
||||
len =
|
||||
getevent_ack_encode_apdu_end(&apdu[apdu_len], sizeof(apdu) - apdu_len,
|
||||
moreEvents);
|
||||
ct_test(pTest, len != 0);
|
||||
ct_test(pTest, len != -1);
|
||||
apdu_len += len;
|
||||
|
||||
+13
-12
@@ -351,7 +351,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
printf_receive_error("MSTP: Rx Header: SilenceTimer %u > %d\n",
|
||||
(unsigned)mstp_port->SilenceTimer(), Tframe_abort);
|
||||
(unsigned) mstp_port->SilenceTimer(), Tframe_abort);
|
||||
}
|
||||
/* Error */
|
||||
else if (mstp_port->ReceiveError == true) {
|
||||
@@ -441,7 +441,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
if (mstp_port->DataLength) {
|
||||
printf_receive_error
|
||||
("MSTP: Rx Header: FrameTooLong %u\n",
|
||||
(unsigned)mstp_port->DataLength);
|
||||
(unsigned) mstp_port->DataLength);
|
||||
/* indicate that a frame with an illegal or */
|
||||
/* unacceptable data length has been received */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
@@ -449,7 +449,8 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* NoData */
|
||||
else if (mstp_port->DataLength == 0) {
|
||||
printf_receive_data("%s",
|
||||
mstptext_frame_type((unsigned)mstp_port->FrameType));
|
||||
mstptext_frame_type((unsigned) mstp_port->
|
||||
FrameType));
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station)
|
||||
|| (mstp_port->DestinationAddress ==
|
||||
@@ -474,7 +475,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error("MSTP: Rx Data: BadIndex %u\n",
|
||||
(unsigned)mstp_port->Index);
|
||||
(unsigned) mstp_port->Index);
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
@@ -491,7 +492,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error
|
||||
("MSTP: Rx Data: SilenceTimer %ums > %dms\n",
|
||||
(unsigned)mstp_port->SilenceTimer(), Tframe_abort);
|
||||
(unsigned) mstp_port->SilenceTimer(), Tframe_abort);
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
@@ -530,7 +531,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->DataCRC);
|
||||
mstp_port->DataCRCActualLSB = mstp_port->DataRegister;
|
||||
printf_receive_data("%s",
|
||||
mstptext_frame_type((unsigned)mstp_port->FrameType));
|
||||
mstptext_frame_type((unsigned) mstp_port->FrameType));
|
||||
/* STATE DATA CRC - no need for new state */
|
||||
/* indicate the complete reception of a valid frame */
|
||||
if (mstp_port->DataCRC == 0xF0B8) {
|
||||
@@ -636,7 +637,7 @@ bool MSTP_Master_Node_FSM(
|
||||
mstp_port->SourceAddress, mstp_port->DestinationAddress,
|
||||
mstp_port->DataLength, mstp_port->FrameCount,
|
||||
mstp_port->SilenceTimer(),
|
||||
mstptext_frame_type((unsigned)mstp_port->FrameType));
|
||||
mstptext_frame_type((unsigned) mstp_port->FrameType));
|
||||
/* destined for me! */
|
||||
if ((mstp_port->DestinationAddress == mstp_port->This_Station)
|
||||
|| (mstp_port->DestinationAddress ==
|
||||
@@ -665,12 +666,12 @@ bool MSTP_Master_Node_FSM(
|
||||
break;
|
||||
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
|
||||
/* indicate successful reception to the higher layers */
|
||||
(void)MSTP_Put_Receive(mstp_port);
|
||||
(void) MSTP_Put_Receive(mstp_port);
|
||||
break;
|
||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||
/*mstp_port->ReplyPostponedTimer = 0; */
|
||||
/* indicate successful reception to the higher layers */
|
||||
(void)MSTP_Put_Receive(mstp_port);
|
||||
(void) MSTP_Put_Receive(mstp_port);
|
||||
/* broadcast DER just remains IDLE */
|
||||
if (mstp_port->DestinationAddress !=
|
||||
MSTP_BROADCAST_ADDRESS) {
|
||||
@@ -703,7 +704,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* more data frames. These may be BACnet Data frames or */
|
||||
/* proprietary frames. */
|
||||
/* FIXME: We could wait for up to Tusage_delay */
|
||||
length = (unsigned)MSTP_Get_Send(mstp_port, 0);
|
||||
length = (unsigned) MSTP_Get_Send(mstp_port, 0);
|
||||
if (length < 1) {
|
||||
/* NothingToSend */
|
||||
mstp_port->FrameCount = mstp_port->Nmax_info_frames;
|
||||
@@ -780,7 +781,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* ReceivedReply */
|
||||
/* or a proprietary type that indicates a reply */
|
||||
/* indicate successful reception to the higher layers */
|
||||
(void)MSTP_Put_Receive(mstp_port);
|
||||
(void) MSTP_Put_Receive(mstp_port);
|
||||
mstp_port->master_state =
|
||||
MSTP_MASTER_STATE_DONE_WITH_TOKEN;
|
||||
break;
|
||||
@@ -1038,7 +1039,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* BACnet Data Expecting Reply, a Test_Request, or */
|
||||
/* a proprietary frame that expects a reply is received. */
|
||||
/* FIXME: we could wait for up to Treply_delay */
|
||||
length = (unsigned)MSTP_Get_Reply(mstp_port, 0);
|
||||
length = (unsigned) MSTP_Get_Reply(mstp_port, 0);
|
||||
if (length > 0) {
|
||||
/* Reply */
|
||||
/* If a reply is available from the higher layers */
|
||||
|
||||
@@ -93,7 +93,8 @@ int ptransfer_encode_apdu(
|
||||
apdu[3] = SERVICE_CONFIRMED_PRIVATE_TRANSFER;
|
||||
apdu_len = 4;
|
||||
len =
|
||||
pt_encode_apdu(&apdu[apdu_len], (uint16_t)(MAX_APDU - apdu_len), private_data);
|
||||
pt_encode_apdu(&apdu[apdu_len], (uint16_t) (MAX_APDU - apdu_len),
|
||||
private_data);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
@@ -112,7 +113,8 @@ int uptransfer_encode_apdu(
|
||||
apdu[1] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
|
||||
apdu_len = 2;
|
||||
len =
|
||||
pt_encode_apdu(&apdu[apdu_len], (uint16_t)(MAX_APDU - apdu_len), private_data);
|
||||
pt_encode_apdu(&apdu[apdu_len], (uint16_t) (MAX_APDU - apdu_len),
|
||||
private_data);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "bacdef.h"
|
||||
#include "rd.h"
|
||||
|
||||
/** @file rd.c Encode/Decode Reinitialize Device APDUs */
|
||||
/** @file rd.c Encode/Decode Reinitialize Device APDUs */
|
||||
|
||||
/* encode service */
|
||||
int rd_encode_apdu(
|
||||
|
||||
@@ -72,7 +72,7 @@ int rr_encode_apdu(
|
||||
uint8_t invoke_id,
|
||||
BACNET_READ_RANGE_DATA * rrdata)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
@@ -180,14 +180,14 @@ int rr_decode_service_request(
|
||||
rrdata->array_index = BACNET_ARRAY_ALL; /* Assuming this is the most common outcome... */
|
||||
if (len < apdu_len) {
|
||||
TagLen =
|
||||
(unsigned)decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
(unsigned) decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value_type);
|
||||
if (tag_number == 2) {
|
||||
len += TagLen;
|
||||
len +=
|
||||
decode_unsigned(&apdu[len], len_value_type, &UnsignedTemp);
|
||||
rrdata->array_index = UnsignedTemp;
|
||||
rrdata->Overhead += RR_INDEX_OVERHEAD; /* Allow for this in the response */
|
||||
rrdata->Overhead += RR_INDEX_OVERHEAD; /* Allow for this in the response */
|
||||
}
|
||||
}
|
||||
/* And/or optional range selection- Tags 3, 6 and 7 */
|
||||
@@ -240,7 +240,7 @@ int rr_decode_service_request(
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value_type);
|
||||
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD; /* Allow for this in the response */
|
||||
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD; /* Allow for this in the response */
|
||||
break;
|
||||
|
||||
case 7: /* ReadRange by time stamp */
|
||||
@@ -265,7 +265,7 @@ int rr_decode_service_request(
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value_type);
|
||||
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD; /* Allow for this in the response */
|
||||
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD; /* Allow for this in the response */
|
||||
break;
|
||||
|
||||
default: /* If we don't recognise the tag then we do nothing here and try to return
|
||||
@@ -301,7 +301,7 @@ int rr_ack_encode_apdu(
|
||||
BACNET_READ_RANGE_DATA * rrdata)
|
||||
{
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */
|
||||
|
||||
+23
-25
@@ -47,7 +47,7 @@
|
||||
* ALGORITHM: none
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
unsigned Ringbuf_Count (
|
||||
unsigned Ringbuf_Count(
|
||||
RING_BUFFER const *b)
|
||||
{
|
||||
return (b ? (b->head - b->tail) : 0);
|
||||
@@ -59,7 +59,7 @@ unsigned Ringbuf_Count (
|
||||
* ALGORITHM: none
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
bool Ringbuf_Full (
|
||||
bool Ringbuf_Full(
|
||||
RING_BUFFER const *b)
|
||||
{
|
||||
return (b ? (Ringbuf_Count(b) == b->element_count) : true);
|
||||
@@ -87,7 +87,8 @@ uint8_t *Ringbuf_Get_Front(
|
||||
RING_BUFFER const *b)
|
||||
{
|
||||
if (b) {
|
||||
return (!Ringbuf_Empty(b) ? &(b->data[(b->tail % b->element_count) * b->element_size]) : NULL);
|
||||
return (!Ringbuf_Empty(b) ? &(b->data[(b->tail % b->element_count) *
|
||||
b->element_size]) : NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -101,7 +102,7 @@ uint8_t *Ringbuf_Get_Front(
|
||||
uint8_t *Ringbuf_Pop_Front(
|
||||
RING_BUFFER * b)
|
||||
{
|
||||
uint8_t *data = NULL; /* return value */
|
||||
uint8_t *data = NULL; /* return value */
|
||||
|
||||
if (!Ringbuf_Empty(b)) {
|
||||
data = &(b->data[(b->tail % b->element_count) * b->element_size]);
|
||||
@@ -119,16 +120,17 @@ uint8_t *Ringbuf_Pop_Front(
|
||||
*****************************************************************************/
|
||||
bool Ringbuf_Put(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
uint8_t *data_element)
|
||||
uint8_t * data_element)
|
||||
{ /* one element to add to the ring */
|
||||
bool status = false; /* return value */
|
||||
uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
unsigned i; /* loop counter */
|
||||
|
||||
if (b && data_element) {
|
||||
/* limit the amount of elements that we accept */
|
||||
if (!Ringbuf_Full(b)) {
|
||||
ring_data = b->data + ((b->head % b->element_count) * b->element_size);
|
||||
ring_data =
|
||||
b->data + ((b->head % b->element_count) * b->element_size);
|
||||
for (i = 0; i < b->element_size; i++) {
|
||||
ring_data[i] = data_element[i];
|
||||
}
|
||||
@@ -147,14 +149,15 @@ bool Ringbuf_Put(
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
uint8_t *Ringbuf_Alloc(
|
||||
RING_BUFFER *b)
|
||||
RING_BUFFER * b)
|
||||
{
|
||||
uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
|
||||
if (b) {
|
||||
/* limit the amount of elements that we accept */
|
||||
if (!Ringbuf_Full(b)) {
|
||||
ring_data = b->data + ((b->head % b->element_count) * b->element_size);
|
||||
ring_data =
|
||||
b->data + ((b->head % b->element_count) * b->element_size);
|
||||
b->head++;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +174,7 @@ uint8_t *Ringbuf_Alloc(
|
||||
*****************************************************************************/
|
||||
void Ringbuf_Init(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
uint8_t *data, /* data block or array of data */
|
||||
uint8_t * data, /* data block or array of data */
|
||||
unsigned element_size, /* size of one element in the data block */
|
||||
unsigned element_count)
|
||||
{ /* number of elements in the data block */
|
||||
@@ -195,8 +198,8 @@ void Ringbuf_Init(
|
||||
/* test the ring buffer */
|
||||
void testRingBuf(
|
||||
Test * pTest,
|
||||
uint8_t *data_store,
|
||||
uint8_t *data_element,
|
||||
uint8_t * data_store,
|
||||
uint8_t * data_element,
|
||||
unsigned element_size,
|
||||
unsigned element_count)
|
||||
{
|
||||
@@ -273,8 +276,7 @@ void testRingBuf(
|
||||
for (index = 0; index < element_count; index++) {
|
||||
for (count = 1; count < 4; count++) {
|
||||
dummy = index * count;
|
||||
for (data_index = 0; data_index < element_size;
|
||||
data_index++) {
|
||||
for (data_index = 0; data_index < element_size; data_index++) {
|
||||
data_element[data_index] = dummy;
|
||||
}
|
||||
status = Ringbuf_Put(&test_buffer, data_element);
|
||||
@@ -286,8 +288,7 @@ void testRingBuf(
|
||||
test_data = Ringbuf_Get_Front(&test_buffer);
|
||||
ct_test(pTest, test_data);
|
||||
if (test_data) {
|
||||
for (data_index = 0; data_index < element_size;
|
||||
data_index++) {
|
||||
for (data_index = 0; data_index < element_size; data_index++) {
|
||||
ct_test(pTest, test_data[data_index] == dummy);
|
||||
}
|
||||
}
|
||||
@@ -295,8 +296,7 @@ void testRingBuf(
|
||||
test_data = Ringbuf_Pop_Front(&test_buffer);
|
||||
ct_test(pTest, test_data);
|
||||
if (test_data) {
|
||||
for (data_index = 0; data_index < element_size;
|
||||
data_index++) {
|
||||
for (data_index = 0; data_index < element_size; data_index++) {
|
||||
ct_test(pTest, test_data[data_index] == dummy);
|
||||
}
|
||||
}
|
||||
@@ -314,9 +314,8 @@ void testRingBufSize16(
|
||||
uint8_t data_element[5];
|
||||
uint8_t data_store[sizeof(data_element) * 16];
|
||||
|
||||
testRingBuf(pTest,data_store,data_element,
|
||||
sizeof(data_element),
|
||||
sizeof(data_store)/sizeof(data_element));
|
||||
testRingBuf(pTest, data_store, data_element, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element));
|
||||
}
|
||||
|
||||
void testRingBufSize32(
|
||||
@@ -325,9 +324,8 @@ void testRingBufSize32(
|
||||
uint8_t data_element[16];
|
||||
uint8_t data_store[sizeof(data_element) * 32];
|
||||
|
||||
testRingBuf(pTest,data_store,data_element,
|
||||
sizeof(data_element),
|
||||
sizeof(data_store)/sizeof(data_element));
|
||||
testRingBuf(pTest, data_store, data_element, sizeof(data_element),
|
||||
sizeof(data_store) / sizeof(data_element));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -133,12 +133,13 @@ uint8_t tsm_transaction_idle_count(
|
||||
|
||||
/* sets the invokeID */
|
||||
|
||||
void tsm_invokeID_set(uint8_t invokeID)
|
||||
void tsm_invokeID_set(
|
||||
uint8_t invokeID)
|
||||
{
|
||||
if(invokeID == 0) {
|
||||
invokeID = 1;
|
||||
}
|
||||
Current_Invoke_ID=invokeID;
|
||||
if (invokeID == 0) {
|
||||
invokeID = 1;
|
||||
}
|
||||
Current_Invoke_ID = invokeID;
|
||||
}
|
||||
|
||||
/* gets the next free invokeID,
|
||||
|
||||
Reference in New Issue
Block a user