Cleaned up comments

This commit is contained in:
skarg
2005-04-10 12:07:03 +00:00
parent 3ebaedbd39
commit 3eb9f20bb0
4 changed files with 21 additions and 32 deletions
+1 -1
View File
@@ -48,7 +48,7 @@
// embedded systems need fixed name sizes // embedded systems need fixed name sizes
#define MAX_OBJECT_NAME 10 #define MAX_OBJECT_NAME 10
// device object properties // common object properties
typedef struct BACnet_Object_Data typedef struct BACnet_Object_Data
{ {
uint32_t Object_Identifier; uint32_t Object_Identifier;
+6 -4
View File
@@ -38,7 +38,7 @@
#include "device.h" #include "device.h"
#include "rp.h" #include "rp.h"
// encode service - use -1 for limit if you want unlimited // encode service
int rp_encode_apdu( int rp_encode_apdu(
uint8_t *apdu, uint8_t *apdu,
uint8_t invoke_id, uint8_t invoke_id,
@@ -63,8 +63,8 @@ int rp_encode_apdu(
len = encode_context_enumerated(&apdu[apdu_len], 1, len = encode_context_enumerated(&apdu[apdu_len], 1,
object_property); object_property);
apdu_len += len; apdu_len += len;
/* optional array index; ALL is -1 which is assumed when missing */ /* optional array index */
if (array_index >= 0) if (array_index != BACNET_ARRAY_ALL)
{ {
len = encode_context_unsigned(&apdu[apdu_len], 2, len = encode_context_unsigned(&apdu[apdu_len], 2,
array_index); array_index);
@@ -112,8 +112,10 @@ int rp_decode_service_request(
len += decode_tag_number_and_value(&apdu[len],&tag_number, len += decode_tag_number_and_value(&apdu[len],&tag_number,
&len_value_type); &len_value_type);
if (tag_number == 2) if (tag_number == 2)
{
len += decode_unsigned(&apdu[len], len_value_type, len += decode_unsigned(&apdu[len], len_value_type,
array_index); array_index);
}
else else
*array_index = BACNET_ARRAY_ALL; *array_index = BACNET_ARRAY_ALL;
} }
@@ -241,7 +243,7 @@ int rp_ack_decode_service_request(
// Tag 3: opening context tag */ // Tag 3: opening context tag */
if (decode_is_opening_tag_number(&apdu[len], 3)) if (decode_is_opening_tag_number(&apdu[len], 3))
{ {
// tag number of 3 is not extended so only one octet // a tag number of 3 is not extended so only one octet
len++; len++;
// don't decode the application tag number or its data here // don't decode the application tag number or its data here
data->application_data = &apdu[len]; data->application_data = &apdu[len];
+1 -1
View File
@@ -47,7 +47,7 @@ typedef struct BACnet_Read_Property_Data
int application_data_len; int application_data_len;
} BACNET_READ_PROPERTY_DATA; } BACNET_READ_PROPERTY_DATA;
// encode service - use -1 for limit if you want unlimited // encode service
int rp_encode_apdu( int rp_encode_apdu(
uint8_t *apdu, uint8_t *apdu,
uint8_t invoke_id, uint8_t invoke_id,
+12 -25
View File
@@ -36,7 +36,7 @@
#include "bacdcode.h" #include "bacdcode.h"
#include "bacdef.h" #include "bacdef.h"
#include "device.h" #include "device.h"
#include "rp.h" #include "wp.h"
// encode service // encode service
int wp_encode_apdu( int wp_encode_apdu(
@@ -61,7 +61,7 @@ int wp_encode_apdu(
/* optional array index; ALL is -1 which is assumed when missing */ /* optional array index; ALL is -1 which is assumed when missing */
if (data->array_index != BACNET_ARRAY_ALL) if (data->array_index != BACNET_ARRAY_ALL)
apdu_len += encode_context_unsigned(&apdu[apdu_len], 2, apdu_len += encode_context_unsigned(&apdu[apdu_len], 2,
array_index); data->array_index);
// propertyValue // propertyValue
apdu_len += encode_opening_tag(&apdu[apdu_len], 3); apdu_len += encode_opening_tag(&apdu[apdu_len], 3);
for (len = 0; len < data->property_value_len; len++) for (len = 0; len < data->property_value_len; len++)
@@ -71,7 +71,7 @@ int wp_encode_apdu(
apdu_len += encode_closing_tag(&apdu[apdu_len], 3); apdu_len += encode_closing_tag(&apdu[apdu_len], 3);
// optional priority - 0 if not set, 1..16 if set // optional priority - 0 if not set, 1..16 if set
if (data->priority) if (data->priority)
apdu_len += = encode_context_unsigned(&apdu[apdu_len], 4, apdu_len += encode_context_unsigned(&apdu[apdu_len], 4,
data->priority); data->priority);
} }
@@ -196,22 +196,14 @@ void testWriteProperty(Test * pTest)
int apdu_len = 0; int apdu_len = 0;
uint8_t invoke_id = 128; uint8_t invoke_id = 128;
uint8_t test_invoke_id = 0; uint8_t test_invoke_id = 0;
BACNET_OBJECT_TYPE object_type = OBJECT_CALENDAR; BACNET_WRITE_PROPERTY_DATA data = {0};
BACNET_OBJECT_TYPE test_object_type = 0; BACNET_WRITE_PROPERTY_DATA test_data = {0};
uint32_t object_instance = 1;
uint32_t test_object_instance = 0;
BACNET_PROPERTY_ID object_property = PROP_ARCHIVE;
BACNET_PROPERTY_ID test_object_property = 0;
int32_t array_index = 2;
int32_t test_array_index = 0;
// FIXME: set values for data
len = wp_encode_apdu( len = wp_encode_apdu(
&apdu[0], &apdu[0],
invoke_id, invoke_id,
object_type, &data);
object_instance,
object_property,
array_index);
ct_test(pTest, len != 0); ct_test(pTest, len != 0);
apdu_len = len; apdu_len = len;
@@ -219,15 +211,12 @@ void testWriteProperty(Test * pTest)
&apdu[0], &apdu[0],
apdu_len, apdu_len,
&test_invoke_id, &test_invoke_id,
&test_object_type, &test_data);
&test_object_instance,
&test_object_property,
&test_array_index);
ct_test(pTest, len != -1); ct_test(pTest, len != -1);
ct_test(pTest, test_object_type == object_type); ct_test(pTest, test_data.object_type == data.object_type);
ct_test(pTest, test_object_instance == object_instance); ct_test(pTest, test_data.object_instance == data.object_instance);
ct_test(pTest, test_object_property == object_property); ct_test(pTest, test_data.object_property == data.object_property);
ct_test(pTest, test_array_index == array_index); ct_test(pTest, test_data.array_index == data.array_index);
return; return;
} }
@@ -242,8 +231,6 @@ int main(void)
/* individual tests */ /* individual tests */
rc = ct_addTestFunction(pTest, testWriteProperty); rc = ct_addTestFunction(pTest, testWriteProperty);
assert(rc); assert(rc);
rc = ct_addTestFunction(pTest, testWritePropertyAck);
assert(rc);
ct_setStream(pTest, stdout); ct_setStream(pTest, stdout);
ct_run(pTest); ct_run(pTest);