Fix (most) compilation warnings in Intel C++ Compiler (#38)

* Use BACNET_OBJECT_TYPE for all object type variables.

* Fix ICC "mixing enumerated type" warnings for assignments and parameters.

* Network Port: Use enums for state structs and remove erroneous bounds checks copy-pasted from IP_Subnet_Prefix setter.

* Fix ICC "unreachable statement" warnings.

* Fix ICC "unused variable" warnings when printing is disabled.

* Fix ICC "mixing enumerated type" warnings for struct initializers { 0 } by ensuring the first member is an integer type.

* Send_GetEvent_Global: Return 0 (invalid TSM invoke ID) instead of -1 = 255 (technically valid invoke ID) on failure.

* Fix ICC "pointless comparison" warnings.

* Fix wrong import in objects.c (memset being used).

* Fix signedness warnings and inconsistencies. Include -1 = 255 check in cov_address_get().

* Add some guards for BACAPP_LIGHTING_COMMAND to avoid errors/warnings.

* RPM test fixes

* Address requested changes. (#38)
This commit is contained in:
Geert Linders
2020-01-23 15:18:47 +01:00
committed by Steve Karg
parent 76abcaedd1
commit f8ce70470c
92 changed files with 438 additions and 263 deletions
-1
View File
@@ -193,7 +193,6 @@ int Send_Network_Layer_Message(BACNET_NETWORK_MESSAGE_TYPE network_message_type,
debug_printf("Not sent: %s message unsupported \n",
bactext_network_layer_msg_name(network_message_type));
return 0;
break; /* Will never reach this line */
}
if (dst != NULL) {
+8 -6
View File
@@ -190,7 +190,7 @@ bool Access_Door_Present_Value_Set(
index = Access_Door_Instance_To_Index(object_instance);
if (index < MAX_ACCESS_DOORS) {
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
(priority != 6 /* reserved */) && (value >= DOOR_VALUE_LOCK) &&
(priority != 6 /* reserved */) &&
(value <= DOOR_VALUE_EXTENDED_PULSE_UNLOCK)) {
ad_descr[index].value_active[priority - 1] = true;
ad_descr[index].priority_array[priority - 1] = value;
@@ -233,7 +233,7 @@ bool Access_Door_Present_Value_Relinquish(
BACNET_DOOR_VALUE Access_Door_Relinquish_Default(uint32_t object_instance)
{
BACNET_DOOR_VALUE status = -1;
BACNET_DOOR_VALUE status = DOOR_VALUE_LOCK;
unsigned index = 0;
index = Access_Door_Instance_To_Index(object_instance);
if (index < MAX_ACCESS_DOORS) {
@@ -467,7 +467,7 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
algorithm and may not be used for other purposes in any
object. */
status = Access_Door_Present_Value_Set(wp_data->object_instance,
value.type.Enumerated, wp_data->priority);
(BACNET_DOOR_VALUE)value.type.Enumerated, wp_data->priority);
if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -505,7 +505,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
ad_descr[object_index].door_status = value.type.Enumerated;
ad_descr[object_index].door_status =
(BACNET_DOOR_STATUS)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -518,7 +519,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
ad_descr[object_index].lock_status = value.type.Enumerated;
ad_descr[object_index].lock_status =
(BACNET_LOCK_STATUS)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -532,7 +534,7 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
&wp_data->error_class, &wp_data->error_code);
if (status) {
ad_descr[object_index].door_alarm_state =
value.type.Enumerated;
(BACNET_DOOR_ALARM_STATE)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+2 -1
View File
@@ -315,7 +315,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
az_descr[object_index].reliability = value.type.Enumerated;
az_descr[object_index].reliability =
(BACNET_RELIABILITY)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+3
View File
@@ -1105,6 +1105,9 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL]
.Time_Stamp = event_data.timeStamp.value.dateTime;
break;
default: /* shouldn't happen */
break;
}
}
}
+3
View File
@@ -1111,6 +1111,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL]
.Time_Stamp = event_data.timeStamp.value.dateTime;
break;
default: /* shouldn't happen */
break;
}
}
}
+5 -5
View File
@@ -232,14 +232,14 @@ unsigned Channel_Last_Priority(uint32_t object_instance)
BACNET_WRITE_STATUS Channel_Write_Status(uint32_t object_instance)
{
unsigned index = 0;
unsigned priority = 0;
BACNET_WRITE_STATUS write_status = BACNET_WRITE_STATUS_IDLE;
index = Channel_Instance_To_Index(object_instance);
if (index < BACNET_CHANNELS_MAX) {
priority = Channel[index].Write_Status;
write_status = Channel[index].Write_Status;
}
return priority;
return write_status;
}
/**
@@ -451,12 +451,12 @@ unsigned Channel_Reference_List_Member_Element_Add(uint32_t object_instance,
* zero if not added
*/
unsigned Channel_Reference_List_Member_Local_Add(uint32_t object_instance,
uint16_t type,
BACNET_OBJECT_TYPE type,
uint32_t instance,
BACNET_PROPERTY_ID propertyIdentifier,
uint32_t arrayIndex)
{
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE member = { { 0 } };
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE member = { 0 };
member.objectIdentifier.type = type;
member.objectIdentifier.instance = instance;
+1 -1
View File
@@ -166,7 +166,7 @@ extern "C" {
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *pMemberSrc);
unsigned Channel_Reference_List_Member_Local_Add(
uint32_t object_instance,
uint16_t type,
BACNET_OBJECT_TYPE type,
uint32_t instance,
BACNET_PROPERTY_ID propertyIdentifier,
uint32_t arrayIndex);
@@ -562,7 +562,7 @@ unsigned Device_Object_List_Count(void)
* @return True if found, else false.
*/
bool Device_Object_List_Identifier(
uint32_t array_index, int *object_type, uint32_t *instance)
uint32_t array_index, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
{
bool status = false;
unsigned count = 0;
@@ -620,11 +620,11 @@ bool Device_Object_List_Identifier(
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
bool found = false;
int type = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE;
uint32_t instance;
uint32_t max_objects = 0, i = 0;
bool check_id = false;
@@ -659,7 +659,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
* @param object_instance [in] The object instance number to be looked up.
* @return True if found, else False if no such Object in this device.
*/
bool Device_Valid_Object_Id(int object_type, uint32_t object_instance)
bool Device_Valid_Object_Id
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{
bool status = false; /* return value */
struct object_functions *pObject = NULL;
@@ -851,7 +852,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
uint32_t i = 0;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t instance = 0;
uint32_t count = 0;
uint8_t *apdu = NULL;
+4 -3
View File
@@ -50,6 +50,7 @@
#include "bacnet/config.h" /* the custom stuff */
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/services.h"
#include "bacnet/lighting.h"
#include "bacnet/proplist.h"
#include "bacnet/timestamp.h"
#include "bacnet/basic/object/command.h"
@@ -71,8 +72,7 @@ int cl_encode_apdu(uint8_t *apdu, BACNET_ACTION_LIST *bcl)
int len = 0;
int apdu_len = 0;
if (bcl->Device_Id.instance >= 0 &&
bcl->Device_Id.instance <= BACNET_MAX_INSTANCE) {
if (bcl->Device_Id.instance <= BACNET_MAX_INSTANCE) {
len = encode_context_object_id(
&apdu[apdu_len], 0, bcl->Device_Id.type, bcl->Device_Id.instance);
if (len < 0) {
@@ -269,13 +269,14 @@ int cl_decode_apdu(uint8_t *apdu,
&bcl->Value.type.Object_Id.type,
&bcl->Value.type.Object_Id.instance);
break;
#if defined(BACAPP_LIGHTING_COMMAND)
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
len = lighting_command_decode(&apdu[dec_len], apdu_len - dec_len,
&bcl->Value.type.Lighting_Command);
break;
#endif
default:
return BACNET_STATUS_REJECT;
break;
}
if (len > 0) {
dec_len += len;
@@ -337,7 +337,8 @@ bool Credential_Data_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
&wp_data->error_class, &wp_data->error_code);
if (status) {
cdi_descr[object_index].reliability = value.type.Enumerated;
cdi_descr[object_index].reliability =
(BACNET_RELIABILITY)value.type.Enumerated;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+11 -9
View File
@@ -216,7 +216,7 @@ static object_functions_t My_Object_Table[] = {
Trend_Log_Write_Property, Trend_Log_Property_Lists, TrendLogGetRRInfo,
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
#if (BACNET_PROTOCOL_REVISION >= 14)
#if (BACNET_PROTOCOL_REVISION >= 14) && defined(BACAPP_LIGHTING_COMMAND)
{ OBJECT_LIGHTING_OUTPUT, Lighting_Output_Init, Lighting_Output_Count,
Lighting_Output_Index_To_Instance, Lighting_Output_Valid_Instance,
Lighting_Output_Object_Name, Lighting_Output_Read_Property,
@@ -827,7 +827,7 @@ unsigned Device_Object_List_Count(void)
* @return True if found, else false.
*/
bool Device_Object_List_Identifier(
uint32_t array_index, int *object_type, uint32_t *instance)
uint32_t array_index, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
{
bool status = false;
uint32_t count = 0;
@@ -885,11 +885,11 @@ bool Device_Object_List_Identifier(
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t *object_instance)
{
bool found = false;
int type = 0;
BACNET_OBJECT_TYPE type = OBJECT_NONE;
uint32_t instance;
uint32_t max_objects = 0, i = 0;
bool check_id = false;
@@ -924,7 +924,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
* @param object_instance [in] The object instance number to be looked up.
* @return True if found, else False if no such Object in this device.
*/
bool Device_Valid_Object_Id(int object_type, uint32_t object_instance)
bool Device_Valid_Object_Id
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{
bool status = false; /* return value */
struct object_functions *pObject = NULL;
@@ -1072,7 +1073,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_BIT_STRING bit_string = { 0 };
BACNET_CHARACTER_STRING char_string = { 0 };
uint32_t i = 0;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t instance = 0;
uint32_t count = 0;
uint8_t *apdu = NULL;
@@ -1183,7 +1184,8 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
pObject = Object_Table;
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
bitstring_set_bit(
&bit_string, (uint8_t)pObject->Object_Type, true);
}
pObject++;
}
@@ -1361,7 +1363,7 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
bool status = false; /* return value */
int len = 0;
BACNET_APPLICATION_DATA_VALUE value;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t object_instance = 0;
int result = 0;
#if defined(BACNET_TIME_MASTER)
@@ -1758,7 +1760,7 @@ void Device_local_reporting(void)
struct object_functions *pObject;
uint32_t objects_count;
uint32_t object_instance;
int object_type;
BACNET_OBJECT_TYPE object_type;
uint32_t idx;
objects_count = Device_Object_List_Count();
+3 -3
View File
@@ -279,7 +279,7 @@ extern "C" {
void);
bool Device_Object_List_Identifier(
uint32_t array_index,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t * instance);
unsigned Device_Count(
@@ -358,10 +358,10 @@ extern "C" {
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING * object_name,
int *object_type,
BACNET_OBJECT_TYPE *object_type,
uint32_t * object_instance);
bool Device_Valid_Object_Id(
int object_type,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance);
int Device_Read_Property(
+3 -3
View File
@@ -112,8 +112,8 @@ uint16_t iCurrent_Device_Idx = 0;
* @param Object_Instance [in] Set the new Device to this instance number.
* @param sObject_Name [in] Use this Object Name for the Device.
* @param sDescription [in] Set this Description for the Device.
* @return The index of this instance in the Devices[] array,
* or -1 if there isn't enough room to add this Device.
* @return The index of this instance in the Devices[] array, or UINT16_MAX if
* there isn't enough room to add this Device.
*/
uint16_t Add_Routed_Device(uint32_t Object_Instance,
BACNET_CHARACTER_STRING *sObject_Name,
@@ -141,7 +141,7 @@ uint16_t Add_Routed_Device(uint32_t Object_Instance,
pDev->Database_Revision = 0; /* Reset/Initialize now */
return i;
} else {
return -1;
return UINT16_MAX;
}
}
+1 -1
View File
@@ -330,7 +330,7 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
object_index = Life_Safety_Point_Instance_To_Index(
wp_data->object_instance);
Life_Safety_Point_Mode[object_index] =
value.type.Enumerated;
(BACNET_LIFE_SAFETY_MODE)value.type.Enumerated;
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
+1 -1
View File
@@ -581,7 +581,7 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_APPLICATION_DATA_VALUE value;
uint32_t max_states = 0;
uint32_t array_index = 0;
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t object_instance = 0;
/* decode the first chunk of the request */
+16 -20
View File
@@ -54,7 +54,7 @@ struct bacnet_ipv4_port {
uint8_t IP_Gateway[4];
uint8_t IP_DNS_Server[BIP_DNS_MAX][4];
uint16_t Port;
uint8_t Mode;
BACNET_IP_MODE Mode;
bool IP_DHCP_Enable;
uint32_t IP_DHCP_Lease_Seconds;
uint32_t IP_DHCP_Lease_Seconds_Remaining;
@@ -75,7 +75,7 @@ struct bacnet_ipv6_port {
uint8_t IP_Multicast_Address[IPV6_ADDR_SIZE];
uint8_t IP_DHCP_Server[IPV6_ADDR_SIZE];
uint16_t Port;
uint8_t Mode;
BACNET_IP_MODE Mode;
char Zone_Index[ZONE_INDEX_SIZE];
};
@@ -92,12 +92,12 @@ struct mstp_port {
struct object_data {
uint32_t Instance_Number;
char *Object_Name;
uint8_t Reliability;
BACNET_RELIABILITY Reliability;
bool Out_Of_Service : 1;
bool Changes_Pending : 1;
uint8_t Network_Type;
uint16_t Network_Number;
uint8_t Quality;
BACNET_PORT_QUALITY Quality;
uint16_t APDU_Length;
float Link_Speed;
union {
@@ -429,7 +429,7 @@ bool Network_Port_Reliability_Set(
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
Object_List[index].Reliability = (uint8_t)value;
Object_List[index].Reliability = value;
status = true;
}
@@ -558,7 +558,7 @@ bool Network_Port_Quality_Set(
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
Object_List[index].Quality = (uint8_t)value;
Object_List[index].Quality = value;
status = true;
}
@@ -1182,7 +1182,7 @@ bool Network_Port_BIP_Port_Set(uint32_t object_instance, uint16_t value)
*/
BACNET_IP_MODE Network_Port_BIP_Mode(uint32_t object_instance)
{
BACNET_IP_MODE value = 0;
BACNET_IP_MODE value = BACNET_IP_MODE_NORMAL;
unsigned index = 0;
index = Network_Port_Instance_To_Index(object_instance);
@@ -1212,13 +1212,11 @@ bool Network_Port_BIP_Mode_Set(uint32_t object_instance, BACNET_IP_MODE value)
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
if (Object_List[index].Network_Type == PORT_TYPE_BIP) {
if (value <= 32) {
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv4.Mode = value;
status = true;
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv4.Mode = value;
status = true;
}
}
@@ -1287,7 +1285,7 @@ bool Network_Port_BBMD_Accept_FD_Registrations_Set(
*/
BACNET_IP_MODE Network_Port_BIP6_Mode(uint32_t object_instance)
{
BACNET_IP_MODE value = 0;
BACNET_IP_MODE value = BACNET_IP_MODE_NORMAL;
unsigned index = 0;
index = Network_Port_Instance_To_Index(object_instance);
@@ -1317,13 +1315,11 @@ bool Network_Port_BIP6_Mode_Set(uint32_t object_instance, BACNET_IP_MODE value)
index = Network_Port_Instance_To_Index(object_instance);
if (index < BACNET_NETWORK_PORTS_MAX) {
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
if (value <= 32) {
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv6.Mode = value;
status = true;
if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true;
}
Object_List[index].Network.IPv6.Mode = value;
status = true;
}
}
+1 -1
View File
@@ -35,7 +35,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include "bacnet/basic/sys/keylist.h"
#include "bacnet/basic/object/objects.h"
+2 -1
View File
@@ -545,7 +545,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
&wp_data->error_class, &wp_data->error_code);
if (status) {
if (value.type.Enumerated != LOGGING_TYPE_COV) {
CurrentLog->LoggingType = value.type.Enumerated;
CurrentLog->LoggingType =
(BACNET_LOGGING_TYPE)value.type.Enumerated;
if (value.type.Enumerated == LOGGING_TYPE_POLLED) {
/* As per 12.25.27 pick a suitable default if interval
* is 0 */
+6 -1
View File
@@ -79,7 +79,9 @@ void handler_alarm_ack(uint8_t *service_request,
{
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
int ack_result = 0;
BACNET_ADDRESS my_address;
BACNET_NPDU_DATA npdu_data;
@@ -182,7 +184,10 @@ void handler_alarm_ack(uint8_t *service_request,
AA_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+8 -5
View File
@@ -68,7 +68,7 @@ typedef struct BACnet_COV_Subscription_Flags {
typedef struct BACnet_COV_Subscription {
BACNET_COV_SUBSCRIPTION_FLAGS flag;
uint8_t dest_index;
unsigned dest_index;
uint8_t invokeID; /* for confirmed COV */
uint32_t subscriberProcessIdentifier;
uint32_t lifetime; /* optional */
@@ -92,7 +92,7 @@ static BACNET_COV_ADDRESS COV_Addresses[MAX_COV_ADDRESSES];
*
* @return true if valid address, false if not valid or not found
*/
static BACNET_ADDRESS *cov_address_get(int index)
static BACNET_ADDRESS *cov_address_get(unsigned index)
{
BACNET_ADDRESS *cov_dest = NULL;
@@ -324,8 +324,9 @@ void handler_cov_init(void)
unsigned index = 0;
for (index = 0; index < MAX_COV_SUBCRIPTIONS; index++) {
/* initialize with invalid COV address */
COV_Subscriptions[index].flag.valid = false;
COV_Subscriptions[index].dest_index = -1;
COV_Subscriptions[index].dest_index = MAX_COV_ADDRESSES;
COV_Subscriptions[index].subscriberProcessIdentifier = 0;
COV_Subscriptions[index].monitoredObjectIdentifier.type =
OBJECT_ANALOG_INPUT;
@@ -374,8 +375,9 @@ static bool cov_list_subscribe(BACNET_ADDRESS *src,
address_match) {
existing_entry = true;
if (cov_data->cancellationRequest) {
/* initialize with invalid COV address */
COV_Subscriptions[index].flag.valid = false;
COV_Subscriptions[index].dest_index = -1;
COV_Subscriptions[index].dest_index = MAX_COV_ADDRESSES;
cov_address_remove_unused();
} else {
COV_Subscriptions[index].dest_index = cov_address_add(src);
@@ -536,8 +538,9 @@ static void cov_lifetime_expiration_handler(
COV_Subscriptions[index].lifetime);
fprintf(stderr, "\n");
#endif
/* initialize with invalid COV address */
COV_Subscriptions[index].flag.valid = false;
COV_Subscriptions[index].dest_index = -1;
COV_Subscriptions[index].dest_index = MAX_COV_ADDRESSES;
cov_address_remove_unused();
if (COV_Subscriptions[index].flag.issueConfirmedNotifications) {
if (COV_Subscriptions[index].invokeID) {
+6 -1
View File
@@ -85,7 +85,9 @@ void handler_get_event_information(uint8_t *service_request,
BACNET_NPDU_DATA npdu_data;
bool error = false;
bool more_events = false;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT;
BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT;
BACNET_ADDRESS my_address;
@@ -222,7 +224,10 @@ GET_EVENT_ERROR:
}
GET_EVENT_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -51,7 +51,9 @@ void handler_lso(uint8_t *service_request,
int len = 0;
int pdu_len = 0;
BACNET_NPDU_DATA npdu_data;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_ADDRESS my_address;
/* encode the NPDU portion of the packet */
@@ -106,7 +108,10 @@ void handler_lso(uint8_t *service_request,
LSO_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+7 -1
View File
@@ -46,13 +46,17 @@
*/
void rp_ack_print_data(BACNET_READ_PROPERTY_DATA *data)
{
#ifdef BACAPP_PRINT_ENABLED
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
#endif
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
int len = 0;
uint8_t *application_data;
int application_data_len;
bool first_value = true;
#if PRINT_ENABLED
bool print_brace = false;
#endif
if (data) {
application_data = data->application_data;
@@ -66,15 +70,17 @@ void rp_ack_print_data(BACNET_READ_PROPERTY_DATA *data)
first_value = false;
#if PRINT_ENABLED
fprintf(stdout, "{");
#endif
print_brace = true;
#endif
}
#ifdef BACAPP_PRINT_ENABLED
object_value.object_type = data->object_type;
object_value.object_instance = data->object_instance;
object_value.object_property = data->object_property;
object_value.array_index = data->array_index;
object_value.value = &value;
bacapp_print_value(stdout, &object_value);
#endif
if (len > 0) {
if (len < application_data_len) {
application_data += len;
+9 -2
View File
@@ -151,7 +151,8 @@ int rpm_ack_decode_service_request(
apdu += len;
/* FIXME: we could validate that the tag is enumerated... */
len = decode_enumerated(apdu, len_value, &error_value);
rpm_property->error.error_class = error_value;
rpm_property->error.error_class =
(BACNET_ERROR_CLASS)error_value;
decoded_len += len;
apdu_len -= len;
apdu += len;
@@ -162,7 +163,7 @@ int rpm_ack_decode_service_request(
apdu += len;
/* FIXME: we could validate that the tag is enumerated... */
len = decode_enumerated(apdu, len_value, &error_value);
rpm_property->error.error_code = error_value;
rpm_property->error.error_code = (BACNET_ERROR_CODE)error_value;
decoded_len += len;
apdu_len -= len;
apdu += len;
@@ -195,7 +196,9 @@ int rpm_ack_decode_service_request(
/* for debugging... */
void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
{
#ifdef BACAPP_PRINT_ENABLED
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
#endif
BACNET_PROPERTY_REFERENCE *listOfProperties;
BACNET_APPLICATION_DATA_VALUE *value;
#if PRINT_ENABLED
@@ -236,15 +239,19 @@ void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
array_value = false;
}
#endif
#ifdef BACAPP_PRINT_ENABLED
object_value.object_type = rpm_data->object_type;
object_value.object_instance = rpm_data->object_instance;
#endif
while (value) {
#ifdef BACAPP_PRINT_ENABLED
object_value.object_property =
listOfProperties->propertyIdentifier;
object_value.array_index =
listOfProperties->propertyArrayIndex;
object_value.value = value;
bacapp_print_value(stdout, &object_value);
#endif
#if PRINT_ENABLED
if (value->next) {
fprintf(stdout, ",\r\n ");
+6 -1
View File
@@ -109,7 +109,9 @@ void handler_read_range(uint8_t *service_request,
int pdu_len = 0;
BACNET_NPDU_DATA npdu_data;
bool error = false;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_ADDRESS my_address;
data.error_class = ERROR_CLASS_OBJECT;
@@ -180,7 +182,10 @@ void handler_read_range(uint8_t *service_request,
}
RR_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+7 -1
View File
@@ -42,13 +42,17 @@
/* for debugging... */
static void PrintReadRangeData(BACNET_READ_RANGE_DATA *data)
{
#ifdef BACAPP_PRINT_ENABLED
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
#endif
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
int len = 0;
uint8_t *application_data;
int application_data_len;
bool first_value = true;
#if PRINT_ENABLED
bool print_brace = false;
#endif
if (data) {
application_data = data->application_data;
@@ -62,15 +66,17 @@ static void PrintReadRangeData(BACNET_READ_RANGE_DATA *data)
first_value = false;
#if PRINT_ENABLED
fprintf(stdout, "{");
#endif
print_brace = true;
#endif
}
#ifdef BACAPP_PRINT_ENABLED
object_value.object_type = data->object_type;
object_value.object_instance = data->object_instance;
object_value.object_property = data->object_property;
object_value.array_index = data->array_index;
object_value.value = &value;
bacapp_print_value(stdout, &object_value);
#endif
if (len > 0) {
if (len < application_data_len) {
application_data += len;
+5 -2
View File
@@ -63,8 +63,8 @@ void handler_ucov_notification(
BACNET_PROPERTY_VALUE property_value[MAX_COV_PROPERTIES];
#if PRINT_ENABLED
BACNET_PROPERTY_VALUE *pProperty_value = NULL;
#endif
int len = 0;
#endif
/* src not needed for this application */
(void)src;
@@ -76,7 +76,10 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: Received Notification!\n");
#endif
/* decode the service request only */
len = cov_notify_decode_service_request(
#if PRINT_ENABLED
len =
#endif
cov_notify_decode_service_request(
service_request, service_len, &cov_data);
#if PRINT_ENABLED
if (len > 0) {
+7 -1
View File
@@ -41,13 +41,17 @@
void private_transfer_print_data(BACNET_PRIVATE_TRANSFER_DATA *private_data)
{
#ifdef BACAPP_PRINT_ENABLED
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
#endif
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
int len = 0;
uint8_t *application_data;
int application_data_len;
bool first_value = true;
#if PRINT_ENABLED
bool print_brace = false;
#endif
if (private_data) {
#if PRINT_ENABLED
@@ -65,16 +69,18 @@ void private_transfer_print_data(BACNET_PRIVATE_TRANSFER_DATA *private_data)
first_value = false;
#if PRINT_ENABLED
fprintf(stdout, "{");
#endif
print_brace = true;
#endif
}
/* private transfer doesn't provide any clues */
#ifdef BACAPP_PRINT_ENABLED
object_value.object_type = MAX_BACNET_OBJECT_TYPE;
object_value.object_instance = BACNET_MAX_INSTANCE;
object_value.object_property = MAX_BACNET_PROPERTY_ID;
object_value.array_index = BACNET_ARRAY_ALL;
object_value.value = &value;
bacapp_print_value(stdout, &object_value);
#endif
if (len > 0) {
if (len < application_data_len) {
application_data += len;
+1 -1
View File
@@ -43,7 +43,7 @@
*/
static void match_name_or_object(BACNET_WHO_HAS_DATA *data)
{
int object_type = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_NONE;
uint32_t object_instance = 0;
bool found = false;
BACNET_CHARACTER_STRING object_name;
+6 -1
View File
@@ -55,7 +55,9 @@ uint8_t Send_Alarm_Acknowledgement(
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
if (!dcc_communication_enabled()) {
@@ -85,7 +87,10 @@ uint8_t Send_Alarm_Acknowledgement(
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -55,7 +55,9 @@ uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_ATOMIC_READ_FILE_DATA data;
/* if we are forbidden to send, don't send! */
@@ -92,7 +94,10 @@ uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -55,7 +55,9 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_ATOMIC_WRITE_FILE_DATA data;
/* if we are forbidden to send, don't send! */
@@ -94,7 +96,10 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
if ((unsigned)pdu_len <= max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -50,7 +50,9 @@ uint8_t Send_CEvent_Notify(
{
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
@@ -86,7 +88,10 @@ uint8_t Send_CEvent_Notify(
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0) {
+6 -1
View File
@@ -64,7 +64,9 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id,
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_CHARACTER_STRING password_string;
BACNET_NPDU_DATA npdu_data;
@@ -98,7 +100,10 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id,
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+7 -2
View File
@@ -52,7 +52,9 @@ uint8_t Send_GetEvent(BACNET_ADDRESS *target_address,
{
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
uint8_t invoke_id = 0;
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -70,7 +72,10 @@ uint8_t Send_GetEvent(BACNET_ADDRESS *target_address,
len = getevent_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id,
lastReceivedObjectIdentifier);
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
target_address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
@@ -97,7 +102,7 @@ uint8_t Send_GetEvent_Global(void)
BACNET_ADDRESS dest;
if (!dcc_communication_enabled()) {
return -1;
return 0;
}
datalink_get_broadcast_address(&dest);
+6 -1
View File
@@ -55,7 +55,9 @@ uint8_t Send_Life_Safety_Operation_Data(
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
if (!dcc_communication_enabled()) {
@@ -85,7 +87,10 @@ uint8_t Send_Life_Safety_Operation_Data(
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -61,7 +61,9 @@ uint8_t Send_Reinitialize_Device_Request(
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_CHARACTER_STRING password_string;
BACNET_NPDU_DATA npdu_data;
@@ -95,7 +97,10 @@ uint8_t Send_Reinitialize_Device_Request(
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -54,7 +54,9 @@ uint8_t Send_ReadRange_Request(uint32_t device_id, /* destination device */
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
if (!dcc_communication_enabled()) {
@@ -91,7 +93,10 @@ uint8_t Send_ReadRange_Request(uint32_t device_id, /* destination device */
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -65,7 +65,9 @@ uint8_t Send_Read_Property_Multiple_Request(uint8_t *pdu,
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
if (!dcc_communication_enabled()) {
@@ -98,7 +100,10 @@ uint8_t Send_Read_Property_Multiple_Request(uint8_t *pdu,
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(
invoke_id, &dest, &npdu_data, &pdu[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
+12 -2
View File
@@ -54,7 +54,9 @@ void Send_TimeSync_Remote(
{
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -71,7 +73,10 @@ void Send_TimeSync_Remote(
len = timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], bdate, btime);
pdu_len += len;
/* send it out the datalink */
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
@@ -106,7 +111,9 @@ void Send_TimeSyncUTC_Remote(
{
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -123,7 +130,10 @@ void Send_TimeSyncUTC_Remote(
len = timesync_utc_encode_apdu(
&Handler_Transmit_Buffer[pdu_len], bdate, btime);
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+12 -2
View File
@@ -58,7 +58,9 @@ void Send_WhoHas_Name(
int len = 0;
int pdu_len = 0;
BACNET_ADDRESS dest;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_WHO_HAS_DATA data;
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -83,7 +85,10 @@ void Send_WhoHas_Name(
len = whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data);
pdu_len += len;
/* send the data */
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
@@ -111,7 +116,9 @@ void Send_WhoHas_Object(int32_t low_limit,
int len = 0;
int pdu_len = 0;
BACNET_ADDRESS dest;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_WHO_HAS_DATA data;
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -136,7 +143,10 @@ void Send_WhoHas_Object(int32_t low_limit,
data.object.identifier.instance = object_instance;
len = whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data);
pdu_len += len;
bytes_sent = datalink_send_pdu(
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
+6 -1
View File
@@ -68,7 +68,9 @@ uint8_t Send_Write_Property_Multiple_Request(uint8_t *pdu,
bool status = false;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
int bytes_sent = 0;
#endif
BACNET_NPDU_DATA npdu_data;
/* if we are forbidden to send, don't send! */
@@ -99,7 +101,10 @@ uint8_t Send_Write_Property_Multiple_Request(uint8_t *pdu,
if ((unsigned)pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(
invoke_id, &dest, &npdu_data, &pdu[0], (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
#if PRINT_ENABLED
bytes_sent =
#endif
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0) {
fprintf(stderr,