Corrected index problem in ao.c, and finished unit test. Closed bug 1266293: error in ao.c: Analog_Output_Present_Value.
This commit is contained in:
+7
-3
@@ -125,7 +125,7 @@ static float Analog_Output_Present_Value(uint32_t object_instance)
|
|||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
Analog_Output_Init();
|
Analog_Output_Init();
|
||||||
index = Analog_Output_Index_To_Instance(object_instance);
|
index = Analog_Output_Instance_To_Index(object_instance);
|
||||||
if (index < MAX_ANALOG_OUTPUTS)
|
if (index < MAX_ANALOG_OUTPUTS)
|
||||||
{
|
{
|
||||||
for (i = 0; i < BACNET_MAX_PRIORITIES; i++)
|
for (i = 0; i < BACNET_MAX_PRIORITIES; i++)
|
||||||
@@ -373,13 +373,17 @@ void testAnalogOutput(Test * pTest)
|
|||||||
BACNET_OBJECT_TYPE decoded_type = OBJECT_ANALOG_OUTPUT;
|
BACNET_OBJECT_TYPE decoded_type = OBJECT_ANALOG_OUTPUT;
|
||||||
uint32_t decoded_instance = 0;
|
uint32_t decoded_instance = 0;
|
||||||
uint32_t instance = 123;
|
uint32_t instance = 123;
|
||||||
|
BACNET_ERROR_CLASS error_class;
|
||||||
|
BACNET_ERROR_CODE error_code;
|
||||||
|
|
||||||
|
|
||||||
len = Analog_Output_Encode_Property_APDU(
|
len = Analog_Output_Encode_Property_APDU(
|
||||||
&apdu[0],
|
&apdu[0],
|
||||||
instance,
|
instance,
|
||||||
PROP_OBJECT_IDENTIFIER,
|
PROP_OBJECT_IDENTIFIER,
|
||||||
BACNET_ARRAY_ALL);
|
BACNET_ARRAY_ALL,
|
||||||
|
&error_class,
|
||||||
|
&error_code);
|
||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
@@ -391,7 +395,7 @@ void testAnalogOutput(Test * pTest)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_ANALOG_INPUT
|
#ifdef TEST_ANALOG_OUTPUT
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Test *pTest;
|
Test *pTest;
|
||||||
|
|||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#Makefile to build test case
|
||||||
|
CC = gcc
|
||||||
|
BASEDIR = .
|
||||||
|
#CFLAGS = -Wall -I.
|
||||||
|
# -g for debugging with gdb
|
||||||
|
#CFLAGS = -Wall -I. -g
|
||||||
|
CFLAGS = -Wall -I. -Itest -DTEST -DTEST_ANALOG_OUTPUT -g
|
||||||
|
|
||||||
|
SRCS = bacdcode.c \
|
||||||
|
bigend.c \
|
||||||
|
ao.c \
|
||||||
|
test/ctest.c
|
||||||
|
|
||||||
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
TARGET = analog_output
|
||||||
|
|
||||||
|
all: ${TARGET}
|
||||||
|
|
||||||
|
${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
|
||||||
@@ -74,6 +74,11 @@ make -f ai.mak
|
|||||||
./analog_input >> test.log
|
./analog_input >> test.log
|
||||||
make -f ai.mak clean
|
make -f ai.mak clean
|
||||||
|
|
||||||
|
make -f ao.mak clean
|
||||||
|
make -f ao.mak
|
||||||
|
./analog_output >> test.log
|
||||||
|
make -f ao.mak clean
|
||||||
|
|
||||||
make -f wp.mak clean
|
make -f wp.mak clean
|
||||||
make -f wp.mak
|
make -f wp.mak
|
||||||
./writeproperty >> test.log
|
./writeproperty >> test.log
|
||||||
|
|||||||
Reference in New Issue
Block a user