changed the modules to use the new BACNet string types.
Modified the device object to handle having the string properties changed via WriteProperty service. Updated the unit tests. Updated the demo objects.
This commit is contained in:
+17
-22
@@ -64,7 +64,7 @@ int awf_encode_apdu(
|
||||
apdu_len += encode_tagged_signed(&apdu[apdu_len],
|
||||
data->type.stream.fileStartPosition);
|
||||
apdu_len += encode_tagged_octet_string(&apdu[apdu_len],
|
||||
data->fileData, data->fileDataLength);
|
||||
&data->fileData);
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 0);
|
||||
break;
|
||||
case FILE_RECORD_ACCESS:
|
||||
@@ -74,7 +74,7 @@ int awf_encode_apdu(
|
||||
apdu_len += encode_tagged_unsigned(&apdu[apdu_len],
|
||||
data->type.record.returnedRecordCount);
|
||||
apdu_len += encode_tagged_octet_string(&apdu[apdu_len],
|
||||
data->fileData, data->fileDataLength);
|
||||
&data->fileData);
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 1);
|
||||
break;
|
||||
default:
|
||||
@@ -127,9 +127,7 @@ int awf_decode_service_request(
|
||||
return -1;
|
||||
len += decode_octet_string(&apdu[len],
|
||||
len_value_type,
|
||||
data->fileData,
|
||||
data->fileDataLength);
|
||||
data->fileDataLength = len_value_type;
|
||||
&data->fileData);
|
||||
if (!decode_is_closing_tag_number(&apdu[len], 0))
|
||||
return -1;
|
||||
// a tag number is not extended so only one octet
|
||||
@@ -166,9 +164,7 @@ int awf_decode_service_request(
|
||||
return -1;
|
||||
len += decode_octet_string(&apdu[len],
|
||||
len_value_type,
|
||||
data->fileData,
|
||||
data->fileDataLength);
|
||||
data->fileDataLength = len_value_type;
|
||||
&data->fileData);
|
||||
if (!decode_is_closing_tag_number(&apdu[len], 1))
|
||||
return -1;
|
||||
// a tag number is not extended so only one octet
|
||||
@@ -322,7 +318,6 @@ void testAtomicWriteFileAccess(Test * pTest,
|
||||
int apdu_len = 0;
|
||||
uint8_t invoke_id = 128;
|
||||
uint8_t test_invoke_id = 0;
|
||||
uint8_t test_octet_string[128] = "bingo!";
|
||||
|
||||
len = awf_encode_apdu(
|
||||
&apdu[0],
|
||||
@@ -331,8 +326,6 @@ void testAtomicWriteFileAccess(Test * pTest,
|
||||
ct_test(pTest, len != 0);
|
||||
apdu_len = len;
|
||||
|
||||
test_data.fileData = test_octet_string;
|
||||
test_data.fileDataLength = sizeof(test_octet_string);
|
||||
len = awf_decode_apdu(
|
||||
&apdu[0],
|
||||
apdu_len,
|
||||
@@ -354,25 +347,26 @@ void testAtomicWriteFileAccess(Test * pTest,
|
||||
ct_test(pTest, test_data.type.record.returnedRecordCount ==
|
||||
data->type.record.returnedRecordCount);
|
||||
}
|
||||
ct_test(pTest, test_data.fileDataLength ==
|
||||
data->fileDataLength);
|
||||
ct_test(pTest, octetstring_length(&test_data.fileData) ==
|
||||
octetstring_length(&data->fileData));
|
||||
ct_test(pTest, memcmp(
|
||||
&test_data.fileData[0],
|
||||
&data->fileData[0],
|
||||
test_data.fileDataLength) == 0);
|
||||
octetstring_value(&test_data.fileData),
|
||||
octetstring_value(&data->fileData),
|
||||
octetstring_length(&test_data.fileData)) == 0);
|
||||
}
|
||||
|
||||
void testAtomicWriteFile(Test * pTest)
|
||||
{
|
||||
BACNET_ATOMIC_WRITE_FILE_DATA data = {0};
|
||||
uint8_t *test_octet_string = "Joshua-Mary-Anna-Christopher";
|
||||
|
||||
uint8_t test_octet_string[32] = "Joshua-Mary-Anna-Christopher";
|
||||
|
||||
data.object_type = OBJECT_FILE;
|
||||
data.object_instance = 1;
|
||||
data.access = FILE_STREAM_ACCESS;
|
||||
data.type.stream.fileStartPosition = 0;
|
||||
data.fileData = test_octet_string;
|
||||
data.fileDataLength = strlen(test_octet_string);
|
||||
octetstring_init(&data.fileData,
|
||||
test_octet_string,
|
||||
sizeof(test_octet_string));
|
||||
testAtomicWriteFileAccess(pTest, &data);
|
||||
|
||||
data.object_type = OBJECT_FILE;
|
||||
@@ -380,8 +374,9 @@ void testAtomicWriteFile(Test * pTest)
|
||||
data.access = FILE_RECORD_ACCESS;
|
||||
data.type.record.fileStartRecord = 1;
|
||||
data.type.record.returnedRecordCount = 2;
|
||||
data.fileData = test_octet_string;
|
||||
data.fileDataLength = strlen(test_octet_string);
|
||||
octetstring_init(&data.fileData,
|
||||
test_octet_string,
|
||||
sizeof(test_octet_string));
|
||||
testAtomicWriteFileAccess(pTest, &data);
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user