Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -1,38 +1,37 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2020 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
*
|
||||
* Copyright (C) 2020 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef BACNET_STACK_EXPORTS_H
|
||||
#define BACNET_STACK_EXPORTS_H
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
|
||||
#ifdef BACNET_STACK_STATIC_DEFINE
|
||||
/* We want a static library */
|
||||
# define BACNET_STACK_EXPORT
|
||||
/* We want a static library */
|
||||
#define BACNET_STACK_EXPORT
|
||||
#else
|
||||
/* We want a shared library */
|
||||
# ifdef _MSC_VER
|
||||
# define BACNET_STACK_LIBRARY_IMPORT __declspec(dllimport)
|
||||
# define BACNET_STACK_LIBRARY_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define BACNET_STACK_LIBRARY_IMPORT
|
||||
# define BACNET_STACK_LIBRARY_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
/* We want a shared library */
|
||||
#ifdef _MSC_VER
|
||||
#define BACNET_STACK_LIBRARY_IMPORT __declspec(dllimport)
|
||||
#define BACNET_STACK_LIBRARY_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define BACNET_STACK_LIBRARY_IMPORT
|
||||
#define BACNET_STACK_LIBRARY_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BACNET_STACK_EXPORT
|
||||
# ifdef bacnet_stack_EXPORTS
|
||||
/* We are building this library */
|
||||
# define BACNET_STACK_EXPORT BACNET_STACK_LIBRARY_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define BACNET_STACK_EXPORT BACNET_STACK_LIBRARY_IMPORT
|
||||
# endif
|
||||
#ifdef bacnet_stack_EXPORTS
|
||||
/* We are building this library */
|
||||
#define BACNET_STACK_EXPORT BACNET_STACK_LIBRARY_EXPORT
|
||||
#else
|
||||
/* We are using this library */
|
||||
#define BACNET_STACK_EXPORT BACNET_STACK_LIBRARY_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* BACNET_STACK_EXPORTS_H */
|
||||
#endif /* BACNET_STACK_EXPORTS_H */
|
||||
|
||||
@@ -13,24 +13,23 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#ifndef BACNET_BIG_ENDIAN
|
||||
/* GCC */
|
||||
#ifdef __BYTE_ORDER__
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define BACNET_BIG_ENDIAN 1
|
||||
#else
|
||||
#define BACNET_BIG_ENDIAN 0
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef BACNET_BIG_ENDIAN
|
||||
/* GCC */
|
||||
#ifdef __BYTE_ORDER__
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define BACNET_BIG_ENDIAN 1
|
||||
#else
|
||||
#define BACNET_BIG_ENDIAN 0
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BACNET_BIG_ENDIAN
|
||||
#define big_endian() BACNET_BIG_ENDIAN
|
||||
#else
|
||||
BACNET_STACK_EXPORT
|
||||
int big_endian(
|
||||
void);
|
||||
#endif
|
||||
#ifdef BACNET_BIG_ENDIAN
|
||||
#define big_endian() BACNET_BIG_ENDIAN
|
||||
#else
|
||||
BACNET_STACK_EXPORT
|
||||
int big_endian(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+12
-12
@@ -9,41 +9,41 @@
|
||||
#define BACNET_SYS_BITS_H
|
||||
|
||||
/********************************************************************
|
||||
* Bit Masks
|
||||
*********************************************************************/
|
||||
* Bit Masks
|
||||
*********************************************************************/
|
||||
#ifndef BIT
|
||||
#define BIT(x) (1<<(x))
|
||||
#define BIT(x) (1 << (x))
|
||||
#endif
|
||||
#ifndef _BV
|
||||
#define _BV(x) (1<<(x))
|
||||
#define _BV(x) (1 << (x))
|
||||
#endif
|
||||
|
||||
/* a=register, b=bit number to act upon 0-n */
|
||||
#ifndef BIT_SET
|
||||
#define BIT_SET(a,b) ((a) |= (1<<(b)))
|
||||
#define BIT_SET(a, b) ((a) |= (1 << (b)))
|
||||
#endif
|
||||
#ifndef BIT_CLEAR
|
||||
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
|
||||
#define BIT_CLEAR(a, b) ((a) &= ~(1 << (b)))
|
||||
#endif
|
||||
#ifndef BIT_FLIP
|
||||
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
|
||||
#define BIT_FLIP(a, b) ((a) ^= (1 << (b)))
|
||||
#endif
|
||||
#ifndef BIT_CHECK
|
||||
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
|
||||
#define BIT_CHECK(a, b) ((a) & (1 << (b)))
|
||||
#endif
|
||||
|
||||
/* x=target variable, y=mask */
|
||||
#ifndef BITMASK_SET
|
||||
#define BITMASK_SET(x,y) ((x) |= (y))
|
||||
#define BITMASK_SET(x, y) ((x) |= (y))
|
||||
#endif
|
||||
#ifndef BITMASK_CLEAR
|
||||
#define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
|
||||
#define BITMASK_CLEAR(x, y) ((x) &= (~(y)))
|
||||
#endif
|
||||
#ifndef BITMASK_FLIP
|
||||
#define BITMASK_FLIP(x,y) ((x) ^= (y))
|
||||
#define BITMASK_FLIP(x, y) ((x) ^= (y))
|
||||
#endif
|
||||
#ifndef BITMASK_CHECK
|
||||
#define BITMASK_CHECK(x,y) (((x) & (y)) == (y))
|
||||
#define BITMASK_CHECK(x, y) (((x) & (y)) == (y))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef LO_NIB
|
||||
#define LO_NIB(b) ((b)&0xF)
|
||||
#define LO_NIB(b) ((b) & 0xF)
|
||||
#endif
|
||||
|
||||
#ifndef HI_NIB
|
||||
|
||||
@@ -41,7 +41,8 @@ static double clamp(double d, double min, double max)
|
||||
* @param gamma_correction - true if gamma correction is applied
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
static void color_rgb_to_xy_gamma_correction(uint8_t r,
|
||||
static void color_rgb_to_xy_gamma_correction(
|
||||
uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
@@ -121,15 +122,16 @@ static void color_rgb_to_xy_gamma_correction(uint8_t r,
|
||||
* @param brightness - return brightness of the CIE xy color 0..255
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_to_xy(uint8_t r,
|
||||
void color_rgb_to_xy(
|
||||
uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness)
|
||||
{
|
||||
color_rgb_to_xy_gamma_correction(r, g, b,
|
||||
x_coordinate, y_coordinate, brightness, false);
|
||||
color_rgb_to_xy_gamma_correction(
|
||||
r, g, b, x_coordinate, y_coordinate, brightness, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,15 +144,16 @@ void color_rgb_to_xy(uint8_t r,
|
||||
* @param brightness - return brightness of the CIE xy color 0..255
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_to_xy_gamma(uint8_t r,
|
||||
void color_rgb_to_xy_gamma(
|
||||
uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness)
|
||||
{
|
||||
color_rgb_to_xy_gamma_correction(r, g, b,
|
||||
x_coordinate, y_coordinate, brightness, true);
|
||||
color_rgb_to_xy_gamma_correction(
|
||||
r, g, b, x_coordinate, y_coordinate, brightness, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +167,8 @@ void color_rgb_to_xy_gamma(uint8_t r,
|
||||
* @param gamma_correction - true if gamma correction is needed
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
static void color_rgb_from_xy_gamma_correction(uint8_t *red,
|
||||
static void color_rgb_from_xy_gamma_correction(
|
||||
uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
@@ -234,15 +238,16 @@ static void color_rgb_from_xy_gamma_correction(uint8_t *red,
|
||||
* @param brightness - brightness of the CIE xy color
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_from_xy(uint8_t *red,
|
||||
void color_rgb_from_xy(
|
||||
uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
color_rgb_from_xy_gamma_correction(red, green, blue,
|
||||
x_coordinate, y_coordinate, brightness, false);
|
||||
color_rgb_from_xy_gamma_correction(
|
||||
red, green, blue, x_coordinate, y_coordinate, brightness, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,15 +260,16 @@ void color_rgb_from_xy(uint8_t *red,
|
||||
* @param brightness - brightness of the CIE xy color
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_from_xy_gamma(uint8_t *red,
|
||||
void color_rgb_from_xy_gamma(
|
||||
uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
color_rgb_from_xy_gamma_correction(red, green, blue,
|
||||
x_coordinate, y_coordinate, brightness, true);
|
||||
color_rgb_from_xy_gamma_correction(
|
||||
red, green, blue, x_coordinate, y_coordinate, brightness, true);
|
||||
}
|
||||
|
||||
/* table for converting RGB to and from ASCII color names */
|
||||
@@ -274,80 +280,154 @@ struct css_color_rgb {
|
||||
uint8_t blue;
|
||||
};
|
||||
static struct css_color_rgb CSS_Color_RGB_Table[] = {
|
||||
{ "aliceblue", 240, 248, 255 }, { "antiquewhite", 250, 235, 215 },
|
||||
{ "aqua", 0, 255, 255 }, { "aquamarine", 127, 255, 212 },
|
||||
{ "azure", 240, 255, 255 }, { "beige", 245, 245, 220 },
|
||||
{ "bisque", 255, 228, 196 }, { "black", 0, 0, 0 },
|
||||
{ "blanchedalmond", 255, 235, 205 }, { "blue", 0, 0, 255 },
|
||||
{ "blueviolet", 138, 43, 226 }, { "brown", 165, 42, 42 },
|
||||
{ "burlywood", 222, 184, 135 }, { "cadetblue", 95, 158, 160 },
|
||||
{ "chartreuse", 127, 255, 0 }, { "chocolate", 210, 105, 30 },
|
||||
{ "coral", 255, 127, 80 }, { "cornflowerblue", 100, 149, 237 },
|
||||
{ "cornsilk", 255, 248, 220 }, { "crimson", 220, 20, 60 },
|
||||
{ "cyan", 0, 255, 255 }, { "darkblue", 0, 0, 139 },
|
||||
{ "darkcyan", 0, 139, 139 }, { "darkgoldenrod", 184, 134, 11 },
|
||||
{ "darkgray", 169, 169, 169 }, { "darkgreen", 0, 100, 0 },
|
||||
{ "darkgrey", 169, 169, 169 }, { "darkkhaki", 189, 183, 107 },
|
||||
{ "darkmagenta", 139, 0, 139 }, { "darkolivegreen", 85, 107, 47 },
|
||||
{ "darkorange", 255, 140, 0 }, { "darkorchid", 153, 50, 204 },
|
||||
{ "darkred", 139, 0, 0 }, { "darksalmon", 233, 150, 122 },
|
||||
{ "darkseagreen", 143, 188, 143 }, { "darkslateblue", 72, 61, 139 },
|
||||
{ "darkslategray", 47, 79, 79 }, { "darkslategrey", 47, 79, 79 },
|
||||
{ "darkturquoise", 0, 206, 209 }, { "darkviolet", 148, 0, 211 },
|
||||
{ "deeppink", 255, 20, 147 }, { "deepskyblue", 0, 191, 255 },
|
||||
{ "dimgray", 105, 105, 105 }, { "dimgrey", 105, 105, 105 },
|
||||
{ "dodgerblue", 30, 144, 255 }, { "firebrick", 178, 34, 34 },
|
||||
{ "floralwhite", 255, 250, 240 }, { "forestgreen", 34, 139, 34 },
|
||||
{ "fuchsia", 255, 0, 255 }, { "gainsboro", 220, 220, 220 },
|
||||
{ "ghostwhite", 248, 248, 255 }, { "gold", 255, 215, 0 },
|
||||
{ "goldenrod", 218, 165, 32 }, { "gray", 128, 128, 128 },
|
||||
{ "green", 0, 128, 0 }, { "greenyellow", 173, 255, 47 },
|
||||
{ "grey", 128, 128, 128 }, { "honeydew", 240, 255, 240 },
|
||||
{ "hotpink", 255, 105, 180 }, { "indianred", 205, 92, 92 },
|
||||
{ "indigo", 75, 0, 130 }, { "ivory", 255, 255, 240 },
|
||||
{ "khaki", 240, 230, 140 }, { "lavender", 230, 230, 250 },
|
||||
{ "lavenderblush", 255, 240, 245 }, { "lawngreen", 124, 252, 0 },
|
||||
{ "lemonchiffon", 255, 250, 205 }, { "lightblue", 173, 216, 230 },
|
||||
{ "lightcoral", 240, 128, 128 }, { "lightcyan", 224, 255, 255 },
|
||||
{ "lightgoldenrodyellow", 250, 250, 210 }, { "lightgray", 211, 211, 211 },
|
||||
{ "lightgreen", 144, 238, 144 }, { "lightgrey", 211, 211, 211 },
|
||||
{ "lightpink", 255, 182, 193 }, { "lightsalmon", 255, 160, 122 },
|
||||
{ "lightseagreen", 32, 178, 170 }, { "lightskyblue", 135, 206, 250 },
|
||||
{ "lightslategray", 119, 136, 153 }, { "lightslategrey", 119, 136, 153 },
|
||||
{ "lightsteelblue", 176, 196, 222 }, { "lightyellow", 255, 255, 224 },
|
||||
{ "lime", 0, 255, 0 }, { "limegreen", 50, 205, 50 },
|
||||
{ "linen", 250, 240, 230 }, { "magenta", 255, 0, 255 },
|
||||
{ "maroon", 128, 0, 0 }, { "mediumaquamarine", 102, 205, 170 },
|
||||
{ "mediumblue", 0, 0, 205 }, { "mediumorchid", 186, 85, 211 },
|
||||
{ "mediumpurple", 147, 112, 219 }, { "mediumseagreen", 60, 179, 113 },
|
||||
{ "mediumslateblue", 123, 104, 238 }, { "mediumspringgreen", 0, 250, 154 },
|
||||
{ "mediumturquoise", 72, 209, 204 }, { "mediumvioletred", 199, 21, 133 },
|
||||
{ "midnightblue", 25, 25, 112 }, { "mintcream", 245, 255, 250 },
|
||||
{ "mistyrose", 255, 228, 225 }, { "moccasin", 255, 228, 181 },
|
||||
{ "navajowhite", 255, 222, 173 }, { "navy", 0, 0, 128 },
|
||||
{ "navyblue", 0, 0, 128 }, { "oldlace", 253, 245, 230 },
|
||||
{ "olive", 128, 128, 0 }, { "olivedrab", 107, 142, 35 },
|
||||
{ "orange", 255, 165, 0 }, { "orangered", 255, 69, 0 },
|
||||
{ "orchid", 218, 112, 214 }, { "palegoldenrod", 238, 232, 170 },
|
||||
{ "palegreen", 152, 251, 152 }, { "paleturquoise", 175, 238, 238 },
|
||||
{ "palevioletred", 219, 112, 147 }, { "papayawhip", 255, 239, 213 },
|
||||
{ "peachpuff", 255, 218, 185 }, { "peru", 205, 133, 63 },
|
||||
{ "pink", 255, 192, 203 }, { "plum", 221, 160, 221 },
|
||||
{ "powderblue", 176, 224, 230 }, { "purple", 128, 0, 128 },
|
||||
{ "red", 255, 0, 0 }, { "rosybrown", 188, 143, 143 },
|
||||
{ "royalblue", 65, 105, 225 }, { "saddlebrown", 139, 69, 19 },
|
||||
{ "salmon", 250, 128, 114 }, { "sandybrown", 244, 164, 96 },
|
||||
{ "seagreen", 46, 139, 87 }, { "seashell", 255, 245, 238 },
|
||||
{ "sienna", 160, 82, 45 }, { "silver", 192, 192, 192 },
|
||||
{ "skyblue", 135, 206, 235 }, { "slateblue", 106, 90, 205 },
|
||||
{ "slategray", 112, 128, 144 }, { "slategrey", 112, 128, 144 },
|
||||
{ "snow", 255, 250, 250 }, { "springgreen", 0, 255, 127 },
|
||||
{ "steelblue", 70, 130, 180 }, { "tan", 210, 180, 140 },
|
||||
{ "teal", 0, 128, 128 }, { "thistle", 216, 191, 216 },
|
||||
{ "tomato", 255, 99, 71 }, { "turquoise", 64, 224, 208 },
|
||||
{ "violet", 238, 130, 238 }, { "wheat", 245, 222, 179 },
|
||||
{ "white", 255, 255, 255 }, { "whitesmoke", 245, 245, 245 },
|
||||
{ "yellow", 255, 255, 0 }, { "yellowgreen", 154, 205, 50 },
|
||||
{ "aliceblue", 240, 248, 255 },
|
||||
{ "antiquewhite", 250, 235, 215 },
|
||||
{ "aqua", 0, 255, 255 },
|
||||
{ "aquamarine", 127, 255, 212 },
|
||||
{ "azure", 240, 255, 255 },
|
||||
{ "beige", 245, 245, 220 },
|
||||
{ "bisque", 255, 228, 196 },
|
||||
{ "black", 0, 0, 0 },
|
||||
{ "blanchedalmond", 255, 235, 205 },
|
||||
{ "blue", 0, 0, 255 },
|
||||
{ "blueviolet", 138, 43, 226 },
|
||||
{ "brown", 165, 42, 42 },
|
||||
{ "burlywood", 222, 184, 135 },
|
||||
{ "cadetblue", 95, 158, 160 },
|
||||
{ "chartreuse", 127, 255, 0 },
|
||||
{ "chocolate", 210, 105, 30 },
|
||||
{ "coral", 255, 127, 80 },
|
||||
{ "cornflowerblue", 100, 149, 237 },
|
||||
{ "cornsilk", 255, 248, 220 },
|
||||
{ "crimson", 220, 20, 60 },
|
||||
{ "cyan", 0, 255, 255 },
|
||||
{ "darkblue", 0, 0, 139 },
|
||||
{ "darkcyan", 0, 139, 139 },
|
||||
{ "darkgoldenrod", 184, 134, 11 },
|
||||
{ "darkgray", 169, 169, 169 },
|
||||
{ "darkgreen", 0, 100, 0 },
|
||||
{ "darkgrey", 169, 169, 169 },
|
||||
{ "darkkhaki", 189, 183, 107 },
|
||||
{ "darkmagenta", 139, 0, 139 },
|
||||
{ "darkolivegreen", 85, 107, 47 },
|
||||
{ "darkorange", 255, 140, 0 },
|
||||
{ "darkorchid", 153, 50, 204 },
|
||||
{ "darkred", 139, 0, 0 },
|
||||
{ "darksalmon", 233, 150, 122 },
|
||||
{ "darkseagreen", 143, 188, 143 },
|
||||
{ "darkslateblue", 72, 61, 139 },
|
||||
{ "darkslategray", 47, 79, 79 },
|
||||
{ "darkslategrey", 47, 79, 79 },
|
||||
{ "darkturquoise", 0, 206, 209 },
|
||||
{ "darkviolet", 148, 0, 211 },
|
||||
{ "deeppink", 255, 20, 147 },
|
||||
{ "deepskyblue", 0, 191, 255 },
|
||||
{ "dimgray", 105, 105, 105 },
|
||||
{ "dimgrey", 105, 105, 105 },
|
||||
{ "dodgerblue", 30, 144, 255 },
|
||||
{ "firebrick", 178, 34, 34 },
|
||||
{ "floralwhite", 255, 250, 240 },
|
||||
{ "forestgreen", 34, 139, 34 },
|
||||
{ "fuchsia", 255, 0, 255 },
|
||||
{ "gainsboro", 220, 220, 220 },
|
||||
{ "ghostwhite", 248, 248, 255 },
|
||||
{ "gold", 255, 215, 0 },
|
||||
{ "goldenrod", 218, 165, 32 },
|
||||
{ "gray", 128, 128, 128 },
|
||||
{ "green", 0, 128, 0 },
|
||||
{ "greenyellow", 173, 255, 47 },
|
||||
{ "grey", 128, 128, 128 },
|
||||
{ "honeydew", 240, 255, 240 },
|
||||
{ "hotpink", 255, 105, 180 },
|
||||
{ "indianred", 205, 92, 92 },
|
||||
{ "indigo", 75, 0, 130 },
|
||||
{ "ivory", 255, 255, 240 },
|
||||
{ "khaki", 240, 230, 140 },
|
||||
{ "lavender", 230, 230, 250 },
|
||||
{ "lavenderblush", 255, 240, 245 },
|
||||
{ "lawngreen", 124, 252, 0 },
|
||||
{ "lemonchiffon", 255, 250, 205 },
|
||||
{ "lightblue", 173, 216, 230 },
|
||||
{ "lightcoral", 240, 128, 128 },
|
||||
{ "lightcyan", 224, 255, 255 },
|
||||
{ "lightgoldenrodyellow", 250, 250, 210 },
|
||||
{ "lightgray", 211, 211, 211 },
|
||||
{ "lightgreen", 144, 238, 144 },
|
||||
{ "lightgrey", 211, 211, 211 },
|
||||
{ "lightpink", 255, 182, 193 },
|
||||
{ "lightsalmon", 255, 160, 122 },
|
||||
{ "lightseagreen", 32, 178, 170 },
|
||||
{ "lightskyblue", 135, 206, 250 },
|
||||
{ "lightslategray", 119, 136, 153 },
|
||||
{ "lightslategrey", 119, 136, 153 },
|
||||
{ "lightsteelblue", 176, 196, 222 },
|
||||
{ "lightyellow", 255, 255, 224 },
|
||||
{ "lime", 0, 255, 0 },
|
||||
{ "limegreen", 50, 205, 50 },
|
||||
{ "linen", 250, 240, 230 },
|
||||
{ "magenta", 255, 0, 255 },
|
||||
{ "maroon", 128, 0, 0 },
|
||||
{ "mediumaquamarine", 102, 205, 170 },
|
||||
{ "mediumblue", 0, 0, 205 },
|
||||
{ "mediumorchid", 186, 85, 211 },
|
||||
{ "mediumpurple", 147, 112, 219 },
|
||||
{ "mediumseagreen", 60, 179, 113 },
|
||||
{ "mediumslateblue", 123, 104, 238 },
|
||||
{ "mediumspringgreen", 0, 250, 154 },
|
||||
{ "mediumturquoise", 72, 209, 204 },
|
||||
{ "mediumvioletred", 199, 21, 133 },
|
||||
{ "midnightblue", 25, 25, 112 },
|
||||
{ "mintcream", 245, 255, 250 },
|
||||
{ "mistyrose", 255, 228, 225 },
|
||||
{ "moccasin", 255, 228, 181 },
|
||||
{ "navajowhite", 255, 222, 173 },
|
||||
{ "navy", 0, 0, 128 },
|
||||
{ "navyblue", 0, 0, 128 },
|
||||
{ "oldlace", 253, 245, 230 },
|
||||
{ "olive", 128, 128, 0 },
|
||||
{ "olivedrab", 107, 142, 35 },
|
||||
{ "orange", 255, 165, 0 },
|
||||
{ "orangered", 255, 69, 0 },
|
||||
{ "orchid", 218, 112, 214 },
|
||||
{ "palegoldenrod", 238, 232, 170 },
|
||||
{ "palegreen", 152, 251, 152 },
|
||||
{ "paleturquoise", 175, 238, 238 },
|
||||
{ "palevioletred", 219, 112, 147 },
|
||||
{ "papayawhip", 255, 239, 213 },
|
||||
{ "peachpuff", 255, 218, 185 },
|
||||
{ "peru", 205, 133, 63 },
|
||||
{ "pink", 255, 192, 203 },
|
||||
{ "plum", 221, 160, 221 },
|
||||
{ "powderblue", 176, 224, 230 },
|
||||
{ "purple", 128, 0, 128 },
|
||||
{ "red", 255, 0, 0 },
|
||||
{ "rosybrown", 188, 143, 143 },
|
||||
{ "royalblue", 65, 105, 225 },
|
||||
{ "saddlebrown", 139, 69, 19 },
|
||||
{ "salmon", 250, 128, 114 },
|
||||
{ "sandybrown", 244, 164, 96 },
|
||||
{ "seagreen", 46, 139, 87 },
|
||||
{ "seashell", 255, 245, 238 },
|
||||
{ "sienna", 160, 82, 45 },
|
||||
{ "silver", 192, 192, 192 },
|
||||
{ "skyblue", 135, 206, 235 },
|
||||
{ "slateblue", 106, 90, 205 },
|
||||
{ "slategray", 112, 128, 144 },
|
||||
{ "slategrey", 112, 128, 144 },
|
||||
{ "snow", 255, 250, 250 },
|
||||
{ "springgreen", 0, 255, 127 },
|
||||
{ "steelblue", 70, 130, 180 },
|
||||
{ "tan", 210, 180, 140 },
|
||||
{ "teal", 0, 128, 128 },
|
||||
{ "thistle", 216, 191, 216 },
|
||||
{ "tomato", 255, 99, 71 },
|
||||
{ "turquoise", 64, 224, 208 },
|
||||
{ "violet", 238, 130, 238 },
|
||||
{ "wheat", 245, 222, 179 },
|
||||
{ "white", 255, 255, 255 },
|
||||
{ "whitesmoke", 245, 245, 245 },
|
||||
{ "yellow", 255, 255, 0 },
|
||||
{ "yellowgreen", 154, 205, 50 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -16,36 +16,54 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_to_xy(
|
||||
uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness);
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_from_xy(
|
||||
uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
float y_coordinate,
|
||||
uint8_t brightness);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
float *x_coordinate, float *y_coordinate, uint8_t *brightness);
|
||||
void color_rgb_to_xy_gamma(
|
||||
uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness);
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
float x_coordinate, float y_coordinate, uint8_t brightness);
|
||||
void color_rgb_from_xy_gamma(
|
||||
uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
float y_coordinate,
|
||||
uint8_t brightness);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_to_xy_gamma(uint8_t r, uint8_t g, uint8_t b,
|
||||
float *x_coordinate, float *y_coordinate, uint8_t *brightness);
|
||||
const char *color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue);
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_from_xy_gamma(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
float x_coordinate, float y_coordinate, uint8_t brightness);
|
||||
|
||||
unsigned color_rgb_from_ascii(
|
||||
uint8_t *red, uint8_t *green, uint8_t *blue, const char *name);
|
||||
BACNET_STACK_EXPORT
|
||||
const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
const char *name);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *color_rgb_from_index(unsigned target_index, uint8_t *red,
|
||||
uint8_t *green, uint8_t *blue);
|
||||
const char *color_rgb_from_index(
|
||||
unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned color_rgb_count(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void color_rgb_from_temperature(
|
||||
uint16_t temperature_kelvin,
|
||||
uint8_t *r, uint8_t *g, uint8_t *b);
|
||||
uint16_t temperature_kelvin, uint8_t *r, uint8_t *g, uint8_t *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ uint8_t days_per_month(uint16_t year, uint8_t month)
|
||||
{
|
||||
/* note: start with a zero in the first element to save us from a
|
||||
month - 1 calculation in the lookup */
|
||||
uint8_t month_days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
|
||||
31 };
|
||||
uint8_t month_days[13] = {
|
||||
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
||||
};
|
||||
|
||||
if ((month == 2) && days_is_leap_year(year)) {
|
||||
return (29);
|
||||
@@ -146,7 +147,8 @@ void days_of_year_to_month_day(
|
||||
* @param day1 - day of month (1-31)
|
||||
* @return number of days apart, or 0 if same dates
|
||||
*/
|
||||
uint32_t days_apart(uint16_t year1,
|
||||
uint32_t days_apart(
|
||||
uint16_t year1,
|
||||
uint8_t month1,
|
||||
uint8_t day1,
|
||||
uint16_t year2,
|
||||
@@ -197,8 +199,8 @@ uint32_t days_apart(uint16_t year1,
|
||||
* @param day - day of month (1-31)
|
||||
* @return number of days since epoch, or 0 if out of range
|
||||
*/
|
||||
uint32_t days_since_epoch(
|
||||
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
|
||||
uint32_t
|
||||
days_since_epoch(uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint32_t days = 0; /* return value */
|
||||
uint16_t yy = 0; /* year */
|
||||
@@ -233,7 +235,8 @@ uint32_t days_since_epoch(
|
||||
* @param pDay - day of month (1-31)
|
||||
* @return nothing
|
||||
*/
|
||||
void days_since_epoch_to_date(uint16_t epoch_year,
|
||||
void days_since_epoch_to_date(
|
||||
uint16_t epoch_year,
|
||||
uint32_t days,
|
||||
uint16_t *pYear,
|
||||
uint8_t *pMonth,
|
||||
|
||||
@@ -30,29 +30,26 @@ BACNET_STACK_EXPORT
|
||||
void days_of_year_to_month_day(
|
||||
uint32_t days, uint16_t year, uint8_t *pMonth, uint8_t *pDay);
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t days_apart(uint16_t year1,
|
||||
uint32_t days_apart(
|
||||
uint16_t year1,
|
||||
uint8_t month1,
|
||||
uint8_t day1,
|
||||
uint16_t year2,
|
||||
uint8_t month2,
|
||||
uint8_t day2);
|
||||
BACNET_STACK_EXPORT
|
||||
uint32_t days_since_epoch(uint16_t epoch_year,
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day);
|
||||
uint32_t days_since_epoch(
|
||||
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day);
|
||||
BACNET_STACK_EXPORT
|
||||
void days_since_epoch_to_date(
|
||||
uint16_t epoch_year,
|
||||
uint32_t days,
|
||||
uint16_t * pYear,
|
||||
uint8_t * pMonth,
|
||||
uint8_t * pDay);
|
||||
uint16_t *pYear,
|
||||
uint8_t *pMonth,
|
||||
uint8_t *pDay);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool days_date_is_valid(uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day);
|
||||
bool days_date_is_valid(uint16_t year, uint8_t month, uint8_t day);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -85,12 +85,13 @@ void debug_printf_hex(
|
||||
uint32_t offset,
|
||||
const uint8_t *buffer,
|
||||
size_t buffer_length,
|
||||
const char *format, ...)
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
#if DEBUG_ENABLED
|
||||
size_t i = 0;
|
||||
bool new_line = true;
|
||||
char line[16+1] = {0};
|
||||
char line[16 + 1] = { 0 };
|
||||
size_t remainder = 0;
|
||||
va_list ap;
|
||||
|
||||
@@ -102,21 +103,21 @@ void debug_printf_hex(
|
||||
for (i = 0; i < buffer_length; i++) {
|
||||
if (new_line) {
|
||||
new_line = false;
|
||||
printf("%08x ", (unsigned int)(offset+i));
|
||||
memset(line, '.', sizeof(line)-1);
|
||||
printf("%08x ", (unsigned int)(offset + i));
|
||||
memset(line, '.', sizeof(line) - 1);
|
||||
}
|
||||
printf("%02x ", buffer[i]);
|
||||
if (isprint(buffer[i])) {
|
||||
line[i%16] = buffer[i];
|
||||
line[i % 16] = buffer[i];
|
||||
}
|
||||
if ((i != 0) && (!((i+1)%16))) {
|
||||
if ((i != 0) && (!((i + 1) % 16))) {
|
||||
printf(" %s\n", line);
|
||||
new_line = true;
|
||||
}
|
||||
}
|
||||
remainder = buffer_length%16;
|
||||
remainder = buffer_length % 16;
|
||||
if (remainder) {
|
||||
for (i = 0; i < (16-remainder); i++) {
|
||||
for (i = 0; i < (16 - remainder); i++) {
|
||||
printf(" ");
|
||||
}
|
||||
printf(" %s\n", line);
|
||||
@@ -187,7 +188,7 @@ int debug_fprintf(FILE *stream, const char *format, ...)
|
||||
* @param ... - variable arguments
|
||||
* @note This function is only available if
|
||||
* PRINT_ENABLED is non-zero
|
||||
*/
|
||||
*/
|
||||
void debug_perror(const char *format, ...)
|
||||
{
|
||||
#if PRINT_ENABLED
|
||||
|
||||
@@ -25,34 +25,24 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
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,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
void debug_printf_hex(
|
||||
uint32_t offset,
|
||||
const uint8_t *buffer,
|
||||
size_t buffer_length,
|
||||
const char *format, ...);
|
||||
BACNET_STACK_EXPORT
|
||||
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, ...);
|
||||
BACNET_STACK_EXPORT
|
||||
void debug_printf_hex(
|
||||
uint32_t offset,
|
||||
const uint8_t *buffer,
|
||||
size_t buffer_length,
|
||||
const char *format,
|
||||
...);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void debug_printf_disabled(
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
void debug_printf_disabled(const char *format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ uint8_t FIFO_Peek(FIFO_BUFFER const *b)
|
||||
* @param length [in] - number of bytes to peek from the FIFO
|
||||
* @return number of bytes peeked
|
||||
*/
|
||||
unsigned FIFO_Peek_Ahead(FIFO_BUFFER const *b, uint8_t* buffer, unsigned length)
|
||||
unsigned FIFO_Peek_Ahead(FIFO_BUFFER const *b, uint8_t *buffer, unsigned length)
|
||||
{
|
||||
unsigned count = 0;
|
||||
unsigned index;
|
||||
@@ -164,7 +164,7 @@ unsigned FIFO_Peek_Ahead(FIFO_BUFFER const *b, uint8_t* buffer, unsigned length)
|
||||
count = length;
|
||||
}
|
||||
tail = b->tail;
|
||||
for(i = 0; i < count; i++) {
|
||||
for (i = 0; i < count; i++) {
|
||||
index = tail % b->buffer_len;
|
||||
buffer[i] = b->buffer[index];
|
||||
tail++;
|
||||
|
||||
+44
-65
@@ -4,7 +4,7 @@
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2004
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
*/
|
||||
#ifndef BACNET_SYS_FIFO_H
|
||||
#define BACNET_SYS_FIFO_H
|
||||
#include <stdint.h>
|
||||
@@ -13,33 +13,33 @@
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
/**
|
||||
* FIFO buffer power of two alignment macro
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
* FIFO buffer power of two alignment macro
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef NEXT_POWER_OF_2
|
||||
#define B2(x) ( (x) | ( (x) >> 1) )
|
||||
#define B4(x) ( B2(x) | ( B2(x) >> 2) )
|
||||
#define B8(x) ( B4(x) | ( B4(x) >> 4) )
|
||||
#define B16(x) ( B8(x) | ( B8(x) >> 8) )
|
||||
#define B32(x) (B16(x) | (B16(x) >>16) )
|
||||
#define B2(x) ((x) | ((x) >> 1))
|
||||
#define B4(x) (B2(x) | (B2(x) >> 2))
|
||||
#define B8(x) (B4(x) | (B4(x) >> 4))
|
||||
#define B16(x) (B8(x) | (B8(x) >> 8))
|
||||
#define B32(x) (B16(x) | (B16(x) >> 16))
|
||||
#define NEXT_POWER_OF_2(x) (B32((x)-1) + 1)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* FIFO data store structure
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define FIFO_DATA_STORE(b,c) uint8_t b[NEXT_POWER_OF_2(c)]
|
||||
* FIFO data store structure
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define FIFO_DATA_STORE(b, c) uint8_t b[NEXT_POWER_OF_2(c)]
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* FIFO data structure
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
* FIFO data structure
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
struct fifo_buffer_t {
|
||||
/** first byte of data */
|
||||
volatile unsigned head;
|
||||
@@ -57,64 +57,43 @@ typedef struct fifo_buffer_t FIFO_BUFFER;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned FIFO_Count(
|
||||
FIFO_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned FIFO_Count(FIFO_BUFFER const *b);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Full(
|
||||
FIFO_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Full(FIFO_BUFFER const *b);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Available(
|
||||
FIFO_BUFFER const *b,
|
||||
unsigned count);
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Available(FIFO_BUFFER const *b, unsigned count);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Empty(
|
||||
FIFO_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Empty(FIFO_BUFFER const *b);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t FIFO_Peek(
|
||||
FIFO_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t FIFO_Peek(FIFO_BUFFER const *b);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned FIFO_Peek_Ahead(
|
||||
FIFO_BUFFER const *b,
|
||||
uint8_t* data_bytes,
|
||||
unsigned length);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned
|
||||
FIFO_Peek_Ahead(FIFO_BUFFER const *b, uint8_t *data_bytes, unsigned length);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t FIFO_Get(
|
||||
FIFO_BUFFER * b);
|
||||
BACNET_STACK_EXPORT
|
||||
uint8_t FIFO_Get(FIFO_BUFFER *b);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned FIFO_Pull(
|
||||
FIFO_BUFFER * b,
|
||||
uint8_t * data_bytes,
|
||||
unsigned length);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned FIFO_Pull(FIFO_BUFFER *b, uint8_t *data_bytes, unsigned length);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Put(
|
||||
FIFO_BUFFER * b,
|
||||
uint8_t data_byte);
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Put(FIFO_BUFFER *b, uint8_t data_byte);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Add(
|
||||
FIFO_BUFFER * b,
|
||||
const uint8_t * data_bytes,
|
||||
unsigned count);
|
||||
BACNET_STACK_EXPORT
|
||||
bool FIFO_Add(FIFO_BUFFER *b, const uint8_t *data_bytes, unsigned count);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void FIFO_Flush(
|
||||
FIFO_BUFFER * b);
|
||||
BACNET_STACK_EXPORT
|
||||
void FIFO_Flush(FIFO_BUFFER *b);
|
||||
|
||||
/* note: buffer_len must be a power of two */
|
||||
BACNET_STACK_EXPORT
|
||||
void FIFO_Init(
|
||||
FIFO_BUFFER * b,
|
||||
volatile uint8_t * buffer,
|
||||
unsigned buffer_len);
|
||||
BACNET_STACK_EXPORT
|
||||
void FIFO_Init(FIFO_BUFFER *b, volatile uint8_t *buffer, unsigned buffer_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2007
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
*/
|
||||
#ifndef BACNET_SYS_FILENAME_H
|
||||
#define BACNET_SYS_FILENAME_H
|
||||
/* BACnet Stack defines - first */
|
||||
@@ -14,9 +14,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
const char *filename_remove_path(
|
||||
const char *filename_in);
|
||||
BACNET_STACK_EXPORT
|
||||
const char *filename_remove_path(const char *filename_in);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+12
-11
@@ -5,7 +5,7 @@
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2004
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
*/
|
||||
#ifndef BACNET_SYS_KEY_H
|
||||
#define BACNET_SYS_KEY_H
|
||||
#include <stdint.h>
|
||||
@@ -16,19 +16,20 @@
|
||||
typedef uint32_t KEY;
|
||||
|
||||
/* assuming a 32 bit KEY */
|
||||
#define KEY_TYPE_OFFSET 22 /* bits - for BACnet */
|
||||
#define KEY_TYPE_MASK 0x000003FFL
|
||||
#define KEY_ID_MASK 0x003FFFFFL
|
||||
#define KEY_ID_MAX (KEY_ID_MASK + 1L)
|
||||
#define KEY_TYPE_MAX (KEY_TYPE_MASK + 1L)
|
||||
#define KEY_TYPE_OFFSET 22 /* bits - for BACnet */
|
||||
#define KEY_TYPE_MASK 0x000003FFL
|
||||
#define KEY_ID_MASK 0x003FFFFFL
|
||||
#define KEY_ID_MAX (KEY_ID_MASK + 1L)
|
||||
#define KEY_TYPE_MAX (KEY_TYPE_MASK + 1L)
|
||||
#define KEY_LAST(key) ((key & KEY_ID_MASK) == KEY_ID_MAX)
|
||||
|
||||
#define KEY_ENCODE(type,id) ( ((unsigned int)\
|
||||
((unsigned int)(type) & KEY_TYPE_MASK) << KEY_TYPE_OFFSET) |\
|
||||
((unsigned int)(id) & KEY_ID_MASK) )
|
||||
#define KEY_ENCODE(type, id) \
|
||||
(((unsigned int)((unsigned int)(type) & KEY_TYPE_MASK) \
|
||||
<< KEY_TYPE_OFFSET) | \
|
||||
((unsigned int)(id) & KEY_ID_MASK))
|
||||
|
||||
#define KEY_DECODE_TYPE(key) ((int)(((unsigned int)(key) >> KEY_TYPE_OFFSET)\
|
||||
& KEY_TYPE_MASK))
|
||||
#define KEY_DECODE_TYPE(key) \
|
||||
((int)(((unsigned int)(key) >> KEY_TYPE_OFFSET) & KEY_TYPE_MASK))
|
||||
|
||||
#define KEY_DECODE_ID(key) ((int)((unsigned int)(key) & KEY_ID_MASK))
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
/* list data and datatype */
|
||||
struct Keylist_Node {
|
||||
KEY key; /* unique number that is sorted in the list */
|
||||
KEY key; /* unique number that is sorted in the list */
|
||||
void *data; /* pointer to some data that is stored */
|
||||
};
|
||||
|
||||
typedef struct Keylist {
|
||||
struct Keylist_Node **array; /* array of nodes */
|
||||
int count; /* number of nodes in this list - more efficient than loop */
|
||||
int size; /* number of available nodes on this list - can grow or shrink */
|
||||
struct Keylist_Node **array; /* array of nodes */
|
||||
int count; /* number of nodes in this list - more efficient than loop */
|
||||
int size; /* number of available nodes on this list - can grow or shrink */
|
||||
} KEYLIST_TYPE;
|
||||
typedef KEYLIST_TYPE *OS_Keylist;
|
||||
|
||||
@@ -34,90 +34,65 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* returns head of the list or NULL on failure. */
|
||||
BACNET_STACK_EXPORT
|
||||
OS_Keylist Keylist_Create(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
OS_Keylist Keylist_Create(void);
|
||||
|
||||
/* delete specified list */
|
||||
/* note: you should pop all the nodes off the list first. */
|
||||
BACNET_STACK_EXPORT
|
||||
void Keylist_Delete(
|
||||
OS_Keylist list);
|
||||
BACNET_STACK_EXPORT
|
||||
void Keylist_Delete(OS_Keylist list);
|
||||
|
||||
/* inserts a node into its sorted position */
|
||||
/* returns the index where it was added */
|
||||
BACNET_STACK_EXPORT
|
||||
int Keylist_Data_Add(
|
||||
OS_Keylist list,
|
||||
KEY key,
|
||||
void *data);
|
||||
BACNET_STACK_EXPORT
|
||||
int Keylist_Data_Add(OS_Keylist list, KEY key, void *data);
|
||||
|
||||
/* deletes a node specified by its key */
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_STACK_EXPORT
|
||||
/* returns the data from the node */
|
||||
void *Keylist_Data_Delete(
|
||||
OS_Keylist list,
|
||||
KEY key);
|
||||
void *Keylist_Data_Delete(OS_Keylist list, KEY key);
|
||||
|
||||
/* deletes a node specified by its index */
|
||||
BACNET_STACK_EXPORT
|
||||
BACNET_STACK_EXPORT
|
||||
/* returns the data from the node */
|
||||
void *Keylist_Data_Delete_By_Index(
|
||||
OS_Keylist list,
|
||||
int index);
|
||||
void *Keylist_Data_Delete_By_Index(OS_Keylist list, int index);
|
||||
|
||||
/* returns the data from last node, and removes it from the list */
|
||||
BACNET_STACK_EXPORT
|
||||
void *Keylist_Data_Pop(
|
||||
OS_Keylist list);
|
||||
BACNET_STACK_EXPORT
|
||||
void *Keylist_Data_Pop(OS_Keylist list);
|
||||
|
||||
/* removes and frees all data from the list */
|
||||
BACNET_STACK_EXPORT
|
||||
void Keylist_Data_Free(
|
||||
OS_Keylist list);
|
||||
BACNET_STACK_EXPORT
|
||||
void Keylist_Data_Free(OS_Keylist list);
|
||||
|
||||
/* returns the data from the node specified by key */
|
||||
BACNET_STACK_EXPORT
|
||||
void *Keylist_Data(
|
||||
OS_Keylist list,
|
||||
KEY key);
|
||||
BACNET_STACK_EXPORT
|
||||
void *Keylist_Data(OS_Keylist list, KEY key);
|
||||
|
||||
/* returns the index from the node specified by key */
|
||||
BACNET_STACK_EXPORT
|
||||
int Keylist_Index(
|
||||
OS_Keylist list,
|
||||
KEY key);
|
||||
BACNET_STACK_EXPORT
|
||||
int Keylist_Index(OS_Keylist list, KEY key);
|
||||
|
||||
/* returns the data specified by index */
|
||||
BACNET_STACK_EXPORT
|
||||
void *Keylist_Data_Index(
|
||||
OS_Keylist list,
|
||||
int index);
|
||||
BACNET_STACK_EXPORT
|
||||
void *Keylist_Data_Index(OS_Keylist list, int index);
|
||||
|
||||
/* returns the node key specified by the index */
|
||||
BACNET_STACK_DEPRECATED("Use Keylist_Index_Key() instead")
|
||||
BACNET_STACK_EXPORT
|
||||
KEY Keylist_Key(
|
||||
OS_Keylist list,
|
||||
int index);
|
||||
BACNET_STACK_DEPRECATED("Use Keylist_Index_Key() instead")
|
||||
BACNET_STACK_EXPORT
|
||||
KEY Keylist_Key(OS_Keylist list, int index);
|
||||
|
||||
/* returns the node key specified by the index */
|
||||
BACNET_STACK_EXPORT
|
||||
bool Keylist_Index_Key(
|
||||
OS_Keylist list,
|
||||
int index,
|
||||
KEY *pKey);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Keylist_Index_Key(OS_Keylist list, int index, KEY *pKey);
|
||||
|
||||
/* returns the next empty key from the list */
|
||||
BACNET_STACK_EXPORT
|
||||
KEY Keylist_Next_Empty_Key(
|
||||
OS_Keylist list,
|
||||
KEY key);
|
||||
BACNET_STACK_EXPORT
|
||||
KEY Keylist_Next_Empty_Key(OS_Keylist list, KEY key);
|
||||
|
||||
/* returns the number of items in the list */
|
||||
BACNET_STACK_EXPORT
|
||||
int Keylist_Count(
|
||||
OS_Keylist list);
|
||||
BACNET_STACK_EXPORT
|
||||
int Keylist_Count(OS_Keylist list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,33 +1,29 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Performs linear interpolation using single precision floating
|
||||
* point math or integer math, or a mixture of both. Linear interpolation
|
||||
* is a method of constructing new data points within the range of a discrete
|
||||
* set of known data points.
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2011
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
* @file
|
||||
* @brief Performs linear interpolation using single precision floating
|
||||
* point math or integer math, or a mixture of both. Linear interpolation
|
||||
* is a method of constructing new data points within the range of a discrete
|
||||
* set of known data points.
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2011
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "bacnet/basic/sys/linear.h"
|
||||
|
||||
/**
|
||||
* Linearly Interpolate the values between y1 and y3 based on x.
|
||||
*
|
||||
* @param x1 - first x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x2 - intermediate x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x3 - last x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param y1 - first y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @param y3 - last y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @return y2 - an intermediate y value y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* and the y value is linearly proportional to x1, x2, and x2.
|
||||
*/
|
||||
float linear_interpolate(float x1,
|
||||
float x2,
|
||||
float x3,
|
||||
float y1,
|
||||
float y3)
|
||||
* Linearly Interpolate the values between y1 and y3 based on x.
|
||||
*
|
||||
* @param x1 - first x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x2 - intermediate x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x3 - last x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param y1 - first y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @param y3 - last y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @return y2 - an intermediate y value y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* and the y value is linearly proportional to x1, x2, and x2.
|
||||
*/
|
||||
float linear_interpolate(float x1, float x2, float x3, float y1, float y3)
|
||||
{
|
||||
float y2;
|
||||
|
||||
@@ -41,22 +37,18 @@ float linear_interpolate(float x1,
|
||||
}
|
||||
|
||||
/**
|
||||
* Linearly Interpolate the values between y1 and y3 based on x
|
||||
* and round up the result. Useful for integer interpolation.
|
||||
*
|
||||
* @param x1 - first x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x2 - intermediate x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x3 - last x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param y1 - first y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @param y3 - last y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @return y2 - an intermediate y value y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* and the y value is linearly proportional to x1, x2, and x2.
|
||||
*/
|
||||
float linear_interpolate_round(float x1,
|
||||
float x2,
|
||||
float x3,
|
||||
float y1,
|
||||
float y3)
|
||||
* Linearly Interpolate the values between y1 and y3 based on x
|
||||
* and round up the result. Useful for integer interpolation.
|
||||
*
|
||||
* @param x1 - first x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x2 - intermediate x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x3 - last x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param y1 - first y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @param y3 - last y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @return y2 - an intermediate y value y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* and the y value is linearly proportional to x1, x2, and x2.
|
||||
*/
|
||||
float linear_interpolate_round(float x1, float x2, float x3, float y1, float y3)
|
||||
{
|
||||
float y2;
|
||||
|
||||
@@ -72,22 +64,18 @@ float linear_interpolate_round(float x1,
|
||||
}
|
||||
|
||||
/**
|
||||
* Linearly Interpolate the values between y1 and y3 based on x
|
||||
* using integer math.
|
||||
*
|
||||
* @param x1 - first x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x2 - intermediate x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x3 - last x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param y1 - first y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @param y3 - last y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @return y2 - an intermediate y value y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* and the y value is linearly proportional to x1, x2, and x2.
|
||||
*/
|
||||
long linear_interpolate_int(long x1,
|
||||
long x2,
|
||||
long x3,
|
||||
long y1,
|
||||
long y3)
|
||||
* Linearly Interpolate the values between y1 and y3 based on x
|
||||
* using integer math.
|
||||
*
|
||||
* @param x1 - first x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x2 - intermediate x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param x3 - last x value, where x1 <= x2 <= x3 or x1 >= x2 >= x3
|
||||
* @param y1 - first y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @param y3 - last y value, where y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* @return y2 - an intermediate y value y1 <= y2 <= y3 or y1 >= y2 >= y3
|
||||
* and the y value is linearly proportional to x1, x2, and x2.
|
||||
*/
|
||||
long linear_interpolate_int(long x1, long x2, long x3, long y1, long y3)
|
||||
{
|
||||
long y2;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief API for linear interpolation library
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2011
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
* @file
|
||||
* @brief API for linear interpolation library
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2011
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_SYS_LINEAR_H
|
||||
#define BACNET_SYS_LINEAR_H
|
||||
|
||||
@@ -15,23 +15,12 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
float linear_interpolate(float x1,
|
||||
float x2,
|
||||
float x3,
|
||||
float y1,
|
||||
float y3);
|
||||
float linear_interpolate(float x1, float x2, float x3, float y1, float y3);
|
||||
|
||||
float linear_interpolate_round(float x1,
|
||||
float x2,
|
||||
float x3,
|
||||
float y1,
|
||||
float y3);
|
||||
float linear_interpolate_round(
|
||||
float x1, float x2, float x3, float y1, float y3);
|
||||
|
||||
long linear_interpolate_int(long x1,
|
||||
long x2,
|
||||
long x3,
|
||||
long y1,
|
||||
long y3);
|
||||
long linear_interpolate_int(long x1, long x2, long x3, long y1, long y3);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ void mstimer_callback_handler(void)
|
||||
* @param callback - pointer to a #timer_callback_function function
|
||||
* @param milliseconds - how often to call the function
|
||||
*/
|
||||
void mstimer_callback(struct mstimer_callback_data_t *new_cb,
|
||||
void mstimer_callback(
|
||||
struct mstimer_callback_data_t *new_cb,
|
||||
mstimer_callback_function callback,
|
||||
unsigned long milliseconds)
|
||||
{
|
||||
@@ -136,7 +137,8 @@ void mstimer_restart(struct mstimer *t)
|
||||
int mstimer_expired(const struct mstimer *t)
|
||||
{
|
||||
if (t->interval) {
|
||||
return ((unsigned long)((mstimer_now()) - (t->start + t->interval)) <
|
||||
return (
|
||||
(unsigned long)((mstimer_now()) - (t->start + t->interval)) <
|
||||
((unsigned long)(~((unsigned long)0)) >> 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
* \hideinitializer
|
||||
*/
|
||||
struct mstimer {
|
||||
unsigned long start;
|
||||
unsigned long interval;
|
||||
unsigned long start;
|
||||
unsigned long interval;
|
||||
};
|
||||
|
||||
/* optional callback function form */
|
||||
typedef void (*mstimer_callback_function) (void);
|
||||
typedef void (*mstimer_callback_function)(void);
|
||||
/* optional callback data structure */
|
||||
struct mstimer_callback_data_t;
|
||||
struct mstimer_callback_data_t {
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef isgreaterequal
|
||||
#define isgreaterequal(x, y) ((x) > (y) || !islessgreater((x),(y)))
|
||||
#define isgreaterequal(x, y) ((x) > (y) || !islessgreater((x), (y)))
|
||||
#endif
|
||||
|
||||
#ifndef islessequal
|
||||
#define islessequal(x, y) ((x) < (y) || !islessgreater((x),(y)))
|
||||
#define islessequal(x, y) ((x) < (y) || !islessgreater((x), (y)))
|
||||
#endif
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
@@ -61,15 +61,17 @@
|
||||
#define snprintf c99_snprintf
|
||||
#define vsnprintf c99_vsnprintf
|
||||
|
||||
__inline int c99_vsnprintf(
|
||||
char *outBuf, size_t size, const char *format, va_list ap)
|
||||
__inline int
|
||||
c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
int count = -1;
|
||||
|
||||
if (size != 0)
|
||||
if (size != 0) {
|
||||
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
||||
if (count == -1)
|
||||
}
|
||||
if (count == -1) {
|
||||
count = _vscprintf(format, ap);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ volatile void *Ringbuf_Peek(RING_BUFFER const *b)
|
||||
* @param data_element - find the next element from this one
|
||||
* @return pointer to the data, or NULL if nothing in the list
|
||||
*/
|
||||
volatile void *Ringbuf_Peek_Next(
|
||||
RING_BUFFER const *b, const uint8_t *data_element)
|
||||
volatile void *
|
||||
Ringbuf_Peek_Next(RING_BUFFER const *b, const uint8_t *data_element)
|
||||
{
|
||||
unsigned index; /* list index */
|
||||
volatile uint8_t *this_element;
|
||||
@@ -398,7 +398,8 @@ static bool isPowerOfTwo(unsigned int x)
|
||||
*
|
||||
* @return true if ring buffer was initialized
|
||||
*/
|
||||
bool Ringbuf_Init(RING_BUFFER *b,
|
||||
bool Ringbuf_Init(
|
||||
RING_BUFFER *b,
|
||||
volatile uint8_t *buffer,
|
||||
unsigned element_size,
|
||||
unsigned element_count)
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
/**
|
||||
* ring buffer power of two alignment macro
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
* ring buffer power of two alignment macro
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef NEXT_POWER_OF_2
|
||||
/* clang-format off */
|
||||
#define B2(x) ( (x) | ( (x) >> 1) )
|
||||
@@ -31,10 +31,10 @@
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* ring buffer data structure
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
* ring buffer data structure
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
struct ring_buffer_t {
|
||||
/** block of memory or array of data */
|
||||
volatile uint8_t *buffer;
|
||||
@@ -56,50 +56,46 @@ typedef struct ring_buffer_t RING_BUFFER;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Count(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Depth(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Depth_Reset(RING_BUFFER *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Size(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Full(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Empty(RING_BUFFER const *b);
|
||||
/* tail */
|
||||
BACNET_STACK_EXPORT
|
||||
volatile void *Ringbuf_Peek(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Pop(RING_BUFFER * b,
|
||||
uint8_t * data_element);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Pop_Element(RING_BUFFER * b,
|
||||
const uint8_t * this_element,
|
||||
uint8_t * data_element);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Put_Front(RING_BUFFER * b,
|
||||
const uint8_t * data_element);
|
||||
/* head */
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Put(RING_BUFFER * b,
|
||||
const uint8_t * data_element);
|
||||
/* pair of functions to use head memory directly */
|
||||
BACNET_STACK_EXPORT
|
||||
volatile void *Ringbuf_Data_Peek(RING_BUFFER * b);
|
||||
BACNET_STACK_EXPORT
|
||||
volatile void *Ringbuf_Peek_Next(RING_BUFFER const *b,
|
||||
const uint8_t * data_element);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Data_Put(
|
||||
RING_BUFFER * b, const volatile uint8_t *data_element);
|
||||
/* Note: element_count must be a power of two */
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Init(RING_BUFFER * b,
|
||||
volatile uint8_t * buffer,
|
||||
unsigned element_size,
|
||||
unsigned element_count);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Count(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Depth(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Depth_Reset(RING_BUFFER *b);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Ringbuf_Size(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Full(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Empty(RING_BUFFER const *b);
|
||||
/* tail */
|
||||
BACNET_STACK_EXPORT
|
||||
volatile void *Ringbuf_Peek(RING_BUFFER const *b);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Pop(RING_BUFFER *b, uint8_t *data_element);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Pop_Element(
|
||||
RING_BUFFER *b, const uint8_t *this_element, uint8_t *data_element);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Put_Front(RING_BUFFER *b, const uint8_t *data_element);
|
||||
/* head */
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Put(RING_BUFFER *b, const uint8_t *data_element);
|
||||
/* pair of functions to use head memory directly */
|
||||
BACNET_STACK_EXPORT
|
||||
volatile void *Ringbuf_Data_Peek(RING_BUFFER *b);
|
||||
BACNET_STACK_EXPORT
|
||||
volatile void *
|
||||
Ringbuf_Peek_Next(RING_BUFFER const *b, const uint8_t *data_element);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Data_Put(RING_BUFFER *b, const volatile uint8_t *data_element);
|
||||
/* Note: element_count must be a power of two */
|
||||
BACNET_STACK_EXPORT
|
||||
bool Ringbuf_Init(
|
||||
RING_BUFFER *b,
|
||||
volatile uint8_t *buffer,
|
||||
unsigned element_size,
|
||||
unsigned element_count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <stddef.h>
|
||||
#include "bacnet/basic/sys/sbuf.h"
|
||||
|
||||
void sbuf_init(STATIC_BUFFER *b, /* static buffer structure */
|
||||
void sbuf_init(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
char *data, /* data block */
|
||||
unsigned size)
|
||||
{ /* actual size, in bytes, of the data block or array of data */
|
||||
@@ -45,7 +46,8 @@ unsigned sbuf_count(STATIC_BUFFER const *b)
|
||||
}
|
||||
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
bool sbuf_put(STATIC_BUFFER *b, /* static buffer structure */
|
||||
bool sbuf_put(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
unsigned offset, /* where to start */
|
||||
const char *data, /* data to place in buffer */
|
||||
unsigned data_size)
|
||||
@@ -69,7 +71,8 @@ bool sbuf_put(STATIC_BUFFER *b, /* static buffer structure */
|
||||
}
|
||||
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
bool sbuf_append(STATIC_BUFFER *b, /* static buffer structure */
|
||||
bool sbuf_append(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
const char *data, /* data to place in buffer */
|
||||
unsigned data_size)
|
||||
{ /* how many bytes to add */
|
||||
@@ -83,7 +86,8 @@ bool sbuf_append(STATIC_BUFFER *b, /* static buffer structure */
|
||||
}
|
||||
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
bool sbuf_truncate(STATIC_BUFFER *b, /* static buffer structure */
|
||||
bool sbuf_truncate(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
unsigned count)
|
||||
{ /* total number of bytes in to remove */
|
||||
bool status = false; /* return value */
|
||||
|
||||
+38
-41
@@ -14,8 +14,8 @@
|
||||
|
||||
struct static_buffer_t {
|
||||
char *data; /* block of memory or array of data */
|
||||
unsigned size; /* actual size, in bytes, of the block of data */
|
||||
unsigned count; /* number of bytes in use */
|
||||
unsigned size; /* actual size, in bytes, of the block of data */
|
||||
unsigned count; /* number of bytes in use */
|
||||
};
|
||||
typedef struct static_buffer_t STATIC_BUFFER;
|
||||
|
||||
@@ -23,46 +23,43 @@ typedef struct static_buffer_t STATIC_BUFFER;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void sbuf_init(
|
||||
STATIC_BUFFER * b, /* static buffer structure */
|
||||
char *data, /* data block */
|
||||
unsigned size); /* actual size, in bytes, of the data block or array of data */
|
||||
BACNET_STACK_EXPORT
|
||||
void sbuf_init(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
char *data, /* data block */
|
||||
unsigned
|
||||
size); /* actual size, in bytes, of the data block or array of data */
|
||||
|
||||
/* returns true if size==0, false if size > 0 */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_empty(
|
||||
STATIC_BUFFER const *b);
|
||||
/* returns the data block, or NULL if not initialized */
|
||||
BACNET_STACK_EXPORT
|
||||
char *sbuf_data(
|
||||
STATIC_BUFFER const *b);
|
||||
/* returns the max size of the data block */
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned sbuf_size(
|
||||
STATIC_BUFFER const *b);
|
||||
/* returns the number of bytes used in the data block */
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned sbuf_count(
|
||||
STATIC_BUFFER const *b);
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_put(
|
||||
STATIC_BUFFER * b, /* static buffer structure */
|
||||
unsigned offset, /* where to start */
|
||||
const char *data, /* data to add */
|
||||
unsigned data_size); /* how many to add */
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_append(
|
||||
STATIC_BUFFER * b, /* static buffer structure */
|
||||
const char *data, /* data to append */
|
||||
unsigned data_size); /* how many to append */
|
||||
/* returns true if successful, false if count is bigger than size */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_truncate(
|
||||
STATIC_BUFFER * b, /* static buffer structure */
|
||||
unsigned count); /* new number of bytes used in buffer */
|
||||
/* returns true if size==0, false if size > 0 */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_empty(STATIC_BUFFER const *b);
|
||||
/* returns the data block, or NULL if not initialized */
|
||||
BACNET_STACK_EXPORT
|
||||
char *sbuf_data(STATIC_BUFFER const *b);
|
||||
/* returns the max size of the data block */
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned sbuf_size(STATIC_BUFFER const *b);
|
||||
/* returns the number of bytes used in the data block */
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned sbuf_count(STATIC_BUFFER const *b);
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_put(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
unsigned offset, /* where to start */
|
||||
const char *data, /* data to add */
|
||||
unsigned data_size); /* how many to add */
|
||||
/* returns true if successful, false if not enough room to append data */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_append(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
const char *data, /* data to append */
|
||||
unsigned data_size); /* how many to append */
|
||||
/* returns true if successful, false if count is bigger than size */
|
||||
BACNET_STACK_EXPORT
|
||||
bool sbuf_truncate(
|
||||
STATIC_BUFFER *b, /* static buffer structure */
|
||||
unsigned count); /* new number of bytes used in buffer */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user