From a1d0a5ff5ac15942666652c375c73c01fbffaa79 Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Thu, 19 Dec 2024 10:25:15 -0600 Subject: [PATCH] Added bitstring-bits-used-set API to use in audit-log status bits (#879) --- src/bacnet/bacstr.c | 18 ++++++++++++++++++ src/bacnet/bacstr.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/bacnet/bacstr.c b/src/bacnet/bacstr.c index d033663f..4f279cf5 100644 --- a/src/bacnet/bacstr.c +++ b/src/bacnet/bacstr.c @@ -116,6 +116,24 @@ uint8_t bitstring_bits_used(const BACNET_BIT_STRING *bit_string) return (bit_string ? bit_string->bits_used : 0); } +/** + * @brief Write the amount of bits used in the bit string structure. + * @param bit_string Pointer to the bit string structure. + * @param bits_used Number of bits in this bitstring + * @return true on success or false on error. + */ +bool bitstring_bits_used_set(BACNET_BIT_STRING *bit_string, uint8_t bits_used) +{ + bool status = false; + + if (bit_string) { + bit_string->bits_used = bits_used; + status = true; + } + + return status; +} + /** * Returns the number of bytes that a bit string is using. * diff --git a/src/bacnet/bacstr.h b/src/bacnet/bacstr.h index ad5bcf57..d4a325b9 100644 --- a/src/bacnet/bacstr.h +++ b/src/bacnet/bacstr.h @@ -45,6 +45,8 @@ BACNET_STACK_EXPORT bool bitstring_bit(const BACNET_BIT_STRING *bit_string, uint8_t bit_number); BACNET_STACK_EXPORT uint8_t bitstring_bits_used(const BACNET_BIT_STRING *bit_string); +BACNET_STACK_EXPORT +bool bitstring_bits_used_set(BACNET_BIT_STRING *bit_string, uint8_t bits_used); /* returns the number of bytes that a bit string is using */ BACNET_STACK_EXPORT uint8_t bitstring_bytes_used(const BACNET_BIT_STRING *bit_string);