mirror of
https://github.com/stargieg/bacnet-stack
synced 2025-10-26 23:35:52 +08:00
fork from http://sourceforge.net/projects/bacnet/
This commit is contained in:
38
demo/epics/Makefile
Normal file
38
demo/epics/Makefile
Normal file
@@ -0,0 +1,38 @@
|
||||
#Makefile to build BACnet Application for the Linux Port
|
||||
|
||||
# tools - only if you need them.
|
||||
# Most platforms have this already defined
|
||||
# CC = gcc
|
||||
|
||||
TARGET = bacepics
|
||||
|
||||
TARGET_BIN = ${TARGET}$(TARGET_EXT)
|
||||
|
||||
SRCS = main.c \
|
||||
../object/device-client.c
|
||||
|
||||
OBJS = ${SRCS:.c=.o}
|
||||
|
||||
all: ${BACNET_LIB_TARGET} Makefile ${TARGET_BIN}
|
||||
|
||||
${TARGET_BIN}: ${OBJS} Makefile ${BACNET_LIB_TARGET}
|
||||
${CC} ${PFLAGS} ${OBJS} ${LFLAGS} -o $@
|
||||
size $@
|
||||
cp $@ ../../bin
|
||||
|
||||
lib: ${BACNET_LIB_TARGET}
|
||||
|
||||
${BACNET_LIB_TARGET}:
|
||||
( cd ${BACNET_LIB_DIR} ; $(MAKE) clean ; $(MAKE) )
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} $*.c -o $@
|
||||
|
||||
depend:
|
||||
rm -f .depend
|
||||
${CC} -MM ${CFLAGS} *.c >> .depend
|
||||
|
||||
clean:
|
||||
rm -f core ${TARGET_BIN} ${OBJS} ${BACNET_LIB_TARGET} $(TARGET).map
|
||||
|
||||
include: .depend
|
||||
60
demo/epics/bacepics.cbp
Normal file
60
demo/epics/bacepics.cbp
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="BACnet EPICS Demo" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin\Debug\bacepics" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj\Debug\" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin\Release\bacepics" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj\Release\" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-fexceptions" />
|
||||
<Add option="-DBACDL_BIP" />
|
||||
<Add option="-DPRINT_ENABLED=1" />
|
||||
<Add option="-DBACAPP_ALL" />
|
||||
<Add directory="." />
|
||||
<Add directory="..\..\include" />
|
||||
<Add directory="..\handler" />
|
||||
<Add directory="..\object" />
|
||||
<Add directory="..\..\ports\win32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="..\..\lib\libbacnet.a" />
|
||||
<Add library="ws2_32" />
|
||||
<Add library="iphlpapi" />
|
||||
</Linker>
|
||||
<Unit filename="..\object\device-client.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
104
demo/epics/bacepics.h
Executable file
104
demo/epics/bacepics.h
Executable file
@@ -0,0 +1,104 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef BACEPICS_H_
|
||||
#define BACEPICS_H_
|
||||
|
||||
/** @file epics/bacepics.h Header for tool to generate EPICS-usable output. */
|
||||
|
||||
|
||||
/** @defgroup BACEPICS Tool to generate EPICS-usable output.
|
||||
* @ingroup Demos
|
||||
* This tool will generate a list of Objects and their properties for use in
|
||||
* an EPICS file.
|
||||
* You will still need to provide the front part of the EPICS (see file
|
||||
* demo/server/epics_vts3.tpi) which cannot be easily determined by observation,
|
||||
* but this tool communicates with the test device and does the grunt work of
|
||||
* creating the list of Objects and the supported properties for
|
||||
* each of those Objects.
|
||||
*
|
||||
* Usage:
|
||||
* bacepics [-v] [-p sport] [-t target_mac] device-instance
|
||||
* -v: show values instead of '?'
|
||||
* -p: Use sport for "my" port, instead of 0xBAC0 (BACnet/IP only)
|
||||
* Allows you to communicate with a localhost target.
|
||||
* -t: declare target's MAC instead of using Who-Is to bind to
|
||||
* device-instance. Format is "C0:A8:00:18:BA:C0" (as usual)
|
||||
*
|
||||
* Examples:
|
||||
* ./bacepics -v 1234
|
||||
* where the device instance to be addressed is 1234
|
||||
* and the optional -v prints values out rather than the '?' that
|
||||
* the EPICS format for VTS3 wants.
|
||||
* ./bacepics -p 0xBAC1 -t "7F:0:0:1:BA:C0" 4194303
|
||||
* communicates with the BACnet device on localhost (127.0.0.1), using
|
||||
* port 47809 as "my" source port so it doesn't conflict with
|
||||
* the device's port 47808.
|
||||
*
|
||||
*
|
||||
* The tool follows an optimal approach which will use efficient communication
|
||||
* means if available or else fall back to simple-minded methods.
|
||||
* Starting with the Device Object, the tool will
|
||||
* - Try to fetch ALL the Properties with RPM
|
||||
* - If RPM is not supported, will use coded properties in demo/object folder
|
||||
* - If response is too big to fit (without segmentation), then will fetch
|
||||
* ALL again with array index of 0, which should result mostly in errors
|
||||
* but will provide the list of supported properties.
|
||||
* - If that succeeds, build the list of properties to be accessed. <br>
|
||||
* - If no RPM or failed to get ALL properties from the target device, then
|
||||
* fetch the coded Required and Optional properties from the demo/object
|
||||
* folder for this object type, and use this to build the list of
|
||||
* properties to be accessed.
|
||||
* - If the Fetch All succeeded, print the values for each property
|
||||
* - Otherwise, for each property in the list for this object,
|
||||
* - Request the single property value with ReadProperty (RP)
|
||||
* - From the response, print the property's value
|
||||
* The Device Object will have fetched the Object List property and built a list
|
||||
* of objects from that; use it now to cycle through each other Object and
|
||||
* repeat the above process to get and print out their property values.
|
||||
*/
|
||||
|
||||
/** The allowed States of the bacepics State Machine.
|
||||
* Important to distinguish the request from the response phases as well
|
||||
* as which approach will get all the properties for us.
|
||||
* @ingroup BACEPICS
|
||||
*/
|
||||
typedef enum {
|
||||
/** Initial state to establish a binding with the target device. */
|
||||
INITIAL_BINDING,
|
||||
/** Get selected device information and put out the heading information. */
|
||||
GET_HEADING_INFO, GET_HEADING_RESPONSE, PRINT_HEADING,
|
||||
/** Getting ALL properties and values at once with RPM. */
|
||||
GET_ALL_REQUEST, GET_ALL_RESPONSE,
|
||||
/** Getting ALL properties with array index = 0, just to get the list. */
|
||||
GET_LIST_OF_ALL_REQUEST, GET_LIST_OF_ALL_RESPONSE,
|
||||
/** Processing the properties individually with ReadProperty. */
|
||||
GET_PROPERTY_REQUEST, GET_PROPERTY_RESPONSE,
|
||||
/** Done with this Object; move onto the next. */
|
||||
NEXT_OBJECT
|
||||
} EPICS_STATES;
|
||||
|
||||
|
||||
#endif /* BACEPICS_H_ */
|
||||
1786
demo/epics/main.c
Normal file
1786
demo/epics/main.c
Normal file
File diff suppressed because it is too large
Load Diff
139
demo/epics/makefile.b32
Normal file
139
demo/epics/makefile.b32
Normal file
@@ -0,0 +1,139 @@
|
||||
#
|
||||
# Simple makefile to build an executable for Win32
|
||||
#
|
||||
# This makefile assumes Borland bcc32 development environment
|
||||
# on Windows NT/9x/2000/XP
|
||||
#
|
||||
|
||||
!ifndef BORLAND_DIR
|
||||
BORLAND_DIR_Not_Defined:
|
||||
@echo .
|
||||
@echo You must define environment variable BORLAND_DIR to compile.
|
||||
!endif
|
||||
|
||||
PRODUCT = bacepics
|
||||
PRODUCT_EXE = $(PRODUCT).exe
|
||||
|
||||
# tools
|
||||
CC = $(BORLAND_DIR)\bin\bcc32
|
||||
MAKE=$(BORLAND_DIR)\bin\make.exe
|
||||
#LINK = $(BORLAND_DIR)\bin\tlink32
|
||||
LINK = $(BORLAND_DIR)\bin\ilink32
|
||||
|
||||
BACNET_LIB_DIR = ..\..\lib
|
||||
BACNET_LIB = $(BACNET_LIB_DIR)\bacnet.lib
|
||||
|
||||
# directories
|
||||
BACNET_SOURCE = ..\..\src
|
||||
BACNET_PORT = ..\..\ports\win32
|
||||
BACNET_INCLUDE = ..\..\include
|
||||
BACNET_OBJECT = ..\object
|
||||
BACNET_HANDLER = ..\handler
|
||||
INCLUDES = \
|
||||
-I$(BACNET_INCLUDE) \
|
||||
-I$(BACNET_PORT) \
|
||||
-I$(BACNET_OBJECT) \
|
||||
-I$(BACNET_HANDLER) \
|
||||
-I$(BORLAND_DIR)\include
|
||||
|
||||
#
|
||||
BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL
|
||||
#BACDL_DEFINE=-DBACDL_MSTP=1
|
||||
BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1
|
||||
DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE)
|
||||
|
||||
SRCS = main.c
|
||||
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
|
||||
#
|
||||
# Compiler definitions
|
||||
#
|
||||
BCC_CFG = bcc32.cfg
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
CFLAGS = $(INCLUDES) $(DEFINES)
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
C_LIB_DIR = $(BORLAND_DIR)\lib
|
||||
|
||||
LIBS = $(BACNET_LIB) \
|
||||
$(C_LIB_DIR)\IMPORT32.lib \
|
||||
$(C_LIB_DIR)\CW32MT.lib \
|
||||
|
||||
#
|
||||
# Main target
|
||||
#
|
||||
# This should be the first one in the makefile
|
||||
|
||||
all : $(BACNET_LIB) $(BCC_CFG) $(OBJS) $(PRODUCT_EXE)
|
||||
del $(BCC_CFG)
|
||||
|
||||
install: $(PRODUCT_EXE)
|
||||
copy $(PRODUCT_EXE) ..\..\bin\$(PRODUCT_EXE)
|
||||
|
||||
# Linker specific: the link below is for BCC linker/compiler. If you link
|
||||
# with a different linker - please change accordingly.
|
||||
#
|
||||
|
||||
# need a temp response file (@&&| ... |) because command line is too long
|
||||
# $** lists each dependency
|
||||
# $< target name
|
||||
# $* target name without extension
|
||||
$(PRODUCT_EXE) : $(OBJS)
|
||||
@echo Running Linker for $(PRODUCT_EXE)
|
||||
$(LINK) -L$(C_LIB_DIR) -L$(BACNET_LIB_DIR) -m -c -s -v @&&|
|
||||
$(BORLAND_DIR)\lib\c0x32.obj $**
|
||||
$<
|
||||
$*.map
|
||||
$(LIBS)
|
||||
|
|
||||
|
||||
#
|
||||
# Utilities
|
||||
|
||||
clean :
|
||||
del $(OBJS)
|
||||
del $(PRODUCT_EXE)
|
||||
del $(PRODUCT).map
|
||||
del $(PRODUCT).ilc
|
||||
del $(PRODUCT).ild
|
||||
del $(PRODUCT).ilf
|
||||
del $(PRODUCT).ils
|
||||
del $(PRODUCT).tds
|
||||
del $(BCC_CFG)
|
||||
|
||||
#
|
||||
# Generic rules
|
||||
#
|
||||
.SUFFIXES: .cpp .c .sbr .obj
|
||||
|
||||
#
|
||||
# cc generic rule
|
||||
#
|
||||
.c.obj:
|
||||
$(CC) +$(BCC_CFG) -o$@ $<
|
||||
|
||||
# Compiler configuration file
|
||||
$(BCC_CFG) :
|
||||
Copy &&|
|
||||
$(CFLAGS)
|
||||
-c
|
||||
-y #include line numbers in OBJ's
|
||||
-v #include debug info
|
||||
-w+ #turn on all warnings
|
||||
-Od #disable all optimizations
|
||||
#-a4 #32 bit data alignment
|
||||
#-M # generate link map
|
||||
#-ls # linker options
|
||||
#-WM- #not multithread
|
||||
-WM #multithread
|
||||
-w-aus # ignore warning assigned a value that is never used
|
||||
-w-sig # ignore warning conversion may lose sig digits
|
||||
| $@
|
||||
|
||||
# EOF: makefile
|
||||
Reference in New Issue
Block a user