From 026a489fc5c13ec194cebd2f0c41b4c81ea49c36 Mon Sep 17 00:00:00 2001 From: tbrennan3 Date: Tue, 23 Mar 2010 12:32:46 +0000 Subject: [PATCH] Answered my own questions, after some thought: Made the epics pretty-printing generate shorter lines by only decoding 4 bits per line (hurts my byte-centered soul, but does look better). Moved the big comment section out of demo/server/main.c out to a new header, server.h. Provided doxygen links to the functions called in the server demo. --- bacnet-stack/demo/epics/main.c | 15 +++-- bacnet-stack/demo/server/main.c | 81 +++++----------------- bacnet-stack/demo/server/server.h | 107 ++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 73 deletions(-) create mode 100644 bacnet-stack/demo/server/server.h diff --git a/bacnet-stack/demo/epics/main.c b/bacnet-stack/demo/epics/main.c index 1b2585be..450907fa 100644 --- a/bacnet-stack/demo/epics/main.c +++ b/bacnet-stack/demo/epics/main.c @@ -137,10 +137,10 @@ void MyRejectHandler( /** Provide a nicer output for Supported Services and Object Types. * - * @param stream - * @param value - * @param property - * @return + * @param stream [in] Normally stdout + * @param value [in] The structure holding this property's value (union) and type. + * @param property [in] Which property we are printing. + * @return True if success. Or otherwise. */ bool PrettyPrintPropertyValue( @@ -165,11 +165,12 @@ void MyRejectHandler( fprintf(stream, ","); else fprintf(stream, " "); - if ( (i == (len-1) ) || ( (i % 8) == 7 ) ) // line break every 8 + // Tried with 8 per line, but with the comments, got way too long. + if ( (i == (len-1) ) || ( (i % 4) == 3 ) ) // line break every 4 { fprintf(stream, " # "); - // Now rerun the same 8 bits, but print labels for true ones - for ( j = i - (i%8); j <= i; j++) + // Now rerun the same 4 bits, but print labels for true ones + for ( j = i - (i%4); j <= i; j++) { if ( bitstring_bit(&value->type.Bit_String, (uint8_t) j) ) { diff --git a/bacnet-stack/demo/server/main.c b/bacnet-stack/demo/server/main.c index bf7feaf3..0eca9670 100644 --- a/bacnet-stack/demo/server/main.c +++ b/bacnet-stack/demo/server/main.c @@ -29,6 +29,7 @@ #include #include #include "config.h" +#include "server.h" #include "address.h" #include "bacdef.h" #include "handlers.h" @@ -52,76 +53,17 @@ /** @file server/main.c Example server application using the BACnet Stack */ -/** @defgroup Demos Demos of Servers and Clients - * Most of the folders under the /demo folder contain demonstration (ie, sample) - * code that implements the name functionality. - * - * The exceptions to this general rule, /handler and /object folders, are - * described in the various BIBBs and Object Framework modules. - */ - -/** @defgroup ServerDemo Demo of a BACnet Server (Device) - * @ingroup Demos - * This is a basic demonstration of a simple BACnet Device consisting of - * the services and properties shown in its PICS (output provided by - * the demo/epics/epics program): - * @verbatim -List of Objects in test device: -{ - object-identifier: (Device, 1234) - object-name: "SimpleServer" - object-type: Device - system-status: operational - vendor-name: "BACnet Stack at SourceForge" - vendor-identifier: 260 - model-name: "GNU" - firmware-version: "0.5.5" - application-software-version: "1.0" - protocol-version: 1 - protocol-revision: 5 - protocol-services-supported: { - false,false,false,false,false, true, true, true, # ,,,,, Subscribe-COV, Atomic-Read-File, Atomic-Write-File, - false,false,false,false, true,false, true, true, # ,,,, Read-Property,, Read-Property-Multiple, Write-Property, - false, true,false,false, true,false,false,false, # , Device-Communication-Control,,, Reinitialize-Device,,,, - false,false,false,false, true,false,false,false, # ,,,, COV-Notification,,,, - true, true, true,false, true,false,false,false # Time-Synchronization, Who-Has, Who-Is,, UTC-Time-Synchronization,,,, - } - protocol-object-types-supported: { - true, true, true, true, true, true,false,false, # Analog Input, Analog Output, Analog Value, Binary Input, Binary Output, Binary Value,,, - true,false, true,false,false, true, true,false, # Device,, File,,, Multi-State Input, Multi-State Output,, - false,false,false,false, true, true,false,false, # ,,,, Trendlog, Life Safety Point,,, - false,false,false,false, true,false,false,false, # ,,,, Load-Control,,,, - false,false,false,false,false,false # ,,,,,, - } - object-list: {(Device, 1234),(Analog Input, 0),(Analog Input, 1), - (Analog Input, 2),(Analog Input, 3),(Analog Output, 0),(Analog Output, 1), - (Analog Output, 2),(Analog Output, 3),(Analog Value, 0),(Analog Value, 1), - (Analog Value, 2),(Analog Value, 3),(Binary Input, 0),(Binary Input, 1), - (Binary Input, 2),(Binary Input, 3),(Binary Input, 4),(Binary Output, 0), - (Binary Output, 1),(Binary Output, 2),(Binary Output, 3),(Binary Value, 0), - (Binary Value, 1),(Binary Value, 2),(Binary Value, 3),(Binary Value, 4), - (Binary Value, 5),(Binary Value, 6),(Binary Value, 7),(Binary Value, 8), - (Binary Value, 9),(Life Safety Point, 0),(Life Safety Point, 1),(Life Safety Point, 2), - (Life Safety Point, 3),(Life Safety Point, 4),(Life Safety Point, 5),(Life Safety Point, 6), - (Load-Control, 0),(Load-Control, 1),(Load-Control, 2),(Load-Control, 3), - (Multi-State Output, 0),(Multi-State Output, 1),(Multi-State Output, 2),(Multi-State Output, 3), - (Multi-State Input, 0),(Trendlog, 0),(Trendlog, 1),(Trendlog, 2), - (Trendlog, 3),(Trendlog, 4),(Trendlog, 5),(Trendlog, 6), - (Trendlog, 7),(File, 0),(File, 1),(File, 2)} - max-apdu-length-accepted: 1476 - segmentation-supported: no-segmentation - apdu-timeout: 3000 - number-of-APDU-retries: 3 - device-address-binding: Null - database-revision: 1 -} @endverbatim - */ +/* (Doxygen note: The next two lines pull all the following Javadoc + * into the ServerDemo module.) */ +/** @ingroup ServerDemo */ /*@{*/ /** Buffer used for receiving */ static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; -/** Initialize the handlers we will utilize. */ +/** Initialize the handlers we will utilize. + * @see Device_Init, apdu_set_unconfirmed_handler, apdu_set_confirmed_handler + */ static void Init_Service_Handlers( void) { @@ -164,6 +106,7 @@ static void Init_Service_Handlers( /** Handler registered with atexit() inside main function to, well, cleanup. * Especially if we don't end normally. + * @see datalink_cleanup */ static void cleanup( void) @@ -172,7 +115,13 @@ static void cleanup( } /** 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, + * Load_Control_State_Machine_Handler, handler_cov_task, + * tsm_timer_milliseconds + * * @param argc [in] Arg count. * @param argv [in] Takes one argument: the Device Instance #. * @return 0 on success. diff --git a/bacnet-stack/demo/server/server.h b/bacnet-stack/demo/server/server.h new file mode 100644 index 00000000..7e4db650 --- /dev/null +++ b/bacnet-stack/demo/server/server.h @@ -0,0 +1,107 @@ +/************************************************************************** +* +* Copyright (C) 2006 Steve Karg +* +* 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 SERVER_H_ +#define SERVER_H_ + +/** @file server/server.h Header for example server (ie, BACnet Device) + * using the BACnet Stack */ + +/** @defgroup Demos Demos of Servers and Clients + * Most of the folders under the /demo folder contain demonstration (ie, sample) + * code that implements the name functionality. + * + * The exceptions to this general rule, /handler and /object folders, are + * described in the various BIBBs and Object Framework modules. + */ + +/** @defgroup ServerDemo Demo of a BACnet Server (Device) + * @ingroup Demos + * This is a basic demonstration of a simple BACnet Device consisting of + * the services and properties shown in its PICS (output provided by + * the demo/epics/epics program): + * @verbatim +List of Objects in test device: +{ + object-identifier: (Device, 1234) + object-name: "SimpleServer" + object-type: Device + system-status: operational + vendor-name: "BACnet Stack at SourceForge" + vendor-identifier: 260 + model-name: "GNU" + firmware-version: "0.5.5" + application-software-version: "1.0" + protocol-version: 1 + protocol-revision: 5 + protocol-services-supported: { + false,false,false,false, # ,,,, + false, true, true, true, # , Subscribe-COV, Atomic-Read-File, Atomic-Write-File, + false,false,false,false, # ,,,, + true,false, true, true, # Read-Property,, Read-Property-Multiple, Write-Property, + false, true,false,false, # , Device-Communication-Control,,, + true,false,false,false, # Reinitialize-Device,,,, + false,false,false,false, # ,,,, + true,false,false,false, # COV-Notification,,,, + true, true, true,false, # Time-Synchronization, Who-Has, Who-Is,, + true,false,false,false # UTC-Time-Synchronization,,,, + } + protocol-object-types-supported: { + true, true, true, true, # Analog Input, Analog Output, Analog Value, Binary Input, + true, true,false,false, # Binary Output, Binary Value,,, + true,false, true,false, # Device,, File,, + false, true, true,false, # , Multi-State Input, Multi-State Output,, + false,false,false,false, # ,,,, + true, true,false,false, # Trendlog, Life Safety Point,,, + false,false,false,false, # ,,,, + true,false,false,false, # Load-Control,,,, + false,false,false,false, # ,,,, + false,false # ,, + } + object-list: {(Device, 1234),(Analog Input, 0),(Analog Input, 1), + (Analog Input, 2),(Analog Input, 3),(Analog Output, 0),(Analog Output, 1), + (Analog Output, 2),(Analog Output, 3),(Analog Value, 0),(Analog Value, 1), + (Analog Value, 2),(Analog Value, 3),(Binary Input, 0),(Binary Input, 1), + (Binary Input, 2),(Binary Input, 3),(Binary Input, 4),(Binary Output, 0), + (Binary Output, 1),(Binary Output, 2),(Binary Output, 3),(Binary Value, 0), + (Binary Value, 1),(Binary Value, 2),(Binary Value, 3),(Binary Value, 4), + (Binary Value, 5),(Binary Value, 6),(Binary Value, 7),(Binary Value, 8), + (Binary Value, 9),(Life Safety Point, 0),(Life Safety Point, 1),(Life Safety Point, 2), + (Life Safety Point, 3),(Life Safety Point, 4),(Life Safety Point, 5),(Life Safety Point, 6), + (Load-Control, 0),(Load-Control, 1),(Load-Control, 2),(Load-Control, 3), + (Multi-State Output, 0),(Multi-State Output, 1),(Multi-State Output, 2),(Multi-State Output, 3), + (Multi-State Input, 0),(Trendlog, 0),(Trendlog, 1),(Trendlog, 2), + (Trendlog, 3),(Trendlog, 4),(Trendlog, 5),(Trendlog, 6), + (Trendlog, 7),(File, 0),(File, 1),(File, 2)} + max-apdu-length-accepted: 1476 + segmentation-supported: no-segmentation + apdu-timeout: 3000 + number-of-APDU-retries: 3 + device-address-binding: Null + database-revision: 1 +} @endverbatim + */ + +#endif /* SERVER_H_ */