indented to standard from script

This commit is contained in:
skarg
2012-05-13 15:07:12 +00:00
parent 173e9fb9a9
commit 48e2c60ce2
130 changed files with 1931 additions and 2014 deletions
+1 -2
View File
@@ -63,8 +63,7 @@ BACNET_ABORT_REASON abort_convert_error_code(
abort_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED;
break;
case ERROR_CODE_ABORT_PROPRIETARY:
abort_code =
(BACNET_ABORT_REASON)FIRST_PROPRIETARY_ABORT_REASON;
abort_code = (BACNET_ABORT_REASON) FIRST_PROPRIETARY_ABORT_REASON;
break;
case ERROR_CODE_ABORT_OTHER:
default:
+9 -9
View File
@@ -149,8 +149,7 @@ 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;
@@ -169,8 +168,7 @@ 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 */
@@ -206,10 +204,11 @@ static void address_file_init(
long device_id = 0;
int snet = 0;
unsigned max_apdu = 0;
unsigned mac[6] = {0};
unsigned mac[6] = { 0 };
int count = 0;
char mac_string[80] = {""}, sadr_string[80] = {""};
BACNET_ADDRESS src = {0};
char mac_string[80] = { "" }, sadr_string[80] = {
""};
BACNET_ADDRESS src = { 0 };
int index = 0;
pFile = fopen(pFilename, "r");
@@ -230,8 +229,9 @@ static void address_file_init(
src.net = (uint16_t) snet;
if (snet) {
count =
sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x", &mac[0],
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4],
&mac[5]);
src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = (uint8_t) mac[index];
+10 -9
View File
@@ -46,10 +46,10 @@
/** @file apdu.c Handles APDU services */
extern int Routed_Device_Service_Approval(
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t *apdu_buff,
uint8_t invoke_id );
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t * apdu_buff,
uint8_t invoke_id);
/* APDU Timeout in Milliseconds */
@@ -155,11 +155,12 @@ bool apdu_service_supported(
found = true;
if (Confirmed_Function[i] != NULL) {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
int len = Routed_Device_Service_Approval(
service_supported, 0, NULL, 0);
if ( len > 0 )
break; /* Not supported - return false */
/* Check to see if the current Device supports this service. */
int len =
Routed_Device_Service_Approval(service_supported, 0,
NULL, 0);
if (len > 0)
break; /* Not supported - return false */
#endif
status = true;
+92 -84
View File
@@ -264,8 +264,7 @@ int bacapp_decode_data(
}
}
if ((len == 0) &&
(tag_data_type != BACNET_APPLICATION_TAG_NULL) &&
if ((len == 0) && (tag_data_type != BACNET_APPLICATION_TAG_NULL) &&
(tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) &&
(tag_data_type != BACNET_APPLICATION_TAG_OCTET_STRING)) {
/* indicate that we were not able to decode the value */
@@ -657,16 +656,16 @@ BACNET_APPLICATION_TAG bacapp_context_tag_type(
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
/* BACnetCOVSubscription */
switch (tag_number) {
case 0: /* BACnetRecipientProcess */
case 1: /* BACnetObjectPropertyReference */
case 0: /* BACnetRecipientProcess */
case 1: /* BACnetObjectPropertyReference */
break;
case 2: /* issueConfirmedNotifications */
case 2: /* issueConfirmedNotifications */
tag = BACNET_APPLICATION_TAG_BOOLEAN;
break;
case 3: /* timeRemaining */
case 3: /* timeRemaining */
tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
break;
case 4: /* covIncrement */
case 4: /* covIncrement */
tag = BACNET_APPLICATION_TAG_REAL;
break;
default:
@@ -723,7 +722,7 @@ int bacapp_decode_context_data(
&len_value_type);
apdu_len = tag_len;
/* Empty construct : (closing tag) => returns NULL value */
if (tag_len && ((unsigned)tag_len <= max_apdu_len) &&
if (tag_len && ((unsigned) tag_len <= max_apdu_len) &&
!decode_is_closing_tag_number(&apdu[0], tag_number)) {
value->context_tag = tag_number;
value->tag = bacapp_context_tag_type(property, tag_number);
@@ -739,9 +738,8 @@ int bacapp_decode_context_data(
} else {
apdu_len = BACNET_STATUS_ERROR;
}
}
else if ( tag_len == 1 ) /* and is a Closing tag */
apdu_len = 0; /* Don't advance over that closing tag. */
} else if (tag_len == 1) /* and is a Closing tag */
apdu_len = 0; /* Don't advance over that closing tag. */
}
return apdu_len;
@@ -961,18 +959,19 @@ int bacapp_data_len(
}
#ifdef BACAPP_SNPRINTF_ENABLED
static bool append_str(char **str, size_t *rem_str_len, const char *add_str)
static bool append_str(
char **str,
size_t * rem_str_len,
const char *add_str)
{
bool retval;
int bytes_written;
bytes_written = snprintf(*str, *rem_str_len, "%s", add_str);
if ( (bytes_written < 0) || (bytes_written >= *rem_str_len) ) {
if ((bytes_written < 0) || (bytes_written >= *rem_str_len)) {
/* If there was an error or output was truncated, return error */
retval = false;
}
else
{
} else {
/* Successfully wrote the contents to the string. Let's advance the
* string pointer to the end, and account for the used space */
*str += bytes_written;
@@ -1016,26 +1015,27 @@ int bacapp_snprintf_value(
ret_val = snprintf(str, str_len, "Null");
break;
case BACNET_APPLICATION_TAG_BOOLEAN:
ret_val = (value->type.Boolean) ?
snprintf(str, str_len, "TRUE") :
snprintf(str, str_len, "FALSE");
ret_val =
(value->type.Boolean) ? snprintf(str, str_len,
"TRUE") : snprintf(str, str_len, "FALSE");
break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
ret_val = snprintf(str, str_len, "%lu",
ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Unsigned_Int);
break;
case BACNET_APPLICATION_TAG_SIGNED_INT:
ret_val = snprintf(str, str_len, "%ld",
ret_val =
snprintf(str, str_len, "%ld",
(long) value->type.Signed_Int);
break;
case BACNET_APPLICATION_TAG_REAL:
ret_val = snprintf(str, str_len, "%f",
(double) value->type.Real);
ret_val =
snprintf(str, str_len, "%f", (double) value->type.Real);
break;
#if defined (BACAPP_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
ret_val = snprintf(str, str_len, "%f",
value->type.Double);
ret_val = snprintf(str, str_len, "%f", value->type.Double);
break;
#endif
case BACNET_APPLICATION_TAG_OCTET_STRING:
@@ -1047,15 +1047,15 @@ int bacapp_snprintf_value(
break;
octet_str++;
}
if (i == len)
{
if (i == len) {
// Everything went fine
ret_val = str_len - rem_str_len;
}
break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
len = characterstring_length(&value->type.Character_String);
char_str = characterstring_value(&value->type.Character_String);
char_str =
characterstring_value(&value->type.Character_String);
if (!append_str(&p_str, &rem_str_len, "\""))
break;
for (i = 0; i < len; i++) {
@@ -1068,10 +1068,8 @@ int bacapp_snprintf_value(
break;
char_str++;
}
if ( (i == len) &&
append_str(&p_str, &rem_str_len, "\"")
)
{
if ((i == len) && append_str(&p_str, &rem_str_len, "\"")
) {
// Everything is fine. Indicate how many bytes were
// written
ret_val = str_len - rem_str_len;
@@ -1087,16 +1085,13 @@ int bacapp_snprintf_value(
(uint8_t) i) ? "true" : "false");
if (!append_str(&p_str, &rem_str_len, temp_str))
break;
if (i < len - 1)
{
if (i < len - 1) {
if (!append_str(&p_str, &rem_str_len, ","))
break;
}
}
if ( (i == len) &&
append_str(&p_str, &rem_str_len, "}")
)
{
if ((i == len) && append_str(&p_str, &rem_str_len, "}")
) {
// Everything is fine. Indicate how many bytes were
// written
ret_val = str_len - rem_str_len;
@@ -1106,83 +1101,97 @@ int bacapp_snprintf_value(
switch (property) {
case PROP_OBJECT_TYPE:
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
ret_val = snprintf(str, str_len, "%s",
bactext_object_type_name(value->type.
Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_object_type_name(value->
type.Enumerated));
} else if (value->type.Enumerated < 128) {
ret_val = snprintf(str, str_len, "reserved %lu",
ret_val =
snprintf(str, str_len, "reserved %lu",
(unsigned long) value->type.Enumerated);
} else {
ret_val = snprintf(str, str_len, "proprietary %lu",
ret_val =
snprintf(str, str_len, "proprietary %lu",
(unsigned long) value->type.Enumerated);
}
break;
case PROP_EVENT_STATE:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_event_state_name(value->type.Enumerated));
break;
case PROP_UNITS:
if (value->type.Enumerated < 256) {
ret_val = snprintf(str, str_len, "%s",
bactext_engineering_unit_name(value->
type.Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_engineering_unit_name(value->type.
Enumerated));
} else {
ret_val = snprintf(str, str_len, "proprietary %lu",
ret_val =
snprintf(str, str_len, "proprietary %lu",
(unsigned long) value->type.Enumerated);
}
break;
case PROP_POLARITY:
ret_val = snprintf(str, str_len, "%s",
bactext_binary_polarity_name(value->
type.Enumerated));
ret_val =
snprintf(str, str_len, "%s",
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));
ret_val =
snprintf(str, str_len, "%s",
bactext_binary_present_value_name(value->
type.Enumerated));
} else {
ret_val = snprintf(str, str_len, "%lu",
ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Enumerated);
}
break;
case PROP_RELIABILITY:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_reliability_name(value->type.Enumerated));
break;
case PROP_SYSTEM_STATUS:
ret_val = snprintf(str, str_len, "%s",
bactext_device_status_name(value->
type.Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_device_status_name(value->type.
Enumerated));
break;
case PROP_SEGMENTATION_SUPPORTED:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_segmentation_name(value->type.Enumerated));
break;
case PROP_NODE_TYPE:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_node_type_name(value->type.Enumerated));
break;
default:
ret_val = snprintf(str, str_len, "%lu",
ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Enumerated);
break;
}
break;
case BACNET_APPLICATION_TAG_DATE:
if (!append_str(&p_str, &rem_str_len,
bactext_day_of_week_name(value->type.Date.wday)
)
)
bactext_day_of_week_name(value->type.Date.wday)
)
)
break;
if (!append_str(&p_str, &rem_str_len, ", "))
break;
if (!append_str(&p_str, &rem_str_len,
bactext_month_name(value->type.Date.month)
)
)
bactext_month_name(value->type.Date.month)
)
)
break;
if (value->type.Date.day == 255) {
if (!append_str(&p_str, &rem_str_len, " (unspecified), "))
@@ -1252,9 +1261,10 @@ 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;
snprintf(temp_str, sizeof(temp_str), ", %lu",
(unsigned long) value->type.Object_Id.instance);
@@ -1313,22 +1323,19 @@ bool bacapp_print_value(
size_t str_len = 32;
int status;
while (true)
{
while (true) {
// Try to allocate memory for the output string. Give up if unable.
str = (char *)calloc(sizeof(char), str_len);
str = (char *) calloc(sizeof(char), str_len);
if (!str)
break;
// Try to extract the value into allocated memory. If unable, try again
// another time with a string that is twice as large.
status = bacapp_snprintf_value(str, str_len, object_value);
if ( (status < 0 ) || (status >= str_len) )
{
if ((status < 0) || (status >= str_len)) {
free(str);
str_len *= 2;
}
else if (status == 0) {
} else if (status == 0) {
free(str);
break;
} else {
@@ -1391,7 +1398,7 @@ bool bacapp_parse_application_data(
break;
#endif
case BACNET_APPLICATION_TAG_OCTET_STRING:
#if PRINT_ENABLED /* Apparently ain't necessarily so. */
#if PRINT_ENABLED /* Apparently ain't necessarily so. */
status =
octetstring_init_ascii_hex(&value->type.Octet_String,
argv);
@@ -1413,7 +1420,8 @@ bool bacapp_parse_application_data(
break;
case BACNET_APPLICATION_TAG_DATE:
count =
sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day, &wday);
sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day,
&wday);
if (count == 3) {
datetime_set_date(&value->type.Date, (uint16_t) year,
(uint8_t) month, (uint8_t) day);
@@ -1637,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:
@@ -2113,8 +2121,8 @@ void testBACnetApplicationData(
ct_test(pTest, testBACnetApplicationDataValue(&value));
/* test empty string */
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
"", &value);
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, "",
&value);
ct_test(pTest, status == true);
ct_test(pTest, testBACnetApplicationDataValue(&value));
+14 -14
View File
@@ -501,21 +501,21 @@ bool characterstring_printable(
placed in the public domain Fall 2005 */
static const char trailingBytesForUTF8[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4,
4, 4, 4, 5, 5, 5, 5
4, 4, 4, 5, 5, 5, 5
};
/* based on the valid_utf8 routine from the PCRE library by Philip Hazel
@@ -546,7 +546,7 @@ bool utf8_isvalid(
if ((c & 0xc0) != 0xc0) {
return false;
}
ab = (size_t)trailingBytesForUTF8[c];
ab = (size_t) trailingBytesForUTF8[c];
if (length < ab) {
return false;
}
@@ -659,7 +659,7 @@ bool octetstring_init(
returns true if successfully converted and fits; false if too long */
bool octetstring_init_ascii_hex(
BACNET_OCTET_STRING * octet_string,
const char * ascii_hex)
const char *ascii_hex)
{
bool status = false; /* return value */
unsigned index = 0; /* offset into buffer */
@@ -678,16 +678,16 @@ bool octetstring_init_ascii_hex(
index++;
continue;
}
if (ascii_hex[index+1] == 0) {
if (ascii_hex[index + 1] == 0) {
break;
}
hex_pair_string[0] = ascii_hex[index];
hex_pair_string[1] = ascii_hex[index+1];
value = (uint8_t)strtol(hex_pair_string, NULL, 16);
hex_pair_string[1] = ascii_hex[index + 1];
value = (uint8_t) strtol(hex_pair_string, NULL, 16);
if (octet_string->length <= MAX_OCTET_STRING_BYTES) {
octet_string->value[octet_string->length] = value;
octet_string->length++;
/* at least one pair was decoded */
/* at least one pair was decoded */
status = true;
} else {
break;
+2 -1
View File
@@ -929,7 +929,8 @@ INDTEXT_DATA bacnet_property_names[] = {
,
{PROP_LAST_KEY_SERVER, "last-key-server"}
,
{PROP_NETWORK_ACCESS_SECURITY_ALGORITHMS, "network-access-security-algorithms"}
{PROP_NETWORK_ACCESS_SECURITY_ALGORITHMS,
"network-access-security-algorithms"}
,
{PROP_PACKET_REORDER_TIME, "packet-reorder-time"}
,
+1 -2
View File
@@ -262,8 +262,7 @@ uint16_t bip_receive(
if (pdu[0] != BVLL_TYPE_BACNET_IP)
return 0;
if ( bvlc_for_non_bbmd(&sin, pdu, received_bytes) > 0 )
{
if (bvlc_for_non_bbmd(&sin, pdu, received_bytes) > 0) {
/* Handled, usually with a NACK. */
#if PRINT_ENABLED
fprintf(stderr, "BIP: BVLC discarded!\n");
+19 -17
View File
@@ -59,7 +59,7 @@ static struct sockaddr_in Remote_BBMD;
BACNET_BVLC_RESULT BVLC_Result_Code = BVLC_RESULT_SUCCESSFUL_COMPLETION;
/** The current BVLC Function Code being handled. */
BACNET_BVLC_FUNCTION BVLC_Function_Code = BVLC_RESULT; /* A safe default */
BACNET_BVLC_FUNCTION BVLC_Function_Code = BVLC_RESULT; /* A safe default */
/* Define BBMD_ENABLED to get the functions that a
* BBMD needs to handle its services.
@@ -665,8 +665,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())
@@ -1244,16 +1244,16 @@ int bvlc_register_with_bbmd(
* BVLC message. If zero, may need further processing.
*/
int bvlc_for_non_bbmd(
struct sockaddr_in * sout,
uint8_t * npdu,
uint16_t received_bytes)
struct sockaddr_in *sout,
uint8_t * npdu,
uint16_t received_bytes)
{
uint16_t result_code = 0; /* aka, BVLC_RESULT_SUCCESSFUL_COMPLETION */
uint16_t result_code = 0; /* aka, BVLC_RESULT_SUCCESSFUL_COMPLETION */
BVLC_Function_Code = npdu[1]; /* The BVLC function */
BVLC_Function_Code = npdu[1]; /* The BVLC function */
switch (BVLC_Function_Code) {
case BVLC_RESULT:
if ( received_bytes >= 6) {
if (received_bytes >= 6) {
/* This is the result of our foreign device registration */
(void) decode_unsigned16(&npdu[4], &result_code);
BVLC_Result_Code = (BACNET_BVLC_RESULT) result_code;
@@ -1268,23 +1268,23 @@ int bvlc_for_non_bbmd(
case BVLC_READ_BROADCAST_DIST_TABLE:
result_code = BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK;
break;
/* case BVLC_READ_BROADCAST_DIST_TABLE_ACK: */
/* case BVLC_READ_BROADCAST_DIST_TABLE_ACK: */
case BVLC_REGISTER_FOREIGN_DEVICE:
result_code = BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK;
break;
case BVLC_READ_FOREIGN_DEVICE_TABLE:
result_code = BVLC_RESULT_READ_FOREIGN_DEVICE_TABLE_NAK;
break;
/* case BVLC_READ_FOREIGN_DEVICE_TABLE_ACK: */
/* case BVLC_READ_FOREIGN_DEVICE_TABLE_ACK: */
case BVLC_DELETE_FOREIGN_DEVICE_TABLE_ENTRY:
result_code = BVLC_RESULT_DELETE_FOREIGN_DEVICE_TABLE_ENTRY_NAK;
break;
case BVLC_DISTRIBUTE_BROADCAST_TO_NETWORK:
result_code = BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK;
result_code = BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK;
break;
/* case BVLC_FORWARDED_NPDU: */
/* case BVLC_ORIGINAL_UNICAST_NPDU: */
/* case BVLC_ORIGINAL_BROADCAST_NPDU: */
/* case BVLC_FORWARDED_NPDU: */
/* case BVLC_ORIGINAL_UNICAST_NPDU: */
/* case BVLC_ORIGINAL_BROADCAST_NPDU: */
default:
break;
}
@@ -1304,7 +1304,8 @@ int bvlc_for_non_bbmd(
* BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK if registration failed,
* or one of the other codes (if we are a BBMD).
*/
BACNET_BVLC_RESULT bvlc_get_last_result(void)
BACNET_BVLC_RESULT bvlc_get_last_result(
void)
{
return BVLC_Result_Code;
}
@@ -1316,7 +1317,8 @@ BACNET_BVLC_RESULT bvlc_get_last_result(void)
*
* @return A BVLC_ code, such as BVLC_ORIGINAL_UNICAST_NPDU.
*/
BACNET_BVLC_FUNCTION bvlc_get_function_code(void)
BACNET_BVLC_FUNCTION bvlc_get_function_code(
void)
{
return BVLC_Function_Code;
}
+2 -1
View File
@@ -127,7 +127,8 @@ bool dcc_set_status_duration(
return valid;
}
#if BACNET_SVC_DCC_A
#if BACNET_SVC_DCC_A
/* encode service */
int dcc_encode_apdu(
uint8_t * apdu,
+138 -143
View File
@@ -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,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;
@@ -1083,16 +1078,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);
@@ -1116,8 +1111,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,
@@ -1180,16 +1175,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);
@@ -1210,8 +1205,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));
/**********************************************************************************/
@@ -1434,12 +1429,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;
@@ -1464,34 +1459,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 ==
+4 -4
View File
@@ -229,7 +229,7 @@ bool FIFO_Add(
void FIFO_Flush(
FIFO_BUFFER * b)
{
unsigned head; /* used to avoid volatile decision */
unsigned head; /* used to avoid volatile decision */
if (b) {
head = b->head;
@@ -271,10 +271,10 @@ void FIFO_Init(
void testFIFOBuffer(
Test * pTest)
{
FIFO_BUFFER test_buffer = {0};
volatile uint8_t data_store[FIFO_BUFFER_SIZE] = {0};
FIFO_BUFFER test_buffer = { 0 };
volatile uint8_t data_store[FIFO_BUFFER_SIZE] = { 0 };
uint8_t add_data[40] = { "RoseSteveLouPatRachelJessicaDaniAmyHerb" };
uint8_t test_add_data[40] = {0};
uint8_t test_add_data[40] = { 0 };
uint8_t test_data = 0;
unsigned index = 0;
unsigned count = 0;
+13 -12
View File
@@ -37,7 +37,7 @@ int get_alarm_summary_ack_encode_apdu_init(
if (apdu) {
apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */
apdu[1] = invoke_id; /* original invoke id from request */
apdu[1] = invoke_id; /* original invoke id from request */
apdu[2] = SERVICE_CONFIRMED_GET_ALARM_SUMMARY;
apdu_len = 3;
}
@@ -54,20 +54,21 @@ int get_alarm_sumary_ack_encode_apdu_data(
if (!apdu) {
apdu_len = BACNET_STATUS_ERROR;
}
else if(max_apdu >= 10) {
} else if (max_apdu >= 10) {
/* tag 0 - Object Identifier */
apdu_len += encode_application_object_id(&apdu[apdu_len],
(int)get_alarm_data->objectIdentifier.type,
get_alarm_data->objectIdentifier.instance);
apdu_len +=
encode_application_object_id(&apdu[apdu_len],
(int) get_alarm_data->objectIdentifier.type,
get_alarm_data->objectIdentifier.instance);
/* tag 1 - Alarm State */
apdu_len += encode_application_enumerated(&apdu[apdu_len],
get_alarm_data->alarmState);
apdu_len +=
encode_application_enumerated(&apdu[apdu_len],
get_alarm_data->alarmState);
/* tag 2 - Acknowledged Transitions */
apdu_len += encode_application_bitstring(&apdu[apdu_len],
&get_alarm_data->acknowledgedTransitions);
}
else {
apdu_len +=
encode_application_bitstring(&apdu[apdu_len],
&get_alarm_data->acknowledgedTransitions);
} else {
apdu_len = BACNET_STATUS_ABORT;
}
+2 -2
View File
@@ -53,8 +53,8 @@ size_t memcopy(
// s1 = dest;
// s2 = src;
if (len <= (max - offset)) {
memcpy(&((char *)dest)[offset], src, len);
return(len);
memcpy(&((char *) dest)[offset], src, len);
return (len);
// for (i = 0; i < len; i++) {
// s1[offset + i] = s2[i];
// copy_len++;
+4 -8
View File
@@ -1096,7 +1096,7 @@ bool MSTP_Master_Node_FSM(
}
void MSTP_Slave_Node_FSM(
volatile struct mstp_port_struct_t * mstp_port)
volatile struct mstp_port_struct_t *mstp_port)
{
unsigned length = 0;
@@ -1140,13 +1140,9 @@ void MSTP_Slave_Node_FSM(
break;
case FRAME_TYPE_TEST_REQUEST:
mstp_port->ReceivedValidFrame = false;
MSTP_Create_And_Send_Frame(
mstp_port,
FRAME_TYPE_TEST_RESPONSE,
mstp_port->SourceAddress,
mstp_port->This_Station,
&mstp_port->InputBuffer[0],
mstp_port->DataLength);
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_RESPONSE,
mstp_port->SourceAddress, mstp_port->This_Station,
&mstp_port->InputBuffer[0], mstp_port->DataLength);
break;
case FRAME_TYPE_TOKEN:
case FRAME_TYPE_POLL_FOR_MASTER:
+6 -6
View File
@@ -409,12 +409,12 @@ int npdu_decode(
}
}
} else if (src) {
/* Clear the net number, with one exception: if the receive()
* function set it to BACNET_BROADCAST_NETWORK, (eg, for
* BVLC_ORIGINAL_BROADCAST_NPDU) then don't stomp on that.
*/
if ( src->net != BACNET_BROADCAST_NETWORK )
src->net = 0;
/* Clear the net number, with one exception: if the receive()
* function set it to BACNET_BROADCAST_NETWORK, (eg, for
* BVLC_ORIGINAL_BROADCAST_NPDU) then don't stomp on that.
*/
if (src->net != BACNET_BROADCAST_NETWORK)
src->net = 0;
src->len = 0;
for (i = 0; i < MAX_MAC_LEN; i++) {
src->adr[i] = 0;
+26 -52
View File
@@ -708,71 +708,49 @@ void property_list_special(
pPropertyList->Proprietary.pList = NULL;
switch (object_type) {
case OBJECT_DEVICE:
pPropertyList->Required.pList =
Device_Properties_Required;
pPropertyList->Optional.pList =
Device_Properties_Optional;
pPropertyList->Required.pList = Device_Properties_Required;
pPropertyList->Optional.pList = Device_Properties_Optional;
break;
break;
case OBJECT_ACCUMULATOR:
pPropertyList->Required.pList =
Accumulator_Properties_Required;
pPropertyList->Optional.pList =
Accumulator_Properties_Optional;
pPropertyList->Required.pList = Accumulator_Properties_Required;
pPropertyList->Optional.pList = Accumulator_Properties_Optional;
break;
case OBJECT_ANALOG_INPUT:
pPropertyList->Required.pList =
Analog_Input_Properties_Required;
pPropertyList->Optional.pList =
Analog_Input_Properties_Optional;
pPropertyList->Required.pList = Analog_Input_Properties_Required;
pPropertyList->Optional.pList = Analog_Input_Properties_Optional;
break;
case OBJECT_ANALOG_OUTPUT:
pPropertyList->Required.pList =
Analog_Output_Properties_Required;
pPropertyList->Optional.pList =
Analog_Output_Properties_Optional;
pPropertyList->Required.pList = Analog_Output_Properties_Required;
pPropertyList->Optional.pList = Analog_Output_Properties_Optional;
break;
case OBJECT_ANALOG_VALUE:
pPropertyList->Required.pList =
Analog_Value_Properties_Required;
pPropertyList->Optional.pList =
Analog_Value_Properties_Optional;
pPropertyList->Required.pList = Analog_Value_Properties_Required;
pPropertyList->Optional.pList = Analog_Value_Properties_Optional;
break;
case OBJECT_AVERAGING:
pPropertyList->Required.pList =
Averaging_Properties_Required;
pPropertyList->Optional.pList =
Averaging_Properties_Optional;
pPropertyList->Required.pList = Averaging_Properties_Required;
pPropertyList->Optional.pList = Averaging_Properties_Optional;
break;
case OBJECT_BINARY_INPUT:
pPropertyList->Required.pList =
Binary_Input_Properties_Required;
pPropertyList->Optional.pList =
Binary_Input_Properties_Optional;
pPropertyList->Required.pList = Binary_Input_Properties_Required;
pPropertyList->Optional.pList = Binary_Input_Properties_Optional;
break;
case OBJECT_BINARY_OUTPUT:
pPropertyList->Required.pList =
Binary_Output_Properties_Required;
pPropertyList->Optional.pList =
Binary_Output_Properties_Optional;
pPropertyList->Required.pList = Binary_Output_Properties_Required;
pPropertyList->Optional.pList = Binary_Output_Properties_Optional;
break;
case OBJECT_BINARY_VALUE:
pPropertyList->Required.pList =
Binary_Value_Properties_Required;
pPropertyList->Optional.pList =
Binary_Value_Properties_Optional;
pPropertyList->Required.pList = Binary_Value_Properties_Required;
pPropertyList->Optional.pList = Binary_Value_Properties_Optional;
break;
case OBJECT_CALENDAR:
pPropertyList->Required.pList =
Calendar_Properties_Required;
pPropertyList->Optional.pList =
Calendar_Properties_Optional;
pPropertyList->Required.pList = Calendar_Properties_Required;
pPropertyList->Optional.pList = Calendar_Properties_Optional;
break;
case OBJECT_COMMAND:
pPropertyList->Required.pList =
Command_Properties_Required;
pPropertyList->Optional.pList =
Command_Properties_Optional;
pPropertyList->Required.pList = Command_Properties_Required;
pPropertyList->Optional.pList = Command_Properties_Optional;
break;
case OBJECT_CHARACTERSTRING_VALUE:
pPropertyList->Required.pList =
@@ -781,10 +759,8 @@ void property_list_special(
CharacterString_Value_Properties_Optional;
break;
case OBJECT_LOAD_CONTROL:
pPropertyList->Required.pList =
Load_Control_Properties_Required;
pPropertyList->Optional.pList =
Load_Control_Properties_Optional;
pPropertyList->Required.pList = Load_Control_Properties_Required;
pPropertyList->Optional.pList = Load_Control_Properties_Optional;
break;
case OBJECT_LIFE_SAFETY_POINT:
pPropertyList->Required.pList =
@@ -817,10 +793,8 @@ void property_list_special(
Notification_Class_Properties_Optional;
break;
case OBJECT_TRENDLOG:
pPropertyList->Required.pList =
Trend_Log_Properties_Required;
pPropertyList->Optional.pList =
Trend_Log_Properties_Optional;
pPropertyList->Required.pList = Trend_Log_Properties_Required;
pPropertyList->Optional.pList = Trend_Log_Properties_Optional;
break;
case OBJECT_EVENT_ENROLLMENT:
case OBJECT_FILE:
+12 -9
View File
@@ -490,7 +490,8 @@ void test_Private_Transfer_Ack(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
@@ -543,7 +544,8 @@ void test_Private_Transfer_Error(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
@@ -585,16 +587,17 @@ void test_Private_Transfer_Request(
uint8_t test_invoke_id = 0;
int private_data_len = 0;
char private_data_chunk[33] = { "00112233445566778899AABBCCDDEEFF" };
BACNET_APPLICATION_DATA_VALUE data_value = {0};
BACNET_APPLICATION_DATA_VALUE test_data_value = {0};
BACNET_PRIVATE_TRANSFER_DATA private_data = {0};
BACNET_PRIVATE_TRANSFER_DATA test_data = {0};
BACNET_APPLICATION_DATA_VALUE data_value = { 0 };
BACNET_APPLICATION_DATA_VALUE test_data_value = { 0 };
BACNET_PRIVATE_TRANSFER_DATA private_data = { 0 };
BACNET_PRIVATE_TRANSFER_DATA test_data = { 0 };
bool status = false;
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
@@ -638,8 +641,8 @@ void test_Unconfirmed_Private_Transfer_Request(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(
BACNET_APPLICATION_TAG_CHARACTER_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_CHARACTER_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
+1 -1
View File
@@ -81,7 +81,7 @@ BACNET_REJECT_REASON reject_convert_error_code(
break;
case ERROR_CODE_REJECT_PROPRIETARY:
reject_code =
(BACNET_REJECT_REASON)FIRST_PROPRIETARY_REJECT_REASON;
(BACNET_REJECT_REASON) FIRST_PROPRIETARY_REJECT_REASON;
break;
case ERROR_CODE_REJECT_OTHER:
default:
+10 -10
View File
@@ -47,15 +47,15 @@
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
unsigned Ringbuf_Count (
unsigned Ringbuf_Count(
RING_BUFFER const *b)
{
unsigned head, tail; /* used to avoid volatile decision */
unsigned head, tail; /* used to avoid volatile decision */
if (b) {
head = b->head;
tail = b->tail;
return head-tail;
return head - tail;
}
return 0;
@@ -67,7 +67,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);
@@ -94,7 +94,7 @@ bool Ringbuf_Empty(
volatile uint8_t *Ringbuf_Get_Front(
RING_BUFFER const *b)
{
volatile uint8_t *data_element = NULL; /* return value */
volatile uint8_t *data_element = NULL; /* return value */
if (!Ringbuf_Empty(b)) {
data_element = b->buffer;
@@ -132,10 +132,10 @@ volatile uint8_t *Ringbuf_Pop_Front(
*****************************************************************************/
bool Ringbuf_Put(
RING_BUFFER * b, /* ring buffer structure */
volatile uint8_t *data_element)
volatile 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 */
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
unsigned i; /* loop counter */
if (b && data_element) {
@@ -161,9 +161,9 @@ bool Ringbuf_Put(
* NOTES: none
*****************************************************************************/
volatile uint8_t *Ringbuf_Alloc(
RING_BUFFER *b)
RING_BUFFER * b)
{
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
volatile uint8_t *ring_data = NULL; /* used to help point ring data */
if (b) {
/* limit the amount of elements that we accept */
@@ -186,7 +186,7 @@ volatile uint8_t *Ringbuf_Alloc(
*****************************************************************************/
void Ringbuf_Init(
RING_BUFFER * b, /* ring buffer structure */
volatile uint8_t * buffer, /* data block or array of data */
volatile uint8_t * buffer, /* 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 */
+1 -2
View File
@@ -158,8 +158,7 @@ int rp_ack_encode_apdu_init(
/* service ack follows */
len =
encode_context_object_id(&apdu[apdu_len], 0,
rpdata->object_type,
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
rpdata->object_instance);
apdu_len += len;
len =
+3 -3
View File
@@ -382,9 +382,9 @@ int rpm_ack_encode_apdu_object_property_value(
if (apdu) {
/* Tag 4: propertyValue */
apdu_len += encode_opening_tag(&apdu[apdu_len], 4);
if (application_data == &apdu[apdu_len]) { /* Is Data already in place? */
apdu_len += application_data_len; /* Yes, step over data */
} else { /* No, copy data in */
if (application_data == &apdu[apdu_len]) { /* Is Data already in place? */
apdu_len += application_data_len; /* Yes, step over data */
} else { /* No, copy data in */
for (len = 0; len < application_data_len; len++) {
apdu[apdu_len++] = application_data[len];
}
+30 -25
View File
@@ -67,12 +67,14 @@ int wpm_decode_object_id(
apdu_len -= len;
if (apdu_len >= 4) {
len +=
decode_object_id(&apdu[len], &object_type, &object_instance);
decode_object_id(&apdu[len], &object_type,
&object_instance);
wp_data->object_type = object_type;
wp_data->object_instance = object_instance;
apdu_len -= len;
} else {
wp_data->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
wp_data->error_code =
ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT;
}
} else {
@@ -90,7 +92,7 @@ int wpm_decode_object_id(
return BACNET_STATUS_REJECT;
}
return (int)len;
return (int) len;
}
@@ -135,7 +137,7 @@ int wpm_decode_object_property(
if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) {
len--;
wp_data->application_data_len =
bacapp_data_len(&apdu[len], (unsigned)(apdu_len - len),
bacapp_data_len(&apdu[len], (unsigned) (apdu_len - len),
wp_data->object_property);
len++;
@@ -174,15 +176,17 @@ int wpm_decode_object_property(
}
/* encode functions */
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id)
int wpm_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id)
{
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;
apdu[1] = encode_max_segs_max_apdu (0, MAX_APDU);
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
apdu[2] = invoke_id;
apdu[3] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE; /* service choice */
apdu[3] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE; /* service choice */
apdu_len = 4;
}
@@ -190,59 +194,60 @@ int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id)
}
int wpm_encode_apdu_object_begin (
int wpm_encode_apdu_object_begin(
uint8_t * apdu,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance)
{
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_len = encode_context_object_id (
&apdu[0], 0, object_type, object_instance);
apdu_len =
encode_context_object_id(&apdu[0], 0, object_type,
object_instance);
/* Tag 1: sequence of WriteAccessSpecification */
apdu_len += encode_opening_tag (&apdu[apdu_len], 1);
apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
}
return apdu_len;
}
int wpm_encode_apdu_object_end (uint8_t * apdu)
int wpm_encode_apdu_object_end(
uint8_t * apdu)
{
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_len = encode_closing_tag (&apdu[0], 1);
apdu_len = encode_closing_tag(&apdu[0], 1);
}
return apdu_len;
}
int wpm_encode_apdu_object_property (
int wpm_encode_apdu_object_property(
uint8_t * apdu,
BACNET_WRITE_PROPERTY_DATA * wpdata)
{
int apdu_len = 0; /* total length of the apdu, return value */
int apdu_len = 0; /* total length of the apdu, return value */
int len = 0;
if (apdu) {
apdu_len = encode_context_enumerated (&apdu[0], 0,
wpdata->object_property);
apdu_len =
encode_context_enumerated(&apdu[0], 0, wpdata->object_property);
/* optional array index */
if (wpdata->array_index != BACNET_ARRAY_ALL) {
apdu_len +=
encode_context_unsigned (&apdu[apdu_len], 1,
encode_context_unsigned(&apdu[apdu_len], 1,
wpdata->array_index);
}
apdu_len += encode_opening_tag (&apdu[apdu_len], 2);
apdu_len += encode_opening_tag(&apdu[apdu_len], 2);
for (len = 0; len < wpdata->application_data_len; len++) {
apdu[apdu_len] = wpdata->application_data[len];
apdu_len++;
}
apdu_len += encode_closing_tag (&apdu[apdu_len], 2);
apdu_len += encode_closing_tag(&apdu[apdu_len], 2);
if (wpdata->priority != BACNET_NO_PRIORITY) {
encode_context_unsigned (&apdu[apdu_len], 3,
wpdata->priority);
encode_context_unsigned(&apdu[apdu_len], 3, wpdata->priority);
}
}