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: |
|
run: |
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -qq libconfig-dev
|
sudo apt-get install -qq libconfig-dev
|
||||||
- name: Build Demo Apps
|
- name: Build Demo Apps GNU89
|
||||||
run: |
|
run: |
|
||||||
gcc --version
|
gcc --version
|
||||||
make clean
|
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:
|
bip-no-bbmd-apps:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
+20
-5
@@ -94,16 +94,31 @@ BACNET_PORT_DIR = $(realpath ../ports/$(BACNET_PORT))
|
|||||||
BACNET_SRC_DIR = $(realpath ../src)
|
BACNET_SRC_DIR = $(realpath ../src)
|
||||||
|
|
||||||
# Compiler flag to set the C Standard level.
|
# Compiler flag to set the C Standard level.
|
||||||
# c89 - "ANSI" C
|
# c89 - "ANSI" C - ISO C90
|
||||||
# gnu89 - c89 plus GCC extensions
|
# gnu89 - c89 plus GNU extensions
|
||||||
|
# c90 - "ANSI" C - ISO C90
|
||||||
|
# gnu90 - C90 with GNU extensions
|
||||||
# c99 - ISO C99 standard
|
# c99 - ISO C99 standard
|
||||||
# gnu99 - c99 plus GCC extensions
|
# gnu99 - C99 plus GNU extensions
|
||||||
CSTANDARD = -std=gnu89
|
# 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
|
#build for release (default) or debug
|
||||||
OPTIMIZATION ?= -Os
|
OPTIMIZATION ?= -Os
|
||||||
DEBUGGING ?=
|
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
|
# dead code removal
|
||||||
ifeq (${BUILD},debug)
|
ifeq (${BUILD},debug)
|
||||||
OPTIMIZATION = -O0
|
OPTIMIZATION = -O0
|
||||||
|
|||||||
+17
-17
@@ -101,33 +101,33 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Send BACnet Abort message to the network.\n");
|
printf("Send BACnet Abort message to the network.\n");
|
||||||
printf(
|
printf("--mac A\n"
|
||||||
"--mac A\n"
|
|
||||||
"Optional destination BACnet mac address."
|
"Optional destination BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional destination BACnet network number N for directed requests.\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"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network "
|
||||||
"number.\n"
|
"number.\n"
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
printf("abort-reason:\n"
|
printf("abort-reason:\n"
|
||||||
" number from 0 to 65535\n"
|
" number from 0 to 65535\n"
|
||||||
"invoke-id:\n"
|
"invoke-id:\n"
|
||||||
" number from 1 to 255\n"
|
" number from 1 to 255\n"
|
||||||
"server:\n"
|
"server:\n"
|
||||||
" 0=false, 1=true\n"
|
" 0=false, 1=true\n");
|
||||||
"Example:\n"
|
printf("\n");
|
||||||
"%s 3 2 1\n",
|
printf("Example:\n"
|
||||||
|
"%s 3 2 1\n",
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+40
-42
@@ -171,54 +171,52 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Send BACnet AcknowledgedAlarm, message to a device.\n");
|
printf("Send BACnet AcknowledgedAlarm, message to a device.\n");
|
||||||
printf(
|
printf("device-id:\n"
|
||||||
"device-id:\n"
|
|
||||||
"BACnet Device Object Instance number that you are trying to\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"
|
"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"
|
"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"
|
"notifying Device Object 123, the device-instance would be 123.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"process-id:\n"
|
printf("process-id:\n"
|
||||||
"Process Identifier in the receiving device for which the\n"
|
"Process Identifier in the receiving device for which the\n"
|
||||||
"notification is intended.\n"
|
"notification is intended.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-object-type:\n"
|
printf("event-object-type:\n"
|
||||||
"The object type is defined either as the object-type name string\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"
|
"as defined in the BACnet specification, or as the integer value.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-object-instance:\n"
|
printf("event-object-instance:\n"
|
||||||
"The object instance number of the event object.\n"
|
"The object instance number of the event object.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-state-acked:\n"
|
printf("event-state-acked:\n"
|
||||||
"The event-state that for this alarm acknowledge.\n"
|
"The event-state that for this alarm acknowledge.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-time-stamp:\n"
|
printf("event-time-stamp:\n"
|
||||||
"The time-stamp of the event.\n"
|
"The time-stamp of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"ack-source-name\n"
|
printf("ack-source-name\n"
|
||||||
"The source name of the alarm acknowledge.\n"
|
"The source name of the alarm acknowledge.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"ack-time-stamp\n"
|
printf("ack-time-stamp\n"
|
||||||
"The time-stamp of the alarm acknowledge.\n"
|
"The time-stamp of the alarm acknowledge.\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
printf("--mac A\n"
|
printf("--mac A\n"
|
||||||
"Optional BACnet mac address."
|
"Optional BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional BACnet network number N for directed requests.\n"
|
"Optional BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network.\n"
|
||||||
"number.\n"
|
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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");
|
||||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
(void)filename;
|
||||||
"\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|||||||
+11
-10
@@ -31,7 +31,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h> /* for time */
|
#include <time.h> /* for time */
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -587,7 +587,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
if (object_type == OBJECT_DATETIME_VALUE) {
|
if (object_type == OBJECT_DATETIME_VALUE) {
|
||||||
break; /* A special case - no braces for this pair */
|
break; /* A special case - no braces for this pair */
|
||||||
}
|
}
|
||||||
/* Else, fall through to normal processing. */
|
BACNET_STACK_FALLTHROUGH();
|
||||||
default:
|
default:
|
||||||
/* Normal array: open brace */
|
/* Normal array: open brace */
|
||||||
fprintf(stdout, "{ ");
|
fprintf(stdout, "{ ");
|
||||||
@@ -747,7 +747,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
fprintf(stdout, "?");
|
fprintf(stdout, "?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Else, fall through for normal processing. */
|
BACNET_STACK_FALLTHROUGH();
|
||||||
case PROP_DAYLIGHT_SAVINGS_STATUS:
|
case PROP_DAYLIGHT_SAVINGS_STATUS:
|
||||||
case PROP_LOCAL_TIME:
|
case PROP_LOCAL_TIME:
|
||||||
case PROP_LOCAL_DATE: /* Only if !ShowValues */
|
case PROP_LOCAL_DATE: /* Only if !ShowValues */
|
||||||
@@ -760,7 +760,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
fprintf(stdout, "?");
|
fprintf(stdout, "?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Else, fall through and print value: */
|
BACNET_STACK_FALLTHROUGH();
|
||||||
default:
|
default:
|
||||||
bacapp_print_value(stdout, &object_value);
|
bacapp_print_value(stdout, &object_value);
|
||||||
break;
|
break;
|
||||||
@@ -895,6 +895,8 @@ static uint8_t Read_Properties(
|
|||||||
case PROP_SUBORDINATE_LIST:
|
case PROP_SUBORDINATE_LIST:
|
||||||
IsLongArray = true;
|
IsLongArray = true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invoke_id = Send_Read_Property_Request(device_instance, pMyObject->type,
|
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)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
|
(void)filename;
|
||||||
printf("Generates Full EPICS file, including Object and Property List\n");
|
printf("Generates Full EPICS file, including Object and Property List\n");
|
||||||
printf("device-instance:\n"
|
printf("device-instance:\n"
|
||||||
"BACnet Device Object Instance number that you are\n"
|
"BACnet Device Object Instance number that you are\n"
|
||||||
@@ -1120,10 +1123,9 @@ static int CheckCommandLineArgs(int argc, char *argv[])
|
|||||||
} else {
|
} else {
|
||||||
printf("ERROR: invalid Target MAC %s \n", argv[i]);
|
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 */
|
BACNET_STACK_FALLTHROUGH();
|
||||||
/* break; */
|
|
||||||
default:
|
default:
|
||||||
print_usage(filename);
|
print_usage(filename);
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -1462,7 +1464,7 @@ int main(int argc, char *argv[])
|
|||||||
address_init();
|
address_init();
|
||||||
Init_Service_Handlers();
|
Init_Service_Handlers();
|
||||||
dlenv_init();
|
dlenv_init();
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
/* Internationalized programs must call setlocale()
|
/* Internationalized programs must call setlocale()
|
||||||
* to initiate a specific language operation.
|
* to initiate a specific language operation.
|
||||||
* This can be done by calling setlocale() as follows.
|
* This can be done by calling setlocale() as follows.
|
||||||
@@ -1581,8 +1583,7 @@ int main(int argc, char *argv[])
|
|||||||
Print_Device_Heading();
|
Print_Device_Heading();
|
||||||
}
|
}
|
||||||
myState = GET_ALL_REQUEST;
|
myState = GET_ALL_REQUEST;
|
||||||
/* Fall through now */
|
BACNET_STACK_FALLTHROUGH();
|
||||||
|
|
||||||
case GET_ALL_REQUEST:
|
case GET_ALL_REQUEST:
|
||||||
case GET_LIST_OF_ALL_REQUEST:
|
case GET_LIST_OF_ALL_REQUEST:
|
||||||
/* "list" differs in ArrayIndex only */
|
/* "list" differs in ArrayIndex only */
|
||||||
|
|||||||
+10
-12
@@ -104,25 +104,23 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Send BACnet Error message to the network.\n");
|
printf("Send BACnet Error message to the network.\n");
|
||||||
printf(
|
printf("--mac A\n"
|
||||||
"--mac A\n"
|
|
||||||
"Optional destination BACnet mac address."
|
"Optional destination BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional destination BACnet network number N for directed requests.\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"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network.\n"
|
||||||
"number.\n"
|
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
printf("error-class:\n"
|
printf("error-class:\n"
|
||||||
" number from 0 to 65535\n"
|
" number from 0 to 65535\n"
|
||||||
"error-code:\n"
|
"error-code:\n"
|
||||||
|
|||||||
+59
-60
@@ -175,72 +175,71 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Send BACnet ConfirmedEventNotification message to a device.\n");
|
printf("Send BACnet ConfirmedEventNotification message to a device.\n");
|
||||||
printf(
|
printf("device-id:\n"
|
||||||
"device-id:\n"
|
|
||||||
"BACnet Device Object Instance number that you are trying to\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"
|
"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"
|
"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"
|
"notifying Device Object 123, the device-instance would be 123.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"process-id:\n"
|
printf("process-id:\n"
|
||||||
"Process Identifier in the receiving device for which the\n"
|
"Process Identifier in the receiving device for which the\n"
|
||||||
"notification is intended.\n"
|
"notification is intended.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"initiating-device-id: the BACnet Device Object Instance number\n"
|
printf("initiating-device-id: the BACnet Device Object Instance number\n"
|
||||||
"that initiated the ConfirmedEventNotification service request.\n"
|
"that initiated the ConfirmedEventNotification service request.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-object-type:\n"
|
printf("event-object-type:\n"
|
||||||
"The object type is defined either as the object-type name string\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"
|
"as defined in the BACnet specification, or as the integer value.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-object-instance:\n"
|
printf("event-object-instance:\n"
|
||||||
"The object instance number of the event object.\n"
|
"The object instance number of the event object.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"sequence-number:\n"
|
printf("sequence-number:\n"
|
||||||
"The sequence number of the event.\n"
|
"The sequence number of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"notification-class:\n"
|
printf("notification-class:\n"
|
||||||
"The notification-class of the event.\n"
|
"The notification-class of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"priority:\n"
|
printf("priority:\n"
|
||||||
"The priority of the event.\n"
|
"The priority of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"message-text:\n"
|
printf("message-text:\n"
|
||||||
"The message text of the event.\n"
|
"The message text of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"notify-type:\n"
|
printf("notify-type:\n"
|
||||||
"The notify type of the event.\n"
|
"The notify type of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"ack-required:\n"
|
printf("ack-required:\n"
|
||||||
"The ack-required of the event (0=FALSE,1=TRUE).\n"
|
"The ack-required of the event (0=FALSE,1=TRUE).\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"from-state:\n"
|
printf("from-state:\n"
|
||||||
"The from-state of the event.\n"
|
"The from-state of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"to-state:\n"
|
printf("to-state:\n"
|
||||||
"The to-state of the event.\n"
|
"The to-state of the event.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"event-type\n"
|
printf("event-type\n"
|
||||||
"The event-type of the event.\n"
|
"The event-type of the event.\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
printf("--mac A\n"
|
printf("--mac A\n"
|
||||||
"Optional BACnet mac address."
|
"Optional BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional BACnet network number N for directed requests.\n"
|
"Optional BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network.\n"
|
||||||
"number.\n"
|
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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");
|
||||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
printf("\n");
|
||||||
"\n");
|
(void)filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
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 len = 0;
|
||||||
int i;
|
int i;
|
||||||
BACNET_GET_EVENT_INFORMATION_DATA data[MAX_OBJ_IDS_IN_GE_ACK];
|
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++) {
|
for (i = 0; i < MAX_OBJ_IDS_IN_GE_ACK - 1; i++) {
|
||||||
data[i].next = &data[i + 1];
|
data[i].next = &data[i + 1];
|
||||||
}
|
}
|
||||||
@@ -197,10 +199,10 @@ int main(int argc, char *argv[])
|
|||||||
time_t last_seconds = 0;
|
time_t last_seconds = 0;
|
||||||
time_t current_seconds = 0;
|
time_t current_seconds = 0;
|
||||||
time_t timeout_seconds = 0;
|
time_t timeout_seconds = 0;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
LastReceivedObjectIdentifier.instance = 0;
|
LastReceivedObjectIdentifier.instance = 0;
|
||||||
LastReceivedObjectIdentifier.type = 0;
|
LastReceivedObjectIdentifier.type = 0;
|
||||||
|
|
||||||
bool found = false;
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
printf("Usage: %s device-instance\r\n", filename_remove_path(argv[0]));
|
printf("Usage: %s device-instance\r\n", filename_remove_path(argv[0]));
|
||||||
return 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("Send BACnet I-Am message for a device.\n");
|
||||||
printf("--mac A\n"
|
printf("--mac A\n"
|
||||||
"Optional BACnet mac address."
|
"Optional BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional BACnet network number N for directed requests.\n"
|
"Optional BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network number.\n"
|
||||||
"number.\n"
|
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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");
|
||||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
printf("\n");
|
||||||
"--repeat\n"
|
printf("--repeat\n"
|
||||||
"Send the message repeatedly until signalled to quit.\n"
|
"Send the message repeatedly until signalled to quit.\n"
|
||||||
"Default is to not repeat, sending only a single message.\n"
|
"Default is to not repeat, sending only a single message.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--retry C\n"
|
printf("--retry C\n"
|
||||||
"Send the message C number of times\n"
|
"Send the message C number of times\n"
|
||||||
"Default is retry 0, only sending one time.\n"
|
"Default is retry 0, only sending one time.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--delay\n"
|
printf("--delay\n"
|
||||||
"Delay, in milliseconds, between repeated messages.\n"
|
"Delay, in milliseconds, between repeated messages.\n"
|
||||||
"Default delay is 100ms.\n"
|
"Default delay is 100ms.\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
printf(
|
printf("device-instance:\n"
|
||||||
"device-instance:\n"
|
"BACnet device-ID 0..4194303\n");
|
||||||
" BACnet device-ID 0..4194303\n"
|
printf("\n");
|
||||||
"vendor-id:\n"
|
printf("vendor-id:\n"
|
||||||
" Vendor Identifier 0..65535\n"
|
"Vendor Identifier 0..65535\n");
|
||||||
"max-apdu:\n"
|
printf("\n");
|
||||||
" Maximum APDU size 50..65535\n"
|
printf("max-apdu:\n"
|
||||||
"segmentation:\n"
|
"Maximum APDU size 50..65535\n");
|
||||||
" BACnet Segmentation 0=both, 1=transmit, 2=receive, 3=none\n"
|
printf("\n");
|
||||||
"To send an I-Am message for instance=1234 vendor-id=260 max-apdu=480\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",
|
"%s 1234 260 480\n",
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
@@ -213,9 +217,6 @@ int main(int argc, char *argv[])
|
|||||||
} else if (strcmp(argv[argi], "--delay") == 0) {
|
} else if (strcmp(argv[argi], "--delay") == 0) {
|
||||||
if (++argi < argc) {
|
if (++argi < argc) {
|
||||||
timeout = strtol(argv[argi], NULL, 0);
|
timeout = strtol(argv[argi], NULL, 0);
|
||||||
if (timeout < 0) {
|
|
||||||
timeout = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (target_args == 0) {
|
if (target_args == 0) {
|
||||||
|
|||||||
@@ -241,9 +241,9 @@ static void print_help(char *filename)
|
|||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"Send BACnet Initialize-Routing-Table message to a network\n"
|
"Send BACnet Initialize-Routing-Table message to a network\n"
|
||||||
"and wait for responses. Displays their network information.\n"
|
"and wait for responses. Displays their network information.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"address:\n"
|
printf("address:\n"
|
||||||
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\n"
|
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\n"
|
||||||
"DNET ID Len Info:\n"
|
"DNET ID Len Info:\n"
|
||||||
"Port-info data:\n"
|
"Port-info data:\n"
|
||||||
|
|||||||
+5
-3
@@ -401,11 +401,13 @@ static void packet_statistics_clear(void)
|
|||||||
|
|
||||||
static uint32_t Timer_Silence(void *pArg)
|
static uint32_t Timer_Silence(void *pArg)
|
||||||
{
|
{
|
||||||
|
(void)pArg;
|
||||||
return mstimer_elapsed(&Silence_Timer);
|
return mstimer_elapsed(&Silence_Timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Timer_Silence_Reset(void *pArg)
|
static void Timer_Silence_Reset(void *pArg)
|
||||||
{
|
{
|
||||||
|
(void)pArg;
|
||||||
mstimer_set(&Silence_Timer, 0);
|
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"
|
printf("Captures MS/TP packets from a serial interface\n"
|
||||||
"and saves them to a file. Saves packets in a\n"
|
"and saves them to a file. Saves packets in a\n"
|
||||||
"filename mstp_20090123091200.cap that has data and time.\n"
|
"filename mstp_20090123091200.cap that has data and time.\n"
|
||||||
"After receiving 65535 packets, a new file is created.\n"
|
"After receiving 65535 packets, a new file is created.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"Command line options:\n"
|
printf("Command line options:\n"
|
||||||
"[--extcap-interface port] - serial interface.\n"
|
"[--extcap-interface port] - serial interface.\n"
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
" Supported values: COM1, COM2, etc.\n"
|
" Supported values: COM1, COM2, etc.\n"
|
||||||
|
|||||||
+12
-11
@@ -229,22 +229,23 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"Read a file from a BACnet device and save it locally.\n"
|
"Read a file from a BACnet device and save it locally.\n");
|
||||||
"device-instance:\n"
|
printf("\n");
|
||||||
|
printf("device-instance:\n"
|
||||||
"BACnet Device Object Instance number that you are trying to\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"
|
"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"
|
"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"
|
"reading from Device Object 123, the device-instance would be 123.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"file-instance:\n"
|
printf("file-instance:\n"
|
||||||
"This is the file object instance number that you are reading from.\n"
|
"This is the file object instance number that you are reading from.\n"
|
||||||
"For example, if you were reading from File 2, \n"
|
"For example, if you were reading from File 2, \n"
|
||||||
"the file-instance would be 2.\n"
|
"the file-instance would be 2.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"local-name:\n"
|
printf("local-name:\n"
|
||||||
"The name of the file that will be stored locally.\n"
|
"The name of the file that will be stored locally.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"Example:\n"
|
printf("Example:\n"
|
||||||
"If you want read File 2 from Device 123 and save it to temp.txt,\n"
|
"If you want read File 2 from Device 123 and save it to temp.txt,\n"
|
||||||
"use the following command:\n"
|
"use the following command:\n"
|
||||||
"%s 123 2 temp.txt\n",
|
"%s 123 2 temp.txt\n",
|
||||||
|
|||||||
+32
-18
@@ -29,7 +29,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h> /* for time */
|
#include <time.h> /* for time */
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -178,13 +178,15 @@ static void print_help(char *filename)
|
|||||||
"Optional BACnet mac address."
|
"Optional BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"--dnet N\n"
|
"--dnet N\n"
|
||||||
"Optional BACnet network number N for directed requests.\n"
|
"Optional BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"--dadr A\n"
|
"--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network "
|
||||||
"number.\n"
|
"number.\n"
|
||||||
@@ -197,42 +199,54 @@ static void print_help(char *filename)
|
|||||||
"trying to communicate to. This number will be used\n"
|
"trying to communicate to. This number will be used\n"
|
||||||
"to try and bind with the device using Who-Is and\n"
|
"to try and bind with the device using Who-Is and\n"
|
||||||
"I-Am services. For example, if you were reading\n"
|
"I-Am services. For example, if you were reading\n"
|
||||||
"Device Object 123, the device-instance would be 123.\n"
|
"Device Object 123, the device-instance would be 123.\n");
|
||||||
"\nobject-type:\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
|
"object-type:\n"
|
||||||
"The object type is object that you are reading. It\n"
|
"The object type is object that you are reading. It\n"
|
||||||
"can be defined either as the object-type name string\n"
|
"can be defined either as the object-type name string\n"
|
||||||
"as defined in the BACnet specification, or as the\n"
|
"as defined in the BACnet specification, or as the\n"
|
||||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||||
"in bacenum.h. For example if you were reading Analog\n"
|
"in bacenum.h. For example if you were reading Analog\n"
|
||||||
"Output 2, the object-type would be analog-output or 1.\n"
|
"Output 2, the object-type would be analog-output or 1.\n");
|
||||||
"\nobject-instance:\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
|
"object-instance:\n"
|
||||||
"This is the object instance number of the object that\n"
|
"This is the object instance number of the object that\n"
|
||||||
"you are reading. For example, if you were reading\n"
|
"you are reading. For example, if you were reading\n"
|
||||||
"Analog Output 2, the object-instance would be 2.\n"
|
"Analog Output 2, the object-instance would be 2.\n");
|
||||||
"\nproperty:\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
|
"property:\n"
|
||||||
"The property of the object that you are reading. It\n"
|
"The property of the object that you are reading. It\n"
|
||||||
"can be defined either as the property name string as\n"
|
"can be defined either as the property name string as\n"
|
||||||
"defined in the BACnet specification, or as an integer\n"
|
"defined in the BACnet specification, or as an integer\n"
|
||||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||||
"bacenum.h. For example, if you were reading the Present\n"
|
"bacenum.h. For example, if you were reading the Present\n"
|
||||||
"Value property, use present-value or 85 as the property.\n"
|
"Value property, use present-value or 85 as the property.\n");
|
||||||
"\nindex:\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
|
"index:\n"
|
||||||
"This integer parameter is the index number of an array.\n"
|
"This integer parameter is the index number of an array.\n"
|
||||||
"If the property is an array, individual elements can\n"
|
"If the property is an array, individual elements can\n"
|
||||||
"be read. If this parameter is missing and the property\n"
|
"be read. If this parameter is missing and the property\n"
|
||||||
"is an array, the entire array will be read.\n"
|
"is an array, the entire array will be read.\n");
|
||||||
"\nExample:\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
|
"Example:\n"
|
||||||
"If you want read the Present-Value of Analog Output 101\n"
|
"If you want read the Present-Value of Analog Output 101\n"
|
||||||
"in Device 123, you could send either of the following\n"
|
"in Device 123, you could send either of the following\n"
|
||||||
"commands:\n"
|
"commands:\n"
|
||||||
"%s 123 analog-output 101 present-value\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"
|
"If you want read the Priority-Array of Analog Output 101\n"
|
||||||
"in Device 123, you could send either of the following\n"
|
"in Device 123, you could send either of the following\n"
|
||||||
"commands:\n"
|
"commands:\n"
|
||||||
"%s 123 analog-output 101 priority-array\n"
|
"%s 123 analog-output 101 priority-array\n"
|
||||||
"%s 123 1 101 87\n",
|
"%s 123 1 101 87\n",
|
||||||
filename, filename, filename, filename);
|
filename, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -369,7 +383,7 @@ int main(int argc, char *argv[])
|
|||||||
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
|
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
|
||||||
Init_Service_Handlers();
|
Init_Service_Handlers();
|
||||||
dlenv_init();
|
dlenv_init();
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
/* Internationalized programs must call setlocale()
|
/* Internationalized programs must call setlocale()
|
||||||
* to initiate a specific language operation.
|
* to initiate a specific language operation.
|
||||||
* This can be done by calling setlocale() as follows.
|
* This can be done by calling setlocale() as follows.
|
||||||
|
|||||||
+35
-33
@@ -29,7 +29,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h> /* for time */
|
#include <time.h> /* for time */
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -261,78 +261,80 @@ static void print_help(char *filename)
|
|||||||
{
|
{
|
||||||
printf("Read one or more properties from one or more objects\n"
|
printf("Read one or more properties from one or more objects\n"
|
||||||
"in a BACnet device and print the value(s).\n");
|
"in a BACnet device and print the value(s).\n");
|
||||||
|
printf("\n");
|
||||||
printf("--mac A\n"
|
printf("--mac A\n"
|
||||||
"Optional BACnet mac address."
|
"Optional BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional BACnet network number N for directed requests.\n"
|
"Optional BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network "
|
||||||
"number.\n"
|
"number.\n"
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("device-instance:\n"
|
printf("device-instance:\n"
|
||||||
"BACnet Device Object Instance number that you are\n"
|
"BACnet Device Object Instance number that you are\n"
|
||||||
"trying to communicate to. This number will be used\n"
|
"trying to communicate to. This number will be used\n"
|
||||||
"to try and bind with the device using Who-Is and\n"
|
"to try and bind with the device using Who-Is and\n"
|
||||||
"I-Am services. For example, if you were reading\n"
|
"I-Am services. For example, if you were reading\n"
|
||||||
"Device Object 123, the device-instance would be 123.\n"
|
"Device Object 123, the device-instance would be 123.\n");
|
||||||
"\nobject-type:\n"
|
printf("\n");
|
||||||
|
printf("object-type:\n"
|
||||||
"The object type is object that you are reading. It\n"
|
"The object type is object that you are reading. It\n"
|
||||||
"can be defined either as the object-type name string\n"
|
"can be defined either as the object-type name string\n"
|
||||||
"as defined in the BACnet specification, or as the\n"
|
"as defined in the BACnet specification, or as the\n"
|
||||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||||
"in bacenum.h. For example if you were reading Analog\n"
|
"in bacenum.h. For example if you were reading Analog\n"
|
||||||
"Output 2, the object-type would be analog-output or 1.\n"
|
"Output 2, the object-type would be analog-output or 1.\n");
|
||||||
"\nobject-instance:\n"
|
printf("\n");
|
||||||
|
printf("object-instance:\n"
|
||||||
"This is the object instance number of the object that\n"
|
"This is the object instance number of the object that\n"
|
||||||
"you are reading. For example, if you were reading\n"
|
"you are reading. For example, if you were reading\n"
|
||||||
"Analog Output 2, the object-instance would be 2.\n"
|
"Analog Output 2, the object-instance would be 2.\n");
|
||||||
"\nproperty:\n"
|
printf("\n");
|
||||||
|
printf("property:\n"
|
||||||
"The property is an integer value of the enumeration\n"
|
"The property is an integer value of the enumeration\n"
|
||||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||||
"you are reading. For example, if you were reading the\n"
|
"you are reading. For example, if you were reading the\n"
|
||||||
"Present Value property, use 85 as the property.\n"
|
"Present Value property, use 85 as the property.\n");
|
||||||
"\n[index]:\n"
|
printf("\n");
|
||||||
|
printf("[index]:\n"
|
||||||
"This optional integer parameter is the index number of \n"
|
"This optional integer parameter is the index number of \n"
|
||||||
"an array property. Individual elements of an array can\n"
|
"an array property. Individual elements of an array can\n"
|
||||||
"be read. If this parameter is missing and the property\n"
|
"be read. If this parameter is missing and the property\n"
|
||||||
"is an array, the entire array will be read.\n"
|
"is an array, the entire array will be read.\n");
|
||||||
"\nExample:\n"
|
printf("\n");
|
||||||
|
printf("Example:\n"
|
||||||
"If you want read the PRESENT_VALUE property and various\n"
|
"If you want read the PRESENT_VALUE property and various\n"
|
||||||
"array elements of the PRIORITY_ARRAY in Device 123\n"
|
"array elements of the PRIORITY_ARRAY in Device 123\n"
|
||||||
"Analog Output object 99, use one of the following commands:\n"
|
"Analog Output object 99, use one of the following commands:\n"
|
||||||
"%s 123 analog-output 99 85,87[0],87\n"
|
"%s 123 analog-output 99 85,87[0],87\n"
|
||||||
"%s 123 1 99 85,87[0],87\n"
|
"%s 123 1 99 85,87[0],87\n", filename, filename);
|
||||||
"If you want read the PRESENT_VALUE property in objects\n"
|
printf("If you want read the PRESENT_VALUE property in objects\n"
|
||||||
"Analog Input 77 and Analog Input 78 in Device 123\n"
|
"Analog Input 77 and Analog Input 78 in Device 123\n"
|
||||||
"use one of the following commands:\n"
|
"use one of the following commands:\n"
|
||||||
"%s 123 analog-input 77 85 analog-input 78 85\n"
|
"%s 123 analog-input 77 85 analog-input 78 85\n"
|
||||||
"%s 123 0 77 85 0 78 85\n"
|
"%s 123 0 77 85 0 78 85\n", filename, filename);
|
||||||
"If you want read the ALL property in\n"
|
printf("If you want read the ALL property in\n"
|
||||||
"Device object 123, you would use one of the following commands:\n"
|
"Device object 123, you would use one of the following commands:\n"
|
||||||
"%s 123 device 123 8\n"
|
"%s 123 device 123 8\n"
|
||||||
"%s 123 8 123 8\n"
|
"%s 123 8 123 8\n", filename, filename);
|
||||||
"If you want read the OPTIONAL property in\n"
|
printf("If you want read the OPTIONAL property in\n"
|
||||||
"Device object 123, you would use one of the following commands:\n"
|
"Device object 123, you would use one of the following commands:\n"
|
||||||
"%s 123 device 123 80\n"
|
"%s 123 device 123 80\n"
|
||||||
"%s 123 8 123 80\n"
|
"%s 123 8 123 80\n", filename, filename);
|
||||||
"If you want read the REQUIRED property in\n"
|
printf("If you want read the REQUIRED property in\n"
|
||||||
"Device object 123, you would one of use the following commands:\n"
|
"Device object 123, you would one of use the following commands:\n"
|
||||||
"%s 123 device 123 105\n"
|
"%s 123 device 123 105\n"
|
||||||
"%s 123 8 123 105\n",
|
"%s 123 8 123 105\n", filename, filename);
|
||||||
filename, filename, filename, filename, filename, filename, filename,
|
|
||||||
filename, filename, filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -501,7 +503,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
Init_Service_Handlers();
|
Init_Service_Handlers();
|
||||||
dlenv_init();
|
dlenv_init();
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
/* Internationalized programs must call setlocale()
|
/* Internationalized programs must call setlocale()
|
||||||
* to initiate a specific language operation.
|
* to initiate a specific language operation.
|
||||||
* This can be done by calling setlocale() as follows.
|
* This can be done by calling setlocale() as follows.
|
||||||
|
|||||||
+44
-36
@@ -31,7 +31,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h> /* for time */
|
#include <time.h> /* for time */
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
#include "bacnet/bacdef.h"
|
#include "bacnet/bacdef.h"
|
||||||
@@ -146,40 +146,48 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Read a range of properties from an array or list property\n"
|
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"
|
"in an object in a BACnet device and print the values.\n");
|
||||||
"device-instance:\n"
|
printf("\n");
|
||||||
"BACnet Device Object Instance number that you are\n"
|
printf("device-instance:\n"
|
||||||
"trying to communicate to. This number will be used\n"
|
"BACnet Device Object Instance number that you are\n"
|
||||||
"to try and bind with the device using Who-Is and\n"
|
"trying to communicate to. This number will be used\n"
|
||||||
"I-Am services. For example, if you were reading\n"
|
"to try and bind with the device using Who-Is and\n"
|
||||||
"Device Object 123, the device-instance would be 123.\n"
|
"I-Am services. For example, if you were reading\n"
|
||||||
"\nobject-type:\n"
|
"Device Object 123, the device-instance would be 123.\n");
|
||||||
"The object type is the integer value of the enumeration\n"
|
printf("\n");
|
||||||
"BACNET_OBJECT_TYPE in bacenum.h. It is the object\n"
|
printf("object-type:\n"
|
||||||
"that you are reading. For example if you were\n"
|
"The object type is the integer value of the enumeration\n"
|
||||||
"reading Trend Log 2, the object-type would be 20.\n"
|
"BACNET_OBJECT_TYPE in bacenum.h. It is the object\n"
|
||||||
"\nobject-instance:\n"
|
"that you are reading. For example if you were\n"
|
||||||
"This is the object instance number of the object that\n"
|
"reading Trend Log 2, the object-type would be 20.\n");
|
||||||
"you are reading. For example, if you were reading\n"
|
printf("\n");
|
||||||
"Trend Log 2, the object-instance would be 2.\n"
|
printf("object-instance:\n"
|
||||||
"\nproperty:\n"
|
"This is the object instance number of the object that\n"
|
||||||
"The property is an integer value of the enumeration\n"
|
"you are reading. For example, if you were reading\n"
|
||||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
"Trend Log 2, the object-instance would be 2.\n");
|
||||||
"you are reading. For example, if you were reading the\n"
|
printf("\n");
|
||||||
"Log_Buffer property, use 131 as the property.\n"
|
printf("property:\n"
|
||||||
"\nrange-type:\n"
|
"The property is an integer value of the enumeration\n"
|
||||||
"1=By Position\n"
|
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||||
"2=By Sequence\n"
|
"you are reading. For example, if you were reading the\n"
|
||||||
"3=By Time\n"
|
"Log_Buffer property, use 131 as the property.\n");
|
||||||
"4=All\n"
|
printf("\n");
|
||||||
"\nindex or date/time:\n"
|
printf("range-type:\n"
|
||||||
"This integer parameter is the starting index, or date & time.\n"
|
"1=By Position\n"
|
||||||
"\ncount:\n"
|
"2=By Sequence\n"
|
||||||
"This integer parameter is the number of elements to read.\n"
|
"3=By Time\n"
|
||||||
"\nExample:\n"
|
"4=All\n");
|
||||||
"If you want read the Log_Buffer of Trend Log 2\n"
|
printf("\n");
|
||||||
"in Device 123, from starting position 1 and read 10 entries,\n"
|
printf("index or date/time:\n"
|
||||||
"you could send the following commands:\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 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 2 1 10\n", filename);
|
||||||
printf("%s 123 trend-log 2 log-buffer 3 1/1/2014 00:00:01 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();
|
address_init();
|
||||||
Init_Service_Handlers();
|
Init_Service_Handlers();
|
||||||
dlenv_init();
|
dlenv_init();
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
/* Internationalized programs must call setlocale()
|
/* Internationalized programs must call setlocale()
|
||||||
* to initiate a specific language operation.
|
* to initiate a specific language operation.
|
||||||
* This can be done by calling setlocale() as follows.
|
* 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) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(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_class_name((int)error_class),
|
||||||
bactext_error_code_name((int)error_code));
|
bactext_error_code_name((int)error_code));
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
@@ -93,7 +93,7 @@ static void MyAbortHandler(
|
|||||||
(void)server;
|
(void)server;
|
||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
printf("BACnet Abort: %s\r\n",
|
printf("BACnet Abort: %s\n",
|
||||||
bactext_abort_reason_name((int)abort_reason));
|
bactext_abort_reason_name((int)abort_reason));
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ static void MyRejectHandler(
|
|||||||
{
|
{
|
||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
printf("BACnet Reject: %s\r\n",
|
printf("BACnet Reject: %s\n",
|
||||||
bactext_reject_reason_name((int)reject_reason));
|
bactext_reject_reason_name((int)reject_reason));
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ static void MyWritePropertySimpleAckHandler(
|
|||||||
{
|
{
|
||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
printf("SubscribeCOV Acknowledged!\r\n");
|
printf("SubscribeCOV Acknowledged!\n");
|
||||||
Simple_Ack_Detected = true;
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||||
@@ -204,61 +255,19 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (print_usage_terse) {
|
if (print_usage_terse) {
|
||||||
filename = filename_remove_path(argv[0]);
|
filename = filename_remove_path(argv[0]);
|
||||||
printf("Usage: %s device-id object-type object-instance "
|
print_usage(filename);
|
||||||
"process-id <[un]confirmed lifetime|cancel>\r\n",
|
|
||||||
filename);
|
|
||||||
if (!print_usage_verbose) {
|
if (!print_usage_verbose) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (print_usage_verbose) {
|
if (print_usage_verbose) {
|
||||||
printf("\r\n"
|
print_help(filename);
|
||||||
"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);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* decode the command line parameters */
|
/* decode the command line parameters */
|
||||||
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
||||||
if (Target_Device_Object_Instance >= BACNET_MAX_INSTANCE) {
|
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);
|
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -274,7 +283,7 @@ int main(int argc, char *argv[])
|
|||||||
cov_data->monitoredObjectIdentifier.type = (uint16_t)uint;
|
cov_data->monitoredObjectIdentifier.type = (uint16_t)uint;
|
||||||
if (cov_data->monitoredObjectIdentifier.type >=
|
if (cov_data->monitoredObjectIdentifier.type >=
|
||||||
MAX_BACNET_OBJECT_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,
|
cov_data->monitoredObjectIdentifier.type,
|
||||||
MAX_BACNET_OBJECT_TYPE);
|
MAX_BACNET_OBJECT_TYPE);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -284,7 +293,7 @@ int main(int argc, char *argv[])
|
|||||||
strtol(argv[argi], NULL, 0);
|
strtol(argv[argi], NULL, 0);
|
||||||
if (cov_data->monitoredObjectIdentifier.instance >
|
if (cov_data->monitoredObjectIdentifier.instance >
|
||||||
BACNET_MAX_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,
|
cov_data->monitoredObjectIdentifier.instance,
|
||||||
BACNET_MAX_INSTANCE + 1);
|
BACNET_MAX_INSTANCE + 1);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -302,7 +311,7 @@ int main(int argc, char *argv[])
|
|||||||
} else if (strcmp(argv[argi], "unconfirmed") == 0) {
|
} else if (strcmp(argv[argi], "unconfirmed") == 0) {
|
||||||
cov_data->issueConfirmedNotifications = false;
|
cov_data->issueConfirmedNotifications = false;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unknown option: %s\r\n", argv[argi]);
|
fprintf(stderr, "unknown option: %s\n", argv[argi]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
argi++;
|
argi++;
|
||||||
@@ -379,7 +388,7 @@ int main(int argc, char *argv[])
|
|||||||
timeout_seconds = cov_data->lifetime;
|
timeout_seconds = cov_data->lifetime;
|
||||||
}
|
}
|
||||||
printf("Sent SubscribeCOV request. "
|
printf("Sent SubscribeCOV request. "
|
||||||
" Waiting up to %u seconds....\r\n",
|
" Waiting up to %u seconds....\n",
|
||||||
(unsigned)(timeout_seconds - elapsed_seconds));
|
(unsigned)(timeout_seconds - elapsed_seconds));
|
||||||
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||||
if (cov_data->next) {
|
if (cov_data->next) {
|
||||||
@@ -391,7 +400,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
} 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);
|
tsm_free_invoke_id(Request_Invoke_ID);
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
break;
|
break;
|
||||||
@@ -400,7 +409,7 @@ int main(int argc, char *argv[])
|
|||||||
/* exit if timed out */
|
/* exit if timed out */
|
||||||
if (elapsed_seconds > timeout_seconds) {
|
if (elapsed_seconds > timeout_seconds) {
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
printf("\rError: APDU Timeout!\r\n");
|
printf("\rError: APDU Timeout!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "bacnet/bactext.h"
|
#include "bacnet/bactext.h"
|
||||||
#include "bacnet/version.h"
|
#include "bacnet/version.h"
|
||||||
#include "bacnet/basic/sys/filename.h"
|
#include "bacnet/basic/sys/filename.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/sys/mstimer.h"
|
#include "bacnet/basic/sys/mstimer.h"
|
||||||
#include "bacnet/basic/client/bac-task.h"
|
#include "bacnet/basic/client/bac-task.h"
|
||||||
#include "bacnet/basic/client/bac-data.h"
|
#include "bacnet/basic/client/bac-data.h"
|
||||||
@@ -26,9 +27,7 @@
|
|||||||
#include "bacnet/datalink/dlenv.h"
|
#include "bacnet/datalink/dlenv.h"
|
||||||
|
|
||||||
/* print with flush by default */
|
/* print with flush by default */
|
||||||
#define PRINTF(...) \
|
#define PRINTF debug_aprintf
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
|
||||||
fflush(stderr)
|
|
||||||
|
|
||||||
/* current version of the BACnet stack */
|
/* current version of the BACnet stack */
|
||||||
static const char *BACnet_Version = BACNET_VERSION_TEXT;
|
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"
|
"trying to communicate to. This number will be used\n"
|
||||||
"to try and bind with the device using Who-Is and\n"
|
"to try and bind with the device using Who-Is and\n"
|
||||||
"I-Am services. For example, if you were reading\n"
|
"I-Am services. For example, if you were reading\n"
|
||||||
"Device Object 123, the device-instance would be 123.\n"
|
"Device Object 123, the device-instance would be 123.\n");
|
||||||
"\nobject-type:\n"
|
PRINTF("\n");
|
||||||
|
PRINTF("object-type:\n"
|
||||||
"The object type is object that you are reading. It\n"
|
"The object type is object that you are reading. It\n"
|
||||||
"can be defined either as the object-type name string\n"
|
"can be defined either as the object-type name string\n"
|
||||||
"as defined in the BACnet specification, or as the\n"
|
"as defined in the BACnet specification, or as the\n"
|
||||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||||
"in bacenum.h. For example if you were reading Analog\n"
|
"in bacenum.h. For example if you were reading Analog\n"
|
||||||
"Output 2, the object-type would be analog-output or 1.\n"
|
"Output 2, the object-type would be analog-output or 1.\n");
|
||||||
"\nobject-instance:\n"
|
PRINTF("\n");
|
||||||
|
PRINTF("object-instance:\n"
|
||||||
"This is the object instance number of the object that\n"
|
"This is the object instance number of the object that\n"
|
||||||
"you are reading. For example, if you were reading\n"
|
"you are reading. For example, if you were reading\n"
|
||||||
"Analog Output 2, the object-instance would be 2.\n");
|
"Analog Output 2, the object-instance would be 2.\n");
|
||||||
PRINTF("\n"
|
PRINTF("\n");
|
||||||
"Example:\n"
|
PRINTF("Example:\n"
|
||||||
"If you want read the Present-Value of Analog Output 101\n"
|
"If you want read the Present-Value of Analog Output 101\n"
|
||||||
"in Device 123, you could send either of the following\n"
|
"in Device 123, you could send either of the following\n"
|
||||||
"commands:\n"
|
"commands:\n"
|
||||||
|
|||||||
+1
-1
@@ -191,6 +191,7 @@ int main(int argc, char *argv[])
|
|||||||
uint32_t elapsed_seconds = 0;
|
uint32_t elapsed_seconds = 0;
|
||||||
uint32_t elapsed_milliseconds = 0;
|
uint32_t elapsed_milliseconds = 0;
|
||||||
uint32_t address_binding_tmr = 0;
|
uint32_t address_binding_tmr = 0;
|
||||||
|
BACNET_CHARACTER_STRING DeviceName;
|
||||||
#if defined(INTRINSIC_REPORTING)
|
#if defined(INTRINSIC_REPORTING)
|
||||||
uint32_t recipient_scan_tmr = 0;
|
uint32_t recipient_scan_tmr = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -266,7 +267,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
ucix_cleanup(ctx);
|
ucix_cleanup(ctx);
|
||||||
#endif /* defined(BAC_UCI) */
|
#endif /* defined(BAC_UCI) */
|
||||||
BACNET_CHARACTER_STRING DeviceName;
|
|
||||||
if (Device_Object_Name(Device_Object_Instance_Number(), &DeviceName)) {
|
if (Device_Object_Name(Device_Object_Instance_Number(), &DeviceName)) {
|
||||||
printf("BACnet Device Name: %s\n", DeviceName.value);
|
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)
|
static void print_usage(char *filename)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [--dnet][--dadr][--mac]\n", filename);
|
printf("Usage: %s [--dnet][--dadr][--mac]\n", filename);
|
||||||
|
printf(" [--date][--time]\n");
|
||||||
printf(" [--version][--help]\n");
|
printf(" [--version][--help]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Send BACnet TimeSynchronization request.\n"
|
printf("Send BACnet TimeSynchronization request.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--mac A\n"
|
printf("--date year/month/day[:weekday]\n"
|
||||||
"BACnet mac address."
|
"Date formatted 2021/12/31 or 2021/12/31:1\n"
|
||||||
"Valid ranges are from 0 to 255\n"
|
"where day is 1..31,\n"
|
||||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
"where month is 1=January..12=December,\n"
|
||||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
"where weekday is 1=Monday..7=Sunday\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--time hours:minutes:seconds.hundredths\n"
|
||||||
"BACnet network number N for directed requests.\n"
|
"Time formatted 23:59:59.99 or 23:59:59 or 23:59\n");
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
printf("\n");
|
||||||
"and 65535 is network broadcast.\n"
|
printf("--mac A\n"
|
||||||
"\n"
|
"BACnet mac address."
|
||||||
"--dadr A\n"
|
"Valid ranges are from 0 to 255\n"
|
||||||
"BACnet mac address on the destination BACnet network number.\n"
|
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
||||||
"Valid ranges are from 0 to 255\n"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"or an IP string with optional port number like 10.1.2.3:47808\n"
|
printf("\n");
|
||||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
printf("--dnet N\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"
|
printf("Examples:\n"
|
||||||
"Send a TimeSynchronization request to DNET 123:\n"
|
"Send a TimeSynchronization request to DNET 123:\n"
|
||||||
"%s --dnet 123\n",
|
"%s --dnet 123\n",
|
||||||
filename);
|
filename);
|
||||||
printf(
|
printf(
|
||||||
"Send a TimeSynchronization request to MAC 10.0.0.1 DNET 123 DADR 5:\n"
|
"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"
|
printf("Send a TimeSynchronization 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);
|
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[])
|
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);
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *value_string = NULL;
|
char *value_string = NULL;
|
||||||
@@ -77,98 +143,7 @@ int main(int argc, char *argv[])
|
|||||||
unsigned object_property = 0;
|
unsigned object_property = 0;
|
||||||
|
|
||||||
if (argc < 7) {
|
if (argc < 7) {
|
||||||
/* note: priority 16 and 0 should produce the same end results... */
|
print_usage(filename_remove_path(argv[0]));
|
||||||
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]));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* decode the command line parameters */
|
/* decode the command line parameters */
|
||||||
@@ -204,29 +179,29 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
|
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);
|
cov_data.initiatingDeviceIdentifier, BACNET_MAX_INSTANCE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (cov_data.monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
|
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);
|
cov_data.monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
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,
|
cov_data.monitoredObjectIdentifier.instance,
|
||||||
BACNET_MAX_INSTANCE + 1);
|
BACNET_MAX_INSTANCE + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (cov_data.listOfValues->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
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,
|
cov_data.listOfValues->propertyIdentifier,
|
||||||
MAX_BACNET_PROPERTY_ID + 1);
|
MAX_BACNET_PROPERTY_ID + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (tag >= MAX_BACNET_APPLICATION_TAG) {
|
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);
|
MAX_BACNET_APPLICATION_TAG);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -234,7 +209,7 @@ int main(int argc, char *argv[])
|
|||||||
tag, value_string, &cov_data.listOfValues->value);
|
tag, value_string, &cov_data.listOfValues->value);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* FIXME: show the expected entry format for the tag */
|
/* 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;
|
return 1;
|
||||||
}
|
}
|
||||||
/* setup my info */
|
/* 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("Send BACnet UnconfirmedEventNotification message for a device.\n");
|
||||||
printf("--mac A\n"
|
printf("--mac A\n"
|
||||||
"Optional BACnet mac address."
|
"Optional BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"Optional BACnet network number N for directed requests.\n"
|
"Optional BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"Optional BACnet mac address on the destination BACnet network "
|
"Optional BACnet mac address on the destination BACnet network\n"
|
||||||
"number.\n"
|
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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");
|
||||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
|
printf("\n");
|
||||||
"\n");
|
(void)filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|||||||
+65
-61
@@ -84,7 +84,7 @@ static void MyErrorHandler(BACNET_ADDRESS *src,
|
|||||||
{
|
{
|
||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(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_class_name((int)error_class),
|
||||||
bactext_error_code_name((int)error_code));
|
bactext_error_code_name((int)error_code));
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
@@ -97,7 +97,7 @@ static void MyAbortHandler(
|
|||||||
(void)server;
|
(void)server;
|
||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
printf("BACnet Abort: %s\r\n",
|
printf("BACnet Abort: %s\n",
|
||||||
bactext_abort_reason_name((int)abort_reason));
|
bactext_abort_reason_name((int)abort_reason));
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ static void MyRejectHandler(
|
|||||||
{
|
{
|
||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
printf("BACnet Reject: %s\r\n",
|
printf("BACnet Reject: %s\n",
|
||||||
bactext_reject_reason_name((int)reject_reason));
|
bactext_reject_reason_name((int)reject_reason));
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
}
|
}
|
||||||
@@ -137,6 +137,57 @@ static void Init_Service_Handlers(void)
|
|||||||
apdu_set_reject_handler(MyRejectHandler);
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||||
@@ -161,56 +212,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (argc < 6) {
|
if (argc < 6) {
|
||||||
filename = filename_remove_path(argv[0]);
|
filename = filename_remove_path(argv[0]);
|
||||||
printf("Usage: %s <device-instance|broadcast|dnet=> vendor-id"
|
print_usage(filename);
|
||||||
" service-number tag value [tag value...]\r\n",
|
|
||||||
filename);
|
|
||||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||||
printf(
|
print_help(filename);
|
||||||
"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);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -228,7 +232,7 @@ int main(int argc, char *argv[])
|
|||||||
Target_Service_Number = strtol(argv[3], NULL, 0);
|
Target_Service_Number = strtol(argv[3], NULL, 0);
|
||||||
if ((!Target_Broadcast) &&
|
if ((!Target_Broadcast) &&
|
||||||
(Target_Device_Object_Instance > BACNET_MAX_INSTANCE)) {
|
(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);
|
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -248,15 +252,15 @@ int main(int argc, char *argv[])
|
|||||||
property_tag = strtol(argv[tag_value_arg], NULL, 0);
|
property_tag = strtol(argv[tag_value_arg], NULL, 0);
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (args_remaining <= 0) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
value_string = argv[tag_value_arg + 1];
|
value_string = argv[tag_value_arg + 1];
|
||||||
args_remaining--;
|
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); */
|
i, property_tag, i, value_string); */
|
||||||
if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
|
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);
|
property_tag, MAX_BACNET_APPLICATION_TAG);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -264,7 +268,7 @@ int main(int argc, char *argv[])
|
|||||||
property_tag, value_string, &Target_Object_Property_Value[i]);
|
property_tag, value_string, &Target_Object_Property_Value[i]);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* FIXME: show the expected entry format for the tag */
|
/* 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;
|
return 1;
|
||||||
}
|
}
|
||||||
Target_Object_Property_Value[i].next = NULL;
|
Target_Object_Property_Value[i].next = NULL;
|
||||||
@@ -277,7 +281,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args_remaining > 0) {
|
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);
|
MAX_PROPERTY_VALUES);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -334,15 +338,15 @@ int main(int argc, char *argv[])
|
|||||||
Send_UnconfirmedPrivateTransfer(&Target_Address, &private_data);
|
Send_UnconfirmedPrivateTransfer(&Target_Address, &private_data);
|
||||||
printf("Sent PrivateTransfer.");
|
printf("Sent PrivateTransfer.");
|
||||||
if (timeout_seconds) {
|
if (timeout_seconds) {
|
||||||
printf(" Waiting %u seconds.\r\n",
|
printf(" Waiting %u seconds.\n",
|
||||||
(unsigned)(timeout_seconds - elapsed_seconds));
|
(unsigned)(timeout_seconds - elapsed_seconds));
|
||||||
} else {
|
} else {
|
||||||
printf("\r\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
sent_message = true;
|
sent_message = true;
|
||||||
} else {
|
} else {
|
||||||
if (elapsed_seconds > timeout_seconds) {
|
if (elapsed_seconds > timeout_seconds) {
|
||||||
printf("\rError: APDU Timeout!\r\n");
|
printf("\rError: APDU Timeout!\n");
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-54
@@ -276,68 +276,69 @@ static void print_usage(char *filename)
|
|||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf("Send BACnet WhoIs service request to a device or multiple\n"
|
printf("Send BACnet WhoIs service request to a device or multiple\n"
|
||||||
"devices, and wait for responses. Displays any devices found\n"
|
"devices, and wait for responses. Displays any devices found\n"
|
||||||
"and their network information.\n"
|
"and their network information.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"device-instance:\n"
|
printf("device-instance:\n"
|
||||||
"BACnet Device Object Instance number that you are trying\n"
|
"BACnet Device Object Instance number that you are trying\n"
|
||||||
"to send a Who-Is service request. The value should be in\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"
|
"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"
|
"specified by using a minimum value and a maximum value.\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
printf("--mac A\n"
|
printf("--mac A\n"
|
||||||
"BACnet mac address."
|
"BACnet mac address."
|
||||||
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dnet N\n"
|
printf("--dnet N\n"
|
||||||
"BACnet network number N for directed requests.\n"
|
"BACnet network number N for directed requests.\n"
|
||||||
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
"Valid range is from 0 to 65535 where 0 is the local connection\n"
|
||||||
"and 65535 is network broadcast.\n"
|
"and 65535 is network broadcast.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--dadr A\n"
|
printf("--dadr A\n"
|
||||||
"BACnet mac address on the destination BACnet network number.\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"
|
"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 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"
|
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--repeat\n"
|
printf("--repeat\n"
|
||||||
"Send the message repeatedly until signalled to quit.\n"
|
"Send the message repeatedly until signalled to quit.\n"
|
||||||
"Default is disabled, using the APDU timeout as time to quit.\n"
|
"Default is disabled, using the APDU timeout as time to quit.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--retry C\n"
|
printf("--retry C\n"
|
||||||
"Send the message C number of times\n"
|
"Send the message C number of times\n"
|
||||||
"Default is retry 0, only sending one time.\n"
|
"Default is retry 0, only sending one time.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--timeout T\n"
|
printf("--timeout T\n"
|
||||||
"Wait T milliseconds after sending before retry\n"
|
"Wait T milliseconds after sending before retry\n"
|
||||||
"Default delay is 3000ms.\n"
|
"Default delay is 3000ms.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"--delay M\n"
|
printf("--delay M\n"
|
||||||
"Wait M milliseconds for responses after sending\n"
|
"Wait M milliseconds for responses after sending\n"
|
||||||
"Default delay is 100ms.\n"
|
"Default delay is 100ms.\n");
|
||||||
"\n");
|
printf("\n");
|
||||||
|
printf("Example:\n");
|
||||||
printf("Send a WhoIs request to DNET 123:\n"
|
printf("Send a WhoIs request to DNET 123:\n"
|
||||||
"%s --dnet 123\n",
|
"%s --dnet 123\n",
|
||||||
filename);
|
filename);
|
||||||
printf("Send a WhoIs request to MAC 10.0.0.1 DNET 123 DADR 05h:\n"
|
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);
|
filename);
|
||||||
printf("Send a WhoIs request to MAC 10.1.2.3:47808:\n"
|
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);
|
filename);
|
||||||
printf("Send a WhoIs request to Device 123:\n"
|
printf("Send a WhoIs request to Device 123:\n"
|
||||||
"%s 123\n",
|
"%s 123\n",
|
||||||
filename);
|
filename);
|
||||||
printf("Send a WhoIs request to Devices from 1000 to 9000:\n"
|
printf("Send a WhoIs request to Devices from 1000 to 9000:\n"
|
||||||
"%s 1000 9000\n",
|
"%s 1000 9000\n",
|
||||||
filename);
|
filename);
|
||||||
printf("Send a WhoIs request to Devices from 1000 to 9000 on DNET 123:\n"
|
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);
|
filename);
|
||||||
printf("Send a WhoIs request to all devices:\n"
|
printf("Send a WhoIs request to all devices:\n"
|
||||||
"%s\n",
|
"%s\n",
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,16 +414,10 @@ int main(int argc, char *argv[])
|
|||||||
} else if (strcmp(argv[argi], "--timeout") == 0) {
|
} else if (strcmp(argv[argi], "--timeout") == 0) {
|
||||||
if (++argi < argc) {
|
if (++argi < argc) {
|
||||||
timeout_milliseconds = strtol(argv[argi], NULL, 0);
|
timeout_milliseconds = strtol(argv[argi], NULL, 0);
|
||||||
if (timeout_milliseconds < 0) {
|
|
||||||
timeout_milliseconds = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[argi], "--delay") == 0) {
|
} else if (strcmp(argv[argi], "--delay") == 0) {
|
||||||
if (++argi < argc) {
|
if (++argi < argc) {
|
||||||
delay_milliseconds = strtol(argv[argi], NULL, 0);
|
delay_milliseconds = strtol(argv[argi], NULL, 0);
|
||||||
if (delay_milliseconds < 0) {
|
|
||||||
delay_milliseconds = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (target_args == 0) {
|
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"
|
"BACnet Device Object Instance number that you are trying to\n"
|
||||||
"communicate to. This number will be used to try and bind with\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"
|
"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"
|
"writing to Device Object 123, the device-instance would be 123.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"object-type:\n"
|
"object-type:\n"
|
||||||
"The object type is object that you are reading. It\n"
|
"The object type is object that you are reading. It\n"
|
||||||
"can be defined either as the object-type name string\n"
|
"can be defined either as the object-type name string\n"
|
||||||
"as defined in the BACnet specification, or as the\n"
|
"as defined in the BACnet specification, or as the\n"
|
||||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||||
"in bacenum.h. For example if you were reading Analog\n"
|
"in bacenum.h. For example if you were reading Analog\n"
|
||||||
"Output 2, the object-type would be analog-output or 1.\n"
|
"Output 2, the object-type would be analog-output or 1.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"object-instance:\n"
|
"object-instance:\n"
|
||||||
"This is the object instance number of the object that you are \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"
|
"writing to. For example, if you were writing to Analog Output 2, \n"
|
||||||
"the object-instance would be 2.\n"
|
"the object-instance would be 2.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"property:\n"
|
"property:\n"
|
||||||
"The property of the object that you are reading. It\n"
|
"The property of the object that you are reading. It\n"
|
||||||
"can be defined either as the property name string as\n"
|
"can be defined either as the property name string as\n"
|
||||||
"defined in the BACnet specification, or as an integer\n"
|
"defined in the BACnet specification, or as an integer\n"
|
||||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||||
"bacenum.h. For example, if you were reading the Present\n"
|
"bacenum.h. For example, if you were reading the Present\n"
|
||||||
"Value property, use present-value or 85 as the property.\n"
|
"Value property, use present-value or 85 as the property.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"priority:\n"
|
"priority:\n"
|
||||||
"This parameter is used for setting the priority of the\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"
|
"write. If Priority 0 is given, no priority is sent. The BACnet \n"
|
||||||
"standard states that the value is written at the lowest \n"
|
"standard states that the value is written at the lowest \n"
|
||||||
"priority (16) if the object property supports priorities\n"
|
"priority (16) if the object property supports priorities\n"
|
||||||
"when no priority is sent.\n"
|
"when no priority is sent.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"index\n"
|
"index\n"
|
||||||
"This integer parameter is the index number of an array.\n"
|
"This integer parameter is the index number of an array.\n"
|
||||||
"If the property is an array, individual elements can be written\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"
|
"to if supported. If this parameter is -1, the index is ignored.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
|
printf(
|
||||||
"tag:\n"
|
"tag:\n"
|
||||||
"Tag is the integer value of the enumeration BACNET_APPLICATION_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"
|
"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"
|
"writing. For example, if you were writing a REAL value, you would \n"
|
||||||
"use a tag of 4.\n"
|
"use a tag of 4.\n"
|
||||||
"Context tags are created using two tags in a row. The context tag\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"
|
"is preceded by a C, and followed by the application tag.\n"
|
||||||
"\n"
|
"Ctag atag. C2 4 creates a context 2 tagged REAL.\n");
|
||||||
|
printf("\n");
|
||||||
|
printf(
|
||||||
"value:\n"
|
"value:\n"
|
||||||
"The value is an ASCII representation of some type of data that you\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"
|
"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"
|
"example, if you were writing a REAL value of 100.0, you would use \n"
|
||||||
"100.0 as the value.\n"
|
"100.0 as the value.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"Here is a brief overview of BACnet property and tags:\n"
|
printf(
|
||||||
"Certain properties are expected to be written with certain \n"
|
"Example:\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"
|
|
||||||
"If you want send a value of 100 to the Present-Value in\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"
|
"Analog Output 0 of Device 123 at priority 16,\n"
|
||||||
"send the one of following commands:\n"
|
"send the one of following commands:\n"
|
||||||
"%s 123 analog-output 0 present-value 16 -1 4 100\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"
|
"To send a relinquish command to the same object:\n"
|
||||||
"%s 123 analog-output 0 present-value 16 -1 0 0\n"
|
"%s 123 analog-output 0 present-value 16 -1 0 0\n"
|
||||||
"%s 123 1 0 85 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[])
|
int main(int argc, char *argv[])
|
||||||
@@ -362,7 +362,7 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the written value (for debug)
|
/* Print the written value (for debug) */
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "Writing: ");
|
fprintf(stderr, "Writing: ");
|
||||||
BACNET_OBJECT_PROPERTY_VALUE dummy_opv = {
|
BACNET_OBJECT_PROPERTY_VALUE dummy_opv = {
|
||||||
|
|||||||
+38
-32
@@ -186,73 +186,79 @@ static void print_usage(char *filename)
|
|||||||
|
|
||||||
static void print_help(char *filename)
|
static void print_help(char *filename)
|
||||||
{
|
{
|
||||||
printf(
|
printf("Write one or more properties to one or more objects\n"
|
||||||
"Write one or more properties to one or more objects\n"
|
"in a BACnet device.\n");
|
||||||
"in a BACnet device.\n"
|
printf("\n");
|
||||||
"device-instance:\n"
|
printf("device-instance:\n"
|
||||||
"BACnet Device Object Instance number that you are\n"
|
"BACnet Device Object Instance number that you are\n"
|
||||||
"trying to communicate to. This number will be used\n"
|
"trying to communicate to. This number will be used\n"
|
||||||
"to try and bind with the device using Who-Is and\n"
|
"to try and bind with the device using Who-Is and\n"
|
||||||
"I-Am services. For example, if you were writing\n"
|
"I-Am services. For example, if you were writing\n"
|
||||||
"Device Object 123, the device-instance would be 123.\n"
|
"Device Object 123, the device-instance would be 123.\n");
|
||||||
"\nobject-type:\n"
|
printf("\n");
|
||||||
|
printf("object-type:\n"
|
||||||
"The object type is object that you are reading. It\n"
|
"The object type is object that you are reading. It\n"
|
||||||
"can be defined either as the object-type name string\n"
|
"can be defined either as the object-type name string\n"
|
||||||
"as defined in the BACnet specification, or as the\n"
|
"as defined in the BACnet specification, or as the\n"
|
||||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||||
"in bacenum.h. For example if you were reading Analog\n"
|
"in bacenum.h. For example if you were reading Analog\n"
|
||||||
"Output 2, the object-type would be analog-output or 1.\n"
|
"Output 2, the object-type would be analog-output or 1.\n");
|
||||||
"\nobject-instance:\n"
|
printf("\n");
|
||||||
|
printf("object-instance:\n"
|
||||||
"This is the object instance number of the object that\n"
|
"This is the object instance number of the object that\n"
|
||||||
"you are writing. For example, if you were writing\n"
|
"you are writing. For example, if you were writing\n"
|
||||||
"Analog Output 2, the object-instance would be 2.\n"
|
"Analog Output 2, the object-instance would be 2.\n");
|
||||||
"\nproperty:\n"
|
printf("\n");
|
||||||
|
printf("property:\n"
|
||||||
"The property is an integer value of the enumeration\n"
|
"The property is an integer value of the enumeration\n"
|
||||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
"BACNET_PROPERTY_ID in bacenum.h. It is the property\n"
|
||||||
"you are writing. For example, if you were writing the\n"
|
"you are writing. For example, if you were writing the\n"
|
||||||
"Present Value property, use 85 as the property.\n"
|
"Present Value property, use 85 as the property.\n");
|
||||||
"priority:\n"
|
printf("\n");
|
||||||
|
printf("priority:\n"
|
||||||
"This parameter is used for setting the priority of the\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"
|
"write. If Priority 0 is given, no priority is sent. The BACnet \n"
|
||||||
"standard states that the value is written at the lowest \n"
|
"standard states that the value is written at the lowest \n"
|
||||||
"priority (16) if the object property supports priorities\n"
|
"priority (16) if the object property supports priorities\n"
|
||||||
"when no priority is sent.\n"
|
"when no priority is sent.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"index\n"
|
printf("index:\n"
|
||||||
"This integer parameter is the index number of an array.\n"
|
"This integer parameter is the index number of an array.\n"
|
||||||
"If the property is an array, individual elements can be written\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"
|
"to if supported. If this parameter is -1, the index is ignored.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"tag:\n"
|
printf("tag:\n"
|
||||||
"Tag is the integer value of the enumeration BACNET_APPLICATION_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"
|
"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"
|
"writing. For example, if you were writing a REAL value, you would \n"
|
||||||
"use a tag of 4.\n"
|
"use a tag of 4.\n"
|
||||||
"Context tags are created using two tags in a row. The context tag\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"
|
"is preceded by a C. Ctag tag. C2 4 creates a context 2 tagged REAL.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"value:\n"
|
printf("value:\n"
|
||||||
"The value is an ASCII representation of some type of data that you\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"
|
"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"
|
"example, if you were writing a REAL value of 100.0, you would use \n"
|
||||||
"100.0 as the value.\n"
|
"100.0 as the value.\n");
|
||||||
"\n"
|
printf("\n");
|
||||||
"Here is a brief overview of BACnet property and tags:\n"
|
printf("Here is a brief overview of BACnet property and tags:\n"
|
||||||
"Certain properties are expected to be written with certain \n"
|
"Certain properties are expected to be written with certain \n"
|
||||||
"application tags, so you probably need to know which ones to use\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"
|
"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"
|
"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"
|
"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"
|
"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"
|
"accepting REAL, BOOLEAN, NULL, etc.\n");
|
||||||
"the demo to use this kind of table - but I also wanted to be able\n"
|
printf("Perhaps it would be simpler for the demo to use this\n"
|
||||||
"to do negative testing by passing the wrong tag and have the server\n"
|
"kind of table - but this tool can also be used for negative\n"
|
||||||
"return a reject message.\n\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"
|
printf("Example:\n"
|
||||||
"If you want send a value of 100 to the Present-Value in\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"
|
"Analog Output 44 and 45 of Device 123 at priority 16,\n"
|
||||||
"send the following command:\n"
|
"send the following command:\n"
|
||||||
"%s 123 1 44 85 16 4 100 1 45 85 16 4 100\n",
|
"%s 123 1 44 85 16 4 100 1 45 85 16 4 100\n",
|
||||||
filename);
|
filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
|
|||||||
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
||||||
{
|
{
|
||||||
/* not something we do within this driver */
|
/* not something we do within this driver */
|
||||||
|
(void)addr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +231,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
|
|||||||
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||||
{
|
{
|
||||||
/* not something we do within this driver */
|
/* not something we do within this driver */
|
||||||
|
(void)addr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +257,7 @@ bool bip_get_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
|||||||
bool bip_set_subnet_prefix(uint8_t prefix)
|
bool bip_set_subnet_prefix(uint8_t prefix)
|
||||||
{
|
{
|
||||||
/* not something we do within this driver */
|
/* not something we do within this driver */
|
||||||
|
(void)prefix;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +339,7 @@ uint16_t bip_receive(
|
|||||||
int max = 0;
|
int max = 0;
|
||||||
struct timeval select_timeout;
|
struct timeval select_timeout;
|
||||||
struct sockaddr_in sin = { 0 };
|
struct sockaddr_in sin = { 0 };
|
||||||
BACNET_IP_ADDRESS addr = { { 0 } };
|
BACNET_IP_ADDRESS addr = { 0 };
|
||||||
socklen_t sin_len = sizeof(sin);
|
socklen_t sin_len = sizeof(sin);
|
||||||
int received_bytes = 0;
|
int received_bytes = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@@ -657,6 +660,8 @@ static void parseRoutes(struct nlmsghdr *nlHdr, struct route_info *rtInfo)
|
|||||||
case RTA_DST:
|
case RTA_DST:
|
||||||
rtInfo->dstAddr = *(u_int *)RTA_DATA(rtAttr);
|
rtInfo->dstAddr = *(u_int *)RTA_DATA(rtAttr);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,11 +117,11 @@ static struct timespec start;
|
|||||||
static int timespec_subtract(
|
static int timespec_subtract(
|
||||||
struct timespec *result, const struct timespec *l, const struct timespec *r)
|
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;
|
struct timespec right = *r;
|
||||||
int secs;
|
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) {
|
if (l->tv_nsec < right.tv_nsec) {
|
||||||
secs = (right.tv_nsec - l->tv_nsec) / NS_PER_S + 1;
|
secs = (right.tv_nsec - l->tv_nsec) / NS_PER_S + 1;
|
||||||
right.tv_nsec -= NS_PER_S * secs;
|
right.tv_nsec -= NS_PER_S * secs;
|
||||||
@@ -133,7 +133,7 @@ static int timespec_subtract(
|
|||||||
right.tv_sec -= secs;
|
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_sec = l->tv_sec - right.tv_sec;
|
||||||
result->tv_nsec = l->tv_nsec - right.tv_nsec;
|
result->tv_nsec = l->tv_nsec - right.tv_nsec;
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -632,7 +632,8 @@ void RS485_Print_Ports(void)
|
|||||||
bool valid_port = false;
|
bool valid_port = false;
|
||||||
struct serial_struct serinfo;
|
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);
|
n = scandir(sysdir, &namelist, NULL, NULL);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
perror("RS485: scandir");
|
perror("RS485: scandir");
|
||||||
@@ -642,7 +643,7 @@ void RS485_Print_Ports(void)
|
|||||||
strcmp(namelist[n]->d_name, ".")) {
|
strcmp(namelist[n]->d_name, ".")) {
|
||||||
snprintf(device_dir, sizeof(device_dir), "%s%s/device", sysdir,
|
snprintf(device_dir, sizeof(device_dir), "%s%s/device", sysdir,
|
||||||
namelist[n]->d_name);
|
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)) {
|
if (lstat(device_dir, &st) == 0 && S_ISLNK(st.st_mode)) {
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
snprintf(device_dir, sizeof(device_dir),
|
snprintf(device_dir, sizeof(device_dir),
|
||||||
@@ -651,16 +652,16 @@ void RS485_Print_Ports(void)
|
|||||||
valid_port = false;
|
valid_port = false;
|
||||||
driver_name = basename(buffer);
|
driver_name = basename(buffer);
|
||||||
if (strcmp(driver_name, "serial8250") == 0) {
|
if (strcmp(driver_name, "serial8250") == 0) {
|
||||||
// serial8250-devices must be probed
|
/* serial8250-devices must be probed */
|
||||||
snprintf(device_dir, sizeof(device_dir), "/dev/%s",
|
snprintf(device_dir, sizeof(device_dir), "/dev/%s",
|
||||||
namelist[n]->d_name);
|
namelist[n]->d_name);
|
||||||
fd = open(
|
fd = open(
|
||||||
device_dir, O_RDWR | O_NONBLOCK | O_NOCTTY);
|
device_dir, O_RDWR | O_NONBLOCK | O_NOCTTY);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
// Get serial_info
|
/* Get serial_info */
|
||||||
if (ioctl(fd, TIOCGSERIAL, &serinfo) == 0) {
|
if (ioctl(fd, TIOCGSERIAL, &serinfo) == 0) {
|
||||||
// If device type is not PORT_UNKNOWN
|
/* If device type is not PORT_UNKNOWN */
|
||||||
// we accept the port
|
/* we accept the port */
|
||||||
if (serinfo.type != PORT_UNKNOWN) {
|
if (serinfo.type != PORT_UNKNOWN) {
|
||||||
valid_port = true;
|
valid_port = true;
|
||||||
}
|
}
|
||||||
@@ -671,7 +672,7 @@ void RS485_Print_Ports(void)
|
|||||||
valid_port = true;
|
valid_port = true;
|
||||||
}
|
}
|
||||||
if (valid_port) {
|
if (valid_port) {
|
||||||
// print full absolute file path
|
/* print full absolute file path */
|
||||||
printf("interface {value=/dev/%s}"
|
printf("interface {value=/dev/%s}"
|
||||||
"{display=MS/TP Capture on /dev/%s}\n",
|
"{display=MS/TP Capture on /dev/%s}\n",
|
||||||
namelist[n]->d_name, namelist[n]->d_name);
|
namelist[n]->d_name, namelist[n]->d_name);
|
||||||
|
|||||||
@@ -158,8 +158,16 @@ CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
|||||||
CFLAGS += -fno-builtin
|
CFLAGS += -fno-builtin
|
||||||
# place uninitialized global variables in the data section of the object file.
|
# place uninitialized global variables in the data section of the object file.
|
||||||
CFLAGS += -fno-common
|
CFLAGS += -fno-common
|
||||||
# enable all relevant warnings
|
# enable all relevant warnings that find bugs
|
||||||
CFLAGS += -Wall
|
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
|
# don't warn about missing braces since GCC is over-achiever for this
|
||||||
CFLAGS += -Wno-missing-braces
|
CFLAGS += -Wno-missing-braces
|
||||||
# don't warn about missing prototypes since STM32 library doesn't have some
|
# 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 <stdlib.h> /* for strtol */
|
||||||
#include <ctype.h> /* for isalnum */
|
#include <ctype.h> /* for isalnum */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef __STDC_ISO_10646__
|
#include <math.h>
|
||||||
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -1168,9 +1169,9 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
// NOTE:
|
/* NOTE: */
|
||||||
// When adding impl for a new prop, also add its tag
|
/* When adding impl for a new prop, also add its tag */
|
||||||
// to bacapp_known_property_tag()
|
/* to bacapp_known_property_tag() */
|
||||||
|
|
||||||
int tag = bacapp_known_property_tag(object_type, property);
|
int tag = bacapp_known_property_tag(object_type, property);
|
||||||
if (tag != -1) {
|
if (tag != -1) {
|
||||||
@@ -1690,7 +1691,7 @@ static int bacapp_snprintf_weeklyschedule(char *str,
|
|||||||
"Sun" };
|
"Sun" };
|
||||||
const int loopend = ((arrayIndex == BACNET_ARRAY_ALL) ? 7 : 1);
|
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;
|
int inner_tag = -1;
|
||||||
for (wi = 0; wi < loopend; wi++) {
|
for (wi = 0; wi < loopend; wi++) {
|
||||||
BACNET_DAILY_SCHEDULE *ds = &ws->weeklySchedule[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)
|
#if defined(BACAPP_OCTET_STRING) || defined(BACAPP_TYPES_EXTRA)
|
||||||
uint8_t *octet_str;
|
uint8_t *octet_str;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
/* Wide character (decoded from multi-byte character). */
|
/* Wide character (decoded from multi-byte character). */
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
/* Wide character length in bytes. */
|
/* Wide character length in bytes. */
|
||||||
@@ -1917,7 +1918,7 @@ int bacapp_snprintf_value(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret_val += slen;
|
ret_val += slen;
|
||||||
#ifdef __STDC_ISO_10646__
|
#if (__STDC_VERSION__ >= 199901L) && defined (__STDC_ISO_10646__)
|
||||||
if (characterstring_encoding(&value->type.Character_String) ==
|
if (characterstring_encoding(&value->type.Character_String) ==
|
||||||
CHARACTER_UTF8) {
|
CHARACTER_UTF8) {
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
@@ -2164,7 +2165,7 @@ int bacapp_snprintf_value(
|
|||||||
ret_val += slen;
|
ret_val += slen;
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_TIMESTAMP:
|
case BACNET_APPLICATION_TAG_TIMESTAMP:
|
||||||
//ISO 8601 format
|
/*ISO 8601 format */
|
||||||
slen = snprintf(str, str_len, "%04u-%02u-%02uT%02u:%02u:%02u.%03u",
|
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.year,
|
||||||
(unsigned) value->type.Time_Stamp.value.dateTime.date.month,
|
(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)
|
static char *rtrim(char *str, const char *trimmedchars)
|
||||||
{
|
{
|
||||||
|
char *end;
|
||||||
|
|
||||||
if (str[0] == 0) {
|
if (str[0] == 0) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
char *end = str + strlen(str) - 1;
|
end = str + strlen(str) - 1;
|
||||||
while (strchr(trimmedchars, *end)) {
|
while (strchr(trimmedchars, *end)) {
|
||||||
*end = 0;
|
*end = 0;
|
||||||
if (end == str)
|
if (end == str)
|
||||||
@@ -2380,7 +2383,7 @@ static char *trim(char *str, const char *trimmedchars)
|
|||||||
static bool parse_weeklyschedule(
|
static bool parse_weeklyschedule(
|
||||||
char *str, BACNET_APPLICATION_DATA_VALUE *value)
|
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;
|
int daynum = 0, tvnum = 0;
|
||||||
unsigned int inner_tag;
|
unsigned int inner_tag;
|
||||||
BACNET_APPLICATION_DATA_VALUE dummy_value = { 0 };
|
BACNET_APPLICATION_DATA_VALUE dummy_value = { 0 };
|
||||||
@@ -2402,13 +2405,13 @@ static bool parse_weeklyschedule(
|
|||||||
|
|
||||||
value->tag = BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE;
|
value->tag = BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE;
|
||||||
|
|
||||||
// Parse the inner tag
|
/* Parse the inner tag */
|
||||||
chunk = strtok(str, ";");
|
chunk = strtok(str, ";");
|
||||||
chunk = ltrim(chunk, "(");
|
chunk = ltrim(chunk, "(");
|
||||||
if (false ==
|
if (false ==
|
||||||
bacapp_parse_application_data(
|
bacapp_parse_application_data(
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT, chunk, &dummy_value)) {
|
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)) {
|
if (false == bactext_application_tag_index(chunk, &inner_tag)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2421,43 +2424,43 @@ static bool parse_weeklyschedule(
|
|||||||
while (chunk != NULL) {
|
while (chunk != NULL) {
|
||||||
dsch = &value->type.Weekly_Schedule.weeklySchedule[daynum];
|
dsch = &value->type.Weekly_Schedule.weeklySchedule[daynum];
|
||||||
|
|
||||||
// Strip day name prefix, if present
|
/* Strip day name prefix, if present */
|
||||||
char *colonpos = strchr(chunk, ':');
|
colonpos = strchr(chunk, ':');
|
||||||
char *sqpos = strchr(chunk, '[');
|
sqpos = strchr(chunk, '[');
|
||||||
if (colonpos && colonpos < sqpos) {
|
if (colonpos && colonpos < sqpos) {
|
||||||
chunk = colonpos + 1;
|
chunk = colonpos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the inner list of time-values
|
/* Extract the inner list of time-values */
|
||||||
chunk = rtrim(ltrim(chunk, "([ "), " ])");
|
chunk = rtrim(ltrim(chunk, "([ "), " ])");
|
||||||
|
|
||||||
// The list can be empty
|
/* The list can be empty */
|
||||||
if (chunk[0] != 0) {
|
if (chunk[0] != 0) {
|
||||||
// loop through the time value pairs
|
/* loop through the time value pairs */
|
||||||
tvnum = 0;
|
tvnum = 0;
|
||||||
do {
|
do {
|
||||||
// Find the comma delimiter, replace with NUL (like strtok)
|
/* Find the comma delimiter, replace with NUL (like strtok) */
|
||||||
comma = strchr(chunk, ',');
|
comma = strchr(chunk, ',');
|
||||||
if (comma) {
|
if (comma) {
|
||||||
*comma = 0;
|
*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, " ");
|
chunk = trim(chunk, " ");
|
||||||
space = strchr(chunk, ' ');
|
space = strchr(chunk, ' ');
|
||||||
if (!space) {
|
if (!space) {
|
||||||
// malformed time-value pair
|
/* malformed time-value pair */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*space = 0;
|
*space = 0;
|
||||||
|
|
||||||
// Extract time and value
|
/* Extract time and value */
|
||||||
t = chunk;
|
t = chunk;
|
||||||
// value starts one byte after the space, and there can be
|
/* value starts one byte after the space, and there can be */
|
||||||
// multiple spaces
|
/* multiple spaces */
|
||||||
chunk = ltrim(space + 1, " ");
|
chunk = ltrim(space + 1, " ");
|
||||||
v = chunk;
|
v = chunk;
|
||||||
|
|
||||||
// Parse time
|
/* Parse time */
|
||||||
if (false ==
|
if (false ==
|
||||||
bacapp_parse_application_data(
|
bacapp_parse_application_data(
|
||||||
BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
||||||
@@ -2465,7 +2468,7 @@ static bool parse_weeklyschedule(
|
|||||||
}
|
}
|
||||||
dsch->Time_Values[tvnum].Time = dummy_value.type.Time;
|
dsch->Time_Values[tvnum].Time = dummy_value.type.Time;
|
||||||
|
|
||||||
// Parse value
|
/* Parse value */
|
||||||
if (false ==
|
if (false ==
|
||||||
bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -2476,7 +2479,7 @@ static bool parse_weeklyschedule(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance past the comma to the next chunk
|
/* Advance past the comma to the next chunk */
|
||||||
if (comma) {
|
if (comma) {
|
||||||
chunk = comma + 1;
|
chunk = comma + 1;
|
||||||
}
|
}
|
||||||
@@ -2486,7 +2489,7 @@ static bool parse_weeklyschedule(
|
|||||||
|
|
||||||
dsch->TV_Count = tvnum;
|
dsch->TV_Count = tvnum;
|
||||||
|
|
||||||
// Find the start of the next day
|
/* Find the start of the next day */
|
||||||
chunk = strtok(NULL, ";");
|
chunk = strtok(NULL, ";");
|
||||||
daynum++;
|
daynum++;
|
||||||
}
|
}
|
||||||
@@ -2506,11 +2509,11 @@ static bool strtol_checked(const char *s, long *out)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
*out = strtol(s, &end, 0);
|
*out = strtol(s, &end, 0);
|
||||||
if (end == s) {
|
if (end == s) {
|
||||||
// Conversion was not possible
|
/* Conversion was not possible */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
// Number too large
|
/* Number too large */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2524,11 +2527,11 @@ static bool strtoul_checked(const char *s, BACNET_UNSIGNED_INTEGER *out)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
*out = strtoul(s, &end, 0);
|
*out = strtoul(s, &end, 0);
|
||||||
if (end == s) {
|
if (end == s) {
|
||||||
// Conversion was not possible
|
/* Conversion was not possible */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
// Number too large
|
/* Number too large */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2542,11 +2545,11 @@ static bool strtod_checked(const char *s, double *out)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
*out = strtod(s, &end);
|
*out = strtod(s, &end);
|
||||||
if (end == s) {
|
if (end == s) {
|
||||||
// Conversion was not possible
|
/* Conversion was not possible */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
// Number too large
|
/* Number too large */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2869,14 +2872,14 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
|||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_REAL)
|
#if defined(BACAPP_REAL)
|
||||||
case BACNET_APPLICATION_TAG_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;
|
status = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_DOUBLE)
|
#if defined(BACAPP_DOUBLE)
|
||||||
case BACNET_APPLICATION_TAG_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;
|
status = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2066,7 +2066,7 @@ typedef enum BACnetColorTransition {
|
|||||||
BACNET_COLOR_TRANSITION_NONE = 0,
|
BACNET_COLOR_TRANSITION_NONE = 0,
|
||||||
BACNET_COLOR_TRANSITION_FADE = 1,
|
BACNET_COLOR_TRANSITION_FADE = 1,
|
||||||
BACNET_COLOR_TRANSITION_RAMP = 2,
|
BACNET_COLOR_TRANSITION_RAMP = 2,
|
||||||
BACNET_COLOR_TRANSITION_MAX = 3,
|
BACNET_COLOR_TRANSITION_MAX = 3
|
||||||
} BACNET_COLOR_TRANSITION;
|
} BACNET_COLOR_TRANSITION;
|
||||||
|
|
||||||
/* NOTE: BACNET_DAYS_OF_WEEK is different than BACNET_WEEKDAY */
|
/* 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;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for valid bytes after the 2nd, if any; all must start 10 */
|
/* 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 len;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
uint8_t *apdu_offset = NULL;
|
uint8_t *apdu_offset = NULL;
|
||||||
|
BACNET_APPLICATION_DATA_VALUE adv;
|
||||||
|
|
||||||
if (!value || !is_data_value_schedule_compatible(value->Value.tag)) {
|
if (!value || !is_data_value_schedule_compatible(value->Value.tag)) {
|
||||||
return BACNET_STATUS_ERROR;
|
return BACNET_STATUS_ERROR;
|
||||||
@@ -93,10 +94,7 @@ int bacnet_time_value_encode(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
|||||||
if (apdu) {
|
if (apdu) {
|
||||||
apdu_offset = &apdu[apdu_len];
|
apdu_offset = &apdu[apdu_len];
|
||||||
}
|
}
|
||||||
|
|
||||||
BACNET_APPLICATION_DATA_VALUE adv;
|
|
||||||
bacnet_primitive_to_application_data_value(&adv, &value->Value);
|
bacnet_primitive_to_application_data_value(&adv, &value->Value);
|
||||||
|
|
||||||
len = bacapp_encode_application_data(apdu_offset, &adv);
|
len = bacapp_encode_application_data(apdu_offset, &adv);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
@@ -147,7 +145,7 @@ int bacnet_application_to_primitive_data_value(
|
|||||||
struct BACnet_Primitive_Data_Value *dest,
|
struct BACnet_Primitive_Data_Value *dest,
|
||||||
const struct BACnet_Application_Data_Value *src)
|
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)) {
|
if (!src || !dest || !is_data_value_schedule_compatible(src->tag)) {
|
||||||
return BACNET_STATUS_ERROR;
|
return BACNET_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@@ -162,7 +160,7 @@ int bacnet_primitive_to_application_data_value(
|
|||||||
struct BACnet_Application_Data_Value *dest,
|
struct BACnet_Application_Data_Value *dest,
|
||||||
const struct BACnet_Primitive_Data_Value *src)
|
const struct BACnet_Primitive_Data_Value *src)
|
||||||
{
|
{
|
||||||
// make sure the value passed is valid
|
/* make sure the value passed is valid */
|
||||||
if (!dest || !src) {
|
if (!dest || !src) {
|
||||||
return BACNET_STATUS_ERROR;
|
return BACNET_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,10 @@
|
|||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
#include "bacnet/proplist.h"
|
#include "bacnet/proplist.h"
|
||||||
#include "bacnet/timestamp.h"
|
#include "bacnet/timestamp.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/object/ai.h"
|
#include "bacnet/basic/object/ai.h"
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_perror
|
||||||
#include <stdio.h>
|
|
||||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX_ANALOG_INPUTS
|
#ifndef MAX_ANALOG_INPUTS
|
||||||
#define MAX_ANALOG_INPUTS 4
|
#define MAX_ANALOG_INPUTS 4
|
||||||
|
|||||||
@@ -236,12 +236,14 @@ bool Analog_Value_Present_Value_Set(
|
|||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
|
(void)priority;
|
||||||
index = Analog_Value_Instance_To_Index(object_instance);
|
index = Analog_Value_Instance_To_Index(object_instance);
|
||||||
if (index < MAX_ANALOG_VALUES) {
|
if (index < MAX_ANALOG_VALUES) {
|
||||||
Analog_Value_COV_Detect(index, value);
|
Analog_Value_COV_Detect(index, value);
|
||||||
AV_Descr[index].Present_Value = value;
|
AV_Descr[index].Present_Value = value;
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,6 +1138,8 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
|||||||
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
||||||
event_data.timeStamp.value.dateTime;
|
event_data.timeStamp.value.dateTime;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -657,6 +657,7 @@ int Channel_Value_Encode(
|
|||||||
{
|
{
|
||||||
int apdu_len = BACNET_STATUS_ERROR;
|
int apdu_len = BACNET_STATUS_ERROR;
|
||||||
|
|
||||||
|
(void)apdu_max;
|
||||||
if (!apdu || !value) {
|
if (!apdu || !value) {
|
||||||
return BACNET_STATUS_ERROR;
|
return BACNET_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@@ -907,7 +908,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
|
|||||||
#if defined(BACAPP_REAL)
|
#if defined(BACAPP_REAL)
|
||||||
case BACNET_APPLICATION_TAG_REAL:
|
case BACNET_APPLICATION_TAG_REAL:
|
||||||
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||||
if (value->type.Real != 0.0F) {
|
if (islessgreater(value->type.Real, 0.0F)) {
|
||||||
boolean_value = true;
|
boolean_value = true;
|
||||||
}
|
}
|
||||||
apdu_len =
|
apdu_len =
|
||||||
@@ -954,7 +955,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
|
|||||||
#if defined(BACAPP_DOUBLE)
|
#if defined(BACAPP_DOUBLE)
|
||||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||||
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||||
if (value->type.Double != 0.0) {
|
if (islessgreater(value->type.Double, 0.0)) {
|
||||||
boolean_value = true;
|
boolean_value = true;
|
||||||
}
|
}
|
||||||
apdu_len =
|
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 Command_Intrinsic_Reporting(uint32_t object_instance)
|
||||||
{
|
{
|
||||||
|
(void)object_instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,16 +39,9 @@
|
|||||||
#include "bacnet/basic/object/ao.h"
|
#include "bacnet/basic/object/ao.h"
|
||||||
#include "bacnet/wp.h"
|
#include "bacnet/wp.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
|
|
||||||
#ifndef LOAD_CONTROL_DEBUG
|
#define PRINTF debug_printf
|
||||||
#define LOAD_CONTROL_DEBUG 0
|
|
||||||
#endif
|
|
||||||
#if LOAD_CONTROL_DEBUG
|
|
||||||
#include <sys/PRINTF.h>
|
|
||||||
#define PRINTF(...) printk(__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* number of demo objects */
|
/* number of demo objects */
|
||||||
#ifndef MAX_LOAD_CONTROLS
|
#ifndef MAX_LOAD_CONTROLS
|
||||||
@@ -67,7 +60,7 @@ typedef enum BACnetShedLevelType {
|
|||||||
|
|
||||||
#define DEFAULT_VALUE_PERCENT 100
|
#define DEFAULT_VALUE_PERCENT 100
|
||||||
#define DEFAULT_VALUE_LEVEL 0
|
#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
|
/* The shed levels for the LEVEL choice of BACnetShedLevel
|
||||||
that have meaning for this particular Load Control object. */
|
that have meaning for this particular Load Control object. */
|
||||||
@@ -423,7 +416,7 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BACNET_SHED_TYPE_AMOUNT:
|
case BACNET_SHED_TYPE_AMOUNT:
|
||||||
if (Requested_Shed_Level[object_index].value.amount ==
|
if (Requested_Shed_Level[object_index].value.amount <=
|
||||||
DEFAULT_VALUE_AMOUNT) {
|
DEFAULT_VALUE_AMOUNT) {
|
||||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||||
}
|
}
|
||||||
@@ -431,7 +424,7 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
case BACNET_SHED_TYPE_LEVEL:
|
case BACNET_SHED_TYPE_LEVEL:
|
||||||
default:
|
default:
|
||||||
if (Requested_Shed_Level[object_index].value.level ==
|
if (Requested_Shed_Level[object_index].value.level ==
|
||||||
DEFAULT_VALUE_LEVEL) {
|
DEFAULT_VALUE_LEVEL) {
|
||||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1228,7 +1228,12 @@ static void Lighting_Output_Ramp_Handler(struct lighting_output_object *pLight,
|
|||||||
BACNET_LIGHTING_COMMAND *pCommand,
|
BACNET_LIGHTING_COMMAND *pCommand,
|
||||||
uint16_t milliseconds)
|
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,
|
BACNET_LIGHTING_COMMAND *pCommand,
|
||||||
uint16_t milliseconds)
|
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)
|
static uint32_t Multistate_Input_Max_States(uint32_t instance)
|
||||||
{
|
{
|
||||||
|
(void)instance;
|
||||||
return MULTISTATE_NUMBER_OF_STATES;
|
return MULTISTATE_NUMBER_OF_STATES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,17 +43,13 @@
|
|||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h"
|
||||||
#include "bacnet/event.h"
|
#include "bacnet/event.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
#include "bacnet/wp.h"
|
#include "bacnet/wp.h"
|
||||||
#include "bacnet/basic/object/nc.h"
|
#include "bacnet/basic/object/nc.h"
|
||||||
#include "bacnet/datalink/datalink.h"
|
#include "bacnet/datalink/datalink.h"
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_perror
|
||||||
#include <stdio.h>
|
|
||||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX_NOTIFICATION_CLASSES
|
#ifndef MAX_NOTIFICATION_CLASSES
|
||||||
#define MAX_NOTIFICATION_CLASSES 2
|
#define MAX_NOTIFICATION_CLASSES 2
|
||||||
@@ -747,8 +743,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
|||||||
* &src); */
|
* &src); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = true;
|
status = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
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)
|
int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||||
{
|
{
|
||||||
|
(void)apdu;
|
||||||
|
(void)pRequest;
|
||||||
return 0;
|
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)
|
int Network_Port_Read_Range_FDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||||
{
|
{
|
||||||
|
(void)apdu;
|
||||||
|
(void)pRequest;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ bool OctetString_Value_Present_Value_Set(
|
|||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
|
(void)priority;
|
||||||
index = OctetString_Value_Instance_To_Index(object_instance);
|
index = OctetString_Value_Instance_To_Index(object_instance);
|
||||||
if (index < MAX_OCTETSTRING_VALUES) {
|
if (index < MAX_OCTETSTRING_VALUES) {
|
||||||
octetstring_copy(&OSV_Descr[index].Present_Value, value);
|
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 OctetString_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||||
{
|
{
|
||||||
|
(void)object_instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,11 +140,13 @@ bool PositiveInteger_Value_Present_Value_Set(
|
|||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
|
(void)priority;
|
||||||
index = PositiveInteger_Value_Instance_To_Index(object_instance);
|
index = PositiveInteger_Value_Instance_To_Index(object_instance);
|
||||||
if (index < MAX_POSITIVEINTEGER_VALUES) {
|
if (index < MAX_POSITIVEINTEGER_VALUES) {
|
||||||
PIV_Descr[index].Present_Value = value;
|
PIV_Descr[index].Present_Value = value;
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
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 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:
|
case TL_TYPE_ANY:
|
||||||
/* Should never happen as we don't support this at the moment */
|
/* Should never happen as we don't support this at the moment */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
iLen += encode_closing_tag(&apdu[iLen], 1);
|
iLen += encode_closing_tag(&apdu[iLen], 1);
|
||||||
|
|||||||
@@ -39,14 +39,10 @@
|
|||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
#include "bacnet/datalink/datalink.h"
|
#include "bacnet/datalink/datalink.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
|
|
||||||
/** @file h_ccov.c Handles Confirmed COV Notifications. */
|
/** @file h_ccov.c Handles Confirmed COV Notifications. */
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_perror
|
||||||
#include <stdio.h>
|
|
||||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* max number of COV properties decoded in a COV notification */
|
/* max number of COV properties decoded in a COV notification */
|
||||||
#ifndef MAX_COV_PROPERTIES
|
#ifndef MAX_COV_PROPERTIES
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ void get_alarm_summary_ack_handler(uint8_t *service_request,
|
|||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
BACNET_GET_ALARM_SUMMARY_DATA data;
|
BACNET_GET_ALARM_SUMMARY_DATA data;
|
||||||
|
|
||||||
|
(void)src;
|
||||||
|
(void)service_data;
|
||||||
while (service_len - len) {
|
while (service_len - len) {
|
||||||
apdu_len = get_alarm_summary_ack_decode_apdu_data(
|
apdu_len = get_alarm_summary_ack_decode_apdu_data(
|
||||||
&service_request[len], service_len - len, &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_NPDU_DATA npdu_data;
|
||||||
BACNET_GET_ALARM_SUMMARY_DATA getalarm_data;
|
BACNET_GET_ALARM_SUMMARY_DATA getalarm_data;
|
||||||
|
|
||||||
|
(void)service_request;
|
||||||
|
(void)service_len;
|
||||||
/* encode the NPDU portion of the packet */
|
/* encode the NPDU portion of the packet */
|
||||||
datalink_get_my_address(&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
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(
|
void ge_ack_print_data(
|
||||||
BACNET_GET_EVENT_INFORMATION_DATA *data, uint32_t device_id)
|
BACNET_GET_EVENT_INFORMATION_DATA *data, uint32_t device_id)
|
||||||
{
|
{
|
||||||
|
unsigned int count = 0;
|
||||||
BACNET_GET_EVENT_INFORMATION_DATA *act_data = data;
|
BACNET_GET_EVENT_INFORMATION_DATA *act_data = data;
|
||||||
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
|
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
|
||||||
printf("DeviceID\tType\tInstance\teventState\n");
|
printf("DeviceID\tType\tInstance\teventState\n");
|
||||||
printf("--------------- ------- --------------- ---------------\n");
|
printf("--------------- ------- --------------- ---------------\n");
|
||||||
unsigned int count = 0;
|
|
||||||
while (act_data) {
|
while (act_data) {
|
||||||
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
|
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
|
||||||
act_data->objectIdentifier.type,
|
act_data->objectIdentifier.type,
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ void get_event_ack_handler(uint8_t *service_request,
|
|||||||
multiple get event data in APDU */
|
multiple get event data in APDU */
|
||||||
BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS];
|
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++) {
|
for (i = 1; i < MAX_NUMBER_OF_EVENTS; i++) {
|
||||||
/* Create linked list */
|
/* Create linked list */
|
||||||
get_event_data[i - 1].next = &get_event_data[i];
|
get_event_data[i - 1].next = &get_event_data[i];
|
||||||
|
|||||||
@@ -38,15 +38,10 @@
|
|||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_aprintf
|
||||||
#include <stdio.h>
|
#define PRINTF_ERR debug_perror
|
||||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
|
||||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#define PRINTF_ERR(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @file h_rp_a.c Handles Read Property Acknowledgments. */
|
/** @file h_rp_a.c Handles Read Property Acknowledgments. */
|
||||||
|
|
||||||
|
|||||||
@@ -37,16 +37,11 @@
|
|||||||
/* some demo stuff needed */
|
/* some demo stuff needed */
|
||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_aprintf
|
||||||
#include <stdio.h>
|
#define PERROR debug_perror
|
||||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
|
||||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#define PRINTF_ERR(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @file h_rpm_a.c Handles Read Property Multiple Acknowledgments. */
|
/** @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 then it's an empty structure, which is OK. */
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
/* problem decoding */
|
/* 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_object_type_name(rpm_object->object_type),
|
||||||
bactext_property_name(
|
bactext_property_name(
|
||||||
rpm_property->propertyIdentifier));
|
rpm_property->propertyIdentifier));
|
||||||
@@ -151,7 +146,7 @@ int rpm_ack_decode_service_request(
|
|||||||
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||||
old_value->next = value;
|
old_value->next = value;
|
||||||
} else {
|
} 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_object_type_name(rpm_object->object_type),
|
||||||
bactext_property_name(
|
bactext_property_name(
|
||||||
rpm_property->propertyIdentifier),
|
rpm_property->propertyIdentifier),
|
||||||
@@ -362,7 +357,7 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
|
|||||||
rpm_data = rpm_data_free(rpm_data);
|
rpm_data = rpm_data_free(rpm_data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PRINTF_ERR("RPM Ack Malformed! Freeing memory...\n");
|
PERROR("RPM Ack Malformed! Freeing memory...\n");
|
||||||
while (rpm_data) {
|
while (rpm_data) {
|
||||||
rpm_data = rpm_data_free(rpm_data);
|
rpm_data = rpm_data_free(rpm_data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,15 +36,11 @@
|
|||||||
#include "bacnet/cov.h"
|
#include "bacnet/cov.h"
|
||||||
#include "bacnet/bactext.h"
|
#include "bacnet/bactext.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
|
|
||||||
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
|
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_perror
|
||||||
#include <stdio.h>
|
|
||||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX_COV_PROPERTIES
|
#ifndef MAX_COV_PROPERTIES
|
||||||
#define MAX_COV_PROPERTIES 2
|
#define MAX_COV_PROPERTIES 2
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ void handler_unconfirmed_private_transfer(
|
|||||||
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
|
(void)src;
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
|
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -41,15 +41,11 @@
|
|||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/datalink/datalink.h"
|
#include "bacnet/datalink/datalink.h"
|
||||||
|
|
||||||
/** @file h_wpm.c Handles Write Property Multiple requests. */
|
/** @file h_wpm.c Handles Write Property Multiple requests. */
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_perror
|
||||||
#include <stdio.h>
|
|
||||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Decoding for an object property.
|
/** Decoding for an object property.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -38,16 +38,12 @@
|
|||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h"
|
||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/tsm/tsm.h"
|
#include "bacnet/basic/tsm/tsm.h"
|
||||||
#include "bacnet/datalink/datalink.h"
|
#include "bacnet/datalink/datalink.h"
|
||||||
|
|
||||||
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
|
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
|
||||||
#if PRINT_ENABLED
|
#define PRINTF debug_perror
|
||||||
#include <stdio.h>
|
|
||||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Sends an Confirmed Alarm Acknowledgment.
|
/** Sends an Confirmed Alarm Acknowledgment.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
#include "bacnet/basic/sys/bigend.h"
|
#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. */
|
/* Big-Endian systems save the most significant byte first. */
|
||||||
/* Sun and Motorola processors, IBM-370s and PDP-10s are big-endian. */
|
/* Sun and Motorola processors, IBM-370s and PDP-10s are big-endian. */
|
||||||
/* "Network Byte Order" is also know as "Big-Endian Byte Order" */
|
/* "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,
|
float *y_coordinate,
|
||||||
uint8_t *brightness)
|
uint8_t *brightness)
|
||||||
{
|
{
|
||||||
|
float X, Y, Z;
|
||||||
|
float x, y;
|
||||||
/* Get the RGB values from your color object
|
/* Get the RGB values from your color object
|
||||||
and convert them to be between 0 and 1.
|
and convert them to be between 0 and 1.
|
||||||
So the RGB color (255, 0, 100) becomes (1.0, 0.0, 0.39) */
|
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
|
/* Convert the RGB values to XYZ using the
|
||||||
Wide RGB D65 conversion formula */
|
Wide RGB D65 conversion formula */
|
||||||
float X = red * 0.649926f + green * 0.103455f + blue * 0.197109f;
|
X = red * 0.649926f + green * 0.103455f + blue * 0.197109f;
|
||||||
float Y = red * 0.234327f + green * 0.743075f + blue * 0.022598f;
|
Y = red * 0.234327f + green * 0.743075f + blue * 0.022598f;
|
||||||
float Z = red * 0.0000000f + green * 0.053077f + blue * 1.035763f;
|
Z = red * 0.0000000f + green * 0.053077f + blue * 1.035763f;
|
||||||
|
|
||||||
/* Calculate the xy values from the XYZ values */
|
/* Calculate the xy values from the XYZ values */
|
||||||
float x = X / (X + Y + Z);
|
x = X / (X + Y + Z);
|
||||||
float y = Y / (X + Y + Z);
|
y = Y / (X + Y + Z);
|
||||||
|
|
||||||
x = clamp(x, 0.0f, 1.0f);
|
x = clamp(x, 0.0f, 1.0f);
|
||||||
y = clamp(y, 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,
|
float y_coordinate,
|
||||||
uint8_t brightness)
|
uint8_t brightness)
|
||||||
{
|
{
|
||||||
|
float r, g, b;
|
||||||
|
float x, y, z, X, Y, Z;
|
||||||
|
|
||||||
/* Calculate XYZ values */
|
/* Calculate XYZ values */
|
||||||
float x = x_coordinate;
|
x = x_coordinate;
|
||||||
float y = y_coordinate;
|
y = y_coordinate;
|
||||||
float z = 1.0f - x - y;
|
z = 1.0f - x - y;
|
||||||
float Y = (float)brightness;
|
Y = (float)brightness;
|
||||||
Y /= 255.0f;
|
Y /= 255.0f;
|
||||||
float X = (Y / y) * x;
|
X = x * (Y / y);
|
||||||
float Z = (Y / y) * z;
|
Z = z * (Y / y);
|
||||||
|
|
||||||
/* Convert to RGB using Wide RGB D65 conversion
|
/* Convert to RGB using Wide RGB D65 conversion
|
||||||
(THIS IS A D50 conversion currently) */
|
(THIS IS A D50 conversion currently) */
|
||||||
float r = X * 1.4628067f - Y * 0.1840623f - Z * 0.2743606f;
|
r = X * 1.4628067f - Y * 0.1840623f - Z * 0.2743606f;
|
||||||
float g = -X * 0.5217933f + Y * 1.4472381f + Z * 0.0677227f;
|
g = -X * 0.5217933f + Y * 1.4472381f + Z * 0.0677227f;
|
||||||
float b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||||
|
|
||||||
/* Apply reverse gamma correction */
|
/* Apply reverse gamma correction */
|
||||||
r = r <= 0.0031308f ? 12.92f * r
|
r = r <= 0.0031308f ? 12.92f * r
|
||||||
|
|||||||
@@ -59,3 +59,59 @@ void debug_printf(const char *format, ...)
|
|||||||
(void)format;
|
(void)format;
|
||||||
}
|
}
|
||||||
#endif
|
#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(
|
void debug_printf(
|
||||||
const char *format,
|
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
|
#if DEBUG_ENABLED
|
||||||
/* Nothing more here */
|
/* Nothing more here */
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -18,6 +18,12 @@
|
|||||||
#ifndef BACNET_SYS_PLATFORM_H
|
#ifndef BACNET_SYS_PLATFORM_H
|
||||||
#define 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' */
|
/* marking some code as 'deprecated' */
|
||||||
# if defined(_MSC_VER)
|
# if defined(_MSC_VER)
|
||||||
# define BACNET_STACK_DEPRECATED(message) __declspec(deprecated(message))
|
# define BACNET_STACK_DEPRECATED(message) __declspec(deprecated(message))
|
||||||
@@ -31,4 +37,10 @@
|
|||||||
# define strcasecmp _stricmp
|
# define strcasecmp _stricmp
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define BACNET_STACK_FALLTHROUGH() __attribute__ ((fallthrough))
|
||||||
|
#else
|
||||||
|
#define BACNET_STACK_FALLTHROUGH() /* fall through */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ static int notify_encode_apdu(
|
|||||||
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
||||||
BACNET_APPLICATION_DATA_VALUE *app_data = NULL;
|
BACNET_APPLICATION_DATA_VALUE *app_data = NULL;
|
||||||
|
|
||||||
|
(void)max_apdu_len;
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
/* tag 0 - subscriberProcessIdentifier */
|
/* tag 0 - subscriberProcessIdentifier */
|
||||||
len = encode_context_unsigned(
|
len = encode_context_unsigned(
|
||||||
@@ -405,6 +406,7 @@ int cov_subscribe_encode_apdu(uint8_t *apdu,
|
|||||||
int len = 0; /* length of each encoding */
|
int len = 0; /* length of each encoding */
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
|
||||||
|
(void)max_apdu_len;
|
||||||
if (apdu && data) {
|
if (apdu && data) {
|
||||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
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 len = 0; /* length of each encoding */
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
|
||||||
|
(void)max_apdu_len;
|
||||||
if (apdu && data) {
|
if (apdu && data) {
|
||||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
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);
|
pEnv = getenv(bbmd_env);
|
||||||
if (pEnv) {
|
if (pEnv) {
|
||||||
bdt_entry_port = strtol(pEnv, NULL, 0);
|
bdt_entry_port = strtol(pEnv, NULL, 0);
|
||||||
if (bdt_entry_port > 0xFFFF) {
|
|
||||||
bdt_entry_port = 0xBAC0;
|
|
||||||
}
|
|
||||||
if (entry_number == 1) {
|
if (entry_number == 1) {
|
||||||
if (BIP_DL_Debug) {
|
if (BIP_DL_Debug) {
|
||||||
fprintf(stderr, "BBMD 1 port overridden %s=%s!\n",
|
fprintf(stderr, "BBMD 1 port overridden %s=%s!\n",
|
||||||
|
|||||||
@@ -20,10 +20,6 @@
|
|||||||
#include "bacnet/bacreal.h"
|
#include "bacnet/bacreal.h"
|
||||||
#include "bacnet/lighting.h"
|
#include "bacnet/lighting.h"
|
||||||
|
|
||||||
#ifndef islessgreater
|
|
||||||
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @file lighting.c Manipulate BACnet lighting command values */
|
/** @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;
|
bool status = false;
|
||||||
|
|
||||||
if (value1 && value2) {
|
if (value1 && value2) {
|
||||||
if ((value1->x_coordinate == value2->x_coordinate) &&
|
if (!islessgreater(value1->x_coordinate, value2->x_coordinate) &&
|
||||||
(value1->y_coordinate == value2->y_coordinate)) {
|
!islessgreater(value1->y_coordinate, value2->y_coordinate)) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1096,9 +1092,9 @@ bool color_command_same(
|
|||||||
status = true;
|
status = true;
|
||||||
break;
|
break;
|
||||||
case BACNET_COLOR_OPERATION_FADE_TO_COLOR:
|
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) &&
|
value2->target.color.x_coordinate) &&
|
||||||
(value1->target.color.y_coordinate ==
|
!islessgreater(value1->target.color.y_coordinate,
|
||||||
value2->target.color.y_coordinate) &&
|
value2->target.color.y_coordinate) &&
|
||||||
(value1->transit.fade_time == value2->transit.fade_time)) {
|
(value1->transit.fade_time == value2->transit.fade_time)) {
|
||||||
status = true;
|
status = true;
|
||||||
|
|||||||
@@ -155,24 +155,27 @@ int bacnet_weeklyschedule_context_decode(uint8_t *apdu,
|
|||||||
bool bacnet_weeklyschedule_same(
|
bool bacnet_weeklyschedule_same(
|
||||||
BACNET_WEEKLY_SCHEDULE *value1, BACNET_WEEKLY_SCHEDULE *value2)
|
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;
|
int wi, ti;
|
||||||
|
|
||||||
for (wi = 0; wi < 7; wi++) {
|
for (wi = 0; wi < 7; wi++) {
|
||||||
BACNET_DAILY_SCHEDULE *ds1 = &value1->weeklySchedule[wi];
|
ds1 = &value1->weeklySchedule[wi];
|
||||||
BACNET_DAILY_SCHEDULE *ds2 = &value2->weeklySchedule[wi];
|
ds2 = &value2->weeklySchedule[wi];
|
||||||
if (ds1->TV_Count != ds2->TV_Count) {
|
if (ds1->TV_Count != ds2->TV_Count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (ti = 0; ti < ds1->TV_Count; ti++) {
|
for (ti = 0; ti < ds1->TV_Count; ti++) {
|
||||||
BACNET_TIME_VALUE *tv1 = &ds1->Time_Values[ti];
|
tv1 = &ds1->Time_Values[ti];
|
||||||
BACNET_TIME_VALUE *tv2 = &ds2->Time_Values[ti];
|
tv2 = &ds2->Time_Values[ti];
|
||||||
if (0 != datetime_compare_time(&tv1->Time, &tv2->Time)) {
|
if (0 != datetime_compare_time(&tv1->Time, &tv2->Time)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO the conversion can be avoided by adding a "primitive"
|
/* TODO the conversion can be avoided by adding a "primitive"
|
||||||
// variant of bacapp_same_value(),
|
variant of bacapp_same_value(),
|
||||||
// at the cost of some code duplication
|
at the cost of some code duplication */
|
||||||
BACNET_APPLICATION_DATA_VALUE adv1, adv2;
|
|
||||||
bacnet_primitive_to_application_data_value(&adv1, &tv1->Value);
|
bacnet_primitive_to_application_data_value(&adv1, &tv1->Value);
|
||||||
bacnet_primitive_to_application_data_value(&adv2, &tv2->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_cov.c
|
||||||
${SRC_DIR}/bacnet/basic/service/h_wp.c
|
${SRC_DIR}/bacnet/basic/service/h_wp.c
|
||||||
${SRC_DIR}/bacnet/basic/sys/bigend.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/sys/keylist.c
|
||||||
${SRC_DIR}/bacnet/basic/tsm/tsm.c
|
${SRC_DIR}/bacnet/basic/tsm/tsm.c
|
||||||
${SRC_DIR}/bacnet/datalink/bvlc.c
|
${SRC_DIR}/bacnet/datalink/bvlc.c
|
||||||
|
|||||||
Reference in New Issue
Block a user