Sync some handler fixes and demo object fixes and updates and some comment fixes from branch bacnet-stack-0-8-0.

This commit is contained in:
skarg
2016-09-08 15:29:32 +00:00
parent 415475ba1f
commit 456c0ed42c
9 changed files with 111 additions and 108 deletions
+2
View File
@@ -808,6 +808,7 @@ static void BuildPropRequest(
} }
propEntry->propertyIdentifier = Property_Value_List[i].property_id; propEntry->propertyIdentifier = Property_Value_List[i].property_id;
propEntry->propertyArrayIndex = BACNET_ARRAY_ALL; propEntry->propertyArrayIndex = BACNET_ARRAY_ALL;
propEntry->next = NULL;
oldEntry = propEntry; oldEntry = propEntry;
propEntry = NULL; propEntry = NULL;
} }
@@ -1377,6 +1378,7 @@ void StartNextObject(
rpm_object->object_instance = pNewObject->instance; rpm_object->object_instance = pNewObject->instance;
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE)); rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
rpm_object->listOfProperties = rpm_property; rpm_object->listOfProperties = rpm_property;
rpm_object->next = NULL;
assert(rpm_property); assert(rpm_property);
rpm_property->propertyIdentifier = PROP_ALL; rpm_property->propertyIdentifier = PROP_ALL;
rpm_property->propertyArrayIndex = BACNET_ARRAY_ALL; rpm_property->propertyArrayIndex = BACNET_ARRAY_ALL;
+2
View File
@@ -298,9 +298,11 @@ void dlenv_init(
if (!datalink_init(getenv("BACNET_IFACE"))) { if (!datalink_init(getenv("BACNET_IFACE"))) {
exit(1); exit(1);
} }
#if (MAX_TSM_TRANSACTIONS)
pEnv = getenv("BACNET_INVOKE_ID"); pEnv = getenv("BACNET_INVOKE_ID");
if (pEnv) { if (pEnv) {
tsm_invokeID_set((uint8_t) strtol(pEnv, NULL, 0)); tsm_invokeID_set((uint8_t) strtol(pEnv, NULL, 0));
} }
#endif
dlenv_register_as_foreign_device(); dlenv_register_as_foreign_device();
} }
+3 -3
View File
@@ -892,13 +892,13 @@ void handler_cov_subscribe(
bytes_sent = bytes_sent =
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len); pdu_len);
if (bytes_sent <= 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "SubscribeCOV: Failed to send PDU (%s)!\n", fprintf(stderr, "SubscribeCOV: Failed to send PDU (%s)!\n",
strerror(errno)); strerror(errno));
#else
bytes_sent = bytes_sent;
#endif #endif
}
return; return;
} }
+87 -87
View File
@@ -1,87 +1,87 @@
/** /**
* @file * @file
* @author Daniel Blazevic <daniel.blazevic@gmail.com> * @author Daniel Blazevic <daniel.blazevic@gmail.com>
* @date 2014 * @date 2014
* @brief GetEvent ACK service handling * @brief GetEvent ACK service handling
* *
* @section LICENSE * @section LICENSE
* *
* Copyright (C) 2014 Daniel Blazevic <daniel.blazevic@gmail.com> * Copyright (C) 2014 Daniel Blazevic <daniel.blazevic@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, * without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to * distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to * permit persons to whom the Software is furnished to do so, subject to
* the following conditions: * the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* @section DESCRIPTION * @section DESCRIPTION
* *
* The GetEventInformation service ACK service handler is used by a client * The GetEventInformation service ACK service handler is used by a client
* BACnet-user to obtain a summary of all "active event states". The term * BACnet-user to obtain a summary of all "active event states". The term
* "active event states" refers to all event-initiating objects that have an * "active event states" refers to all event-initiating objects that have an
* Event_State property whose value is not equal to NORMAL, or have an * Event_State property whose value is not equal to NORMAL, or have an
* Acked_Transitions property, which has at least one of the bits * Acked_Transitions property, which has at least one of the bits
* (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. * (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE.
*/ */
#include <assert.h> #include <assert.h>
#include "config.h" #include "config.h"
#include "txbuf.h" #include "txbuf.h"
#include "bacdef.h" #include "bacdef.h"
#include "bacdcode.h" #include "bacdcode.h"
#include "bacerror.h" #include "bacerror.h"
#include "apdu.h" #include "apdu.h"
#include "npdu.h" #include "npdu.h"
#include "abort.h" #include "abort.h"
#include "handlers.h" #include "handlers.h"
#include "getevent.h" #include "getevent.h"
/* 40 = min size of get event data in APDU */ /* 40 = min size of get event data in APDU */
#define MAX_NUMBER_OF_EVENTS ((MAX_APDU / 40) + 1) #define MAX_NUMBER_OF_EVENTS ((MAX_APDU / 40) + 1)
/** Example function to handle a GetEvent ACK. /** Example function to handle a GetEvent ACK.
* *
* @param service_request [in] The contents of the service request. * @param service_request [in] The contents of the service request.
* @param service_len [in] The length of the service_request. * @param service_len [in] The length of the service_request.
* @param src [in] BACNET_ADDRESS of the source of the message * @param src [in] BACNET_ADDRESS of the source of the message
* @param service_data [in] The BACNET_CONFIRMED_SERVICE_ACK_DATA information * @param service_data [in] The BACNET_CONFIRMED_SERVICE_ACK_DATA information
* decoded from the APDU header of this message. * decoded from the APDU header of this message.
*/ */
void get_event_ack_handler( void get_event_ack_handler(
uint8_t *service_request, uint8_t *service_request,
uint16_t service_len, uint16_t service_len,
BACNET_ADDRESS *src, BACNET_ADDRESS *src,
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data) BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
{ {
uint8_t i = 0; uint8_t i = 0;
uint16_t apdu_len = 0; uint16_t apdu_len = 0;
bool more_events = false; bool more_events = false;
/* initialize array big enough to accommodate /* initialize array big enough to accommodate
multiple get event data in APDU */ multiple get event data in APDU */
BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS]; BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS];
for (i = 1; i < MAX_NUMBER_OF_EVENTS; i++) { for (i = 1; i < MAX_NUMBER_OF_EVENTS; i++) {
/* Create linked list */ /* Create linked list */
get_event_data[i - 1].next = &get_event_data[i]; get_event_data[i - 1].next = &get_event_data[i];
} }
apdu_len = apdu_len =
getevent_ack_decode_service_request(&service_request[0], getevent_ack_decode_service_request(&service_request[0],
service_len, &get_event_data[0], &more_events); service_len, &get_event_data[0], &more_events);
if (apdu_len > 0) { if (apdu_len > 0) {
/* FIXME: Add code to process get_event_data */ /* FIXME: Add code to process get_event_data */
} }
} }
+7 -7
View File
@@ -49,8 +49,8 @@
ANALOG_INPUT_DESCR AI_Descr[MAX_ANALOG_INPUTS]; ANALOG_INPUT_DESCR AI_Descr[MAX_ANALOG_INPUTS];
/* These arrays are used by the ReadPropertyMultiple handler */ /* These three arrays are used by the ReadPropertyMultiple handler */
static const int Analog_Input_Properties_Required[] = { static const int Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_NAME,
PROP_OBJECT_TYPE, PROP_OBJECT_TYPE,
@@ -62,7 +62,7 @@ static const int Analog_Input_Properties_Required[] = {
-1 -1
}; };
static const int Analog_Input_Properties_Optional[] = { static const int Properties_Optional[] = {
PROP_DESCRIPTION, PROP_DESCRIPTION,
PROP_RELIABILITY, PROP_RELIABILITY,
PROP_COV_INCREMENT, PROP_COV_INCREMENT,
@@ -81,7 +81,7 @@ static const int Analog_Input_Properties_Optional[] = {
-1 -1
}; };
static const int Analog_Input_Properties_Proprietary[] = { static const int Properties_Proprietary[] = {
9997, 9997,
9998, 9998,
9999, 9999,
@@ -94,11 +94,11 @@ void Analog_Input_Property_Lists(
const int **pProprietary) const int **pProprietary)
{ {
if (pRequired) if (pRequired)
*pRequired = Analog_Input_Properties_Required; *pRequired = Properties_Required;
if (pOptional) if (pOptional)
*pOptional = Analog_Input_Properties_Optional; *pOptional = Properties_Optional;
if (pProprietary) if (pProprietary)
*pProprietary = Analog_Input_Properties_Proprietary; *pProprietary = Properties_Proprietary;
return; return;
} }
+3 -4
View File
@@ -100,10 +100,9 @@ void Analog_Value_Property_Lists(
void Analog_Value_Init( void Analog_Value_Init(
void) void)
{ {
#if defined(INTRINSIC_REPORTING)
unsigned i, j;
#else
unsigned i; unsigned i;
#if defined(INTRINSIC_REPORTING)
unsigned j;
#endif #endif
for (i = 0; i < MAX_ANALOG_VALUES; i++) { for (i = 0; i < MAX_ANALOG_VALUES; i++) {
@@ -247,7 +246,7 @@ int Analog_Value_Read_Property(
ANALOG_VALUE_DESCR *CurrentAV; ANALOG_VALUE_DESCR *CurrentAV;
#if defined(INTRINSIC_REPORTING) #if defined(INTRINSIC_REPORTING)
int len = 0; int len = 0;
unsigned int i = 0; unsigned i = 0;
#endif #endif
if ((rpdata == NULL) || (rpdata->application_data == NULL) || if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
+2 -2
View File
@@ -54,8 +54,8 @@ static BACNET_LIFE_SAFETY_OPERATION
/* Writable out-of-service allows others to play with our Present Value */ /* Writable out-of-service allows others to play with our Present Value */
/* without changing the physical output */ /* without changing the physical output */
static bool Life_Safety_Point_Out_Of_Service[MAX_LIFE_SAFETY_POINTS]; static bool Life_Safety_Point_Out_Of_Service[MAX_LIFE_SAFETY_POINTS];
/* These arrays are used by the ReadPropertyMultiple handler and
property-list property (as of protocol-revision 14) */ /* These three arrays are used by the ReadPropertyMultiple handler */
static const int Life_Safety_Point_Properties_Required[] = { static const int Life_Safety_Point_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_NAME,
+2 -2
View File
@@ -43,8 +43,8 @@
#endif #endif
/* When all the priorities are level null, the present value returns */ /* When all the priorities are level null, the present value returns */
/* the Relinquish Default value */ /* the Relinquish Default value, 0 is not allowed */
#define MULTISTATE_RELINQUISH_DEFAULT 1 /* multistates cannot be 0 ! */ #define MULTISTATE_RELINQUISH_DEFAULT 1
/* NULL part of the array */ /* NULL part of the array */
#define MULTISTATE_NULL (255) #define MULTISTATE_NULL (255)
+3 -3
View File
@@ -1594,13 +1594,13 @@ static int local_read_property(
* Attempt to fetch the logged property and store it in the Trend Log * * Attempt to fetch the logged property and store it in the Trend Log *
****************************************************************************/ ****************************************************************************/
static void TL_fetch_property( void TL_fetch_property(
int iLog) int iLog)
{ {
uint8_t ValueBuf[MAX_APDU]; /* This is a big buffer in case someone selects the device object list for example */ uint8_t ValueBuf[MAX_APDU]; /* This is a big buffer in case someone selects the device object list for example */
uint8_t StatusBuf[3]; /* Should be tag, bits unused in last octet and 1 byte of data */ uint8_t StatusBuf[3]; /* Should be tag, bits unused in last octet and 1 byte of data */
BACNET_ERROR_CLASS error_class = 0; BACNET_ERROR_CLASS error_class = ERROR_CLASS_SERVICES;
BACNET_ERROR_CODE error_code = ERROR_CODE_SUCCESS; BACNET_ERROR_CODE error_code = ERROR_CODE_OTHER;
int iLen; int iLen;
uint8_t ucCount; uint8_t ucCount;
TL_LOG_INFO *CurrentLog; TL_LOG_INFO *CurrentLog;