From d189f72abd84ed5fc0b504c349c8a6f792a044ca Mon Sep 17 00:00:00 2001 From: skarg Date: Wed, 7 Mar 2012 22:04:01 +0000 Subject: [PATCH] Notification Class had wrong array indexes when assigning priorities. Thank you, Dmitry Korobkov! Bug ID 3495994. --- bacnet-stack/demo/object/nc.c | 23 ++++++++++------------- bacnet-stack/demo/object/nc.h | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/bacnet-stack/demo/object/nc.c b/bacnet-stack/demo/object/nc.c index e8b02bbd..220675e0 100644 --- a/bacnet-stack/demo/object/nc.c +++ b/bacnet-stack/demo/object/nc.c @@ -95,9 +95,9 @@ void Notification_Class_Init( memset(&NC_Info[NotifyIdx], 0x00, sizeof(NOTIFICATION_CLASS_INFO)); /* set the basic parameters */ NC_Info[NotifyIdx].Ack_Required = 0; - NC_Info[NotifyIdx].Priority[0] = 255; /* The lowest priority for Normal message. */ - NC_Info[NotifyIdx].Priority[1] = 255; /* The lowest priority for Normal message. */ - NC_Info[NotifyIdx].Priority[2] = 255; /* The lowest priority for Normal message. */ + NC_Info[NotifyIdx].Priority[TRANSITION_TO_OFFNORMAL] = 255; /* The lowest priority for Normal message. */ + NC_Info[NotifyIdx].Priority[TRANSITION_TO_FAULT] = 255; /* The lowest priority for Normal message. */ + NC_Info[NotifyIdx].Priority[TRANSITION_TO_NORMAL] = 255; /* The lowest priority for Normal message. */ } return; @@ -223,19 +223,16 @@ int Notification_Class_Read_Property( apdu_len += encode_application_unsigned(&apdu[0], 3); else { if (rpdata->array_index == BACNET_ARRAY_ALL) { - /* TO-OFFNORMAL */ apdu_len += encode_application_unsigned(&apdu[apdu_len], - CurrentNotify->Priority[0]); - /* TO-FAULT */ + CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL]); apdu_len += encode_application_unsigned(&apdu[apdu_len], - CurrentNotify->Priority[1]); - /* TO-NORMAL */ + CurrentNotify->Priority[TRANSITION_TO_FAULT]); apdu_len += encode_application_unsigned(&apdu[apdu_len], - CurrentNotify->Priority[2]); - } else if (rpdata->array_index <= 3) { + CurrentNotify->Priority[TRANSITION_TO_NORMAL]); + } else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) { apdu_len += encode_application_unsigned(&apdu[apdu_len], CurrentNotify->Priority[rpdata->array_index - 1]); @@ -819,14 +816,14 @@ void Notification_Class_common_reporting_function( /* Priority and AckRequired */ switch (event_data->toState) { case EVENT_STATE_NORMAL: - event_data->priority = CurrentNotify->Priority[EVENT_STATE_NORMAL]; + event_data->priority = CurrentNotify->Priority[TRANSITION_TO_NORMAL]; event_data->ackRequired = (CurrentNotify-> Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? true : false; break; case EVENT_STATE_FAULT: - event_data->priority = CurrentNotify->Priority[EVENT_STATE_FAULT]; + event_data->priority = CurrentNotify->Priority[TRANSITION_TO_FAULT]; event_data->ackRequired = (CurrentNotify-> Ack_Required & TRANSITION_TO_FAULT_MASKED) ? true : false; @@ -836,7 +833,7 @@ void Notification_Class_common_reporting_function( case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_LOW_LIMIT: event_data->priority = - CurrentNotify->Priority[EVENT_STATE_OFFNORMAL]; + CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL]; event_data->ackRequired = (CurrentNotify-> Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false; diff --git a/bacnet-stack/demo/object/nc.h b/bacnet-stack/demo/object/nc.h index 04c0ea68..ecd6e73f 100644 --- a/bacnet-stack/demo/object/nc.h +++ b/bacnet-stack/demo/object/nc.h @@ -76,7 +76,7 @@ BACnetRecipient ::= CHOICE { /* Structure containing configuration for a Notification Class */ typedef struct Notification_Class_info { - uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */ + uint8_t Priority[MAX_BACNET_EVENT_TRANSITION]; /* BACnetARRAY[3] of Unsigned */ uint8_t Ack_Required; /* BACnetEventTransitionBits */ BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */ } NOTIFICATION_CLASS_INFO;