Feature - added create/delete/COV services for analog, binary, and multistate objects (#612)

* Added Create/Delete object services to Analog Input, Analog Value, Binary Input, Binary Value, Multistate Input, Multistate Value object examples, and updated their units tests.
This commit is contained in:
Steve Karg
2024-04-03 13:27:03 -05:00
committed by GitHub
parent 8a0a01c0fa
commit 76d3680b5e
47 changed files with 4450 additions and 2919 deletions
File diff suppressed because it is too large Load Diff
+29 -29
View File
@@ -40,39 +40,39 @@
#include "bacnet/get_alarm_sum.h" #include "bacnet/get_alarm_sum.h"
#endif #endif
typedef struct analog_input_descr {
unsigned Event_State:3;
float Present_Value;
BACNET_RELIABILITY Reliability;
bool Out_Of_Service;
uint8_t Units;
float Prior_Value;
float COV_Increment;
bool Changed;
char* Object_Name;
char* Description;
#if defined(INTRINSIC_REPORTING)
uint32_t Time_Delay;
uint32_t Notification_Class;
float High_Limit;
float Low_Limit;
float Deadband;
unsigned Limit_Enable:2;
unsigned Event_Enable:3;
unsigned Notify_Type:1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */
uint32_t Remaining_Time_Delay;
/* AckNotification information */
ACK_NOTIFICATION Ack_notify_data;
#endif
} ANALOG_INPUT_DESCR;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
typedef struct analog_input_descr {
unsigned Event_State:3;
float Present_Value;
BACNET_RELIABILITY Reliability;
bool Out_Of_Service;
uint8_t Units;
float Prior_Value;
float COV_Increment;
bool Changed;
char* Object_Name;
char* Description;
#if defined(INTRINSIC_REPORTING)
uint32_t Time_Delay;
uint32_t Notification_Class;
float High_Limit;
float Low_Limit;
float Deadband;
unsigned Limit_Enable:2;
unsigned Event_Enable:3;
unsigned Notify_Type:1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */
uint32_t Remaining_Time_Delay;
/* AckNotification information */
ACK_NOTIFICATION Ack_notify_data;
#endif
} ANALOG_INPUT_DESCR;
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Analog_Input_Property_Lists( void Analog_Input_Property_Lists(
const int **pRequired, const int **pRequired,
+5 -1
View File
@@ -903,14 +903,18 @@ bool Analog_Output_Encode_Value_List(
bool status = false; bool status = false;
struct object_data *pObject; struct object_data *pObject;
const bool in_alarm = false; const bool in_alarm = false;
const bool fault = false; bool fault = false;
const bool overridden = false; const bool overridden = false;
pObject = Keylist_Data(Object_List, object_instance); pObject = Keylist_Data(Object_List, object_instance);
if (pObject) { if (pObject) {
if (pObject->Reliability != RELIABILITY_NO_FAULT_DETECTED) {
fault = true;
}
status = cov_value_list_encode_real(value_list, pObject->Prior_Value, status = cov_value_list_encode_real(value_list, pObject->Prior_Value,
in_alarm, fault, overridden, pObject->Out_Of_Service); in_alarm, fault, overridden, pObject->Out_Of_Service);
} }
return status; return status;
} }
File diff suppressed because it is too large Load Diff
+42 -57
View File
@@ -1,30 +1,16 @@
/************************************************************************** /**
* * @file
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg
* Copyright (C) 2011 Krzysztof Malorny <malornykrzysztof@gmail.com> * @date 2006
* * @brief Analog Value object is an input object with a present-value that
* Permission is hereby granted, free of charge, to any person obtaining * uses an single precision floating point data type.
* a copy of this software and associated documentation files (the * @section LICENSE
* "Software"), to deal in the Software without restriction, including * Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
* without limitation the rights to use, copy, modify, merge, publish, * Copyright (C) 2011 Krzysztof Malorny <malornykrzysztof@gmail.com>
* distribute, sublicense, and/or sell copies of the Software, and to * SPDX-License-Identifier: MIT
* permit persons to whom the Software is furnished to do so, subject to */
* the following conditions: #ifndef BACNET_ANALOG_VALUE_OBJECT_H
* #define BACNET_ANALOG_VALUE_OBJECT_H
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
#ifndef AV_H
#define AV_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -41,39 +27,38 @@
#include "bacnet/get_alarm_sum.h" #include "bacnet/get_alarm_sum.h"
#endif #endif
typedef struct analog_value_descr {
unsigned Event_State:3;
bool Out_Of_Service;
uint16_t Units;
float Present_Value;
float Prior_Value;
float COV_Increment;
bool Changed;
char* Object_Name;
char* Description;
BACNET_RELIABILITY Reliability;
#if defined(INTRINSIC_REPORTING)
uint32_t Time_Delay;
uint32_t Notification_Class;
float High_Limit;
float Low_Limit;
float Deadband;
unsigned Limit_Enable:2;
unsigned Event_Enable:3;
unsigned Notify_Type:1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */
uint32_t Remaining_Time_Delay;
/* AckNotification information */
ACK_NOTIFICATION Ack_notify_data;
#endif
} ANALOG_VALUE_DESCR;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
typedef struct analog_value_descr {
unsigned Event_State:3;
bool Out_Of_Service;
uint16_t Units;
float Present_Value;
float Prior_Value;
float COV_Increment;
bool Changed;
char* Object_Name;
char* Description;
#if defined(INTRINSIC_REPORTING)
uint32_t Time_Delay;
uint32_t Notification_Class;
float High_Limit;
float Low_Limit;
float Deadband;
unsigned Limit_Enable:2;
unsigned Event_Enable:3;
unsigned Notify_Type:1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */
uint32_t Remaining_Time_Delay;
/* AckNotification information */
ACK_NOTIFICATION Ack_notify_data;
#endif
} ANALOG_VALUE_DESCR;
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Analog_Value_Property_Lists( void Analog_Value_Property_Lists(
const int **pRequired, const int **pRequired,
+538 -246
View File
@@ -1,33 +1,17 @@
/************************************************************************** /**
* * @file
* @author Steve Karg
* @date 2006
* @brief Binary Input object is an input object with a present-value that
* uses an enumerated two state active/inactive data type.
* @section LICENSE
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net> * Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
* * SPDX-License-Identifier: MIT
* Permission is hereby granted, free of charge, to any person obtaining */
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
/* Binary Input Objects customize for your use */
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
/* BACnet Stack defines - first */ /* BACnet Stack defines - first */
#include "bacnet/bacdef.h" #include "bacnet/bacdef.h"
/* BACnet Stack API */ /* BACnet Stack API */
@@ -36,25 +20,33 @@
#include "bacnet/rp.h" #include "bacnet/rp.h"
#include "bacnet/wp.h" #include "bacnet/wp.h"
#include "bacnet/cov.h" #include "bacnet/cov.h"
#include "bacnet/basic/object/bi.h" #include "bacnet/basic/object/device.h"
#include "bacnet/basic/services.h" #include "bacnet/basic/services.h"
#include "bacnet/basic/sys/keylist.h"
/* me! */
#include "bacnet/basic/object/bi.h"
#ifndef MAX_BINARY_INPUTS static const char *Default_Active_Text = "Active";
#define MAX_BINARY_INPUTS 5 static const char *Default_Inactive_Text = "Inactive";
#endif struct object_data {
bool Out_Of_Service : 1;
/* stores the current value */ bool Change_Of_Value : 1;
static BACNET_BINARY_PV Present_Value[MAX_BINARY_INPUTS]; bool Present_Value : 1;
/* out of service decouples physical input from Present_Value */ bool Polarity : 1;
static bool Out_Of_Service[MAX_BINARY_INPUTS]; bool Write_Enabled : 1;
/* Change of Value flag */ uint8_t Reliability;
static bool Change_Of_Value[MAX_BINARY_INPUTS]; const char *Object_Name;
/* Polarity of Input */ const char *Active_Text;
static BACNET_POLARITY Polarity[MAX_BINARY_INPUTS]; const char *Inactive_Text;
/* stores the object name */ const char *Description;
static char* Object_Name[MAX_BINARY_INPUTS]; };
/* stores the description */ /* Key List for storing the object data sorted by instance number */
static char* Description[MAX_BINARY_INPUTS]; static OS_Keylist Object_List;
/* common object type */
static const BACNET_OBJECT_TYPE Object_Type = OBJECT_BINARY_INPUT;
/* callback for present value writes */
static binary_input_write_present_value_callback
Binary_Input_Write_Present_Value_Callback;
/* These three arrays are used by the ReadPropertyMultiple handler */ /* These three arrays are used by the ReadPropertyMultiple handler */
static const int Binary_Input_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Binary_Input_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
@@ -65,6 +57,14 @@ static const int Binary_Input_Properties_Optional[] = { PROP_DESCRIPTION, -1 };
static const int Binary_Input_Properties_Proprietary[] = { -1 }; static const int Binary_Input_Properties_Proprietary[] = { -1 };
/**
* Initialize the pointers for the required, the optional and the properitary
* value properties.
*
* @param pRequired - Pointer to the pointer of required values.
* @param pOptional - Pointer to the pointer of optional values.
* @param pProprietary - Pointer to the pointer of properitary values.
*/
void Binary_Input_Property_Lists( void Binary_Input_Property_Lists(
const int **pRequired, const int **pOptional, const int **pProprietary) const int **pRequired, const int **pOptional, const int **pProprietary)
{ {
@@ -81,73 +81,80 @@ void Binary_Input_Property_Lists(
return; return;
} }
/* we simply have 0-n object instances. Yours might be */ /**
/* more complex, and then you need validate that the */ * @brief Gets an object from the list using an instance number as the key
/* given instance exists */ * @param object_instance - object-instance number of the object
* @return object found in the list, or NULL if not found
*/
static struct object_data *Binary_Input_Object(uint32_t object_instance)
{
return Keylist_Data(Object_List, object_instance);
}
/**
* @brief Determines if a given Binary Input instance is valid
* @param object_instance - object-instance number of the object
* @return true if the instance is valid, and false if not
*/
bool Binary_Input_Valid_Instance(uint32_t object_instance) bool Binary_Input_Valid_Instance(uint32_t object_instance)
{ {
if (object_instance < MAX_BINARY_INPUTS) { struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
return true; return true;
} }
return false; return false;
} }
/* we simply have 0-n object instances. Yours might be */ /**
/* more complex, and then count how many you have */ * @brief Determines the number of objects
* @return Number of Analog Value objects
*/
unsigned Binary_Input_Count(void) unsigned Binary_Input_Count(void)
{ {
return MAX_BINARY_INPUTS; return Keylist_Count(Object_List);
} }
/* we simply have 0-n object instances. Yours might be */ /**
/* more complex, and then you need to return the instance */ * @brief Determines the object instance-number for a given 0..N index
/* that correlates to the correct index */ * of Binary Input objects where N is Binary_Input_Count().
* @param index - 0..MAX_BINARY_INPUTS value
* @return object instance-number for the given index
*/
uint32_t Binary_Input_Index_To_Instance(unsigned index) uint32_t Binary_Input_Index_To_Instance(unsigned index)
{ {
return index; return Keylist_Key(Object_List, index);
} }
void Binary_Input_Init(void) /**
{ * @brief For a given object instance-number, determines a 0..N index
static bool initialized = false; * of objects where N is the count.
unsigned i; * @param object_instance - object-instance number of the object
* @return index for the given instance-number, or count if not valid.
if (!initialized) { */
initialized = true;
/* initialize all the values */
for (i = 0; i < MAX_BINARY_INPUTS; i++) {
Present_Value[i] = BINARY_INACTIVE;
}
}
return;
}
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need to return the index */
/* that correlates to the correct instance number */
unsigned Binary_Input_Instance_To_Index(uint32_t object_instance) unsigned Binary_Input_Instance_To_Index(uint32_t object_instance)
{ {
unsigned index = MAX_BINARY_INPUTS; return Keylist_Index(Object_List, object_instance);
if (object_instance < MAX_BINARY_INPUTS) {
index = object_instance;
}
return index;
} }
/**
* For a given object instance-number, determines the present-value
*
* @param object_instance - object-instance number of the object
*
* @return present-value of the object
*/
BACNET_BINARY_PV Binary_Input_Present_Value(uint32_t object_instance) BACNET_BINARY_PV Binary_Input_Present_Value(uint32_t object_instance)
{ {
BACNET_BINARY_PV value = BINARY_INACTIVE; BACNET_BINARY_PV value = BINARY_INACTIVE;
unsigned index = 0; struct object_data *pObject;
index = Binary_Input_Instance_To_Index(object_instance); pObject = Binary_Input_Object(object_instance);
if (index < MAX_BINARY_INPUTS) { if (pObject) {
value = Present_Value[index]; value = pObject->Present_Value;
if (Polarity[index] != POLARITY_NORMAL) { if (pObject->Polarity != POLARITY_NORMAL) {
if (value == BINARY_INACTIVE) { if (value == BINARY_INACTIVE) {
value = BINARY_ACTIVE; value = BINARY_ACTIVE;
} else { } else {
@@ -159,151 +166,186 @@ BACNET_BINARY_PV Binary_Input_Present_Value(uint32_t object_instance)
return value; return value;
} }
/**
* @brief For a given object instance-number, checks the present-value for COV
* @param pObject - specific object with valid data
* @param value - floating point analog value
*/
static void Binary_Input_Present_Value_COV_Detect(
struct object_data *pObject, BACNET_BINARY_PV value)
{
if (pObject) {
if (pObject->Present_Value != value) {
pObject->Change_Of_Value = true;
}
}
}
/**
* @brief For a given object instance-number, returns the out-of-service
* property value
* @param object_instance - object-instance number of the object
* @return out-of-service property value
*/
bool Binary_Input_Out_Of_Service(uint32_t object_instance) bool Binary_Input_Out_Of_Service(uint32_t object_instance)
{ {
bool value = false; bool value = false;
unsigned index = 0; struct object_data *pObject;
index = Binary_Input_Instance_To_Index(object_instance); pObject = Binary_Input_Object(object_instance);
if (index < MAX_BINARY_INPUTS) { if (pObject) {
value = Out_Of_Service[index]; value = pObject->Out_Of_Service;
} }
return value; return value;
} }
bool Binary_Input_Change_Of_Value(uint32_t object_instance) /**
* @brief For a given object instance-number, sets the out-of-service property value
* @param object_instance - object-instance number of the object
* @param value - boolean out-of-service value
* @return true if the out-of-service property value was set
*/
void Binary_Input_Out_Of_Service_Set(uint32_t object_instance, bool value)
{ {
bool status = false; struct object_data *pObject;
unsigned index;
index = Binary_Input_Instance_To_Index(object_instance); pObject = Binary_Input_Object(object_instance);
if (index < MAX_BINARY_INPUTS) { if (pObject) {
status = Change_Of_Value[index]; if (pObject->Out_Of_Service != value) {
} pObject->Out_Of_Service = value;
pObject->Change_Of_Value = true;
return status; }
}
void Binary_Input_Change_Of_Value_Clear(uint32_t object_instance)
{
unsigned index;
index = Binary_Input_Instance_To_Index(object_instance);
if (index < MAX_BINARY_INPUTS) {
Change_Of_Value[index] = false;
} }
return; return;
} }
/** /**
* For a given object instance-number, loads the value_list with the COV data. * @brief For a given object, gets the Fault status flag
* * @param object_instance - object-instance number of the object
* @return true the status flag is in Fault
*/
static bool Binary_Input_Object_Fault(struct object_data *pObject)
{
bool fault = false;
if (pObject) {
if (pObject->Reliability != RELIABILITY_NO_FAULT_DETECTED) {
fault = true;
}
}
return fault;
}
/**
* @brief For a given object instance-number, gets the Fault status flag
* @param object_instance - object-instance number of the object
* @return true the status flag is in Fault
*/
static bool Binary_Input_Fault(uint32_t object_instance)
{
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
return Binary_Input_Object_Fault(pObject);
}
/**
* @brief For a given object instance-number, determines if the COV flag
* has been triggered.
* @param object_instance - object-instance number of the object
* @return true if the COV flag is set
*/
bool Binary_Input_Change_Of_Value(uint32_t object_instance)
{
bool status = false;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
status = pObject->Change_Of_Value;
}
return status;
}
/**
* @brief For a given object instance-number, clears the COV flag
* @param object_instance - object-instance number of the object
*/
void Binary_Input_Change_Of_Value_Clear(uint32_t object_instance)
{
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
pObject->Change_Of_Value = false;
}
return;
}
/**
* @brief For a given object instance-number, loads the value_list with the COV data.
* @param object_instance - object-instance number of the object * @param object_instance - object-instance number of the object
* @param value_list - list of COV data * @param value_list - list of COV data
*
* @return true if the value list is encoded * @return true if the value list is encoded
*/ */
bool Binary_Input_Encode_Value_List( bool Binary_Input_Encode_Value_List(
uint32_t object_instance, BACNET_PROPERTY_VALUE *value_list) uint32_t object_instance, BACNET_PROPERTY_VALUE *value_list)
{ {
bool status = false; bool status = false;
const bool in_alarm = false;
bool out_of_service = false;
bool fault = false;
const bool overridden = false;
BACNET_BINARY_PV present_value = BINARY_INACTIVE;
struct object_data *pObject;
if (value_list) { pObject = Binary_Input_Object(object_instance);
value_list->propertyIdentifier = PROP_PRESENT_VALUE; if (pObject) {
value_list->propertyArrayIndex = BACNET_ARRAY_ALL; if (pObject->Reliability != RELIABILITY_NO_FAULT_DETECTED) {
value_list->value.context_specific = false; fault = true;
value_list->value.tag = BACNET_APPLICATION_TAG_ENUMERATED;
value_list->value.next = NULL;
value_list->value.type.Enumerated =
Binary_Input_Present_Value(object_instance);
value_list->priority = BACNET_NO_PRIORITY;
value_list = value_list->next;
}
if (value_list) {
value_list->propertyIdentifier = PROP_STATUS_FLAGS;
value_list->propertyArrayIndex = BACNET_ARRAY_ALL;
value_list->value.context_specific = false;
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
value_list->value.next = NULL;
bitstring_init(&value_list->value.type.Bit_String);
bitstring_set_bit(
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, false);
bitstring_set_bit(
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, false);
bitstring_set_bit(
&value_list->value.type.Bit_String, STATUS_FLAG_OVERRIDDEN, false);
if (Binary_Input_Out_Of_Service(object_instance)) {
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_OUT_OF_SERVICE, true);
} else {
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_OUT_OF_SERVICE, false);
} }
value_list->priority = BACNET_NO_PRIORITY; out_of_service = pObject->Out_Of_Service;
value_list->next = NULL; if (pObject->Present_Value) {
status = true; present_value = BINARY_ACTIVE;
}
status = cov_value_list_encode_enumerated(value_list, present_value,
in_alarm, fault, overridden, out_of_service);
} }
return status; return status;
} }
/**
* @brief For a given object instance-number, sets the present-value
* @param object_instance - object-instance number of the object
* @param value - enumerated binary present-value
* @return true if values are within range and present-value is set.
*/
bool Binary_Input_Present_Value_Set( bool Binary_Input_Present_Value_Set(
uint32_t object_instance, BACNET_BINARY_PV value) uint32_t object_instance, BACNET_BINARY_PV value)
{ {
unsigned index = 0;
bool status = false; bool status = false;
struct object_data *pObject;
index = Binary_Input_Instance_To_Index(object_instance); pObject = Binary_Input_Object(object_instance);
if (index < MAX_BINARY_INPUTS) { if (pObject) {
if (Polarity[index] != POLARITY_NORMAL) { if (value <= MAX_BINARY_PV) {
if (value == BINARY_INACTIVE) { if (pObject->Polarity != POLARITY_NORMAL) {
value = BINARY_ACTIVE; if (value == BINARY_INACTIVE) {
} else { value = BINARY_ACTIVE;
value = BINARY_INACTIVE; } else {
value = BINARY_INACTIVE;
}
} }
} Binary_Input_Present_Value_COV_Detect(pObject, value);
if (Present_Value[index] != value) { pObject->Present_Value = true;
Change_Of_Value[index] = true; status = true;
}
Present_Value[index] = value;
status = true;
}
return status;
}
void Binary_Input_Out_Of_Service_Set(uint32_t object_instance, bool value)
{
unsigned index = 0;
index = Binary_Input_Instance_To_Index(object_instance);
if (index < MAX_BINARY_INPUTS) {
if (Out_Of_Service[index] != value) {
Change_Of_Value[index] = true;
}
Out_Of_Service[index] = value;
}
return;
}
bool Binary_Input_Object_Name(
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
unsigned index = 0;
index = Binary_Input_Instance_To_Index(object_instance);
if (index < MAX_BINARY_INPUTS) {
if (Object_Name[index] == NULL) {
sprintf(
text_string, "BINARY INPUT %lu", (unsigned long)object_instance);
status = characterstring_init_ansi(object_name, text_string);
} else {
status = characterstring_init_ansi(object_name, Object_Name[index]);
} }
} }
@@ -311,46 +353,140 @@ bool Binary_Input_Object_Name(
} }
/** /**
* For a given object instance-number, sets the object-name * For a given object instance-number, sets the present-value
* *
* @param object_instance - object-instance number of the object * @param object_instance - object-instance number of the object
* @param new_name - holds the object-name to be set * @param value - floating point analog value
* @param error_class - the BACnet error class
* @param error_code - BACnet Error code
* *
* @return true if object-name was set * @return true if values are within range and present-value is set.
*/ */
bool Binary_Input_Name_Set(uint32_t object_instance, char *new_name) static bool Binary_Input_Present_Value_Write(
uint32_t object_instance, BACNET_BINARY_PV value,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{ {
bool status = false; bool status = false;
if (object_instance < MAX_BINARY_INPUTS && new_name) { struct object_data *pObject;
status = true; BACNET_BINARY_PV old_value = BINARY_INACTIVE;
Object_Name[object_instance] = new_name;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
if (value <= MAX_BINARY_PV) {
if (pObject->Write_Enabled) {
old_value = pObject->Present_Value;
Binary_Input_Present_Value_COV_Detect(pObject, value);
pObject->Present_Value = value;
if (pObject->Out_Of_Service) {
/* The physical point that the object represents
is not in service. This means that changes to the
Present_Value property are decoupled from the
physical point when the value of Out_Of_Service
is true. */
} else if (Binary_Input_Write_Present_Value_Callback) {
Binary_Input_Write_Present_Value_Callback(
object_instance, old_value, value);
}
status = true;
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
} }
return status; return status;
} }
/**
* @brief Get the object name
* @param object_instance - object-instance number of the object
* @param object_name - holds the object-name to be retrieved
* @return true if object-name was retrieved
*/
bool Binary_Input_Object_Name(
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
if (pObject->Object_Name == NULL) {
sprintf(
text_string, "BINARY INPUT %lu", (unsigned long)object_instance);
status = characterstring_init_ansi(object_name, text_string);
} else {
status = characterstring_init_ansi(object_name, pObject->Object_Name);
}
}
return status;
}
/**
* @brief For a given object instance-number, sets the object-name
* @param object_instance - object-instance number of the object
* @param new_name - holds the object-name to be set
* @return true if object-name was set
*/
bool Binary_Input_Name_Set(uint32_t object_instance, char *new_name)
{
bool status = false;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
if (new_name) {
status = true;
pObject->Object_Name = new_name;
}
}
return status;
}
/**
* @brief For a given object instance-number, returns the polarity property.
* @param object_instance - object-instance number of the object
* @return the polarity property of the object.
*/
BACNET_POLARITY Binary_Input_Polarity(uint32_t object_instance) BACNET_POLARITY Binary_Input_Polarity(uint32_t object_instance)
{ {
BACNET_POLARITY polarity = POLARITY_NORMAL; BACNET_POLARITY polarity = POLARITY_NORMAL;
unsigned index = 0; struct object_data *pObject;
index = Binary_Input_Instance_To_Index(object_instance); pObject = Binary_Input_Object(object_instance);
if (index < MAX_BINARY_INPUTS) { if (pObject) {
polarity = Polarity[index]; polarity = pObject->Polarity;
} }
return polarity; return polarity;
} }
/**
* @brief For a given object instance-number, sets the polarity property
* @param object_instance - object-instance number of the object
* @param polarity - polarity property value
* @return true if polarity was set
*/
bool Binary_Input_Polarity_Set( bool Binary_Input_Polarity_Set(
uint32_t object_instance, BACNET_POLARITY polarity) uint32_t object_instance, BACNET_POLARITY polarity)
{ {
bool status = false; bool status = false;
unsigned index = 0; struct object_data *pObject;
index = Binary_Input_Instance_To_Index(object_instance); pObject = Binary_Input_Object(object_instance);
if (index < MAX_BINARY_INPUTS) { if (pObject) {
Polarity[index] = polarity; pObject->Polarity = polarity;
} }
return status; return status;
@@ -364,12 +500,14 @@ bool Binary_Input_Polarity_Set(
char *Binary_Input_Description(uint32_t object_instance) char *Binary_Input_Description(uint32_t object_instance)
{ {
char *name = NULL; char *name = NULL;
struct object_data *pObject;
if (object_instance < MAX_BINARY_INPUTS) { pObject = Binary_Input_Object(object_instance);
if (Description[object_instance] == NULL) { if (pObject) {
if (pObject->Description == NULL) {
name = ""; name = "";
} else { } else {
name = Description[object_instance]; name = (char *)pObject->Description;
} }
} }
@@ -385,17 +523,27 @@ char *Binary_Input_Description(uint32_t object_instance)
bool Binary_Input_Description_Set(uint32_t object_instance, char *new_name) bool Binary_Input_Description_Set(uint32_t object_instance, char *new_name)
{ {
bool status = false; /* return value */ bool status = false; /* return value */
struct object_data *pObject;
if (object_instance < MAX_BINARY_INPUTS && new_name) { pObject = Binary_Input_Object(object_instance);
if (pObject) {
status = true; status = true;
Description[object_instance] = new_name; pObject->Description = new_name;
} }
return status; return status;
} }
/* return apdu length, or BACNET_STATUS_ERROR on error */ /**
/* assumption - object already exists, and has been bounds checked */ * ReadProperty handler for this object. For the given ReadProperty
* data, the application_data is loaded or the error flags are set.
*
* @param rpdata - BACNET_READ_PROPERTY_DATA data, including
* requested data and space for the reply, or error response.
*
* @return number of APDU bytes in the response, or
* BACNET_STATUS_ERROR on error.
*/
int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata) int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
{ {
int apdu_len = 0; /* return value */ int apdu_len = 0; /* return value */
@@ -412,7 +560,7 @@ int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
switch (rpdata->object_property) { switch (rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
apdu_len = encode_application_object_id( apdu_len = encode_application_object_id(
&apdu[0], OBJECT_BINARY_INPUT, rpdata->object_instance); &apdu[0], Object_Type, rpdata->object_instance);
break; break;
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
/* note: object name must be unique in our device */ /* note: object name must be unique in our device */
@@ -420,18 +568,11 @@ int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
apdu_len = apdu_len =
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
break; break;
case PROP_DESCRIPTION:
characterstring_init_ansi(&char_string,
Binary_Input_Description(rpdata->object_instance));
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
break;
case PROP_OBJECT_TYPE: case PROP_OBJECT_TYPE:
apdu_len = apdu_len =
encode_application_enumerated(&apdu[0], OBJECT_BINARY_INPUT); encode_application_enumerated(&apdu[0], Object_Type);
break; break;
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
/* note: you need to look up the actual value */
apdu_len = encode_application_enumerated( apdu_len = encode_application_enumerated(
&apdu[0], Binary_Input_Present_Value(rpdata->object_instance)); &apdu[0], Binary_Input_Present_Value(rpdata->object_instance));
break; break;
@@ -439,14 +580,14 @@ int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
/* note: see the details in the standard on how to use these */ /* note: see the details in the standard on how to use these */
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false); bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false); state = Binary_Input_Fault(rpdata->object_instance);
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, state);
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
state = Binary_Input_Out_Of_Service(rpdata->object_instance); state = Binary_Input_Out_Of_Service(rpdata->object_instance);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state); bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, state);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string); apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break; break;
case PROP_EVENT_STATE: case PROP_EVENT_STATE:
/* note: see the details in the standard on how to use this */
apdu_len = apdu_len =
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL); encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
break; break;
@@ -458,6 +599,12 @@ int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
apdu_len = encode_application_enumerated( apdu_len = encode_application_enumerated(
&apdu[0], Binary_Input_Polarity(rpdata->object_instance)); &apdu[0], Binary_Input_Polarity(rpdata->object_instance));
break; break;
case PROP_DESCRIPTION:
characterstring_init_ansi(&char_string,
Binary_Input_Description(rpdata->object_instance));
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
break;
default: default:
rpdata->error_class = ERROR_CLASS_PROPERTY; rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY; rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
@@ -474,7 +621,15 @@ int Binary_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
return apdu_len; return apdu_len;
} }
/* returns true if successful */ /**
* WriteProperty handler for this object. For the given WriteProperty
* data, the application_data is loaded or the error flags are set.
*
* @param wp_data - BACNET_WRITE_PROPERTY_DATA data, including
* requested data and space for the reply, or error response.
*
* @return false if an error is loaded, true if no errors
*/
bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data) bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
{ {
bool status = false; /* return value */ bool status = false; /* return value */
@@ -502,14 +657,10 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = write_property_type_valid( status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED); wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) { if (status) {
if (value.type.Enumerated <= MAX_BINARY_PV) { status =
Binary_Input_Present_Value_Set(wp_data->object_instance, Binary_Input_Present_Value_Write(wp_data->object_instance,
(BACNET_BINARY_PV)value.type.Enumerated); value.type.Enumerated,
} else { &wp_data->error_class, &wp_data->error_code);
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} }
break; break;
case PROP_OUT_OF_SERVICE: case PROP_OUT_OF_SERVICE:
@@ -534,20 +685,161 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
} }
} }
break; break;
case PROP_OBJECT_IDENTIFIER:
case PROP_OBJECT_NAME:
case PROP_DESCRIPTION:
case PROP_OBJECT_TYPE:
case PROP_STATUS_FLAGS:
case PROP_EVENT_STATE:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
default: default:
wp_data->error_class = ERROR_CLASS_PROPERTY; if (property_lists_member(
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY; Binary_Input_Properties_Required,
Binary_Input_Properties_Optional,
Binary_Input_Properties_Proprietary,
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; break;
} }
return status; return status;
} }
/**
* @brief Sets a callback used when present-value is written from BACnet
* @param cb - callback used to provide indications
*/
void Binary_Input_Write_Present_Value_Callback_Set(
binary_input_write_present_value_callback cb)
{
Binary_Input_Write_Present_Value_Callback = cb;
}
/**
* @brief Determines a object write-enabled flag state
* @param object_instance - object-instance number of the object
* @return write-enabled status flag
*/
bool Binary_Input_Write_Enabled(uint32_t object_instance)
{
bool value = false;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
value = pObject->Write_Enabled;
}
return value;
}
/**
* @brief For a given object instance-number, sets the write-enabled flag
* @param object_instance - object-instance number of the object
*/
void Binary_Input_Write_Enable(uint32_t object_instance)
{
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
pObject->Write_Enabled = true;
}
}
/**
* @brief For a given object instance-number, clears the write-enabled flag
* @param object_instance - object-instance number of the object
*/
void Binary_Input_Write_Disable(uint32_t object_instance)
{
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
pObject->Write_Enabled = false;
}
}
/**
* Creates a Binary Input object
* @param object_instance - object-instance number of the object
*/
uint32_t Binary_Input_Create(uint32_t object_instance)
{
struct object_data *pObject = NULL;
int index = 0;
pObject = Binary_Input_Object(object_instance);
if (!pObject) {
pObject = calloc(1, sizeof(struct object_data));
if (pObject) {
pObject->Object_Name = NULL;
pObject->Description = NULL;
pObject->Reliability = RELIABILITY_NO_FAULT_DETECTED;
pObject->Present_Value = false;
pObject->Out_Of_Service = false;
pObject->Active_Text = Default_Active_Text;
pObject->Inactive_Text = Default_Inactive_Text;
pObject->Change_Of_Value = false;
pObject->Write_Enabled = false;
pObject->Polarity = false;
/* add to list */
index = Keylist_Data_Add(Object_List, object_instance, pObject);
if (index < 0) {
free(pObject);
return BACNET_MAX_INSTANCE;
}
} else {
return BACNET_MAX_INSTANCE;
}
}
return object_instance;
}
/**
* Initializes the Binary Input object data
*/
void Binary_Input_Cleanup(void)
{
struct object_data *pObject;
if (Object_List) {
do {
pObject = Keylist_Data_Pop(Object_List);
if (pObject) {
free(pObject);
}
} while (pObject);
Keylist_Delete(Object_List);
Object_List = NULL;
}
}
/**
* Delete a specific Binary Input object
* @param object_instance - object-instance number of the object
* @return true if the object is deleted
*/
bool Binary_Input_Delete(uint32_t object_instance)
{
bool status = false;
struct object_data *pObject;
pObject = Keylist_Data_Delete(Object_List, object_instance);
if (pObject) {
free(pObject);
status = true;
}
return status;
}
/**
* Initializes the Binary Input object data
*/
void Binary_Input_Init(void)
{
if (!Object_List) {
Object_List = Keylist_Create();
}
}
+26 -27
View File
@@ -1,29 +1,15 @@
/************************************************************************** /**
* * @file
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg
* * @date 2006
* Permission is hereby granted, free of charge, to any person obtaining * @brief Binary Input object is an input object with a present-value that
* a copy of this software and associated documentation files (the * uses an enumerated two state active/inactive data type.
* "Software"), to deal in the Software without restriction, including * @section LICENSE
* without limitation the rights to use, copy, modify, merge, publish, * Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
* distribute, sublicense, and/or sell copies of the Software, and to * SPDX-License-Identifier: MIT
* permit persons to whom the Software is furnished to do so, subject to */
* the following conditions: #ifndef BACNET_BINARY_INPUT_OBJECT_H
* #define BACNET_BINARY_INPUT_OBJECT_H
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
#ifndef BI_H
#define BI_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -34,6 +20,16 @@
#include "bacnet/rp.h" #include "bacnet/rp.h"
#include "bacnet/wp.h" #include "bacnet/wp.h"
/**
* @brief Callback for gateway write present value request
* @param object_instance - object-instance number of the object
* @param old_value - binary preset-value prior to write
* @param value - binary preset-value of the write
*/
typedef void (*binary_input_write_present_value_callback)(
uint32_t object_instance, BACNET_BINARY_PV old_value,
BACNET_BINARY_PV value);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@@ -100,6 +96,7 @@ extern "C" {
bool Binary_Input_Inactive_Text_Set( bool Binary_Input_Inactive_Text_Set(
uint32_t instance, uint32_t instance,
char *new_name); char *new_name);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
char *Binary_Input_Active_Text( char *Binary_Input_Active_Text(
uint32_t instance); uint32_t instance);
@@ -138,10 +135,12 @@ extern "C" {
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
int Binary_Input_Read_Property( int Binary_Input_Read_Property(
BACNET_READ_PROPERTY_DATA * rpdata); BACNET_READ_PROPERTY_DATA * rpdata);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
bool Binary_Input_Write_Property( bool Binary_Input_Write_Property(
BACNET_WRITE_PROPERTY_DATA * wp_data); BACNET_WRITE_PROPERTY_DATA * wp_data);
BACNET_STACK_EXPORT
void Binary_Input_Write_Present_Value_Callback_Set(
binary_input_write_present_value_callback cb);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
uint32_t Binary_Input_Create( uint32_t Binary_Input_Create(
+17 -26
View File
@@ -79,7 +79,7 @@ static binary_output_write_present_value_callback
Binary_Output_Write_Present_Value_Callback; Binary_Output_Write_Present_Value_Callback;
/* These three arrays are used by the ReadPropertyMultiple handler */ /* These three arrays are used by the ReadPropertyMultiple handler */
static const int Binary_Output_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
PROP_EVENT_STATE, PROP_OUT_OF_SERVICE, PROP_POLARITY, PROP_PRIORITY_ARRAY, PROP_EVENT_STATE, PROP_OUT_OF_SERVICE, PROP_POLARITY, PROP_PRIORITY_ARRAY,
PROP_RELINQUISH_DEFAULT, PROP_RELINQUISH_DEFAULT,
@@ -88,10 +88,10 @@ static const int Binary_Output_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
#endif #endif
-1 }; -1 };
static const int Binary_Output_Properties_Optional[] = { PROP_RELIABILITY, static const int Properties_Optional[] = { PROP_RELIABILITY,
PROP_DESCRIPTION, PROP_ACTIVE_TEXT, PROP_INACTIVE_TEXT, -1 }; PROP_DESCRIPTION, PROP_ACTIVE_TEXT, PROP_INACTIVE_TEXT, -1 };
static const int Binary_Output_Properties_Proprietary[] = { -1 }; static const int Properties_Proprietary[] = { -1 };
/** /**
* Returns the list of required, optional, and proprietary properties. * Returns the list of required, optional, and proprietary properties.
@@ -108,13 +108,13 @@ void Binary_Output_Property_Lists(
const int **pRequired, const int **pOptional, const int **pProprietary) const int **pRequired, const int **pOptional, const int **pProprietary)
{ {
if (pRequired) { if (pRequired) {
*pRequired = Binary_Output_Properties_Required; *pRequired = Properties_Required;
} }
if (pOptional) { if (pOptional) {
*pOptional = Binary_Output_Properties_Optional; *pOptional = Properties_Optional;
} }
if (pProprietary) { if (pProprietary) {
*pProprietary = Binary_Output_Properties_Proprietary; *pProprietary = Properties_Proprietary;
} }
return; return;
@@ -340,7 +340,7 @@ bool Binary_Output_Present_Value_Relinquish(
* @brief For a given object instance-number, writes the present-value to the * @brief For a given object instance-number, writes the present-value to the
* remote node * remote node
* @param object_instance - object-instance number of the object * @param object_instance - object-instance number of the object
* @param value - floating point analog value * @param value - present-value
* @param priority - priority-array index value 1..16 * @param priority - priority-array index value 1..16
* @param error_class - the BACnet error class * @param error_class - the BACnet error class
* @param error_code - BACnet Error code * @param error_code - BACnet Error code
@@ -911,11 +911,12 @@ bool Binary_Output_Encode_Value_List(
bool status = false; bool status = false;
struct object_data *pObject; struct object_data *pObject;
const bool in_alarm = false; const bool in_alarm = false;
const bool fault = false; bool fault = false;
const bool overridden = false; const bool overridden = false;
pObject = Keylist_Data(Object_List, object_instance); pObject = Keylist_Data(Object_List, object_instance);
if (pObject) { if (pObject) {
fault = Binary_Output_Object_Fault(pObject);
status = status =
cov_value_list_encode_enumerated(value_list, pObject->Present_Value, cov_value_list_encode_enumerated(value_list, pObject->Present_Value,
in_alarm, fault, overridden, pObject->Out_Of_Service); in_alarm, fault, overridden, pObject->Out_Of_Service);
@@ -1117,25 +1118,15 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->object_instance, value.type.Boolean); wp_data->object_instance, value.type.Boolean);
} }
break; break;
case PROP_OBJECT_IDENTIFIER:
case PROP_OBJECT_TYPE:
case PROP_OBJECT_NAME:
case PROP_STATUS_FLAGS:
case PROP_EVENT_STATE:
case PROP_DESCRIPTION:
case PROP_POLARITY:
case PROP_RELIABILITY:
case PROP_ACTIVE_TEXT:
case PROP_INACTIVE_TEXT:
#if (BACNET_PROTOCOL_REVISION >= 17)
case PROP_CURRENT_COMMAND_PRIORITY:
#endif
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
default: default:
wp_data->error_class = ERROR_CLASS_PROPERTY; if (property_lists_member(Properties_Required, Properties_Optional,
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY; Properties_Proprietary, 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; break;
} }
/* not using len at this time */ /* not using len at this time */
File diff suppressed because it is too large Load Diff
+22 -27
View File
@@ -1,30 +1,15 @@
/************************************************************************** /**
* * @file
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg
* * @date 2006
* Permission is hereby granted, free of charge, to any person obtaining * @brief Binary Value object is an input object with a present-value that
* a copy of this software and associated documentation files (the * uses an enumerated two state active/inactive data type.
* "Software"), to deal in the Software without restriction, including * @section LICENSE
* without limitation the rights to use, copy, modify, merge, publish, * Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
* distribute, sublicense, and/or sell copies of the Software, and to * SPDX-License-Identifier: MIT
* permit persons to whom the Software is furnished to do so, subject to */
* the following conditions: #ifndef BACNET_BINARY_VALUE_OBJECT_H
* #define BACNET_BINARY_VALUE_OBJECT_H
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
#ifndef BV_H
#define BV_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
/* BACnet Stack defines - first */ /* BACnet Stack defines - first */
@@ -34,6 +19,16 @@
#include "bacnet/rp.h" #include "bacnet/rp.h"
#include "bacnet/wp.h" #include "bacnet/wp.h"
/**
* @brief Callback for gateway write present value request
* @param object_instance - object-instance number of the object
* @param old_value - binary preset-value prior to write
* @param value - binary preset-value of the write
*/
typedef void (*binary_value_write_present_value_callback)(
uint32_t object_instance, BACNET_BINARY_PV old_value,
BACNET_BINARY_PV value);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
+31 -44
View File
@@ -1,31 +1,13 @@
/************************************************************************** /**
* * @file
* Copyright (C) 2005,2006,2009 Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg
* * @date 2005
* Permission is hereby granted, free of charge, to any person obtaining * @brief Base "class" for handling all BACnet objects belonging
* a copy of this software and associated documentation files (the * to a BACnet device, as well as Device-specific properties.
* "Software"), to deal in the Software without restriction, including * @section LICENSE
* without limitation the rights to use, copy, modify, merge, publish, * Copyright (C) 2005 Steve Karg <skarg@users.sourceforge.net>
* distribute, sublicense, and/or sell copies of the Software, and to * SPDX-License-Identifier: MIT
* permit persons to whom the Software is furnished to do so, subject to */
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
/** @file device.c Base "class" for handling all BACnet objects belonging
* to a BACnet device, as well as Device-specific properties. */
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@@ -124,13 +106,14 @@ static object_functions_t My_Object_Table[] = {
Analog_Input_Encode_Value_List, Analog_Input_Change_Of_Value, Analog_Input_Encode_Value_List, Analog_Input_Change_Of_Value,
Analog_Input_Change_Of_Value_Clear, Analog_Input_Intrinsic_Reporting, Analog_Input_Change_Of_Value_Clear, Analog_Input_Intrinsic_Reporting,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
NULL /* Create */, NULL /* Delete */, NULL /* Timer */ }, Analog_Input_Create, Analog_Input_Delete, NULL /* Timer */ },
{ OBJECT_ANALOG_OUTPUT, Analog_Output_Init, Analog_Output_Count, { OBJECT_ANALOG_OUTPUT, Analog_Output_Init, Analog_Output_Count,
Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance, Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance,
Analog_Output_Object_Name, Analog_Output_Read_Property, Analog_Output_Object_Name, Analog_Output_Read_Property,
Analog_Output_Write_Property, Analog_Output_Property_Lists, Analog_Output_Write_Property, Analog_Output_Property_Lists,
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */, NULL /* ReadRangeInfo */, NULL /* Iterator */,
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */, Analog_Output_Encode_Value_List, Analog_Output_Change_Of_Value,
Analog_Output_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
Analog_Output_Create, Analog_Output_Delete, NULL /* Timer */ }, Analog_Output_Create, Analog_Output_Delete, NULL /* Timer */ },
{ OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count, { OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
@@ -141,7 +124,7 @@ static object_functions_t My_Object_Table[] = {
Analog_Value_Encode_Value_List, Analog_Value_Change_Of_Value, Analog_Value_Encode_Value_List, Analog_Value_Change_Of_Value,
Analog_Value_Change_Of_Value_Clear, Analog_Value_Intrinsic_Reporting, Analog_Value_Change_Of_Value_Clear, Analog_Value_Intrinsic_Reporting,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
NULL /* Create */, NULL /* Delete */, NULL /* Timer */ }, Analog_Value_Create, Analog_Value_Delete, NULL /* Timer */ },
{ OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count, { OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance, Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
Binary_Input_Object_Name, Binary_Input_Read_Property, Binary_Input_Object_Name, Binary_Input_Read_Property,
@@ -150,23 +133,25 @@ static object_functions_t My_Object_Table[] = {
Binary_Input_Encode_Value_List, Binary_Input_Change_Of_Value, Binary_Input_Encode_Value_List, Binary_Input_Change_Of_Value,
Binary_Input_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */, Binary_Input_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
NULL /* Create */, NULL /* Delete */, NULL /* Timer */ }, Binary_Input_Create, Binary_Input_Delete, NULL /* Timer */ },
{ OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count, { OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count,
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance, Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
Binary_Output_Object_Name, Binary_Output_Read_Property, Binary_Output_Object_Name, Binary_Output_Read_Property,
Binary_Output_Write_Property, Binary_Output_Property_Lists, Binary_Output_Write_Property, Binary_Output_Property_Lists,
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */, NULL /* ReadRangeInfo */, NULL /* Iterator */,
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */, Binary_Output_Encode_Value_List, Binary_Output_Change_Of_Value,
Binary_Output_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
Binary_Output_Create, Binary_Output_Delete, NULL /* Timer */ }, Binary_Output_Create, Binary_Output_Delete, NULL /* Timer */ },
{ OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count, { OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance, Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
Binary_Value_Object_Name, Binary_Value_Read_Property, Binary_Value_Object_Name, Binary_Value_Read_Property,
Binary_Value_Write_Property, Binary_Value_Property_Lists, Binary_Value_Write_Property, Binary_Value_Property_Lists,
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */, NULL /* ReadRangeInfo */, NULL /* Iterator */,
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */, Binary_Value_Encode_Value_List, Binary_Value_Change_Of_Value,
Binary_Value_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
NULL /* Create */, NULL /* Delete */, NULL /* Timer */ }, Binary_Value_Create, Binary_Value_Delete, NULL /* Timer */ },
{ OBJECT_CALENDAR, Calendar_Init, Calendar_Count, { OBJECT_CALENDAR, Calendar_Init, Calendar_Count,
Calendar_Index_To_Instance, Calendar_Valid_Instance, Calendar_Index_To_Instance, Calendar_Valid_Instance,
Calendar_Object_Name, Calendar_Read_Property, Calendar_Object_Name, Calendar_Read_Property,
@@ -242,17 +227,19 @@ static object_functions_t My_Object_Table[] = {
Multistate_Input_Index_To_Instance, Multistate_Input_Valid_Instance, Multistate_Input_Index_To_Instance, Multistate_Input_Valid_Instance,
Multistate_Input_Object_Name, Multistate_Input_Read_Property, Multistate_Input_Object_Name, Multistate_Input_Read_Property,
Multistate_Input_Write_Property, Multistate_Input_Property_Lists, Multistate_Input_Write_Property, Multistate_Input_Property_Lists,
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */, NULL /* ReadRangeInfo */, NULL /* Iterator */,
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */, Multistate_Input_Encode_Value_List, Multistate_Input_Change_Of_Value,
Multistate_Input_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
NULL /* Create */, NULL /* Delete */, NULL /* Timer */ }, Multistate_Input_Create, Multistate_Input_Delete, NULL /* Timer */ },
{ OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init, { OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
Multistate_Output_Count, Multistate_Output_Index_To_Instance, Multistate_Output_Count, Multistate_Output_Index_To_Instance,
Multistate_Output_Valid_Instance, Multistate_Output_Object_Name, Multistate_Output_Valid_Instance, Multistate_Output_Object_Name,
Multistate_Output_Read_Property, Multistate_Output_Write_Property, Multistate_Output_Read_Property, Multistate_Output_Write_Property,
Multistate_Output_Property_Lists, NULL /* ReadRangeInfo */, Multistate_Output_Property_Lists, NULL /* ReadRangeInfo */,
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */, NULL /* Iterator */,
NULL /* COV Clear */, NULL /* Intrinsic Reporting */, Multistate_Output_Encode_Value_List, Multistate_Output_Change_Of_Value,
Multistate_Output_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
Multistate_Output_Create, Multistate_Output_Delete, NULL /* Timer */ }, Multistate_Output_Create, Multistate_Output_Delete, NULL /* Timer */ },
{ OBJECT_MULTI_STATE_VALUE, Multistate_Value_Init, Multistate_Value_Count, { OBJECT_MULTI_STATE_VALUE, Multistate_Value_Init, Multistate_Value_Count,
@@ -263,7 +250,7 @@ static object_functions_t My_Object_Table[] = {
Multistate_Value_Encode_Value_List, Multistate_Value_Change_Of_Value, Multistate_Value_Encode_Value_List, Multistate_Value_Change_Of_Value,
Multistate_Value_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */, Multistate_Value_Change_Of_Value_Clear, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */, NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
NULL /* Create */, NULL /* Delete */, NULL /* Timer */ }, Multistate_Value_Create, Multistate_Value_Delete, NULL /* Timer */ },
{ OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count, { OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance, Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance,
Trend_Log_Object_Name, Trend_Log_Read_Property, Trend_Log_Object_Name, Trend_Log_Read_Property,
File diff suppressed because it is too large Load Diff
+22 -26
View File
@@ -1,29 +1,15 @@
/************************************************************************** /**
* * @file
* Copyright (C) 2005 Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg
* * @date 2009
* Permission is hereby granted, free of charge, to any person obtaining * @brief Multi-State object is an input object with a present-value that
* a copy of this software and associated documentation files (the * uses an integer data type with a sequence of 1 to N values.
* "Software"), to deal in the Software without restriction, including * @section LICENSE
* without limitation the rights to use, copy, modify, merge, publish, * Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
* distribute, sublicense, and/or sell copies of the Software, and to * SPDX-License-Identifier: MIT
* permit persons to whom the Software is furnished to do so, subject to */
* the following conditions: #ifndef BACNET_MULTI_STATE_INPUT_H
* #define BACNET_MULTI_STATE_INPUT_H
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
#ifndef MS_INPUT_H
#define MS_INPUT_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -34,6 +20,16 @@
#include "bacnet/rp.h" #include "bacnet/rp.h"
#include "bacnet/wp.h" #include "bacnet/wp.h"
/**
* @brief Callback for gateway write present value request
* @param object_instance - object-instance number of the object
* @param old_value - multistate preset-value prior to write
* @param value - multistate preset-value of the write
*/
typedef void (*multistate_input_write_present_value_callback)(
uint32_t object_instance, uint32_t old_value,
uint32_t value);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
+11 -17
View File
@@ -1100,24 +1100,18 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->object_instance, value.type.Boolean); wp_data->object_instance, value.type.Boolean);
} }
break; break;
case PROP_OBJECT_NAME:
case PROP_OBJECT_IDENTIFIER:
case PROP_OBJECT_TYPE:
case PROP_STATE_TEXT:
case PROP_STATUS_FLAGS:
case PROP_EVENT_STATE:
case PROP_NUMBER_OF_STATES:
case PROP_RELIABILITY:
case PROP_DESCRIPTION:
#if (BACNET_PROTOCOL_REVISION >= 17)
case PROP_CURRENT_COMMAND_PRIORITY:
#endif
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
default: default:
wp_data->error_class = ERROR_CLASS_PROPERTY; if (property_lists_member(
wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY; Properties_Required,
Properties_Optional,
Properties_Proprietary,
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; break;
} }
File diff suppressed because it is too large Load Diff
+22 -26
View File
@@ -1,29 +1,15 @@
/************************************************************************** /**
* * @file
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg
* * @date 2009
* Permission is hereby granted, free of charge, to any person obtaining * @brief Multi-State object is an input object with a present-value that
* a copy of this software and associated documentation files (the * uses an integer data type with a sequence of 1 to N values.
* "Software"), to deal in the Software without restriction, including * @section LICENSE
* without limitation the rights to use, copy, modify, merge, publish, * Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
* distribute, sublicense, and/or sell copies of the Software, and to * SPDX-License-Identifier: MIT
* permit persons to whom the Software is furnished to do so, subject to */
* the following conditions: #ifndef BACNET_MULTI_STATE_VALUE_H
* #define BACNET_MULTI_STATE_VALUE_H
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*********************************************************************/
#ifndef MULTISTATE_VALUE_H
#define MULTISTATE_VALUE_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -34,6 +20,16 @@
#include "bacnet/rp.h" #include "bacnet/rp.h"
#include "bacnet/wp.h" #include "bacnet/wp.h"
/**
* @brief Callback for gateway write present value request
* @param object_instance - object-instance number of the object
* @param old_value - multistate preset-value prior to write
* @param value - multistate preset-value of the write
*/
typedef void (*multistate_value_write_present_value_callback)(
uint32_t object_instance, uint32_t old_value,
uint32_t value);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
+8 -2
View File
@@ -23,10 +23,12 @@ set(ZTST_DIR "${TST_DIR}/ztest/src")
add_compile_definitions( add_compile_definitions(
BIG_ENDIAN=0 BIG_ENDIAN=0
CONFIG_ZTEST=1 CONFIG_ZTEST=1
INTRINSIC_REPORTING=1
) )
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,10 +45,8 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/bacapp.c ${SRC_DIR}/bacnet/bacapp.c
${SRC_DIR}/bacnet/bacdevobjpropref.c ${SRC_DIR}/bacnet/bacdevobjpropref.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
@@ -59,8 +59,14 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
./stubs.c
${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+25 -36
View File
@@ -1,16 +1,15 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/ai.h> #include <bacnet/basic/object/ai.h>
#include <bacnet/bactext.h> #include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -26,36 +25,26 @@ ZTEST(ai_tests, testAnalogInput)
static void testAnalogInput(void) static void testAnalogInput(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Analog_Input_Init(); Analog_Input_Init();
rpdata.application_data = &apdu[0]; object_instance = Analog_Input_Create(object_instance);
rpdata.application_data_len = sizeof(apdu); count = Analog_Input_Count();
rpdata.object_type = OBJECT_ANALOG_INPUT; zassert_true(count == 1, NULL);
rpdata.object_instance = instance; test_object_instance = Analog_Input_Index_To_Instance(0);
rpdata.array_index = BACNET_ARRAY_ALL; zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
Analog_Input_Property_Lists(&required_property, NULL, NULL); OBJECT_ANALOG_INPUT,
while ((*required_property) >= 0) { object_instance,
rpdata.object_property = *required_property; Analog_Input_Property_Lists,
len = Analog_Input_Read_Property(&rpdata); Analog_Input_Read_Property,
zassert_true(len >= 0, NULL); Analog_Input_Write_Property,
if (len >= 0) { skip_fail_property_list);
test_len = bacapp_decode_known_property(rpdata.application_data, status = Analog_Input_Delete(object_instance);
len, &value, rpdata.object_type, rpdata.object_property); zassert_true(status, NULL);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
} }
/** /**
* @} * @}
+66
View File
@@ -0,0 +1,66 @@
/**
* @file
* @brief Stub functions for unit test of a BACnet object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date December 2022
*
* SPDX-License-Identifier: MIT
*/
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "bacnet/bacdef.h"
#include "bacnet/alarm_ack.h"
#include "bacnet/datetime.h"
#include "bacnet/event.h"
#include "bacnet/getevent.h"
#include "bacnet/get_alarm_sum.h"
#include "bacnet/npdu.h"
bool datetime_local(BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
(void)bdate;
(void)btime;
(void)utc_offset_minutes;
(void)dst_active;
return false;
}
void Notification_Class_common_reporting_function(
BACNET_EVENT_NOTIFICATION_DATA *event_data)
{
(void)event_data;
}
void Notification_Class_Get_Priorities(
uint32_t Object_Instance, uint32_t *pPriorityArray)
{
(void)Object_Instance;
(void)pPriorityArray;
}
void handler_get_event_information_set(
BACNET_OBJECT_TYPE object_type, get_event_info_function pFunction)
{
(void)object_type;
(void)pFunction;
}
void handler_alarm_ack_set(
BACNET_OBJECT_TYPE object_type, alarm_ack_function pFunction)
{
(void)object_type;
(void)pFunction;
}
void handler_get_alarm_summary_set(
BACNET_OBJECT_TYPE object_type, get_alarm_summary_function pFunction)
{
(void)object_type;
(void)pFunction;
}
+6 -5
View File
@@ -7,7 +7,6 @@ project(test_${basename}
VERSION 1.0.0 VERSION 1.0.0
LANGUAGES C) LANGUAGES C)
string(REGEX REPLACE string(REGEX REPLACE
"/test/bacnet/[a-zA-Z_/-]*$" "/test/bacnet/[a-zA-Z_/-]*$"
"/src" "/src"
@@ -27,6 +26,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,14 +43,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/memcopy.c ${SRC_DIR}/bacnet/memcopy.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
@@ -59,9 +57,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
../mock/device_mock.c ${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+25 -46
View File
@@ -1,15 +1,15 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/ao.h> #include <bacnet/basic/object/ao.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -25,47 +25,26 @@ ZTEST(ao_tests, testAnalogOutput)
static void testAnalogOutput(void) static void testAnalogOutput(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { PROP_PRIORITY_ARRAY, -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Analog_Output_Init(); Analog_Output_Init();
Analog_Output_Create(1); object_instance = Analog_Output_Create(object_instance);
rpdata.application_data = &apdu[0]; count = Analog_Output_Count();
rpdata.application_data_len = sizeof(apdu); zassert_true(count == 1, NULL);
rpdata.object_type = OBJECT_ANALOG_OUTPUT; test_object_instance = Analog_Output_Index_To_Instance(0);
rpdata.object_instance = instance; zassert_equal(object_instance, test_object_instance, NULL);
rpdata.array_index = BACNET_ARRAY_ALL; bacnet_object_properties_read_write_test(
OBJECT_ANALOG_OUTPUT,
Analog_Output_Property_Lists(&required_property, NULL, NULL); object_instance,
while ((*required_property) >= 0) { Analog_Output_Property_Lists,
rpdata.object_property = *required_property; Analog_Output_Read_Property,
len = Analog_Output_Read_Property(&rpdata); Analog_Output_Write_Property,
if (len < 0) { skip_fail_property_list);
printf("property %u: failed to read!\n", status = Analog_Output_Delete(object_instance);
(unsigned)rpdata.object_property); zassert_true(status, NULL);
}
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
if (len != test_len) {
printf("property %u: failed to decode!\n",
(unsigned)rpdata.object_property);
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
return;
} }
/** /**
* @} * @}
+8 -2
View File
@@ -23,10 +23,12 @@ set(ZTST_DIR "${TST_DIR}/ztest/src")
add_compile_definitions( add_compile_definitions(
BIG_ENDIAN=0 BIG_ENDIAN=0
CONFIG_ZTEST=1 CONFIG_ZTEST=1
INTRINSIC_REPORTING=1
) )
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,10 +45,8 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
@@ -59,8 +59,14 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
./stubs.c
${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+25 -39
View File
@@ -1,15 +1,15 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/av.h> #include <bacnet/basic/object/av.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -25,40 +25,26 @@ ZTEST(av_tests, testAnalog_Value)
static void testAnalog_Value(void) static void testAnalog_Value(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Analog_Value_Init(); Analog_Value_Init();
rpdata.application_data = &apdu[0]; object_instance = Analog_Value_Create(object_instance);
rpdata.application_data_len = sizeof(apdu); count = Analog_Value_Count();
rpdata.object_type = OBJECT_ANALOG_VALUE; zassert_true(count == 1, NULL);
rpdata.object_instance = instance; test_object_instance = Analog_Value_Index_To_Instance(0);
rpdata.array_index = BACNET_ARRAY_ALL; zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
Analog_Value_Property_Lists(&required_property, NULL, NULL); OBJECT_ANALOG_VALUE,
while ((*required_property) >= 0) { object_instance,
rpdata.object_property = *required_property; Analog_Value_Property_Lists,
len = Analog_Value_Read_Property(&rpdata); Analog_Value_Read_Property,
zassert_true(len >= 0, NULL); Analog_Value_Write_Property,
if (len >= 0) { skip_fail_property_list);
test_len = bacapp_decode_known_property(rpdata.application_data, status = Analog_Value_Delete(object_instance);
len, &value, rpdata.object_type, rpdata.object_property); zassert_true(status, NULL);
if (len != test_len) {
//printf("property '%s': failed to decode!\n",
// bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
} }
/** /**
* @} * @}
+66
View File
@@ -0,0 +1,66 @@
/**
* @file
* @brief Stub functions for unit test of a BACnet object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date December 2022
*
* SPDX-License-Identifier: MIT
*/
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "bacnet/bacdef.h"
#include "bacnet/alarm_ack.h"
#include "bacnet/datetime.h"
#include "bacnet/event.h"
#include "bacnet/getevent.h"
#include "bacnet/get_alarm_sum.h"
#include "bacnet/npdu.h"
bool datetime_local(BACNET_DATE *bdate,
BACNET_TIME *btime,
int16_t *utc_offset_minutes,
bool *dst_active)
{
(void)bdate;
(void)btime;
(void)utc_offset_minutes;
(void)dst_active;
return false;
}
void Notification_Class_common_reporting_function(
BACNET_EVENT_NOTIFICATION_DATA *event_data)
{
(void)event_data;
}
void Notification_Class_Get_Priorities(
uint32_t Object_Instance, uint32_t *pPriorityArray)
{
(void)Object_Instance;
(void)pPriorityArray;
}
void handler_get_event_information_set(
BACNET_OBJECT_TYPE object_type, get_event_info_function pFunction)
{
(void)object_type;
(void)pFunction;
}
void handler_alarm_ack_set(
BACNET_OBJECT_TYPE object_type, alarm_ack_function pFunction)
{
(void)object_type;
(void)pFunction;
}
void handler_get_alarm_summary_set(
BACNET_OBJECT_TYPE object_type, get_alarm_summary_function pFunction)
{
(void)object_type;
(void)pFunction;
}
+7 -2
View File
@@ -27,6 +27,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,13 +44,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/memcopy.c ${SRC_DIR}/bacnet/memcopy.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
@@ -58,8 +58,13 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+26 -36
View File
@@ -1,16 +1,16 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/bi.h>
#include <bacnet/bactext.h> #include <bacnet/bactext.h>
#include <bacnet/basic/object/bi.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -26,36 +26,26 @@ ZTEST(bi_tests, testBinaryInput)
static void testBinaryInput(void) static void testBinaryInput(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Binary_Input_Init(); Binary_Input_Init();
rpdata.application_data = &apdu[0]; object_instance = Binary_Input_Create(object_instance);
rpdata.application_data_len = sizeof(apdu); count = Binary_Input_Count();
rpdata.object_type = OBJECT_BINARY_INPUT; zassert_true(count == 1, NULL);
rpdata.object_instance = instance; test_object_instance = Binary_Input_Index_To_Instance(0);
rpdata.array_index = BACNET_ARRAY_ALL; zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
Binary_Input_Property_Lists(&required_property, NULL, NULL); OBJECT_BINARY_INPUT,
while ((*required_property) >= 0) { object_instance,
rpdata.object_property = *required_property; Binary_Input_Property_Lists,
len = Binary_Input_Read_Property(&rpdata); Binary_Input_Read_Property,
zassert_true(len >= 0, NULL); Binary_Input_Write_Property,
if (len >= 0) { skip_fail_property_list);
test_len = bacapp_decode_known_property(rpdata.application_data, status = Binary_Input_Delete(object_instance);
len, &value, rpdata.object_type, rpdata.object_property); zassert_true(status, NULL);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
} }
/** /**
* @} * @}
+7 -4
View File
@@ -27,6 +27,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,14 +44,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/memcopy.c ${SRC_DIR}/bacnet/memcopy.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
@@ -59,9 +58,13 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
../mock/device_mock.c ${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+25 -44
View File
@@ -1,15 +1,15 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/bo.h> #include <bacnet/basic/object/bo.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -25,45 +25,26 @@ ZTEST(bo_tests, testBinaryOutput)
static void testBinaryOutput(void) static void testBinaryOutput(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { PROP_PRIORITY_ARRAY, -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Binary_Output_Init(); Binary_Output_Init();
Binary_Output_Create(1); object_instance = Binary_Output_Create(object_instance);
rpdata.application_data = &apdu[0]; count = Binary_Output_Count();
rpdata.application_data_len = sizeof(apdu); zassert_true(count == 1, NULL);
rpdata.object_type = OBJECT_BINARY_OUTPUT; test_object_instance = Binary_Output_Index_To_Instance(0);
rpdata.object_instance = instance; zassert_equal(object_instance, test_object_instance, NULL);
rpdata.array_index = BACNET_ARRAY_ALL; bacnet_object_properties_read_write_test(
OBJECT_BINARY_OUTPUT,
Binary_Output_Property_Lists(&required_property, NULL, NULL); object_instance,
while ((*required_property) >= 0) { Binary_Output_Property_Lists,
rpdata.object_property = *required_property; Binary_Output_Read_Property,
len = Binary_Output_Read_Property(&rpdata); Binary_Output_Write_Property,
if (len < 0) { skip_fail_property_list);
printf("property %u: failed to read!\n", status = Binary_Output_Delete(object_instance);
(unsigned)rpdata.object_property); zassert_true(status, NULL);
}
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
if (len != test_len) {
printf("property %u: failed to decode!\n",
(unsigned)rpdata.object_property);
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
} }
/** /**
* @} * @}
+8 -2
View File
@@ -27,6 +27,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,12 +44,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
${SRC_DIR}/bacnet/weeklyschedule.c ${SRC_DIR}/bacnet/weeklyschedule.c
@@ -56,8 +57,13 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+20 -32
View File
@@ -9,7 +9,9 @@
*/ */
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/bactext.h>
#include <bacnet/basic/object/bv.h> #include <bacnet/basic/object/bv.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -25,40 +27,26 @@ ZTEST(bv_tests, testBinary_Value)
static void testBinary_Value(void) static void testBinary_Value(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Binary_Value_Init(); Binary_Value_Init();
rpdata.application_data = &apdu[0]; object_instance = Binary_Value_Create(object_instance);
rpdata.application_data_len = sizeof(apdu); count = Binary_Value_Count();
rpdata.object_type = OBJECT_BINARY_VALUE; zassert_true(count == 1, NULL);
rpdata.object_instance = instance; test_object_instance = Binary_Value_Index_To_Instance(0);
rpdata.array_index = BACNET_ARRAY_ALL; zassert_equal(object_instance, test_object_instance, NULL);
bacnet_object_properties_read_write_test(
Binary_Value_Property_Lists(&required_property, NULL, NULL); OBJECT_BINARY_VALUE,
while ((*required_property) >= 0) { object_instance,
rpdata.object_property = *required_property; Binary_Value_Property_Lists,
len = Binary_Value_Read_Property(&rpdata); Binary_Value_Read_Property,
zassert_true(len >= 0, NULL); Binary_Value_Write_Property,
if (len >= 0) { skip_fail_property_list);
test_len = bacapp_decode_known_property(rpdata.application_data, status = Binary_Value_Delete(object_instance);
len, &value, rpdata.object_type, rpdata.object_property); zassert_true(status, NULL);
if (len != test_len) {
//printf("property '%s': failed to decode!\n",
// bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
} }
/** /**
* @} * @}
+1 -1
View File
@@ -3,10 +3,10 @@
* @brief Unit test for object * @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net> * @author Steve Karg <skarg@users.sourceforge.net>
* @date July 2023 * @date July 2023
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/channel.h> #include <bacnet/basic/object/channel.h>
#include <bacnet/bactext.h> #include <bacnet/bactext.h>
@@ -27,6 +27,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,12 +44,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
${SRC_DIR}/bacnet/weeklyschedule.c ${SRC_DIR}/bacnet/weeklyschedule.c
@@ -56,9 +57,13 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
../mock/device_mock.c ${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+22 -64
View File
@@ -1,16 +1,16 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/ms-input.h> #include <bacnet/basic/object/ms-input.h>
#include <bacnet/bactext.h> #include <bacnet/bactext.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -26,68 +26,26 @@ ZTEST(ms_input_tests, testMultistateInput)
static void testMultistateInput(void) static void testMultistateInput(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0, test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0};
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
unsigned count = 0;
bool status = false; bool status = false;
unsigned count = 0;
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
const int skip_fail_property_list[] = { -1 };
Multistate_Input_Init(); Multistate_Input_Init();
object_instance = Multistate_Input_Create(object_instance);
count = Multistate_Input_Count(); count = Multistate_Input_Count();
zassert_true(count > 0, NULL); zassert_true(count == 1, NULL);
rpdata.application_data = &apdu[0]; test_object_instance = Multistate_Input_Index_To_Instance(0);
rpdata.application_data_len = sizeof(apdu); zassert_equal(object_instance, test_object_instance, NULL);
rpdata.object_type = OBJECT_MULTI_STATE_INPUT; bacnet_object_properties_read_write_test(
rpdata.object_instance = Multistate_Input_Index_To_Instance(0); OBJECT_MULTI_STATE_INPUT,
rpdata.array_index = BACNET_ARRAY_ALL; object_instance,
status = Multistate_Input_Valid_Instance(rpdata.object_instance); Multistate_Input_Property_Lists,
Multistate_Input_Read_Property,
Multistate_Input_Write_Property,
skip_fail_property_list);
status = Multistate_Input_Delete(object_instance);
zassert_true(status, NULL); zassert_true(status, NULL);
Multistate_Input_Property_Lists(&pRequired, &pOptional, &pProprietary);
while ((*pRequired) >= 0) {
rpdata.object_property = *pRequired;
len = Multistate_Input_Read_Property(&rpdata);
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, NULL);
} else {
printf("property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pRequired++;
}
while ((*pOptional) != -1) {
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Multistate_Input_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_true(test_len >= 0, NULL);
} else {
printf("property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pOptional++;
}
} }
/** /**
* @} * @}
+7 -4
View File
@@ -27,6 +27,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,14 +44,12 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/memcopy.c ${SRC_DIR}/bacnet/memcopy.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
@@ -59,9 +58,13 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
../mock/device_mock.c ${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+25 -46
View File
@@ -1,15 +1,15 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/mso.h> #include <bacnet/basic/object/mso.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -25,47 +25,26 @@ ZTEST(mso_tests, testMultistateOutput)
static void testMultistateOutput(void) static void testMultistateOutput(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 }; bool status = false;
int len = 0, test_len = 0; unsigned count = 0;
BACNET_READ_PROPERTY_DATA rpdata = { 0 }; uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
BACNET_APPLICATION_DATA_VALUE value = {0}; const int skip_fail_property_list[] = { PROP_PRIORITY_ARRAY, -1 };
const int *required_property = NULL;
const uint32_t instance = 1;
Multistate_Output_Init(); Multistate_Output_Init();
Multistate_Output_Create(1); object_instance = Multistate_Output_Create(object_instance);
rpdata.application_data = &apdu[0]; count = Multistate_Output_Count();
rpdata.application_data_len = sizeof(apdu); zassert_true(count == 1, NULL);
rpdata.object_type = OBJECT_MULTI_STATE_OUTPUT; test_object_instance = Multistate_Output_Index_To_Instance(0);
rpdata.object_instance = instance; zassert_equal(object_instance, test_object_instance, NULL);
rpdata.array_index = BACNET_ARRAY_ALL; bacnet_object_properties_read_write_test(
OBJECT_MULTI_STATE_OUTPUT,
Multistate_Output_Property_Lists(&required_property, NULL, NULL); object_instance,
while ((*required_property) >= 0) { Multistate_Output_Property_Lists,
rpdata.object_property = *required_property; Multistate_Output_Read_Property,
len = Multistate_Output_Read_Property(&rpdata); Multistate_Output_Write_Property,
if (len < 0) { skip_fail_property_list);
printf("property %u: failed to read!\n", status = Multistate_Output_Delete(object_instance);
(unsigned)rpdata.object_property); zassert_true(status, NULL);
}
zassert_true(len >= 0, NULL);
if (len >= 0) {
test_len = bacapp_decode_known_property(rpdata.application_data,
len, &value, rpdata.object_type, rpdata.object_property);
if (len != test_len) {
printf("property %u: failed to decode!\n",
(unsigned)rpdata.object_property);
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_equal(len, test_len, NULL);
}
required_property++;
}
return;
} }
/** /**
* @} * @}
+7 -3
View File
@@ -27,6 +27,7 @@ add_compile_definitions(
include_directories( include_directories(
${SRC_DIR} ${SRC_DIR}
${TST_DIR}/bacnet/basic/object
${TST_DIR}/ztest/include ${TST_DIR}/ztest/include
) )
@@ -43,23 +44,26 @@ add_executable(${PROJECT_NAME}
${SRC_DIR}/bacnet/bacreal.c ${SRC_DIR}/bacnet/bacreal.c
${SRC_DIR}/bacnet/bacstr.c ${SRC_DIR}/bacnet/bacstr.c
${SRC_DIR}/bacnet/bactext.c ${SRC_DIR}/bacnet/bactext.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/cov.c ${SRC_DIR}/bacnet/cov.c
${SRC_DIR}/bacnet/datetime.c ${SRC_DIR}/bacnet/datetime.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/indtext.c ${SRC_DIR}/bacnet/indtext.c
${SRC_DIR}/bacnet/hostnport.c ${SRC_DIR}/bacnet/hostnport.c
${SRC_DIR}/bacnet/lighting.c ${SRC_DIR}/bacnet/lighting.c
${SRC_DIR}/bacnet/proplist.c
${SRC_DIR}/bacnet/timestamp.c ${SRC_DIR}/bacnet/timestamp.c
${SRC_DIR}/bacnet/memcopy.c
${SRC_DIR}/bacnet/wp.c ${SRC_DIR}/bacnet/wp.c
${SRC_DIR}/bacnet/weeklyschedule.c ${SRC_DIR}/bacnet/weeklyschedule.c
${SRC_DIR}/bacnet/bactimevalue.c ${SRC_DIR}/bacnet/bactimevalue.c
${SRC_DIR}/bacnet/dailyschedule.c ${SRC_DIR}/bacnet/dailyschedule.c
${SRC_DIR}/bacnet/calendar_entry.c ${SRC_DIR}/bacnet/calendar_entry.c
${SRC_DIR}/bacnet/special_event.c ${SRC_DIR}/bacnet/special_event.c
${SRC_DIR}/bacnet/basic/sys/bigend.c
${SRC_DIR}/bacnet/basic/sys/days.c
${SRC_DIR}/bacnet/basic/sys/debug.c
${SRC_DIR}/bacnet/basic/sys/keylist.c
# Test and test library files # Test and test library files
./src/main.c ./src/main.c
${TST_DIR}/bacnet/basic/object/property_test.c
${ZTST_DIR}/ztest_mock.c ${ZTST_DIR}/ztest_mock.c
${ZTST_DIR}/ztest.c ${ZTST_DIR}/ztest.c
) )
+22 -66
View File
@@ -1,16 +1,16 @@
/* /**
* Copyright (c) 2020 Legrand North America, LLC. * @file
* @brief Unit test for object
* @author Steve Karg <skarg@users.sourceforge.net>
* @date April 2024
* @section LICENSE
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
/* @file
* @brief test BACnet integer encode/decode APIs
*/
#include <zephyr/ztest.h> #include <zephyr/ztest.h>
#include <bacnet/basic/object/msv.h> #include <bacnet/basic/object/msv.h>
#include <bacnet/bactext.h> #include <bacnet/bactext.h>
#include <property_test.h>
/** /**
* @addtogroup bacnet_tests * @addtogroup bacnet_tests
@@ -26,70 +26,26 @@ ZTEST(msv_tests, testMultistateValue)
static void testMultistateValue(void) static void testMultistateValue(void)
#endif #endif
{ {
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata;
/* for decode value data */
BACNET_APPLICATION_DATA_VALUE value;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
unsigned count = 0;
bool status = false; bool status = false;
unsigned count = 0;
uint32_t object_instance = BACNET_MAX_INSTANCE, test_object_instance = 0;
const int skip_fail_property_list[] = { -1 };
Multistate_Value_Init(); Multistate_Value_Init();
object_instance = Multistate_Value_Create(object_instance);
count = Multistate_Value_Count(); count = Multistate_Value_Count();
zassert_true(count > 0, NULL); zassert_true(count == 1, NULL);
rpdata.application_data = &apdu[0]; test_object_instance = Multistate_Value_Index_To_Instance(0);
rpdata.application_data_len = sizeof(apdu); zassert_equal(object_instance, test_object_instance, NULL);
rpdata.object_type = OBJECT_MULTI_STATE_VALUE; bacnet_object_properties_read_write_test(
rpdata.object_instance = Multistate_Value_Index_To_Instance(0);; OBJECT_MULTI_STATE_VALUE,
status = Multistate_Value_Valid_Instance(rpdata.object_instance); object_instance,
Multistate_Value_Property_Lists,
Multistate_Value_Read_Property,
Multistate_Value_Write_Property,
skip_fail_property_list);
status = Multistate_Value_Delete(object_instance);
zassert_true(status, NULL); zassert_true(status, NULL);
Multistate_Value_Property_Lists(&pRequired, &pOptional, &pProprietary);
while ((*pRequired) != -1) {
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Multistate_Value_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
if (rpdata.object_property == PROP_PRIORITY_ARRAY) {
/* FIXME: known fail to decode */
len = test_len;
}
zassert_true(test_len >= 0, NULL);
} else {
printf("property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pRequired++;
}
while ((*pOptional) != -1) {
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Multistate_Value_Read_Property(&rpdata);
zassert_not_equal(len, BACNET_STATUS_ERROR, NULL);
if (len > 0) {
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
if (len != test_len) {
printf("property '%s': failed to decode!\n",
bactext_property_name(rpdata.object_property));
}
zassert_true(test_len >= 0, NULL);
} else {
printf("property '%s': failed to read!\n",
bactext_property_name(rpdata.object_property));
}
pOptional++;
}
} }
/** /**
* @} * @}
@@ -20,12 +20,18 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${BACNET_TEST_PATH}/stubs.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
@@ -39,25 +45,27 @@ if(BOARD STREQUAL unit_testing)
${BACNET_SRC}/bacstr.c ${BACNET_SRC}/bacstr.c
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/bactext.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c ${BACNET_SRC}/timestamp.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/bactext.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/proplist.c ${BACNET_SRC}/proplist.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/memcopy.c ${BACNET_SRC}/memcopy.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/bactimevalue.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/basic/sys/bigend.c ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/basic/sys/days.c
) ${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -66,9 +74,13 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${BACNET_TEST_PATH}/stubs.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,41 +20,50 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH) get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH)
get_filename_component(BACNET_SRC ${BACNET_BASIC_SRC} PATH) get_filename_component(BACNET_SRC ${BACNET_BASIC_SRC} PATH)
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC}/bacaddr.c ${BACNET_SRC}/bacaddr.c
${BACNET_SRC}/bacapp.c ${BACNET_SRC}/bacapp.c
${BACNET_SRC}/bacdcode.c ${BACNET_SRC}/bacdcode.c
${BACNET_SRC}/bacdest.c ${BACNET_SRC}/bacdest.c
${BACNET_SRC}/bacstr.c ${BACNET_SRC}/bacstr.c
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/basic/sys/days.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/cov.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/proplist.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/timestamp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/basic/sys/bigend.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
) ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -63,9 +72,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,12 +20,18 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${BACNET_TEST_PATH}/stubs.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
@@ -40,22 +46,25 @@ if(BOARD STREQUAL unit_testing)
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/proplist.c ${BACNET_SRC}/proplist.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
) ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -64,9 +73,13 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${BACNET_TEST_PATH}/stubs.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,12 +20,17 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
@@ -41,19 +46,23 @@ if(BOARD STREQUAL unit_testing)
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c ${BACNET_SRC}/timestamp.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/proplist.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
) )
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
@@ -63,9 +72,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,12 +20,17 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
@@ -40,32 +45,25 @@ if(BOARD STREQUAL unit_testing)
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/proplist.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c ${BACNET_SRC}/basic/sys/keylist.c
${BACNET_SRC}/basic/object/device.c )
${BACNET_SRC}/proplist.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/dcc.c
${BACNET_SRC}/basic/service/h_apdu.c
${BACNET_SRC}/basic/binding/address.c
${BACNET_SRC}/basic/service/h_cov.c
${BACNET_SRC}/npdu.c
${BACNET_SRC}/abort.c
${BACNET_SRC}/bacerror.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -74,9 +72,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,41 +20,50 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH) get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH)
get_filename_component(BACNET_SRC ${BACNET_BASIC_SRC} PATH) get_filename_component(BACNET_SRC ${BACNET_BASIC_SRC} PATH)
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC}/bacaddr.c ${BACNET_SRC}/bacaddr.c
${BACNET_SRC}/bacapp.c ${BACNET_SRC}/bacapp.c
${BACNET_SRC}/bacdcode.c ${BACNET_SRC}/bacdcode.c
${BACNET_SRC}/bacdest.c ${BACNET_SRC}/bacdest.c
${BACNET_SRC}/bacstr.c ${BACNET_SRC}/bacstr.c
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/basic/sys/days.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/cov.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/proplist.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/timestamp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/basic/sys/bigend.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
) ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -63,9 +72,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,42 +20,50 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${BACNET_TEST_PATH}/../mock/device_mock.c ${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH) get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH)
get_filename_component(BACNET_SRC ${BACNET_BASIC_SRC} PATH) get_filename_component(BACNET_SRC ${BACNET_BASIC_SRC} PATH)
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC}/bacaddr.c ${BACNET_SRC}/bacaddr.c
${BACNET_SRC}/bacapp.c ${BACNET_SRC}/bacapp.c
${BACNET_SRC}/bacdcode.c ${BACNET_SRC}/bacdcode.c
${BACNET_SRC}/bacdest.c ${BACNET_SRC}/bacdest.c
${BACNET_SRC}/bacstr.c ${BACNET_SRC}/bacstr.c
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/basic/sys/days.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/cov.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/proplist.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/timestamp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/basic/sys/bigend.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
) ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -64,9 +72,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -20,13 +20,18 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
) ${TEST_OBJECT_SRC}/property_test.c
)
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH) get_filename_component(BACNET_BASIC_SRC ${BACNET_OBJECT_SRC} PATH)
@@ -40,21 +45,25 @@ if(BOARD STREQUAL unit_testing)
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/proplist.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
) ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -63,9 +72,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -19,12 +19,17 @@ get_filename_component(BACNET_NAME ${BACNET_BASE} NAME)
# Update include path for this module # Update include path for this module
list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src) list(APPEND BACNET_INCLUDE ${BACNET_BASE}/src)
set(TEST_OBJECT_SRC ${BACNET_BASE}/test/bacnet/basic/object)
list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
list(APPEND INCLUDE ${BACNET_INCLUDE}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH) get_filename_component(BACNET_OBJECT_SRC ${BACNET_SRC_PATH} PATH)
@@ -39,23 +44,25 @@ if(BOARD STREQUAL unit_testing)
${BACNET_SRC}/bacint.c ${BACNET_SRC}/bacint.c
${BACNET_SRC}/bacreal.c ${BACNET_SRC}/bacreal.c
${BACNET_SRC}/datetime.c ${BACNET_SRC}/datetime.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/bacdevobjpropref.c ${BACNET_SRC}/bacdevobjpropref.c
${BACNET_SRC}/bactext.c ${BACNET_SRC}/bactext.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/indtext.c ${BACNET_SRC}/indtext.c
${BACNET_SRC}/lighting.c ${BACNET_SRC}/lighting.c
${BACNET_SRC}/proplist.c
${BACNET_SRC}/timestamp.c
${BACNET_SRC}/wp.c ${BACNET_SRC}/wp.c
${BACNET_SRC}/cov.c
${BACNET_SRC}/memcopy.c
${BACNET_SRC}/hostnport.c ${BACNET_SRC}/hostnport.c
${BACNET_SRC}/dailyschedule.c ${BACNET_SRC}/dailyschedule.c
${BACNET_SRC}/weeklyschedule.c ${BACNET_SRC}/weeklyschedule.c
${BACNET_SRC}/calendar_entry.c ${BACNET_SRC}/calendar_entry.c
${BACNET_SRC}/special_event.c ${BACNET_SRC}/special_event.c
${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/bactimevalue.c ${BACNET_SRC}/bactimevalue.c
) ${BACNET_SRC}/basic/sys/bigend.c
${BACNET_SRC}/basic/sys/days.c
${BACNET_SRC}/basic/sys/debug.c
${BACNET_SRC}/basic/sys/keylist.c
)
set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf") set(CONF_FILE "${CONF_FILE};prj.unit_testing.conf")
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
@@ -64,9 +71,12 @@ else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(${BACNET_NAME}) project(${BACNET_NAME})
target_include_directories(app PRIVATE ${BACNET_INCLUDE}) target_include_directories(app PRIVATE
${BACNET_INCLUDE}
${TEST_OBJECT_INCLUDE})
target_sources(app PRIVATE target_sources(app PRIVATE
${BACNET_TEST_PATH}/src/main.c ${BACNET_TEST_PATH}/src/main.c
${TEST_OBJECT_SRC}/property_test.c
) )
endif() endif()
@@ -25,7 +25,7 @@ list(APPEND TEST_OBJECT_INCLUDE ${TEST_OBJECT_SRC})
if(BOARD STREQUAL unit_testing) if(BOARD STREQUAL unit_testing)
file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src) file(RELATIVE_PATH BACNET_INCLUDE $ENV{ZEPHYR_BASE} ${BACNET_BASE}/src)
file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC}) file(RELATIVE_PATH TEST_OBJECT_INCLUDE $ENV{ZEPHYR_BASE} ${TEST_OBJECT_SRC})
list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE}) list(APPEND INCLUDE ${BACNET_INCLUDE} ${TEST_OBJECT_INCLUDE})
list(APPEND SOURCES list(APPEND SOURCES
${BACNET_SRC_PATH}.c ${BACNET_SRC_PATH}.c