Indented and cleaned up build. Added Multi-state Output to unit test script.

This commit is contained in:
skarg
2006-08-05 22:00:27 +00:00
parent 4d19c82f59
commit eb2bb41aca
14 changed files with 125 additions and 109 deletions
+13 -14
View File
@@ -275,9 +275,7 @@ int cov_notify_decode_service_request(uint8_t * apdu,
}
int ccov_notify_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
uint8_t * invoke_id,
BACNET_COV_DATA * data)
unsigned apdu_len, uint8_t * invoke_id, BACNET_COV_DATA * data)
{
int len = 0;
unsigned offset = 0;
@@ -295,8 +293,9 @@ int ccov_notify_decode_apdu(uint8_t * apdu,
/* optional limits - must be used as a pair */
if (apdu_len > offset) {
len = cov_notify_decode_service_request(
&apdu[offset], apdu_len - offset, data);
len =
cov_notify_decode_service_request(&apdu[offset],
apdu_len - offset, data);
}
return len;
@@ -318,8 +317,9 @@ int ucov_notify_decode_apdu(uint8_t * apdu,
/* optional limits - must be used as a pair */
offset = 2;
if (apdu_len > offset) {
len = cov_notify_decode_service_request(
&apdu[offset], apdu_len - offset, data);
len =
cov_notify_decode_service_request(&apdu[offset],
apdu_len - offset, data);
}
return len;
@@ -364,8 +364,8 @@ int npdu_encode_apdu(uint8_t * npdu, BACNET_ADDRESS * dest, BACNET_ADDRESS * src
/* dummy function stubs */
int datalink_send_pdu(BACNET_ADDRESS * dest, /* destination address */
uint8_t * pdu, /* any data to be sent - may be null */
unsigned pdu_len) /* number of bytes of data */
{
unsigned pdu_len)
{ /* number of bytes of data */
return 0;
}
@@ -381,8 +381,7 @@ uint16_t Device_Max_APDU_Length_Accepted(void)
}
void testCOVNotifyData(Test * pTest,
BACNET_COV_DATA * data,
BACNET_COV_DATA * test_data)
BACNET_COV_DATA * data, BACNET_COV_DATA * test_data)
{
ct_test(pTest,
test_data->subscriberProcessIdentifier ==
@@ -396,8 +395,7 @@ void testCOVNotifyData(Test * pTest,
ct_test(pTest,
test_data->monitoredObjectIdentifier.instance ==
data->monitoredObjectIdentifier.instance);
ct_test(pTest,
test_data->timeRemaining == data->timeRemaining);
ct_test(pTest, test_data->timeRemaining == data->timeRemaining);
/* FIXME: test the listOfValues in some clever manner */
}
@@ -418,7 +416,8 @@ void testUCOVNotifyData(Test * pTest, BACNET_COV_DATA * data)
testCOVNotifyData(pTest, data, &test_data);
}
void testCCOVNotifyData(Test * pTest, uint8_t invoke_id, BACNET_COV_DATA * data)
void testCCOVNotifyData(Test * pTest, uint8_t invoke_id,
BACNET_COV_DATA * data)
{
uint8_t apdu[480] = { 0 };
int len = 0;
+1 -3
View File
@@ -72,9 +72,7 @@ extern "C" {
uint8_t invoke_id, BACNET_COV_DATA * data);
int ccov_notify_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
uint8_t * invoke_id,
BACNET_COV_DATA * data);
unsigned apdu_len, uint8_t * invoke_id, BACNET_COV_DATA * data);
/* common for both confirmed and unconfirmed */
int cov_notify_decode_service_request(uint8_t * apdu,
+8 -4
View File
@@ -101,7 +101,8 @@ void handler_read_property(uint8_t * service_request,
pdu_len +=
rp_ack_encode_apdu(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id, &data);
fprintf(stderr, "Sending Read Property Ack for Device!\n");
fprintf(stderr,
"Sending Read Property Ack for Device!\n");
send = true;
} else
error = true;
@@ -248,7 +249,8 @@ void handler_read_property(uint8_t * service_request,
pdu_len +=
rp_ack_encode_apdu(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id, &data);
fprintf(stderr, "Sending Read Property Ack for LSP!\n");
fprintf(stderr,
"Sending Read Property Ack for LSP!\n");
send = true;
} else
error = true;
@@ -269,7 +271,8 @@ void handler_read_property(uint8_t * service_request,
pdu_len +=
rp_ack_encode_apdu(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id, &data);
fprintf(stderr, "Sending Read Property Ack for MSO!\n");
fprintf(stderr,
"Sending Read Property Ack for MSO!\n");
send = true;
} else
error = true;
@@ -291,7 +294,8 @@ void handler_read_property(uint8_t * service_request,
pdu_len +=
rp_ack_encode_apdu(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id, &data);
fprintf(stderr, "Sending Read Property Ack for File!\n");
fprintf(stderr,
"Sending Read Property Ack for File!\n");
send = true;
} else
error = true;
+16 -8
View File
@@ -103,7 +103,8 @@ void handler_write_property(uint8_t * service_request,
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
fprintf(stderr, "Sending Write Property Error for Device!\n");
fprintf(stderr,
"Sending Write Property Error for Device!\n");
}
break;
case OBJECT_ANALOG_INPUT:
@@ -123,7 +124,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for BO!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for BO!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
@@ -140,7 +142,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for BV!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for BV!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
@@ -157,7 +160,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for AO!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for AO!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
@@ -174,7 +178,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for AV!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for AV!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
@@ -191,7 +196,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for LSP!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for LSP!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
@@ -208,7 +214,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for MSO!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for MSO!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
@@ -226,7 +233,8 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
fprintf(stderr, "Sending Write Property Simple Ack for File!\n");
fprintf(stderr,
"Sending Write Property Simple Ack for File!\n");
} else {
pdu_len +=
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
+6 -9
View File
@@ -46,8 +46,7 @@
/* Here is our Priority Array. They are supposed to be Real, but */
/* we don't have that kind of memory, so we will use a single byte */
/* and load a Real for returning the value when asked. */
static uint8_t
Analog_Value_Level[MAX_ANALOG_VALUES][BACNET_MAX_PRIORITY];
static uint8_t Analog_Value_Level[MAX_ANALOG_VALUES][BACNET_MAX_PRIORITY];
/* Writable out-of-service allows others to play with our Present Value */
/* without changing the physical output */
static bool Analog_Value_Out_Of_Service[MAX_ANALOG_VALUES];
@@ -178,8 +177,7 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_OBJECT_TYPE:
apdu_len =
encode_tagged_enumerated(&apdu[0], OBJECT_ANALOG_VALUE);
apdu_len = encode_tagged_enumerated(&apdu[0], OBJECT_ANALOG_VALUE);
break;
case PROP_PRESENT_VALUE:
real_value = Analog_Value_Present_Value(object_instance);
@@ -212,11 +210,11 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (array_index == BACNET_ARRAY_ALL) {
object_index =
Analog_Value_Instance_To_Index(object_instance);
object_index = Analog_Value_Instance_To_Index(object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */
if (Analog_Value_Level[object_index][i] == ANALOG_LEVEL_NULL)
if (Analog_Value_Level[object_index][i] ==
ANALOG_LEVEL_NULL)
len = encode_tagged_null(&apdu[apdu_len]);
else {
real_value = Analog_Value_Level[object_index][i];
@@ -233,8 +231,7 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
}
}
} else {
object_index =
Analog_Value_Instance_To_Index(object_instance);
object_index = Analog_Value_Instance_To_Index(object_instance);
if (array_index <= BACNET_MAX_PRIORITY) {
if (Analog_Value_Level[object_index][array_index] ==
ANALOG_LEVEL_NULL)
+2 -5
View File
@@ -237,12 +237,9 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
made to the file data by internal processes or through File
Access Services since the last time the object was archived. */
if (wp_data->value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
if (wp_data->value.type.Boolean)
{
if (wp_data->value.type.Boolean) {
/* FIXME: do something to wp_data->object_instance */
}
else
{
} else {
/* FIXME: do something to wp_data->object_instance */
}
} else {
+3 -6
View File
@@ -170,8 +170,7 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
case PROP_OBJECT_TYPE:
apdu_len =
encode_tagged_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
apdu_len = encode_tagged_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
break;
case PROP_PRESENT_VALUE:
present_value = Binary_Value_Present_Value(object_instance);
@@ -206,8 +205,7 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (array_index == BACNET_ARRAY_ALL) {
object_index =
Binary_Value_Instance_To_Index(object_instance);
object_index = Binary_Value_Instance_To_Index(object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */
if (Binary_Value_Level[object_index][i] == BINARY_NULL)
@@ -229,8 +227,7 @@ int Binary_Value_Encode_Property_APDU(uint8_t * apdu,
}
}
} else {
object_index =
Binary_Value_Instance_To_Index(object_instance);
object_index = Binary_Value_Instance_To_Index(object_instance);
if (array_index <= BACNET_MAX_PRIORITY) {
if (Binary_Value_Level[object_index][array_index] ==
BINARY_NULL)
+2 -1
View File
@@ -657,7 +657,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
if (Life_Safety_Point_Count())
bitstring_set_bit(&bit_string, OBJECT_LIFE_SAFETY_POINT, true);
if (Multistate_Output_Count())
bitstring_set_bit(&bit_string, OBJECT_MULTI_STATE_OUTPUT, true);
bitstring_set_bit(&bit_string, OBJECT_MULTI_STATE_OUTPUT,
true);
#if BACFILE
if (bacfile_count())
bitstring_set_bit(&bit_string, OBJECT_FILE, true);
+15 -9
View File
@@ -109,8 +109,7 @@ unsigned Multistate_Output_Instance_To_Index(uint32_t object_instance)
return index;
}
static uint32_t Multistate_Output_Present_Value(uint32_t
object_instance)
static uint32_t Multistate_Output_Present_Value(uint32_t object_instance)
{
uint32_t value = MULTISTATE_RELINQUISH_DEFAULT;
unsigned index = 0;
@@ -162,7 +161,8 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
Multistate_Output_Init();
switch (property) {
case PROP_OBJECT_IDENTIFIER:
apdu_len = encode_tagged_object_id(&apdu[0], OBJECT_MULTI_STATE_OUTPUT,
apdu_len =
encode_tagged_object_id(&apdu[0], OBJECT_MULTI_STATE_OUTPUT,
object_instance);
break;
/* note: Name and Description don't have to be the same.
@@ -195,7 +195,8 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_enumerated(&apdu[0], EVENT_STATE_NORMAL);
break;
case PROP_OUT_OF_SERVICE:
object_index = Multistate_Output_Instance_To_Index(object_instance);
object_index =
Multistate_Output_Instance_To_Index(object_instance);
state = Multistate_Output_Out_Of_Service[object_index];
apdu_len = encode_tagged_boolean(&apdu[0], state);
break;
@@ -211,10 +212,12 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
Multistate_Output_Instance_To_Index(object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] == MULTISTATE_NULL)
if (Multistate_Output_Level[object_index][i] ==
MULTISTATE_NULL)
len = encode_tagged_null(&apdu[apdu_len]);
else {
present_value = Multistate_Output_Level[object_index][i];
present_value =
Multistate_Output_Level[object_index][i];
len =
encode_tagged_unsigned(&apdu[apdu_len],
present_value);
@@ -295,7 +298,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
object. */
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
(priority != 6 /* reserved */ ) &&
(wp_data->value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
(wp_data->value.type.Unsigned_Int <=
MULTISTATE_NUMBER_OF_STATES)) {
level = wp_data->value.type.Unsigned_Int;
object_index =
Multistate_Output_Instance_To_Index(wp_data->
@@ -321,7 +325,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
} else if (wp_data->value.tag == BACNET_APPLICATION_TAG_NULL) {
level = MULTISTATE_NULL;
object_index =
Multistate_Output_Instance_To_Index(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
@@ -345,7 +350,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
case PROP_OUT_OF_SERVICE:
if (wp_data->value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
object_index =
Multistate_Output_Instance_To_Index(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
Multistate_Output_Out_Of_Service[object_index] =
wp_data->value.type.Boolean;
status = true;
+3 -2
View File
@@ -46,8 +46,9 @@ extern "C" {
int32_t array_index,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *
wp_data, BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
#ifdef TEST
#include "ctest.h"
+9 -6
View File
@@ -143,8 +143,7 @@ int main(int argc, char *argv[])
"%s 1 2 3 4 5 85 4 100.0\r\n"
"where 1=pid, 2=device-id, 3=AV, 4=object-id, 5=time,\r\n"
"85=Present-Value, 4=REAL, 100.0=value\r\n",
filename_remove_path(argv[0]),
filename_remove_path(argv[0]));
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
return 0;
}
/* decode the command line parameters */
@@ -163,7 +162,8 @@ int main(int argc, char *argv[])
cov_data.listOfValues.priority = BACNET_NO_PRIORITY;
/* optional index */
if (argc > 10)
cov_data.listOfValues.propertyArrayIndex = strtol(argv[10], NULL, 0);
cov_data.listOfValues.propertyArrayIndex =
strtol(argv[10], NULL, 0);
else
cov_data.listOfValues.propertyArrayIndex = BACNET_ARRAY_ALL;
@@ -174,17 +174,20 @@ int main(int argc, char *argv[])
}
if (cov_data.monitoredObjectIdentifier.type > MAX_BACNET_OBJECT_TYPE) {
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
cov_data.monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE + 1);
cov_data.monitoredObjectIdentifier.type,
MAX_BACNET_OBJECT_TYPE + 1);
return 1;
}
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
fprintf(stderr, "object-instance=%u - it must be less than %u\r\n",
cov_data.monitoredObjectIdentifier.instance, BACNET_MAX_INSTANCE + 1);
cov_data.monitoredObjectIdentifier.instance,
BACNET_MAX_INSTANCE + 1);
return 1;
}
if (cov_data.listOfValues.propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
cov_data.listOfValues.propertyIdentifier, MAX_BACNET_PROPERTY_ID + 1);
cov_data.listOfValues.propertyIdentifier,
MAX_BACNET_PROPERTY_ID + 1);
return 1;
}
if (tag >= MAX_BACNET_APPLICATION_TAG) {
+5
View File
@@ -114,6 +114,11 @@ make -f demo/object/lsp.mak
./lsp >> test.log
make -f demo/object/lsp.mak clean
make -f demo/object/mso.mak clean
make -f demo/object/mso.mak
./multistate_output >> test.log
make -f demo/object/mso.mak clean
make -f mstp.mak clean
make -f mstp.mak
./mstp >> test.log