Bugfix/double float promotion warnings (#605)
* Fixed compile warnings from double-float promotions. * Changed zephyr compile to suppress deprecation warnings * Fixed CreateObject API return value in many objects header files * Changed zephyr build defines as strdup is no longer required for log print of strings
This commit is contained in:
@@ -153,7 +153,7 @@ extern "C" {
|
||||
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data);
|
||||
#endif
|
||||
|
||||
bool Analog_Input_Create(
|
||||
uint32_t Analog_Input_Create(
|
||||
uint32_t object_instance);
|
||||
bool Analog_Input_Delete(
|
||||
uint32_t object_instance);
|
||||
|
||||
@@ -122,7 +122,7 @@ extern "C" {
|
||||
bool Binary_Output_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
bool Binary_Output_Create(
|
||||
uint32_t Binary_Output_Create(
|
||||
uint32_t object_instance);
|
||||
bool Binary_Output_Delete(
|
||||
uint32_t object_instance);
|
||||
|
||||
@@ -116,7 +116,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Credential_Create(
|
||||
uint32_t Access_Credential_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Credential_Delete(
|
||||
|
||||
@@ -148,7 +148,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Door_Create(
|
||||
uint32_t Access_Door_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Door_Delete(
|
||||
|
||||
@@ -113,7 +113,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Point_Create(
|
||||
uint32_t Access_Point_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Point_Delete(
|
||||
|
||||
@@ -101,7 +101,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Rights_Create(
|
||||
uint32_t Access_Rights_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Rights_Delete(
|
||||
|
||||
@@ -94,7 +94,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_User_Create(
|
||||
uint32_t Access_User_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_User_Delete(
|
||||
|
||||
@@ -109,7 +109,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Zone_Create(
|
||||
uint32_t Access_Zone_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Access_Zone_Delete(
|
||||
|
||||
@@ -81,6 +81,34 @@ void Analog_Input_Property_Lists(
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if the object property is a member of this object instance
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param object_property - object-property to be checked
|
||||
* @return true if the property is a member of this object instance
|
||||
*/
|
||||
static bool Property_List_Member(
|
||||
uint32_t object_instance, int object_property)
|
||||
{
|
||||
bool found = false;
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
|
||||
(void)object_instance;
|
||||
Analog_Input_Property_Lists(
|
||||
&pRequired, &pOptional, &pProprietary);
|
||||
found = property_list_member(pRequired, object_property);
|
||||
if (!found) {
|
||||
found = property_list_member(pOptional, object_property);
|
||||
}
|
||||
if (!found) {
|
||||
found = property_list_member(pProprietary, object_property);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
void Analog_Input_Init(void)
|
||||
{
|
||||
unsigned i;
|
||||
@@ -166,7 +194,7 @@ unsigned Analog_Input_Instance_To_Index(uint32_t object_instance)
|
||||
|
||||
float Analog_Input_Present_Value(uint32_t object_instance)
|
||||
{
|
||||
float value = 0.0;
|
||||
float value = 0.0f;
|
||||
unsigned int index;
|
||||
|
||||
index = Analog_Input_Instance_To_Index(object_instance);
|
||||
@@ -179,9 +207,9 @@ float Analog_Input_Present_Value(uint32_t object_instance)
|
||||
|
||||
static void Analog_Input_COV_Detect(unsigned int index, float value)
|
||||
{
|
||||
float prior_value = 0.0;
|
||||
float cov_increment = 0.0;
|
||||
float cov_delta = 0.0;
|
||||
float prior_value = 0.0f;
|
||||
float cov_increment = 0.0f;
|
||||
float cov_delta = 0.0f;
|
||||
|
||||
if (index < MAX_ANALOG_INPUTS) {
|
||||
prior_value = AI_Descr[index].Prior_Value;
|
||||
@@ -274,6 +302,8 @@ unsigned Analog_Input_Event_State(uint32_t object_instance)
|
||||
if (index < MAX_ANALOG_INPUTS) {
|
||||
state = AI_Descr[index].Event_State;
|
||||
}
|
||||
#else
|
||||
(void)object_instance;
|
||||
#endif
|
||||
|
||||
return state;
|
||||
@@ -352,7 +382,7 @@ bool Analog_Input_Encode_Value_List(
|
||||
bool out_of_service = false;
|
||||
const bool fault = false;
|
||||
const bool overridden = false;
|
||||
float present_value = 0.0;
|
||||
float present_value = 0.0f;
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
|
||||
index = Analog_Input_Instance_To_Index(object_instance);
|
||||
@@ -773,7 +803,7 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (value.type.Real >= 0.0) {
|
||||
if (value.type.Real >= 0.0f) {
|
||||
Analog_Input_COV_Increment_Set(
|
||||
wp_data->object_instance, value.type.Real);
|
||||
} else {
|
||||
@@ -874,26 +904,15 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_OBJECT_TYPE:
|
||||
case PROP_STATUS_FLAGS:
|
||||
case PROP_EVENT_STATE:
|
||||
case PROP_DESCRIPTION:
|
||||
case PROP_RELIABILITY:
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_ACKED_TRANSITIONS:
|
||||
case PROP_EVENT_TIME_STAMPS:
|
||||
#endif
|
||||
case 9997:
|
||||
case 9998:
|
||||
case 9999:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
default:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
if (Property_List_Member(
|
||||
wp_data->object_instance, wp_data->object_property)) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Input_Create(
|
||||
uint32_t Analog_Input_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Input_Delete(
|
||||
|
||||
@@ -86,6 +86,34 @@ void Analog_Value_Property_Lists(
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if the object property is a member of this object instance
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param object_property - object-property to be checked
|
||||
* @return true if the property is a member of this object instance
|
||||
*/
|
||||
static bool Property_List_Member(
|
||||
uint32_t object_instance, int object_property)
|
||||
{
|
||||
bool found = false;
|
||||
const int *pRequired = NULL;
|
||||
const int *pOptional = NULL;
|
||||
const int *pProprietary = NULL;
|
||||
|
||||
(void)object_instance;
|
||||
Analog_Value_Property_Lists(
|
||||
&pRequired, &pOptional, &pProprietary);
|
||||
found = property_list_member(pRequired, object_property);
|
||||
if (!found) {
|
||||
found = property_list_member(pOptional, object_property);
|
||||
}
|
||||
if (!found) {
|
||||
found = property_list_member(pProprietary, object_property);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the analog values.
|
||||
*/
|
||||
@@ -98,7 +126,7 @@ void Analog_Value_Init(void)
|
||||
|
||||
for (i = 0; i < MAX_ANALOG_VALUES; i++) {
|
||||
memset(&AV_Descr[i], 0x00, sizeof(ANALOG_VALUE_DESCR));
|
||||
AV_Descr[i].Present_Value = 0.0;
|
||||
AV_Descr[i].Present_Value = 0.0f;
|
||||
AV_Descr[i].Units = UNITS_NO_UNITS;
|
||||
AV_Descr[i].Prior_Value = 0.0f;
|
||||
AV_Descr[i].COV_Increment = 1.0f;
|
||||
@@ -201,9 +229,9 @@ unsigned Analog_Value_Instance_To_Index(uint32_t object_instance)
|
||||
*/
|
||||
static void Analog_Value_COV_Detect(unsigned int index, float value)
|
||||
{
|
||||
float prior_value = 0.0;
|
||||
float cov_increment = 0.0;
|
||||
float cov_delta = 0.0;
|
||||
float prior_value = 0.0f;
|
||||
float cov_increment = 0.0f;
|
||||
float cov_delta = 0.0f;
|
||||
|
||||
if (index < MAX_ANALOG_VALUES) {
|
||||
prior_value = AV_Descr[index].Prior_Value;
|
||||
@@ -332,6 +360,8 @@ unsigned Analog_Value_Event_State(uint32_t object_instance)
|
||||
if (index < MAX_ANALOG_VALUES) {
|
||||
state = AV_Descr[index].Event_State;
|
||||
}
|
||||
#else
|
||||
(void)object_instance;
|
||||
#endif
|
||||
|
||||
return state;
|
||||
@@ -894,7 +924,7 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (value.type.Real >= 0.0) {
|
||||
if (value.type.Real >= 0.0f) {
|
||||
Analog_Value_COV_Increment_Set(
|
||||
wp_data->object_instance, value.type.Real);
|
||||
} else {
|
||||
@@ -995,24 +1025,15 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_OBJECT_TYPE:
|
||||
case PROP_STATUS_FLAGS:
|
||||
case PROP_EVENT_STATE:
|
||||
case PROP_DESCRIPTION:
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_ACKED_TRANSITIONS:
|
||||
case PROP_EVENT_TIME_STAMPS:
|
||||
#endif
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
case PROP_RELINQUISH_DEFAULT:
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
default:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
if (Property_List_Member(
|
||||
wp_data->object_instance, wp_data->object_property)) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Value_Create(
|
||||
uint32_t Analog_Value_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Value_Delete(
|
||||
|
||||
@@ -144,7 +144,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Binary_Input_Create(
|
||||
uint32_t Binary_Input_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Binary_Input_Delete(
|
||||
|
||||
@@ -173,7 +173,7 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
BACNET_POLARITY polarity);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Binary_Value_Create(
|
||||
uint32_t Binary_Value_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Binary_Value_Delete(
|
||||
|
||||
@@ -110,7 +110,7 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Credential_Data_Input_Create(
|
||||
uint32_t Credential_Data_Input_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Credential_Data_Input_Delete(
|
||||
|
||||
@@ -137,7 +137,7 @@ extern "C" {
|
||||
uint32_t state_index);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Multistate_Input_Create(
|
||||
uint32_t Multistate_Input_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Multistate_Input_Delete(
|
||||
|
||||
@@ -128,7 +128,7 @@ extern "C" {
|
||||
uint32_t state_index);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Multistate_Value_Create(
|
||||
uint32_t Multistate_Value_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Multistate_Value_Delete(
|
||||
|
||||
@@ -401,7 +401,7 @@ extern "C" {
|
||||
RR_PROP_INFO * pInfo);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Network_Port_Create(
|
||||
uint32_t Network_Port_Create(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Network_Port_Delete(
|
||||
|
||||
@@ -89,10 +89,10 @@ float linear_interpolate_round(float x1,
|
||||
|
||||
y2 = linear_interpolate(x1, x2, x3, y1, y3);
|
||||
/* round away from zero */
|
||||
if (y2 > 0.0) {
|
||||
y2 += 0.5;
|
||||
} else if (y2 < 0.0) {
|
||||
y2 -= 0.5;
|
||||
if (y2 > 0.0f) {
|
||||
y2 += 0.5f;
|
||||
} else if (y2 < 0.0f) {
|
||||
y2 -= 0.5f;
|
||||
}
|
||||
|
||||
return y2;
|
||||
|
||||
@@ -497,7 +497,8 @@ int lighting_command_to_ascii(
|
||||
priority = value->priority;
|
||||
}
|
||||
len = snprintf(buf, buf_size, "%u,%f,%lu,%u", value->operation,
|
||||
target_level, (unsigned long)fade_time, (unsigned)priority);
|
||||
(float)target_level, (unsigned long)fade_time,
|
||||
(unsigned)priority);
|
||||
break;
|
||||
case BACNET_LIGHTS_RAMP_TO:
|
||||
if (value->use_target_level) {
|
||||
@@ -510,8 +511,8 @@ int lighting_command_to_ascii(
|
||||
priority = value->priority;
|
||||
}
|
||||
len = snprintf(buf, buf_size, "%u,%f,%f,%u",
|
||||
(unsigned)value->operation, target_level, ramp_rate,
|
||||
(unsigned)priority);
|
||||
(unsigned)value->operation, (float)target_level,
|
||||
(float)ramp_rate, (unsigned)priority);
|
||||
break;
|
||||
case BACNET_LIGHTS_STEP_UP:
|
||||
case BACNET_LIGHTS_STEP_DOWN:
|
||||
@@ -524,7 +525,8 @@ int lighting_command_to_ascii(
|
||||
priority = value->priority;
|
||||
}
|
||||
len = snprintf(buf, buf_size, "%u,%f,%u",
|
||||
(unsigned)value->operation, step_increment, (unsigned)priority);
|
||||
(unsigned)value->operation, (float)step_increment,
|
||||
(unsigned)priority);
|
||||
break;
|
||||
case BACNET_LIGHTS_WARN:
|
||||
case BACNET_LIGHTS_WARN_OFF:
|
||||
@@ -943,7 +945,8 @@ bool xy_color_same(BACNET_XY_COLOR *value1, BACNET_XY_COLOR *value2)
|
||||
int xy_color_to_ascii(const BACNET_XY_COLOR *value, char *buf, size_t buf_size)
|
||||
{
|
||||
return snprintf(
|
||||
buf, buf_size, "(%f,%f)", value->x_coordinate, value->x_coordinate);
|
||||
buf, buf_size, "(%f,%f)", (float)value->x_coordinate,
|
||||
(float)value->x_coordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
|
||||
@@ -50,6 +50,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/proplist.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#
|
||||
|
||||
zephyr_compile_definitions(
|
||||
_POSIX_C_SOURCE=200809 # Expose `strdup()` for bacfile, ao, bo, mso
|
||||
CONFIG_NEWLIB_LIBC # Choose library providing `strdup()` impl.
|
||||
BACNET_STACK_DEPRECATED_DISABLE
|
||||
)
|
||||
|
||||
zephyr_sources(device.c)
|
||||
|
||||
@@ -46,6 +46,7 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/bactext.c
|
||||
${BACNET_SRC}/indtext.c
|
||||
${BACNET_SRC}/lighting.c
|
||||
${BACNET_SRC}/proplist.c
|
||||
${BACNET_SRC}/wp.c
|
||||
${BACNET_SRC}/cov.c
|
||||
${BACNET_SRC}/memcopy.c
|
||||
|
||||
@@ -46,6 +46,7 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/bactext.c
|
||||
${BACNET_SRC}/indtext.c
|
||||
${BACNET_SRC}/lighting.c
|
||||
${BACNET_SRC}/proplist.c
|
||||
${BACNET_SRC}/wp.c
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
|
||||
Reference in New Issue
Block a user