RP and RPM Network Port indefinite object instance (#146)

* RP and RPM Network Port indefinite object instance

Added ReadProperty and ReadPropertyMultiple handling for
Network Port object indefinite object instance 4194303.

* Add network port object to some examples

* Fix stm32f10x build

* Fix Endian order of network port IP UDP port

* Add network port object to BDK Makefile

* Add network port object header to BDK device.c

* fix BDK and AT91SAM7S port builds

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2021-01-07 10:21:11 -06:00
committed by GitHub
parent 63e4fa1f4b
commit 7cb63dcf06
31 changed files with 3205 additions and 136 deletions
-92
View File
@@ -746,95 +746,3 @@ void Network_Port_Init(void)
Object_List[0].Max_Info_Frames = dlmstp_max_info_frames();
Object_List[0].Link_Speed = rs485_baud_rate();
}
#ifdef BACNET_UNIT_TEST
#include <assert.h>
#include <string.h>
#include "ctest.h"
bool WPValidateArgType(BACNET_APPLICATION_DATA_VALUE *pValue,
uint8_t ucExpectedTag,
BACNET_ERROR_CLASS *pErrorClass,
BACNET_ERROR_CODE *pErrorCode)
{
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
void test_network_port(Test *pTest)
{
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata;
/* for decode value data */
BACNET_APPLICATION_DATA_VALUE value;
const int *pRequired = NULL;
const int *pOptional = NULL;
const int *pProprietary = NULL;
unsigned count = 0;
unsigned index = 0;
Network_Port_init();
count = Network_Port_Count();
for (index = 0; index < count; index++) {
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_NETWORK_PORT;
rpdata.object_instance = Network_Port_Index_To_Instance(index);
Network_Port_Property_Lists(&pRequired, &pOptional, &pProprietary);
while ((*pRequired) != -1) {
rpdata.object_property = *pRequired;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Network_Port_Read_Property(&rpdata);
ct_test(pTest, len != 0);
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
ct_test(pTest, test_len >= 0);
if (test_len < 0) {
printf("<decode failed!>\n");
}
pRequired++;
}
while ((*pOptional) != -1) {
rpdata.object_property = *pOptional;
rpdata.array_index = BACNET_ARRAY_ALL;
len = Network_Port_Read_Property(&rpdata);
ct_test(pTest, len != 0);
test_len = bacapp_decode_application_data(rpdata.application_data,
(uint8_t)rpdata.application_data_len, &value);
ct_test(pTest, test_len >= 0);
if (test_len < 0) {
printf("<decode failed!>\n");
}
pOptional++;
}
}
return;
}
#ifdef TEST_NETWORK_PORT
int main(void)
{
Test *pTest;
bool rc;
pTest = ct_create("BACnet Network Port", NULL);
/* individual tests */
rc = ct_addTestFunction(pTest, test_network_port);
assert(rc);
ct_setStream(pTest, stdout);
ct_run(pTest);
(void)ct_report(pTest);
ct_destroy(pTest);
return 0;
}
#endif
#endif /* TEST */