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:
@@ -17,11 +17,23 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -qq libconfig-dev
|
||||
- name: Build Demo Apps
|
||||
- name: Build Demo Apps GNU89
|
||||
run: |
|
||||
gcc --version
|
||||
make clean
|
||||
make all
|
||||
make CSTANDARD="-std=gnu89" all
|
||||
- name: Build Demo Apps GNU99
|
||||
run: |
|
||||
make clean
|
||||
make CSTANDARD="-std=gnu99" all
|
||||
- name: Build Demo Apps GNU11
|
||||
run: |
|
||||
make clean
|
||||
make CSTANDARD="-std=gnu11" all
|
||||
- name: Build Demo Apps GNU17
|
||||
run: |
|
||||
make clean
|
||||
make CSTANDARD="-std=gnu17" all
|
||||
|
||||
bip-no-bbmd-apps:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+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);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
|
||||
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)addr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,6 +231,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)addr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -255,6 +257,7 @@ bool bip_get_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_subnet_prefix(uint8_t prefix)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)prefix;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -336,7 +339,7 @@ uint16_t bip_receive(
|
||||
int max = 0;
|
||||
struct timeval select_timeout;
|
||||
struct sockaddr_in sin = { 0 };
|
||||
BACNET_IP_ADDRESS addr = { { 0 } };
|
||||
BACNET_IP_ADDRESS addr = { 0 };
|
||||
socklen_t sin_len = sizeof(sin);
|
||||
int received_bytes = 0;
|
||||
int offset = 0;
|
||||
@@ -657,6 +660,8 @@ static void parseRoutes(struct nlmsghdr *nlHdr, struct route_info *rtInfo)
|
||||
case RTA_DST:
|
||||
rtInfo->dstAddr = *(u_int *)RTA_DATA(rtAttr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ static struct timespec start;
|
||||
static int timespec_subtract(
|
||||
struct timespec *result, const struct timespec *l, const struct timespec *r)
|
||||
{
|
||||
#define NS_PER_S 1000000000 // nano-seconds per second
|
||||
#define NS_PER_S 1000000000 /* nano-seconds per second */
|
||||
struct timespec right = *r;
|
||||
int secs;
|
||||
|
||||
// Perform the carry for the later subtraction by updating y.
|
||||
/* Perform the carry for the later subtraction by updating y. */
|
||||
if (l->tv_nsec < right.tv_nsec) {
|
||||
secs = (right.tv_nsec - l->tv_nsec) / NS_PER_S + 1;
|
||||
right.tv_nsec -= NS_PER_S * secs;
|
||||
@@ -133,7 +133,7 @@ static int timespec_subtract(
|
||||
right.tv_sec -= secs;
|
||||
}
|
||||
|
||||
// Compute the time remaining. tv_nsec is certainly positive.
|
||||
/* Compute the time remaining. tv_nsec is certainly positive. */
|
||||
result->tv_sec = l->tv_sec - right.tv_sec;
|
||||
result->tv_nsec = l->tv_nsec - right.tv_nsec;
|
||||
|
||||
|
||||
+8
-7
@@ -632,7 +632,8 @@ void RS485_Print_Ports(void)
|
||||
bool valid_port = false;
|
||||
struct serial_struct serinfo;
|
||||
|
||||
// Scan through /sys/class/tty - it contains all tty-devices in the system
|
||||
/* Scan through /sys/class/tty -
|
||||
it contains all tty-devices in the system */
|
||||
n = scandir(sysdir, &namelist, NULL, NULL);
|
||||
if (n < 0) {
|
||||
perror("RS485: scandir");
|
||||
@@ -642,7 +643,7 @@ void RS485_Print_Ports(void)
|
||||
strcmp(namelist[n]->d_name, ".")) {
|
||||
snprintf(device_dir, sizeof(device_dir), "%s%s/device", sysdir,
|
||||
namelist[n]->d_name);
|
||||
// Stat the devicedir and handle it if it is a symlink
|
||||
/* Stat the devicedir and handle it if it is a symlink */
|
||||
if (lstat(device_dir, &st) == 0 && S_ISLNK(st.st_mode)) {
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
snprintf(device_dir, sizeof(device_dir),
|
||||
@@ -651,16 +652,16 @@ void RS485_Print_Ports(void)
|
||||
valid_port = false;
|
||||
driver_name = basename(buffer);
|
||||
if (strcmp(driver_name, "serial8250") == 0) {
|
||||
// serial8250-devices must be probed
|
||||
/* serial8250-devices must be probed */
|
||||
snprintf(device_dir, sizeof(device_dir), "/dev/%s",
|
||||
namelist[n]->d_name);
|
||||
fd = open(
|
||||
device_dir, O_RDWR | O_NONBLOCK | O_NOCTTY);
|
||||
if (fd >= 0) {
|
||||
// Get serial_info
|
||||
/* Get serial_info */
|
||||
if (ioctl(fd, TIOCGSERIAL, &serinfo) == 0) {
|
||||
// If device type is not PORT_UNKNOWN
|
||||
// we accept the port
|
||||
/* If device type is not PORT_UNKNOWN */
|
||||
/* we accept the port */
|
||||
if (serinfo.type != PORT_UNKNOWN) {
|
||||
valid_port = true;
|
||||
}
|
||||
@@ -671,7 +672,7 @@ void RS485_Print_Ports(void)
|
||||
valid_port = true;
|
||||
}
|
||||
if (valid_port) {
|
||||
// print full absolute file path
|
||||
/* print full absolute file path */
|
||||
printf("interface {value=/dev/%s}"
|
||||
"{display=MS/TP Capture on /dev/%s}\n",
|
||||
namelist[n]->d_name, namelist[n]->d_name);
|
||||
|
||||
@@ -158,8 +158,16 @@ CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
CFLAGS += -fno-builtin
|
||||
# place uninitialized global variables in the data section of the object file.
|
||||
CFLAGS += -fno-common
|
||||
# enable all relevant warnings
|
||||
CFLAGS += -Wall
|
||||
# enable all relevant warnings that find bugs
|
||||
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
|
||||
CFLAGS += $(WARNING_ALL)
|
||||
# don't warn about missing braces since GCC is over-achiever for this
|
||||
CFLAGS += -Wno-missing-braces
|
||||
# don't warn about missing prototypes since STM32 library doesn't have some
|
||||
|
||||
+39
-36
@@ -38,7 +38,8 @@
|
||||
#include <stdlib.h> /* for strtol */
|
||||
#include <ctype.h> /* for isalnum */
|
||||
#include <errno.h>
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#include <math.h>
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#endif
|
||||
@@ -1168,9 +1169,9 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
// NOTE:
|
||||
// When adding impl for a new prop, also add its tag
|
||||
// to bacapp_known_property_tag()
|
||||
/* NOTE: */
|
||||
/* When adding impl for a new prop, also add its tag */
|
||||
/* to bacapp_known_property_tag() */
|
||||
|
||||
int tag = bacapp_known_property_tag(object_type, property);
|
||||
if (tag != -1) {
|
||||
@@ -1690,7 +1691,7 @@ static int bacapp_snprintf_weeklyschedule(char *str,
|
||||
"Sun" };
|
||||
const int loopend = ((arrayIndex == BACNET_ARRAY_ALL) ? 7 : 1);
|
||||
|
||||
// Find what inner type it uses
|
||||
/* Find what inner type it uses */
|
||||
int inner_tag = -1;
|
||||
for (wi = 0; wi < loopend; wi++) {
|
||||
BACNET_DAILY_SCHEDULE *ds = &ws->weeklySchedule[wi];
|
||||
@@ -1837,7 +1838,7 @@ int bacapp_snprintf_value(
|
||||
#if defined(BACAPP_OCTET_STRING) || defined(BACAPP_TYPES_EXTRA)
|
||||
uint8_t *octet_str;
|
||||
#endif
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
/* Wide character (decoded from multi-byte character). */
|
||||
wchar_t wc;
|
||||
/* Wide character length in bytes. */
|
||||
@@ -1917,7 +1918,7 @@ int bacapp_snprintf_value(
|
||||
}
|
||||
}
|
||||
ret_val += slen;
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||
if (characterstring_encoding(&value->type.Character_String) ==
|
||||
CHARACTER_UTF8) {
|
||||
while (len > 0) {
|
||||
@@ -2164,7 +2165,7 @@ int bacapp_snprintf_value(
|
||||
ret_val += slen;
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_TIMESTAMP:
|
||||
//ISO 8601 format
|
||||
/*ISO 8601 format */
|
||||
slen = snprintf(str, str_len, "%04u-%02u-%02uT%02u:%02u:%02u.%03u",
|
||||
(unsigned) value->type.Time_Stamp.value.dateTime.date.year,
|
||||
(unsigned) value->type.Time_Stamp.value.dateTime.date.month,
|
||||
@@ -2358,10 +2359,12 @@ static char *ltrim(char *str, const char *trimmedchars)
|
||||
|
||||
static char *rtrim(char *str, const char *trimmedchars)
|
||||
{
|
||||
char *end;
|
||||
|
||||
if (str[0] == 0) {
|
||||
return str;
|
||||
}
|
||||
char *end = str + strlen(str) - 1;
|
||||
end = str + strlen(str) - 1;
|
||||
while (strchr(trimmedchars, *end)) {
|
||||
*end = 0;
|
||||
if (end == str)
|
||||
@@ -2380,7 +2383,7 @@ static char *trim(char *str, const char *trimmedchars)
|
||||
static bool parse_weeklyschedule(
|
||||
char *str, BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
char *chunk, *comma, *space, *t, *v;
|
||||
char *chunk, *comma, *space, *t, *v, *colonpos, *sqpos;
|
||||
int daynum = 0, tvnum = 0;
|
||||
unsigned int inner_tag;
|
||||
BACNET_APPLICATION_DATA_VALUE dummy_value = { 0 };
|
||||
@@ -2402,13 +2405,13 @@ static bool parse_weeklyschedule(
|
||||
|
||||
value->tag = BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE;
|
||||
|
||||
// Parse the inner tag
|
||||
/* Parse the inner tag */
|
||||
chunk = strtok(str, ";");
|
||||
chunk = ltrim(chunk, "(");
|
||||
if (false ==
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT, chunk, &dummy_value)) {
|
||||
// Try searching it by name
|
||||
/* Try searching it by name */
|
||||
if (false == bactext_application_tag_index(chunk, &inner_tag)) {
|
||||
return false;
|
||||
}
|
||||
@@ -2421,43 +2424,43 @@ static bool parse_weeklyschedule(
|
||||
while (chunk != NULL) {
|
||||
dsch = &value->type.Weekly_Schedule.weeklySchedule[daynum];
|
||||
|
||||
// Strip day name prefix, if present
|
||||
char *colonpos = strchr(chunk, ':');
|
||||
char *sqpos = strchr(chunk, '[');
|
||||
/* Strip day name prefix, if present */
|
||||
colonpos = strchr(chunk, ':');
|
||||
sqpos = strchr(chunk, '[');
|
||||
if (colonpos && colonpos < sqpos) {
|
||||
chunk = colonpos + 1;
|
||||
}
|
||||
|
||||
// Extract the inner list of time-values
|
||||
/* Extract the inner list of time-values */
|
||||
chunk = rtrim(ltrim(chunk, "([ "), " ])");
|
||||
|
||||
// The list can be empty
|
||||
/* The list can be empty */
|
||||
if (chunk[0] != 0) {
|
||||
// loop through the time value pairs
|
||||
/* loop through the time value pairs */
|
||||
tvnum = 0;
|
||||
do {
|
||||
// Find the comma delimiter, replace with NUL (like strtok)
|
||||
/* Find the comma delimiter, replace with NUL (like strtok) */
|
||||
comma = strchr(chunk, ',');
|
||||
if (comma) {
|
||||
*comma = 0;
|
||||
}
|
||||
// trim the time-value pair and find the delimiter space
|
||||
/* trim the time-value pair and find the delimiter space */
|
||||
chunk = trim(chunk, " ");
|
||||
space = strchr(chunk, ' ');
|
||||
if (!space) {
|
||||
// malformed time-value pair
|
||||
/* malformed time-value pair */
|
||||
return false;
|
||||
}
|
||||
*space = 0;
|
||||
|
||||
// Extract time and value
|
||||
/* Extract time and value */
|
||||
t = chunk;
|
||||
// value starts one byte after the space, and there can be
|
||||
// multiple spaces
|
||||
/* value starts one byte after the space, and there can be */
|
||||
/* multiple spaces */
|
||||
chunk = ltrim(space + 1, " ");
|
||||
v = chunk;
|
||||
|
||||
// Parse time
|
||||
/* Parse time */
|
||||
if (false ==
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
||||
@@ -2465,7 +2468,7 @@ static bool parse_weeklyschedule(
|
||||
}
|
||||
dsch->Time_Values[tvnum].Time = dummy_value.type.Time;
|
||||
|
||||
// Parse value
|
||||
/* Parse value */
|
||||
if (false ==
|
||||
bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
||||
return false;
|
||||
@@ -2476,7 +2479,7 @@ static bool parse_weeklyschedule(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Advance past the comma to the next chunk
|
||||
/* Advance past the comma to the next chunk */
|
||||
if (comma) {
|
||||
chunk = comma + 1;
|
||||
}
|
||||
@@ -2486,7 +2489,7 @@ static bool parse_weeklyschedule(
|
||||
|
||||
dsch->TV_Count = tvnum;
|
||||
|
||||
// Find the start of the next day
|
||||
/* Find the start of the next day */
|
||||
chunk = strtok(NULL, ";");
|
||||
daynum++;
|
||||
}
|
||||
@@ -2506,11 +2509,11 @@ static bool strtol_checked(const char *s, long *out)
|
||||
errno = 0;
|
||||
*out = strtol(s, &end, 0);
|
||||
if (end == s) {
|
||||
// Conversion was not possible
|
||||
/* Conversion was not possible */
|
||||
return false;
|
||||
}
|
||||
if (errno == ERANGE) {
|
||||
// Number too large
|
||||
/* Number too large */
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2524,11 +2527,11 @@ static bool strtoul_checked(const char *s, BACNET_UNSIGNED_INTEGER *out)
|
||||
errno = 0;
|
||||
*out = strtoul(s, &end, 0);
|
||||
if (end == s) {
|
||||
// Conversion was not possible
|
||||
/* Conversion was not possible */
|
||||
return false;
|
||||
}
|
||||
if (errno == ERANGE) {
|
||||
// Number too large
|
||||
/* Number too large */
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2542,11 +2545,11 @@ static bool strtod_checked(const char *s, double *out)
|
||||
errno = 0;
|
||||
*out = strtod(s, &end);
|
||||
if (end == s) {
|
||||
// Conversion was not possible
|
||||
/* Conversion was not possible */
|
||||
return false;
|
||||
}
|
||||
if (errno == ERANGE) {
|
||||
// Number too large
|
||||
/* Number too large */
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2869,14 +2872,14 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
#endif
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
if (test_value->type.Real == value->type.Real) {
|
||||
if (!islessgreater(test_value->type.Real, value->type.Real)) {
|
||||
status = true;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
if (test_value->type.Double == value->type.Double) {
|
||||
if (!islessgreater(test_value->type.Double,value->type.Double)) {
|
||||
status = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2066,7 +2066,7 @@ typedef enum BACnetColorTransition {
|
||||
BACNET_COLOR_TRANSITION_NONE = 0,
|
||||
BACNET_COLOR_TRANSITION_FADE = 1,
|
||||
BACNET_COLOR_TRANSITION_RAMP = 2,
|
||||
BACNET_COLOR_TRANSITION_MAX = 3,
|
||||
BACNET_COLOR_TRANSITION_MAX = 3
|
||||
} BACNET_COLOR_TRANSITION;
|
||||
|
||||
/* NOTE: BACNET_DAYS_OF_WEEK is different than BACNET_WEEKDAY */
|
||||
|
||||
@@ -900,6 +900,8 @@ bool utf8_isvalid(const char *str, size_t length)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for valid bytes after the 2nd, if any; all must start 10 */
|
||||
|
||||
@@ -79,6 +79,7 @@ int bacnet_time_value_encode(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
uint8_t *apdu_offset = NULL;
|
||||
BACNET_APPLICATION_DATA_VALUE adv;
|
||||
|
||||
if (!value || !is_data_value_schedule_compatible(value->Value.tag)) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
@@ -93,10 +94,7 @@ int bacnet_time_value_encode(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
|
||||
BACNET_APPLICATION_DATA_VALUE adv;
|
||||
bacnet_primitive_to_application_data_value(&adv, &value->Value);
|
||||
|
||||
len = bacapp_encode_application_data(apdu_offset, &adv);
|
||||
apdu_len += len;
|
||||
|
||||
@@ -147,7 +145,7 @@ int bacnet_application_to_primitive_data_value(
|
||||
struct BACnet_Primitive_Data_Value *dest,
|
||||
const struct BACnet_Application_Data_Value *src)
|
||||
{
|
||||
// make sure the value passed is valid
|
||||
/* make sure the value passed is valid */
|
||||
if (!src || !dest || !is_data_value_schedule_compatible(src->tag)) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -162,7 +160,7 @@ int bacnet_primitive_to_application_data_value(
|
||||
struct BACnet_Application_Data_Value *dest,
|
||||
const struct BACnet_Primitive_Data_Value *src)
|
||||
{
|
||||
// make sure the value passed is valid
|
||||
/* make sure the value passed is valid */
|
||||
if (!dest || !src) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -39,14 +39,10 @@
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/proplist.h"
|
||||
#include "bacnet/timestamp.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/object/ai.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
#ifndef MAX_ANALOG_INPUTS
|
||||
#define MAX_ANALOG_INPUTS 4
|
||||
|
||||
@@ -236,12 +236,14 @@ bool Analog_Value_Present_Value_Set(
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
|
||||
(void)priority;
|
||||
index = Analog_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_ANALOG_VALUES) {
|
||||
Analog_Value_COV_Detect(index, value);
|
||||
AV_Descr[index].Present_Value = value;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1136,6 +1138,8 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -657,6 +657,7 @@ int Channel_Value_Encode(
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
|
||||
(void)apdu_max;
|
||||
if (!apdu || !value) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -907,7 +908,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
if (value->type.Real != 0.0F) {
|
||||
if (islessgreater(value->type.Real, 0.0F)) {
|
||||
boolean_value = true;
|
||||
}
|
||||
apdu_len =
|
||||
@@ -954,7 +955,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
if (value->type.Double != 0.0) {
|
||||
if (islessgreater(value->type.Double, 0.0)) {
|
||||
boolean_value = true;
|
||||
}
|
||||
apdu_len =
|
||||
|
||||
@@ -820,4 +820,5 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
void Command_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
(void)object_instance;
|
||||
}
|
||||
|
||||
@@ -39,16 +39,9 @@
|
||||
#include "bacnet/basic/object/ao.h"
|
||||
#include "bacnet/wp.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
|
||||
#ifndef LOAD_CONTROL_DEBUG
|
||||
#define LOAD_CONTROL_DEBUG 0
|
||||
#endif
|
||||
#if LOAD_CONTROL_DEBUG
|
||||
#include <sys/PRINTF.h>
|
||||
#define PRINTF(...) printk(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_printf
|
||||
|
||||
/* number of demo objects */
|
||||
#ifndef MAX_LOAD_CONTROLS
|
||||
@@ -67,7 +60,7 @@ typedef enum BACnetShedLevelType {
|
||||
|
||||
#define DEFAULT_VALUE_PERCENT 100
|
||||
#define DEFAULT_VALUE_LEVEL 0
|
||||
#define DEFAULT_VALUE_AMOUNT 0
|
||||
#define DEFAULT_VALUE_AMOUNT 0.0
|
||||
|
||||
/* The shed levels for the LEVEL choice of BACnetShedLevel
|
||||
that have meaning for this particular Load Control object. */
|
||||
@@ -423,7 +416,7 @@ void Load_Control_State_Machine(int object_index)
|
||||
}
|
||||
break;
|
||||
case BACNET_SHED_TYPE_AMOUNT:
|
||||
if (Requested_Shed_Level[object_index].value.amount ==
|
||||
if (Requested_Shed_Level[object_index].value.amount <=
|
||||
DEFAULT_VALUE_AMOUNT) {
|
||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||
}
|
||||
@@ -431,7 +424,7 @@ void Load_Control_State_Machine(int object_index)
|
||||
case BACNET_SHED_TYPE_LEVEL:
|
||||
default:
|
||||
if (Requested_Shed_Level[object_index].value.level ==
|
||||
DEFAULT_VALUE_LEVEL) {
|
||||
DEFAULT_VALUE_LEVEL) {
|
||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1228,7 +1228,12 @@ static void Lighting_Output_Ramp_Handler(struct lighting_output_object *pLight,
|
||||
BACNET_LIGHTING_COMMAND *pCommand,
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
if (pLight && pCommand) { }
|
||||
if (pLight && pCommand) {
|
||||
/* FIXME: add ramp functionality */
|
||||
(void)pLight;
|
||||
(void)pCommand;
|
||||
(void)milliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1243,7 +1248,12 @@ static void Lighting_Output_Fade_Handler(struct lighting_output_object *pLight,
|
||||
BACNET_LIGHTING_COMMAND *pCommand,
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
if (pLight && pCommand) { }
|
||||
if (pLight && pCommand) {
|
||||
/* FIXME: add fade functionality */
|
||||
(void)pLight;
|
||||
(void)pCommand;
|
||||
(void)milliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,7 @@ bool Multistate_Input_Valid_Instance(uint32_t object_instance)
|
||||
|
||||
static uint32_t Multistate_Input_Max_States(uint32_t instance)
|
||||
{
|
||||
(void)instance;
|
||||
return MULTISTATE_NUMBER_OF_STATES;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,17 +43,13 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/event.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/wp.h"
|
||||
#include "bacnet/basic/object/nc.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
#ifndef MAX_NOTIFICATION_CLASSES
|
||||
#define MAX_NOTIFICATION_CLASSES 2
|
||||
@@ -747,8 +743,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
* &src); */
|
||||
}
|
||||
}
|
||||
|
||||
status = true;
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_NAME:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -2561,6 +2561,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
*/
|
||||
int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
{
|
||||
(void)apdu;
|
||||
(void)pRequest;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2574,6 +2576,8 @@ int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
*/
|
||||
int Network_Port_Read_Range_FDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
{
|
||||
(void)apdu;
|
||||
(void)pRequest;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@ bool OctetString_Value_Present_Value_Set(
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
|
||||
(void)priority;
|
||||
index = OctetString_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_OCTETSTRING_VALUES) {
|
||||
octetstring_copy(&OSV_Descr[index].Present_Value, value);
|
||||
@@ -354,4 +355,5 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
void OctetString_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
(void)object_instance;
|
||||
}
|
||||
|
||||
@@ -140,11 +140,13 @@ bool PositiveInteger_Value_Present_Value_Set(
|
||||
unsigned index = 0;
|
||||
bool status = false;
|
||||
|
||||
(void)priority;
|
||||
index = PositiveInteger_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_POSITIVEINTEGER_VALUES) {
|
||||
PIV_Descr[index].Present_Value = value;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -359,4 +361,5 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
void PositiveInteger_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
(void)object_instance;
|
||||
}
|
||||
|
||||
@@ -1498,6 +1498,9 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
||||
case TL_TYPE_ANY:
|
||||
/* Should never happen as we don't support this at the moment */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
iLen += encode_closing_tag(&apdu[iLen], 1);
|
||||
|
||||
@@ -39,14 +39,10 @@
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
|
||||
/** @file h_ccov.c Handles Confirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
/* max number of COV properties decoded in a COV notification */
|
||||
#ifndef MAX_COV_PROPERTIES
|
||||
|
||||
@@ -65,6 +65,8 @@ void get_alarm_summary_ack_handler(uint8_t *service_request,
|
||||
uint16_t len = 0;
|
||||
BACNET_GET_ALARM_SUMMARY_DATA data;
|
||||
|
||||
(void)src;
|
||||
(void)service_data;
|
||||
while (service_len - len) {
|
||||
apdu_len = get_alarm_summary_ack_decode_apdu_data(
|
||||
&service_request[len], service_len - len, &data);
|
||||
|
||||
@@ -67,6 +67,8 @@ void handler_get_alarm_summary(uint8_t *service_request,
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
BACNET_GET_ALARM_SUMMARY_DATA getalarm_data;
|
||||
|
||||
(void)service_request;
|
||||
(void)service_len;
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
@@ -51,11 +51,11 @@ static get_event_info_function Get_Event_Info[MAX_BACNET_OBJECT_TYPE];
|
||||
void ge_ack_print_data(
|
||||
BACNET_GET_EVENT_INFORMATION_DATA *data, uint32_t device_id)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
BACNET_GET_EVENT_INFORMATION_DATA *act_data = data;
|
||||
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
|
||||
printf("DeviceID\tType\tInstance\teventState\n");
|
||||
printf("--------------- ------- --------------- ---------------\n");
|
||||
unsigned int count = 0;
|
||||
while (act_data) {
|
||||
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
|
||||
act_data->objectIdentifier.type,
|
||||
|
||||
@@ -72,6 +72,8 @@ void get_event_ack_handler(uint8_t *service_request,
|
||||
multiple get event data in APDU */
|
||||
BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS];
|
||||
|
||||
(void)src;
|
||||
(void)service_data;
|
||||
for (i = 1; i < MAX_NUMBER_OF_EVENTS; i++) {
|
||||
/* Create linked list */
|
||||
get_event_data[i - 1].next = &get_event_data[i];
|
||||
|
||||
@@ -38,15 +38,10 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
#endif
|
||||
#define PRINTF debug_aprintf
|
||||
#define PRINTF_ERR debug_perror
|
||||
|
||||
/** @file h_rp_a.c Handles Read Property Acknowledgments. */
|
||||
|
||||
|
||||
@@ -37,16 +37,11 @@
|
||||
/* some demo stuff needed */
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
#endif
|
||||
#define PRINTF debug_aprintf
|
||||
#define PERROR debug_perror
|
||||
|
||||
/** @file h_rpm_a.c Handles Read Property Multiple Acknowledgments. */
|
||||
|
||||
@@ -130,7 +125,7 @@ int rpm_ack_decode_service_request(
|
||||
/* If len == 0 then it's an empty structure, which is OK. */
|
||||
if (len < 0) {
|
||||
/* problem decoding */
|
||||
PRINTF_ERR("RPM Ack: unable to decode! %s:%s\n",
|
||||
PERROR("RPM Ack: unable to decode! %s:%s\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier));
|
||||
@@ -151,7 +146,7 @@ int rpm_ack_decode_service_request(
|
||||
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
old_value->next = value;
|
||||
} else {
|
||||
PRINTF_ERR("RPM Ack: decoded %s:%s len=%d\n",
|
||||
PERROR("RPM Ack: decoded %s:%s len=%d\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier),
|
||||
@@ -362,7 +357,7 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
}
|
||||
} else {
|
||||
PRINTF_ERR("RPM Ack Malformed! Freeing memory...\n");
|
||||
PERROR("RPM Ack Malformed! Freeing memory...\n");
|
||||
while (rpm_data) {
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
}
|
||||
|
||||
@@ -36,15 +36,11 @@
|
||||
#include "bacnet/cov.h"
|
||||
#include "bacnet/bactext.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
|
||||
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
#ifndef MAX_COV_PROPERTIES
|
||||
#define MAX_COV_PROPERTIES 2
|
||||
|
||||
@@ -111,6 +111,7 @@ void handler_unconfirmed_private_transfer(
|
||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||
int len = 0;
|
||||
|
||||
(void)src;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
|
||||
#endif
|
||||
|
||||
@@ -41,15 +41,11 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
/** @file h_wpm.c Handles Write Property Multiple requests. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
/** Decoding for an object property.
|
||||
*
|
||||
|
||||
@@ -38,16 +38,12 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
#define PRINTF debug_perror
|
||||
|
||||
/** Sends an Confirmed Alarm Acknowledgment.
|
||||
*
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
#include "bacnet/basic/sys/bigend.h"
|
||||
|
||||
#ifndef BACNET_BIG_ENDIAN
|
||||
#ifdef BACNET_BIG_ENDIAN
|
||||
/* workaround: warning: ISO C forbids an empty translation unit [-Wpedantic] */
|
||||
typedef int make_iso_compilers_happy;
|
||||
#else
|
||||
/* Big-Endian systems save the most significant byte first. */
|
||||
/* Sun and Motorola processors, IBM-370s and PDP-10s are big-endian. */
|
||||
/* "Network Byte Order" is also know as "Big-Endian Byte Order" */
|
||||
|
||||
@@ -50,6 +50,8 @@ void color_rgb_to_xy(uint8_t r,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness)
|
||||
{
|
||||
float X, Y, Z;
|
||||
float x, y;
|
||||
/* Get the RGB values from your color object
|
||||
and convert them to be between 0 and 1.
|
||||
So the RGB color (255, 0, 100) becomes (1.0, 0.0, 0.39) */
|
||||
@@ -76,13 +78,13 @@ void color_rgb_to_xy(uint8_t r,
|
||||
|
||||
/* Convert the RGB values to XYZ using the
|
||||
Wide RGB D65 conversion formula */
|
||||
float X = red * 0.649926f + green * 0.103455f + blue * 0.197109f;
|
||||
float Y = red * 0.234327f + green * 0.743075f + blue * 0.022598f;
|
||||
float Z = red * 0.0000000f + green * 0.053077f + blue * 1.035763f;
|
||||
X = red * 0.649926f + green * 0.103455f + blue * 0.197109f;
|
||||
Y = red * 0.234327f + green * 0.743075f + blue * 0.022598f;
|
||||
Z = red * 0.0000000f + green * 0.053077f + blue * 1.035763f;
|
||||
|
||||
/* Calculate the xy values from the XYZ values */
|
||||
float x = X / (X + Y + Z);
|
||||
float y = Y / (X + Y + Z);
|
||||
x = X / (X + Y + Z);
|
||||
y = Y / (X + Y + Z);
|
||||
|
||||
x = clamp(x, 0.0f, 1.0f);
|
||||
y = clamp(y, 0.0f, 1.0f);
|
||||
@@ -122,20 +124,23 @@ void color_rgb_from_xy(uint8_t *red,
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
float r, g, b;
|
||||
float x, y, z, X, Y, Z;
|
||||
|
||||
/* Calculate XYZ values */
|
||||
float x = x_coordinate;
|
||||
float y = y_coordinate;
|
||||
float z = 1.0f - x - y;
|
||||
float Y = (float)brightness;
|
||||
x = x_coordinate;
|
||||
y = y_coordinate;
|
||||
z = 1.0f - x - y;
|
||||
Y = (float)brightness;
|
||||
Y /= 255.0f;
|
||||
float X = (Y / y) * x;
|
||||
float Z = (Y / y) * z;
|
||||
X = x * (Y / y);
|
||||
Z = z * (Y / y);
|
||||
|
||||
/* Convert to RGB using Wide RGB D65 conversion
|
||||
(THIS IS A D50 conversion currently) */
|
||||
float r = X * 1.4628067f - Y * 0.1840623f - Z * 0.2743606f;
|
||||
float g = -X * 0.5217933f + Y * 1.4472381f + Z * 0.0677227f;
|
||||
float b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||
r = X * 1.4628067f - Y * 0.1840623f - Z * 0.2743606f;
|
||||
g = -X * 0.5217933f + Y * 1.4472381f + Z * 0.0677227f;
|
||||
b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||
|
||||
/* Apply reverse gamma correction */
|
||||
r = r <= 0.0031308f ? 12.92f * r
|
||||
|
||||
@@ -59,3 +59,59 @@ void debug_printf(const char *format, ...)
|
||||
(void)format;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PRINT_ENABLED
|
||||
int debug_aprintf(const char *format, ...)
|
||||
{
|
||||
int length = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
length = vfprintf(stdout, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stdout);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
int debug_fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
int length = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
length = vfprintf(stream, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stream);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void debug_perror(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stderr);
|
||||
}
|
||||
#else
|
||||
int debug_aprintf(const char *format, ...)
|
||||
{
|
||||
(void)format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int debug_fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
(void)stream;
|
||||
(void)format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void debug_perror(const char *format, ...)
|
||||
{
|
||||
(void)format;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -42,6 +42,19 @@ extern "C" {
|
||||
void debug_printf(
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
int debug_aprintf(
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
int debug_fprintf(
|
||||
FILE *stream,
|
||||
const char *format,
|
||||
...);
|
||||
BACNET_STACK_EXPORT
|
||||
void debug_perror(
|
||||
const char *format,
|
||||
...);
|
||||
#if DEBUG_ENABLED
|
||||
/* Nothing more here */
|
||||
#else
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
#ifndef BACNET_SYS_PLATFORM_H
|
||||
#define BACNET_SYS_PLATFORM_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef islessgreater
|
||||
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
|
||||
#endif
|
||||
|
||||
/* marking some code as 'deprecated' */
|
||||
# if defined(_MSC_VER)
|
||||
# define BACNET_STACK_DEPRECATED(message) __declspec(deprecated(message))
|
||||
@@ -31,4 +37,10 @@
|
||||
# define strcasecmp _stricmp
|
||||
# endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define BACNET_STACK_FALLTHROUGH() __attribute__ ((fallthrough))
|
||||
#else
|
||||
#define BACNET_STACK_FALLTHROUGH() /* fall through */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,6 +65,7 @@ static int notify_encode_apdu(
|
||||
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
||||
BACNET_APPLICATION_DATA_VALUE *app_data = NULL;
|
||||
|
||||
(void)max_apdu_len;
|
||||
if (apdu) {
|
||||
/* tag 0 - subscriberProcessIdentifier */
|
||||
len = encode_context_unsigned(
|
||||
@@ -405,6 +406,7 @@ int cov_subscribe_encode_apdu(uint8_t *apdu,
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
(void)max_apdu_len;
|
||||
if (apdu && data) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
@@ -554,6 +556,7 @@ int cov_subscribe_property_encode_apdu(uint8_t *apdu,
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
(void)max_apdu_len;
|
||||
if (apdu && data) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
||||
|
||||
@@ -215,9 +215,6 @@ static int bbmd_register_as_foreign_device(void)
|
||||
pEnv = getenv(bbmd_env);
|
||||
if (pEnv) {
|
||||
bdt_entry_port = strtol(pEnv, NULL, 0);
|
||||
if (bdt_entry_port > 0xFFFF) {
|
||||
bdt_entry_port = 0xBAC0;
|
||||
}
|
||||
if (entry_number == 1) {
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr, "BBMD 1 port overridden %s=%s!\n",
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
#include "bacnet/bacreal.h"
|
||||
#include "bacnet/lighting.h"
|
||||
|
||||
#ifndef islessgreater
|
||||
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
|
||||
#endif
|
||||
|
||||
/** @file lighting.c Manipulate BACnet lighting command values */
|
||||
|
||||
/**
|
||||
@@ -604,8 +600,8 @@ bool xy_color_same(BACNET_XY_COLOR *value1, BACNET_XY_COLOR *value2)
|
||||
bool status = false;
|
||||
|
||||
if (value1 && value2) {
|
||||
if ((value1->x_coordinate == value2->x_coordinate) &&
|
||||
(value1->y_coordinate == value2->y_coordinate)) {
|
||||
if (!islessgreater(value1->x_coordinate, value2->x_coordinate) &&
|
||||
!islessgreater(value1->y_coordinate, value2->y_coordinate)) {
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
@@ -1096,9 +1092,9 @@ bool color_command_same(
|
||||
status = true;
|
||||
break;
|
||||
case BACNET_COLOR_OPERATION_FADE_TO_COLOR:
|
||||
if ((value1->target.color.x_coordinate ==
|
||||
if (!islessgreater(value1->target.color.x_coordinate,
|
||||
value2->target.color.x_coordinate) &&
|
||||
(value1->target.color.y_coordinate ==
|
||||
!islessgreater(value1->target.color.y_coordinate,
|
||||
value2->target.color.y_coordinate) &&
|
||||
(value1->transit.fade_time == value2->transit.fade_time)) {
|
||||
status = true;
|
||||
|
||||
@@ -155,24 +155,27 @@ int bacnet_weeklyschedule_context_decode(uint8_t *apdu,
|
||||
bool bacnet_weeklyschedule_same(
|
||||
BACNET_WEEKLY_SCHEDULE *value1, BACNET_WEEKLY_SCHEDULE *value2)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE adv1, adv2;
|
||||
BACNET_DAILY_SCHEDULE *ds1, *ds2;
|
||||
BACNET_TIME_VALUE *tv1, *tv2;
|
||||
int wi, ti;
|
||||
|
||||
for (wi = 0; wi < 7; wi++) {
|
||||
BACNET_DAILY_SCHEDULE *ds1 = &value1->weeklySchedule[wi];
|
||||
BACNET_DAILY_SCHEDULE *ds2 = &value2->weeklySchedule[wi];
|
||||
ds1 = &value1->weeklySchedule[wi];
|
||||
ds2 = &value2->weeklySchedule[wi];
|
||||
if (ds1->TV_Count != ds2->TV_Count) {
|
||||
return false;
|
||||
}
|
||||
for (ti = 0; ti < ds1->TV_Count; ti++) {
|
||||
BACNET_TIME_VALUE *tv1 = &ds1->Time_Values[ti];
|
||||
BACNET_TIME_VALUE *tv2 = &ds2->Time_Values[ti];
|
||||
tv1 = &ds1->Time_Values[ti];
|
||||
tv2 = &ds2->Time_Values[ti];
|
||||
if (0 != datetime_compare_time(&tv1->Time, &tv2->Time)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO the conversion can be avoided by adding a "primitive"
|
||||
// variant of bacapp_same_value(),
|
||||
// at the cost of some code duplication
|
||||
BACNET_APPLICATION_DATA_VALUE adv1, adv2;
|
||||
/* TODO the conversion can be avoided by adding a "primitive"
|
||||
variant of bacapp_same_value(),
|
||||
at the cost of some code duplication */
|
||||
bacnet_primitive_to_application_data_value(&adv1, &tv1->Value);
|
||||
bacnet_primitive_to_application_data_value(&adv2, &tv2->Value);
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/basic/service/h_cov.c
|
||||
${SRC_DIR}/bacnet/basic/service/h_wp.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
${SRC_DIR}/bacnet/basic/tsm/tsm.c
|
||||
${SRC_DIR}/bacnet/datalink/bvlc.c
|
||||
|
||||
Reference in New Issue
Block a user