Feature/router mstp example app (#101)
* Ported router-ipv6 app to router-mstp * Fixed router-ipv6 build * Added router-ipv6 and router-mstp to pipeline Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -41,6 +41,14 @@ jobs:
|
||||
os: linux
|
||||
compiler: gcc
|
||||
script: make clean router
|
||||
- stage: router-ipv6
|
||||
os: linux
|
||||
compiler: gcc
|
||||
script: make clean router-ipv6
|
||||
- stage: router-mstp
|
||||
os: linux
|
||||
compiler: gcc
|
||||
script: make clean router-mstp
|
||||
- stage: mstp-build
|
||||
os: linux
|
||||
compiler: gcc
|
||||
|
||||
@@ -105,6 +105,10 @@ router:
|
||||
router-ipv6:
|
||||
$(MAKE) -s -C apps $@
|
||||
|
||||
.PHONY: router-mstp
|
||||
router-mstp:
|
||||
$(MAKE) -s -C apps $@
|
||||
|
||||
# Add "ports" to the build, if desired
|
||||
.PHONY: ports
|
||||
ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x
|
||||
@@ -163,6 +167,7 @@ clean:
|
||||
$(MAKE) -s -C apps clean
|
||||
$(MAKE) -s -C apps/router clean
|
||||
$(MAKE) -s -C apps/router-ipv6 clean
|
||||
$(MAKE) -s -C apps/router-mstp clean
|
||||
$(MAKE) -s -C apps/gateway clean
|
||||
$(MAKE) -s -C test clean
|
||||
|
||||
|
||||
@@ -281,6 +281,11 @@ router:
|
||||
router-ipv6:
|
||||
$(MAKE) -b -C $@
|
||||
|
||||
.PHONY: router-mstp
|
||||
router-mstp:
|
||||
$(MAKE) -b -C $@
|
||||
|
||||
.PHONY: writepropm
|
||||
writepropm:
|
||||
$(MAKE) -b -C $@
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ endif
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
LFLAGS += -Wl,--gc-sections
|
||||
|
||||
BACNET_SRC ?= \
|
||||
BACNET_SRC = \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/binding/*.c) \
|
||||
@@ -50,7 +50,7 @@ BACNET_SRC ?= \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/s_router.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/tsm/tsm.c
|
||||
|
||||
SRCS = ${SRC} $(BACNET_SRC) ${PORT_BIP6_SRC} ${PORT_BIP_SRC}
|
||||
SRCS = ${SRC} ${BACNET_SRC} ${PORT_BIP6_SRC} ${PORT_BIP_SRC}
|
||||
|
||||
OBJS += ${SRCS:.c=.o}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#undef MAX_MPDU
|
||||
#include "bacnet/datalink/bip.h"
|
||||
#include "bacnet/datalink/bvlc.h"
|
||||
#include "bacnet/basic/bbmd/h_bbmd.h"
|
||||
|
||||
/* current version of the BACnet stack */
|
||||
static const char *BACnet_Version = BACNET_VERSION_TEXT;
|
||||
@@ -335,11 +336,11 @@ static int datalink_send_pdu(uint16_t snet,
|
||||
|
||||
if (snet == 0) {
|
||||
debug_printf("BVLC/BVLC6 Send to DNET %u\n", (unsigned)dest->net);
|
||||
bytes_sent = bvlc_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
bytes_sent = bip_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
bytes_sent = bip6_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
} else if (snet == BIP_Net) {
|
||||
debug_printf("BVLC Send to DNET %u\n", (unsigned)dest->net);
|
||||
bytes_sent = bvlc_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
bytes_sent = bip_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
} else if (snet == BIP6_Net) {
|
||||
debug_printf("BVLC6 Send to DNET %u\n", (unsigned)dest->net);
|
||||
bytes_sent = bip6_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
@@ -1149,7 +1150,7 @@ int main(int argc, char *argv[])
|
||||
/* input */
|
||||
current_seconds = time(NULL);
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = bvlc_receive(&src, &BIP_Rx_Buffer[0], MAX_MPDU, 5);
|
||||
pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0], MAX_MPDU, 5);
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
debug_printf("BACnet/IP Received packet\n");
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
#Makefile to build BACnet Application for the GCC port
|
||||
|
||||
# tools - only if you need them.
|
||||
# Most platforms have this already defined
|
||||
# CC = gcc
|
||||
|
||||
# Executable file name
|
||||
TARGET = router-mstp
|
||||
|
||||
TARGET_BIN = ${TARGET}$(TARGET_EXT)
|
||||
|
||||
# BACNET_PORT, BACNET_PORT_DIR, BACNET_PORT_SRC are defined in common Makefile
|
||||
# BACNET_SRC_DIR is defined in common apps Makefile
|
||||
BACNET_OBJECT_DIR = $(BACNET_SRC_DIR)/bacnet/basic/object
|
||||
SRC = main.c \
|
||||
$(BACNET_OBJECT_DIR)/netport.c \
|
||||
$(BACNET_OBJECT_DIR)/client/device-client.c
|
||||
|
||||
PORT_MSTP_SRC = \
|
||||
$(BACNET_PORT_DIR)/rs485.c \
|
||||
$(BACNET_PORT_DIR)/dlmstp.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/mstp.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/mstptext.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/crc.c
|
||||
|
||||
PORT_BIP_SRC = \
|
||||
$(BACNET_PORT_DIR)/bip-init.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/bvlc.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/bbmd/h_bbmd.c
|
||||
|
||||
# WARNINGS, DEBUGGING, OPTIMIZATION are defined in common apps Makefile
|
||||
# BACNET_DEFINES is defined in common apps Makefile
|
||||
# put all the flags together
|
||||
INCLUDES = -I$(BACNET_SRC_DIR) -I$(BACNET_PORT_DIR)
|
||||
CFLAGS += $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(BACNET_DEFINES) $(INCLUDES)
|
||||
LFLAGS += -Wl,$(SYSTEM_LIB)
|
||||
ifneq (${BACNET_LIB},)
|
||||
LFLAGS += -Wl,$(BACNET_LIB)
|
||||
endif
|
||||
# GCC dead code removal
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
LFLAGS += -Wl,--gc-sections
|
||||
|
||||
BACNET_SRC = \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/binding/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/service/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/sys/*.c) \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/h_routed_npdu.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/s_router.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/tsm/tsm.c
|
||||
|
||||
SRCS = ${SRC} ${BACNET_SRC} ${PORT_MSTP_SRC} ${PORT_BIP_SRC}
|
||||
|
||||
OBJS += ${SRCS:.c=.o}
|
||||
|
||||
.PHONY: all
|
||||
all: Makefile ${TARGET_BIN}
|
||||
|
||||
${TARGET_BIN}: ${OBJS}
|
||||
${CC} ${PFLAGS} ${OBJS} ${LFLAGS} -o $@
|
||||
size $@
|
||||
cp $@ ../../bin
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} $*.c -o $@
|
||||
|
||||
.PHONY: depend
|
||||
depend:
|
||||
rm -f .depend
|
||||
${CC} -MM ${CFLAGS} *.c >> .depend
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f core ${TARGET_BIN} ${OBJS} $(TARGET).map
|
||||
|
||||
.PHONY: include
|
||||
include: .depend
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
BACnet Simple Router Demo
|
||||
=========================
|
||||
|
||||
The Simple Router demo connects one BACnet/IP and one BACnet MS/TP network.
|
||||
It also includes a BBMD so that Foreign Device Registration can be used
|
||||
to tunnel local command line demos to BACnet/IP and BACnet MS/TP networks.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
It uses environment variables to configure
|
||||
the MS/TP COM port and BACnet/IP address on Windows:
|
||||
|
||||
set BACNET_IFACE=192.168.0.1
|
||||
set BACNET_MSTP_IFACE=COM1
|
||||
set BACNET_MSTP_BAUD=38400
|
||||
set BACNET_MSTP_MAC=99
|
||||
|
||||
It uses environment variables to configure
|
||||
the MS/TP COM port and BACnet/IP address on Linux:
|
||||
|
||||
export BACNET_IFACE=eth0
|
||||
export BACNET_MSTP_IFACE=/dev/ttyUSB0
|
||||
export BACNET_MSTP_BAUD=38400
|
||||
export BACNET_MSTP_MAC=99
|
||||
|
||||
Also uses these configurations, but defaults to these values if not set:
|
||||
set BACNET_MAX_INFO_FRAMES=128
|
||||
set BACNET_MAX_MASTER=127
|
||||
set BACNET_IP_PORT=47808
|
||||
set BACNET_IP_NET=1
|
||||
set BACNET_MSTP_NET=2
|
||||
|
||||
Note: NET number must be unique and 1..65534 (never 0 or 65535)
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/bbmd6/vmac.h"
|
||||
#include "bacnet/basic/bbmd6/h_bbmd6.h"
|
||||
|
||||
/** result from a client request */
|
||||
static uint16_t BVLC6_Result_Code = BVLC6_RESULT_SUCCESSFUL_COMPLETION;
|
||||
|
||||
Reference in New Issue
Block a user