added clang format C and H files.
This commit is contained in:
+104
-72
@@ -1,34 +1,34 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
*
|
||||
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
/* command line tool that sends a BACnet service */
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h> /* for time */
|
||||
#include <time.h> /* for time */
|
||||
#include <errno.h>
|
||||
#include "bactext.h"
|
||||
#include "iam.h"
|
||||
@@ -50,8 +50,7 @@
|
||||
#include "txbuf.h"
|
||||
#include "dlenv.h"
|
||||
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
static void Init_Service_Handlers(void)
|
||||
{
|
||||
Device_Init(NULL);
|
||||
/* we need to handle who-is
|
||||
@@ -61,16 +60,13 @@ static void Init_Service_Handlers(
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_bind);
|
||||
/* set the handler for all the services we don't implement
|
||||
It is required to send the proper reject message... */
|
||||
apdu_set_unrecognized_service_handler_handler
|
||||
(handler_unrecognized_service);
|
||||
apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
|
||||
/* we must implement read property - it's required! */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
handler_read_property);
|
||||
handler_read_property);
|
||||
}
|
||||
|
||||
int main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *value_string = NULL;
|
||||
bool status = false;
|
||||
@@ -80,49 +76,85 @@ int main(
|
||||
|
||||
if (argc < 7) {
|
||||
/* note: priority 16 and 0 should produce the same end results... */
|
||||
printf("Usage: %s pid device-id object-type object-instance "
|
||||
"time property tag value [priority] [index]\r\n" "\r\n" "pid:\r\n"
|
||||
"Process Identifier for this broadcast.\r\n" "\r\n"
|
||||
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"
|
||||
"The Initiating BACnet Device Object Instance number.\r\n"
|
||||
"\r\n"
|
||||
"object-type:\r\n"
|
||||
"The monitored object type is the integer value of the\r\n"
|
||||
"enumeration BACNET_OBJECT_TYPE in bacenum.h. For example,\r\n"
|
||||
"if you were monitoring Analog Output 2, the object-type\r\n"
|
||||
"would be 1.\r\n" "\r\n" "object-instance:\r\n"
|
||||
"The monitored object instance number.\r\n" "\r\n" "time:\r\n"
|
||||
"would be 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"
|
||||
"\r\n"
|
||||
"property:\r\n"
|
||||
"The property is an integer value of the enumeration \r\n"
|
||||
"BACNET_PROPERTY_ID in bacenum.h. For example, if you were\r\n"
|
||||
"monitoring the Present Value property, you would use 85\r\n"
|
||||
"as the property.\r\n" "\r\n" "tag:\r\n"
|
||||
"Tag is the integer value of the enumeration BACNET_APPLICATION_TAG \r\n"
|
||||
"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"
|
||||
"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"
|
||||
"\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"
|
||||
"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 the following command:\r\n"
|
||||
"%s 1 2 3 4 5 85 4 100.0\r\n"
|
||||
@@ -155,34 +187,34 @@ int main(
|
||||
|
||||
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||
cov_data.initiatingDeviceIdentifier, BACNET_MAX_INSTANCE);
|
||||
cov_data.initiatingDeviceIdentifier, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
if (cov_data.monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
|
||||
cov_data.monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE);
|
||||
cov_data.monitoredObjectIdentifier.type,
|
||||
MAX_BACNET_OBJECT_TYPE);
|
||||
return 1;
|
||||
}
|
||||
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "object-instance=%u - it must be less than %u\r\n",
|
||||
cov_data.monitoredObjectIdentifier.instance,
|
||||
BACNET_MAX_INSTANCE + 1);
|
||||
cov_data.monitoredObjectIdentifier.instance,
|
||||
BACNET_MAX_INSTANCE + 1);
|
||||
return 1;
|
||||
}
|
||||
if (cov_data.listOfValues->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
||||
fprintf(stderr, "property-identifier=%u - it must be less than %u\r\n",
|
||||
cov_data.listOfValues->propertyIdentifier,
|
||||
MAX_BACNET_PROPERTY_ID + 1);
|
||||
cov_data.listOfValues->propertyIdentifier,
|
||||
MAX_BACNET_PROPERTY_ID + 1);
|
||||
return 1;
|
||||
}
|
||||
if (tag >= MAX_BACNET_APPLICATION_TAG) {
|
||||
fprintf(stderr, "tag=%u - it must be less than %u\r\n", tag,
|
||||
MAX_BACNET_APPLICATION_TAG);
|
||||
MAX_BACNET_APPLICATION_TAG);
|
||||
return 1;
|
||||
}
|
||||
status =
|
||||
bacapp_parse_application_data(tag, value_string,
|
||||
&cov_data.listOfValues->value);
|
||||
status = bacapp_parse_application_data(tag, value_string,
|
||||
&cov_data.listOfValues->value);
|
||||
if (!status) {
|
||||
/* FIXME: show the expected entry format for the tag */
|
||||
fprintf(stderr, "unable to parse the tag value\r\n");
|
||||
@@ -194,7 +226,7 @@ int main(
|
||||
dlenv_init();
|
||||
atexit(datalink_cleanup);
|
||||
Send_UCOV_Notify(&Handler_Transmit_Buffer[0],
|
||||
sizeof(Handler_Transmit_Buffer), &cov_data);
|
||||
sizeof(Handler_Transmit_Buffer), &cov_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user