Indented.
This commit is contained in:
@@ -426,8 +426,8 @@ static bool cov_subscribe(
|
||||
|
||||
switch (cov_data->monitoredObjectIdentifier.type) {
|
||||
case OBJECT_BINARY_INPUT:
|
||||
if (Binary_Input_Valid_Instance(
|
||||
cov_data->monitoredObjectIdentifier.instance)) {
|
||||
if (Binary_Input_Valid_Instance(cov_data->
|
||||
monitoredObjectIdentifier.instance)) {
|
||||
status =
|
||||
cov_list_subscribe(src, cov_data, error_class, error_code);
|
||||
} else {
|
||||
|
||||
@@ -244,8 +244,7 @@ int RPM_Encode_Property(
|
||||
rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0],
|
||||
error_class, error_code);
|
||||
len =
|
||||
memcopy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len,
|
||||
max_apdu);
|
||||
memcopy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len, max_apdu);
|
||||
if (!len) {
|
||||
return 0;
|
||||
}
|
||||
@@ -344,8 +343,8 @@ void handler_read_property_multiple(
|
||||
rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], object_type,
|
||||
object_instance);
|
||||
copy_len =
|
||||
memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
||||
apdu_len, len, sizeof(Handler_Transmit_Buffer));
|
||||
memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], apdu_len,
|
||||
len, sizeof(Handler_Transmit_Buffer));
|
||||
if (!copy_len) {
|
||||
apdu_len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
|
||||
@@ -45,11 +45,11 @@
|
||||
/* note: initial the linked list of read_access_data */
|
||||
static int rpm_ack_decode_service_request(
|
||||
uint8_t * apdu,
|
||||
int apdu_len, /* total length of the apdu */
|
||||
int apdu_len, /* total length of the apdu */
|
||||
BACNET_READ_ACCESS_DATA * read_access_data)
|
||||
{
|
||||
int decoded_len = 0; /* return value */
|
||||
int len = 0; /* number of bytes returned from decoding */
|
||||
int decoded_len = 0; /* return value */
|
||||
int len = 0; /* number of bytes returned from decoding */
|
||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||
@@ -60,9 +60,8 @@ static int rpm_ack_decode_service_request(
|
||||
rpm_object = read_access_data;
|
||||
old_rpm_object = rpm_object;
|
||||
while (rpm_object && apdu_len) {
|
||||
len = rpm_ack_decode_object_id(
|
||||
apdu, apdu_len,
|
||||
&rpm_object->object_type,
|
||||
len =
|
||||
rpm_ack_decode_object_id(apdu, apdu_len, &rpm_object->object_type,
|
||||
&rpm_object->object_instance);
|
||||
if (len <= 0) {
|
||||
old_rpm_object->next = NULL;
|
||||
@@ -76,9 +75,8 @@ static int rpm_ack_decode_service_request(
|
||||
rpm_object->listOfProperties = rpm_property;
|
||||
old_rpm_property = rpm_property;
|
||||
while (rpm_property && apdu_len) {
|
||||
len = rpm_ack_decode_object_property(
|
||||
apdu,
|
||||
apdu_len,
|
||||
len =
|
||||
rpm_ack_decode_object_property(apdu, apdu_len,
|
||||
&rpm_property->propertyIdentifier,
|
||||
&rpm_property->propertyArrayIndex);
|
||||
if (len <= 0) {
|
||||
@@ -94,15 +92,13 @@ static int rpm_ack_decode_service_request(
|
||||
apdu_len--;
|
||||
apdu++;
|
||||
/* note: if this is an array, there will be
|
||||
more than one element to decode */
|
||||
more than one element to decode */
|
||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
rpm_property->value = value;
|
||||
old_value = value;
|
||||
while (value && (apdu_len > 0)) {
|
||||
len = bacapp_decode_application_data(
|
||||
apdu,
|
||||
apdu_len,
|
||||
value);
|
||||
len =
|
||||
bacapp_decode_application_data(apdu, apdu_len, value);
|
||||
decoded_len += len;
|
||||
apdu_len -= len;
|
||||
apdu += len;
|
||||
@@ -113,7 +109,8 @@ static int rpm_ack_decode_service_request(
|
||||
break;
|
||||
} else {
|
||||
old_value = value;
|
||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
value =
|
||||
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
old_value->next = value;
|
||||
}
|
||||
}
|
||||
@@ -174,8 +171,7 @@ static void PrintReadPropertyMultipleData(
|
||||
}
|
||||
#endif
|
||||
while (value) {
|
||||
bacapp_print_value(stdout,
|
||||
value,
|
||||
bacapp_print_value(stdout, value,
|
||||
listOfProperties->propertyIdentifier);
|
||||
#if PRINT_ENABLED
|
||||
if (value->next) {
|
||||
@@ -205,19 +201,20 @@ void handler_read_property_multiple_ack(
|
||||
BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
|
||||
{
|
||||
int len = 0;
|
||||
BACNET_READ_ACCESS_DATA * rpm_data;
|
||||
BACNET_READ_ACCESS_DATA * old_rpm_data;
|
||||
BACNET_READ_ACCESS_DATA *rpm_data;
|
||||
BACNET_READ_ACCESS_DATA *old_rpm_data;
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
||||
BACNET_APPLICATION_DATA_VALUE *value;
|
||||
BACNET_APPLICATION_DATA_VALUE *old_value;
|
||||
|
||||
(void) src;
|
||||
(void) service_data; /* we could use these... */
|
||||
(void) service_data; /* we could use these... */
|
||||
|
||||
rpm_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
||||
if (rpm_data) {
|
||||
len = rpm_ack_decode_service_request(service_request, service_len,
|
||||
len =
|
||||
rpm_ack_decode_service_request(service_request, service_len,
|
||||
rpm_data);
|
||||
}
|
||||
#if 1
|
||||
|
||||
@@ -1,85 +1,81 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "config.h"
|
||||
#include "txbuf.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "apdu.h"
|
||||
#include "npdu.h"
|
||||
#include "abort.h"
|
||||
/* special for this module */
|
||||
#include "cov.h"
|
||||
#include "bactext.h"
|
||||
|
||||
/* note: nothing is specified in BACnet about what to do with the
|
||||
information received from Unconfirmed COV Notifications. */
|
||||
void handler_ucov_notification(
|
||||
uint8_t * service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS * src)
|
||||
{
|
||||
BACNET_COV_DATA cov_data;
|
||||
BACNET_PROPERTY_VALUE property_value;
|
||||
int len = 0;
|
||||
|
||||
/* create linked list to store data if more
|
||||
than one property value is expected */
|
||||
property_value.next = NULL;
|
||||
cov_data.listOfValues = &property_value;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "UCOV: Received Notification!\n");
|
||||
#endif
|
||||
/* decode the service request only */
|
||||
len = cov_notify_decode_service_request(
|
||||
service_request, service_len, &cov_data);
|
||||
#if PRINT_ENABLED
|
||||
if (len > 0) {
|
||||
fprintf(stderr, "UCOV: PID=%u ",
|
||||
cov_data.subscriberProcessIdentifier);
|
||||
fprintf(stderr, "instance=%u ",
|
||||
cov_data.initiatingDeviceIdentifier);
|
||||
fprintf(stderr, "%s %u ",
|
||||
bactext_object_type_name(
|
||||
cov_data.monitoredObjectIdentifier.type),
|
||||
cov_data.monitoredObjectIdentifier.instance);
|
||||
fprintf(stderr, "time remaining=%u seconds ",
|
||||
cov_data.timeRemaining);
|
||||
fprintf(stderr, "%s ",
|
||||
bactext_property_name(property_value.propertyIdentifier));
|
||||
if (property_value.propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
fprintf(stderr, "%u ",
|
||||
property_value.propertyArrayIndex);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
} else {
|
||||
fprintf(stderr, "UCOV: Unable to decode service request!\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "config.h"
|
||||
#include "txbuf.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "apdu.h"
|
||||
#include "npdu.h"
|
||||
#include "abort.h"
|
||||
/* special for this module */
|
||||
#include "cov.h"
|
||||
#include "bactext.h"
|
||||
|
||||
/* note: nothing is specified in BACnet about what to do with the
|
||||
information received from Unconfirmed COV Notifications. */
|
||||
void handler_ucov_notification(
|
||||
uint8_t * service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS * src)
|
||||
{
|
||||
BACNET_COV_DATA cov_data;
|
||||
BACNET_PROPERTY_VALUE property_value;
|
||||
int len = 0;
|
||||
|
||||
/* create linked list to store data if more
|
||||
than one property value is expected */
|
||||
property_value.next = NULL;
|
||||
cov_data.listOfValues = &property_value;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "UCOV: Received Notification!\n");
|
||||
#endif
|
||||
/* decode the service request only */
|
||||
len =
|
||||
cov_notify_decode_service_request(service_request, service_len,
|
||||
&cov_data);
|
||||
#if PRINT_ENABLED
|
||||
if (len > 0) {
|
||||
fprintf(stderr, "UCOV: PID=%u ", cov_data.subscriberProcessIdentifier);
|
||||
fprintf(stderr, "instance=%u ", cov_data.initiatingDeviceIdentifier);
|
||||
fprintf(stderr, "%s %u ",
|
||||
bactext_object_type_name(cov_data.monitoredObjectIdentifier.type),
|
||||
cov_data.monitoredObjectIdentifier.instance);
|
||||
fprintf(stderr, "time remaining=%u seconds ", cov_data.timeRemaining);
|
||||
fprintf(stderr, "%s ",
|
||||
bactext_property_name(property_value.propertyIdentifier));
|
||||
if (property_value.propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
fprintf(stderr, "%u ", property_value.propertyArrayIndex);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
} else {
|
||||
fprintf(stderr, "UCOV: Unable to decode service request!\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,94 +1,93 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "address.h"
|
||||
#include "tsm.h"
|
||||
#include "dcc.h"
|
||||
#include "npdu.h"
|
||||
#include "apdu.h"
|
||||
#include "device.h"
|
||||
#include "datalink.h"
|
||||
#include "iam.h"
|
||||
/* some demo stuff needed */
|
||||
#include "handlers.h"
|
||||
|
||||
int iam_encode_pdu(
|
||||
uint8_t * buffer,
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data)
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
|
||||
/* I-Am is a global broadcast */
|
||||
datalink_get_broadcast_address(dest);
|
||||
/* encode the NPDU portion of the packet */
|
||||
npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data);
|
||||
/* encode the APDU portion of the packet */
|
||||
len =
|
||||
iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(),
|
||||
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
|
||||
pdu_len += len;
|
||||
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
void Send_I_Am(
|
||||
uint8_t * buffer)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest;
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
#if 0
|
||||
/* note: there is discussion in the BACnet committee
|
||||
that we should allow a device to reply with I-Am
|
||||
so that dynamic binding always work. If the DCC
|
||||
initiator loses the MAC address and routing info,
|
||||
they can never re-enable DCC because they can't
|
||||
find the device with WhoIs/I-Am */
|
||||
/* are we are forbidden to send? */
|
||||
if (!dcc_communication_enabled())
|
||||
return 0;
|
||||
#endif
|
||||
/* encode the data */
|
||||
pdu_len = iam_encode_pdu(buffer, &dest, &npdu_data);
|
||||
/* send data */
|
||||
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &buffer[0], pdu_len);
|
||||
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "address.h"
|
||||
#include "tsm.h"
|
||||
#include "dcc.h"
|
||||
#include "npdu.h"
|
||||
#include "apdu.h"
|
||||
#include "device.h"
|
||||
#include "datalink.h"
|
||||
#include "iam.h"
|
||||
/* some demo stuff needed */
|
||||
#include "handlers.h"
|
||||
|
||||
int iam_encode_pdu(
|
||||
uint8_t * buffer,
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data)
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
|
||||
/* I-Am is a global broadcast */
|
||||
datalink_get_broadcast_address(dest);
|
||||
/* encode the NPDU portion of the packet */
|
||||
npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data);
|
||||
/* encode the APDU portion of the packet */
|
||||
len =
|
||||
iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(),
|
||||
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
|
||||
pdu_len += len;
|
||||
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
void Send_I_Am(
|
||||
uint8_t * buffer)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest;
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
#if 0
|
||||
/* note: there is discussion in the BACnet committee
|
||||
that we should allow a device to reply with I-Am
|
||||
so that dynamic binding always work. If the DCC
|
||||
initiator loses the MAC address and routing info,
|
||||
they can never re-enable DCC because they can't
|
||||
find the device with WhoIs/I-Am */
|
||||
/* are we are forbidden to send? */
|
||||
if (!dcc_communication_enabled())
|
||||
return 0;
|
||||
#endif
|
||||
/* encode the data */
|
||||
pdu_len = iam_encode_pdu(buffer, &dest, &npdu_data);
|
||||
/* send data */
|
||||
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &buffer[0], pdu_len);
|
||||
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -69,8 +69,7 @@ void Send_Who_Is_Router_To_Network(
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK,
|
||||
false,
|
||||
NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, false,
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
/* fixme: should dnet/dlen/dadr be set in NPDU? */
|
||||
pdu_len =
|
||||
@@ -112,8 +111,7 @@ void Send_I_Am_Router_To_Network(
|
||||
unsigned index = 0;
|
||||
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK,
|
||||
false,
|
||||
NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK, false,
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||
@@ -157,9 +155,7 @@ void Send_Initialize_Routing_Table(
|
||||
BACNET_ROUTER_PORT *router_port;
|
||||
unsigned i = 0; /* counter */
|
||||
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_INIT_RT_TABLE,
|
||||
true,
|
||||
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_INIT_RT_TABLE, true,
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||
@@ -208,10 +204,8 @@ void Send_Initialize_Routing_Table_Ack(
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK,
|
||||
false,
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_INIT_RT_TABLE_ACK,
|
||||
false, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||
/* encode the optional DNET list portion of the packet */
|
||||
|
||||
@@ -48,7 +48,7 @@ uint8_t Send_Read_Property_Multiple_Request(
|
||||
uint8_t * pdu,
|
||||
size_t max_pdu,
|
||||
uint32_t device_id, /* destination device */
|
||||
BACNET_READ_ACCESS_DATA *read_access_data)
|
||||
BACNET_READ_ACCESS_DATA * read_access_data)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS my_address;
|
||||
@@ -72,14 +72,10 @@ uint8_t Send_Read_Property_Multiple_Request(
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&pdu[0], &dest, &my_address,
|
||||
&npdu_data);
|
||||
pdu_len = npdu_encode_pdu(&pdu[0], &dest, &my_address, &npdu_data);
|
||||
/* encode the APDU portion of the packet */
|
||||
len = rpm_encode_apdu(
|
||||
&pdu[pdu_len],
|
||||
max_pdu - pdu_len,
|
||||
invoke_id,
|
||||
len =
|
||||
rpm_encode_apdu(&pdu[pdu_len], max_pdu - pdu_len, invoke_id,
|
||||
read_access_data);
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
@@ -94,8 +90,7 @@ uint8_t Send_Read_Property_Multiple_Request(
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||
&npdu_data, &pdu[0], (uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&pdu[0], pdu_len);
|
||||
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -86,9 +86,9 @@ static void MyRejectHandler(
|
||||
}
|
||||
|
||||
static void My_Router_Handler(
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t * npdu, /* PDU data */
|
||||
BACNET_ADDRESS * src,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * npdu, /* PDU data */
|
||||
uint16_t npdu_len)
|
||||
{
|
||||
uint16_t npdu_offset = 0;
|
||||
@@ -122,26 +122,26 @@ static void My_Router_Handler(
|
||||
}
|
||||
}
|
||||
port_mappings = npdu[0];
|
||||
printf("\nPort Mappings: %u\n",port_mappings);
|
||||
printf("\nPort Mappings: %u\n", port_mappings);
|
||||
npdu_offset = 1;
|
||||
npdu_len--;
|
||||
while (npdu_len) {
|
||||
len = decode_unsigned16(&npdu[npdu_offset], &dnet);
|
||||
printf("DNET=%hu, ",dnet);
|
||||
printf("DNET=%hu, ", dnet);
|
||||
npdu_offset += len;
|
||||
npdu_len -= len;
|
||||
if (!npdu_len) {
|
||||
break;
|
||||
}
|
||||
port_id = npdu[npdu_offset];
|
||||
printf("Port ID=%u, ",port_id);
|
||||
printf("Port ID=%u, ", port_id);
|
||||
npdu_offset++;
|
||||
npdu_len--;
|
||||
if (!npdu_len) {
|
||||
break;
|
||||
}
|
||||
port_info_len = npdu[npdu_offset];
|
||||
printf("Port Info Length=%u, ",port_info_len);
|
||||
printf("Port Info Length=%u, ", port_info_len);
|
||||
npdu_offset++;
|
||||
npdu_len--;
|
||||
printf("Port Info=\"");
|
||||
@@ -150,7 +150,7 @@ static void My_Router_Handler(
|
||||
break;
|
||||
}
|
||||
if (j < port_info_len) {
|
||||
printf("%02X",npdu[npdu_offset]);
|
||||
printf("%02X", npdu[npdu_offset]);
|
||||
npdu_offset++;
|
||||
npdu_len--;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ static void My_NPDU_Handler(
|
||||
|
||||
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
||||
if (npdu_data.network_layer_message) {
|
||||
My_Router_Handler(src,&npdu_data,&pdu[apdu_offset],
|
||||
My_Router_Handler(src, &npdu_data, &pdu[apdu_offset],
|
||||
(uint16_t) (pdu_len - apdu_offset));
|
||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
||||
@@ -325,7 +325,8 @@ static void address_parse(BACNET_ADDRESS * dst,
|
||||
dst->mac_len = 6;
|
||||
for (index = 0; index < 4; index++) {
|
||||
dst->mac[index] = mac[index];
|
||||
} encode_unsigned16(&dst->mac[4],
|
||||
}
|
||||
encode_unsigned16(&dst->mac[4],
|
||||
port);
|
||||
} else {
|
||||
count =
|
||||
@@ -364,22 +365,14 @@ int main(int argc, char *argv[]) {
|
||||
filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
}
|
||||
if ((
|
||||
argc > 1) && (
|
||||
strcmp(argv[1],
|
||||
"--help") == 0)) {
|
||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||
printf("Send BACnet Initialize-Routing-Table message to a network\r\n"
|
||||
"and wait for responses. Displays their network information.\r\n"
|
||||
"\r\n"
|
||||
"address:\r\n"
|
||||
"\r\n" "address:\r\n"
|
||||
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\r\n"
|
||||
"DNET ID Len Info:\r\n"
|
||||
"Port-info data:\r\n"
|
||||
" DNET:\r\n"
|
||||
" Destination network number 0-65534\r\n"
|
||||
" ID:\r\n"
|
||||
" Port Identifier number 0-255\r\n"
|
||||
" Info:\r\n"
|
||||
"DNET ID Len Info:\r\n" "Port-info data:\r\n" " DNET:\r\n"
|
||||
" Destination network number 0-65534\r\n" " ID:\r\n"
|
||||
" Port Identifier number 0-255\r\n" " Info:\r\n"
|
||||
" Octet string of data, up to 255 octets\r\n"
|
||||
"To query the complete routing table, do not include any port-info.\r\n"
|
||||
"To query using Initialize-Routing-Table message to 192.168.0.18:\r\n"
|
||||
|
||||
@@ -139,7 +139,7 @@ static void milliseconds_task_win32(
|
||||
|
||||
/* functions used by the MS/TP state machine to put or get data */
|
||||
uint16_t MSTP_Put_Receive(
|
||||
volatile struct mstp_port_struct_t * mstp_port)
|
||||
volatile struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
(void) mstp_port;
|
||||
|
||||
@@ -217,7 +217,7 @@ static void write_received_packet(
|
||||
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
||||
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
||||
if (mstp_port->DataLength) {
|
||||
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
||||
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
||||
incl_len = orig_len = 8 + max_data + 2;
|
||||
} else {
|
||||
incl_len = orig_len = 8;
|
||||
|
||||
@@ -308,12 +308,12 @@ int Binary_Output_Encode_Property_APDU(
|
||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||
break;
|
||||
case PROP_ACTIVE_TEXT:
|
||||
characterstring_init_ansi(&char_string,"on" );
|
||||
characterstring_init_ansi(&char_string, "on");
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_INACTIVE_TEXT:
|
||||
characterstring_init_ansi(&char_string,"off" );
|
||||
characterstring_init_ansi(&char_string, "off");
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
|
||||
@@ -216,23 +216,21 @@ static void Init_DataLink(
|
||||
#endif
|
||||
}
|
||||
|
||||
void cleanup(void)
|
||||
{
|
||||
void cleanup(void) {
|
||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
||||
|
||||
rpm_object = Read_Access_Data;
|
||||
old_rpm_object = rpm_object;
|
||||
while (rpm_object) {
|
||||
rpm_object = Read_Access_Data;
|
||||
old_rpm_object = rpm_object;
|
||||
while (rpm_object) {
|
||||
rpm_property = rpm_object->listOfProperties;
|
||||
while (rpm_property) {
|
||||
old_rpm_property = rpm_property;
|
||||
rpm_property = rpm_property->next;
|
||||
free(old_rpm_property);
|
||||
}
|
||||
old_rpm_object = rpm_object;
|
||||
} old_rpm_object = rpm_object;
|
||||
rpm_object = rpm_object->next;
|
||||
free(old_rpm_object);
|
||||
}
|
||||
@@ -251,14 +249,16 @@ int main(int argc, char *argv[]) {
|
||||
time_t timeout_seconds = 0;
|
||||
uint8_t invoke_id = 0;
|
||||
bool found = false;
|
||||
uint8_t buffer[MAX_PDU] = {0};
|
||||
uint8_t buffer[MAX_PDU] = {
|
||||
0};
|
||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||
|
||||
|
||||
if (argc < 5) {
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property index [object-type ...]\r\n", filename_remove_path(argv[0]));
|
||||
"property index [object-type ...]\r\n",
|
||||
filename_remove_path(argv[0]));
|
||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||
printf("device-instance:\r\n"
|
||||
"BACnet Device Object Instance number that you are\r\n"
|
||||
@@ -285,8 +285,7 @@ int main(int argc, char *argv[]) {
|
||||
"If the property is an array, individual elements can\r\n"
|
||||
"be read. If this parameter is missing and the property\r\n"
|
||||
"is an array, the entire array will be read.\r\n"
|
||||
"\r\nExample:\r\n"
|
||||
"If you want read the ALL property in\r\n"
|
||||
"\r\nExample:\r\n" "If you want read the ALL property in\r\n"
|
||||
"Device object 123, you would use the following command:\r\n"
|
||||
"%s 123 8 123 8 -1\r\n"
|
||||
"If you want read the OPTIONAL property in\r\n"
|
||||
@@ -294,10 +293,8 @@ int main(int argc, char *argv[]) {
|
||||
"%s 123 8 123 80 -1\r\n"
|
||||
"If you want read the REQUIRED property in\r\n"
|
||||
"Device object 123, you would use the following command:\r\n"
|
||||
"%s 123 8 123 105 -1\r\n",
|
||||
filename_remove_path(argv[0]),
|
||||
filename_remove_path(argv[0]),
|
||||
filename_remove_path(argv[0]));
|
||||
"%s 123 8 123 105 -1\r\n", filename_remove_path(argv[0]),
|
||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -315,8 +312,7 @@ int main(int argc, char *argv[]) {
|
||||
arg_sets = 0;
|
||||
while (rpm_object) {
|
||||
tag_value_arg = 2 + (arg_sets * 4);
|
||||
rpm_object->object_type =
|
||||
strtol(argv[tag_value_arg], NULL, 0);
|
||||
rpm_object->object_type = strtol(argv[tag_value_arg], NULL, 0);
|
||||
tag_value_arg++;
|
||||
args_remaining--;
|
||||
if (args_remaining <= 0) {
|
||||
@@ -328,8 +324,7 @@ int main(int argc, char *argv[]) {
|
||||
rpm_object->object_type, MAX_BACNET_OBJECT_TYPE + 1);
|
||||
return 1;
|
||||
}
|
||||
rpm_object->object_instance =
|
||||
strtol(argv[tag_value_arg], NULL, 0);
|
||||
rpm_object->object_instance = strtol(argv[tag_value_arg], NULL, 0);
|
||||
tag_value_arg++;
|
||||
args_remaining--;
|
||||
if (args_remaining <= 0) {
|
||||
@@ -350,12 +345,14 @@ int main(int argc, char *argv[]) {
|
||||
tag_value_arg++;
|
||||
args_remaining--;
|
||||
if (args_remaining <= 0) {
|
||||
fprintf(stderr, "Error: not enough object property quads.\r\n");
|
||||
fprintf(stderr,
|
||||
"Error: not enough object property quads.\r\n");
|
||||
return 1;
|
||||
}
|
||||
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
||||
fprintf(stderr, "property=%u - it must be less than %u\r\n",
|
||||
rpm_property->propertyIdentifier, MAX_BACNET_PROPERTY_ID + 1);
|
||||
rpm_property->propertyIdentifier,
|
||||
MAX_BACNET_PROPERTY_ID + 1);
|
||||
return 1;
|
||||
}
|
||||
rpm_property->propertyArrayIndex =
|
||||
@@ -413,10 +410,9 @@ int main(int argc, char *argv[]) {
|
||||
&Target_Address);
|
||||
if (found) {
|
||||
if (invoke_id == 0) {
|
||||
invoke_id = Send_Read_Property_Multiple_Request(
|
||||
&buffer[0],
|
||||
sizeof(buffer),
|
||||
Target_Device_Object_Instance,
|
||||
invoke_id =
|
||||
Send_Read_Property_Multiple_Request(&buffer[0],
|
||||
sizeof(buffer), Target_Device_Object_Instance,
|
||||
Read_Access_Data);
|
||||
} else if (tsm_invoke_id_free(invoke_id))
|
||||
break;
|
||||
|
||||
@@ -87,7 +87,7 @@ static void Init_Service_Handlers(
|
||||
handler_timesync);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_SUBSCRIBE_COV,
|
||||
handler_cov_subscribe);
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_COV_NOTIFICATION,
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_COV_NOTIFICATION,
|
||||
handler_ucov_notification);
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
|
||||
@@ -212,8 +212,8 @@ int main(int argc, char *argv[]) {
|
||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
}
|
||||
/* decode the command line parameters */
|
||||
cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||
/* decode the command line parameters */ cov_data.
|
||||
subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
||||
cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0);
|
||||
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
||||
|
||||
@@ -87,7 +87,7 @@ static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
/* Note: this applications doesn't need to handle who-is
|
||||
it is confusing for the user! */
|
||||
it is confusing for the user! */
|
||||
/* set the handler for all the services we don't implement
|
||||
It is required to send the proper reject message... */
|
||||
apdu_set_unrecognized_service_handler_handler
|
||||
|
||||
@@ -86,9 +86,9 @@ static void MyRejectHandler(
|
||||
}
|
||||
|
||||
static void My_Router_Handler(
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t * npdu, /* PDU data */
|
||||
BACNET_ADDRESS * src,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * npdu, /* PDU data */
|
||||
uint16_t npdu_len)
|
||||
{
|
||||
uint16_t npdu_offset = 0;
|
||||
@@ -109,7 +109,7 @@ static void My_Router_Handler(
|
||||
printf("\nNetworks: ");
|
||||
while (npdu_len) {
|
||||
len = decode_unsigned16(&npdu[npdu_offset], &dnet);
|
||||
printf("%hu",dnet);
|
||||
printf("%hu", dnet);
|
||||
npdu_len -= len;
|
||||
if (npdu_len) {
|
||||
printf(", ");
|
||||
@@ -141,7 +141,7 @@ void My_NPDU_Handler(
|
||||
|
||||
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
||||
if (npdu_data.network_layer_message) {
|
||||
My_Router_Handler(src,&npdu_data,&pdu[apdu_offset],
|
||||
My_Router_Handler(src, &npdu_data, &pdu[apdu_offset],
|
||||
(uint16_t) (pdu_len - apdu_offset));
|
||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
||||
|
||||
Reference in New Issue
Block a user