Added makefile for event notification unit tests. Cleaned up compile warnings for event notification files.
This commit is contained in:
@@ -36,7 +36,6 @@
|
|||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "datalink.h"
|
|
||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
#include "bacdevobjpropref.h"
|
#include "bacdevobjpropref.h"
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "datalink.h"
|
|
||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
#include "bacpropstates.h"
|
#include "bacpropstates.h"
|
||||||
|
|
||||||
@@ -302,6 +301,7 @@ int bacapp_encode_property_state(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
|
#include <string.h> /* for memset */
|
||||||
|
|
||||||
void testPropStates(
|
void testPropStates(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
|
|||||||
+36
-25
@@ -36,7 +36,6 @@
|
|||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "datalink.h"
|
|
||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
|
|
||||||
int uevent_notify_encode_apdu(
|
int uevent_notify_encode_apdu(
|
||||||
@@ -72,11 +71,9 @@ int cevent_notify_encode_apdu(
|
|||||||
int len = 0; /* length of each encoding */
|
int len = 0; /* length of each encoding */
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
|
||||||
uint16_t max_apdu = Device_Max_APDU_Length_Accepted();
|
|
||||||
|
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||||
apdu[1] = encode_max_segs_max_apdu(0, max_apdu);
|
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||||
apdu[2] = invoke_id;
|
apdu[2] = invoke_id;
|
||||||
apdu[3] = SERVICE_CONFIRMED_EVENT_NOTIFICATION; /* service choice */
|
apdu[3] = SERVICE_CONFIRMED_EVENT_NOTIFICATION; /* service choice */
|
||||||
apdu_len = 4;
|
apdu_len = 4;
|
||||||
@@ -99,8 +96,6 @@ int event_notify_encode_service_request(
|
|||||||
{
|
{
|
||||||
int len = 0; /* length of each encoding */
|
int len = 0; /* length of each encoding */
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
//BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
|
||||||
|
|
||||||
|
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
/* tag 0 - processIdentifier */
|
/* tag 0 - processIdentifier */
|
||||||
@@ -396,7 +391,6 @@ int event_notify_encode_service_request(
|
|||||||
len = encode_closing_tag(&apdu[apdu_len], 10);
|
len = encode_closing_tag(&apdu[apdu_len], 10);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_UNSIGNED_RANGE:
|
case EVENT_UNSIGNED_RANGE:
|
||||||
len = encode_opening_tag(&apdu[apdu_len], 11);
|
len = encode_opening_tag(&apdu[apdu_len], 11);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
@@ -422,8 +416,6 @@ int event_notify_encode_service_request(
|
|||||||
len = encode_closing_tag(&apdu[apdu_len], 11);
|
len = encode_closing_tag(&apdu[apdu_len], 11);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case EVENT_EXTENDED:
|
case EVENT_EXTENDED:
|
||||||
case EVENT_COMMAND_FAILURE:
|
case EVENT_COMMAND_FAILURE:
|
||||||
default:
|
default:
|
||||||
@@ -433,6 +425,10 @@ int event_notify_encode_service_request(
|
|||||||
len = encode_closing_tag(&apdu[apdu_len], 12);
|
len = encode_closing_tag(&apdu[apdu_len], 12);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
|
case NOTIFY_ACK_NOTIFICATION:
|
||||||
|
/* FIXME: handle this case */
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
@@ -444,8 +440,9 @@ int event_notify_decode_service_request(
|
|||||||
BACNET_EVENT_NOTIFICATION_DATA * data)
|
BACNET_EVENT_NOTIFICATION_DATA * data)
|
||||||
{
|
{
|
||||||
int len = 0; /* return value */
|
int len = 0; /* return value */
|
||||||
int section_length;
|
int section_length = 0;
|
||||||
uint32_t tmpUInt;
|
uint32_t value = 0;
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
/* tag 0 - processIdentifier */
|
/* tag 0 - processIdentifier */
|
||||||
if ((section_length =
|
if ((section_length =
|
||||||
@@ -492,22 +489,23 @@ int event_notify_decode_service_request(
|
|||||||
}
|
}
|
||||||
/* tag 5 - priority */
|
/* tag 5 - priority */
|
||||||
if ((section_length =
|
if ((section_length =
|
||||||
decode_context_unsigned(&apdu[len], 5, &tmpUInt)) == -1) {
|
decode_context_unsigned(&apdu[len], 5, &value)) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if (tmpUInt > 0xff) {
|
if (value > 0xff) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
data->priority = (uint8_t) tmpUInt;
|
data->priority = (uint8_t) value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* tag 6 - eventType */
|
/* tag 6 - eventType */
|
||||||
if ((section_length =
|
if ((section_length =
|
||||||
decode_context_enumerated(&apdu[len], 6,
|
decode_context_enumerated(&apdu[len], 6,
|
||||||
(int*)&data->eventType)) == -1) {
|
&value)) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
data->eventType = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
}
|
}
|
||||||
/* tag 7 - messageText */
|
/* tag 7 - messageText */
|
||||||
@@ -534,9 +532,10 @@ int event_notify_decode_service_request(
|
|||||||
/* tag 8 - notifyType */
|
/* tag 8 - notifyType */
|
||||||
if ((section_length =
|
if ((section_length =
|
||||||
decode_context_enumerated(&apdu[len], 8,
|
decode_context_enumerated(&apdu[len], 8,
|
||||||
(int*)&data->notifyType)) == -1) {
|
&value)) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
data->notifyType = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
}
|
}
|
||||||
switch (data->notifyType) {
|
switch (data->notifyType) {
|
||||||
@@ -553,20 +552,27 @@ int event_notify_decode_service_request(
|
|||||||
/* tag 10 - fromState */
|
/* tag 10 - fromState */
|
||||||
if ((section_length =
|
if ((section_length =
|
||||||
decode_context_enumerated(&apdu[len], 10,
|
decode_context_enumerated(&apdu[len], 10,
|
||||||
(int*)&data->fromState)) == -1) {
|
&value)) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
data->fromState = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NOTIFY_ACK_NOTIFICATION:
|
||||||
|
/* FIXME: handle this case */
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* tag 11 - toState */
|
/* tag 11 - toState */
|
||||||
if ((section_length =
|
if ((section_length =
|
||||||
decode_context_enumerated(&apdu[len], 11,
|
decode_context_enumerated(&apdu[len], 11,
|
||||||
(int*)&data->toState)) == -1) {
|
&value)) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
data->toState = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
}
|
}
|
||||||
/* tag 12 - eventValues */
|
/* tag 12 - eventValues */
|
||||||
@@ -744,18 +750,18 @@ int event_notify_decode_service_request(
|
|||||||
case EVENT_CHANGE_OF_LIFE_SAFETY:
|
case EVENT_CHANGE_OF_LIFE_SAFETY:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_enumerated(&apdu[len], 0,
|
decode_context_enumerated(&apdu[len], 0,
|
||||||
(int*)&data->notificationParams.
|
&value))) {
|
||||||
changeOfLifeSafety.newState))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
data->notificationParams.changeOfLifeSafety.newState = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_enumerated(&apdu[len], 1,
|
decode_context_enumerated(&apdu[len], 1,
|
||||||
(int*)&data->notificationParams.
|
&value))) {
|
||||||
changeOfLifeSafety.newMode))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
data->notificationParams.changeOfLifeSafety.newMode = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
@@ -768,10 +774,10 @@ int event_notify_decode_service_request(
|
|||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_enumerated(&apdu[len], 3,
|
decode_context_enumerated(&apdu[len], 3,
|
||||||
(int*)&data->notificationParams.
|
&value))) {
|
||||||
changeOfLifeSafety.operationExpected))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
data->notificationParams.changeOfLifeSafety.operationExpected = value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -828,7 +834,6 @@ int event_notify_decode_service_request(
|
|||||||
len += section_length;
|
len += section_length;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -843,6 +848,12 @@ int event_notify_decode_service_request(
|
|||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case NOTIFY_ACK_NOTIFICATION:
|
||||||
|
/* FIXME: handle this case */
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
LOGFILE = test.log
|
LOGFILE = test.log
|
||||||
|
|
||||||
all: abort address arf awf bacapp bacdcode bacerror bacint \
|
all: abort address arf awf bacapp bacdcode bacerror bacint \
|
||||||
bacstr cov crc datetime dcc fifo filename iam ihave \
|
bacstr cov crc datetime dcc event fifo filename iam ihave \
|
||||||
indtext keylist key lso mstp npdu rd reject ringbuf rp \
|
indtext keylist key lso mstp npdu rd reject ringbuf rp \
|
||||||
rpm sbuf timesync whohas whois wp
|
rpm sbuf timesync whohas whois wp
|
||||||
|
|
||||||
@@ -76,6 +76,11 @@ dcc: logfile test/dcc.mak
|
|||||||
( ./test/dcc >> ${LOGFILE} )
|
( ./test/dcc >> ${LOGFILE} )
|
||||||
make -C test -f dcc.mak clean
|
make -C test -f dcc.mak clean
|
||||||
|
|
||||||
|
event: logfile test/event.mak
|
||||||
|
make -C test -f event.mak clean all
|
||||||
|
( ./test/event >> ${LOGFILE} )
|
||||||
|
make -C test -f event.mak clean
|
||||||
|
|
||||||
filename: logfile test/filename.mak
|
filename: logfile test/filename.mak
|
||||||
make -C test -f filename.mak clean all
|
make -C test -f filename.mak clean all
|
||||||
( ./test/filename >> ${LOGFILE} )
|
( ./test/filename >> ${LOGFILE} )
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#Makefile to build test case
|
||||||
|
CC = gcc
|
||||||
|
SRC_DIR = ../src
|
||||||
|
INCLUDES = -I../include -I.
|
||||||
|
DEFINES = -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_EVENT
|
||||||
|
|
||||||
|
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
|
||||||
|
|
||||||
|
SRCS = $(SRC_DIR)/bacdcode.c \
|
||||||
|
$(SRC_DIR)/bacint.c \
|
||||||
|
$(SRC_DIR)/bacstr.c \
|
||||||
|
$(SRC_DIR)/bacreal.c \
|
||||||
|
$(SRC_DIR)/bacerror.c \
|
||||||
|
$(SRC_DIR)/bacapp.c \
|
||||||
|
$(SRC_DIR)/bactext.c \
|
||||||
|
$(SRC_DIR)/indtext.c \
|
||||||
|
$(SRC_DIR)/datetime.c \
|
||||||
|
$(SRC_DIR)/memcopy.c \
|
||||||
|
$(SRC_DIR)/timestamp.c \
|
||||||
|
$(SRC_DIR)/bacpropstates.c \
|
||||||
|
$(SRC_DIR)/bacdevobjpropref.c \
|
||||||
|
$(SRC_DIR)/event.c \
|
||||||
|
ctest.c
|
||||||
|
|
||||||
|
TARGET = event
|
||||||
|
|
||||||
|
all: ${TARGET}
|
||||||
|
|
||||||
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
${TARGET}: ${OBJS}
|
||||||
|
${CC} -o $@ ${OBJS}
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
${CC} -c ${CFLAGS} $*.c -o $@
|
||||||
|
|
||||||
|
depend:
|
||||||
|
rm -f .depend
|
||||||
|
${CC} -MM ${CFLAGS} *.c >> .depend
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
|
||||||
|
|
||||||
|
include: .depend
|
||||||
Reference in New Issue
Block a user