diff --git a/bacnet-stack/demo/dcc/Makefile b/bacnet-stack/demo/dcc/Makefile
index bca0ea2f..e8472f08 100644
--- a/bacnet-stack/demo/dcc/Makefile
+++ b/bacnet-stack/demo/dcc/Makefile
@@ -69,7 +69,8 @@ SRCS = main.c \
$(BACNET_ROOT)/reject.c \
$(BACNET_ROOT)/bacerror.c \
$(BACNET_ROOT)/apdu.c \
- $(BACNET_ROOT)/npdu.c
+ $(BACNET_ROOT)/npdu.c \
+ $(BACNET_ROOT)/version.c
OBJS = ${SRCS:.c=.o}
diff --git a/bacnet-stack/demo/dcc/makefile.b32 b/bacnet-stack/demo/dcc/makefile.b32
index 34066f6a..e54e7079 100644
--- a/bacnet-stack/demo/dcc/makefile.b32
+++ b/bacnet-stack/demo/dcc/makefile.b32
@@ -61,7 +61,8 @@ SRCS = main.c \
..\..\reject.c \
..\..\bacerror.c \
..\..\apdu.c \
- ..\..\npdu.c
+ ..\..\npdu.c \
+ ..\..\version.c
OBJS = $(SRCS:.c=.obj)
diff --git a/bacnet-stack/demo/epics/Makefile b/bacnet-stack/demo/epics/Makefile
index 7502030e..4ba40671 100644
--- a/bacnet-stack/demo/epics/Makefile
+++ b/bacnet-stack/demo/epics/Makefile
@@ -69,7 +69,8 @@ SRCS = main.c \
$(BACNET_ROOT)/reject.c \
$(BACNET_ROOT)/bacerror.c \
$(BACNET_ROOT)/apdu.c \
- $(BACNET_ROOT)/npdu.c
+ $(BACNET_ROOT)/npdu.c \
+ $(BACNET_ROOT)/version.c
OBJS = ${SRCS:.c=.o}
diff --git a/bacnet-stack/demo/epics/makefile.b32 b/bacnet-stack/demo/epics/makefile.b32
index 321440b1..99e464c8 100644
--- a/bacnet-stack/demo/epics/makefile.b32
+++ b/bacnet-stack/demo/epics/makefile.b32
@@ -62,7 +62,8 @@ SRCS = main.c \
..\..\reject.c \
..\..\bacerror.c \
..\..\apdu.c \
- ..\..\npdu.c
+ ..\..\npdu.c \
+ ..\..\version.c
OBJS = $(SRCS:.c=.obj)
diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c
index 3bed85b4..925ece07 100644
--- a/bacnet-stack/demo/object/device.c
+++ b/bacnet-stack/demo/object/device.c
@@ -42,6 +42,7 @@
#include "lsp.h" /* object list dependency */
#include "mso.h" /* object list dependency */
#include "wp.h" /* write property handling */
+#include "version.h"
#include "device.h" /* me */
#if BACFILE
#include "bacfile.h" /* object list dependency */
@@ -122,7 +123,6 @@ static char Vendor_Name[16] = "ASHRAE";
/* FIXME: your vendor id assigned by ASHRAE */
static uint16_t Vendor_Identifier = 0;
static char Model_Name[16] = "GNU";
-static char Firmware_Revision[16] = "0.3.2";
static char Application_Software_Version[16] = "1.0";
static char Location[16] = "USA";
static char Description[16] = "server";
@@ -265,20 +265,7 @@ bool Device_Set_Model_Name(const char *name, size_t length)
const char *Device_Firmware_Revision(void)
{
- return Firmware_Revision;
-}
-
-bool Device_Set_Firmware_Revision(const char *name, size_t length)
-{
- bool status = false; /*return value */
-
- if (length < sizeof(Firmware_Revision)) {
- memmove(Firmware_Revision, name, length);
- Firmware_Revision[length] = 0;
- status = true;
- }
-
- return status;
+ return BACnet_Version;
}
const char *Device_Application_Software_Version(void)
@@ -681,7 +668,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_FIRMWARE_REVISION:
- characterstring_init_ansi(&char_string, Firmware_Revision);
+ characterstring_init_ansi(&char_string, BACnet_Version);
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_APPLICATION_SOFTWARE_VERSION:
diff --git a/bacnet-stack/demo/object/device.h b/bacnet-stack/demo/object/device.h
index 957aa9a6..766801f6 100644
--- a/bacnet-stack/demo/object/device.h
+++ b/bacnet-stack/demo/object/device.h
@@ -69,7 +69,6 @@ extern "C" {
bool Device_Set_Model_Name(const char *name, size_t length);
const char *Device_Firmware_Revision(void);
- bool Device_Set_Firmware_Revision(const char *name, size_t length);
const char *Device_Application_Software_Version(void);
bool Device_Set_Application_Software_Version(const char *name,
diff --git a/bacnet-stack/demo/server/bacserv.cbp b/bacnet-stack/demo/server/bacserv.cbp
index 5954ff08..f47d8c4c 100644
--- a/bacnet-stack/demo/server/bacserv.cbp
+++ b/bacnet-stack/demo/server/bacserv.cbp
@@ -88,6 +88,10 @@
+
+
+
+
@@ -251,6 +255,10 @@
+
+
+
+
diff --git a/bacnet-stack/demo/server/main.c b/bacnet-stack/demo/server/main.c
index b40533ab..016382d6 100644
--- a/bacnet-stack/demo/server/main.c
+++ b/bacnet-stack/demo/server/main.c
@@ -45,6 +45,7 @@
#include "net.h"
#include "txbuf.h"
#include "lc.h"
+#include "version.h"
#if defined(BACDL_MSTP)
#include "rs485.h"
#endif
@@ -108,6 +109,7 @@ int main(int argc, char *argv[])
if (argc > 1)
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
#if defined(BACDL_BIP)
+ /* FIXME: really needs to come from a config file */
if (argc > 2)
Network_Interface = argv[2];
if (argc > 3)
@@ -125,8 +127,10 @@ int main(int argc, char *argv[])
}
#endif
printf("BACnet Server Demo\n"
+ "BACnet Stack Version %s\n"
"BACnet Device ID: %u\n"
"Max APDU: %d\n",
+ BACnet_Version,
Device_Object_Instance_Number(),
MAX_APDU);
Init_Service_Handlers();
diff --git a/bacnet-stack/doc/README.todo b/bacnet-stack/doc/README.todo
index 46d34b0e..81e70cb1 100644
--- a/bacnet-stack/doc/README.todo
+++ b/bacnet-stack/doc/README.todo
@@ -1,32 +1,32 @@
To Do List - BACnet Stack at SourceForge
Here are some things to do:
-1. Finish demo/epics/main.c - EPICS demo. Use object property lists.
-2. Finish demo/object/lo.c - Lighting Output object demo
-3. Complete bvlc.c and use it instead of or in compliment to bip.c
-4. Complete client demo for ReadPropertyMultiple from rpm.c
-5. Add HTTP demo like bacnet4linux
-6. Add subscribe COV support in server demo.
-7. Add hooks to increment Database_Revision property
-8. Add BBMD and FD support to server example for BACnet/IP.
-9. Add Foreign Device registration options to client examples.
-A. Change bip.c to not use extra buffer (shift data)
-B. Add Visual Studio 2005 makefiles or projects for demos.
-C. Add Code::Blocks projects for demos.
-D. Add function headers to each module and function with
- doc-tags for some document generator like doxygen, robodoc,
- or Natural Docs. Wikipedia has a nice comparison at:
+A. Finish demo/epics/main.c - EPICS demo. Use object property lists.
+B. Finish demo/object/lo.c - Lighting Output object demo
+C. Complete bvlc.c and use it instead of or in compliment to bip.c
+D. Complete client demo for ReadPropertyMultiple from rpm.c
+E. Add HTTP demo like bacnet4linux
+F. Add subscribe COV support in server demo.
+G. Add hooks to increment Database_Revision property
+H. Add BBMD and FD support to server example for BACnet/IP.
+I. Add Foreign Device registration options to client examples.
+J. Change bip.c to not use extra buffer (shift data)
+K. Add Visual Studio 2005 makefiles or projects for demos.
+L. Add Code::Blocks projects for demos.
+M. Add function headers to each module and function with
+ doc-tags for some document generator like doxygen, robodoc,
+ or Natural Docs. Wikipedia has a comparison of generators at:
http://en.wikipedia.org/wiki/Comparison_of_documentation_generators
-E. Convert core code into library.
+N. Convert core code into library.
For example, libbacnet. Includes client and server functionality
and only requires a dummy tsm_free_invoke_id function for servers.
Create bacnet.h file that includes all the necessary includes.
Split core functions into files to make library effecient.
For example, rp.c becomes rp_client.c, rp_server.c , rp_test.c;
bacint.c becomes bacint_encode.c, bacint_decode.c, bacint_test.c
-F: Change address to store in a file and demos to use file
+O. Change address to store in a file and demos to use file
instead of having to send who-is for each query.
Use a config file for interface and interface options.
These will make scripting cleaner.
+P. Changed encode_tagged_xx to encode_application_xx in bacdcode.c.
-Will I use alphabet (G) or hex (10) for the next item?
diff --git a/bacnet-stack/ports/at91sam7s/device.c b/bacnet-stack/ports/at91sam7s/device.c
index 061688c1..b8a88cab 100644
--- a/bacnet-stack/ports/at91sam7s/device.c
+++ b/bacnet-stack/ports/at91sam7s/device.c
@@ -32,6 +32,7 @@
#include "apdu.h"
#include "dlmstp.h"
#include "rs485.h"
+#include "version.h"
/* objects */
#include "device.h"
#include "ai.h"
@@ -41,8 +42,8 @@
#include "wp.h"
#include "dcc.h"
-/* note: you really only need to define variables for
- properties that are writable or that may change.
+/* note: you really only need to define variables for
+ properties that are writable or that may change.
The properties that are constant can be hard coded
into the read-property encoding. */
static uint32_t Object_Instance_Number = 12345;
@@ -63,9 +64,9 @@ void Device_Init(void)
Reinitialize_State = REINITIALIZED_STATE_IDLE;
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
/* FIXME: Get the data from the eeprom */
- /* I2C_Read_Block(EEPROM_DEVICE_ADDRESS,
- (char *)&Object_Instance_Number,
- sizeof(Object_Instance_Number),
+ /* I2C_Read_Block(EEPROM_DEVICE_ADDRESS,
+ (char *)&Object_Instance_Number,
+ sizeof(Object_Instance_Number),
EEPROM_BACNET_ID_ADDR); */
}
@@ -83,9 +84,9 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
Object_Instance_Number = object_id;
/* FIXME: Write the data to the eeprom */
/* I2C_Write_Block(
- EEPROM_DEVICE_ADDRESS,
- (char *)&Object_Instance_Number,
- sizeof(Object_Instance_Number),
+ EEPROM_DEVICE_ADDRESS,
+ (char *)&Object_Instance_Number,
+ sizeof(Object_Instance_Number),
EEPROM_BACNET_ID_ADDR); */
} else
status = false;
@@ -182,9 +183,9 @@ bool Device_Object_List_Identifier(unsigned array_index,
}
/* normalize the index since
we know it is not the previous objects */
- /* array index starts at 1 */
+ /* array index starts at 1 */
object_index = array_index - 1;
- /* 1 for the device object */
+ /* 1 for the device object */
object_count = 1;
/* FIXME: add objects as needed */
/* binary value objects */
@@ -288,7 +289,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_FIRMWARE_REVISION:
- characterstring_init_ansi(&char_string, "0.3.3");
+ characterstring_init_ansi(&char_string, BACnet_Version);
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_APPLICATION_SOFTWARE_VERSION:
@@ -528,7 +529,7 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
/* Display_Set_Name(
characterstring_value(&value.type.Character_String)); */
/* FIXME: All the object names in a device must be unique.
- Disallow setting the Device Object Name to any objects in
+ Disallow setting the Device Object Name to any objects in
the device. */
} else {
*error_class = ERROR_CLASS_PROPERTY;
diff --git a/bacnet-stack/ports/at91sam7s/makefile b/bacnet-stack/ports/at91sam7s/makefile
index 98a601e6..0595d81c 100644
--- a/bacnet-stack/ports/at91sam7s/makefile
+++ b/bacnet-stack/ports/at91sam7s/makefile
@@ -12,7 +12,7 @@ AR=arm-elf-ar
LDSCRIPT=at91sam7s256.ld
BACNET_FLAGS = -DBACDL_MSTP=1 -DPRINT_ENABLED=0 -DBIG_ENDIAN=0 -DMAX_APDU=480 -DDLMSTP_TEST
-INCLUDES = -I. -I../.. -I../../demo/handler -I../../demo/object
+INCLUDES = -I. -I../.. -I../../demo/handler -I../../demo/object
#OPTIMIZATION = -O0
OPTIMIZATION = -Os
CFLAGS = -fno-common $(OPTIMIZATION) $(INCLUDES) $(BACNET_FLAGS) -Wall -g
@@ -64,7 +64,8 @@ CORESRC = ../../npdu.c \
../../dcc.c \
../../rd.c \
../../whois.c \
- ../../iam.c
+ ../../iam.c \
+ ../../version.c
#CSRC = $(PORTSRC) $(DEMOSRC) $(CORESRC)
CSRC = $(PORTSRC)
@@ -80,12 +81,12 @@ $(TARGET).bin: $(TARGET).elf
$(OBJCOPY) $(TARGET).elf $(CPFLAGS) $(TARGET).bin
$(TARGET).elf: $(COBJ) $(AOBJ) $(LIBRARY) Makefile
- $(CC) $(CFLAGS) $(AOBJ) $(COBJ) $(LDFLAGS) -o $@
+ $(CC) $(CFLAGS) $(AOBJ) $(COBJ) $(LDFLAGS) -o $@
lib: $(LIBRARY)
$(LIBRARY): $(COREOBJ) Makefile
- $(AR) rcs $@ $(COREOBJ)
+ $(AR) rcs $@ $(COREOBJ)
$(COBJ): %.o : %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@
@@ -95,7 +96,7 @@ $(AOBJ): %.o : %.s Makefile
clean:
touch Makefile
- rm $(COBJ) $(AOBJ) $(COREOBJ)
+ rm $(COBJ) $(AOBJ) $(COREOBJ)
rm $(TARGET).elf $(TARGET).bin $(TARGET).dmp $(TARGET).map
rm $(LIBRARY)
rm *.lst
diff --git a/bacnet-stack/ports/pic18f6720/device.c b/bacnet-stack/ports/pic18f6720/device.c
index 52efeb82..64754396 100644
--- a/bacnet-stack/ports/pic18f6720/device.c
+++ b/bacnet-stack/ports/pic18f6720/device.c
@@ -41,9 +41,10 @@
#include "bv.h"
#include "wp.h"
#include "dcc.h"
+#include "version.h"
-/* note: you really only need to define variables for
- properties that are writable or that may change.
+/* note: you really only need to define variables for
+ properties that are writable or that may change.
The properties that are constant can be hard coded
into the read-property encoding. */
static uint32_t Object_Instance_Number = 12345;
@@ -63,9 +64,9 @@ void Device_Init(void)
Reinitialize_State = REINITIALIZED_STATE_IDLE;
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
/* FIXME: Get the data from the eeprom */
- /* I2C_Read_Block(EEPROM_DEVICE_ADDRESS,
- (char *)&Object_Instance_Number,
- sizeof(Object_Instance_Number),
+ /* I2C_Read_Block(EEPROM_DEVICE_ADDRESS,
+ (char *)&Object_Instance_Number,
+ sizeof(Object_Instance_Number),
EEPROM_BACNET_ID_ADDR); */
}
@@ -83,9 +84,9 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
Object_Instance_Number = object_id;
/* FIXME: Write the data to the eeprom */
/* I2C_Write_Block(
- EEPROM_DEVICE_ADDRESS,
- (char *)&Object_Instance_Number,
- sizeof(Object_Instance_Number),
+ EEPROM_DEVICE_ADDRESS,
+ (char *)&Object_Instance_Number,
+ sizeof(Object_Instance_Number),
EEPROM_BACNET_ID_ADDR); */
} else
status = false;
@@ -186,9 +187,9 @@ bool Device_Object_List_Identifier(unsigned array_index,
}
/* normalize the index since
we know it is not the previous objects */
- /* array index starts at 1 */
+ /* array index starts at 1 */
object_index = array_index - 1;
- /* 1 for the device object */
+ /* 1 for the device object */
object_count = 1;
/* FIXME: add objects as needed */
/* binary value objects */
@@ -299,8 +300,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_FIRMWARE_REVISION:
- (void) strcpypgm2ram(&string_buffer[0], "0.3.3");
- characterstring_init_ansi(&char_string, string_buffer);
+ characterstring_init_ansi(&char_string, BACnet_Version);
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_APPLICATION_SOFTWARE_VERSION:
@@ -541,7 +541,7 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
/* Display_Set_Name(
characterstring_value(&value.type.Character_String)); */
/* FIXME: All the object names in a device must be unique.
- Disallow setting the Device Object Name to any objects in
+ Disallow setting the Device Object Name to any objects in
the device. */
} else {
*error_class = ERROR_CLASS_PROPERTY;
diff --git a/bacnet-stack/version.c b/bacnet-stack/version.c
new file mode 100644
index 00000000..b7c12920
--- /dev/null
+++ b/bacnet-stack/version.c
@@ -0,0 +1,36 @@
+/*####COPYRIGHTBEGIN####
+ -------------------------------------------
+ Copyright (C) 2007 Steve Karg
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to:
+ The Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330
+ Boston, MA 02111-1307, USA.
+
+ As a special exception, if other files instantiate templates or
+ use macros or inline functions from this file, or you compile
+ this file and link it with other works to produce a work based
+ on this file, this file does not by itself cause the resulting
+ work to be covered by the GNU General Public License. However
+ the source code for this file must still be made available in
+ accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work
+ based on this file might be covered by the GNU General Public
+ License.
+ -------------------------------------------
+####COPYRIGHTEND####*/
+#include "version.h"
+
+char *BACnet_Version = "0.3.4";
diff --git a/bacnet-stack/version.h b/bacnet-stack/version.h
new file mode 100644
index 00000000..5b828831
--- /dev/null
+++ b/bacnet-stack/version.h
@@ -0,0 +1,47 @@
+/*####COPYRIGHTBEGIN####
+ -------------------------------------------
+ Copyright (C) 2007 Steve Karg
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to:
+ The Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330
+ Boston, MA 02111-1307, USA.
+
+ As a special exception, if other files instantiate templates or
+ use macros or inline functions from this file, or you compile
+ this file and link it with other works to produce a work based
+ on this file, this file does not by itself cause the resulting
+ work to be covered by the GNU General Public License. However
+ the source code for this file must still be made available in
+ accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work
+ based on this file might be covered by the GNU General Public
+ License.
+ -------------------------------------------
+####COPYRIGHTEND####*/
+#ifndef VERSION_H
+#define VERSION_H
+
+/* This BACnet protocol stack version 0.0.0 - FF.FF.FF */
+#ifndef BACNET_VERSION
+#define BACNET_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
+#endif
+#define BACNET_VERSION_CODE BACNET_VERSION(0,3,4)
+#define BACNET_VERSION_MAJOR ((BACNET_VERSION_CODE>>16)&0xFF)
+#define BACNET_VERSION_MINOR ((BACNET_VERSION_CODE>>8)&0xFF)
+#define BACNET_VERSION_MAINTENANCE (BACNET_VERSION_CODE&0xFF)
+extern char *BACnet_Version;
+
+#endif