Bugfix/code clean using gcc warnings (#371)
* Enable extra GCC warnings to discover subtle bugs * convert c++ comments to c comments * cleanup pedantic compiler warnings * Compile apps with GNU89 GNU99 GNU11 and GNU17 Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
+20
-5
@@ -94,16 +94,31 @@ BACNET_PORT_DIR = $(realpath ../ports/$(BACNET_PORT))
|
||||
BACNET_SRC_DIR = $(realpath ../src)
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 - "ANSI" C
|
||||
# gnu89 - c89 plus GCC extensions
|
||||
# c89 - "ANSI" C - ISO C90
|
||||
# gnu89 - c89 plus GNU extensions
|
||||
# c90 - "ANSI" C - ISO C90
|
||||
# gnu90 - C90 with GNU extensions
|
||||
# c99 - ISO C99 standard
|
||||
# gnu99 - c99 plus GCC extensions
|
||||
CSTANDARD = -std=gnu89
|
||||
# gnu99 - C99 plus GNU extensions
|
||||
# c11 - C11
|
||||
# gnu11 - C11 plus GNU extensions
|
||||
# c17 - C11 with corrections
|
||||
# note: default is compiled as ANSI C for widest compiler compatibilty
|
||||
# note: code that requires newer language features must use __STDC_VERSION__
|
||||
CSTANDARD ?= -std=gnu89
|
||||
|
||||
#build for release (default) or debug
|
||||
OPTIMIZATION ?= -Os
|
||||
DEBUGGING ?=
|
||||
WARNINGS ?= -Wall -Wmissing-prototypes -Wno-missing-braces
|
||||
WARNING_ALL := -Wall -Wextra -Wall -Wfloat-equal -Wconversion -Wparentheses
|
||||
WARNING_ALL += -pedantic -Wunused-parameter -Wunused-variable -Wreturn-type
|
||||
WARNING_ALL += -Wunused-function -Wreturn-type -Wunused-value
|
||||
WARNING_ALL += -Wswitch-default -Wuninitialized -Winit-self
|
||||
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
|
||||
WARNING_ALL += -Wno-long-long
|
||||
#WARNING_ALL += -Wredundant-decls
|
||||
#WARNING_ALL += -Werror
|
||||
WARNINGS ?= $(WARNING_ALL)
|
||||
# dead code removal
|
||||
ifeq (${BUILD},debug)
|
||||
OPTIMIZATION = -O0
|
||||
|
||||
+17
-17
@@ -101,33 +101,33 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet Abort message to the network.\n");
|
||||
printf(
|
||||
"--mac A\n"
|
||||
printf("--mac A\n"
|
||||
"Optional destination BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional destination BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("abort-reason:\n"
|
||||
" number from 0 to 65535\n"
|
||||
"invoke-id:\n"
|
||||
" number from 1 to 255\n"
|
||||
"server:\n"
|
||||
" 0=false, 1=true\n"
|
||||
"Example:\n"
|
||||
"%s 3 2 1\n",
|
||||
" number from 0 to 65535\n"
|
||||
"invoke-id:\n"
|
||||
" number from 1 to 255\n"
|
||||
"server:\n"
|
||||
" 0=false, 1=true\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"%s 3 2 1\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
|
||||
+40
-42
@@ -171,54 +171,52 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet AcknowledgedAlarm, message to a device.\n");
|
||||
printf(
|
||||
"device-id:\n"
|
||||
printf("device-id:\n"
|
||||
"BACnet Device Object Instance number that you are trying to\n"
|
||||
"communicate to. This number will be used to try and bind with\n"
|
||||
"the device using Who-Is and I-Am services. For example, if you were\n"
|
||||
"notifying Device Object 123, the device-instance would be 123.\n"
|
||||
"\n"
|
||||
"process-id:\n"
|
||||
"notifying Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf("process-id:\n"
|
||||
"Process Identifier in the receiving device for which the\n"
|
||||
"notification is intended.\n"
|
||||
"\n"
|
||||
"event-object-type:\n"
|
||||
"notification is intended.\n");
|
||||
printf("\n");
|
||||
printf("event-object-type:\n"
|
||||
"The object type is defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the integer value.\n"
|
||||
"\n"
|
||||
"event-object-instance:\n"
|
||||
"The object instance number of the event object.\n"
|
||||
"\n"
|
||||
"event-state-acked:\n"
|
||||
"The event-state that for this alarm acknowledge.\n"
|
||||
"\n"
|
||||
"event-time-stamp:\n"
|
||||
"The time-stamp of the event.\n"
|
||||
"\n"
|
||||
"ack-source-name\n"
|
||||
"The source name of the alarm acknowledge.\n"
|
||||
"\n"
|
||||
"ack-time-stamp\n"
|
||||
"The time-stamp of the alarm acknowledge.\n"
|
||||
"\n");
|
||||
"as defined in the BACnet specification, or as the integer value.\n");
|
||||
printf("\n");
|
||||
printf("event-object-instance:\n"
|
||||
"The object instance number of the event object.\n");
|
||||
printf("\n");
|
||||
printf("event-state-acked:\n"
|
||||
"The event-state that for this alarm acknowledge.\n");
|
||||
printf("\n");
|
||||
printf("event-time-stamp:\n"
|
||||
"The time-stamp of the event.\n");
|
||||
printf("\n");
|
||||
printf("ack-source-name\n"
|
||||
"The source name of the alarm acknowledge.\n");
|
||||
printf("\n");
|
||||
printf("ack-time-stamp\n"
|
||||
"The time-stamp of the alarm acknowledge.\n");
|
||||
printf("\n");
|
||||
printf("--mac A\n"
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
(void)filename;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
+11
-10
@@ -31,7 +31,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h> /* for time */
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
@@ -587,7 +587,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
if (object_type == OBJECT_DATETIME_VALUE) {
|
||||
break; /* A special case - no braces for this pair */
|
||||
}
|
||||
/* Else, fall through to normal processing. */
|
||||
BACNET_STACK_FALLTHROUGH();
|
||||
default:
|
||||
/* Normal array: open brace */
|
||||
fprintf(stdout, "{ ");
|
||||
@@ -747,7 +747,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
fprintf(stdout, "?");
|
||||
break;
|
||||
}
|
||||
/* Else, fall through for normal processing. */
|
||||
BACNET_STACK_FALLTHROUGH();
|
||||
case PROP_DAYLIGHT_SAVINGS_STATUS:
|
||||
case PROP_LOCAL_TIME:
|
||||
case PROP_LOCAL_DATE: /* Only if !ShowValues */
|
||||
@@ -760,7 +760,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
fprintf(stdout, "?");
|
||||
break;
|
||||
}
|
||||
/* Else, fall through and print value: */
|
||||
BACNET_STACK_FALLTHROUGH();
|
||||
default:
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
break;
|
||||
@@ -895,6 +895,8 @@ static uint8_t Read_Properties(
|
||||
case PROP_SUBORDINATE_LIST:
|
||||
IsLongArray = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
invoke_id = Send_Read_Property_Request(device_instance, pMyObject->type,
|
||||
@@ -1016,6 +1018,7 @@ static void print_usage(char *filename)
|
||||
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
(void)filename;
|
||||
printf("Generates Full EPICS file, including Object and Property List\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
@@ -1120,10 +1123,9 @@ static int CheckCommandLineArgs(int argc, char *argv[])
|
||||
} else {
|
||||
printf("ERROR: invalid Target MAC %s \n", argv[i]);
|
||||
}
|
||||
/* And fall through to print_usage */
|
||||
/* fall through to print_usage */
|
||||
}
|
||||
/* Either break or fall through, as above */
|
||||
/* break; */
|
||||
BACNET_STACK_FALLTHROUGH();
|
||||
default:
|
||||
print_usage(filename);
|
||||
exit(0);
|
||||
@@ -1462,7 +1464,7 @@ int main(int argc, char *argv[])
|
||||
address_init();
|
||||
Init_Service_Handlers();
|
||||
dlenv_init();
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
/* Internationalized programs must call setlocale()
|
||||
* to initiate a specific language operation.
|
||||
* This can be done by calling setlocale() as follows.
|
||||
@@ -1581,8 +1583,7 @@ int main(int argc, char *argv[])
|
||||
Print_Device_Heading();
|
||||
}
|
||||
myState = GET_ALL_REQUEST;
|
||||
/* Fall through now */
|
||||
|
||||
BACNET_STACK_FALLTHROUGH();
|
||||
case GET_ALL_REQUEST:
|
||||
case GET_LIST_OF_ALL_REQUEST:
|
||||
/* "list" differs in ArrayIndex only */
|
||||
|
||||
+10
-12
@@ -104,25 +104,23 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet Error message to the network.\n");
|
||||
printf(
|
||||
"--mac A\n"
|
||||
printf("--mac A\n"
|
||||
"Optional destination BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional destination BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("error-class:\n"
|
||||
" number from 0 to 65535\n"
|
||||
"error-code:\n"
|
||||
|
||||
+59
-60
@@ -175,72 +175,71 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet ConfirmedEventNotification message to a device.\n");
|
||||
printf(
|
||||
"device-id:\n"
|
||||
printf("device-id:\n"
|
||||
"BACnet Device Object Instance number that you are trying to\n"
|
||||
"communicate to. This number will be used to try and bind with\n"
|
||||
"the device using Who-Is and I-Am services. For example, if you were\n"
|
||||
"notifying Device Object 123, the device-instance would be 123.\n"
|
||||
"\n"
|
||||
"process-id:\n"
|
||||
"notifying Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf("process-id:\n"
|
||||
"Process Identifier in the receiving device for which the\n"
|
||||
"notification is intended.\n"
|
||||
"\n"
|
||||
"initiating-device-id: the BACnet Device Object Instance number\n"
|
||||
"that initiated the ConfirmedEventNotification service request.\n"
|
||||
"\n"
|
||||
"event-object-type:\n"
|
||||
"notification is intended.\n");
|
||||
printf("\n");
|
||||
printf("initiating-device-id: the BACnet Device Object Instance number\n"
|
||||
"that initiated the ConfirmedEventNotification service request.\n");
|
||||
printf("\n");
|
||||
printf("event-object-type:\n"
|
||||
"The object type is defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the integer value.\n"
|
||||
"\n"
|
||||
"event-object-instance:\n"
|
||||
"The object instance number of the event object.\n"
|
||||
"\n"
|
||||
"sequence-number:\n"
|
||||
"The sequence number of the event.\n"
|
||||
"\n"
|
||||
"notification-class:\n"
|
||||
"The notification-class of the event.\n"
|
||||
"\n"
|
||||
"priority:\n"
|
||||
"The priority of the event.\n"
|
||||
"\n"
|
||||
"message-text:\n"
|
||||
"The message text of the event.\n"
|
||||
"\n"
|
||||
"notify-type:\n"
|
||||
"The notify type of the event.\n"
|
||||
"\n"
|
||||
"ack-required:\n"
|
||||
"The ack-required of the event (0=FALSE,1=TRUE).\n"
|
||||
"\n"
|
||||
"from-state:\n"
|
||||
"The from-state of the event.\n"
|
||||
"\n"
|
||||
"to-state:\n"
|
||||
"The to-state of the event.\n"
|
||||
"\n"
|
||||
"event-type\n"
|
||||
"The event-type of the event.\n"
|
||||
"\n");
|
||||
"as defined in the BACnet specification, or as the integer value.\n");
|
||||
printf("\n");
|
||||
printf("event-object-instance:\n"
|
||||
"The object instance number of the event object.\n");
|
||||
printf("\n");
|
||||
printf("sequence-number:\n"
|
||||
"The sequence number of the event.\n");
|
||||
printf("\n");
|
||||
printf("notification-class:\n"
|
||||
"The notification-class of the event.\n");
|
||||
printf("\n");
|
||||
printf("priority:\n"
|
||||
"The priority of the event.\n");
|
||||
printf("\n");
|
||||
printf("message-text:\n"
|
||||
"The message text of the event.\n");
|
||||
printf("\n");
|
||||
printf("notify-type:\n"
|
||||
"The notify type of the event.\n");
|
||||
printf("\n");
|
||||
printf("ack-required:\n"
|
||||
"The ack-required of the event (0=FALSE,1=TRUE).\n");
|
||||
printf("\n");
|
||||
printf("from-state:\n"
|
||||
"The from-state of the event.\n");
|
||||
printf("\n");
|
||||
printf("to-state:\n"
|
||||
"The to-state of the event.\n");
|
||||
printf("\n");
|
||||
printf("event-type\n"
|
||||
"The event-type of the event.\n");
|
||||
printf("\n");
|
||||
printf("--mac A\n"
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
(void)filename;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -125,6 +125,8 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
|
||||
int len = 0;
|
||||
int i;
|
||||
BACNET_GET_EVENT_INFORMATION_DATA data[MAX_OBJ_IDS_IN_GE_ACK];
|
||||
|
||||
(void)src;
|
||||
for (i = 0; i < MAX_OBJ_IDS_IN_GE_ACK - 1; i++) {
|
||||
data[i].next = &data[i + 1];
|
||||
}
|
||||
@@ -197,10 +199,10 @@ int main(int argc, char *argv[])
|
||||
time_t last_seconds = 0;
|
||||
time_t current_seconds = 0;
|
||||
time_t timeout_seconds = 0;
|
||||
bool found = false;
|
||||
|
||||
LastReceivedObjectIdentifier.instance = 0;
|
||||
LastReceivedObjectIdentifier.type = 0;
|
||||
|
||||
bool found = false;
|
||||
if (argc <= 1) {
|
||||
printf("Usage: %s device-instance\r\n", filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
|
||||
+42
-41
@@ -108,44 +108,48 @@ static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet I-Am message for a device.\n");
|
||||
printf("--mac A\n"
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"--repeat\n"
|
||||
"Send the message repeatedly until signalled to quit.\n"
|
||||
"Default is to not repeat, sending only a single message.\n"
|
||||
"\n"
|
||||
"--retry C\n"
|
||||
"Send the message C number of times\n"
|
||||
"Default is retry 0, only sending one time.\n"
|
||||
"\n"
|
||||
"--delay\n"
|
||||
"Delay, in milliseconds, between repeated messages.\n"
|
||||
"Default delay is 100ms.\n"
|
||||
"\n");
|
||||
printf(
|
||||
"device-instance:\n"
|
||||
" BACnet device-ID 0..4194303\n"
|
||||
"vendor-id:\n"
|
||||
" Vendor Identifier 0..65535\n"
|
||||
"max-apdu:\n"
|
||||
" Maximum APDU size 50..65535\n"
|
||||
"segmentation:\n"
|
||||
" BACnet Segmentation 0=both, 1=transmit, 2=receive, 3=none\n"
|
||||
"To send an I-Am message for instance=1234 vendor-id=260 max-apdu=480\n"
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--repeat\n"
|
||||
"Send the message repeatedly until signalled to quit.\n"
|
||||
"Default is to not repeat, sending only a single message.\n");
|
||||
printf("\n");
|
||||
printf("--retry C\n"
|
||||
"Send the message C number of times\n"
|
||||
"Default is retry 0, only sending one time.\n");
|
||||
printf("\n");
|
||||
printf("--delay\n"
|
||||
"Delay, in milliseconds, between repeated messages.\n"
|
||||
"Default delay is 100ms.\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet device-ID 0..4194303\n");
|
||||
printf("\n");
|
||||
printf("vendor-id:\n"
|
||||
"Vendor Identifier 0..65535\n");
|
||||
printf("\n");
|
||||
printf("max-apdu:\n"
|
||||
"Maximum APDU size 50..65535\n");
|
||||
printf("\n");
|
||||
printf("segmentation:\n"
|
||||
"BACnet Segmentation 0=both, 1=transmit, 2=receive, 3=none\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"To send an I-Am message of instance=1234 vendor-id=260 max-apdu=480\n"
|
||||
"%s 1234 260 480\n",
|
||||
filename);
|
||||
}
|
||||
@@ -213,9 +217,6 @@ int main(int argc, char *argv[])
|
||||
} else if (strcmp(argv[argi], "--delay") == 0) {
|
||||
if (++argi < argc) {
|
||||
timeout = strtol(argv[argi], NULL, 0);
|
||||
if (timeout < 0) {
|
||||
timeout = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (target_args == 0) {
|
||||
|
||||
@@ -241,9 +241,9 @@ static void print_help(char *filename)
|
||||
{
|
||||
printf(
|
||||
"Send BACnet Initialize-Routing-Table message to a network\n"
|
||||
"and wait for responses. Displays their network information.\n"
|
||||
"\n"
|
||||
"address:\n"
|
||||
"and wait for responses. Displays their network information.\n");
|
||||
printf("\n");
|
||||
printf("address:\n"
|
||||
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\n"
|
||||
"DNET ID Len Info:\n"
|
||||
"Port-info data:\n"
|
||||
|
||||
+5
-3
@@ -401,11 +401,13 @@ static void packet_statistics_clear(void)
|
||||
|
||||
static uint32_t Timer_Silence(void *pArg)
|
||||
{
|
||||
(void)pArg;
|
||||
return mstimer_elapsed(&Silence_Timer);
|
||||
}
|
||||
|
||||
static void Timer_Silence_Reset(void *pArg)
|
||||
{
|
||||
(void)pArg;
|
||||
mstimer_set(&Silence_Timer, 0);
|
||||
}
|
||||
|
||||
@@ -924,9 +926,9 @@ static void print_help(char *filename)
|
||||
printf("Captures MS/TP packets from a serial interface\n"
|
||||
"and saves them to a file. Saves packets in a\n"
|
||||
"filename mstp_20090123091200.cap that has data and time.\n"
|
||||
"After receiving 65535 packets, a new file is created.\n"
|
||||
"\n"
|
||||
"Command line options:\n"
|
||||
"After receiving 65535 packets, a new file is created.\n");
|
||||
printf("\n");
|
||||
printf("Command line options:\n"
|
||||
"[--extcap-interface port] - serial interface.\n"
|
||||
#if defined(_WIN32)
|
||||
" Supported values: COM1, COM2, etc.\n"
|
||||
|
||||
+12
-11
@@ -229,22 +229,23 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf(
|
||||
"Read a file from a BACnet device and save it locally.\n"
|
||||
"device-instance:\n"
|
||||
"Read a file from a BACnet device and save it locally.\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are trying to\n"
|
||||
"communicate to. This number will be used to try and bind with\n"
|
||||
"the device using Who-Is and I-Am services. For example, if you were\n"
|
||||
"reading from Device Object 123, the device-instance would be 123.\n"
|
||||
"\n"
|
||||
"file-instance:\n"
|
||||
"reading from Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf("file-instance:\n"
|
||||
"This is the file object instance number that you are reading from.\n"
|
||||
"For example, if you were reading from File 2, \n"
|
||||
"the file-instance would be 2.\n"
|
||||
"\n"
|
||||
"local-name:\n"
|
||||
"The name of the file that will be stored locally.\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
"the file-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf("local-name:\n"
|
||||
"The name of the file that will be stored locally.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"If you want read File 2 from Device 123 and save it to temp.txt,\n"
|
||||
"use the following command:\n"
|
||||
"%s 123 2 temp.txt\n",
|
||||
|
||||
+32
-18
@@ -29,7 +29,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h> /* for time */
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
@@ -178,13 +178,15 @@ static void print_help(char *filename)
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
@@ -197,42 +199,54 @@ static void print_help(char *filename)
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were reading\n"
|
||||
"Device Object 123, the device-instance would be 123.\n"
|
||||
"\nobject-type:\n"
|
||||
"Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n"
|
||||
"\nobject-instance:\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"object-instance:\n"
|
||||
"This is the object instance number of the object that\n"
|
||||
"you are reading. For example, if you were reading\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n"
|
||||
"\nproperty:\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"property:\n"
|
||||
"The property of the object that you are reading. It\n"
|
||||
"can be defined either as the property name string as\n"
|
||||
"defined in the BACnet specification, or as an integer\n"
|
||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||
"bacenum.h. For example, if you were reading the Present\n"
|
||||
"Value property, use present-value or 85 as the property.\n"
|
||||
"\nindex:\n"
|
||||
"Value property, use present-value or 85 as the property.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"index:\n"
|
||||
"This integer parameter is the index number of an array.\n"
|
||||
"If the property is an array, individual elements can\n"
|
||||
"be read. If this parameter is missing and the property\n"
|
||||
"is an array, the entire array will be read.\n"
|
||||
"\nExample:\n"
|
||||
"is an array, the entire array will be read.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"Example:\n"
|
||||
"If you want read the Present-Value of Analog Output 101\n"
|
||||
"in Device 123, you could send either of the following\n"
|
||||
"commands:\n"
|
||||
"%s 123 analog-output 101 present-value\n"
|
||||
"%s 123 1 101 85\n"
|
||||
"%s 123 1 101 85\n",
|
||||
filename, filename);
|
||||
printf(
|
||||
"If you want read the Priority-Array of Analog Output 101\n"
|
||||
"in Device 123, you could send either of the following\n"
|
||||
"commands:\n"
|
||||
"%s 123 analog-output 101 priority-array\n"
|
||||
"%s 123 1 101 87\n",
|
||||
filename, filename, filename, filename);
|
||||
filename, filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -369,7 +383,7 @@ int main(int argc, char *argv[])
|
||||
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
|
||||
Init_Service_Handlers();
|
||||
dlenv_init();
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
/* Internationalized programs must call setlocale()
|
||||
* to initiate a specific language operation.
|
||||
* This can be done by calling setlocale() as follows.
|
||||
|
||||
+35
-33
@@ -29,7 +29,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h> /* for time */
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
@@ -261,78 +261,80 @@ static void print_help(char *filename)
|
||||
{
|
||||
printf("Read one or more properties from one or more objects\n"
|
||||
"in a BACnet device and print the value(s).\n");
|
||||
|
||||
printf("\n");
|
||||
printf("--mac A\n"
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were reading\n"
|
||||
"Device Object 123, the device-instance would be 123.\n"
|
||||
"\nobject-type:\n"
|
||||
"Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n"
|
||||
"\nobject-instance:\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf("object-instance:\n"
|
||||
"This is the object instance number of the object that\n"
|
||||
"you are reading. For example, if you were reading\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n"
|
||||
"\nproperty:\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf("property:\n"
|
||||
"The property is an integer value of the enumeration\n"
|
||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||
"you are reading. For example, if you were reading the\n"
|
||||
"Present Value property, use 85 as the property.\n"
|
||||
"\n[index]:\n"
|
||||
"Present Value property, use 85 as the property.\n");
|
||||
printf("\n");
|
||||
printf("[index]:\n"
|
||||
"This optional integer parameter is the index number of \n"
|
||||
"an array property. Individual elements of an array can\n"
|
||||
"be read. If this parameter is missing and the property\n"
|
||||
"is an array, the entire array will be read.\n"
|
||||
"\nExample:\n"
|
||||
"is an array, the entire array will be read.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"If you want read the PRESENT_VALUE property and various\n"
|
||||
"array elements of the PRIORITY_ARRAY in Device 123\n"
|
||||
"Analog Output object 99, use one of the following commands:\n"
|
||||
"%s 123 analog-output 99 85,87[0],87\n"
|
||||
"%s 123 1 99 85,87[0],87\n"
|
||||
"If you want read the PRESENT_VALUE property in objects\n"
|
||||
"%s 123 1 99 85,87[0],87\n", filename, filename);
|
||||
printf("If you want read the PRESENT_VALUE property in objects\n"
|
||||
"Analog Input 77 and Analog Input 78 in Device 123\n"
|
||||
"use one of the following commands:\n"
|
||||
"%s 123 analog-input 77 85 analog-input 78 85\n"
|
||||
"%s 123 0 77 85 0 78 85\n"
|
||||
"If you want read the ALL property in\n"
|
||||
"%s 123 0 77 85 0 78 85\n", filename, filename);
|
||||
printf("If you want read the ALL property in\n"
|
||||
"Device object 123, you would use one of the following commands:\n"
|
||||
"%s 123 device 123 8\n"
|
||||
"%s 123 8 123 8\n"
|
||||
"If you want read the OPTIONAL property in\n"
|
||||
"%s 123 8 123 8\n", filename, filename);
|
||||
printf("If you want read the OPTIONAL property in\n"
|
||||
"Device object 123, you would use one of the following commands:\n"
|
||||
"%s 123 device 123 80\n"
|
||||
"%s 123 8 123 80\n"
|
||||
"If you want read the REQUIRED property in\n"
|
||||
"%s 123 8 123 80\n", filename, filename);
|
||||
printf("If you want read the REQUIRED property in\n"
|
||||
"Device object 123, you would one of use the following commands:\n"
|
||||
"%s 123 device 123 105\n"
|
||||
"%s 123 8 123 105\n",
|
||||
filename, filename, filename, filename, filename, filename, filename,
|
||||
filename, filename, filename);
|
||||
"%s 123 8 123 105\n", filename, filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -501,7 +503,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Init_Service_Handlers();
|
||||
dlenv_init();
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
/* Internationalized programs must call setlocale()
|
||||
* to initiate a specific language operation.
|
||||
* This can be done by calling setlocale() as follows.
|
||||
|
||||
+44
-36
@@ -31,7 +31,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h> /* for time */
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#include "bacnet/bacdef.h"
|
||||
@@ -146,40 +146,48 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Read a range of properties from an array or list property\n"
|
||||
"in an object in a BACnet device and print the values.\n"
|
||||
"device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were reading\n"
|
||||
"Device Object 123, the device-instance would be 123.\n"
|
||||
"\nobject-type:\n"
|
||||
"The object type is the integer value of the enumeration\n"
|
||||
"BACNET_OBJECT_TYPE in bacenum.h. It is the object\n"
|
||||
"that you are reading. For example if you were\n"
|
||||
"reading Trend Log 2, the object-type would be 20.\n"
|
||||
"\nobject-instance:\n"
|
||||
"This is the object instance number of the object that\n"
|
||||
"you are reading. For example, if you were reading\n"
|
||||
"Trend Log 2, the object-instance would be 2.\n"
|
||||
"\nproperty:\n"
|
||||
"The property is an integer value of the enumeration\n"
|
||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||
"you are reading. For example, if you were reading the\n"
|
||||
"Log_Buffer property, use 131 as the property.\n"
|
||||
"\nrange-type:\n"
|
||||
"1=By Position\n"
|
||||
"2=By Sequence\n"
|
||||
"3=By Time\n"
|
||||
"4=All\n"
|
||||
"\nindex or date/time:\n"
|
||||
"This integer parameter is the starting index, or date & time.\n"
|
||||
"\ncount:\n"
|
||||
"This integer parameter is the number of elements to read.\n"
|
||||
"\nExample:\n"
|
||||
"If you want read the Log_Buffer of Trend Log 2\n"
|
||||
"in Device 123, from starting position 1 and read 10 entries,\n"
|
||||
"you could send the following commands:\n");
|
||||
"in an object in a BACnet device and print the values.\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were reading\n"
|
||||
"Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is the integer value of the enumeration\n"
|
||||
"BACNET_OBJECT_TYPE in bacenum.h. It is the object\n"
|
||||
"that you are reading. For example if you were\n"
|
||||
"reading Trend Log 2, the object-type would be 20.\n");
|
||||
printf("\n");
|
||||
printf("object-instance:\n"
|
||||
"This is the object instance number of the object that\n"
|
||||
"you are reading. For example, if you were reading\n"
|
||||
"Trend Log 2, the object-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf("property:\n"
|
||||
"The property is an integer value of the enumeration\n"
|
||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||
"you are reading. For example, if you were reading the\n"
|
||||
"Log_Buffer property, use 131 as the property.\n");
|
||||
printf("\n");
|
||||
printf("range-type:\n"
|
||||
"1=By Position\n"
|
||||
"2=By Sequence\n"
|
||||
"3=By Time\n"
|
||||
"4=All\n");
|
||||
printf("\n");
|
||||
printf("index or date/time:\n"
|
||||
"This integer parameter is the starting index, or date & time.\n");
|
||||
printf("\n");
|
||||
printf("count:\n"
|
||||
"This integer parameter is the number of elements to read.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"If you want read the Log_Buffer of Trend Log 2\n"
|
||||
"in Device 123, from starting position 1 and read 10 entries,\n"
|
||||
"you could send the following commands:\n");
|
||||
printf("%s 123 trend-log 2 log-buffer 1 1 10\n", filename);
|
||||
printf("%s 123 trend-log 2 log-buffer 2 1 10\n", filename);
|
||||
printf("%s 123 trend-log 2 log-buffer 3 1/1/2014 00:00:01 10\n", filename);
|
||||
@@ -326,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
address_init();
|
||||
Init_Service_Handlers();
|
||||
dlenv_init();
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
/* Internationalized programs must call setlocale()
|
||||
* to initiate a specific language operation.
|
||||
* This can be done by calling setlocale() as follows.
|
||||
|
||||
+64
-55
@@ -80,7 +80,7 @@ static void MyErrorHandler(BACNET_ADDRESS *src,
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Error: %s: %s\r\n",
|
||||
printf("BACnet Error: %s: %s\n",
|
||||
bactext_error_class_name((int)error_class),
|
||||
bactext_error_code_name((int)error_code));
|
||||
Error_Detected = true;
|
||||
@@ -93,7 +93,7 @@ static void MyAbortHandler(
|
||||
(void)server;
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Abort: %s\r\n",
|
||||
printf("BACnet Abort: %s\n",
|
||||
bactext_abort_reason_name((int)abort_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ static void MyRejectHandler(
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Reject: %s\r\n",
|
||||
printf("BACnet Reject: %s\n",
|
||||
bactext_reject_reason_name((int)reject_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ static void MyWritePropertySimpleAckHandler(
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("SubscribeCOV Acknowledged!\r\n");
|
||||
printf("SubscribeCOV Acknowledged!\n");
|
||||
Simple_Ack_Detected = true;
|
||||
}
|
||||
}
|
||||
@@ -175,6 +175,57 @@ static void cleanup(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
{
|
||||
printf("Usage: %s device-id object-type object-instance "
|
||||
"process-id <[un]confirmed lifetime|cancel>\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("\n");
|
||||
printf("device-id:\n"
|
||||
"The subscriber BACnet Device Object Instance number.\n");
|
||||
printf("\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf("object-instance:\n"
|
||||
"The monitored object instance number.\n");
|
||||
printf("\n");
|
||||
printf("process-id:\n"
|
||||
"Process Identifier for this COV subscription.\n");
|
||||
printf("\n");
|
||||
printf("confirmed:\n"
|
||||
"Optional flag to subscribe using Confirmed notifications.\n"
|
||||
"Use the word \'confirmed\' or \'unconfirmed\'.\n");
|
||||
printf("\n");
|
||||
printf("lifetime:\n"
|
||||
"Optional subscription lifetime is conveyed in seconds.\n");
|
||||
printf("\n");
|
||||
printf("cancel:\n"
|
||||
"Use the word \'cancel\' instead of confirm and lifetime.\n"
|
||||
"This shall indicate a cancellation request.\n");
|
||||
printf("\n");
|
||||
printf("Examples:\n");
|
||||
printf("If you want subscribe to Device 123 Analog Input 9 object\n"
|
||||
"using confirmed COV notifications for 5 minutes,\n"
|
||||
"you could send the following command:\n"
|
||||
"%s 123 0 9 1 confirmed 600\n", filename);
|
||||
printf("To send the same COV subscription request for unconfirmed\n"
|
||||
"notifications, send the following command:\n"
|
||||
"%s 123 0 9 1 unconfirmed 600\n", filename);
|
||||
printf("To cancel the same COV subscription request,\n"
|
||||
"send the following command:\n"
|
||||
"%s 123 0 9 1 cancel\n", filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||
@@ -204,61 +255,19 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (print_usage_terse) {
|
||||
filename = filename_remove_path(argv[0]);
|
||||
printf("Usage: %s device-id object-type object-instance "
|
||||
"process-id <[un]confirmed lifetime|cancel>\r\n",
|
||||
filename);
|
||||
print_usage(filename);
|
||||
if (!print_usage_verbose) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (print_usage_verbose) {
|
||||
printf("\r\n"
|
||||
"device-id:\r\n"
|
||||
"The subscriber BACnet Device Object Instance number.\r\n"
|
||||
"\r\n"
|
||||
"object-type:\r\n"
|
||||
"The object type is object that you are reading. It\r\n"
|
||||
"can be defined either as the object-type name string\r\n"
|
||||
"as defined in the BACnet specification, or as the\r\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\r\n"
|
||||
"in bacenum.h. For example if you were reading Analog\r\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\r\n"
|
||||
"\r\n"
|
||||
"object-instance:\r\n"
|
||||
"The monitored object instance number.\r\n"
|
||||
"\r\n"
|
||||
"process-id:\r\n"
|
||||
"Process Identifier for this COV subscription.\r\n"
|
||||
"\r\n"
|
||||
"confirmed:\r\n"
|
||||
"Optional flag to subscribe using Confirmed notifications.\r\n"
|
||||
"Use the word \'confirmed\' or \'unconfirmed\'.\r\n"
|
||||
"\r\n"
|
||||
"lifetime:\r\n"
|
||||
"Optional subscription lifetime is conveyed in seconds.\r\n"
|
||||
"\r\n"
|
||||
"cancel:\r\n"
|
||||
"Use the word \'cancel\' instead of confirm and lifetime.\r\n"
|
||||
"This shall indicate a cancellation request.\r\n"
|
||||
"\r\n"
|
||||
"Example:\r\n"
|
||||
"If you want subscribe to Device 123 Analog Input 9 object\r\n"
|
||||
"using confirmed COV notifications for 5 minutes,\r\n"
|
||||
"you could send the following command:\r\n"
|
||||
"%s 123 0 9 1 confirmed 600\r\n"
|
||||
"To send the same COV subscription request for unconfirmed\r\n"
|
||||
"notifications, send the following command:\r\n"
|
||||
"%s 123 0 9 1 unconfirmed 600\r\n"
|
||||
"To cancel the same COV subscription request,\r\n"
|
||||
"send the following command:\r\n"
|
||||
"%s 123 0 9 1 cancel\r\n",
|
||||
filename, filename, filename);
|
||||
print_help(filename);
|
||||
return 0;
|
||||
}
|
||||
/* decode the command line parameters */
|
||||
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
||||
if (Target_Device_Object_Instance >= BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
@@ -274,7 +283,7 @@ int main(int argc, char *argv[])
|
||||
cov_data->monitoredObjectIdentifier.type = (uint16_t)uint;
|
||||
if (cov_data->monitoredObjectIdentifier.type >=
|
||||
MAX_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\n",
|
||||
cov_data->monitoredObjectIdentifier.type,
|
||||
MAX_BACNET_OBJECT_TYPE);
|
||||
return 1;
|
||||
@@ -284,7 +293,7 @@ int main(int argc, char *argv[])
|
||||
strtol(argv[argi], NULL, 0);
|
||||
if (cov_data->monitoredObjectIdentifier.instance >
|
||||
BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "object-instance=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "object-instance=%u - it must be less than %u\n",
|
||||
cov_data->monitoredObjectIdentifier.instance,
|
||||
BACNET_MAX_INSTANCE + 1);
|
||||
return 1;
|
||||
@@ -302,7 +311,7 @@ int main(int argc, char *argv[])
|
||||
} else if (strcmp(argv[argi], "unconfirmed") == 0) {
|
||||
cov_data->issueConfirmedNotifications = false;
|
||||
} else {
|
||||
fprintf(stderr, "unknown option: %s\r\n", argv[argi]);
|
||||
fprintf(stderr, "unknown option: %s\n", argv[argi]);
|
||||
return 1;
|
||||
}
|
||||
argi++;
|
||||
@@ -379,7 +388,7 @@ int main(int argc, char *argv[])
|
||||
timeout_seconds = cov_data->lifetime;
|
||||
}
|
||||
printf("Sent SubscribeCOV request. "
|
||||
" Waiting up to %u seconds....\r\n",
|
||||
" Waiting up to %u seconds....\n",
|
||||
(unsigned)(timeout_seconds - elapsed_seconds));
|
||||
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||
if (cov_data->next) {
|
||||
@@ -391,7 +400,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
||||
fprintf(stderr, "\rError: TSM Timeout!\r\n");
|
||||
fprintf(stderr, "\rError: TSM Timeout!\n");
|
||||
tsm_free_invoke_id(Request_Invoke_ID);
|
||||
Error_Detected = true;
|
||||
break;
|
||||
@@ -400,7 +409,7 @@ int main(int argc, char *argv[])
|
||||
/* exit if timed out */
|
||||
if (elapsed_seconds > timeout_seconds) {
|
||||
Error_Detected = true;
|
||||
printf("\rError: APDU Timeout!\r\n");
|
||||
printf("\rError: APDU Timeout!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "bacnet/bactext.h"
|
||||
#include "bacnet/version.h"
|
||||
#include "bacnet/basic/sys/filename.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/sys/mstimer.h"
|
||||
#include "bacnet/basic/client/bac-task.h"
|
||||
#include "bacnet/basic/client/bac-data.h"
|
||||
@@ -26,9 +27,7 @@
|
||||
#include "bacnet/datalink/dlenv.h"
|
||||
|
||||
/* print with flush by default */
|
||||
#define PRINTF(...) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr)
|
||||
#define PRINTF debug_aprintf
|
||||
|
||||
/* current version of the BACnet stack */
|
||||
static const char *BACnet_Version = BACNET_VERSION_TEXT;
|
||||
@@ -49,20 +48,22 @@ static void print_help(const char *filename)
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were reading\n"
|
||||
"Device Object 123, the device-instance would be 123.\n"
|
||||
"\nobject-type:\n"
|
||||
"Device Object 123, the device-instance would be 123.\n");
|
||||
PRINTF("\n");
|
||||
PRINTF("object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n"
|
||||
"\nobject-instance:\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
PRINTF("\n");
|
||||
PRINTF("object-instance:\n"
|
||||
"This is the object instance number of the object that\n"
|
||||
"you are reading. For example, if you were reading\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n");
|
||||
PRINTF("\n"
|
||||
"Example:\n"
|
||||
PRINTF("\n");
|
||||
PRINTF("Example:\n"
|
||||
"If you want read the Present-Value of Analog Output 101\n"
|
||||
"in Device 123, you could send either of the following\n"
|
||||
"commands:\n"
|
||||
|
||||
+1
-1
@@ -191,6 +191,7 @@ int main(int argc, char *argv[])
|
||||
uint32_t elapsed_seconds = 0;
|
||||
uint32_t elapsed_milliseconds = 0;
|
||||
uint32_t address_binding_tmr = 0;
|
||||
BACNET_CHARACTER_STRING DeviceName;
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
uint32_t recipient_scan_tmr = 0;
|
||||
#endif
|
||||
@@ -266,7 +267,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
ucix_cleanup(ctx);
|
||||
#endif /* defined(BAC_UCI) */
|
||||
BACNET_CHARACTER_STRING DeviceName;
|
||||
if (Device_Object_Name(Device_Object_Instance_Number(), &DeviceName)) {
|
||||
printf("BACnet Device Name: %s\n", DeviceName.value);
|
||||
}
|
||||
|
||||
+31
-32
@@ -101,33 +101,43 @@ static void Init_Service_Handlers(void)
|
||||
static void print_usage(char *filename)
|
||||
{
|
||||
printf("Usage: %s [--dnet][--dadr][--mac]\n", filename);
|
||||
printf(" [--date][--time]\n");
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet TimeSynchronization request.\n"
|
||||
"\n"
|
||||
"--mac A\n"
|
||||
"BACnet mac address."
|
||||
"Valid ranges are from 0 to 255\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"BACnet mac address on the destination BACnet network number.\n"
|
||||
"Valid ranges are from 0 to 255\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
printf("Send BACnet TimeSynchronization request.\n");
|
||||
printf("\n");
|
||||
printf("--date year/month/day[:weekday]\n"
|
||||
"Date formatted 2021/12/31 or 2021/12/31:1\n"
|
||||
"where day is 1..31,\n"
|
||||
"where month is 1=January..12=December,\n"
|
||||
"where weekday is 1=Monday..7=Sunday\n");
|
||||
printf("\n");
|
||||
printf("--time hours:minutes:seconds.hundredths\n"
|
||||
"Time formatted 23:59:59.99 or 23:59:59 or 23:59\n");
|
||||
printf("\n");
|
||||
printf("--mac A\n"
|
||||
"BACnet mac address."
|
||||
"Valid ranges are from 0 to 255\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"BACnet mac address on the destination BACnet network number.\n"
|
||||
"Valid ranges are from 0 to 255\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("Examples:\n"
|
||||
"Send a TimeSynchronization request to DNET 123:\n"
|
||||
"%s --dnet 123\n",
|
||||
"Send a TimeSynchronization request to DNET 123:\n"
|
||||
"%s --dnet 123\n",
|
||||
filename);
|
||||
printf(
|
||||
"Send a TimeSynchronization request to MAC 10.0.0.1 DNET 123 DADR 5:\n"
|
||||
@@ -136,17 +146,6 @@ static void print_help(char *filename)
|
||||
printf("Send a TimeSynchronization request to MAC 10.1.2.3:47808:\n"
|
||||
"%s --mac 10.1.2.3:47808\n",
|
||||
filename);
|
||||
#if 0
|
||||
/* FIXME: it would be nice to be able to send arbitrary time values */
|
||||
"date format: year/month/day:dayofweek (e.g. 2006/4/1:6)\n"
|
||||
"year: AD, such as 2006\n" "month: 1=January, 12=December\n"
|
||||
"day: 1-31\n" "dayofweek: 1=Monday, 7=Sunday\n" "\n"
|
||||
"time format: hour:minute:second.hundredths (e.g. 23:59:59.12)\n"
|
||||
"hour: 0-23\n" "minute: 0-59\n" "second: 0-59\n"
|
||||
"hundredths: 0-99\n" "\n"
|
||||
"Optional device-instance sends a unicast time sync.\n",
|
||||
filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
+73
-98
@@ -66,6 +66,72 @@ static void Init_Service_Handlers(void)
|
||||
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
{
|
||||
printf("Usage: %s pid device-id object-type object-instance "
|
||||
"time property tag value [priority] [index]\n", filename);
|
||||
printf("\n");
|
||||
printf("pid:\n"
|
||||
"Process Identifier for this broadcast.\n");
|
||||
printf("\n");
|
||||
printf("device-id:\n"
|
||||
"The Initiating BACnet Device Object Instance number.\n");
|
||||
printf("\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf("object-instance:\n"
|
||||
"The monitored object instance number.\n");
|
||||
printf("\n");
|
||||
printf("time:\n"
|
||||
"The subscription time remaining is conveyed in seconds.\n");
|
||||
printf("\n");
|
||||
printf("property:\n"
|
||||
"The property of the object that you are reading. It\n"
|
||||
"can be defined either as the property name string as\n"
|
||||
"defined in the BACnet specification, or as an integer\n"
|
||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||
"bacenum.h. For example, if you were reading the Present\n"
|
||||
"Value property, use present-value or 85 as the property.\n");
|
||||
printf("\n");
|
||||
printf("tag:\n"
|
||||
"Tag is the integer value of the enumeration BACNET_APPLICATION_TAG \n"
|
||||
"in bacenum.h. It is the data type of the value that you are\n"
|
||||
"monitoring. For example, if you were monitoring a REAL value,\n"
|
||||
"you would use a tag of 4.\n");
|
||||
printf("\n");
|
||||
printf("value:\n"
|
||||
"The value is an ASCII representation of some type of data that you\n"
|
||||
"are monitoring. It is encoded using the tag information provided.\n"
|
||||
"For example, if you were writing a REAL value of 100.0,\n"
|
||||
"you would use 100.0 as the value.\n");
|
||||
printf("\n");
|
||||
printf("[priority]:\n"
|
||||
"This optional parameter is used for reporting the priority of the\n"
|
||||
"value. If no priority is given, none is sent, and the BACnet \n"
|
||||
"standard requires that the value is reported at the lowest \n"
|
||||
"priority (16) if the object property supports priorities.\n");
|
||||
printf("\n");
|
||||
printf("[index]\n"
|
||||
"This optional integer parameter is the index number of an array.\n"
|
||||
"If the property is an array, individual elements can be reported.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"If you want generate an unconfirmed COV,\n"
|
||||
"you could send one of the following command:\n"
|
||||
"%s 1 2 analog-value 4 5 prevent-value 4 100.0\n"
|
||||
"%s 1 2 3 4 5 85 4 100.0\n"
|
||||
"where 1=pid, 2=device-id, 3=AV, 4=object-id, 5=time,\n"
|
||||
"85=Present-Value, 4=REAL, 100.0=value\n",
|
||||
filename, filename);
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *value_string = NULL;
|
||||
@@ -77,98 +143,7 @@ int main(int argc, char *argv[])
|
||||
unsigned object_property = 0;
|
||||
|
||||
if (argc < 7) {
|
||||
/* note: priority 16 and 0 should produce the same end results... */
|
||||
printf(
|
||||
"Usage: %s pid device-id object-type object-instance "
|
||||
"time property tag value [priority] [index]\r\n"
|
||||
"\r\n"
|
||||
"pid:\r\n"
|
||||
"Process Identifier for this broadcast.\r\n"
|
||||
"\r\n"
|
||||
"device-id:\r\n"
|
||||
"The Initiating BACnet Device Object Instance number.\r\n"
|
||||
"\r\n"
|
||||
"object-type:\r\n"
|
||||
"The object type is object that you are reading. It\r\n"
|
||||
"can be defined either as the object-type name string\r\n"
|
||||
"as defined in the BACnet specification, or as the\r\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\r\n"
|
||||
"in bacenum.h. For example if you were reading Analog\r\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\r\n"
|
||||
"\r\n"
|
||||
"object-instance:\r\n"
|
||||
"The monitored object instance number.\r\n"
|
||||
"\r\n"
|
||||
"time:\r\n"
|
||||
"The subscription time remaining is conveyed in seconds.\r\n"
|
||||
"\r\n"
|
||||
"property:\r\n"
|
||||
"The property of the object that you are reading. It\r\n"
|
||||
"can be defined either as the property name string as\r\n"
|
||||
"defined in the BACnet specification, or as an integer\r\n"
|
||||
"value of the enumeration BACNET_PROPERTY_ID in\\rn"
|
||||
"bacenum.h. For example, if you were reading the Present\r\n"
|
||||
"Value property, use present-value or 85 as the property.\r\n"
|
||||
"\r\n"
|
||||
"tag:\r\n"
|
||||
"Tag is the integer value of the enumeration "
|
||||
"BACNET_APPLICATION_TAG \r\n"
|
||||
"in bacenum.h. It is the data type of the value that you are\r\n"
|
||||
"monitoring. For example, if you were monitoring a REAL value, "
|
||||
"you would \r\n"
|
||||
"use a tag of 4."
|
||||
"\r\n"
|
||||
"value:\r\n"
|
||||
"The value is an ASCII representation of some type of data that "
|
||||
"you\r\n"
|
||||
"are monitoring. It is encoded using the tag information "
|
||||
"provided. For\r\n"
|
||||
"example, if you were writing a REAL value of 100.0, you would use "
|
||||
"\r\n"
|
||||
"100.0 as the value.\r\n"
|
||||
"\r\n"
|
||||
"[priority]:\r\n"
|
||||
"This optional parameter is used for reporting the priority of "
|
||||
"the\r\n"
|
||||
"value. If no priority is given, none is sent, and the BACnet \r\n"
|
||||
"standard requires that the value is reported at the lowest \r\n"
|
||||
"priority (16) if the object property supports priorities.\r\n"
|
||||
"\r\n"
|
||||
"[index]\r\n"
|
||||
"This optional integer parameter is the index number of an "
|
||||
"array.\r\n"
|
||||
"If the property is an array, individual elements can be "
|
||||
"reported.\r\n"
|
||||
"\r\n"
|
||||
"Here is a brief overview of BACnet property and tags:\r\n"
|
||||
"Certain properties are expected to be written with certain \r\n"
|
||||
"application tags, so you probably need to know which ones to "
|
||||
"use\r\n"
|
||||
"with each property of each object. It is almost safe to say "
|
||||
"that\r\n"
|
||||
"given a property and an object and a table, the tag could be "
|
||||
"looked\r\n"
|
||||
"up automatically. There may be a few exceptions to this, such "
|
||||
"as\r\n"
|
||||
"the Any property type in the schedule object and the Present "
|
||||
"Value\r\n"
|
||||
"accepting REAL, BOOLEAN, NULL, etc. Perhaps it would be simpler "
|
||||
"for\r\n"
|
||||
"the demo to use this kind of table - but I also wanted to be "
|
||||
"able\r\n"
|
||||
"to do negative testing by passing the wrong tag and have the "
|
||||
"server\r\n"
|
||||
"return a reject message.\r\n"
|
||||
"\r\n"
|
||||
"Example:\r\n"
|
||||
"If you want generate an unconfirmed COV,\r\n"
|
||||
"you could send one of the following command:\r\n"
|
||||
"%s 1 2 analog-value 4 5 prevent-value 4 100.0\r\n"
|
||||
"%s 1 2 3 4 5 85 4 100.0\r\n"
|
||||
"where 1=pid, 2=device-id, 3=AV, 4=object-id, 5=time,\r\n"
|
||||
"85=Present-Value, 4=REAL, 100.0=value\r\n",
|
||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]),
|
||||
filename_remove_path(argv[0]));
|
||||
print_usage(filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
}
|
||||
/* decode the command line parameters */
|
||||
@@ -204,29 +179,29 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
|
||||
cov_data.initiatingDeviceIdentifier, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
if (cov_data.monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\n",
|
||||
cov_data.monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE);
|
||||
return 1;
|
||||
}
|
||||
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "object-instance=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "object-instance=%u - it must be less than %u\n",
|
||||
cov_data.monitoredObjectIdentifier.instance,
|
||||
BACNET_MAX_INSTANCE + 1);
|
||||
return 1;
|
||||
}
|
||||
if (cov_data.listOfValues->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
||||
fprintf(stderr, "property-identifier=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "property-identifier=%u - it must be less than %u\n",
|
||||
cov_data.listOfValues->propertyIdentifier,
|
||||
MAX_BACNET_PROPERTY_ID + 1);
|
||||
return 1;
|
||||
}
|
||||
if (tag >= MAX_BACNET_APPLICATION_TAG) {
|
||||
fprintf(stderr, "tag=%u - it must be less than %u\r\n", tag,
|
||||
fprintf(stderr, "tag=%u - it must be less than %u\n", tag,
|
||||
MAX_BACNET_APPLICATION_TAG);
|
||||
return 1;
|
||||
}
|
||||
@@ -234,7 +209,7 @@ int main(int argc, char *argv[])
|
||||
tag, value_string, &cov_data.listOfValues->value);
|
||||
if (!status) {
|
||||
/* FIXME: show the expected entry format for the tag */
|
||||
fprintf(stderr, "unable to parse the tag value\r\n");
|
||||
fprintf(stderr, "unable to parse the tag value\n");
|
||||
return 1;
|
||||
}
|
||||
/* setup my info */
|
||||
|
||||
+17
-17
@@ -86,23 +86,23 @@ static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet UnconfirmedEventNotification message for a device.\n");
|
||||
printf("--mac A\n"
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network "
|
||||
"number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n");
|
||||
"Optional BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"Optional BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"Optional BACnet mac address on the destination BACnet network\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
(void)filename;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
+65
-61
@@ -84,7 +84,7 @@ static void MyErrorHandler(BACNET_ADDRESS *src,
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Error: %s: %s\r\n",
|
||||
printf("BACnet Error: %s: %s\n",
|
||||
bactext_error_class_name((int)error_class),
|
||||
bactext_error_code_name((int)error_code));
|
||||
Error_Detected = true;
|
||||
@@ -97,7 +97,7 @@ static void MyAbortHandler(
|
||||
(void)server;
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Abort: %s\r\n",
|
||||
printf("BACnet Abort: %s\n",
|
||||
bactext_abort_reason_name((int)abort_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ static void MyRejectHandler(
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Reject: %s\r\n",
|
||||
printf("BACnet Reject: %s\n",
|
||||
bactext_reject_reason_name((int)reject_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
@@ -137,6 +137,57 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
{
|
||||
printf("Usage: %s <device-instance|broadcast|dnet=> vendor-id"
|
||||
" service-number tag value [tag value...]\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were transferring to\n"
|
||||
"Device Object 123, the device-instance would be 123.\n"
|
||||
"For Global Broadcast, use the word 'broadcast'.\n"
|
||||
"For Local Broadcast to a particular DNET n, use 'dnet=n'.\n");
|
||||
printf("\n");
|
||||
printf("vendor_id:\n"
|
||||
"the unique vendor identification code for the type of\n"
|
||||
"vendor proprietary service to be performed.\n");
|
||||
printf("\n");
|
||||
printf("service-number (Unsigned32):\n"
|
||||
"the desired proprietary service to be performed.\n");
|
||||
printf("\n");
|
||||
printf("tag:\n"
|
||||
"Tag is the integer value of the enumeration \n"
|
||||
"BACNET_APPLICATION_TAG in bacenum.h.\n"
|
||||
"It is the data type of the value that you are sending.\n"
|
||||
"For example, if you were transfering a REAL value, you would\n"
|
||||
"use a tag of 4.\n"
|
||||
"Context tags are created using two tags in a row.\n"
|
||||
"The context tag is preceded by a C. Ctag tag.\n"
|
||||
"C2 4 creates a context 2 tagged REAL.\n");
|
||||
printf("\n");
|
||||
printf("value:\n"
|
||||
"The value is an ASCII representation of some type of data\n"
|
||||
"that you are transfering.\n"
|
||||
"It is encoded using the tag information provided.\n"
|
||||
"For example, if you were transferring a REAL value of 100.0,\n"
|
||||
"you would use 100.0 as the value.\n"
|
||||
"If you were transferring an object identifier for Device 123,\n"
|
||||
"you would use 8:123 as the value.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"If you want to transfer a REAL value of 1.1 to service 23 of \n"
|
||||
"vendor 260 in Device 99, you could send the following command:\n"
|
||||
"%s 99 260 23 4 1.1\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||
@@ -161,56 +212,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 6) {
|
||||
filename = filename_remove_path(argv[0]);
|
||||
printf("Usage: %s <device-instance|broadcast|dnet=> vendor-id"
|
||||
" service-number tag value [tag value...]\r\n",
|
||||
filename);
|
||||
print_usage(filename);
|
||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||
printf(
|
||||
"device-instance:\r\n"
|
||||
"BACnet Device Object Instance number that you are\r\n"
|
||||
"trying to communicate to. This number will be used\r\n"
|
||||
"to try and bind with the device using Who-Is and\r\n"
|
||||
"I-Am services. For example, if you were transferring to\r\n"
|
||||
"Device Object 123, the device-instance would be 123.\r\n"
|
||||
"For Global Broadcast, use the word 'broadcast'.\r\n"
|
||||
"For Local Broadcast to a particular DNET n, use 'dnet=n'.\r\n"
|
||||
"\r\n"
|
||||
"vendor_id:\r\n"
|
||||
"the unique vendor identification code for the type of\r\n"
|
||||
"vendor proprietary service to be performed.\r\n"
|
||||
"\r\n"
|
||||
"service-number (Unsigned32):\r\n"
|
||||
"the desired proprietary service to be performed.\r\n"
|
||||
"\r\n"
|
||||
"tag:\r\n"
|
||||
"Tag is the integer value of the enumeration \r\n"
|
||||
"BACNET_APPLICATION_TAG in bacenum.h.\r\n"
|
||||
"It is the data type of the value that you are sending.\r\n"
|
||||
"For example, if you were transfering a REAL value, you would "
|
||||
"\r\n"
|
||||
"use a tag of 4.\r\n"
|
||||
"Context tags are created using two tags in a row.\r\n"
|
||||
"The context tag is preceded by a C. Ctag tag.\r\n"
|
||||
"C2 4 creates a context 2 tagged REAL.\r\n"
|
||||
"\r\n"
|
||||
"value:\r\n"
|
||||
"The value is an ASCII representation of some type of data\r\n"
|
||||
"that you are transfering.\r\n"
|
||||
"It is encoded using the tag information provided.\r\n"
|
||||
"For example, if you were transferring a REAL value of "
|
||||
"100.0,\r\n"
|
||||
"you would use 100.0 as the value.\r\n"
|
||||
"If you were transferring an object identifier for Device "
|
||||
"123,\r\n"
|
||||
"you would use 8:123 as the value.\r\n"
|
||||
"\r\n"
|
||||
"Example:\r\n"
|
||||
"If you want to transfer a REAL value of 1.1 to service 23 of "
|
||||
"\r\n"
|
||||
"vendor 260 in Device 99, you could send the following "
|
||||
"command:\r\n"
|
||||
"%s 99 260 23 4 1.1\r\n",
|
||||
filename);
|
||||
print_help(filename);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -228,7 +232,7 @@ int main(int argc, char *argv[])
|
||||
Target_Service_Number = strtol(argv[3], NULL, 0);
|
||||
if ((!Target_Broadcast) &&
|
||||
(Target_Device_Object_Instance > BACNET_MAX_INSTANCE)) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
@@ -248,15 +252,15 @@ int main(int argc, char *argv[])
|
||||
property_tag = strtol(argv[tag_value_arg], NULL, 0);
|
||||
args_remaining--;
|
||||
if (args_remaining <= 0) {
|
||||
fprintf(stderr, "Error: not enough tag-value pairs\r\n");
|
||||
fprintf(stderr, "Error: not enough tag-value pairs\n");
|
||||
return 1;
|
||||
}
|
||||
value_string = argv[tag_value_arg + 1];
|
||||
args_remaining--;
|
||||
/* printf("tag[%d]=%u value[%d]=%s\r\n",
|
||||
/* printf("tag[%d]=%u value[%d]=%s\n",
|
||||
i, property_tag, i, value_string); */
|
||||
if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
|
||||
fprintf(stderr, "Error: tag=%u - it must be less than %u\r\n",
|
||||
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
|
||||
property_tag, MAX_BACNET_APPLICATION_TAG);
|
||||
return 1;
|
||||
}
|
||||
@@ -264,7 +268,7 @@ int main(int argc, char *argv[])
|
||||
property_tag, value_string, &Target_Object_Property_Value[i]);
|
||||
if (!status) {
|
||||
/* FIXME: show the expected entry format for the tag */
|
||||
fprintf(stderr, "Error: unable to parse the tag value\r\n");
|
||||
fprintf(stderr, "Error: unable to parse the tag value\n");
|
||||
return 1;
|
||||
}
|
||||
Target_Object_Property_Value[i].next = NULL;
|
||||
@@ -277,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (args_remaining > 0) {
|
||||
fprintf(stderr, "Error: Exceeded %d tag-value pairs.\r\n",
|
||||
fprintf(stderr, "Error: Exceeded %d tag-value pairs.\n",
|
||||
MAX_PROPERTY_VALUES);
|
||||
return 1;
|
||||
}
|
||||
@@ -334,15 +338,15 @@ int main(int argc, char *argv[])
|
||||
Send_UnconfirmedPrivateTransfer(&Target_Address, &private_data);
|
||||
printf("Sent PrivateTransfer.");
|
||||
if (timeout_seconds) {
|
||||
printf(" Waiting %u seconds.\r\n",
|
||||
printf(" Waiting %u seconds.\n",
|
||||
(unsigned)(timeout_seconds - elapsed_seconds));
|
||||
} else {
|
||||
printf("\r\n");
|
||||
printf("\n");
|
||||
}
|
||||
sent_message = true;
|
||||
} else {
|
||||
if (elapsed_seconds > timeout_seconds) {
|
||||
printf("\rError: APDU Timeout!\r\n");
|
||||
printf("\rError: APDU Timeout!\n");
|
||||
Error_Detected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+49
-54
@@ -276,68 +276,69 @@ static void print_usage(char *filename)
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf("Send BACnet WhoIs service request to a device or multiple\n"
|
||||
"devices, and wait for responses. Displays any devices found\n"
|
||||
"and their network information.\n"
|
||||
"\n"
|
||||
"device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are trying\n"
|
||||
"to send a Who-Is service request. The value should be in\n"
|
||||
"the range of 0 to 4194303. A range of values can also be\n"
|
||||
"specified by using a minimum value and a maximum value.\n"
|
||||
"\n");
|
||||
"devices, and wait for responses. Displays any devices found\n"
|
||||
"and their network information.\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are trying\n"
|
||||
"to send a Who-Is service request. The value should be in\n"
|
||||
"the range of 0 to 4194303. A range of values can also be\n"
|
||||
"specified by using a minimum value and a maximum value.\n");
|
||||
printf("\n");
|
||||
printf("--mac A\n"
|
||||
"BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--dnet N\n"
|
||||
"BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n"
|
||||
"\n"
|
||||
"--dadr A\n"
|
||||
"BACnet mac address on the destination BACnet network number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
||||
"\n"
|
||||
"--repeat\n"
|
||||
"Send the message repeatedly until signalled to quit.\n"
|
||||
"Default is disabled, using the APDU timeout as time to quit.\n"
|
||||
"\n"
|
||||
"--retry C\n"
|
||||
"Send the message C number of times\n"
|
||||
"Default is retry 0, only sending one time.\n"
|
||||
"\n"
|
||||
"--timeout T\n"
|
||||
"Wait T milliseconds after sending before retry\n"
|
||||
"Default delay is 3000ms.\n"
|
||||
"\n"
|
||||
"--delay M\n"
|
||||
"Wait M milliseconds for responses after sending\n"
|
||||
"Default delay is 100ms.\n"
|
||||
"\n");
|
||||
"BACnet mac address."
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--dnet N\n"
|
||||
"BACnet network number N for directed requests.\n"
|
||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||
"and 65535 is network broadcast.\n");
|
||||
printf("\n");
|
||||
printf("--dadr A\n"
|
||||
"BACnet mac address on the destination BACnet network number.\n"
|
||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
|
||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("--repeat\n"
|
||||
"Send the message repeatedly until signalled to quit.\n"
|
||||
"Default is disabled, using the APDU timeout as time to quit.\n");
|
||||
printf("\n");
|
||||
printf("--retry C\n"
|
||||
"Send the message C number of times\n"
|
||||
"Default is retry 0, only sending one time.\n");
|
||||
printf("\n");
|
||||
printf("--timeout T\n"
|
||||
"Wait T milliseconds after sending before retry\n"
|
||||
"Default delay is 3000ms.\n");
|
||||
printf("\n");
|
||||
printf("--delay M\n"
|
||||
"Wait M milliseconds for responses after sending\n"
|
||||
"Default delay is 100ms.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n");
|
||||
printf("Send a WhoIs request to DNET 123:\n"
|
||||
"%s --dnet 123\n",
|
||||
"%s --dnet 123\n",
|
||||
filename);
|
||||
printf("Send a WhoIs request to MAC 10.0.0.1 DNET 123 DADR 05h:\n"
|
||||
"%s --mac 10.0.0.1 --dnet 123 --dadr 05\n",
|
||||
"%s --mac 10.0.0.1 --dnet 123 --dadr 05\n",
|
||||
filename);
|
||||
printf("Send a WhoIs request to MAC 10.1.2.3:47808:\n"
|
||||
"%s --mac 10.1.2.3:47808\n",
|
||||
"%s --mac 10.1.2.3:47808\n",
|
||||
filename);
|
||||
printf("Send a WhoIs request to Device 123:\n"
|
||||
"%s 123\n",
|
||||
"%s 123\n",
|
||||
filename);
|
||||
printf("Send a WhoIs request to Devices from 1000 to 9000:\n"
|
||||
"%s 1000 9000\n",
|
||||
"%s 1000 9000\n",
|
||||
filename);
|
||||
printf("Send a WhoIs request to Devices from 1000 to 9000 on DNET 123:\n"
|
||||
"%s 1000 9000 --dnet 123\n",
|
||||
"%s 1000 9000 --dnet 123\n",
|
||||
filename);
|
||||
printf("Send a WhoIs request to all devices:\n"
|
||||
"%s\n",
|
||||
"%s\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
@@ -413,16 +414,10 @@ int main(int argc, char *argv[])
|
||||
} else if (strcmp(argv[argi], "--timeout") == 0) {
|
||||
if (++argi < argc) {
|
||||
timeout_milliseconds = strtol(argv[argi], NULL, 0);
|
||||
if (timeout_milliseconds < 0) {
|
||||
timeout_milliseconds = 0;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(argv[argi], "--delay") == 0) {
|
||||
if (++argi < argc) {
|
||||
delay_milliseconds = strtol(argv[argi], NULL, 0);
|
||||
if (delay_milliseconds < 0) {
|
||||
delay_milliseconds = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (target_args == 0) {
|
||||
|
||||
+31
-31
@@ -161,76 +161,76 @@ static void print_help(char *filename)
|
||||
"BACnet Device Object Instance number that you are trying to\n"
|
||||
"communicate to. This number will be used to try and bind with\n"
|
||||
"the device using Who-Is and I-Am services. For example, if you were\n"
|
||||
"writing to Device Object 123, the device-instance would be 123.\n"
|
||||
"\n"
|
||||
"writing to Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n"
|
||||
"\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"object-instance:\n"
|
||||
"This is the object instance number of the object that you are \n"
|
||||
"writing to. For example, if you were writing to Analog Output 2, \n"
|
||||
"the object-instance would be 2.\n"
|
||||
"\n"
|
||||
"the object-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"property:\n"
|
||||
"The property of the object that you are reading. It\n"
|
||||
"can be defined either as the property name string as\n"
|
||||
"defined in the BACnet specification, or as an integer\n"
|
||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||
"bacenum.h. For example, if you were reading the Present\n"
|
||||
"Value property, use present-value or 85 as the property.\n"
|
||||
"\n"
|
||||
"Value property, use present-value or 85 as the property.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"priority:\n"
|
||||
"This parameter is used for setting the priority of the\n"
|
||||
"write. If Priority 0 is given, no priority is sent. The BACnet \n"
|
||||
"standard states that the value is written at the lowest \n"
|
||||
"priority (16) if the object property supports priorities\n"
|
||||
"when no priority is sent.\n"
|
||||
"\n"
|
||||
"when no priority is sent.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"index\n"
|
||||
"This integer parameter is the index number of an array.\n"
|
||||
"If the property is an array, individual elements can be written\n"
|
||||
"to if supported. If this parameter is -1, the index is ignored.\n"
|
||||
"\n"
|
||||
"to if supported. If this parameter is -1, the index is ignored.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"tag:\n"
|
||||
"Tag is the integer value of the enumeration BACNET_APPLICATION_TAG \n"
|
||||
"in bacenum.h. It is the data type of the value that you are\n"
|
||||
"writing. For example, if you were writing a REAL value, you would \n"
|
||||
"use a tag of 4.\n"
|
||||
"Context tags are created using two tags in a row. The context tag\n"
|
||||
"is preceded by a C. Ctag tag. C2 4 creates a context 2 tagged REAL.\n"
|
||||
"\n"
|
||||
"is preceded by a C, and followed by the application tag.\n"
|
||||
"Ctag atag. C2 4 creates a context 2 tagged REAL.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"value:\n"
|
||||
"The value is an ASCII representation of some type of data that you\n"
|
||||
"are writing. It is encoded using the tag information provided. For\n"
|
||||
"example, if you were writing a REAL value of 100.0, you would use \n"
|
||||
"100.0 as the value.\n"
|
||||
"\n"
|
||||
"Here is a brief overview of BACnet property and tags:\n"
|
||||
"Certain properties are expected to be written with certain \n"
|
||||
"application tags, so you probably need to know which ones to use\n"
|
||||
"with each property of each object. It is almost safe to say that\n"
|
||||
"given a property and an object and a table, the tag could be looked\n"
|
||||
"up automatically. There may be a few exceptions to this, such as\n"
|
||||
"the Any property type in the schedule object and the Present Value\n"
|
||||
"accepting REAL, BOOLEAN, NULL, etc. Perhaps it would be simpler for\n"
|
||||
"the demo to use this kind of table - but I also wanted to be able\n"
|
||||
"to do negative testing by passing the wrong tag and have the server\n"
|
||||
"return a reject message.\n"
|
||||
"\nExample:\n"
|
||||
"100.0 as the value.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"Example:\n"
|
||||
"If you want send a value of 100 to the Present-Value in\n"
|
||||
"Analog Output 0 of Device 123 at priority 16,\n"
|
||||
"send the one of following commands:\n"
|
||||
"%s 123 analog-output 0 present-value 16 -1 4 100\n"
|
||||
"%s 123 1 0 85 16 -1 4 100\n"
|
||||
"%s 123 1 0 85 16 -1 4 100\n",
|
||||
filename, filename);
|
||||
printf(
|
||||
"To send a relinquish command to the same object:\n"
|
||||
"%s 123 analog-output 0 present-value 16 -1 0 0\n"
|
||||
"%s 123 1 0 85 16 -1 0 0\n",
|
||||
filename, filename, filename, filename);
|
||||
filename, filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -362,7 +362,7 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Print the written value (for debug)
|
||||
/* Print the written value (for debug) */
|
||||
#if 0
|
||||
fprintf(stderr, "Writing: ");
|
||||
BACNET_OBJECT_PROPERTY_VALUE dummy_opv = {
|
||||
|
||||
+38
-32
@@ -186,73 +186,79 @@ static void print_usage(char *filename)
|
||||
|
||||
static void print_help(char *filename)
|
||||
{
|
||||
printf(
|
||||
"Write one or more properties to one or more objects\n"
|
||||
"in a BACnet device.\n"
|
||||
"device-instance:\n"
|
||||
printf("Write one or more properties to one or more objects\n"
|
||||
"in a BACnet device.\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
"trying to communicate to. This number will be used\n"
|
||||
"to try and bind with the device using Who-Is and\n"
|
||||
"I-Am services. For example, if you were writing\n"
|
||||
"Device Object 123, the device-instance would be 123.\n"
|
||||
"\nobject-type:\n"
|
||||
"Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n"
|
||||
"\nobject-instance:\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf("object-instance:\n"
|
||||
"This is the object instance number of the object that\n"
|
||||
"you are writing. For example, if you were writing\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n"
|
||||
"\nproperty:\n"
|
||||
"Analog Output 2, the object-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf("property:\n"
|
||||
"The property is an integer value of the enumeration\n"
|
||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||
"you are writing. For example, if you were writing the\n"
|
||||
"Present Value property, use 85 as the property.\n"
|
||||
"priority:\n"
|
||||
"Present Value property, use 85 as the property.\n");
|
||||
printf("\n");
|
||||
printf("priority:\n"
|
||||
"This parameter is used for setting the priority of the\n"
|
||||
"write. If Priority 0 is given, no priority is sent. The BACnet \n"
|
||||
"standard states that the value is written at the lowest \n"
|
||||
"priority (16) if the object property supports priorities\n"
|
||||
"when no priority is sent.\n"
|
||||
"\n"
|
||||
"index\n"
|
||||
"when no priority is sent.\n");
|
||||
printf("\n");
|
||||
printf("index:\n"
|
||||
"This integer parameter is the index number of an array.\n"
|
||||
"If the property is an array, individual elements can be written\n"
|
||||
"to if supported. If this parameter is -1, the index is ignored.\n"
|
||||
"\n"
|
||||
"tag:\n"
|
||||
"to if supported. If this parameter is -1, the index is ignored.\n");
|
||||
printf("\n");
|
||||
printf("tag:\n"
|
||||
"Tag is the integer value of the enumeration BACNET_APPLICATION_TAG \n"
|
||||
"in bacenum.h. It is the data type of the value that you are\n"
|
||||
"writing. For example, if you were writing a REAL value, you would \n"
|
||||
"use a tag of 4.\n"
|
||||
"Context tags are created using two tags in a row. The context tag\n"
|
||||
"is preceded by a C. Ctag tag. C2 4 creates a context 2 tagged REAL.\n"
|
||||
"\n"
|
||||
"value:\n"
|
||||
"is preceded by a C. Ctag tag. C2 4 creates a context 2 tagged REAL.\n");
|
||||
printf("\n");
|
||||
printf("value:\n"
|
||||
"The value is an ASCII representation of some type of data that you\n"
|
||||
"are writing. It is encoded using the tag information provided. For\n"
|
||||
"example, if you were writing a REAL value of 100.0, you would use \n"
|
||||
"100.0 as the value.\n"
|
||||
"\n"
|
||||
"Here is a brief overview of BACnet property and tags:\n"
|
||||
"100.0 as the value.\n");
|
||||
printf("\n");
|
||||
printf("Here is a brief overview of BACnet property and tags:\n"
|
||||
"Certain properties are expected to be written with certain \n"
|
||||
"application tags, so you probably need to know which ones to use\n"
|
||||
"with each property of each object. It is almost safe to say that\n"
|
||||
"given a property and an object and a table, the tag could be looked\n"
|
||||
"up automatically. There may be a few exceptions to this, such as\n"
|
||||
"the Any property type in the schedule object and the Present Value\n"
|
||||
"accepting REAL, BOOLEAN, NULL, etc. Perhaps it would be simpler for\n"
|
||||
"the demo to use this kind of table - but I also wanted to be able\n"
|
||||
"to do negative testing by passing the wrong tag and have the server\n"
|
||||
"return a reject message.\n\n");
|
||||
"accepting REAL, BOOLEAN, NULL, etc.\n");
|
||||
printf("Perhaps it would be simpler for the demo to use this\n"
|
||||
"kind of table - but this tool can also be used for negative\n"
|
||||
"testing by passing the wrong tag to validate that the server\n"
|
||||
"returns an error, reject, or abort message.\n");
|
||||
printf("\n");
|
||||
printf("Example:\n"
|
||||
"If you want send a value of 100 to the Present-Value in\n"
|
||||
"Analog Output 44 and 45 of Device 123 at priority 16,\n"
|
||||
"send the following command:\n"
|
||||
"%s 123 1 44 85 16 4 100 1 45 85 16 4 100\n",
|
||||
"If you want write a value of 100 to the Present-Value in\n"
|
||||
"Analog Output 44 and 45 of Device 123 at priority 16,\n"
|
||||
"send the following command:\n"
|
||||
"%s 123 1 44 85 16 4 100 1 45 85 16 4 100\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user