indented using indent.sh script to get uniform looking code for release
This commit is contained in:
@@ -149,7 +149,8 @@ static 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;
|
||||
@@ -168,7 +169,8 @@ static 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))) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
|
||||
@@ -66,7 +66,7 @@ bool bacnet_address_same(
|
||||
uint8_t i = 0; /* loop counter */
|
||||
uint8_t max_len = 0; /* used for dynamic max */
|
||||
|
||||
if (dest == src) /* same ? */
|
||||
if (dest == src) /* same ? */
|
||||
return true;
|
||||
|
||||
if (dest->net != src->net)
|
||||
@@ -82,8 +82,7 @@ bool bacnet_address_same(
|
||||
if (dest->adr[i] != src->adr[i])
|
||||
return false;
|
||||
}
|
||||
if (dest->net == 0)
|
||||
{
|
||||
if (dest->net == 0) {
|
||||
if (dest->mac_len != src->mac_len)
|
||||
return false;
|
||||
max_len = dest->mac_len;
|
||||
|
||||
+14
-14
@@ -1103,8 +1103,8 @@ int bacapp_snprintf_value(
|
||||
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
ret_val =
|
||||
snprintf(str, str_len, "%s",
|
||||
bactext_object_type_name(value->
|
||||
type.Enumerated));
|
||||
bactext_object_type_name(value->type.
|
||||
Enumerated));
|
||||
} else if (value->type.Enumerated < 128) {
|
||||
ret_val =
|
||||
snprintf(str, str_len, "reserved %lu",
|
||||
@@ -1124,8 +1124,8 @@ int bacapp_snprintf_value(
|
||||
if (value->type.Enumerated < 256) {
|
||||
ret_val =
|
||||
snprintf(str, str_len, "%s",
|
||||
bactext_engineering_unit_name(value->type.
|
||||
Enumerated));
|
||||
bactext_engineering_unit_name(value->
|
||||
type.Enumerated));
|
||||
} else {
|
||||
ret_val =
|
||||
snprintf(str, str_len, "proprietary %lu",
|
||||
@@ -1135,16 +1135,16 @@ int bacapp_snprintf_value(
|
||||
case PROP_POLARITY:
|
||||
ret_val =
|
||||
snprintf(str, str_len, "%s",
|
||||
bactext_binary_polarity_name(value->type.
|
||||
Enumerated));
|
||||
bactext_binary_polarity_name(value->
|
||||
type.Enumerated));
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
case PROP_RELINQUISH_DEFAULT:
|
||||
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
|
||||
ret_val =
|
||||
snprintf(str, str_len, "%s",
|
||||
bactext_binary_present_value_name(value->
|
||||
type.Enumerated));
|
||||
bactext_binary_present_value_name(value->type.
|
||||
Enumerated));
|
||||
} else {
|
||||
ret_val =
|
||||
snprintf(str, str_len, "%lu",
|
||||
@@ -1159,8 +1159,8 @@ int bacapp_snprintf_value(
|
||||
case PROP_SYSTEM_STATUS:
|
||||
ret_val =
|
||||
snprintf(str, str_len, "%s",
|
||||
bactext_device_status_name(value->type.
|
||||
Enumerated));
|
||||
bactext_device_status_name(value->
|
||||
type.Enumerated));
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
ret_val =
|
||||
@@ -1261,8 +1261,8 @@ int bacapp_snprintf_value(
|
||||
break;
|
||||
if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
if (!append_str(&p_str, &rem_str_len,
|
||||
bactext_object_type_name(value->type.Object_Id.
|
||||
type)
|
||||
bactext_object_type_name(value->type.
|
||||
Object_Id.type)
|
||||
)
|
||||
)
|
||||
break;
|
||||
@@ -1645,8 +1645,8 @@ void testBACnetApplicationData_Safe(
|
||||
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:
|
||||
|
||||
@@ -994,7 +994,7 @@ uint32_t encode_bacnet_character_string_safe(
|
||||
char *pString,
|
||||
uint32_t length)
|
||||
{
|
||||
uint32_t apdu_len = 1 /*encoding*/;
|
||||
uint32_t apdu_len = 1 /*encoding */ ;
|
||||
uint32_t i;
|
||||
|
||||
apdu_len += length;
|
||||
@@ -1014,9 +1014,7 @@ int encode_bacnet_character_string(
|
||||
uint8_t * apdu,
|
||||
BACNET_CHARACTER_STRING * char_string)
|
||||
{
|
||||
return (int)encode_bacnet_character_string_safe(
|
||||
apdu,
|
||||
MAX_APDU,
|
||||
return (int) encode_bacnet_character_string_safe(apdu, MAX_APDU,
|
||||
characterstring_encoding(char_string),
|
||||
characterstring_value(char_string),
|
||||
characterstring_length(char_string));
|
||||
|
||||
@@ -743,7 +743,7 @@ size_t octetstring_copy_value(
|
||||
if (src && dest) {
|
||||
if (length <= src->length) {
|
||||
for (i = 0; i < src->length; i++) {
|
||||
dest[i]= src->value[i];
|
||||
dest[i] = src->value[i];
|
||||
}
|
||||
bytes_copied = src->length;
|
||||
}
|
||||
|
||||
@@ -915,7 +915,7 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
{PROP_LAST_KEY_SERVER, "last-key-server"}
|
||||
,
|
||||
{PROP_NETWORK_ACCESS_SECURITY_POLICIES,
|
||||
"network-access-security-policies"}
|
||||
"network-access-security-policies"}
|
||||
,
|
||||
{PROP_PACKET_REORDER_TIME, "packet-reorder-time"}
|
||||
,
|
||||
@@ -1013,7 +1013,8 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
,
|
||||
{PROP_LIGHTING_COMMAND, "lighting-command"}
|
||||
,
|
||||
{PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, "lighting-command-default-priority"}
|
||||
{PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY,
|
||||
"lighting-command-default-priority"}
|
||||
,
|
||||
{PROP_MAX_ACTUAL_VALUE, "max-actual-value"}
|
||||
,
|
||||
|
||||
@@ -166,9 +166,8 @@ int bip_send_pdu(
|
||||
|
||||
mtu[0] = BVLL_TYPE_BACNET_IP;
|
||||
bip_dest.sin_family = AF_INET;
|
||||
if ((dest->net == BACNET_BROADCAST_NETWORK) ||
|
||||
((dest->net > 0) && (dest->len == 0)) ||
|
||||
(dest->mac_len == 0)) {
|
||||
if ((dest->net == BACNET_BROADCAST_NETWORK) || ((dest->net > 0) &&
|
||||
(dest->len == 0)) || (dest->mac_len == 0)) {
|
||||
/* broadcast */
|
||||
address.s_addr = BIP_Broadcast_Address.s_addr;
|
||||
port = BIP_Port;
|
||||
|
||||
@@ -700,8 +700,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 =
|
||||
((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
|
||||
dest_address.s_addr);
|
||||
((~BBMD_Table[i].broadcast_mask.
|
||||
s_addr) | BBMD_Table[i].dest_address.s_addr);
|
||||
bip_dest.sin_port = BBMD_Table[i].dest_port;
|
||||
/* don't send to my broadcast address and same port */
|
||||
if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr())
|
||||
@@ -1179,9 +1179,8 @@ int bvlc_send_pdu(
|
||||
/* mac_len = 0 is a broadcast address */
|
||||
/* net = 0 indicates local, net = 65535 indicates global */
|
||||
/* net > 0 and net < 65535 are network specific broadcast if len = 0 */
|
||||
if ((dest->net == BACNET_BROADCAST_NETWORK) ||
|
||||
((dest->net > 0) && (dest->len == 0)) ||
|
||||
(dest->mac_len == 0)) {
|
||||
if ((dest->net == BACNET_BROADCAST_NETWORK) || ((dest->net > 0) &&
|
||||
(dest->len == 0)) || (dest->mac_len == 0)) {
|
||||
/* if we are a foreign device */
|
||||
if (Remote_BBMD.sin_port) {
|
||||
mtu[1] = BVLC_DISTRIBUTE_BROADCAST_TO_NETWORK;
|
||||
|
||||
@@ -87,7 +87,7 @@ static bool date_is_valid(
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
{
|
||||
bool status = false; /* true if value date */
|
||||
bool status = false; /* true if value date */
|
||||
uint8_t monthdays; /* days in a month */
|
||||
|
||||
|
||||
@@ -193,16 +193,17 @@ static bool time_is_valid(
|
||||
* @return true if the date and time are valid
|
||||
*/
|
||||
bool datetime_is_valid(
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime)
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
bool status = false; /* return value */
|
||||
|
||||
/* get the number of days in the month, and check for valid month too */
|
||||
if (bdate) {
|
||||
status = date_is_valid(bdate->year, bdate->month, bdate->day);
|
||||
if (status && btime) {
|
||||
status = time_is_valid(btime->hour, btime->min, btime->sec,
|
||||
status =
|
||||
time_is_valid(btime->hour, btime->min, btime->sec,
|
||||
btime->hundredths);
|
||||
} else {
|
||||
status = false;
|
||||
|
||||
+143
-138
@@ -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);
|
||||
@@ -595,16 +595,18 @@ 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;
|
||||
@@ -615,16 +617,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;
|
||||
@@ -642,8 +644,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -654,8 +657,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -673,8 +677,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;
|
||||
@@ -683,31 +687,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;
|
||||
@@ -716,31 +720,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;
|
||||
@@ -768,8 +772,9 @@ 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;
|
||||
@@ -779,8 +784,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;
|
||||
@@ -789,24 +794,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;
|
||||
@@ -815,24 +820,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;
|
||||
@@ -1078,16 +1083,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);
|
||||
|
||||
@@ -1111,8 +1116,8 @@ void testEventEventState(
|
||||
testBaseEventState(pTest);
|
||||
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString,
|
||||
bitstring_same(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString,
|
||||
&data2.notificationParams.changeOfBitstring.referencedBitString));
|
||||
|
||||
ct_test(pTest,
|
||||
@@ -1175,16 +1180,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);
|
||||
@@ -1205,8 +1210,8 @@ void testEventEventState(
|
||||
data2.notificationParams.changeOfValue.tag);
|
||||
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits,
|
||||
bitstring_same(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits,
|
||||
&data2.notificationParams.changeOfValue.newValue.changedBits));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1429,12 +1434,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;
|
||||
@@ -1459,34 +1464,34 @@ void testEventEventState(
|
||||
|
||||
|
||||
ct_test(pTest,
|
||||
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);
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
propertyIdentifier ==
|
||||
deviceIndentifier.instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
propertyIdentifier);
|
||||
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);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
|
||||
|
||||
+26
-13
@@ -101,7 +101,8 @@
|
||||
*
|
||||
* @return Number of bytes in the FIFO
|
||||
*/
|
||||
unsigned FIFO_Count(FIFO_BUFFER const *b)
|
||||
unsigned FIFO_Count(
|
||||
FIFO_BUFFER const *b)
|
||||
{
|
||||
unsigned head, tail; /* used to avoid volatile decision */
|
||||
|
||||
@@ -121,7 +122,8 @@ unsigned FIFO_Count(FIFO_BUFFER const *b)
|
||||
*
|
||||
* @return true if the FIFO is full, false if it is not.
|
||||
*/
|
||||
bool FIFO_Full(FIFO_BUFFER const *b)
|
||||
bool FIFO_Full(
|
||||
FIFO_BUFFER const *b)
|
||||
{
|
||||
return (b ? (FIFO_Count(b) == b->buffer_len) : true);
|
||||
}
|
||||
@@ -134,7 +136,8 @@ bool FIFO_Full(FIFO_BUFFER const *b)
|
||||
*
|
||||
* @return true if the number of bytes sought is available
|
||||
*/
|
||||
bool FIFO_Available(FIFO_BUFFER const *b,
|
||||
bool FIFO_Available(
|
||||
FIFO_BUFFER const *b,
|
||||
unsigned count)
|
||||
{
|
||||
return (b ? (count <= (b->buffer_len - FIFO_Count(b))) : false);
|
||||
@@ -146,7 +149,8 @@ bool FIFO_Available(FIFO_BUFFER const *b,
|
||||
* @param b - pointer to FIFO_BUFFER structure
|
||||
* @return true if the FIFO is empty, false if it is not.
|
||||
*/
|
||||
bool FIFO_Empty(FIFO_BUFFER const *b)
|
||||
bool FIFO_Empty(
|
||||
FIFO_BUFFER const *b)
|
||||
{
|
||||
return (b ? (FIFO_Count(b) == 0) : true);
|
||||
}
|
||||
@@ -161,7 +165,8 @@ bool FIFO_Empty(FIFO_BUFFER const *b)
|
||||
*
|
||||
* @return byte of data, or zero if nothing in the list
|
||||
*/
|
||||
uint8_t FIFO_Peek(FIFO_BUFFER const *b)
|
||||
uint8_t FIFO_Peek(
|
||||
FIFO_BUFFER const *b)
|
||||
{
|
||||
unsigned index;
|
||||
|
||||
@@ -183,7 +188,8 @@ uint8_t FIFO_Peek(FIFO_BUFFER const *b)
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
uint8_t FIFO_Get(FIFO_BUFFER * b)
|
||||
uint8_t FIFO_Get(
|
||||
FIFO_BUFFER * b)
|
||||
{
|
||||
uint8_t data_byte = 0;
|
||||
unsigned index;
|
||||
@@ -207,7 +213,8 @@ uint8_t FIFO_Get(FIFO_BUFFER * b)
|
||||
*
|
||||
* @return the number of bytes actually pulled from the FIFO
|
||||
*/
|
||||
unsigned FIFO_Pull(FIFO_BUFFER * b,
|
||||
unsigned FIFO_Pull(
|
||||
FIFO_BUFFER * b,
|
||||
uint8_t * buffer,
|
||||
unsigned length)
|
||||
{
|
||||
@@ -246,7 +253,8 @@ unsigned FIFO_Pull(FIFO_BUFFER * b,
|
||||
*
|
||||
* @return true on successful add, false if not added
|
||||
*/
|
||||
bool FIFO_Put(FIFO_BUFFER * b,
|
||||
bool FIFO_Put(
|
||||
FIFO_BUFFER * b,
|
||||
uint8_t data_byte)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
@@ -274,7 +282,8 @@ bool FIFO_Put(FIFO_BUFFER * b,
|
||||
*
|
||||
* @return true if space available and added, false if not added
|
||||
*/
|
||||
bool FIFO_Add(FIFO_BUFFER * b,
|
||||
bool FIFO_Add(
|
||||
FIFO_BUFFER * b,
|
||||
uint8_t * buffer,
|
||||
unsigned count)
|
||||
{
|
||||
@@ -303,7 +312,8 @@ bool FIFO_Add(FIFO_BUFFER * b,
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void FIFO_Flush(FIFO_BUFFER * b)
|
||||
void FIFO_Flush(
|
||||
FIFO_BUFFER * b)
|
||||
{
|
||||
unsigned head; /* used to avoid volatile decision */
|
||||
|
||||
@@ -322,7 +332,8 @@ void FIFO_Flush(FIFO_BUFFER * b)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void FIFO_Init(FIFO_BUFFER * b,
|
||||
void FIFO_Init(
|
||||
FIFO_BUFFER * b,
|
||||
volatile uint8_t * buffer,
|
||||
unsigned buffer_len)
|
||||
{
|
||||
@@ -347,7 +358,8 @@ void FIFO_Init(FIFO_BUFFER * b,
|
||||
*
|
||||
* @param pTest - test tracking pointer
|
||||
*/
|
||||
void testFIFOBuffer(Test * pTest)
|
||||
void testFIFOBuffer(
|
||||
Test * pTest)
|
||||
{
|
||||
/* FIFO data structure */
|
||||
FIFO_BUFFER test_buffer = { 0 };
|
||||
@@ -466,7 +478,8 @@ void testFIFOBuffer(Test * pTest)
|
||||
*
|
||||
* @return returns 0 on success, and non-zero on fail.
|
||||
*/
|
||||
int main(void)
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
|
||||
@@ -126,8 +126,7 @@ int get_alarm_summary_ack_decode_apdu_data(
|
||||
/* tag 0 - Object Identifier */
|
||||
apdu_len +=
|
||||
bacapp_decode_application_data(&apdu[apdu_len],
|
||||
max_apdu - apdu_len,
|
||||
&value);
|
||||
max_apdu - apdu_len, &value);
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
get_alarm_data->objectIdentifier = value.type.Object_Id;
|
||||
} else {
|
||||
@@ -136,18 +135,17 @@ int get_alarm_summary_ack_decode_apdu_data(
|
||||
/* tag 1 - Alarm State */
|
||||
apdu_len +=
|
||||
bacapp_decode_application_data(&apdu[apdu_len],
|
||||
max_apdu - apdu_len,
|
||||
&value);
|
||||
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED){
|
||||
get_alarm_data->alarmState = (BACNET_EVENT_STATE)value.type.Enumerated;
|
||||
max_apdu - apdu_len, &value);
|
||||
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
|
||||
get_alarm_data->alarmState =
|
||||
(BACNET_EVENT_STATE) value.type.Enumerated;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* tag 2 - Acknowledged Transitions */
|
||||
apdu_len +=
|
||||
bacapp_decode_application_data(&apdu[apdu_len],
|
||||
max_apdu - apdu_len,
|
||||
&value);
|
||||
max_apdu - apdu_len, &value);
|
||||
if (value.tag == BACNET_APPLICATION_TAG_BIT_STRING) {
|
||||
get_alarm_data->acknowledgedTransitions = value.type.Bit_String;
|
||||
} else {
|
||||
|
||||
+33
-27
@@ -256,14 +256,14 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstptext_receive_state(mstp_port->receive_state),
|
||||
mstp_port->DataRegister, mstp_port->HeaderCRC, mstp_port->Index,
|
||||
mstp_port->EventCount, mstp_port->DataLength,
|
||||
mstp_port->SilenceTimer((void*)mstp_port));
|
||||
mstp_port->SilenceTimer((void *) mstp_port));
|
||||
switch (mstp_port->receive_state) {
|
||||
/* In the IDLE state, the node waits for the beginning of a frame. */
|
||||
case MSTP_RECEIVE_STATE_IDLE:
|
||||
/* EatAnError */
|
||||
if (mstp_port->ReceiveError == true) {
|
||||
mstp_port->ReceiveError = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount);
|
||||
/* wait for the start of a frame. */
|
||||
} else if (mstp_port->DataAvailable == true) {
|
||||
@@ -279,14 +279,14 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* wait for the start of a frame. */
|
||||
}
|
||||
mstp_port->DataAvailable = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount);
|
||||
}
|
||||
break;
|
||||
/* In the PREAMBLE state, the node waits for the second octet of the preamble. */
|
||||
case MSTP_RECEIVE_STATE_PREAMBLE:
|
||||
/* Timeout */
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) > Tframe_abort) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) > Tframe_abort) {
|
||||
/* a correct preamble has not been received */
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
@@ -294,7 +294,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* Error */
|
||||
else if (mstp_port->ReceiveError == true) {
|
||||
mstp_port->ReceiveError = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount);
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
@@ -317,25 +317,26 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
mstp_port->DataAvailable = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount);
|
||||
}
|
||||
break;
|
||||
/* In the HEADER state, the node waits for the fixed message header. */
|
||||
case MSTP_RECEIVE_STATE_HEADER:
|
||||
/* Timeout */
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) > Tframe_abort) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) > Tframe_abort) {
|
||||
/* indicate that an error has occurred during the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
/* 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((void*)mstp_port), Tframe_abort);
|
||||
(unsigned) mstp_port->SilenceTimer((void *) mstp_port),
|
||||
Tframe_abort);
|
||||
}
|
||||
/* Error */
|
||||
else if (mstp_port->ReceiveError == true) {
|
||||
mstp_port->ReceiveError = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount);
|
||||
/* indicate that an error has occurred during the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
@@ -460,7 +461,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount);
|
||||
mstp_port->DataAvailable = false;
|
||||
}
|
||||
@@ -469,19 +470,20 @@ void MSTP_Receive_Frame_FSM(
|
||||
case MSTP_RECEIVE_STATE_DATA:
|
||||
case MSTP_RECEIVE_STATE_SKIP_DATA:
|
||||
/* Timeout */
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) > Tframe_abort) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) > Tframe_abort) {
|
||||
/* indicate that an error has occurred during the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error
|
||||
("MSTP: Rx Data: SilenceTimer %ums > %dms\n",
|
||||
(unsigned) mstp_port->SilenceTimer((void*)mstp_port), Tframe_abort);
|
||||
(unsigned) mstp_port->SilenceTimer((void *) mstp_port),
|
||||
Tframe_abort);
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
/* Error */
|
||||
else if (mstp_port->ReceiveError == true) {
|
||||
mstp_port->ReceiveError = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
/* indicate that an error has occurred during the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error("MSTP: Rx Data: ReceiveError\n");
|
||||
@@ -538,7 +540,7 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
mstp_port->DataAvailable = false;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -590,7 +592,7 @@ bool MSTP_Master_Node_FSM(
|
||||
case MSTP_MASTER_STATE_IDLE:
|
||||
/* In the IDLE state, the node waits for a frame. */
|
||||
/* LostToken */
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) >= Tno_token) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) >= Tno_token) {
|
||||
/* assume that the token has been lost */
|
||||
mstp_port->EventCount = 0; /* Addendum 135-2004d-8 */
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_NO_TOKEN;
|
||||
@@ -609,7 +611,7 @@ bool MSTP_Master_Node_FSM(
|
||||
"Src=%02X Dest=%02X DataLen=%u " "FC=%u ST=%u Type=%s\n",
|
||||
mstp_port->SourceAddress, mstp_port->DestinationAddress,
|
||||
mstp_port->DataLength, mstp_port->FrameCount,
|
||||
mstp_port->SilenceTimer((void*)mstp_port),
|
||||
mstp_port->SilenceTimer((void *) mstp_port),
|
||||
mstptext_frame_type((unsigned) mstp_port->FrameType));
|
||||
/* destined for me! */
|
||||
if ((mstp_port->DestinationAddress == mstp_port->This_Station)
|
||||
@@ -720,7 +722,7 @@ bool MSTP_Master_Node_FSM(
|
||||
case MSTP_MASTER_STATE_WAIT_FOR_REPLY:
|
||||
/* In the WAIT_FOR_REPLY state, the node waits for */
|
||||
/* a reply from another node. */
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) >= Treply_timeout) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) >= Treply_timeout) {
|
||||
/* ReplyTimeout */
|
||||
/* assume that the request has failed */
|
||||
mstp_port->FrameCount = mstp_port->Nmax_info_frames;
|
||||
@@ -867,7 +869,7 @@ bool MSTP_Master_Node_FSM(
|
||||
case MSTP_MASTER_STATE_PASS_TOKEN:
|
||||
/* The PASS_TOKEN state listens for a successor to begin using */
|
||||
/* the token that this node has just attempted to pass. */
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) <= Tusage_timeout) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) <= Tusage_timeout) {
|
||||
if (mstp_port->EventCount > Nmin_octets) {
|
||||
/* SawTokenUser */
|
||||
/* Assume that a frame has been sent by the new token user. */
|
||||
@@ -912,7 +914,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* for that period of time. The timeout is continued to determine */
|
||||
/* whether or not this node may create a token. */
|
||||
my_timeout = Tno_token + (Tslot * mstp_port->This_Station);
|
||||
if (mstp_port->SilenceTimer((void*)mstp_port) < my_timeout) {
|
||||
if (mstp_port->SilenceTimer((void *) mstp_port) < my_timeout) {
|
||||
if (mstp_port->EventCount > Nmin_octets) {
|
||||
/* SawFrame */
|
||||
/* Some other node exists at a lower address. */
|
||||
@@ -925,8 +927,9 @@ bool MSTP_Master_Node_FSM(
|
||||
Tno_token + (Tslot * (mstp_port->This_Station + 1));
|
||||
mm_timeout =
|
||||
Tno_token + (Tslot * (mstp_port->Nmax_master + 1));
|
||||
if ((mstp_port->SilenceTimer((void*)mstp_port) < ns_timeout) ||
|
||||
(mstp_port->SilenceTimer((void*)mstp_port) > mm_timeout)) {
|
||||
if ((mstp_port->SilenceTimer((void *) mstp_port) < ns_timeout)
|
||||
|| (mstp_port->SilenceTimer((void *) mstp_port) >
|
||||
mm_timeout)) {
|
||||
/* GenerateToken */
|
||||
/* Assume that this node is the lowest numerical address */
|
||||
/* on the network and is empowered to create a token. */
|
||||
@@ -990,7 +993,8 @@ bool MSTP_Master_Node_FSM(
|
||||
transition_now = true;
|
||||
}
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
} else if ((mstp_port->SilenceTimer((void*)mstp_port) > Tusage_timeout) ||
|
||||
} else if ((mstp_port->SilenceTimer((void *) mstp_port) >
|
||||
Tusage_timeout) ||
|
||||
(mstp_port->ReceivedInvalidFrame == true)) {
|
||||
if (mstp_port->SoleMaster == true) {
|
||||
/* SoleMaster */
|
||||
@@ -1059,7 +1063,8 @@ bool MSTP_Master_Node_FSM(
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
|
||||
/* clear our flag we were holding for comparison */
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
} else if (mstp_port->SilenceTimer((void*)mstp_port) > Treply_delay) {
|
||||
} else if (mstp_port->SilenceTimer((void *) mstp_port) >
|
||||
Treply_delay) {
|
||||
/* DeferredReply */
|
||||
/* If no reply will be available from the higher layers */
|
||||
/* within Treply_delay after the reception of the */
|
||||
@@ -1088,7 +1093,7 @@ bool MSTP_Master_Node_FSM(
|
||||
mstp_port->This_Station, next_this_station,
|
||||
mstp_port->Next_Station, next_next_station,
|
||||
mstp_port->Poll_Station, next_poll_station, mstp_port->EventCount,
|
||||
mstp_port->TokenCount, mstp_port->SilenceTimer((void*)mstp_port),
|
||||
mstp_port->TokenCount, mstp_port->SilenceTimer((void *) mstp_port),
|
||||
mstptext_master_state(mstp_port->master_state));
|
||||
}
|
||||
|
||||
@@ -1126,7 +1131,8 @@ void MSTP_Slave_Node_FSM(
|
||||
(uint16_t) length);
|
||||
/* clear our flag we were holding for comparison */
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
} else if (mstp_port->SilenceTimer((void*)mstp_port) > Treply_delay) {
|
||||
} else if (mstp_port->SilenceTimer((void *) mstp_port) >
|
||||
Treply_delay) {
|
||||
/* If no reply will be available from the higher layers
|
||||
within Treply_delay after the reception of the final octet
|
||||
of the requesting frame (the mechanism used to determine
|
||||
@@ -1198,7 +1204,7 @@ void MSTP_Init(
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
mstp_port->ReceivedValidFrameNotForUs = false;
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->SilenceTimerReset((void*)mstp_port);
|
||||
mstp_port->SilenceTimerReset((void *) mstp_port);
|
||||
mstp_port->SoleMaster = false;
|
||||
mstp_port->SourceAddress = 0;
|
||||
mstp_port->TokenCount = 0;
|
||||
@@ -1263,7 +1269,7 @@ void RS485_Check_UART_Data(
|
||||
mstp_port->DataRegister = *data;
|
||||
mstp_port->DataAvailable = true;
|
||||
}
|
||||
(void)Ringbuf_Pop(&Test_Buffer, NULL);
|
||||
(void) Ringbuf_Pop(&Test_Buffer, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -112,10 +112,10 @@ volatile uint8_t *Ringbuf_Peek(
|
||||
*****************************************************************************/
|
||||
bool Ringbuf_Pop(
|
||||
RING_BUFFER * b,
|
||||
uint8_t *data_element)
|
||||
uint8_t * data_element)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
bool status = false; /* return value */
|
||||
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
unsigned i; /* loop counter */
|
||||
|
||||
if (!Ringbuf_Empty(b)) {
|
||||
@@ -141,7 +141,7 @@ bool Ringbuf_Pop(
|
||||
*****************************************************************************/
|
||||
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 */
|
||||
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
@@ -173,11 +173,11 @@ bool Ringbuf_Put(
|
||||
*****************************************************************************/
|
||||
bool Ringbuf_Put_Front(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
uint8_t *data_element)
|
||||
uint8_t * data_element)
|
||||
{ /* one element to add to the front of the ring */
|
||||
bool status = false; /* return value */
|
||||
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
unsigned i = 0; /* loop counter */
|
||||
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
|
||||
unsigned i = 0; /* loop counter */
|
||||
|
||||
if (b && data_element) {
|
||||
/* limit the amount of elements that we accept */
|
||||
@@ -285,7 +285,7 @@ static void testRingAroundBuffer(
|
||||
ct_test(pTest, test_data[data_index] == dummy);
|
||||
}
|
||||
}
|
||||
(void)Ringbuf_Pop(test_buffer, NULL);
|
||||
(void) Ringbuf_Pop(test_buffer, NULL);
|
||||
}
|
||||
}
|
||||
ct_test(pTest, Ringbuf_Empty(test_buffer));
|
||||
@@ -320,7 +320,7 @@ static void testRingBuf(
|
||||
ct_test(pTest, test_data[data_index] == data_element[data_index]);
|
||||
}
|
||||
ct_test(pTest, !Ringbuf_Empty(&test_buffer));
|
||||
(void)Ringbuf_Pop(&test_buffer, NULL);
|
||||
(void) Ringbuf_Pop(&test_buffer, NULL);
|
||||
ct_test(pTest, Ringbuf_Empty(&test_buffer));
|
||||
|
||||
/* fill to max */
|
||||
@@ -351,7 +351,7 @@ static void testRingBuf(
|
||||
ct_test(pTest, test_data[data_index] == index);
|
||||
}
|
||||
}
|
||||
(void)Ringbuf_Pop(&test_buffer, NULL);
|
||||
(void) Ringbuf_Pop(&test_buffer, NULL);
|
||||
}
|
||||
ct_test(pTest, Ringbuf_Empty(&test_buffer));
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ int rp_encode_apdu(
|
||||
/* check bounds so that we could create malformed
|
||||
messages for testing */
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
|
||||
rpdata->object_instance);
|
||||
encode_context_object_id(&apdu[apdu_len], 0,
|
||||
rpdata->object_type, rpdata->object_instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
if (rpdata->object_property <= 4194303) {
|
||||
|
||||
+31
-31
@@ -140,7 +140,7 @@ int timesync_decode_service_request(
|
||||
int timesync_encode_timesync_recipients(
|
||||
uint8_t * apdu,
|
||||
unsigned max_apdu,
|
||||
BACNET_RECIPIENT_LIST *recipient)
|
||||
BACNET_RECIPIENT_LIST * recipient)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -150,9 +150,10 @@ int timesync_encode_timesync_recipients(
|
||||
pRecipient = recipient;
|
||||
while (pRecipient != NULL) {
|
||||
if (pRecipient->tag == 0) {
|
||||
if (max_apdu >= (1+4)) {
|
||||
if (max_apdu >= (1 + 4)) {
|
||||
/* CHOICE - device [0] BACnetObjectIdentifier */
|
||||
len = encode_context_object_id(&apdu[apdu_len], 0,
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 0,
|
||||
pRecipient->type.device.type,
|
||||
pRecipient->type.device.instance);
|
||||
apdu_len += len;
|
||||
@@ -181,14 +182,15 @@ int timesync_encode_timesync_recipients(
|
||||
octetstring_init(&octet_string, NULL, 0);
|
||||
} else if (pRecipient->type.address.net) {
|
||||
octetstring_init(&octet_string,
|
||||
&pRecipient->type.address.adr[0],
|
||||
pRecipient->type.address.len);
|
||||
&pRecipient->type.address.adr[0],
|
||||
pRecipient->type.address.len);
|
||||
} else {
|
||||
octetstring_init(&octet_string,
|
||||
&pRecipient->type.address.mac[0],
|
||||
pRecipient->type.address.mac_len);
|
||||
&pRecipient->type.address.mac[0],
|
||||
pRecipient->type.address.mac_len);
|
||||
}
|
||||
len = encode_application_octet_string(&apdu[apdu_len],
|
||||
len =
|
||||
encode_application_octet_string(&apdu[apdu_len],
|
||||
&octet_string);
|
||||
apdu_len += len;
|
||||
/* CHOICE - address [1] BACnetAddress - closing */
|
||||
@@ -231,7 +233,7 @@ int timesync_encode_timesync_recipients(
|
||||
int timesync_decode_timesync_recipients(
|
||||
uint8_t * apdu,
|
||||
unsigned max_apdu,
|
||||
BACNET_RECIPIENT_LIST *recipient)
|
||||
BACNET_RECIPIENT_LIST * recipient)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -247,7 +249,8 @@ int timesync_decode_timesync_recipients(
|
||||
/* device [0] BACnetObjectIdentifier */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
pRecipient->tag = 0;
|
||||
len = decode_context_object_id(&apdu[apdu_len], 0,
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&pRecipient->type.device.type,
|
||||
&pRecipient->type.device.instance);
|
||||
if (len < 0) {
|
||||
@@ -265,7 +268,9 @@ int timesync_decode_timesync_recipients(
|
||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
return BACNET_STATUS_ABORT;
|
||||
}
|
||||
len = decode_unsigned(&apdu[apdu_len], len_value_type, &unsigned_value);
|
||||
len =
|
||||
decode_unsigned(&apdu[apdu_len], len_value_type,
|
||||
&unsigned_value);
|
||||
pRecipient->type.address.net = unsigned_value;
|
||||
apdu_len += len;
|
||||
/* mac-address OCTET STRING */
|
||||
@@ -276,23 +281,18 @@ int timesync_decode_timesync_recipients(
|
||||
if (tag_number != BACNET_APPLICATION_TAG_OCTET_STRING) {
|
||||
return BACNET_STATUS_ABORT;
|
||||
}
|
||||
len = decode_octet_string(&apdu[0], len_value_type,
|
||||
&octet_string);
|
||||
len = decode_octet_string(&apdu[0], len_value_type, &octet_string);
|
||||
apdu_len += len;
|
||||
if (octetstring_length(&octet_string) == 0) {
|
||||
/* -- A string of length 0 indicates a broadcast */
|
||||
} else if (pRecipient->type.address.net) {
|
||||
pRecipient->type.address.len =
|
||||
octetstring_copy_value(
|
||||
&pRecipient->type.address.adr[0],
|
||||
sizeof(pRecipient->type.address.adr),
|
||||
&octet_string);
|
||||
octetstring_copy_value(&pRecipient->type.address.adr[0],
|
||||
sizeof(pRecipient->type.address.adr), &octet_string);
|
||||
} else {
|
||||
pRecipient->type.address.mac_len =
|
||||
octetstring_copy_value(
|
||||
&pRecipient->type.address.mac[0],
|
||||
sizeof(pRecipient->type.address.mac),
|
||||
&octet_string);
|
||||
octetstring_copy_value(&pRecipient->type.address.mac[0],
|
||||
sizeof(pRecipient->type.address.mac), &octet_string);
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ABORT;
|
||||
@@ -311,8 +311,8 @@ int timesync_decode_timesync_recipients(
|
||||
|
||||
void testTimeSyncRecipientData(
|
||||
Test * pTest,
|
||||
BACNET_RECIPIENT_LIST *recipient1,
|
||||
BACNET_RECIPIENT_LIST *recipient2)
|
||||
BACNET_RECIPIENT_LIST * recipient1,
|
||||
BACNET_RECIPIENT_LIST * recipient2)
|
||||
{
|
||||
unsigned i = 0;
|
||||
|
||||
@@ -320,15 +320,13 @@ void testTimeSyncRecipientData(
|
||||
ct_test(pTest, recipient1->tag == recipient2->tag);
|
||||
if (recipient1->tag == 0) {
|
||||
ct_test(pTest,
|
||||
recipient1->type.device.type ==
|
||||
recipient2->type.device.type);
|
||||
recipient1->type.device.type == recipient2->type.device.type);
|
||||
ct_test(pTest,
|
||||
recipient1->type.device.instance ==
|
||||
recipient2->type.device.instance);
|
||||
} else if (recipient1->tag == 1) {
|
||||
ct_test(pTest,
|
||||
recipient1->type.address.net ==
|
||||
recipient2->type.address.net);
|
||||
recipient1->type.address.net == recipient2->type.address.net);
|
||||
if (recipient1->type.address.net == BACNET_BROADCAST_NETWORK) {
|
||||
ct_test(pTest,
|
||||
recipient1->type.address.mac_len ==
|
||||
@@ -400,12 +398,14 @@ void testTimeSyncRecipient(
|
||||
recipient[2].type.address.mac[5] = 0xC1;
|
||||
recipient[2].type.address.mac_len = 6;
|
||||
/* perform positive test */
|
||||
len = timesync_encode_timesync_recipients(&apdu[0],
|
||||
sizeof(apdu), &recipient[0]);
|
||||
len =
|
||||
timesync_encode_timesync_recipients(&apdu[0], sizeof(apdu),
|
||||
&recipient[0]);
|
||||
ct_test(pTest, len != BACNET_STATUS_ABORT);
|
||||
ct_test(pTest, len > 0);
|
||||
len = timesync_decode_timesync_recipients(&apdu[0],
|
||||
sizeof(apdu), &test_recipient[0]);
|
||||
len =
|
||||
timesync_decode_timesync_recipients(&apdu[0], sizeof(apdu),
|
||||
&test_recipient[0]);
|
||||
ct_test(pTest, len != BACNET_STATUS_ABORT);
|
||||
ct_test(pTest, len > 0);
|
||||
testTimeSyncRecipientData(pTest, &recipient[0], &test_recipient[0]);
|
||||
|
||||
Reference in New Issue
Block a user