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
+4 -1
View File
@@ -40,6 +40,7 @@
#include "bacnet/basic/binding/address.h"
#include "bacnet/bacdef.h"
#include "bacnet/bacapp.h"
#include "bacnet/bacint.h"
#include "bacnet/bacdcode.h"
#include "bacnet/npdu.h"
#include "bacnet/apdu.h"
@@ -599,7 +600,9 @@ bool Network_Port_MAC_Address(
case PORT_TYPE_BIP:
memcpy(
&ip_mac[0], &Object_List[index].Network.IPv4.IP_Address, 4);
memcpy(&ip_mac[4], &Object_List[index].Network.IPv4.Port, 2);
/* convert port from host-byte-order to network-byte-order */
encode_unsigned16(&ip_mac[4],
&Object_List[index].Network.IPv4.Port);
mac = &ip_mac[0];
mac_len = sizeof(ip_mac);
break;
+33 -8
View File
@@ -39,6 +39,9 @@
#include "bacnet/rp.h"
/* basic objects, services, TSM, and datalink */
#include "bacnet/basic/object/device.h"
#if (BACNET_PROTOCOL_REVISION >= 17)
#include "bacnet/basic/object/netport.h"
#endif
#include "bacnet/basic/tsm/tsm.h"
#include "bacnet/basic/services.h"
#include "bacnet/datalink/datalink.h"
@@ -112,16 +115,37 @@ void handler_read_property(uint8_t *service_request,
fprintf(stderr, "RP: Bad Encoding.\n");
#endif
} else {
/* Test for case of indefinite Device object instance */
/* When the object-type in the Object Identifier parameter
contains the value DEVICE and the instance in the 'Object
Identifier' parameter contains the value 4194303, the responding
BACnet-user shall treat the Object Identifier as if it correctly
matched the local Device object. This allows the device instance
of a device that does not generate I-Am messages to be
determined. */
if ((rpdata.object_type == OBJECT_DEVICE) &&
(rpdata.object_instance == BACNET_MAX_INSTANCE)) {
rpdata.object_instance = Device_Object_Instance_Number();
}
#if (BACNET_PROTOCOL_REVISION >= 17)
/* When the object-type in the Object Identifier parameter
contains the value NETWORK_PORT and the instance in the 'Object
Identifier' parameter contains the value 4194303, the responding
BACnet-user shall treat the Object Identifier as if it correctly
matched the local Network Port object representing the network
port through which the request was received. This allows the
network port instance of the network port that was used to
receive the request to be determined. */
if ((rpdata.object_type == OBJECT_NETWORK_PORT) &&
(rpdata.object_instance == BACNET_MAX_INSTANCE)) {
rpdata.object_instance = Network_Port_Index_To_Instance(0);
}
#endif
apdu_len = rp_ack_encode_apdu_init(
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id, &rpdata);
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
&rpdata);
/* configure our storage */
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len + apdu_len];
rpdata.application_data =
&Handler_Transmit_Buffer[npdu_len + apdu_len];
rpdata.application_data_len =
sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len);
len = Device_Read_Property(&rpdata);
@@ -131,10 +155,11 @@ void handler_read_property(uint8_t *service_request,
&Handler_Transmit_Buffer[npdu_len + apdu_len]);
apdu_len += len;
if (apdu_len > service_data->max_resp) {
/* too big for the sender - send an abort
* Setting of error code needed here as read property processing may
* have overriden the default set at start */
rpdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
/* too big for the sender - send an abort!
Setting of error code needed here as read property
processing may have overriden the default set at start */
rpdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
len = BACNET_STATUS_ABORT;
#if PRINT_ENABLED
fprintf(stderr, "RP: Message too large.\n");
+18
View File
@@ -41,6 +41,9 @@
#include "bacnet/rpm.h"
/* basic objects, services, TSM, and datalink */
#include "bacnet/basic/object/device.h"
#if (BACNET_PROTOCOL_REVISION >= 17)
#include "bacnet/basic/object/netport.h"
#endif
#include "bacnet/basic/tsm/tsm.h"
#include "bacnet/basic/services.h"
#include "bacnet/datalink/datalink.h"
@@ -239,6 +242,21 @@ void handler_read_property_multiple(uint8_t *service_request,
(rpmdata.object_instance == BACNET_MAX_INSTANCE)) {
rpmdata.object_instance = Device_Object_Instance_Number();
}
#if (BACNET_PROTOCOL_REVISION >= 17)
/* When the object-type in the Object Identifier parameter
contains the value NETWORK_PORT and the instance in the
'Object Identifier' parameter contains the value 4194303,
the responding BACnet-user shall treat the Object Identifier
as if it correctly matched the local Network Port object
representing the network port through which the request was
received. This allows the network port instance of the
network port that was used to receive the request to be
determined. */
if ((rpmdata.object_type == OBJECT_NETWORK_PORT) &&
(rpmdata.object_instance == BACNET_MAX_INSTANCE)) {
rpmdata.object_instance = Network_Port_Index_To_Instance(0);
}
#endif
/* Stick this object id into the reply - if it will fit */
len = rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], &rpmdata);