From adbbbeef64f8a842eb76cf39a55a71b514438529 Mon Sep 17 00:00:00 2001 From: Mikhail Antropov Date: Wed, 15 Jun 2022 09:31:23 +0300 Subject: [PATCH] OSCBS-23 Add backport.h for all ports BACNET_OBJECT_TABLE will be use in zephyr port for create iterable section --- ports/bsd/bacport.h | 6 ++++++ ports/linux/bacport.h | 8 ++++++++ ports/lwip/bacport.h | 7 +++++++ ports/win32/bacport.h | 14 +++++++++++++ ports/zephyr/bacport.h | 24 ++++++++++++++++++++++ test/bacnet/include/bacport.h | 38 +++++++++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+) create mode 100644 test/bacnet/include/bacport.h diff --git a/ports/bsd/bacport.h b/ports/bsd/bacport.h index 03b0b7d3..9c2aae9b 100644 --- a/ports/bsd/bacport.h +++ b/ports/bsd/bacport.h @@ -95,5 +95,11 @@ extern int bip_get_local_netmask( struct in_addr *netmask); +#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \ + _index_to_instance, _valid_instance, _object_name, \ + _read_property, _write_property, _RPM_list, \ + _RR_info, _iterator, _value_list, _COV, \ + _COV_clear, _intrinsic_reporting) \ + /*TODO Add compile error "Unsupported BACNET_OBJECT_TABLE for this platform." */ #endif diff --git a/ports/linux/bacport.h b/ports/linux/bacport.h index 98812bbb..4d63c2d2 100644 --- a/ports/linux/bacport.h +++ b/ports/linux/bacport.h @@ -101,6 +101,14 @@ #include #include "bacnet/bacnet_stack_exports.h" +#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \ + _index_to_instance, _valid_instance, _object_name, \ + _read_property, _write_property, _RPM_list, \ + _RR_info, _iterator, _value_list, _COV, \ + _COV_clear, _intrinsic_reporting) \ +/*TODO Add compile error "Unsupported BACNET_OBJECT_TABLE for this platform." */ + + /** @file linux/bacport.h Includes Linux network headers. */ /* Local helper functions for this port */ diff --git a/ports/lwip/bacport.h b/ports/lwip/bacport.h index 5582fed5..9867960c 100644 --- a/ports/lwip/bacport.h +++ b/ports/lwip/bacport.h @@ -36,4 +36,11 @@ #include "lwip/dhcp.h" #include "lwip/inet.h" +#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \ + _index_to_instance, _valid_instance, _object_name, \ + _read_property, _write_property, _RPM_list, \ + _RR_info, _iterator, _value_list, _COV, \ + _COV_clear, _intrinsic_reporting) \ + /*TODO Add compile error "Unsupported BACNET_OBJECT_TABLE for this platform." */ + #endif diff --git a/ports/win32/bacport.h b/ports/win32/bacport.h index 8557bf66..f3e6ab26 100644 --- a/ports/win32/bacport.h +++ b/ports/win32/bacport.h @@ -70,6 +70,12 @@ and globals in favor of more secure versions. */ #endif #include +#if defined(__BORLANDC__) || defined(_WIN32) +/* seems to not be defined in time.h as specified by The Open Group */ +/* difference from UTC and local standard time */ +long int timezone; +#endif + #ifdef _MSC_VER #define inline __inline #endif @@ -82,4 +88,12 @@ and globals in favor of more secure versions. */ #define snprintf _snprintf #endif +#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \ + _index_to_instance, _valid_instance, _object_name, \ + _read_property, _write_property, _RPM_list, \ + _RR_info, _iterator, _value_list, _COV, \ + _COV_clear, _intrinsic_reporting) \ +/*TODO Add compile error "Unsupported BACNET_OBJECT_TABLE for this platform." */ + + #endif diff --git a/ports/zephyr/bacport.h b/ports/zephyr/bacport.h index 4cf244a3..c86a345c 100644 --- a/ports/zephyr/bacport.h +++ b/ports/zephyr/bacport.h @@ -28,6 +28,8 @@ #include #include +#include +#include "bacnet/basic/object/device.h" static inline char *inet_ntoa(struct in_addr in) { return "(inet_ntoa() to be implemented)"; @@ -37,5 +39,27 @@ static inline char *inet_ntoa(struct in_addr in) { extern int bip_get_local_netmask( struct in_addr *netmask); +#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \ + _index_to_instance, _valid_instance, _object_name, \ + _read_property, _write_property, _RPM_list, \ + _RR_info, _iterator, _value_list, _COV, \ + _COV_clear, _intrinsic_reporting) \ +STRUCT_SECTION_ITERABLE(object_functions, table_name) = { \ + .Object_Type = _type, \ + .Object_Init = _init, \ + .Object_Count = _count, \ + .Object_Index_To_Instance = _index_to_instance, \ + .Object_Valid_Instance = _valid_instance, \ + .Object_Name = _object_name, \ + .Object_Read_Property = _read_property, \ + .Object_Write_Property = _write_property, \ + .Object_RPM_List = _RPM_list, \ + .Object_RR_Info = _RR_info, \ + .Object_Iterator = _iterator, \ + .Object_Value_List = _value_list, \ + .Object_COV = _COV, \ + .Object_COV_Clear = _COV_clear, \ + .Object_Intrinsic_Reporting = _intrinsic_reporting \ +} #endif diff --git a/test/bacnet/include/bacport.h b/test/bacnet/include/bacport.h new file mode 100644 index 00000000..fe56cfc9 --- /dev/null +++ b/test/bacnet/include/bacport.h @@ -0,0 +1,38 @@ +/************************************************************************** +* +* Copyright (c) 2022 Legrand North America, LLC. +* +* 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. +* +*********************************************************************/ + +/* ztest mock file */ + +#ifndef BACPORT_H +#define BACPORT_H + +#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \ + _index_to_instance, _valid_instance, _object_name, \ + _read_property, _write_property, _RPM_list, \ + _RR_info, _iterator, _value_list, _COV, \ + _COV_clear, _intrinsic_reporting) \ + /* Empty define */ + +#endif