Reverted the WriteProperty value changes. I am not really happy with the solution and it would require a bunch of fixes to the demos.

This commit is contained in:
skarg
2006-08-29 20:43:46 +00:00
parent 42e0033c98
commit 6e67d7388d
5 changed files with 34 additions and 30 deletions
+21
View File
@@ -1038,6 +1038,27 @@ int encode_tagged_octet_string(uint8_t * apdu,
return apdu_len;
}
/* from clause 20.2.8 Encoding of an Octet String Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_context_octet_string(uint8_t * apdu,
int tag_number,
BACNET_OCTET_STRING * octet_string)
{
int apdu_len = 0;
if (apdu && octet_string) {
apdu_len = encode_tag(&apdu[0], (uint8_t) tag_number,
true, octetstring_length(octet_string));
if ((apdu_len + octetstring_length(octet_string)) < MAX_APDU)
apdu_len += encode_octet_string(&apdu[apdu_len], octet_string);
else
apdu_len = 0;
}
return apdu_len;
}
/* from clause 20.2.8 Encoding of an Octet String Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
+3
View File
@@ -108,6 +108,9 @@ extern "C" {
BACNET_OCTET_STRING * octet_string);
int encode_tagged_octet_string(uint8_t * apdu,
BACNET_OCTET_STRING * octet_string);
int encode_context_octet_string(uint8_t * apdu,
int tag_number,
BACNET_OCTET_STRING * octet_string);
int decode_octet_string(uint8_t * apdu, uint32_t len_value,
BACNET_OCTET_STRING * octet_string);
+1
View File
@@ -227,6 +227,7 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
return false;
}
/* decode the some of the request */
switch (wp_data->object_property) {
case PROP_ARCHIVE:
+6 -19
View File
@@ -67,8 +67,8 @@ int wp_encode_apdu(uint8_t * apdu,
/* propertyValue */
len = encode_opening_tag(&apdu[apdu_len], 3);
apdu_len += len;
memmove(&apdu[apdu_len], &data->value[0], value_len);
apdu_len += value_len;
len = bacapp_encode_application_data(&apdu[apdu_len], &data->value);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 3);
apdu_len += len;
/* optional priority - 0 if not set, 1..16 if set */
@@ -82,24 +82,11 @@ int wp_encode_apdu(uint8_t * apdu,
return apdu_len;
}
int wp_encode_application_apdu(uint8_t * apdu,
uint8_t invoke_id,
BACNET_WRITE_PROPERTY_DATA * data,
BACNET_APPLICATION_DATA_VALUE * value)
{
data->value_len = bacapp_encode_application_data(
&data->value[0], value);
return wp_encode_apdu(apdu, invoke_id, data);
}
/* decode the service request only */
/* FIXME: there could be various error messages returned
using unique values less than zero */
int wp_decode_service_request(uint8_t * apdu,
unsigned apdu_len, BACNET_WRITE_PROPERTY_DATA * data,
BACNET_APPLICATION_DATA_VALUE * value)
unsigned apdu_len, BACNET_WRITE_PROPERTY_DATA * data)
{
int len = 0;
int tag_len = 0;
@@ -143,11 +130,11 @@ int wp_decode_service_request(uint8_t * apdu,
if (decode_is_context_specific(&apdu[len]))
return -2;
len += bacapp_decode_application_data(&apdu[len],
apdu_len - len, &value);
apdu_len - len, &data->value);
/* FIXME: check the return value; abort if no valid data? */
/* FIXME: there might be more than one data element in here! */
if (!decode_is_closing_tag_number(&apdu[len], 3))
return -1;
return -4;
/* a tag number of 3 is not extended so only one octet */
len++;
/* Tag 4: optional Priority - assumed MAX if not explicitly set */
@@ -164,7 +151,7 @@ int wp_decode_service_request(uint8_t * apdu,
&& (unsigned_value <= BACNET_MAX_PRIORITY)) {
data->priority = (uint8_t) unsigned_value;
} else
return -1;
return -5;
}
}
}
+3 -11
View File
@@ -47,8 +47,7 @@ typedef struct BACnet_Write_Property_Data {
uint32_t object_instance;
BACNET_PROPERTY_ID object_property;
int32_t array_index; /* use BACNET_ARRAY_ALL when not setting */
uint8_t value[MAX_APDU];
uint16_t value_len;
BACNET_APPLICATION_DATA_VALUE value;
uint8_t priority; /* use BACNET_NO_PRIORITY if no priority */
} BACNET_WRITE_PROPERTY_DATA;
@@ -60,23 +59,16 @@ extern "C" {
int wp_encode_apdu(uint8_t * apdu,
uint8_t invoke_id, BACNET_WRITE_PROPERTY_DATA * data);
int wp_encode_application_apdu(uint8_t * apdu,
uint8_t invoke_id,
BACNET_WRITE_PROPERTY_DATA * data,
BACNET_APPLICATION_DATA_VALUE * value);
/* decode the service request only */
int wp_decode_service_request(uint8_t * apdu,
unsigned apdu_len, BACNET_WRITE_PROPERTY_DATA * data);
#ifdef TEST
#include "ctest.h"
int wp_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
uint8_t * invoke_id, BACNET_WRITE_PROPERTY_DATA * data);
#ifdef TEST
#include "ctest.h"
void test_ReadProperty(Test * pTest);
void test_ReadPropertyAck(Test * pTest);
#endif