Issue 2 move folders and use deep path include file names to prevent collisions (#4)

* moving folders and files and adjust server demo build

* Fix Makefile for apps/server on Linux

* fix unit test source file folders

* fix datetime convert UTC functions. Add Code::Blocks project for datetime testing

* added some ignore extensions

* disable parallel make option

* fix build for abort, dcc, and epics apps

* fix build for dcc, epics, error, and getevent apps.

* Fixed building of all apps

* fix the ipv4 to ipv6 router app build

* Change indent style from Google to Webkit

* make pretty to re-format style

* removed common Makefile since we already had one and two was too many

* remove scripts from root folder that are no longer maintained or used

* remove mercurial EOL and ignore files for git repo

* remove .vscodeconfig files from repo

* tweak clang-format style

* clang-format src and apps with tweaked style

* added clang-tidy to fix readability if braces in src

* result of make tidy for src and apps

* fix clang-tidy mangling

* Added code::blocks project for BACnet server simulation

* added code::blocks linux project for WhoIs app

* update text files for EOL

* fix EOL in some files

* fixed make win32 apps for older gcc

* Removed Borland C++ Makefile in apps. Unable to maintain support for Borland C++ compiler.

* created codeblocks project for apps/epics for Windows

* fixing ports/xplained to work with new data structure.

* fix ports/xplained example for Atmel Studio compile

* fix ports/stm32f10x example for gcc Makefile compile

* fix ports/stm32f10x example for IAR EWARM compile

* fix ports/xplained timer callback

* fix ports/bdk_atxx_mspt build with subdirs

* fix ports/bdk_atxx_mspt build with subdirs

* updated git ignore for IAR build artifacts

* updated gitignore for non-tracked files and folders

* fixed bdk-atxx4-mstp port for Rowley Crossworks project file

* fixed bdk-atxx4-mstp port for GCC AVR Makefile

* fixed atmega168 port for IAR AVR and GCC AVR Makefile

* fixed at91sam7s port for IAR ARM and GCC ARM Makefile

* removed unmaintainable DOS, RTOS32, and atmega8 ports.  Updated rx62n (untested).

* changed arm7 to uip port
This commit is contained in:
Steve Karg
2019-12-13 15:19:10 -06:00
committed by GitHub
parent 8a38dbe2cf
commit d50c190957
912 changed files with 36206 additions and 52502 deletions
+223
View File
@@ -0,0 +1,223 @@
###############################################################################
# Makefile for Project - PiFace
###############################################################################
## General Flags
TARGET = bacpiface
# Source locations
BACNET_CORE = ../../src
BACNET_INCLUDE = ../../include
BACNET_HANDLER = ../../demo/handler
BACNET_OBJECT = ../../demo/object
BACNET_DEMO = ../../demo
BACNET_PORT_DIR = ../../ports/linux
PIFACE_INCLUDE = libpifacedigital/src
PIFACE_LIB = libpifacedigital
MCP23S17_LIB = libmcp23s17
## BACnet options
BACDL_DEFINE ?= -DBACDL_BIP=1
# Declare your level of BBMD support
BBMD_DEFINE ?= -DBBMD_ENABLED=1
# local files for this project
CSRC = main.c \
device.c
# common demo files needed
DEMOSRC = \
$(BACNET_HANDLER)/dlenv.c \
$(BACNET_HANDLER)/txbuf.c \
$(BACNET_HANDLER)/noserv.c \
$(BACNET_HANDLER)/h_npdu.c \
$(BACNET_HANDLER)/h_whois.c \
$(BACNET_HANDLER)/h_iam.c \
$(BACNET_HANDLER)/h_rp.c \
$(BACNET_HANDLER)/h_rp_a.c \
$(BACNET_HANDLER)/h_rpm.c \
$(BACNET_HANDLER)/h_rpm_a.c \
$(BACNET_HANDLER)/h_rr.c \
$(BACNET_HANDLER)/h_wp.c \
$(BACNET_HANDLER)/h_wpm.c \
$(BACNET_HANDLER)/h_alarm_ack.c \
$(BACNET_HANDLER)/h_arf.c \
$(BACNET_HANDLER)/h_arf_a.c \
$(BACNET_HANDLER)/h_awf.c \
$(BACNET_HANDLER)/h_rd.c \
$(BACNET_HANDLER)/h_dcc.c \
$(BACNET_HANDLER)/h_ts.c \
$(BACNET_HANDLER)/h_whohas.c \
$(BACNET_HANDLER)/h_ihave.c \
$(BACNET_HANDLER)/h_cov.c \
$(BACNET_HANDLER)/h_ccov.c \
$(BACNET_HANDLER)/h_ucov.c \
$(BACNET_HANDLER)/h_getevent.c \
$(BACNET_HANDLER)/h_gas_a.c \
$(BACNET_HANDLER)/h_get_alarm_sum.c \
$(BACNET_HANDLER)/h_getevent_a.c \
$(BACNET_HANDLER)/h_pt.c \
$(BACNET_HANDLER)/h_pt_a.c \
$(BACNET_HANDLER)/h_upt.c \
$(BACNET_HANDLER)/s_arfs.c \
$(BACNET_HANDLER)/s_awfs.c \
$(BACNET_HANDLER)/s_dcc.c \
$(BACNET_HANDLER)/s_ihave.c \
$(BACNET_HANDLER)/s_get_alarm_sum.c \
$(BACNET_HANDLER)/s_get_event.c \
$(BACNET_HANDLER)/s_iam.c \
$(BACNET_HANDLER)/s_cov.c \
$(BACNET_HANDLER)/s_ptransfer.c \
$(BACNET_HANDLER)/s_rd.c \
$(BACNET_HANDLER)/s_rp.c \
$(BACNET_HANDLER)/s_rpm.c \
$(BACNET_HANDLER)/s_ts.c \
$(BACNET_HANDLER)/s_cevent.c \
$(BACNET_HANDLER)/s_router.c \
$(BACNET_HANDLER)/s_uevent.c \
$(BACNET_HANDLER)/s_whohas.c \
$(BACNET_HANDLER)/s_whois.c \
$(BACNET_HANDLER)/s_wpm.c \
$(BACNET_HANDLER)/s_upt.c \
$(BACNET_HANDLER)/s_wp.c
OBJSRC = \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/bo.c \
$(BACNET_OBJECT)/netport.c
# core BACnet stack files
CORESRC = \
$(BACNET_CORE)/apdu.c \
$(BACNET_CORE)/npdu.c \
$(BACNET_CORE)/bacdcode.c \
$(BACNET_CORE)/bacint.c \
$(BACNET_CORE)/bacreal.c \
$(BACNET_CORE)/bacstr.c \
$(BACNET_CORE)/bacapp.c \
$(BACNET_CORE)/bacprop.c \
$(BACNET_CORE)/bactext.c \
$(BACNET_CORE)/datetime.c \
$(BACNET_CORE)/indtext.c \
$(BACNET_CORE)/key.c \
$(BACNET_CORE)/keylist.c \
$(BACNET_CORE)/proplist.c \
$(BACNET_CORE)/debug.c \
$(BACNET_CORE)/bigend.c \
$(BACNET_CORE)/arf.c \
$(BACNET_CORE)/awf.c \
$(BACNET_CORE)/cov.c \
$(BACNET_CORE)/dcc.c \
$(BACNET_CORE)/iam.c \
$(BACNET_CORE)/ihave.c \
$(BACNET_CORE)/rd.c \
$(BACNET_CORE)/rp.c \
$(BACNET_CORE)/rpm.c \
$(BACNET_CORE)/timesync.c \
$(BACNET_CORE)/whohas.c \
$(BACNET_CORE)/whois.c \
$(BACNET_CORE)/wp.c \
$(BACNET_CORE)/wpm.c \
$(BACNET_CORE)/abort.c \
$(BACNET_CORE)/reject.c \
$(BACNET_CORE)/bacerror.c \
$(BACNET_CORE)/ptransfer.c \
$(BACNET_CORE)/memcopy.c \
$(BACNET_CORE)/filename.c \
$(BACNET_CORE)/tsm.c \
$(BACNET_CORE)/bacaddr.c \
$(BACNET_CORE)/address.c \
$(BACNET_CORE)/bacdevobjpropref.c \
$(BACNET_CORE)/bacpropstates.c \
$(BACNET_CORE)/alarm_ack.c \
$(BACNET_CORE)/event.c \
$(BACNET_CORE)/getevent.c \
$(BACNET_CORE)/get_alarm_sum.c \
$(BACNET_CORE)/readrange.c \
$(BACNET_CORE)/timestamp.c \
$(BACNET_CORE)/lighting.c \
$(BACNET_CORE)/version.c
PORT_BIP_SRC = \
$(BACNET_PORT_DIR)/bip-init.c \
$(BACNET_CORE)/bvlc.c \
$(BACNET_CORE)/bip.c
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
PORT_SRC = ${PORT_BIP_SRC}
endif
## Include Directories
INCLUDES = -I. -I$(BACNET_INCLUDE) -I$(BACNET_HANDLER) -I$(BACNET_OBJECT)
INCLUDES += -I$(BACNET_PORT_DIR)
INCLUDES += -I$(PIFACE_INCLUDE)
# Source to Object conversion
COBJ = $(CSRC:%.c=%.o)
DEMOOBJ = $(DEMOSRC:.c=.o)
COREOBJ = $(CORESRC:.c=.o)
OBJOBJ = $(OBJSRC:.c=.o)
PORTOBJ = $(PORT_SRC:.c=.o)
# define something from the Makefile or batch file
DEFINES = $(BACDL_DEFINE) $(BBMD_DEFINE)
OPTIMIZATION = -Os $(OPTIMIZE_FLAGS)
DEBUGGING = -g
ifeq (${BUILD},debug)
OPTIMIZATION = -O0
DEBUGGING = -g
endif
ifeq (${BUILD},release)
OPTIMIZATION = -Os $(OPTIMIZE_FLAGS)
DEBUGGING = -DNDEBUG
endif
BFLAGS += -DBACNET_PROTOCOL_REVISION=17
BFLAGS += -DMAX_TSM_TRANSACTIONS=1
BFLAGS += -DMAX_BINARY_INPUTS=4
BFLAGS += -DMAX_BINARY_OUTPUTS=8
## Compile options for C files
CFLAGS = $(DEFINES)
CFLAGS += $(DEBUGGING)
CFLAGS += $(INCLUDES)
# warnings
CFLAGS += -Wall
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wmissing-prototypes
# put it all together
CFLAGS += $(BFLAGS) $(OPTIMIZATION)
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
## Linker flags
LDPIFACE = -Wl,-L$(PIFACE_LIB),-lpifacedigital,-L$(MCP23S17_LIB),-lmcp23s17
LDFLAGS = -Wl,-lc,-lgcc,-lrt,-lm
LFLAGS := $(LDPIFACE) $(LDFLAGS)
## Objects not in library that must be built in order to link
OBJECTS = $(COBJ) $(DEMOOBJ) $(COREOBJ) $(OBJOBJ) $(PORTOBJ)
all: $(TARGET)
$(TARGET): $(OBJECTS) $(LIBRARY)
$(CC) $(OBJECTS) $(LFLAGS) -o $@
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -f core ${TARGET} ${OBJECTS}
include: .depend
.PHONY: clean all include depend
## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
# A script to download and build the libpifacedigital for PiFace
# The library is located at github.com/piface
# Since the PiFace library is GPLv3, we have to keep it separate.
git clone https://github.com/piface/libmcp23s17.git
git clone https://github.com/piface/libpifacedigital.git
# Build the library
make -C libmcp23s17
make -C libpifacedigital
+1679
View File
File diff suppressed because it is too large Load Diff
+281
View File
@@ -0,0 +1,281 @@
/**************************************************************************
*
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
*
* 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.
*
*********************************************************************/
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include "bacnet/config.h"
#include "bacnet/basic/binding/address.h"
#include "bacnet/bacdef.h"
#include "bacnet/basic/services.h"
#include "bacnet/basic/services.h"
#include "bacnet/datalink/dlenv.h"
#include "bacnet/bacdcode.h"
#include "bacnet/npdu.h"
#include "bacnet/apdu.h"
#include "bacnet/iam.h"
#include "bacnet/basic/tsm/tsm.h"
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/object/bacfile.h"
#include "bacnet/datalink/datalink.h"
#include "bacnet/dcc.h"
#include "bacnet/getevent.h"
#include "bacport.h"
#include "bacnet/basic/tsm/tsm.h"
#include "bacnet/basic/tsm/tsm.h"
#include "bacnet/version.h"
/* include the device object */
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/object/bi.h"
#include "bacnet/basic/object/bo.h"
#include "pifacedigital.h"
/** @file server/main.c Example server application using the BACnet Stack. */
/* (Doxygen note: The next two lines pull all the following Javadoc
* into the ServerDemo module.) */
/** @addtogroup ServerDemo */
/*@{*/
/** Buffer used for receiving */
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/* current version of the BACnet stack */
static const char *BACnet_Version = BACNET_VERSION_TEXT;
/** Initialize the handlers we will utilize.
* @see Device_Init, apdu_set_unconfirmed_handler, apdu_set_confirmed_handler
*/
static void Init_Service_Handlers(void)
{
Device_Init(NULL);
/* we need to handle who-is to support dynamic device binding */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
/* handle i-am to support binding to other devices */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_bind);
/* set the handler for all the services we don't implement */
/* It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
/* Set the handlers for any confirmed services that we support. */
/* We must implement read property - it's required! */
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_READ_PROP_MULTIPLE, handler_read_property_multiple);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_WRITE_PROPERTY, handler_write_property);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE, handler_write_property_multiple);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_READ_RANGE, handler_read_range);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_REINITIALIZE_DEVICE, handler_reinitialize_device);
apdu_set_unconfirmed_handler(
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, handler_timesync_utc);
apdu_set_unconfirmed_handler(
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, handler_timesync);
apdu_set_confirmed_handler(
SERVICE_CONFIRMED_SUBSCRIBE_COV, handler_cov_subscribe);
apdu_set_unconfirmed_handler(
SERVICE_UNCONFIRMED_COV_NOTIFICATION, handler_ucov_notification);
/* handle communication so we can shutup when asked */
apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
handler_device_communication_control);
/* handle the data coming back from private requests */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_PRIVATE_TRANSFER,
handler_unconfirmed_private_transfer);
}
static void piface_init(void)
{
int hw_addr = 0; /**< PiFaceDigital hardware address */
#ifdef PIFACE_INTERRUPT_ENABLE
int intenable = 1; /**< Whether or not interrupts are enabled */
#endif
/**
* Open piface digital SPI connection(s)
*/
printf("Opening piface digital connection at location %d\n", hw_addr);
pifacedigital_open(hw_addr);
#ifdef PIFACE_INTERRUPT_ENABLE
/**
* Enable interrupt processing (only required for all
* blocking/interrupt methods)
*/
intenable = pifacedigital_enable_interrupts();
if (intenable == 0) {
printf("Interrupts enabled.\n");
} else {
printf("Could not enable interrupts. "
"Try running using sudo to enable PiFaceDigital interrupts.\n");
}
#endif
}
/* track the Piface pin state to react on changes only */
static bool PiFace_Pin_Status[MAX_BINARY_INPUTS];
/**
* Clean up the PiFace interface
*/
static void piface_cleanup(void)
{
pifacedigital_close(0);
}
/**
* Perform a periodic task for the PiFace card
*/
static void piface_task(void)
{
unsigned i = 0;
BACNET_BINARY_PV present_value = BINARY_INACTIVE;
bool pin_status = false;
for (i = 0; i < MAX_BINARY_INPUTS; i++) {
if (!Binary_Input_Out_Of_Service(i)) {
present_value = Binary_Input_Present_Value(i);
pin_status = false;
if (pifacedigital_digital_read(i)) {
pin_status = true;
}
if (pin_status != PiFace_Pin_Status[i]) {
PiFace_Pin_Status[i] = pin_status;
if (pin_status) {
/* toggle the input only when button is pressed */
if (present_value == BINARY_INACTIVE) {
present_value = BINARY_ACTIVE;
} else {
present_value = BINARY_INACTIVE;
}
Binary_Input_Present_Value_Set(i, present_value);
}
}
}
}
for (i = 0; i < MAX_BINARY_OUTPUTS; i++) {
if (!Binary_Output_Out_Of_Service(i)) {
present_value = Binary_Output_Present_Value(i);
if (present_value == BINARY_INACTIVE) {
pifacedigital_digital_write(i, 0);
} else {
pifacedigital_digital_write(i, 1);
}
}
}
}
/** Main function of server demo.
*
* @see Device_Set_Object_Instance_Number, dlenv_init, Send_I_Am,
* datalink_receive, npdu_handler,
* dcc_timer_seconds, bvlc_maintenance_timer,
* handler_cov_task,
* tsm_timer_milliseconds
*
* @param argc [in] Arg count.
* @param argv [in] Takes one argument: the Device Instance #.
* @return 0 on success.
*/
int main(int argc, char *argv[])
{
BACNET_ADDRESS src = { 0 }; /* address where message came from */
uint16_t pdu_len = 0;
unsigned timeout = 1; /* milliseconds */
time_t last_seconds = 0;
time_t current_seconds = 0;
uint32_t elapsed_seconds = 0;
uint32_t elapsed_milliseconds = 0;
uint32_t address_binding_tmr = 0;
/* allow the device ID to be set */
if (argc > 1) {
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
}
printf("BACnet Raspberry Pi PiFace Digital Demo\n"
"BACnet Stack Version %s\n"
"BACnet Device ID: %u\n"
"Max APDU: %d\n",
BACnet_Version, Device_Object_Instance_Number(), MAX_APDU);
/* load any static address bindings to show up
in our device bindings list */
address_init();
Init_Service_Handlers();
dlenv_init();
atexit(datalink_cleanup);
piface_init();
atexit(piface_cleanup);
/* configure the timeout values */
last_seconds = time(NULL);
/* broadcast an I-Am on startup */
Send_I_Am(&Handler_Transmit_Buffer[0]);
/* loop forever */
for (;;) {
/* input */
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
/* process */
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
}
/* at least one second has passed */
elapsed_seconds = (uint32_t)(current_seconds - last_seconds);
if (elapsed_seconds) {
last_seconds = current_seconds;
dcc_timer_seconds(elapsed_seconds);
#if defined(BACDL_BIP) && BBMD_ENABLED
bvlc_maintenance_timer(elapsed_seconds);
#endif
dlenv_maintenance_timer(elapsed_seconds);
elapsed_milliseconds = elapsed_seconds * 1000;
handler_cov_timer_seconds(elapsed_seconds);
tsm_timer_milliseconds(elapsed_milliseconds);
}
handler_cov_task();
/* scan cache address */
address_binding_tmr += elapsed_seconds;
if (address_binding_tmr >= 60) {
address_cache_timer(address_binding_tmr);
address_binding_tmr = 0;
}
/* output/input */
piface_task();
}
return 0;
}
/* @} */
/* End group ServerDemo */
+10
View File
@@ -0,0 +1,10 @@
This demo is designed for a Raspberry Pi connected to a PiFace card.
The demo uses libpifacedigital from github.com/piface repository.
To build, start with the configure script:
$ ./configure.sh
$ make clean all