Bugfix/code clean using gcc warnings (#371)
* Enable extra GCC warnings to discover subtle bugs * convert c++ comments to c comments * cleanup pedantic compiler warnings * Compile apps with GNU89 GNU99 GNU11 and GNU17 Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -39,14 +39,10 @@
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/proplist.h"
|
||||
#include "bacnet/timestamp.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/object/ai.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
#ifndef MAX_ANALOG_INPUTS
|
||||
#define MAX_ANALOG_INPUTS 4
|
||||
|
||||
@@ -236,12 +236,14 @@ bool Analog_Value_Present_Value_Set(
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
|
||||
(void)priority;
|
||||
index = Analog_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_ANALOG_VALUES) {
|
||||
Analog_Value_COV_Detect(index, value);
|
||||
AV_Descr[index].Present_Value = value;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1136,6 +1138,8 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -657,6 +657,7 @@ int Channel_Value_Encode(
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
|
||||
(void)apdu_max;
|
||||
if (!apdu || !value) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -907,7 +908,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
if (value->type.Real != 0.0F) {
|
||||
if (islessgreater(value->type.Real, 0.0F)) {
|
||||
boolean_value = true;
|
||||
}
|
||||
apdu_len =
|
||||
@@ -954,7 +955,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
if (value->type.Double != 0.0) {
|
||||
if (islessgreater(value->type.Double, 0.0)) {
|
||||
boolean_value = true;
|
||||
}
|
||||
apdu_len =
|
||||
|
||||
@@ -820,4 +820,5 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
void Command_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
(void)object_instance;
|
||||
}
|
||||
|
||||
@@ -39,16 +39,9 @@
|
||||
#include "bacnet/basic/object/ao.h"
|
||||
#include "bacnet/wp.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
|
||||
#ifndef LOAD_CONTROL_DEBUG
|
||||
#define LOAD_CONTROL_DEBUG 0
|
||||
#endif
|
||||
#if LOAD_CONTROL_DEBUG
|
||||
#include <sys/PRINTF.h>
|
||||
#define PRINTF(...) printk(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_printf
|
||||
|
||||
/* number of demo objects */
|
||||
#ifndef MAX_LOAD_CONTROLS
|
||||
@@ -67,7 +60,7 @@ typedef enum BACnetShedLevelType {
|
||||
|
||||
#define DEFAULT_VALUE_PERCENT 100
|
||||
#define DEFAULT_VALUE_LEVEL 0
|
||||
#define DEFAULT_VALUE_AMOUNT 0
|
||||
#define DEFAULT_VALUE_AMOUNT 0.0
|
||||
|
||||
/* The shed levels for the LEVEL choice of BACnetShedLevel
|
||||
that have meaning for this particular Load Control object. */
|
||||
@@ -423,7 +416,7 @@ void Load_Control_State_Machine(int object_index)
|
||||
}
|
||||
break;
|
||||
case BACNET_SHED_TYPE_AMOUNT:
|
||||
if (Requested_Shed_Level[object_index].value.amount ==
|
||||
if (Requested_Shed_Level[object_index].value.amount <=
|
||||
DEFAULT_VALUE_AMOUNT) {
|
||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||
}
|
||||
@@ -431,7 +424,7 @@ void Load_Control_State_Machine(int object_index)
|
||||
case BACNET_SHED_TYPE_LEVEL:
|
||||
default:
|
||||
if (Requested_Shed_Level[object_index].value.level ==
|
||||
DEFAULT_VALUE_LEVEL) {
|
||||
DEFAULT_VALUE_LEVEL) {
|
||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1228,7 +1228,12 @@ static void Lighting_Output_Ramp_Handler(struct lighting_output_object *pLight,
|
||||
BACNET_LIGHTING_COMMAND *pCommand,
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
if (pLight && pCommand) { }
|
||||
if (pLight && pCommand) {
|
||||
/* FIXME: add ramp functionality */
|
||||
(void)pLight;
|
||||
(void)pCommand;
|
||||
(void)milliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1243,7 +1248,12 @@ static void Lighting_Output_Fade_Handler(struct lighting_output_object *pLight,
|
||||
BACNET_LIGHTING_COMMAND *pCommand,
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
if (pLight && pCommand) { }
|
||||
if (pLight && pCommand) {
|
||||
/* FIXME: add fade functionality */
|
||||
(void)pLight;
|
||||
(void)pCommand;
|
||||
(void)milliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,7 @@ bool Multistate_Input_Valid_Instance(uint32_t object_instance)
|
||||
|
||||
static uint32_t Multistate_Input_Max_States(uint32_t instance)
|
||||
{
|
||||
(void)instance;
|
||||
return MULTISTATE_NUMBER_OF_STATES;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,17 +43,13 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/event.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/wp.h"
|
||||
#include "bacnet/basic/object/nc.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
#ifndef MAX_NOTIFICATION_CLASSES
|
||||
#define MAX_NOTIFICATION_CLASSES 2
|
||||
@@ -747,8 +743,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
* &src); */
|
||||
}
|
||||
}
|
||||
|
||||
status = true;
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_NAME:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -2561,6 +2561,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
*/
|
||||
int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
{
|
||||
(void)apdu;
|
||||
(void)pRequest;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2574,6 +2576,8 @@ int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
*/
|
||||
int Network_Port_Read_Range_FDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
{
|
||||
(void)apdu;
|
||||
(void)pRequest;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@ bool OctetString_Value_Present_Value_Set(
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
|
||||
(void)priority;
|
||||
index = OctetString_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_OCTETSTRING_VALUES) {
|
||||
octetstring_copy(&OSV_Descr[index].Present_Value, value);
|
||||
@@ -354,4 +355,5 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
void OctetString_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
(void)object_instance;
|
||||
}
|
||||
|
||||
@@ -140,11 +140,13 @@ bool PositiveInteger_Value_Present_Value_Set(
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
|
||||
(void)priority;
|
||||
index = PositiveInteger_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_POSITIVEINTEGER_VALUES) {
|
||||
PIV_Descr[index].Present_Value = value;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -359,4 +361,5 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
void PositiveInteger_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
(void)object_instance;
|
||||
}
|
||||
|
||||
@@ -1498,6 +1498,9 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
||||
case TL_TYPE_ANY:
|
||||
/* Should never happen as we don't support this at the moment */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
iLen += encode_closing_tag(&apdu[iLen], 1);
|
||||
|
||||
@@ -39,14 +39,10 @@
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
|
||||
/** @file h_ccov.c Handles Confirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
/* max number of COV properties decoded in a COV notification */
|
||||
#ifndef MAX_COV_PROPERTIES
|
||||
|
||||
@@ -65,6 +65,8 @@ void get_alarm_summary_ack_handler(uint8_t *service_request,
|
||||
uint16_t len = 0;
|
||||
BACNET_GET_ALARM_SUMMARY_DATA data;
|
||||
|
||||
(void)src;
|
||||
(void)service_data;
|
||||
while (service_len - len) {
|
||||
apdu_len = get_alarm_summary_ack_decode_apdu_data(
|
||||
&service_request[len], service_len - len, &data);
|
||||
|
||||
@@ -67,6 +67,8 @@ void handler_get_alarm_summary(uint8_t *service_request,
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
BACNET_GET_ALARM_SUMMARY_DATA getalarm_data;
|
||||
|
||||
(void)service_request;
|
||||
(void)service_len;
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
@@ -51,11 +51,11 @@ static get_event_info_function Get_Event_Info[MAX_BACNET_OBJECT_TYPE];
|
||||
void ge_ack_print_data(
|
||||
BACNET_GET_EVENT_INFORMATION_DATA *data, uint32_t device_id)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
BACNET_GET_EVENT_INFORMATION_DATA *act_data = data;
|
||||
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
|
||||
printf("DeviceID\tType\tInstance\teventState\n");
|
||||
printf("--------------- ------- --------------- ---------------\n");
|
||||
unsigned int count = 0;
|
||||
while (act_data) {
|
||||
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
|
||||
act_data->objectIdentifier.type,
|
||||
|
||||
@@ -72,6 +72,8 @@ void get_event_ack_handler(uint8_t *service_request,
|
||||
multiple get event data in APDU */
|
||||
BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS];
|
||||
|
||||
(void)src;
|
||||
(void)service_data;
|
||||
for (i = 1; i < MAX_NUMBER_OF_EVENTS; i++) {
|
||||
/* Create linked list */
|
||||
get_event_data[i - 1].next = &get_event_data[i];
|
||||
|
||||
@@ -38,15 +38,10 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
#endif
|
||||
#define PRINTF debug_aprintf
|
||||
#define PRINTF_ERR debug_perror
|
||||
|
||||
/** @file h_rp_a.c Handles Read Property Acknowledgments. */
|
||||
|
||||
|
||||
@@ -37,16 +37,11 @@
|
||||
/* some demo stuff needed */
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
#endif
|
||||
#define PRINTF debug_aprintf
|
||||
#define PERROR debug_perror
|
||||
|
||||
/** @file h_rpm_a.c Handles Read Property Multiple Acknowledgments. */
|
||||
|
||||
@@ -130,7 +125,7 @@ int rpm_ack_decode_service_request(
|
||||
/* If len == 0 then it's an empty structure, which is OK. */
|
||||
if (len < 0) {
|
||||
/* problem decoding */
|
||||
PRINTF_ERR("RPM Ack: unable to decode! %s:%s\n",
|
||||
PERROR("RPM Ack: unable to decode! %s:%s\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier));
|
||||
@@ -151,7 +146,7 @@ int rpm_ack_decode_service_request(
|
||||
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
old_value->next = value;
|
||||
} else {
|
||||
PRINTF_ERR("RPM Ack: decoded %s:%s len=%d\n",
|
||||
PERROR("RPM Ack: decoded %s:%s len=%d\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier),
|
||||
@@ -362,7 +357,7 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
}
|
||||
} else {
|
||||
PRINTF_ERR("RPM Ack Malformed! Freeing memory...\n");
|
||||
PERROR("RPM Ack Malformed! Freeing memory...\n");
|
||||
while (rpm_data) {
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
}
|
||||
|
||||
@@ -36,15 +36,11 @@
|
||||
#include "bacnet/cov.h"
|
||||
#include "bacnet/bactext.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
|
||||
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
#ifndef MAX_COV_PROPERTIES
|
||||
#define MAX_COV_PROPERTIES 2
|
||||
|
||||
@@ -111,6 +111,7 @@ void handler_unconfirmed_private_transfer(
|
||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||
int len = 0;
|
||||
|
||||
(void)src;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
|
||||
#endif
|
||||
|
||||
@@ -41,15 +41,11 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
/** @file h_wpm.c Handles Write Property Multiple requests. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
/** Decoding for an object property.
|
||||
*
|
||||
|
||||
@@ -38,16 +38,12 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
/** Sends an Confirmed Alarm Acknowledgment.
|
||||
*
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
#include "bacnet/basic/sys/bigend.h"
|
||||
|
||||
#ifndef BACNET_BIG_ENDIAN
|
||||
#ifdef BACNET_BIG_ENDIAN
|
||||
/* workaround: warning: ISO C forbids an empty translation unit [-Wpedantic] */
|
||||
typedef int make_iso_compilers_happy;
|
||||
#else
|
||||
/* Big-Endian systems save the most significant byte first. */
|
||||
/* Sun and Motorola processors, IBM-370s and PDP-10s are big-endian. */
|
||||
/* "Network Byte Order" is also know as "Big-Endian Byte Order" */
|
||||
|
||||
@@ -50,6 +50,8 @@ void color_rgb_to_xy(uint8_t r,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness)
|
||||
{
|
||||
float X, Y, Z;
|
||||
float x, y;
|
||||
/* Get the RGB values from your color object
|
||||
and convert them to be between 0 and 1.
|
||||
So the RGB color (255, 0, 100) becomes (1.0, 0.0, 0.39) */
|
||||
@@ -76,13 +78,13 @@ void color_rgb_to_xy(uint8_t r,
|
||||
|
||||
/* Convert the RGB values to XYZ using the
|
||||
Wide RGB D65 conversion formula */
|
||||
float X = red * 0.649926f + green * 0.103455f + blue * 0.197109f;
|
||||
float Y = red * 0.234327f + green * 0.743075f + blue * 0.022598f;
|
||||
float Z = red * 0.0000000f + green * 0.053077f + blue * 1.035763f;
|
||||
X = red * 0.649926f + green * 0.103455f + blue * 0.197109f;
|
||||
Y = red * 0.234327f + green * 0.743075f + blue * 0.022598f;
|
||||
Z = red * 0.0000000f + green * 0.053077f + blue * 1.035763f;
|
||||
|
||||
/* Calculate the xy values from the XYZ values */
|
||||
float x = X / (X + Y + Z);
|
||||
float y = Y / (X + Y + Z);
|
||||
x = X / (X + Y + Z);
|
||||
y = Y / (X + Y + Z);
|
||||
|
||||
x = clamp(x, 0.0f, 1.0f);
|
||||
y = clamp(y, 0.0f, 1.0f);
|
||||
@@ -122,20 +124,23 @@ void color_rgb_from_xy(uint8_t *red,
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
float r, g, b;
|
||||
float x, y, z, X, Y, Z;
|
||||
|
||||
/* Calculate XYZ values */
|
||||
float x = x_coordinate;
|
||||
float y = y_coordinate;
|
||||
float z = 1.0f - x - y;
|
||||
float Y = (float)brightness;
|
||||
x = x_coordinate;
|
||||
y = y_coordinate;
|
||||
z = 1.0f - x - y;
|
||||
Y = (float)brightness;
|
||||
Y /= 255.0f;
|
||||
float X = (Y / y) * x;
|
||||
float Z = (Y / y) * z;
|
||||
X = x * (Y / y);
|
||||
Z = z * (Y / y);
|
||||
|
||||
/* Convert to RGB using Wide RGB D65 conversion
|
||||
(THIS IS A D50 conversion currently) */
|
||||
float r = X * 1.4628067f - Y * 0.1840623f - Z * 0.2743606f;
|
||||
float g = -X * 0.5217933f + Y * 1.4472381f + Z * 0.0677227f;
|
||||
float b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||
r = X * 1.4628067f - Y * 0.1840623f - Z * 0.2743606f;
|
||||
g = -X * 0.5217933f + Y * 1.4472381f + Z * 0.0677227f;
|
||||
b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||
|
||||
/* Apply reverse gamma correction */
|
||||
r = r <= 0.0031308f ? 12.92f * r
|
||||
|
||||
@@ -59,3 +59,59 @@ void debug_printf(const char *format, ...)
|
||||
(void)format;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PRINT_ENABLED
|
||||
int debug_aprintf(const char *format, ...)
|
||||
{
|
||||
int length = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
length = vfprintf(stdout, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stdout);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
int debug_fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
int length = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
length = vfprintf(stream, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stream);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void debug_perror(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stderr);
|
||||
}
|
||||
#else
|
||||
int debug_aprintf(const char *format, ...)
|
||||
{
|
||||
(void)format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int debug_fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
(void)stream;
|
||||
(void)format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void debug_perror(const char *format, ...)
|
||||
{
|
||||
(void)format;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -42,6 +42,19 @@ extern "C" {
|
||||
void debug_printf(
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
int debug_aprintf(
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
int debug_fprintf(
|
||||
FILE *stream,
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
void debug_perror(
|
||||
const char *format,
|
||||
...);
|
||||
#if DEBUG_ENABLED
|
||||
/* Nothing more here */
|
||||
#else
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
#ifndef BACNET_SYS_PLATFORM_H
|
||||
#define BACNET_SYS_PLATFORM_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef islessgreater
|
||||
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
|
||||
#endif
|
||||
|
||||
/* marking some code as 'deprecated' */
|
||||
# if defined(_MSC_VER)
|
||||
# define BACNET_STACK_DEPRECATED(message) __declspec(deprecated(message))
|
||||
@@ -31,4 +37,10 @@
|
||||
# define strcasecmp _stricmp
|
||||
# endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define BACNET_STACK_FALLTHROUGH() __attribute__ ((fallthrough))
|
||||
#else
|
||||
#define BACNET_STACK_FALLTHROUGH() /* fall through */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user