indented to standard from script

This commit is contained in:
skarg
2012-05-13 15:07:12 +00:00
parent 173e9fb9a9
commit 48e2c60ce2
130 changed files with 1931 additions and 2014 deletions
+1 -1
View File
@@ -88,7 +88,7 @@
typedef enum {
/** Initial state to establish a binding with the target device. */
INITIAL_BINDING,
/** Get selected device information and put out the heading information. */
/** Get selected device information and put out the heading information. */
GET_HEADING_INFO, GET_HEADING_RESPONSE, PRINT_HEADING,
/** Getting ALL properties and values at once with RPM. */
GET_ALL_REQUEST, GET_ALL_RESPONSE,
+266 -261
View File
@@ -129,17 +129,19 @@ static int32_t Property_List[MAX_PROPS + 2];
#define INIT_ID_PROPLIST_SIZE 5
/* Define Enums to match the property and value arrays below */
enum init_ids { INIT_VENDOR_NAME, INIT_MODEL_NAME, INIT_DESCRIPTION, INIT_OBJ_TYPES };
enum init_ids { INIT_VENDOR_NAME, INIT_MODEL_NAME, INIT_DESCRIPTION,
INIT_OBJ_TYPES };
static int32_t InitIdPropList[INIT_ID_PROPLIST_SIZE] = {
PROP_VENDOR_NAME,
PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */
PROP_DESCRIPTION, /* Optional, but hopefully available */
PROP_VENDOR_NAME,
PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */
PROP_DESCRIPTION, /* Optional, but hopefully available */
PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED,
-1
};
/* Will hold GET_HEADING_RESPONSE results here: */
static BACNET_APPLICATION_DATA_VALUE * InitIdValues[INIT_ID_PROPLIST_SIZE] =
{ NULL, NULL, NULL, NULL, NULL };
static BACNET_APPLICATION_DATA_VALUE *InitIdValues[INIT_ID_PROPLIST_SIZE] =
{ NULL, NULL, NULL, NULL, NULL };
/* When we have to walk through an array of things, like ObjectIDs or
@@ -245,8 +247,8 @@ void MyReadPropertyAckHandler(
rp_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
if (rp_data) {
len =
rp_ack_fully_decode_service_request(service_request, service_len,
rp_data);
rp_ack_fully_decode_service_request(service_request,
service_len, rp_data);
}
if (len > 0) {
memmove(&Read_Property_Multiple_Data.service_data, service_data,
@@ -254,7 +256,7 @@ void MyReadPropertyAckHandler(
Read_Property_Multiple_Data.rpm_data = rp_data;
Read_Property_Multiple_Data.new_data = true;
} else {
if (len < 0) /* Eg, failed due to no segmentation */
if (len < 0) /* Eg, failed due to no segmentation */
Error_Detected = true;
free(rp_data);
}
@@ -285,7 +287,7 @@ void MyReadPropertyMultipleAckHandler(
Read_Property_Multiple_Data.new_data = true;
/* Will process and free the RPM data later */
} else {
if (len < 0) /* Eg, failed due to no segmentation */
if (len < 0) /* Eg, failed due to no segmentation */
Error_Detected = true;
free(rpm_data);
}
@@ -303,8 +305,7 @@ static void Init_Service_Handlers(
/* Put this client Device into the Routing table (first entry) */
Object_Instance = Device_Object_Instance_Number();
Device_Object_Name(Object_Instance, &name_string);
Add_Routed_Device(Object_Instance, &name_string,
Device_Description());
Add_Routed_Device(Object_Instance, &name_string, Device_Description());
#endif
/* we need to handle who-is
@@ -349,9 +350,9 @@ void CheckIsWritableProperty(
BACNET_PROPERTY_REFERENCE * rpm_property)
{
bool bIsWritable = false;
if ( object_type == OBJECT_DEVICE ) {
if ( (rpm_property->propertyIdentifier == PROP_OBJECT_IDENTIFIER) ||
(rpm_property->propertyIdentifier == PROP_OBJECT_NAME) )
if (object_type == OBJECT_DEVICE) {
if ((rpm_property->propertyIdentifier == PROP_OBJECT_IDENTIFIER) ||
(rpm_property->propertyIdentifier == PROP_OBJECT_NAME))
bIsWritable = true;
}
/* Add more checking here, eg for Time_Synchronization_Recipients,
@@ -440,13 +441,11 @@ bool PrettyPrintPropertyValue(
/* eg, property == PROP_LOCAL_DATE
* VTS needs (3-Aug-2011,4) or (8/3/11,4), so we'll use the
* clearer, international form. */
strncpy( short_month, bactext_month_name(value->type.Date.month), 3);
strncpy(short_month, bactext_month_name(value->type.Date.month), 3);
short_month[3] = 0;
fprintf(stream, "(%u-%3s-%u, %u)",
(unsigned) value->type.Date.day,
short_month,
(unsigned) value->type.Date.year,
(unsigned) value->type.Date.wday);
fprintf(stream, "(%u-%3s-%u, %u)", (unsigned) value->type.Date.day,
short_month, (unsigned) value->type.Date.year,
(unsigned) value->type.Date.wday);
} else if (value != NULL) {
assert(false); /* How did I get here? Fix your code. */
/* Meanwhile, a fallback plan */
@@ -511,7 +510,7 @@ void PrintReadPropertyData(
break;
}
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. */
default:
/* Normal array: open brace */
@@ -637,40 +636,40 @@ void PrintReadPropertyData(
default:
/* First, if this is a date type, it needs a different format
* for VTS, so pretty print it. */
if (ShowValues && (object_value.value->tag == BACNET_APPLICATION_TAG_DATE))
{
if (ShowValues &&
(object_value.value->tag == BACNET_APPLICATION_TAG_DATE)) {
/* This would be PROP_LOCAL_DATE, or OBJECT_DATETIME_VALUE,
* or OBJECT_DATE_VALUE */
PrettyPrintPropertyValue(stdout, &object_value);
} else {
/* Some properties are presented just as '?' in an EPICS;
* screen these out here, unless ShowValues is true. */
switch (rpm_property->propertyIdentifier) {
case PROP_DEVICE_ADDRESS_BINDING:
/* Make it VTS3-friendly and don't show "Null"
* as a value. */
if (value->tag == BACNET_APPLICATION_TAG_NULL) {
fprintf(stdout, "?");
/* Some properties are presented just as '?' in an EPICS;
* screen these out here, unless ShowValues is true. */
switch (rpm_property->propertyIdentifier) {
case PROP_DEVICE_ADDRESS_BINDING:
/* Make it VTS3-friendly and don't show "Null"
* as a value. */
if (value->tag == BACNET_APPLICATION_TAG_NULL) {
fprintf(stdout, "?");
break;
}
/* Else, fall through for normal processing. */
case PROP_DAYLIGHT_SAVINGS_STATUS:
case PROP_LOCAL_TIME:
case PROP_LOCAL_DATE: /* Only if !ShowValues */
case PROP_PRESENT_VALUE:
case PROP_PRIORITY_ARRAY:
case PROP_RELIABILITY:
case PROP_UTC_OFFSET:
case PROP_DATABASE_REVISION:
if (!ShowValues) {
fprintf(stdout, "?");
break;
}
/* Else, fall through and print value: */
default:
bacapp_print_value(stdout, &object_value);
break;
}
/* Else, fall through for normal processing. */
case PROP_DAYLIGHT_SAVINGS_STATUS:
case PROP_LOCAL_TIME:
case PROP_LOCAL_DATE: /* Only if !ShowValues */
case PROP_PRESENT_VALUE:
case PROP_PRIORITY_ARRAY:
case PROP_RELIABILITY:
case PROP_UTC_OFFSET:
case PROP_DATABASE_REVISION:
if (!ShowValues) {
fprintf(stdout, "?");
break;
}
/* Else, fall through and print value: */
default:
bacapp_print_value(stdout, &object_value);
break;
}
}
}
if (value->next != NULL) {
/* there's more! */
@@ -680,8 +679,8 @@ void PrintReadPropertyData(
/* Closing brace for this multi-valued array */
fprintf(stdout, " }");
}
CheckIsWritableProperty(object_type, /* object_instance, */
rpm_property);
CheckIsWritableProperty(object_type, /* object_instance, */
rpm_property);
fprintf(stdout, "\r\n");
}
break;
@@ -712,26 +711,27 @@ void Print_Property_Identifier(
* @param rpm_object [out] The structure holding our linked list of properties to request.
* @param propList [in] Simple list of properties (ptr to array), terminated with -1
*/
void BuildPropRequest( BACNET_READ_ACCESS_DATA *rpm_object, int32_t *propList )
void BuildPropRequest(
BACNET_READ_ACCESS_DATA * rpm_object,
int32_t * propList)
{
int i;
/* To start with, StartNextObject() has prepopulated one propEntry,
* but we will overwrite it and link more to it
*/
BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties;
BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties;
for( i = 0; propList[i] != -1; i++ )
{
if ( propEntry == NULL ) {
propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
assert(propEntry);
oldEntry->next = propEntry;
}
propEntry->propertyIdentifier = propList[i];
propEntry->propertyArrayIndex = BACNET_ARRAY_ALL;
oldEntry = propEntry;
propEntry = NULL;
}
int i;
/* To start with, StartNextObject() has prepopulated one propEntry,
* but we will overwrite it and link more to it
*/
BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties;
BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties;
for (i = 0; propList[i] != -1; i++) {
if (propEntry == NULL) {
propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
assert(propEntry);
oldEntry->next = propEntry;
}
propEntry->propertyIdentifier = propList[i];
propEntry->propertyArrayIndex = BACNET_ARRAY_ALL;
oldEntry = propEntry;
propEntry = NULL;
}
}
/** Send an RP request to read one property from the current Object.
@@ -750,7 +750,7 @@ static uint8_t Read_Properties(
{
uint8_t invoke_id = 0;
struct special_property_list_t PropertyListStruct;
unsigned int i = 0,j = 0;
unsigned int i = 0, j = 0;
if ((!Has_RPM && (Property_List_Index == 0)) ||
(Property_List_Length == 0)) {
@@ -761,7 +761,8 @@ static uint8_t Read_Properties(
*/
property_list_special(pMyObject->type, &PropertyListStruct);
if (Optional_Properties) {
Property_List_Length = PropertyListStruct.Required.count +
Property_List_Length =
PropertyListStruct.Required.count +
PropertyListStruct.Optional.count;
} else {
Property_List_Length = PropertyListStruct.Required.count;
@@ -872,11 +873,11 @@ EPICS_STATES ProcessRPMData(
value = value->next;
free(old_value);
}
} else if ( myState == GET_HEADING_RESPONSE ) {
InitIdValues[i++] = rpm_property->value;
/* copy this pointer.
* On error, the pointer will be null
* We won't free these values*/
} else if (myState == GET_HEADING_RESPONSE) {
InitIdValues[i++] = rpm_property->value;
/* copy this pointer.
* On error, the pointer will be null
* We won't free these values*/
} else {
fprintf(stdout, " ");
Print_Property_Identifier(rpm_property->propertyIdentifier);
@@ -894,9 +895,9 @@ EPICS_STATES ProcessRPMData(
}
/* Now determine the next state */
if ( myState == GET_HEADING_RESPONSE )
nextState = PRINT_HEADING;
/* press ahead with or without the data */
if (myState == GET_HEADING_RESPONSE)
nextState = PRINT_HEADING;
/* press ahead with or without the data */
else if (bSuccess && (myState == GET_ALL_RESPONSE))
nextState = NEXT_OBJECT;
else if (bSuccess) { /* and GET_LIST_OF_ALL_RESPONSE */
@@ -923,7 +924,8 @@ EPICS_STATES ProcessRPMData(
void PrintUsage(
)
{
printf("bacepics -- Generates Full EPICS file, including Object and Property List \r\n");
printf
("bacepics -- Generates Full EPICS file, including Object and Property List \r\n");
printf("Usage: \r\n");
printf
(" bacepics [-v] [-p sport] [-t target_mac [-n dnet]] device-instance \r\n");
@@ -935,13 +937,12 @@ void PrintUsage(
(" -t: declare target's MAC instead of using Who-Is to bind to \r\n");
printf
(" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n");
printf
(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n");
printf
(" -n: specify target's DNET if not local BACnet network \r\n");
printf(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n");
printf(" -n: specify target's DNET if not local BACnet network \r\n");
printf(" or on routed Virtual Network \r\n");
printf("\r\n");
printf("You may want to redirect the output to a .tpi file for VTS use,\r\n");
printf
("You may want to redirect the output to a .tpi file for VTS use,\r\n");
printf(" eg, bacepics -v 2701876 > epics-2701876.tpi \r\n");
printf("\r\n");
exit(0);
@@ -1040,166 +1041,169 @@ int CheckCommandLineArgs(
}
void PrintHeading( )
void PrintHeading(
)
{
BACNET_APPLICATION_DATA_VALUE *value;
char *relation = "for"; /* Text for Gateways */
if ( Target_Address.net != 0 )
relation = "provided by"; /* Text for child routed devices */
BACNET_APPLICATION_DATA_VALUE *value;
char *relation = "for"; /* Text for Gateways */
if (Target_Address.net != 0)
relation = "provided by"; /* Text for child routed devices */
printf("PICS 0\r\n");
printf("BACnet Protocol Implementation Conformance Statement\r\n\r\n");
printf("PICS 0\r\n");
printf("BACnet Protocol Implementation Conformance Statement\r\n\r\n");
printf("--\r\n--\r\n");
printf("-- BACnet/IP Interface for BACnet-stack Devices\r\n");
printf("-- http://sourceforge.net/projects/bacnet/ \r\n");
printf("-- \r\n-- \r\n\r\n");
printf("--\r\n--\r\n");
printf("-- BACnet/IP Interface for BACnet-stack Devices\r\n");
printf("-- http://sourceforge.net/projects/bacnet/ \r\n");
printf("-- \r\n-- \r\n\r\n");
/* InitIdValues , , , */
value = InitIdValues[INIT_VENDOR_NAME];
if ( value != NULL )
printf("Vendor Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) );
else
printf("Vendor Name: \"bacnet-stack\"\r\n");
value = InitIdValues[INIT_VENDOR_NAME];
if (value != NULL)
printf("Vendor Name: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
else
printf("Vendor Name: \"bacnet-stack\"\r\n");
value = InitIdValues[INIT_MODEL_NAME];
/* Best we can do with Product Name and Model Number is use the same text */
if ( value != NULL ) {
printf("Product Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) );
printf("Product Model Number: \"%s\"\r\n", characterstring_value( &value->type.Character_String) );
} else {
printf("Product Name: \"bacnet-stack Device\"\r\n");
printf("Product Model Number: \"Model XXX\"\r\n");
}
value = InitIdValues[INIT_MODEL_NAME];
/* Best we can do with Product Name and Model Number is use the same text */
if (value != NULL) {
printf("Product Name: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
printf("Product Model Number: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
} else {
printf("Product Name: \"bacnet-stack Device\"\r\n");
printf("Product Model Number: \"Model XXX\"\r\n");
}
value = InitIdValues[INIT_DESCRIPTION];
if ( value != NULL )
printf("Product Description: \"%s\"\r\n\r\n", characterstring_value( &value->type.Character_String) );
else
printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n");
value = InitIdValues[INIT_DESCRIPTION];
if (value != NULL)
printf("Product Description: \"%s\"\r\n\r\n",
characterstring_value(&value->type.Character_String));
else
printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n");
printf("BIBBs Supported:\r\n");
printf("{\r\n");
printf(" DS-RP-B\r\n");
printf(" DS-RPM-B\r\n");
printf(" DS-WP-B\r\n");
printf(" DM-DDB-B\r\n");
printf(" DM-DOB-B\r\n");
printf(" DM-DCC-B\r\n");
printf(" DM-RD-B\r\n");
printf("BIBBs Supported:\r\n");
printf("{\r\n");
printf(" DS-RP-B\r\n");
printf(" DS-RPM-B\r\n");
printf(" DS-WP-B\r\n");
printf(" DM-DDB-B\r\n");
printf(" DM-DOB-B\r\n");
printf(" DM-DCC-B\r\n");
printf(" DM-RD-B\r\n");
#ifdef BAC_ROUTING
/* Next line only for the gateway (ie, if not addressing a subNet) */
if ( Target_Address.net == 0 )
printf(" NM-RC-B\r\n");
/* Next line only for the gateway (ie, if not addressing a subNet) */
if (Target_Address.net == 0)
printf(" NM-RC-B\r\n");
#endif
printf("}\r\n\r\n");
/* You might add some of:
* -- DS-COV-A DS-COV-B
* -- AE-N-A AE-N-I-B AE-N-E-B
* -- AE-ACK-A AE-ACK-B
* -- DM-UTC-B
*/
printf("BACnet Standard Application Services Supported:\r\n");
printf("{\r\n");
/* You might change the "Initiate Execute" values, or edit the result. */
printf(" ReadProperty Initiate Execute\r\n");
printf(" ReadPropertyMultiple Execute\r\n");
printf(" WriteProperty Execute\r\n");
printf(" DeviceCommunicationControl Execute\r\n");
printf(" Who-Has Execute\r\n");
printf(" I-Have Initiate\r\n");
printf(" Who-Is Initiate Execute\r\n");
printf(" I-Am Initiate\r\n");
printf(" ReinitializeDevice Execute\r\n");
#ifdef BAC_ROUTING
if ( Target_Address.net == 0 )
{
printf(" -- Note: The following Routing Services are Supported:\r\n");
printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n");
printf(" -- I-Am-Router-To-Network Initiate Execute\r\n");
printf(" -- Initialize-Routing-Table Execute\r\n");
printf(" -- Initialize-Routing-Table-Ack Initiate\r\n");
}
#endif
printf("}\r\n\r\n");
/* You might want to add some of:
* -- AcknowledgeAlarm Initiate Execute
* -- ConfirmedCOVNotification Initiate Execute
* -- UnconfirmedCOVNotification Initiate
* -- ConfirmedEventNotification Initiate Execute
* -- UnconfirmedEventNotification Initiate Execute
* -- GetAlarmSummary Initiate Execute
* -- GetEnrollmentSummary Initiate Execute
* -- WritePropertyMultiple Initiate Execute
* -- ReadRange Initiate Execute
* -- GetEventInformation Initiate Execute
* -- SubscribeCOVProperty Initiate Execute
*/
printf("Standard Object-Types Supported:\r\n");
printf("{\r\n");
value = InitIdValues[INIT_OBJ_TYPES];
/* We have to process this bit string and determine which Object Types we have,
* and show them
*/
if ( ( value != NULL ) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) )
{
int i, len = bitstring_bits_used(&value->type.Bit_String);
for ( i = 0; i < len; i++) {
if ( bitstring_bit(&value->type.Bit_String, (uint8_t) i) )
printf(" %s\r\n", bactext_object_type_name(i));
}
} else { /* Else, just show the usual suspects */
printf(" Analog Input\r\n");
printf(" Analog Value\r\n");
printf(" Binary Input\r\n");
printf(" Binary Value\r\n");
printf(" Device\r\n");
printf(" Multi-state Input\r\n");
printf(" Multi-state Value\r\n");
printf(" Structured View\r\n");
printf(" Characterstring Value\r\n");
printf(" Datetime Value\r\n");
printf(" Integer Value\r\n");
printf(" Positive Integer Value\r\n");
}
printf("}\r\n\r\n");
/* You might add some of:
* -- Analog Output
* -- Binary Output
* -- Multi-state Output
* -- Trend Log Createable Deleteable
* -- Load Control
* -- Bitstring Value
* -- Date Pattern Value
* -- Date Value
* -- Datetime Pattern Value
* -- Large Analog Value
* -- Octetstring Value
* -- Time Pattern Value
* -- Time Value
printf("}\r\n\r\n");
/* You might add some of:
* -- DS-COV-A DS-COV-B
* -- AE-N-A AE-N-I-B AE-N-E-B
* -- AE-ACK-A AE-ACK-B
* -- DM-UTC-B
*/
printf("Data Link Layer Option:\r\n");
printf("{\r\n");
printf(" BACnet/IP, 'DIX' Ethernet\r\n");
printf("}\r\n\r\n");
printf("BACnet Standard Application Services Supported:\r\n");
printf("{\r\n");
/* You might change the "Initiate Execute" values, or edit the result. */
printf(" ReadProperty Initiate Execute\r\n");
printf(" ReadPropertyMultiple Execute\r\n");
printf(" WriteProperty Execute\r\n");
printf(" DeviceCommunicationControl Execute\r\n");
printf(" Who-Has Execute\r\n");
printf(" I-Have Initiate\r\n");
printf(" Who-Is Initiate Execute\r\n");
printf(" I-Am Initiate\r\n");
printf(" ReinitializeDevice Execute\r\n");
#ifdef BAC_ROUTING
if (Target_Address.net == 0) {
printf(" -- Note: The following Routing Services are Supported:\r\n");
printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n");
printf(" -- I-Am-Router-To-Network Initiate Execute\r\n");
printf(" -- Initialize-Routing-Table Execute\r\n");
printf(" -- Initialize-Routing-Table-Ack Initiate\r\n");
}
#endif
printf("}\r\n\r\n");
/* You might want to add some of:
* -- AcknowledgeAlarm Initiate Execute
* -- ConfirmedCOVNotification Initiate Execute
* -- UnconfirmedCOVNotification Initiate
* -- ConfirmedEventNotification Initiate Execute
* -- UnconfirmedEventNotification Initiate Execute
* -- GetAlarmSummary Initiate Execute
* -- GetEnrollmentSummary Initiate Execute
* -- WritePropertyMultiple Initiate Execute
* -- ReadRange Initiate Execute
* -- GetEventInformation Initiate Execute
* -- SubscribeCOVProperty Initiate Execute
*/
printf("Character Sets Supported:\r\n");
printf("{\r\n");
printf(" ANSI X3.4\r\n");
printf("}\r\n\r\n");
printf("Standard Object-Types Supported:\r\n");
printf("{\r\n");
value = InitIdValues[INIT_OBJ_TYPES];
/* We have to process this bit string and determine which Object Types we have,
* and show them
*/
if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING)) {
int i, len = bitstring_bits_used(&value->type.Bit_String);
for (i = 0; i < len; i++) {
if (bitstring_bit(&value->type.Bit_String, (uint8_t) i))
printf(" %s\r\n", bactext_object_type_name(i));
}
} else { /* Else, just show the usual suspects */
printf(" Analog Input\r\n");
printf(" Analog Value\r\n");
printf(" Binary Input\r\n");
printf(" Binary Value\r\n");
printf(" Device\r\n");
printf(" Multi-state Input\r\n");
printf(" Multi-state Value\r\n");
printf(" Structured View\r\n");
printf(" Characterstring Value\r\n");
printf(" Datetime Value\r\n");
printf(" Integer Value\r\n");
printf(" Positive Integer Value\r\n");
}
printf("}\r\n\r\n");
/* You might add some of:
* -- Analog Output
* -- Binary Output
* -- Multi-state Output
* -- Trend Log Createable Deleteable
* -- Load Control
* -- Bitstring Value
* -- Date Pattern Value
* -- Date Value
* -- Datetime Pattern Value
* -- Large Analog Value
* -- Octetstring Value
* -- Time Pattern Value
* -- Time Value
*/
printf("Special Functionality:\r\n");
printf("{\r\n");
printf(" Maximum APDU size in octets: 1476\r\n");
printf("}\r\n\r\n");
printf("Data Link Layer Option:\r\n");
printf("{\r\n");
printf(" BACnet/IP, 'DIX' Ethernet\r\n");
printf("}\r\n\r\n");
printf("List of Objects in Test Device:\r\n");
/* Print Opening brace, then kick off the Device Object */
printf("{\r\n");
printf(" {\r\n"); /* And opening brace for the first object */
printf("Character Sets Supported:\r\n");
printf("{\r\n");
printf(" ANSI X3.4\r\n");
printf("}\r\n\r\n");
printf("Special Functionality:\r\n");
printf("{\r\n");
printf(" Maximum APDU size in octets: 1476\r\n");
printf("}\r\n\r\n");
printf("List of Objects in Test Device:\r\n");
/* Print Opening brace, then kick off the Device Object */
printf("{\r\n");
printf(" {\r\n"); /* And opening brace for the first object */
}
@@ -1354,22 +1358,22 @@ int main(
case GET_HEADING_INFO:
last_seconds = current_seconds;
StartNextObject(rpm_object, &myObject);
BuildPropRequest( rpm_object, &InitIdPropList[0] );
BuildPropRequest(rpm_object, &InitIdPropList[0]);
Request_Invoke_ID =
Send_Read_Property_Multiple_Request(buffer, MAX_PDU,
Target_Device_Object_Instance, rpm_object);
if (Request_Invoke_ID > 0) {
elapsed_seconds = 0;
} else {
/* We failed. Will hurt the header info we can show. */
fprintf(stderr, "\r-- Failed to get Heading info \r\n");
/* We failed. Will hurt the header info we can show. */
fprintf(stderr, "\r-- Failed to get Heading info \r\n");
}
myState = GET_HEADING_RESPONSE;
break;
case PRINT_HEADING:
/* Print out the header information */
PrintHeading( );
/* Print out the header information */
PrintHeading();
myState = GET_ALL_REQUEST;
/* Fall through now */
@@ -1421,9 +1425,9 @@ int main(
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
elapsed_seconds = 0;
Request_Invoke_ID = 0;
if ( myState == GET_HEADING_RESPONSE )
myState = PRINT_HEADING;
/* just press ahead without the data */
if (myState == GET_HEADING_RESPONSE)
myState = PRINT_HEADING;
/* just press ahead without the data */
else if (Error_Detected) {
if (Last_Error_Code ==
ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) {
@@ -1432,7 +1436,7 @@ int main(
Has_RPM = false;
myState = GET_PROPERTY_REQUEST;
} else if (Last_Error_Code ==
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED) {
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED) {
myState = GET_PROPERTY_REQUEST;
StartNextObject(rpm_object, &myObject);
} else if (myState == GET_ALL_RESPONSE)
@@ -1452,20 +1456,20 @@ int main(
tsm_free_invoke_id(Request_Invoke_ID);
Request_Invoke_ID = 0;
elapsed_seconds = 0;
if ( myState == GET_HEADING_RESPONSE )
myState = PRINT_HEADING;
/* just press ahead without the data */
if (myState == GET_HEADING_RESPONSE)
myState = PRINT_HEADING;
/* just press ahead without the data */
else
myState = GET_ALL_REQUEST; /* Let's try again */
myState = GET_ALL_REQUEST; /* Let's try again */
} else if (Error_Detected) {
/* Don't think we'll ever actually reach this point. */
elapsed_seconds = 0;
Request_Invoke_ID = 0;
if ( myState == GET_HEADING_RESPONSE )
myState = PRINT_HEADING;
/* just press ahead without the data */
if (myState == GET_HEADING_RESPONSE)
myState = PRINT_HEADING;
/* just press ahead without the data */
else
myState = NEXT_OBJECT; /* Give up and move on to the next. */
myState = NEXT_OBJECT; /* Give up and move on to the next. */
Error_Count++;
}
break;
@@ -1500,11 +1504,11 @@ int main(
(Request_Invoke_ID ==
Read_Property_Multiple_Data.service_data.invoke_id)) {
Read_Property_Multiple_Data.new_data = false;
PrintReadPropertyData(Read_Property_Multiple_Data.
rpm_data->object_type,
PrintReadPropertyData
(Read_Property_Multiple_Data.rpm_data->object_type,
Read_Property_Multiple_Data.rpm_data->object_instance,
Read_Property_Multiple_Data.rpm_data->
listOfProperties);
Read_Property_Multiple_Data.
rpm_data->listOfProperties);
if (tsm_invoke_id_free(Request_Invoke_ID)) {
Request_Invoke_ID = 0;
} else {
@@ -1538,12 +1542,13 @@ int main(
} else {
/* OK, skip this one and try the next property. */
fprintf(stdout, " -- Failed to get ");
Print_Property_Identifier(
Property_List[Property_List_Index]);
Print_Property_Identifier(Property_List
[Property_List_Index]);
fprintf(stdout, " \r\n");
Error_Count++;
Property_List_Index++;
if (Property_List_Index >= Property_List_Length) {
if (Property_List_Index >=
Property_List_Length) {
/* Give up and move on to the next. */
myState = NEXT_OBJECT;
}
@@ -1563,7 +1568,7 @@ int main(
tsm_free_invoke_id(Request_Invoke_ID);
elapsed_seconds = 0;
Request_Invoke_ID = 0;
myState = 3; /* Let's try again, same Property */
myState = 3; /* Let's try again, same Property */
} else if (Error_Detected) {
/* Don't think we'll ever actually reach this point. */
elapsed_seconds = 0;
@@ -1636,10 +1641,10 @@ int main(
fprintf(stdout, "\r-- Found %d Errors \r\n", Error_Count);
/* Closing brace for all Objects, if we got any, and closing footer */
if (myState != INITIAL_BINDING)
{
if (myState != INITIAL_BINDING) {
printf("} \r\n");
printf("End of BACnet Protocol Implementation Conformance Statement\r\n");
printf
("End of BACnet Protocol Implementation Conformance Statement\r\n");
printf("\r\n");
}
+2 -3
View File
@@ -131,9 +131,8 @@ static void Init_Service_Handlers(
* each device in turn.
*/
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
handler_who_is_unicast);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
handler_who_has);
handler_who_is_unicast);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
/* 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
+19 -16
View File
@@ -45,7 +45,7 @@ static uint16_t BBMD_Timer_Seconds;
static long bbmd_timetolive_seconds = 60000;
static long bbmd_port = 0xBAC0;
static long bbmd_address = 0;
static int bbmd_result = 0;
static int bbmd_result = 0;
/* Simple setters for BBMD registration variables. */
@@ -55,7 +55,8 @@ static int bbmd_result = 0;
* @param address - IPv4 address (long) of BBMD to register with,
* in network byte order.
*/
void dlenv_bbmd_address_set( long address )
void dlenv_bbmd_address_set(
long address)
{
bbmd_address = address;
}
@@ -64,7 +65,8 @@ void dlenv_bbmd_address_set( long address )
* Default if not set is 0xBAC0.
* @param port - The port number (provided in network byte order).
*/
void dlenv_bbmd_port_set( int port )
void dlenv_bbmd_port_set(
int port)
{
bbmd_port = port;
}
@@ -73,7 +75,8 @@ void dlenv_bbmd_port_set( int port )
* Default if not set is 60000 (1000 minutes).
* @param ttl_secs - The Lease Time, in seconds.
*/
void dlenv_bbmd_ttl_set( int ttl_secs )
void dlenv_bbmd_ttl_set(
int ttl_secs)
{
bbmd_timetolive_seconds = ttl_secs;
}
@@ -86,10 +89,11 @@ void dlenv_bbmd_ttl_set( int ttl_secs )
* 0 if no registration request was made, or
* -1 if registration attempt failed.
*/
int dlenv_bbmd_result( void )
int dlenv_bbmd_result(
void)
{
if ( (bbmd_result > 0) &&
(bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK) )
if ((bbmd_result > 0) &&
(bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK))
return -1;
/* Else, show our send: */
return bbmd_result;
@@ -113,7 +117,7 @@ int dlenv_bbmd_result( void )
int dlenv_register_as_foreign_device(
void)
{
int retval = 0;
int retval = 0;
#if defined(BACDL_BIP)
char *pEnv = NULL;
@@ -138,15 +142,14 @@ int dlenv_register_as_foreign_device(
if (bbmd_address) {
struct in_addr addr;
addr.s_addr = bbmd_address;
fprintf(stderr,
"Registering with BBMD at %s:%ld for %ld seconds\n",
fprintf(stderr, "Registering with BBMD at %s:%ld for %ld seconds\n",
inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds);
retval = bvlc_register_with_bbmd(bbmd_address,
htons((uint16_t) bbmd_port),
(uint16_t) bbmd_timetolive_seconds);
if ( retval < 0 )
fprintf(stderr,
"FAILED to Register with BBMD at %s \n", inet_ntoa(addr) );
retval =
bvlc_register_with_bbmd(bbmd_address, htons((uint16_t) bbmd_port),
(uint16_t) bbmd_timetolive_seconds);
if (retval < 0)
fprintf(stderr, "FAILED to Register with BBMD at %s \n",
inet_ntoa(addr));
BBMD_Timer_Seconds = bbmd_timetolive_seconds;
}
+4 -3
View File
@@ -106,7 +106,8 @@ void handler_ccov_notification(
fprintf(stderr, "CCOV: Segmented message. Sending Abort!\n");
#endif
goto CCOV_ABORT;
} /* decode the service request only */
}
/* decode the service request only */
/* decode the service request only */
len =
cov_notify_decode_service_request(service_request, service_len,
@@ -125,8 +126,8 @@ void handler_ccov_notification(
fprintf(stderr, "CCOV: ");
if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ",
bactext_property_name
(pProperty_value->propertyIdentifier));
bactext_property_name(pProperty_value->
propertyIdentifier));
} else {
fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier);
+24 -20
View File
@@ -50,7 +50,7 @@
of an object that have been specified in the standard. */
typedef struct BACnet_COV_Subscription_Flags {
bool valid:1;
bool issueConfirmedNotifications:1; /* optional */
bool issueConfirmedNotifications:1; /* optional */
bool send_requested:1;
} BACNET_COV_SUBSCRIPTION_FLAGS;
@@ -59,7 +59,7 @@ typedef struct BACnet_COV_Subscription {
BACNET_ADDRESS dest;
uint32_t subscriberProcessIdentifier;
BACNET_OBJECT_ID monitoredObjectIdentifier;
uint8_t invokeID; /* for confirmed COV */
uint8_t invokeID; /* for confirmed COV */
uint32_t lifetime; /* optional */
} BACNET_COV_SUBSCRIPTION;
@@ -390,8 +390,8 @@ static void cov_lifetime_expiration_handler(
if (lifetime_seconds >= elapsed_seconds) {
COV_Subscriptions[index].lifetime -= elapsed_seconds;
#if 0
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
index, (unsigned long) COV_Subscriptions[index].lifetime);
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n", index,
(unsigned long) COV_Subscriptions[index].lifetime);
#endif
} else {
COV_Subscriptions[index].lifetime = 0;
@@ -443,8 +443,7 @@ void handler_cov_timer_seconds(
lifetime_seconds = COV_Subscriptions[index].lifetime;
if (lifetime_seconds) {
/* only expire COV with definite lifetimes */
cov_lifetime_expiration_handler(index,
elapsed_seconds,
cov_lifetime_expiration_handler(index, elapsed_seconds,
lifetime_seconds);
}
}
@@ -452,7 +451,8 @@ void handler_cov_timer_seconds(
}
}
void handler_cov_task(void)
void handler_cov_task(
void)
{
static int index = 0;
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
@@ -461,8 +461,7 @@ void handler_cov_task(void)
bool send = false;
BACNET_PROPERTY_VALUE value_list[2];
/* states for transmitting */
static enum
{
static enum {
COV_STATE_IDLE = 0,
COV_STATE_MARK,
COV_STATE_CLEAR,
@@ -481,7 +480,8 @@ void handler_cov_task(void)
object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
status = Device_COV(object_type, object_instance);
if (status) {
COV_Subscriptions[index].flag.send_requested = true;
@@ -500,7 +500,8 @@ void handler_cov_task(void)
object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
Device_COV_Clear(object_type, object_instance);
}
index++;
@@ -516,8 +517,8 @@ void handler_cov_task(void)
(COV_Subscriptions[index].invokeID)) {
if (tsm_invoke_id_free(COV_Subscriptions[index].invokeID)) {
COV_Subscriptions[index].invokeID = 0;
} else if (tsm_invoke_id_failed(
COV_Subscriptions[index].invokeID)) {
} else if (tsm_invoke_id_failed(COV_Subscriptions[index].
invokeID)) {
tsm_free_invoke_id(COV_Subscriptions[index].invokeID);
COV_Subscriptions[index].invokeID = 0;
}
@@ -545,16 +546,18 @@ void handler_cov_task(void)
}
if (send) {
object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type;
COV_Subscriptions[index].monitoredObjectIdentifier.
type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
/* configure the linked list for the two properties */
value_list[0].next = &value_list[1];
value_list[1].next = NULL;
(void)Device_Encode_Value_List(object_type, object_instance,
&value_list[0]);
status = cov_send_request(
&COV_Subscriptions[index],
(void) Device_Encode_Value_List(object_type,
object_instance, &value_list[0]);
status =
cov_send_request(&COV_Subscriptions[index],
&value_list[0]);
if (status) {
COV_Subscriptions[index].flag.send_requested = false;
@@ -584,7 +587,8 @@ static bool cov_subscribe(
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
uint32_t object_instance = 0;
object_type = (BACNET_OBJECT_TYPE)cov_data->monitoredObjectIdentifier.type;
object_type =
(BACNET_OBJECT_TYPE) cov_data->monitoredObjectIdentifier.type;
object_instance = cov_data->monitoredObjectIdentifier.instance;
status = Device_Valid_Object_Id(object_type, object_instance);
if (status) {
+6 -5
View File
@@ -157,13 +157,14 @@ void handler_device_communication_control(
} else {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval(
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id );
if ( len > 0 )
len =
Routed_Device_Service_Approval
(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
if (len > 0)
goto DCC_ABORT;
#endif
if (characterstring_ansi_same(&password, My_Password)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
+14 -17
View File
@@ -57,9 +57,9 @@ void handler_get_alarm_summary(
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
int len = 0;
int pdu_len = 0;
int pdu_len = 0;
int apdu_len = 0;
int bytes_sent = 0;
int bytes_sent = 0;
int alarm_value = 0;
unsigned i = 0;
unsigned j = 0;
@@ -90,9 +90,9 @@ void handler_get_alarm_summary(
}
/* init header */
apdu_len = get_alarm_summary_ack_encode_apdu_init(
&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id);
apdu_len =
get_alarm_summary_ack_encode_apdu_init(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id);
for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) {
@@ -100,18 +100,16 @@ void handler_get_alarm_summary(
for (j = 0; j < 0xffff; j++) {
alarm_value = Get_Alarm_Summary[i] (j, &getalarm_data);
if (alarm_value > 0) {
len = get_alarm_sumary_ack_encode_apdu_data(
&Handler_Transmit_Buffer[pdu_len + apdu_len],
service_data->max_resp - apdu_len,
&getalarm_data);
len =
get_alarm_sumary_ack_encode_apdu_data
(&Handler_Transmit_Buffer[pdu_len + apdu_len],
service_data->max_resp - apdu_len, &getalarm_data);
if (len <= 0) {
error = true;
goto GET_ALARM_SUMMARY_ERROR;
}
else
} else
apdu_len += len;
}
else if (alarm_value < 0) {
} else if (alarm_value < 0) {
break;
}
}
@@ -123,7 +121,7 @@ void handler_get_alarm_summary(
fprintf(stderr, "GetAlarmSummary: Sending response!\n");
#endif
GET_ALARM_SUMMARY_ERROR:
GET_ALARM_SUMMARY_ERROR:
if (error) {
if (len == BACNET_STATUS_ABORT) {
/* BACnet APDU too small to fit data, so proper response is Abort */
@@ -135,8 +133,7 @@ GET_ALARM_SUMMARY_ERROR:
fprintf(stderr,
"GetAlarmSummary: Reply too big to fit into APDU!\n");
#endif
}
else {
} else {
apdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_GET_ALARM_SUMMARY,
@@ -148,7 +145,7 @@ GET_ALARM_SUMMARY_ERROR:
}
GET_ALARM_SUMMARY_ABORT:
GET_ALARM_SUMMARY_ABORT:
pdu_len += apdu_len;
bytes_sent =
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
+6 -5
View File
@@ -131,13 +131,14 @@ void handler_reinitialize_device(
} else {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval(
SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id );
if ( len > 0 )
len =
Routed_Device_Service_Approval
(SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
if (len > 0)
goto RD_ABORT;
#endif
if (Device_Reinitialize(&rd_data)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
+5 -5
View File
@@ -210,17 +210,17 @@ static void routed_apdu_handler(
* we don't try the standard path of asking Who-Is-Router-to-Network. */
#if defined(BACDL_BIP)
/* If wasn't unicast to us, must have been one of the bcast types.
* Drop it. */
if ( bvlc_get_function_code() != BVLC_ORIGINAL_UNICAST_NPDU )
* Drop it. */
if (bvlc_get_function_code() != BVLC_ORIGINAL_UNICAST_NPDU)
return;
#endif
/* Upper level handlers knew that this was sent as a bcast,
/* Upper level handlers knew that this was sent as a bcast,
* but our only other way to guess at that here is if the dest->adr
* is absent, then we know this is some sort of bcast.
*/
if ( dest->len > 0 ) {
if (dest->len > 0) {
Send_Reject_Message_To_Network(src, NETWORK_REJECT_NO_ROUTE,
dest->net);
dest->net);
} /* else, silently drop it */
return;
}
+2 -1
View File
@@ -296,7 +296,8 @@ void handler_read_property_multiple(
&Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) {
#if PRINT_ENABLED
fprintf(stderr, "RPM: Too full to encode property!\r\n");
fprintf(stderr,
"RPM: Too full to encode property!\r\n");
#endif
rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
+6 -6
View File
@@ -221,8 +221,8 @@ void rpm_ack_print_data(
#if PRINT_ENABLED
if (listOfProperties->propertyIdentifier < 512) {
fprintf(stdout, " %s: ",
bactext_property_name(listOfProperties->
propertyIdentifier));
bactext_property_name
(listOfProperties->propertyIdentifier));
} else {
fprintf(stdout, " proprietary %u: ",
(unsigned) listOfProperties->propertyIdentifier);
@@ -269,10 +269,10 @@ void rpm_ack_print_data(
#if PRINT_ENABLED
/* AccessError */
fprintf(stdout, "BACnet Error: %s: %s\r\n",
bactext_error_class_name((int) listOfProperties->
error.error_class),
bactext_error_code_name((int) listOfProperties->
error.error_code));
bactext_error_class_name((int) listOfProperties->error.
error_class),
bactext_error_code_name((int) listOfProperties->error.
error_code));
#endif
}
listOfProperties = listOfProperties->next;
+2 -2
View File
@@ -104,8 +104,8 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: ");
if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ",
bactext_property_name
(pProperty_value->propertyIdentifier));
bactext_property_name(pProperty_value->
propertyIdentifier));
} else {
fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier);
+5 -5
View File
@@ -56,14 +56,15 @@ void handler_unconfirmed_private_transfer(
#if PRINT_ENABLED
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
#endif
len = ptransfer_decode_service_request(
service_request, service_len, &private_data);
len =
ptransfer_decode_service_request(service_request, service_len,
&private_data);
if (len >= 0) {
#if PRINT_ENABLED
printf("PrivateTransfer:vendorID=%u\r\n",
(unsigned)private_data.vendorID);
(unsigned) private_data.vendorID);
printf("PrivateTransfer:serviceNumber=%lu\r\n",
(unsigned long)private_data.serviceNumber);
(unsigned long) private_data.serviceNumber);
#endif
application_data = private_data.serviceParameters;
application_data_len = private_data.serviceParametersLen;
@@ -107,4 +108,3 @@ void handler_unconfirmed_private_transfer(
#endif
}
}
+3 -4
View File
@@ -65,9 +65,8 @@ static void match_name_or_object(
} else {
/* valid object_name copy in my device? */
found =
Device_Object_Name_Copy(
(BACNET_OBJECT_TYPE)data->object.identifier.type,
data->object.identifier.instance, &object_name);
Device_Object_Name_Copy((BACNET_OBJECT_TYPE) data->object.
identifier.type, data->object.identifier.instance, &object_name);
if (found) {
Send_I_Have(Device_Object_Instance_Number(),
(BACNET_OBJECT_TYPE) data->object.identifier.type,
@@ -110,7 +109,7 @@ void handler_who_has(
}
#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */
#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */
/** Handler for Who-Has requests in the virtual routing setup,
* with broadcast I-Have response.
* Will respond if the device Object ID matches, and we have
+1 -1
View File
@@ -113,7 +113,7 @@ void handler_who_is_unicast(
}
#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */
#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */
/** Local function to check Who-Is requests against our Device IDs.
* Will check the gateway (root Device) and all virtual routed
* Devices against the range and respond for each that matches.
+2 -2
View File
@@ -181,8 +181,8 @@ bool WPValidateString(
(!characterstring_printable(&pValue->type.Character_String))) {
/* assumption: non-empty also means must be "printable" */
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (characterstring_length(&pValue->
type.Character_String) > iMaxLen) {
} else if (characterstring_length(&pValue->type.Character_String) >
iMaxLen) {
*pErrorClass = ERROR_CLASS_RESOURCES;
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
} else
+1 -1
View File
@@ -155,7 +155,7 @@ void handler_write_property_multiple(
}
} while (decode_len < service_len);
WPM_ABORT:
WPM_ABORT:
/* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address);
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
+2 -3
View File
@@ -157,9 +157,8 @@ uint8_t Send_Write_Property_Request(
#if PRINT_ENABLED_DEBUG
fprintf(stderr, "WriteProperty service: " "%s tag=%d\n",
(object_value->context_specific ? "context" : "application"),
(int) (object_value->
context_specific ? object_value->context_tag : object_value->
tag));
(int) (object_value->context_specific ? object_value->
context_tag : object_value->tag));
#endif
len = bacapp_encode_data(&application_data[apdu_len], object_value);
if ((len + apdu_len) < MAX_APDU) {
+47 -42
View File
@@ -73,18 +73,20 @@ static FILE *pFile = NULL; /* stream pointer */
* RETURN: number of arguments parsed
* NOTES: none
******************************************************************/
static void Parse_Arguments(int argc, char *argv[])
static void Parse_Arguments(
int argc,
char *argv[])
{
int i = 0;
long long_value = 0;
for (i=1;i<argc;i++) {
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
/* numeric arguments */
if (isdigit(argv[i][1])) {
long_value = strtol(&argv[i][1], NULL, 10);
/* dash arguments */
switch(long_value) {
switch (long_value) {
case 8:
CRC_Size = 8;
break;
@@ -99,7 +101,7 @@ static void Parse_Arguments(int argc, char *argv[])
}
}
/* dash arguments */
switch(argv[i][1]) {
switch (argv[i][1]) {
case 'h':
case 'H':
ASCII_Decimal = false;
@@ -122,7 +124,7 @@ static void Parse_Arguments(int argc, char *argv[])
} else {
long_value = strtol(argv[i], NULL, 16);
}
CRC_Buffer[CRC_Buffer_Len] = (uint8_t)long_value;
CRC_Buffer[CRC_Buffer_Len] = (uint8_t) long_value;
CRC_Buffer_Len++;
}
}
@@ -158,13 +160,13 @@ static void write_global_header(
/* create a new file. */
pFile = fopen(filename, "wb");
if (pFile) {
(void) fwrite(&magic_number, sizeof(magic_number), 1, pFile);
(void) fwrite(&version_major, sizeof(version_major), 1, pFile);
(void) fwrite(&version_minor, sizeof(version_minor), 1, pFile);
(void) fwrite(&thiszone, sizeof(thiszone), 1, pFile);
(void) fwrite(&sigfigs, sizeof(sigfigs), 1, pFile);
(void) fwrite(&snaplen, sizeof(snaplen), 1, pFile);
(void) fwrite(&network, sizeof(network), 1, pFile);
(void) fwrite(&magic_number, sizeof(magic_number), 1, pFile);
(void) fwrite(&version_major, sizeof(version_major), 1, pFile);
(void) fwrite(&version_minor, sizeof(version_minor), 1, pFile);
(void) fwrite(&thiszone, sizeof(thiszone), 1, pFile);
(void) fwrite(&sigfigs, sizeof(sigfigs), 1, pFile);
(void) fwrite(&snaplen, sizeof(snaplen), 1, pFile);
(void) fwrite(&network, sizeof(network), 1, pFile);
fflush(pFile);
fprintf(stdout, "mstpcap: saving capture to %s\n", filename);
} else {
@@ -173,7 +175,9 @@ static void write_global_header(
}
}
static void write_received_packet(uint8_t *buffer, unsigned length)
static void write_received_packet(
uint8_t * buffer,
unsigned length)
{
uint32_t ts_sec; /* timestamp seconds */
uint32_t ts_usec; /* timestamp microseconds */
@@ -197,7 +201,9 @@ static void write_received_packet(uint8_t *buffer, unsigned length)
}
}
static void Write_Pcap(uint8_t *buffer, unsigned length)
static void Write_Pcap(
uint8_t * buffer,
unsigned length)
{
filename_create(&Capture_Filename[0]);
write_global_header(&Capture_Filename[0]);
@@ -220,8 +226,7 @@ int main(
/* initialize our interface */
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
printf("mstpcrc [options] <00 00 00 00...>\r\n"
"perform MS/TP CRC on data bytes.\r\n"
"options:\r\n"
"perform MS/TP CRC on data bytes.\r\n" "options:\r\n"
"[-x] interprete the arguments as ascii hex (default)\r\n"
"[-d] interprete the argument as ascii decimal\r\n"
"[-m] Write the bytes to Wireshark capture file\r\n"
@@ -243,35 +248,35 @@ int main(
if (MSTP_Cap) {
Write_Pcap(CRC_Buffer, CRC_Buffer_Len);
} else {
for (i = 0; i < CRC_Buffer_Len; i++) {
for (i = 0; i < CRC_Buffer_Len; i++) {
if (CRC_Size == 8) {
crc8 = CRC_Calc_Header(CRC_Buffer[i], crc8);
} else if (CRC_Size == 16) {
crc16 = CRC_Calc_Data(CRC_Buffer[i], crc16);
}
if (ASCII_Decimal) {
printf("%u\r\n", (unsigned) CRC_Buffer[i]);
} else {
printf("0x%02X\r\n", CRC_Buffer[i]);
}
}
if (CRC_Size == 8) {
crc8 = CRC_Calc_Header(CRC_Buffer[i], crc8);
crc8 = ~crc8;
if (ASCII_Decimal) {
printf("%u Header CRC\r\n", (unsigned) crc8);
} else {
printf("0x%02X Header CRC\r\n", crc8);
}
} else if (CRC_Size == 16) {
crc16 = CRC_Calc_Data(CRC_Buffer[i], crc16);
crc16 = ~crc16;
if (ASCII_Decimal) {
printf("%u Data CRC\r\n", (unsigned) (crc16 & 0xFF));
printf("%u Data CRC\r\n", (unsigned) (crc16 >> 8));
} else {
printf("0x%02X Data CRC\r\n", (crc16 & 0xFF));
printf("0x%02X Data CRC\r\n", (crc16 >> 8));
}
}
if (ASCII_Decimal) {
printf("%u\r\n", (unsigned)CRC_Buffer[i]);
} else {
printf("0x%02X\r\n", CRC_Buffer[i]);
}
}
if (CRC_Size == 8) {
crc8 = ~crc8;
if (ASCII_Decimal) {
printf("%u Header CRC\r\n", (unsigned)crc8);
} else {
printf("0x%02X Header CRC\r\n", crc8);
}
} else if (CRC_Size == 16) {
crc16 = ~crc16;
if (ASCII_Decimal) {
printf("%u Data CRC\r\n", (unsigned)(crc16 & 0xFF));
printf("%u Data CRC\r\n", (unsigned)(crc16 >> 8));
} else {
printf("0x%02X Data CRC\r\n", (crc16 & 0xFF));
printf("0x%02X Data CRC\r\n", (crc16 >> 8));
}
}
}
}
+79 -72
View File
@@ -352,11 +352,11 @@ int Analog_Input_Read_Property(
case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0,
(CurrentAI->
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
(CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true :
false);
bitstring_set_bit(&bit_string, 1,
(CurrentAI->
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
(CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -364,14 +364,14 @@ int Analog_Input_Read_Property(
case PROP_EVENT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -379,8 +379,8 @@ int Analog_Input_Read_Property(
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
@@ -504,7 +504,7 @@ bool Analog_Input_Write_Property(
else
return false;
switch ((int)wp_data->object_property) {
switch ((int) wp_data->object_property) {
case PROP_PRESENT_VALUE:
status =
WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL,
@@ -909,17 +909,17 @@ void Analog_Input_Intrinsic_Reporting(
event_data.notificationParams.outOfRange.exceedingValue =
PresentVal;
/* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange.
statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_IN_ALARM,
bitstring_init(&event_data.notificationParams.
outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAI->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAI->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband =
@@ -939,24 +939,30 @@ void Analog_Input_Intrinsic_Reporting(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
false;
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
false;
CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
false;
CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
}
}
@@ -983,12 +989,12 @@ int Analog_Input_Event_Information(
/* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions =
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked == false);
(AI_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked ==
false) | (AI_Descr[index].
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) | (AI_Descr[index].
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
} else
return -1; /* end of list */
@@ -1003,8 +1009,8 @@ int Analog_Input_Event_Information(
bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AI_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
@@ -1022,14 +1028,14 @@ int Analog_Input_Event_Information(
/* Event Enable */
bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
/* Event Priorities */
Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class,
getevent_data->eventPriorities);
@@ -1049,8 +1055,8 @@ int Analog_Input_Alarm_Ack(
object_index =
Analog_Input_Instance_To_Index(alarmack_data->eventObjectIdentifier.
instance);
Analog_Input_Instance_To_Index(alarmack_data->
eventObjectIdentifier.instance);
if (object_index < MAX_ANALOG_INPUTS)
CurrentAI = &AI_Descr[object_index];
@@ -1063,22 +1069,22 @@ int Analog_Input_Alarm_Ack(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
if (CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked == false) {
if (CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
if (datetime_compare(&CurrentAI->Acked_Transitions
[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* FIXME: Send ack notification */
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = true;
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
@@ -1092,8 +1098,8 @@ int Analog_Input_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
if (datetime_compare(&CurrentAI->Acked_Transitions
[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1115,8 +1121,8 @@ int Analog_Input_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
if (datetime_compare(&CurrentAI->Acked_Transitions
[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1147,31 +1153,32 @@ int Analog_Input_Alarm_Summary(
if (index < MAX_ANALOG_INPUTS) {
/* Event_State is not equal to NORMAL and
Notify_Type property value is ALARM */
if((AI_Descr[index].Event_State != EVENT_STATE_NORMAL) &&
(AI_Descr[index].Notify_Type == NOTIFY_ALARM)){
if ((AI_Descr[index].Event_State != EVENT_STATE_NORMAL) &&
(AI_Descr[index].Notify_Type == NOTIFY_ALARM)) {
/* Object Identifier */
getalarm_data->objectIdentifier.type = OBJECT_ANALOG_INPUT;
getalarm_data->objectIdentifier.instance =
Analog_Input_Index_To_Instance(index);
Analog_Input_Index_To_Instance(index);
/* Alarm State */
getalarm_data->alarmState = AI_Descr[index].Event_State;
/* Acknowledged Transitions */
bitstring_init(&getalarm_data->acknowledgedTransitions);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AI_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked);
return 1; /* active alarm */
}
else
return 0; /* no active alarm at this index */
return 1; /* active alarm */
} else
return 0; /* no active alarm at this index */
} else
return -1; /* end of list */
}
-1
View File
@@ -149,5 +149,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+4 -4
View File
@@ -447,11 +447,11 @@ bool Analog_Output_Write_Property(
if (status) {
level = AO_LEVEL_NULL;
object_index =
Analog_Output_Instance_To_Index
(wp_data->object_instance);
Analog_Output_Instance_To_Index(wp_data->
object_instance);
status =
Analog_Output_Present_Value_Relinquish
(wp_data->object_instance, wp_data->priority);
Analog_Output_Present_Value_Relinquish(wp_data->
object_instance, wp_data->priority);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -100,5 +100,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+78 -71
View File
@@ -424,11 +424,11 @@ int Analog_Value_Read_Property(
case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0,
(CurrentAV->
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
(CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true :
false);
bitstring_set_bit(&bit_string, 1,
(CurrentAV->
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
(CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -436,14 +436,14 @@ int Analog_Value_Read_Property(
case PROP_EVENT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -451,8 +451,8 @@ int Analog_Value_Read_Property(
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
@@ -1004,17 +1004,17 @@ void Analog_Value_Intrinsic_Reporting(
event_data.notificationParams.outOfRange.exceedingValue =
PresentVal;
/* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange.
statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_IN_ALARM,
bitstring_init(&event_data.notificationParams.
outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAV->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAV->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband =
@@ -1034,24 +1034,30 @@ void Analog_Value_Intrinsic_Reporting(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
false;
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
false;
CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
false;
CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
}
}
@@ -1078,12 +1084,12 @@ int Analog_Value_Event_Information(
/* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions =
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked == false);
(AV_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked ==
false) | (AV_Descr[index].
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) | (AV_Descr[index].
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
} else
return -1; /* end of list */
@@ -1098,8 +1104,8 @@ int Analog_Value_Event_Information(
bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AV_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
@@ -1117,14 +1123,14 @@ int Analog_Value_Event_Information(
/* Event Enable */
bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
/* Event Priorities */
Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class,
getevent_data->eventPriorities);
@@ -1143,8 +1149,8 @@ int Analog_Value_Alarm_Ack(
object_index =
Analog_Value_Instance_To_Index(alarmack_data->eventObjectIdentifier.
instance);
Analog_Value_Instance_To_Index(alarmack_data->
eventObjectIdentifier.instance);
if (object_index < MAX_ANALOG_VALUES)
CurrentAV = &AV_Descr[object_index];
@@ -1157,22 +1163,22 @@ int Analog_Value_Alarm_Ack(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
if (CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked == false) {
if (CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
if (datetime_compare(&CurrentAV->Acked_Transitions
[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = true;
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
@@ -1186,8 +1192,8 @@ int Analog_Value_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
if (datetime_compare(&CurrentAV->Acked_Transitions
[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1209,8 +1215,8 @@ int Analog_Value_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
if (datetime_compare(&CurrentAV->Acked_Transitions
[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1246,31 +1252,32 @@ int Analog_Value_Alarm_Summary(
if (index < MAX_ANALOG_VALUES) {
/* Event_State is not equal to NORMAL and
Notify_Type property value is ALARM */
if((AV_Descr[index].Event_State != EVENT_STATE_NORMAL) &&
(AV_Descr[index].Notify_Type == NOTIFY_ALARM)){
if ((AV_Descr[index].Event_State != EVENT_STATE_NORMAL) &&
(AV_Descr[index].Notify_Type == NOTIFY_ALARM)) {
/* Object Identifier */
getalarm_data->objectIdentifier.type = OBJECT_ANALOG_VALUE;
getalarm_data->objectIdentifier.instance =
Analog_Value_Index_To_Instance(index);
Analog_Value_Index_To_Instance(index);
/* Alarm State */
getalarm_data->alarmState = AV_Descr[index].Event_State;
/* Acknowledged Transitions */
bitstring_init(&getalarm_data->acknowledgedTransitions);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AV_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked);
return 1; /* active alarm */
}
else
return 0; /* no active alarm at this index */
return 1; /* active alarm */
} else
return 0; /* no active alarm at this index */
} else
return -1; /* end of list */
}
+2 -3
View File
@@ -116,8 +116,8 @@ extern "C" {
BACNET_ERROR_CODE * error_code);
int Analog_Value_Alarm_Summary(
unsigned index,
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data);
unsigned index,
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data);
#endif
void Analog_Value_Init(
@@ -132,5 +132,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+2 -1
View File
@@ -474,7 +474,8 @@ bool bacfile_write_stream_data(
}
if (pFile) {
if (data->type.stream.fileStartPosition != -1) {
(void) fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
(void) fseek(pFile, data->type.stream.fileStartPosition,
SEEK_SET);
}
if (fwrite(octetstring_value(&data->fileData),
octetstring_length(&data->fileData), 1, pFile) != 1) {
-1
View File
@@ -98,5 +98,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
-1
View File
@@ -114,5 +114,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+4 -4
View File
@@ -376,8 +376,8 @@ bool Binary_Output_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index =
Binary_Output_Instance_To_Index
(wp_data->object_instance);
Binary_Output_Instance_To_Index(wp_data->
object_instance);
priority--;
Binary_Output_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we
@@ -403,8 +403,8 @@ bool Binary_Output_Write_Property(
if (status) {
level = BINARY_NULL;
object_index =
Binary_Output_Instance_To_Index
(wp_data->object_instance);
Binary_Output_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
-1
View File
@@ -116,5 +116,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+4 -4
View File
@@ -359,8 +359,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Binary_Value_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we
@@ -386,8 +386,8 @@ bool Binary_Value_Write_Property(
if (status) {
level = BINARY_NULL;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
-1
View File
@@ -71,5 +71,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+10 -14
View File
@@ -152,9 +152,7 @@ bool CharacterString_Value_Present_Value(
index = CharacterString_Value_Instance_To_Index(object_instance);
if (object_name && (index < MAX_CHARACTERSTRING_VALUES)) {
status = characterstring_copy(
object_name,
&Present_Value[index]);
status = characterstring_copy(object_name, &Present_Value[index]);
}
return status;
@@ -169,9 +167,7 @@ bool CharacterString_Value_Present_Value_Set(
index = CharacterString_Value_Instance_To_Index(object_instance);
if (index < MAX_CHARACTERSTRING_VALUES) {
status = characterstring_copy(
&Present_Value[index],
object_name);
status = characterstring_copy(&Present_Value[index], object_name);
}
return status;
@@ -361,7 +357,8 @@ int CharacterString_Value_Read_Property(
break;
case PROP_OUT_OF_SERVICE:
object_index =
CharacterString_Value_Instance_To_Index(rpdata->object_instance);
CharacterString_Value_Instance_To_Index(rpdata->
object_instance);
state = Out_Of_Service[object_index];
apdu_len = encode_application_boolean(&apdu[0], state);
break;
@@ -405,13 +402,12 @@ bool CharacterString_Value_Write_Property(
case PROP_PRESENT_VALUE:
status =
WPValidateArgType(&value,
BACNET_APPLICATION_TAG_CHARACTER_STRING,
&wp_data->error_class, &wp_data->error_code);
BACNET_APPLICATION_TAG_CHARACTER_STRING, &wp_data->error_class,
&wp_data->error_code);
if (status) {
status =
CharacterString_Value_Present_Value_Set
(wp_data->object_instance,
&value.type.Character_String);
CharacterString_Value_Present_Value_Set(wp_data->
object_instance, &value.type.Character_String);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -423,8 +419,8 @@ bool CharacterString_Value_Write_Property(
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
&wp_data->error_class, &wp_data->error_code);
if (status) {
CharacterString_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
CharacterString_Value_Out_Of_Service_Set(wp_data->
object_instance, value.type.Boolean);
}
break;
default:
-1
View File
@@ -92,5 +92,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+29 -30
View File
@@ -104,35 +104,35 @@ extern bool Routed_Device_Write_Property_Local(
/* All included BACnet objects */
static object_functions_t Object_Table[] = {
{OBJECT_DEVICE,
NULL /* Init - don't init Device or it will recourse! */,
Device_Count,
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Object_Name,
Device_Read_Property_Local,
NULL /* Write_Property */,
NULL /* Property_Lists */,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
NULL /* Init - don't init Device or it will recourse! */ ,
Device_Count,
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Object_Name,
Device_Read_Property_Local,
NULL /* Write_Property */ ,
NULL /* Property_Lists */ ,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{MAX_BACNET_OBJECT_TYPE,
NULL /* Init */,
NULL /* Count */,
NULL /* Index_To_Instance */,
NULL /* Valid_Instance */,
NULL /* Object_Name */,
NULL /* Read_Property */,
NULL /* Write_Property */,
NULL /* Property_Lists */,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */}
NULL /* Init */ ,
NULL /* Count */ ,
NULL /* Index_To_Instance */ ,
NULL /* Valid_Instance */ ,
NULL /* Object_Name */ ,
NULL /* Read_Property */ ,
NULL /* Write_Property */ ,
NULL /* Property_Lists */ ,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ }
};
/** Glue function to let the Device object, when called by a handler,
@@ -906,6 +906,7 @@ bool Device_Write_Property(
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
return (status);
}
/* Ditto for the local version; always returns false */
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data)
@@ -941,5 +942,3 @@ void Device_Init(
pObject++;
}
}
+225 -226
View File
@@ -90,234 +90,234 @@ static object_functions_t *Object_Table;
static object_functions_t My_Object_Table[] = {
{OBJECT_DEVICE,
NULL /* Init - don't init Device or it will recourse! */,
Device_Count,
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Object_Name,
Device_Read_Property_Local,
Device_Write_Property_Local,
Device_Property_Lists,
DeviceGetRRInfo,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
NULL /* Init - don't init Device or it will recourse! */ ,
Device_Count,
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Object_Name,
Device_Read_Property_Local,
Device_Write_Property_Local,
Device_Property_Lists,
DeviceGetRRInfo,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_ANALOG_INPUT,
Analog_Input_Init,
Analog_Input_Count,
Analog_Input_Index_To_Instance,
Analog_Input_Valid_Instance,
Analog_Input_Object_Name,
Analog_Input_Read_Property,
Analog_Input_Write_Property,
Analog_Input_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
Analog_Input_Init,
Analog_Input_Count,
Analog_Input_Index_To_Instance,
Analog_Input_Valid_Instance,
Analog_Input_Object_Name,
Analog_Input_Read_Property,
Analog_Input_Write_Property,
Analog_Input_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
Analog_Input_Intrinsic_Reporting},
{OBJECT_ANALOG_VALUE,
Analog_Value_Init,
Analog_Value_Count,
Analog_Value_Index_To_Instance,
Analog_Value_Valid_Instance,
Analog_Value_Object_Name,
Analog_Value_Read_Property,
Analog_Value_Write_Property,
Analog_Value_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
Analog_Value_Init,
Analog_Value_Count,
Analog_Value_Index_To_Instance,
Analog_Value_Valid_Instance,
Analog_Value_Object_Name,
Analog_Value_Read_Property,
Analog_Value_Write_Property,
Analog_Value_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
Analog_Value_Intrinsic_Reporting},
{OBJECT_BINARY_INPUT,
Binary_Input_Init,
Binary_Input_Count,
Binary_Input_Index_To_Instance,
Binary_Input_Valid_Instance,
Binary_Input_Object_Name,
Binary_Input_Read_Property,
NULL /* Write Property */,
Binary_Input_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
Binary_Input_Encode_Value_List,
Binary_Input_Change_Of_Value,
Binary_Input_Change_Of_Value_Clear,
NULL /* Intrinsic Reporting */},
Binary_Input_Init,
Binary_Input_Count,
Binary_Input_Index_To_Instance,
Binary_Input_Valid_Instance,
Binary_Input_Object_Name,
Binary_Input_Read_Property,
NULL /* Write Property */ ,
Binary_Input_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
Binary_Input_Encode_Value_List,
Binary_Input_Change_Of_Value,
Binary_Input_Change_Of_Value_Clear,
NULL /* Intrinsic Reporting */ },
{OBJECT_BINARY_VALUE,
Binary_Value_Init,
Binary_Value_Count,
Binary_Value_Index_To_Instance,
Binary_Value_Valid_Instance,
Binary_Value_Object_Name,
Binary_Value_Read_Property,
Binary_Value_Write_Property,
Binary_Value_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Binary_Value_Init,
Binary_Value_Count,
Binary_Value_Index_To_Instance,
Binary_Value_Valid_Instance,
Binary_Value_Object_Name,
Binary_Value_Read_Property,
Binary_Value_Write_Property,
Binary_Value_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_CHARACTERSTRING_VALUE,
CharacterString_Value_Init,
CharacterString_Value_Count,
CharacterString_Value_Index_To_Instance,
CharacterString_Value_Valid_Instance,
CharacterString_Value_Object_Name,
CharacterString_Value_Read_Property,
CharacterString_Value_Write_Property,
CharacterString_Value_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
CharacterString_Value_Init,
CharacterString_Value_Count,
CharacterString_Value_Index_To_Instance,
CharacterString_Value_Valid_Instance,
CharacterString_Value_Object_Name,
CharacterString_Value_Read_Property,
CharacterString_Value_Write_Property,
CharacterString_Value_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
#if defined(INTRINSIC_REPORTING)
{OBJECT_NOTIFICATION_CLASS,
Notification_Class_Init,
Notification_Class_Count,
Notification_Class_Index_To_Instance,
Notification_Class_Valid_Instance,
Notification_Class_Object_Name,
Notification_Class_Read_Property,
Notification_Class_Write_Property,
Notification_Class_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Notification_Class_Init,
Notification_Class_Count,
Notification_Class_Index_To_Instance,
Notification_Class_Valid_Instance,
Notification_Class_Object_Name,
Notification_Class_Read_Property,
Notification_Class_Write_Property,
Notification_Class_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
#endif
{OBJECT_LIFE_SAFETY_POINT,
Life_Safety_Point_Init,
Life_Safety_Point_Count,
Life_Safety_Point_Index_To_Instance,
Life_Safety_Point_Valid_Instance,
Life_Safety_Point_Object_Name,
Life_Safety_Point_Read_Property,
Life_Safety_Point_Write_Property,
Life_Safety_Point_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Life_Safety_Point_Init,
Life_Safety_Point_Count,
Life_Safety_Point_Index_To_Instance,
Life_Safety_Point_Valid_Instance,
Life_Safety_Point_Object_Name,
Life_Safety_Point_Read_Property,
Life_Safety_Point_Write_Property,
Life_Safety_Point_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_LOAD_CONTROL,
Load_Control_Init,
Load_Control_Count,
Load_Control_Index_To_Instance,
Load_Control_Valid_Instance,
Load_Control_Object_Name,
Load_Control_Read_Property,
Load_Control_Write_Property,
Load_Control_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Load_Control_Init,
Load_Control_Count,
Load_Control_Index_To_Instance,
Load_Control_Valid_Instance,
Load_Control_Object_Name,
Load_Control_Read_Property,
Load_Control_Write_Property,
Load_Control_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_MULTI_STATE_INPUT,
Multistate_Input_Init,
Multistate_Input_Count,
Multistate_Input_Index_To_Instance,
Multistate_Input_Valid_Instance,
Multistate_Input_Object_Name,
Multistate_Input_Read_Property,
Multistate_Input_Write_Property,
Multistate_Input_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Multistate_Input_Init,
Multistate_Input_Count,
Multistate_Input_Index_To_Instance,
Multistate_Input_Valid_Instance,
Multistate_Input_Object_Name,
Multistate_Input_Read_Property,
Multistate_Input_Write_Property,
Multistate_Input_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_MULTI_STATE_OUTPUT,
Multistate_Output_Init,
Multistate_Output_Count,
Multistate_Output_Index_To_Instance,
Multistate_Output_Valid_Instance,
Multistate_Output_Object_Name,
Multistate_Output_Read_Property,
Multistate_Output_Write_Property,
Multistate_Output_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Multistate_Output_Init,
Multistate_Output_Count,
Multistate_Output_Index_To_Instance,
Multistate_Output_Valid_Instance,
Multistate_Output_Object_Name,
Multistate_Output_Read_Property,
Multistate_Output_Write_Property,
Multistate_Output_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_MULTI_STATE_VALUE,
Multistate_Value_Init,
Multistate_Value_Count,
Multistate_Value_Index_To_Instance,
Multistate_Value_Valid_Instance,
Multistate_Value_Object_Name,
Multistate_Value_Read_Property,
Multistate_Value_Write_Property,
Multistate_Value_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Multistate_Value_Init,
Multistate_Value_Count,
Multistate_Value_Index_To_Instance,
Multistate_Value_Valid_Instance,
Multistate_Value_Object_Name,
Multistate_Value_Read_Property,
Multistate_Value_Write_Property,
Multistate_Value_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
{OBJECT_TRENDLOG,
Trend_Log_Init,
Trend_Log_Count,
Trend_Log_Index_To_Instance,
Trend_Log_Valid_Instance,
Trend_Log_Object_Name,
Trend_Log_Read_Property,
Trend_Log_Write_Property,
Trend_Log_Property_Lists,
TrendLogGetRRInfo,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
Trend_Log_Init,
Trend_Log_Count,
Trend_Log_Index_To_Instance,
Trend_Log_Valid_Instance,
Trend_Log_Object_Name,
Trend_Log_Read_Property,
Trend_Log_Write_Property,
Trend_Log_Property_Lists,
TrendLogGetRRInfo,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
#if defined(BACFILE)
{OBJECT_FILE,
bacfile_init,
bacfile_count,
bacfile_index_to_instance,
bacfile_valid_instance,
bacfile_object_name,
bacfile_read_property,
bacfile_write_property,
BACfile_Property_Lists,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */},
bacfile_init,
bacfile_count,
bacfile_index_to_instance,
bacfile_valid_instance,
bacfile_object_name,
bacfile_read_property,
bacfile_write_property,
BACfile_Property_Lists,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ },
#endif
{MAX_BACNET_OBJECT_TYPE,
NULL /* Init */,
NULL /* Count */,
NULL /* Index_To_Instance */,
NULL /* Valid_Instance */,
NULL /* Object_Name */,
NULL /* Read_Property */,
NULL /* Write_Property */,
NULL /* Property_Lists */,
NULL /* ReadRangeInfo */,
NULL /* Iterator */,
NULL /* Value_Lists */,
NULL /* COV */,
NULL /* COV Clear */,
NULL /* Intrinsic Reporting */}
NULL /* Init */ ,
NULL /* Count */ ,
NULL /* Index_To_Instance */ ,
NULL /* Valid_Instance */ ,
NULL /* Object_Name */ ,
NULL /* Read_Property */ ,
NULL /* Write_Property */ ,
NULL /* Property_Lists */ ,
NULL /* ReadRangeInfo */ ,
NULL /* Iterator */ ,
NULL /* Value_Lists */ ,
NULL /* COV */ ,
NULL /* COV Clear */ ,
NULL /* Intrinsic Reporting */ }
};
/** Glue function to let the Device object, when called by a handler,
@@ -1419,8 +1419,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */
} else {
status = false;
@@ -1453,8 +1453,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
/* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t) value.
type.Unsigned_Int);
Device_Set_Vendor_Identifier((uint16_t) value.type.
Unsigned_Int);
}
break;
case PROP_SYSTEM_STATUS:
@@ -1500,8 +1500,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Location(characterstring_value(&value.
type.Character_String),
Device_Set_Location(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1511,8 +1511,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Description(characterstring_value(&value.
type.Character_String),
Device_Set_Description(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1521,8 +1521,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Model_Name(characterstring_value(&value.
type.Character_String),
Device_Set_Model_Name(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1534,8 +1534,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames((uint8_t) value.
type.Unsigned_Int);
dlmstp_set_max_info_frames((uint8_t) value.type.
Unsigned_Int);
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1639,8 +1639,8 @@ bool Device_Encode_Value_List(
}
bool Device_COV(
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance)
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance)
{
bool status = false; /* Ever the pessamist! */
struct object_functions *pObject = NULL;
@@ -1650,8 +1650,7 @@ bool Device_COV(
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
if (pObject->Object_COV) {
status = pObject->Object_COV(
object_instance);
status = pObject->Object_COV(object_instance);
}
}
}
@@ -1660,8 +1659,8 @@ bool Device_COV(
}
void Device_COV_Clear(
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance)
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance)
{
struct object_functions *pObject = NULL;
+9 -14
View File
@@ -126,7 +126,7 @@ typedef bool(
* @ingroup ObjHelpers
* @param [in] The object instance number to be looked up.
*/
typedef void(
typedef void (
*object_cov_clear_function) (
uint32_t object_instance);
@@ -282,7 +282,7 @@ extern "C" {
BACNET_CHARACTER_STRING * object_name);
/* Copy a child object name, given its ID. */
bool Device_Object_Name_Copy(
BACNET_OBJECT_TYPE object_type,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name);
@@ -378,7 +378,7 @@ extern "C" {
uint16_t Add_Routed_Device(
uint32_t Object_Instance,
BACNET_CHARACTER_STRING *Object_Name,
BACNET_CHARACTER_STRING * Object_Name,
const char *Description);
DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
int idx);
@@ -421,17 +421,16 @@ extern "C" {
void Routed_Device_Inc_Database_Revision(
void);
int Routed_Device_Service_Approval(
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t *apdu_buff,
uint8_t invoke_id );
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t * apdu_buff,
uint8_t invoke_id);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/** @defgroup ObjFrmwk Object Framework
* The modules in this section describe the BACnet-stack's framework for
* BACnet-defined Objects (Device, Analog Input, etc). There are two submodules
@@ -441,15 +440,11 @@ extern "C" {
* - The interface between the implemented Objects and the BAC-stack services,
* specifically the handlers, which are mediated through function calls to
* the Device object.
*/
/** @defgroup ObjHelpers Object Helper Functions
*//** @defgroup ObjHelpers Object Helper Functions
* @ingroup ObjFrmwk
* This section describes the function templates for the helper functions that
* provide common object support.
*/
/** @defgroup ObjIntf Handler-to-Object Interface Functions
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
* @ingroup ObjFrmwk
* This section describes the fairly limited set of functions that link the
* BAC-stack handlers to the BACnet Object instances. All of these calls are
+26 -24
View File
@@ -116,7 +116,7 @@ uint16_t iCurrent_Device_Idx = 0;
*/
uint16_t Add_Routed_Device(
uint32_t Object_Instance,
BACNET_CHARACTER_STRING *sObject_Name,
BACNET_CHARACTER_STRING * sObject_Name,
const char *sDescription)
{
int i = Num_Managed_Devices;
@@ -127,8 +127,8 @@ uint16_t Add_Routed_Device(
pDev->bacObj.mObject_Type = OBJECT_DEVICE;
pDev->bacObj.Object_Instance_Number = Object_Instance;
if (sObject_Name != NULL)
Routed_Device_Set_Object_Name(sObject_Name->encoding,
sObject_Name->value, sObject_Name->length);
Routed_Device_Set_Object_Name(sObject_Name->encoding,
sObject_Name->value, sObject_Name->length);
else
Routed_Device_Set_Object_Name(CHARACTER_UTF8, "No Name",
strlen("No Name"));
@@ -402,12 +402,13 @@ bool Routed_Device_Valid_Object_Instance_Number(
}
bool Routed_Device_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name)
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name)
{
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if (object_instance == pDev->bacObj.Object_Instance_Number) {
return characterstring_init_ansi(object_name, pDev->bacObj.Object_Name);
return characterstring_init_ansi(object_name,
pDev->bacObj.Object_Name);
}
return NULL;
@@ -485,8 +486,8 @@ bool Routed_Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Routed_Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Routed_Device_Set_Object_Instance_Number(value.
type.Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */
} else {
status = false;
@@ -500,8 +501,8 @@ bool Routed_Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Routed_Device_Set_Object_Name(characterstring_encoding(&value.
type.Character_String),
Routed_Device_Set_Object_Name(characterstring_encoding
(&value.type.Character_String),
characterstring_value(&value.type.Character_String),
characterstring_length(&value.type.Character_String));
}
@@ -611,32 +612,33 @@ void Routed_Device_Inc_Database_Revision(
* else 0 if service is approved for the current device.
*/
int Routed_Device_Service_Approval(
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t *apdu_buff,
uint8_t invoke_id )
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t * apdu_buff,
uint8_t invoke_id)
{
int len = 0;
switch(service)
{
switch (service) {
case SERVICE_CONFIRMED_REINITIALIZE_DEVICE:
/* If not the gateway device, we don't support RD */
if ( iCurrent_Device_Idx > 0 ) {
if (iCurrent_Device_Idx > 0) {
if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
len =
reject_encode_apdu(apdu_buff, invoke_id,
REJECT_REASON_UNRECOGNIZED_SERVICE);
else
len = 1; /* Non-zero return */
len = 1; /* Non-zero return */
}
break;
case SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL:
/* If not the gateway device, we don't support DCC */
if ( iCurrent_Device_Idx > 0 ) {
if (iCurrent_Device_Idx > 0) {
if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
len =
reject_encode_apdu(apdu_buff, invoke_id,
REJECT_REASON_UNRECOGNIZED_SERVICE);
else
len = 1; /* Non-zero return */
len = 1; /* Non-zero return */
}
break;
default:
-1
View File
@@ -76,5 +76,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+8 -8
View File
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
object_index =
Lighting_Output_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Lighting_Output_Level[object_index][rpdata->array_index
- 1] == LIGHTING_LEVEL_NULL)
if (Lighting_Output_Level[object_index][rpdata->
array_index - 1] == LIGHTING_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]);
else {
real_value = Lighting_Output_Level[object_index]
@@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property(
if (status) {
level = LIGHTING_LEVEL_NULL;
object_index =
Lighting_Output_Instance_To_Index
(wp_data->object_instance);
Lighting_Output_Instance_To_Index(wp_data->
object_instance);
status =
Lighting_Output_Present_Value_Relinquish
(wp_data->object_instance, wp_data->priority);
Lighting_Output_Present_Value_Relinquish(wp_data->
object_instance, wp_data->priority);
if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Lighting_Output_Instance_To_Index
(wp_data->object_instance);
Lighting_Output_Instance_To_Index(wp_data->
object_instance);
Lighting_Output_Out_Of_Service[object_index] =
value.type.Boolean;
}
+4 -4
View File
@@ -332,8 +332,8 @@ bool Life_Safety_Point_Write_Property(
if (status) {
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
object_index =
Life_Safety_Point_Instance_To_Index
(wp_data->object_instance);
Life_Safety_Point_Instance_To_Index(wp_data->
object_instance);
Life_Safety_Point_Mode[object_index] =
value.type.Enumerated;
} else {
@@ -349,8 +349,8 @@ bool Life_Safety_Point_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Life_Safety_Point_Instance_To_Index
(wp_data->object_instance);
Life_Safety_Point_Instance_To_Index(wp_data->
object_instance);
Life_Safety_Point_Out_Of_Service[object_index] =
value.type.Boolean;
}
-1
View File
@@ -69,5 +69,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+6 -6
View File
@@ -436,8 +436,8 @@ int Multistate_Input_Read_Property(
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
object_index =
Multistate_Input_Instance_To_Index
(rpdata->object_instance);
Multistate_Input_Instance_To_Index(rpdata->
object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance,
@@ -458,8 +458,8 @@ int Multistate_Input_Read_Property(
}
} else {
object_index =
Multistate_Input_Instance_To_Index
(rpdata->object_instance);
Multistate_Input_Instance_To_Index(rpdata->
object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance,
@@ -517,8 +517,8 @@ bool Multistate_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
status =
Multistate_Input_Present_Value_Set
(wp_data->object_instance, value.type.Unsigned_Int);
Multistate_Input_Present_Value_Set(wp_data->
object_instance, value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -103,5 +103,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+10 -10
View File
@@ -268,8 +268,8 @@ int Multistate_Output_Read_Property(
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index =
Multistate_Output_Instance_To_Index
(rpdata->object_instance);
Multistate_Output_Instance_To_Index(rpdata->
object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] ==
@@ -294,8 +294,8 @@ int Multistate_Output_Read_Property(
}
} else {
object_index =
Multistate_Output_Instance_To_Index
(rpdata->object_instance);
Multistate_Output_Instance_To_Index(rpdata->
object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Multistate_Output_Level[object_index]
[rpdata->array_index - 1] == MULTISTATE_NULL)
@@ -377,8 +377,8 @@ bool Multistate_Output_Write_Property(
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
level = value.type.Unsigned_Int;
object_index =
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
priority--;
Multistate_Output_Level[object_index][priority] =
(uint8_t) level;
@@ -405,8 +405,8 @@ bool Multistate_Output_Write_Property(
if (status) {
level = MULTISTATE_NULL;
object_index =
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
@@ -432,8 +432,8 @@ bool Multistate_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
Multistate_Output_Out_Of_Service[object_index] =
value.type.Boolean;
}
-1
View File
@@ -71,5 +71,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+6 -6
View File
@@ -438,8 +438,8 @@ int Multistate_Value_Read_Property(
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
object_index =
Multistate_Value_Instance_To_Index
(rpdata->object_instance);
Multistate_Value_Instance_To_Index(rpdata->
object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string,
Multistate_Value_State_Text(rpdata->object_instance,
@@ -460,8 +460,8 @@ int Multistate_Value_Read_Property(
}
} else {
object_index =
Multistate_Value_Instance_To_Index
(rpdata->object_instance);
Multistate_Value_Instance_To_Index(rpdata->
object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string,
Multistate_Value_State_Text(rpdata->object_instance,
@@ -519,8 +519,8 @@ bool Multistate_Value_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
status =
Multistate_Value_Present_Value_Set
(wp_data->object_instance, value.type.Unsigned_Int);
Multistate_Value_Present_Value_Set(wp_data->
object_instance, value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -103,5 +103,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+59 -64
View File
@@ -95,9 +95,9 @@ void Notification_Class_Init(
memset(&NC_Info[NotifyIdx], 0x00, sizeof(NOTIFICATION_CLASS_INFO));
/* set the basic parameters */
NC_Info[NotifyIdx].Ack_Required = 0;
NC_Info[NotifyIdx].Priority[TRANSITION_TO_OFFNORMAL] = 255; /* The lowest priority for Normal message. */
NC_Info[NotifyIdx].Priority[TRANSITION_TO_FAULT] = 255; /* The lowest priority for Normal message. */
NC_Info[NotifyIdx].Priority[TRANSITION_TO_NORMAL] = 255; /* The lowest priority for Normal message. */
NC_Info[NotifyIdx].Priority[TRANSITION_TO_OFFNORMAL] = 255; /* The lowest priority for Normal message. */
NC_Info[NotifyIdx].Priority[TRANSITION_TO_FAULT] = 255; /* The lowest priority for Normal message. */
NC_Info[NotifyIdx].Priority[TRANSITION_TO_NORMAL] = 255; /* The lowest priority for Normal message. */
}
return;
@@ -189,8 +189,8 @@ int Notification_Class_Read_Property(
apdu = rpdata->application_data;
CurrentNotify =
&NC_Info[Notification_Class_Instance_To_Index(rpdata->
object_instance)];
&NC_Info[Notification_Class_Instance_To_Index
(rpdata->object_instance)];
switch (rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER:
@@ -400,8 +400,8 @@ bool Notification_Class_Write_Property(
CurrentNotify =
&NC_Info[Notification_Class_Instance_To_Index(wp_data->
object_instance)];
&NC_Info[Notification_Class_Instance_To_Index
(wp_data->object_instance)];
/* decode the some of the request
*/
@@ -455,9 +455,8 @@ bool Notification_Class_Write_Property(
while (iOffset < wp_data->application_data_len) {
/* Decode Valid Days */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
@@ -480,9 +479,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Decode From Time */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
/* Bad decode, wrong tag or following required parameter missing */
@@ -496,9 +494,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Decode To Time */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
/* Bad decode, wrong tag or following required parameter missing */
@@ -517,9 +514,8 @@ bool Notification_Class_Write_Property(
RECIPIENT_TYPE_DEVICE;
/* Decode Network Number */
len =
bacapp_decode_context_data(&wp_data->
application_data[iOffset],
wp_data->application_data_len, &value,
bacapp_decode_context_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value,
PROP_RECIPIENT_LIST);
if ((len == 0) ||
@@ -530,21 +526,21 @@ bool Notification_Class_Write_Property(
return false;
}
/* store value */
TmpNotify.Recipient_List[idx].Recipient._.
DeviceIdentifier = value.type.Object_Id.instance;
TmpNotify.Recipient_List[idx].Recipient.
_.DeviceIdentifier = value.type.Object_Id.instance;
iOffset += len;
}
/* opening tag [1] - Recipient */
else if (decode_is_opening_tag_number(&wp_data->
application_data[iOffset], 1)) {
else if (decode_is_opening_tag_number
(&wp_data->application_data[iOffset], 1)) {
iOffset++;
TmpNotify.Recipient_List[idx].Recipient.RecipientType =
RECIPIENT_TYPE_ADDRESS;
/* Decode Network Number */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset],
bacapp_decode_application_data
(&wp_data->application_data[iOffset],
wp_data->application_data_len, &value);
if ((len == 0) ||
@@ -561,8 +557,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Decode Address */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset],
bacapp_decode_application_data
(&wp_data->application_data[iOffset],
wp_data->application_data_len, &value);
if ((len == 0) ||
@@ -573,16 +569,16 @@ bool Notification_Class_Write_Property(
return false;
}
/* store value */
if (TmpNotify.Recipient_List[idx].Recipient._.Address.
net == 0) {
memcpy(TmpNotify.Recipient_List[idx].Recipient._.
Address.mac, value.type.Octet_String.value,
if (TmpNotify.Recipient_List[idx].Recipient._.
Address.net == 0) {
memcpy(TmpNotify.Recipient_List[idx].Recipient.
_.Address.mac, value.type.Octet_String.value,
value.type.Octet_String.length);
TmpNotify.Recipient_List[idx].Recipient._.Address.
mac_len = value.type.Octet_String.length;
TmpNotify.Recipient_List[idx].Recipient._.
Address.mac_len = value.type.Octet_String.length;
} else {
memcpy(TmpNotify.Recipient_List[idx].Recipient._.
Address.adr, value.type.Octet_String.value,
memcpy(TmpNotify.Recipient_List[idx].Recipient.
_.Address.adr, value.type.Octet_String.value,
value.type.Octet_String.length);
TmpNotify.Recipient_List[idx].Recipient._.Address.len =
value.type.Octet_String.length;
@@ -590,8 +586,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* closing tag [1] - Recipient */
if (decode_is_closing_tag_number(&wp_data->
application_data[iOffset], 1))
if (decode_is_closing_tag_number(&wp_data->application_data
[iOffset], 1))
iOffset++;
else {
/* Bad decode, wrong tag or following required parameter missing */
@@ -608,9 +604,8 @@ bool Notification_Class_Write_Property(
/* Process Identifier */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
@@ -626,9 +621,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Issue Confirmed Notifications */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) {
@@ -644,9 +638,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Transitions */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
@@ -687,16 +680,16 @@ bool Notification_Class_Write_Property(
CurrentNotify->Recipient_List[idx] =
TmpNotify.Recipient_List[idx];
if (CurrentNotify->Recipient_List[idx].Recipient.
RecipientType == RECIPIENT_TYPE_DEVICE) {
if (CurrentNotify->Recipient_List[idx].
Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) {
/* copy Device_ID */
DeviceID =
CurrentNotify->Recipient_List[idx].Recipient._.
DeviceIdentifier;
CurrentNotify->Recipient_List[idx].Recipient.
_.DeviceIdentifier;
address_bind_request(DeviceID, &max_apdu, &src);
} else if (CurrentNotify->Recipient_List[idx].Recipient.
RecipientType == RECIPIENT_TYPE_ADDRESS) {
} else if (CurrentNotify->Recipient_List[idx].
Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
/* copy Address */
/* src = CurrentNotify->Recipient_List[idx].Recipient._.Address; */
/* address_bind_request(BACNET_MAX_INSTANCE, &max_apdu, &src); */
@@ -816,17 +809,19 @@ void Notification_Class_common_reporting_function(
/* Priority and AckRequired */
switch (event_data->toState) {
case EVENT_STATE_NORMAL:
event_data->priority = CurrentNotify->Priority[TRANSITION_TO_NORMAL];
event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_NORMAL];
event_data->ackRequired =
(CurrentNotify->
Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? true : false;
(CurrentNotify->Ack_Required & TRANSITION_TO_NORMAL_MASKED) ?
true : false;
break;
case EVENT_STATE_FAULT:
event_data->priority = CurrentNotify->Priority[TRANSITION_TO_FAULT];
event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_FAULT];
event_data->ackRequired =
(CurrentNotify->
Ack_Required & TRANSITION_TO_FAULT_MASKED) ? true : false;
(CurrentNotify->Ack_Required & TRANSITION_TO_FAULT_MASKED) ?
true : false;
break;
case EVENT_STATE_OFFNORMAL:
@@ -835,8 +830,8 @@ void Notification_Class_common_reporting_function(
event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL];
event_data->ackRequired =
(CurrentNotify->
Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false;
(CurrentNotify->Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED)
? true : false;
break;
default: /* shouldn't happen */
@@ -911,13 +906,13 @@ void Notification_Class_find_recipient(
RECIPIENT_TYPE_DEVICE) {
/* Device ID */
DeviceID =
CurrentNotify->Recipient_List[idx].Recipient._.
DeviceIdentifier;
CurrentNotify->Recipient_List[idx].Recipient.
_.DeviceIdentifier;
/* Send who_ is request only when address of device is unknown. */
if (!address_bind_request(DeviceID, &max_apdu, &src))
Send_WhoIs(DeviceID, DeviceID);
} else if (CurrentNotify->Recipient_List[idx].Recipient.
RecipientType == RECIPIENT_TYPE_ADDRESS) {
} else if (CurrentNotify->Recipient_List[idx].
Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
}
}
+1 -2
View File
@@ -76,7 +76,7 @@ BACnetRecipient ::= CHOICE {
/* Structure containing configuration for a Notification Class */
typedef struct Notification_Class_info {
uint8_t Priority[MAX_BACNET_EVENT_TRANSITION]; /* BACnetARRAY[3] of Unsigned */
uint8_t Priority[MAX_BACNET_EVENT_TRANSITION]; /* BACnetARRAY[3] of Unsigned */
uint8_t Ack_Required; /* BACnetEventTransitionBits */
BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */
} NOTIFICATION_CLASS_INFO;
@@ -138,5 +138,4 @@ BACnetRecipient ::= CHOICE {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* NC_H */
+7 -7
View File
@@ -736,9 +736,9 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) {
iOffset += len;
len =
bacapp_decode_context_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY);
bacapp_decode_context_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || ((value.context_tag != 2) &&
(value.context_tag != 3))) {
/* Bad decode or wrong tag */
@@ -755,8 +755,8 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) {
iOffset += len;
len =
bacapp_decode_context_data
(&wp_data->application_data[iOffset],
bacapp_decode_context_data(&wp_data->
application_data[iOffset],
wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || (value.context_tag != 3)) {
@@ -1098,8 +1098,8 @@ int rr_trend_log_encode(
pRequest->ItemCount = 0; /* Start out with nothing */
/* Bail out now if nowt - should never happen for a Trend Log but ... */
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->
object_instance)].ulRecordCount == 0)
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
ulRecordCount == 0)
return (0);
if ((pRequest->RequestType == RR_BY_POSITION) ||
-1
View File
@@ -197,5 +197,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+246 -266
View File
@@ -27,18 +27,24 @@ static bool isAtomicReadFileHandlerRegistered = false;
#define MAX_ERROR_STRING 128
#define NO_ERROR "No Error"
static char Last_Error[MAX_ERROR_STRING] = NO_ERROR;
static void LogError(const char *msg)
static void LogError(
const char *msg)
{
strcpy(Last_Error, msg);
Error_Detected = true;
}
void BacnetGetError(SV *errorMsg)
void BacnetGetError(
SV * errorMsg)
{
sv_setpv(errorMsg, Last_Error);
strcpy(Last_Error, NO_ERROR);
Error_Detected = false;
}
static void __LogAnswer(const char *msg, unsigned append)
static void __LogAnswer(
const char *msg,
unsigned append)
{
dSP;
ENTER;
@@ -63,10 +69,10 @@ static void MyAbortHandler(
{
(void) server;
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Abort: %s", bactext_abort_reason_name((int) abort_reason));
sprintf(msg, "BACnet Abort: %s",
bactext_abort_reason_name((int) abort_reason));
LogError(msg);
}
}
@@ -77,10 +83,10 @@ static void MyRejectHandler(
uint8_t reject_reason)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Reject: %s", bactext_reject_reason_name((int) reject_reason));
sprintf(msg, "BACnet Reject: %s",
bactext_reject_reason_name((int) reject_reason));
LogError(msg);
}
}
@@ -92,10 +98,11 @@ static void My_Error_Handler(
BACNET_ERROR_CODE error_code)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Error: %s: %s", bactext_error_class_name((int) error_class), bactext_error_code_name((int) error_code));
(invoke_id == Request_Invoke_ID)) {
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Error: %s: %s",
bactext_error_class_name((int) error_class),
bactext_error_code_name((int) error_code));
LogError(msg);
}
}
@@ -107,8 +114,9 @@ static void My_Error_Handler(
/*****************************************/
// Decode the ReadProperty Ack and pass to perl
/****************************************/
#define MAX_ACK_STRING 512
void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
#define MAX_ACK_STRING 512
void rp_ack_extract_data(
BACNET_READ_PROPERTY_DATA * data)
{
char ackString[MAX_ACK_STRING] = "";
char *pAckString = &ackString[0];
@@ -120,8 +128,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
bool first_value = true;
bool print_brace = false;
if (data)
{
if (data) {
application_data = data->application_data;
application_data_len = data->application_data_len;
/* FIXME: what if application_data_len is bigger than 255? */
@@ -130,8 +137,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
len =
bacapp_decode_application_data(application_data,
(uint8_t) application_data_len, &value);
if (first_value && (len < application_data_len))
{
if (first_value && (len < application_data_len)) {
first_value = false;
strncat(pAckString, "{", 1);
pAckString += 1;
@@ -142,7 +148,8 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
object_value.object_property = data->object_property;
object_value.array_index = data->array_index;
object_value.value = &value;
bacapp_snprintf_value(pAckString, MAX_ACK_STRING - (pAckString - ackString), &object_value);
bacapp_snprintf_value(pAckString,
MAX_ACK_STRING - (pAckString - ackString), &object_value);
if (len > 0) {
if (len < application_data_len) {
application_data += len;
@@ -157,12 +164,10 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
break;
}
}
if (print_brace)
{
if (print_brace) {
strncat(pAckString, "}", 1);
pAckString += 1;
}
// Now let's call a Perl function to display the data
__LogAnswer(ackString, 0);
}
@@ -171,7 +176,8 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
/*****************************************/
// Decode the ReadPropertyMultiple Ack and pass to perl
/****************************************/
void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
void rpm_ack_extract_data(
BACNET_READ_ACCESS_DATA * rpm_data)
{
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
BACNET_PROPERTY_REFERENCE *listOfProperties;
@@ -195,10 +201,14 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
object_value.object_type = rpm_data->object_type;
object_value.object_instance = rpm_data->object_instance;
while (value) {
object_value.object_property = listOfProperties->propertyIdentifier;
object_value.array_index = listOfProperties->propertyArrayIndex;
object_value.object_property =
listOfProperties->propertyIdentifier;
object_value.array_index =
listOfProperties->propertyArrayIndex;
object_value.value = value;
bacapp_snprintf_value(pAckString, MAX_ACK_STRING - (pAckString - ackString), &object_value);
bacapp_snprintf_value(pAckString,
MAX_ACK_STRING - (pAckString - ackString),
&object_value);
if (value->next) {
strncat(pAckString, ",", 1);
pAckString++;
@@ -213,10 +223,10 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
} else {
/* AccessError */
sprintf(ackString, "BACnet Error: %s: %s",
bactext_error_class_name((int) listOfProperties->
error.error_class),
bactext_error_code_name((int) listOfProperties->
error.error_code));
bactext_error_class_name((int) listOfProperties->error.
error_class),
bactext_error_code_name((int) listOfProperties->error.
error_code));
LogError(ackString);
}
listOfProperties = listOfProperties->next;
@@ -226,7 +236,7 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
strncat(pAckString, "QQQ", 3);
pAckString += 3;
}
// Now let's call a Perl function to display the data
__LogAnswer(ackString, 1);
}
@@ -241,31 +251,30 @@ static void AtomicReadFileAckHandler(
int len = 0;
BACNET_ATOMIC_READ_FILE_DATA data;
if (address_match(&Target_Address, src) && (service_data->invoke_id == Request_Invoke_ID))
{
len = arf_ack_decode_service_request(service_request, service_len, &data);
if (len > 0)
{
if (address_match(&Target_Address, src) &&
(service_data->invoke_id == Request_Invoke_ID)) {
len =
arf_ack_decode_service_request(service_request, service_len,
&data);
if (len > 0) {
/* validate the parameters before storing data */
if ((data.access == FILE_STREAM_ACCESS) && (service_data->invoke_id == Request_Invoke_ID))
{
if ((data.access == FILE_STREAM_ACCESS) &&
(service_data->invoke_id == Request_Invoke_ID)) {
char msg[32];
uint8_t *pFileData;
int i;
sprintf(msg, "EOF=%d,start=%d,", data.endOfFile, data.type.stream.fileStartPosition);
sprintf(msg, "EOF=%d,start=%d,", data.endOfFile,
data.type.stream.fileStartPosition);
__LogAnswer(msg, 0);
pFileData = octetstring_value(&data.fileData);
for (i=0; i<octetstring_length(&data.fileData); i++)
{
for (i = 0; i < octetstring_length(&data.fileData); i++) {
sprintf(msg, "%02x ", *pFileData);
__LogAnswer(msg, 1);
pFileData++;
}
}
else
{
} else {
LogError("Bad stream access reported");
}
}
@@ -295,9 +304,9 @@ static void My_Read_Property_Ack_Handler(
if (address_match(&Target_Address, src) &&
(service_data->invoke_id == Request_Invoke_ID)) {
len = rp_ack_decode_service_request(service_request, service_len, &data);
if (len > 0)
{
len =
rp_ack_decode_service_request(service_request, service_len, &data);
if (len > 0) {
rp_ack_extract_data(&data);
}
}
@@ -383,14 +392,14 @@ void My_Write_Property_SimpleAck_Handler(
uint8_t invoke_id)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
__LogAnswer("WriteProperty Acknowledged!", 0);
}
}
static void Init_Service_Handlers()
static void Init_Service_Handlers(
)
{
Device_Init(NULL);
@@ -402,89 +411,79 @@ static void Init_Service_Handlers()
/* 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);
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
handler_read_property);
/* handle generic errors coming back */
apdu_set_abort_handler(MyAbortHandler);
apdu_set_reject_handler(MyRejectHandler);
}
typedef enum
{
typedef enum {
waitAnswer,
waitBind,
} waitAction;
static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
static void Wait_For_Answer_Or_Timeout(
unsigned timeout_ms,
waitAction action)
{
// Wait for timeout, failure, or success
time_t last_seconds = time(NULL);
time_t timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
time_t elapsed_seconds = 0;
uint16_t pdu_len = 0;
BACNET_ADDRESS src = {0}; /* address where message came from */
BACNET_ADDRESS src = { 0 }; /* address where message came from */
uint8_t Rx_Buf[MAX_MPDU] = { 0 };
while (true)
{
while (true) {
time_t current_seconds = time(NULL);
// If error was detected then bail out
if (Error_Detected)
{
if (Error_Detected) {
LogError("Some other error occurred");
break;
}
if (elapsed_seconds > timeout_seconds)
{
if (elapsed_seconds > timeout_seconds) {
LogError("APDU Timeout");
break;
}
/* Process PDU if one comes in */
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout_ms);
if (pdu_len)
{
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
}
/* at least one second has passed */
if (current_seconds != last_seconds)
{
if (current_seconds != last_seconds) {
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
}
if (action == waitAnswer)
{
if (action == waitAnswer) {
// Response was received. Exit.
if (tsm_invoke_id_free(Request_Invoke_ID))
{
if (tsm_invoke_id_free(Request_Invoke_ID)) {
break;
}
else if (tsm_invoke_id_failed(Request_Invoke_ID))
{
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
LogError("TSM Timeout!");
tsm_free_invoke_id(Request_Invoke_ID);
break;
}
}
else if (action == waitBind)
{
if (address_bind_request(Target_Device_Object_Instance, &Target_Max_APDU, &Target_Address))
{
} else if (action == waitBind) {
if (address_bind_request(Target_Device_Object_Instance,
&Target_Max_APDU, &Target_Address)) {
break;
}
}
else
{
} else {
LogError("Invalid waitAction requested");
break;
}
// Keep track of time
elapsed_seconds += (current_seconds - last_seconds);
last_seconds = current_seconds;
@@ -498,7 +497,8 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
/****************************************************/
// This is the most fundamental setup needed to start communication
/****************************************************/
void BacnetPrepareComm()
void BacnetPrepareComm(
)
{
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
@@ -511,7 +511,8 @@ void BacnetPrepareComm()
// Try to bind to a device. If successful, return zero. If failure, return
// non-zero and log the error details
/****************************************************/
int BacnetBindToDevice(int deviceInstanceNumber)
int BacnetBindToDevice(
int deviceInstanceNumber)
{
int isFailure = 0;
@@ -520,39 +521,46 @@ int BacnetBindToDevice(int deviceInstanceNumber)
Target_Device_Object_Instance = deviceInstanceNumber;
/* try to bind with the device */
if (! address_bind_request(deviceInstanceNumber, &Target_Max_APDU, &Target_Address))
{
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
if (!address_bind_request(deviceInstanceNumber, &Target_Max_APDU,
&Target_Address)) {
Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
// Wait for timeout, failure, or success
Wait_For_Answer_Or_Timeout(100, waitBind);
}
// Clean up after ourselves
isFailure = Error_Detected;
Error_Detected = false;
return isFailure;
}
}
/****************************************************/
// This is the interface to ReadProperty
/****************************************************/
int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInstanceNumber, int objectProperty, int objectIndex)
int BacnetReadProperty(
int deviceInstanceNumber,
int objectType,
int objectInstanceNumber,
int objectProperty,
int objectIndex)
{
if (!isReadPropertyHandlerRegistered)
{
if (!isReadPropertyHandlerRegistered) {
/* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY, My_Read_Property_Ack_Handler);
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY,
My_Read_Property_Ack_Handler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY,
My_Error_Handler);
// indicate that handlers are now registered
isReadPropertyHandlerRegistered = true;
}
// Send the message out
Request_Invoke_ID = Send_Read_Property_Request(deviceInstanceNumber, objectType, objectInstanceNumber, objectProperty, objectIndex);
Request_Invoke_ID =
Send_Read_Property_Request(deviceInstanceNumber, objectType,
objectInstanceNumber, objectProperty, objectIndex);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
int isFailure = Error_Detected;
@@ -563,144 +571,118 @@ int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInsta
/************************************************/
// This is the interface to ReadPropertyMultiple
/************************************************/
int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
int BacnetReadPropertyMultiple(
int deviceInstanceNumber,
...)
{
// Get the variable argument list from the stack
Inline_Stack_Vars;
int rpmIndex = 1;
BACNET_READ_ACCESS_DATA *rpm_object = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
BACNET_READ_ACCESS_DATA *rpm_object =
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
BACNET_READ_ACCESS_DATA *Read_Access_Data = rpm_object;
BACNET_PROPERTY_REFERENCE *rpm_property;
uint8_t buffer[MAX_PDU] = { 0 };
while (rpmIndex < Inline_Stack_Items)
{
while (rpmIndex < Inline_Stack_Items) {
SV *pSV = Inline_Stack_Item(rpmIndex++);
// Make sure the argument is an Array Reference
if (SvTYPE(SvRV(pSV)) != SVt_PVAV)
{
if (SvTYPE(SvRV(pSV)) != SVt_PVAV) {
LogError("Argument is not an Array reference");
break;
}
// Make sure we can access the memory
if (rpm_object)
{
if (rpm_object) {
rpm_object->listOfProperties = NULL;
}
else
{
} else {
LogError("Memory Allocation Issue");
break;
}
AV *pAV = (AV *)SvRV(pSV);
AV *pAV = (AV *) SvRV(pSV);
SV **ppSV;
// The 0th argument is the object type
ppSV = av_fetch(pAV, 0, 0);
if (ppSV)
{
if (ppSV) {
rpm_object->object_type = SvIV(*ppSV);
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// The 1st argument is the object instance
ppSV = av_fetch(pAV, 1, 0);
if (ppSV)
{
if (ppSV) {
rpm_object->object_instance = SvIV(*ppSV);
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// The 2nd argument is the property type
ppSV = av_fetch(pAV, 2, 0);
if (ppSV)
{
if (ppSV) {
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
rpm_object->listOfProperties = rpm_property;
if (rpm_property)
{
if (rpm_property) {
rpm_property->propertyIdentifier = SvIV(*ppSV);
}
else
{
} else {
LogError("Memory allocation error");
break;
}
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// The 3rd argument is the property index
ppSV = av_fetch(pAV, 3, 0);
if (ppSV)
{
if (ppSV) {
rpm_property->propertyArrayIndex = SvIV(*ppSV);
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// Advance to the next RPM index
if (rpmIndex < Inline_Stack_Items)
{
if (rpmIndex < Inline_Stack_Items) {
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
rpm_object = rpm_object->next;
}
else
{
} else {
rpm_object->next = NULL;
}
}
if (!isReadPropertyMultipleHandlerRegistered)
{
if (!isReadPropertyMultipleHandlerRegistered) {
/* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
My_Read_Property_Multiple_Ack_Handler);
My_Read_Property_Multiple_Ack_Handler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
My_Error_Handler);
// indicate that handlers are now registered
isReadPropertyMultipleHandlerRegistered = true;
}
// Send the message out
if (!Error_Detected)
{
Request_Invoke_ID = Send_Read_Property_Multiple_Request(
&buffer[0], sizeof(buffer),
if (!Error_Detected) {
Request_Invoke_ID =
Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer),
deviceInstanceNumber, Read_Access_Data);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
}
// Clean up allocated memory
BACNET_READ_ACCESS_DATA *old_rpm_object;
BACNET_PROPERTY_REFERENCE *old_rpm_property;
rpm_object = Read_Access_Data;
old_rpm_object = rpm_object;
while (rpm_object)
{
while (rpm_object) {
rpm_property = rpm_object->listOfProperties;
while (rpm_property)
{
while (rpm_property) {
old_rpm_property = rpm_property;
rpm_property = rpm_property->next;
free(old_rpm_property);
@@ -719,80 +701,76 @@ int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
/****************************************************/
// This is the interface to WriteProperty
/****************************************************/
int BacnetWriteProperty(int deviceInstanceNumber,
int objectType,
int objectInstanceNumber,
int objectProperty,
int objectPriority,
int objectIndex,
const char *tag,
const char *value)
int BacnetWriteProperty(
int deviceInstanceNumber,
int objectType,
int objectInstanceNumber,
int objectProperty,
int objectPriority,
int objectIndex,
const char *tag,
const char *value)
{
char msg[MAX_ERROR_STRING];
int isFailure = 1;
if (!isWritePropertyHandlerRegistered)
{
if (!isWritePropertyHandlerRegistered) {
/* handle the ack coming back */
apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, My_Write_Property_SimpleAck_Handler);
apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
My_Write_Property_SimpleAck_Handler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
My_Error_Handler);
// indicate that handlers are now registered
isWritePropertyHandlerRegistered = true;
}
if (objectIndex == -1)
{
if (objectIndex == -1) {
objectIndex = BACNET_ARRAY_ALL;
}
// Loop for eary exit;
do
{
do {
// Handle the tag/value pair
uint8_t context_tag = 0;
BACNET_APPLICATION_TAG property_tag;
BACNET_APPLICATION_DATA_VALUE propertyValue;
if (toupper(tag[0]) == 'C')
{
if (toupper(tag[0]) == 'C') {
context_tag = strtol(&tag[1], NULL, 0);
propertyValue.context_tag = context_tag;
propertyValue.context_specific = true;
}
else
{
} else {
propertyValue.context_specific = false;
}
property_tag = strtol(tag, NULL, 0);
if (property_tag >= MAX_BACNET_APPLICATION_TAG)
{
sprintf(msg, "Error: tag=%u - it must be less than %u", property_tag, MAX_BACNET_APPLICATION_TAG);
if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
sprintf(msg, "Error: tag=%u - it must be less than %u",
property_tag, MAX_BACNET_APPLICATION_TAG);
LogError(msg);
break;
}
if (!bacapp_parse_application_data(property_tag, value, &propertyValue))
{
if (!bacapp_parse_application_data(property_tag, value,
&propertyValue)) {
sprintf(msg, "Error: unable to parse the tag value");
LogError(msg);
break;
}
propertyValue.next = NULL;
// Send out the message
Request_Invoke_ID = Send_Write_Property_Request(
deviceInstanceNumber,
objectType, objectInstanceNumber,
objectProperty, &propertyValue, objectPriority, objectIndex);
Request_Invoke_ID =
Send_Write_Property_Request(deviceInstanceNumber, objectType,
objectInstanceNumber, objectProperty, &propertyValue,
objectPriority, objectIndex);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
// If we get here, then there were no explicit failures. However, there
// could have been implicit failures. Let's look at those also.
isFailure = Error_Detected;
} while(false);
} while (false);
// Clean up after ourselves.
Error_Detected = false;
@@ -800,42 +778,36 @@ int BacnetWriteProperty(int deviceInstanceNumber,
}
int BacnetAtomicWriteFile (int deviceInstanceNumber,
int fileInstanceNumber,
int blockStartAddr,
int blockNumBytes,
char *nibbleBuffer)
int BacnetAtomicWriteFile(
int deviceInstanceNumber,
int fileInstanceNumber,
int blockStartAddr,
int blockNumBytes,
char *nibbleBuffer)
{
BACNET_OCTET_STRING fileData;
int i, nibble;
uint8_t byteValue;
unsigned char nibbleValue;
if (!isAtomicWriteFileHandlerRegistered)
{
if (!isAtomicWriteFileHandlerRegistered) {
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE,
My_Error_Handler);
// indicate that handlers are now registered
isAtomicWriteFileHandlerRegistered = true;
}
for (i=0; i<blockNumBytes; i++)
{
for (i = 0; i < blockNumBytes; i++) {
byteValue = 0;
for (nibble=0; nibble<2; nibble++)
{
nibbleValue = toupper(nibbleBuffer[i*2+nibble]);
if ( (nibbleValue >= '0') && (nibbleValue <= '9') )
{
byteValue += (nibbleValue-'0') << (4*(1-nibble));
}
else if ( (nibbleValue >= 'A') && (nibbleValue <= 'F') )
{
byteValue += (nibbleValue-'A'+10) << (4*(1-nibble));
}
else
{
for (nibble = 0; nibble < 2; nibble++) {
nibbleValue = toupper(nibbleBuffer[i * 2 + nibble]);
if ((nibbleValue >= '0') && (nibbleValue <= '9')) {
byteValue += (nibbleValue - '0') << (4 * (1 - nibble));
} else if ((nibbleValue >= 'A') && (nibbleValue <= 'F')) {
byteValue += (nibbleValue - 'A' + 10) << (4 * (1 - nibble));
} else {
LogError("Bad data in buffer.");
}
}
@@ -844,13 +816,10 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
octetstring_truncate(&fileData, blockNumBytes);
// Send out the message and wait for answer
if (!Error_Detected)
{
Request_Invoke_ID = Send_Atomic_Write_File_Stream(
deviceInstanceNumber,
fileInstanceNumber,
blockStartAddr,
&fileData);
if (!Error_Detected) {
Request_Invoke_ID =
Send_Atomic_Write_File_Stream(deviceInstanceNumber,
fileInstanceNumber, blockStartAddr, &fileData);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
}
@@ -859,7 +828,8 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
return isFailure;
}
int BacnetGetMaxApdu()
int BacnetGetMaxApdu(
)
{
unsigned requestedOctetCount = 0;
uint16_t my_max_apdu = 0;
@@ -887,16 +857,16 @@ int BacnetGetMaxApdu()
return requestedOctetCount;
}
int BacnetTimeSync(int deviceInstanceNumber,
int year,
int month,
int day,
int hour,
int minute,
int second,
int isUTC,
int UTCOffset)
int BacnetTimeSync(
int deviceInstanceNumber,
int year,
int month,
int day,
int hour,
int minute,
int second,
int isUTC,
int UTCOffset)
{
BACNET_DATE bdate;
BACNET_TIME btime;
@@ -908,24 +878,24 @@ int BacnetTimeSync(int deviceInstanceNumber,
my_time.tm_min = minute;
my_time.tm_hour = hour;
my_time.tm_mday = day;
my_time.tm_mon = month-1;
my_time.tm_year = year-1900;
my_time.tm_wday = 0; // does not matter
my_time.tm_yday = 0; // does not matter
my_time.tm_isdst = 0; // does not matter
my_time.tm_mon = month - 1;
my_time.tm_year = year - 1900;
my_time.tm_wday = 0; // does not matter
my_time.tm_yday = 0; // does not matter
my_time.tm_isdst = 0; // does not matter
aTime = mktime(&my_time);
newTime = localtime(&aTime);
bdate.year = newTime->tm_year;
bdate.month = newTime->tm_mon+1;
bdate.day = newTime->tm_mday;
bdate.wday = newTime->tm_wday ? newTime->tm_wday : 7;
btime.hour = newTime->tm_hour;
btime.min = newTime->tm_min;
btime.sec = newTime->tm_sec;
bdate.year = newTime->tm_year;
bdate.month = newTime->tm_mon + 1;
bdate.day = newTime->tm_mday;
bdate.wday = newTime->tm_wday ? newTime->tm_wday : 7;
btime.hour = newTime->tm_hour;
btime.min = newTime->tm_min;
btime.sec = newTime->tm_sec;
btime.hundredths = 0;
int len = 0;
int pdu_len = 0;
int bytes_sent = 0;
@@ -934,10 +904,8 @@ int BacnetTimeSync(int deviceInstanceNumber,
uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 };
// Loop for eary exit
do
{
if (!dcc_communication_enabled())
{
do {
if (!dcc_communication_enabled()) {
LogError("DCC communicaiton is not enabled");
break;
}
@@ -945,25 +913,32 @@ int BacnetTimeSync(int deviceInstanceNumber,
/* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
datalink_get_my_address(&my_address);
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &Target_Address, &my_address, &npdu_data);
pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &Target_Address,
&my_address, &npdu_data);
/* encode the APDU portion of the packet */
len = timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &bdate, &btime);
len =
timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &bdate,
&btime);
pdu_len += len;
/* send it out the datalink */
bytes_sent = datalink_send_pdu(&Target_Address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0)
{
bytes_sent =
datalink_send_pdu(&Target_Address, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0) {
char errorMsg[64];
sprintf(errorMsg, "Failed to Send Time-Synchronization Request (%s)!", strerror(errno));
sprintf(errorMsg,
"Failed to Send Time-Synchronization Request (%s)!",
strerror(errno));
LogError(errorMsg);
break;
}
Wait_For_Answer_Or_Timeout(100, waitAnswer);
} while (false);
int isFailure = Error_Detected;
Error_Detected = 0;
return isFailure;
@@ -972,26 +947,31 @@ int BacnetTimeSync(int deviceInstanceNumber,
/****************************************************/
// This is the interface to AtomicReadFile
/****************************************************/
int BacnetAtomicReadFile(int deviceInstanceNumber, int fileInstanceNumber, int startOffset, int numBytes)
int BacnetAtomicReadFile(
int deviceInstanceNumber,
int fileInstanceNumber,
int startOffset,
int numBytes)
{
if (!isAtomicReadFileHandlerRegistered)
{
if (!isAtomicReadFileHandlerRegistered) {
/* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE, AtomicReadFileAckHandler);
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
AtomicReadFileAckHandler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
My_Error_Handler);
// indicate that handlers are now registered
isAtomicReadFileHandlerRegistered = true;
}
// Send the message out
Request_Invoke_ID = Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber, startOffset, numBytes);
Request_Invoke_ID =
Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber,
startOffset, numBytes);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
int isFailure = Error_Detected;
Error_Detected = 0;
return isFailure;
}
+7 -7
View File
@@ -298,8 +298,7 @@ int main(
"%s 123 1 99 85,87[0],87\r\n"
"If you want read the PRESENT_VALUE property in objects\r\n"
"Analog Input 77 and Analog Input 78 in Device 123\r\n"
"use the following command:\r\n"
"%s 123 0 77 85 0 78 85\r\n"
"use the following command:\r\n" "%s 123 0 77 85 0 78 85\r\n"
"If you want read the ALL property in\r\n"
"Device object 123, you would use the following command:\r\n"
"%s 123 8 123 8\r\n"
@@ -308,8 +307,8 @@ int main(
"%s 123 8 123 80\r\n"
"If you want read the REQUIRED property in\r\n"
"Device object 123, you would use the following command:\r\n"
"%s 123 8 123 105\r\n",
filename, filename, filename, filename, filename);
"%s 123 8 123 105\r\n", filename, filename, filename, filename,
filename);
}
return 0;
}
@@ -356,13 +355,14 @@ int main(
property_token = strtok(argv[tag_value_arg], ",");
/* add all the properties and optional index to our list */
while (rpm_property) {
scan_count = sscanf(property_token, "%u[%u]",
&property_id,
scan_count =
sscanf(property_token, "%u[%u]", &property_id,
&property_array_index);
if (scan_count > 0) {
rpm_property->propertyIdentifier = property_id;
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
fprintf(stderr, "property=%u - it must be less than %u\r\n",
fprintf(stderr,
"property=%u - it must be less than %u\r\n",
rpm_property->propertyIdentifier,
MAX_BACNET_PROPERTY_ID + 1);
return 1;
+22 -35
View File
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <errno.h>
#include <time.h> /* for time */
#include <ctype.h> /* for toupper */
#include <ctype.h> /* for toupper */
#define PRINT_ENABLED 1
@@ -187,40 +187,30 @@ int main(
if (print_usage_terse) {
filename = filename_remove_path(argv[0]);
printf("Usage: %s device-id object-type object-instance "
"process-id <[un]confirmed lifetime|cancel>\r\n",
filename);
"process-id <[un]confirmed lifetime|cancel>\r\n", filename);
if (!print_usage_verbose) {
return 0;
}
}
if (print_usage_verbose) {
printf("\r\n"
"device-id:\r\n"
"The subscriber BACnet Device Object Instance number.\r\n"
"\r\n"
printf("\r\n" "device-id:\r\n"
"The subscriber 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"
"would be 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"
"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"
"Use the word \'confirmed\' or \'unconfirmed\'.\r\n" "\r\n"
"lifetime:\r\n"
"Optional subscription lifetime is conveyed in seconds.\r\n"
"\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"
"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"
@@ -230,8 +220,7 @@ int main(
"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",
"send the following command:\r\n" "%s 123 0 9 1 cancel\r\n",
filename, filename, filename);
return 0;
}
@@ -247,11 +236,11 @@ int main(
cov_data = COV_Subscribe_Data;
argi = 2;
while (cov_data) {
cov_data->monitoredObjectIdentifier.type =
strtol(argv[argi], NULL, 0);
cov_data->monitoredObjectIdentifier.type = strtol(argv[argi], NULL, 0);
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;
}
argi++;
@@ -264,21 +253,19 @@ int main(
return 1;
}
argi++;
cov_data->subscriberProcessIdentifier =
strtol(argv[argi], NULL, 0);
cov_data->subscriberProcessIdentifier = strtol(argv[argi], NULL, 0);
argi++;
if (strcmp(argv[argi],"cancel") == 0) {
if (strcmp(argv[argi], "cancel") == 0) {
cov_data->cancellationRequest = true;
argi++;
} else {
cov_data->cancellationRequest = false;
if (strcmp(argv[argi],"confirmed") == 0) {
if (strcmp(argv[argi], "confirmed") == 0) {
cov_data->issueConfirmedNotifications = true;
} else if (strcmp(argv[argi],"unconfirmed") == 0) {
} else if (strcmp(argv[argi], "unconfirmed") == 0) {
cov_data->issueConfirmedNotifications = false;
} else {
fprintf(stderr, "unknown option: %s\r\n",
argv[argi]);
fprintf(stderr, "unknown option: %s\r\n", argv[argi]);
return 1;
}
argi++;
@@ -342,8 +329,8 @@ int main(
if (Request_Invoke_ID == 0) {
Target_Device_Process_Identifier =
cov_data->subscriberProcessIdentifier;
Request_Invoke_ID = Send_COV_Subscribe(
Target_Device_Object_Instance,
Request_Invoke_ID =
Send_COV_Subscribe(Target_Device_Object_Instance,
cov_data);
if (!cov_data->cancellationRequest &&
(timeout_seconds < cov_data->lifetime)) {
@@ -351,7 +338,7 @@ int main(
timeout_seconds = cov_data->lifetime;
}
printf("Sent SubscribeCOV request. Waiting %u seconds.\r\n",
(unsigned)(timeout_seconds - elapsed_seconds));
(unsigned) (timeout_seconds - elapsed_seconds));
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
if (cov_data->next) {
cov_data = cov_data->next;
+1 -1
View File
@@ -128,7 +128,7 @@ static void Init_Service_Handlers(
handler_get_event_information);
apdu_set_confirmed_handler(SERVICE_CONFIRMED_GET_ALARM_SUMMARY,
handler_get_alarm_summary);
#endif /* defined(INTRINSIC_REPORTING) */
#endif /* defined(INTRINSIC_REPORTING) */
}
/** Main function of server demo.
+14 -22
View File
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <errno.h>
#include <time.h> /* for time */
#include <ctype.h> /* for toupper */
#include <ctype.h> /* for toupper */
#define PRINT_ENABLED 1
@@ -164,7 +164,7 @@ int main(
int args_remaining = 0, tag_value_arg = 0, i = 0;
BACNET_APPLICATION_TAG property_tag;
uint8_t context_tag = 0;
BACNET_PRIVATE_TRANSFER_DATA private_data = {0};
BACNET_PRIVATE_TRANSFER_DATA private_data = { 0 };
int len = 0;
bool sent_message = false;
@@ -179,34 +179,26 @@ int main(
"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"
"\r\n"
"vendor_id:\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"
"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"
"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"
"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"
"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);
@@ -222,9 +214,9 @@ int main(
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
return 1;
}
args_remaining = (argc - (6-2));
args_remaining = (argc - (6 - 2));
for (i = 0; i < MAX_PROPERTY_VALUES; i++) {
tag_value_arg = (6-2) + (i * 2);
tag_value_arg = (6 - 2) + (i * 2);
/* special case for context tagged values */
if (toupper(argv[tag_value_arg][0]) == 'C') {
context_tag = strtol(&argv[tag_value_arg][1], NULL, 0);
@@ -310,17 +302,17 @@ int main(
}
if (!sent_message) {
if (found) {
len = bacapp_encode_data(&Service_Parameters[0],
len =
bacapp_encode_data(&Service_Parameters[0],
&Target_Object_Property_Value[0]);
private_data.serviceParameters = &Service_Parameters[0];
private_data.serviceParametersLen = len;
private_data.vendorID = Target_Vendor_Identifier;
private_data.serviceNumber = Target_Service_Number;
Send_UnconfirmedPrivateTransfer(
&Target_Address,
Send_UnconfirmedPrivateTransfer(&Target_Address,
&private_data);
printf("Sent PrivateTransfer. Waiting %u seconds.\r\n",
(unsigned)(timeout_seconds - elapsed_seconds));
(unsigned) (timeout_seconds - elapsed_seconds));
sent_message = true;
} else {
if (elapsed_seconds > timeout_seconds) {
-1
View File
@@ -311,4 +311,3 @@ int main(
}
return 0;
}
+5 -5
View File
@@ -88,7 +88,7 @@ typedef struct BACnet_Access_Error {
struct BACnet_Property_Reference;
typedef struct BACnet_Property_Reference {
BACNET_PROPERTY_ID propertyIdentifier;
uint32_t propertyArrayIndex; /* optional */
uint32_t propertyArrayIndex; /* optional */
/* either value or error, but not both.
Use NULL value to indicate error */
BACNET_APPLICATION_DATA_VALUE *value;
@@ -195,10 +195,10 @@ extern "C" {
#endif
#ifdef BACAPP_SNPRINTF_ENABLED
int bacapp_snprintf_value(
char *str,
size_t str_len,
BACNET_OBJECT_PROPERTY_VALUE * object_value);
int bacapp_snprintf_value(
char *str,
size_t str_len,
BACNET_OBJECT_PROPERTY_VALUE * object_value);
#endif
#ifdef BACAPP_PRINT_ENABLED
+10 -10
View File
@@ -379,12 +379,12 @@ typedef enum {
PROP_COVU_PERIOD = 349,
PROP_COVU_RECIPIENTS = 350,
PROP_EVENT_MESSAGE_TEXTS = 351,
/* The special property identifiers all, optional, and required */
/* are reserved for use in the ReadPropertyConditional and */
/* ReadPropertyMultiple services or services not defined in this standard. */
/* Enumerated values 0-511 are reserved for definition by ASHRAE. */
/* Enumerated values 512-4194303 may be used by others subject to the */
/* procedures and constraints described in Clause 23. */
/* The special property identifiers all, optional, and required */
/* are reserved for use in the ReadPropertyConditional and */
/* ReadPropertyMultiple services or services not defined in this standard. */
/* Enumerated values 0-511 are reserved for definition by ASHRAE. */
/* Enumerated values 512-4194303 may be used by others subject to the */
/* procedures and constraints described in Clause 23. */
/* enumerations used to test Addendum i to ANSI/ASHRAE 135-2008 - private */
PROP_BLINK_PRIORITY_THRESHOLD = 4201,
PROP_BLINK_TIME = 4202,
@@ -1398,10 +1398,10 @@ typedef enum {
ERROR_CODE_BUSY = 82,
ERROR_CODE_COMMUNICATION_DISABLED = 83,
MAX_BACNET_ERROR_CODE = 84
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */
/* Enumerated values 256-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */
/* The last enumeration used in this version is 50. */
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */
/* Enumerated values 256-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */
/* The last enumeration used in this version is 50. */
} BACNET_ERROR_CODE;
#define FIRST_PROPRIETARY_ERROR_CODE 256
#define LAST_PROPRIETARY_ERROR_CODE 65535
+1 -1
View File
@@ -160,7 +160,7 @@ extern "C" {
returns true if successfully converted and fits; false if too long */
bool octetstring_init_ascii_hex(
BACNET_OCTET_STRING * octet_string,
const char * ascii_hex);
const char *ascii_hex);
#endif
bool octetstring_copy(
BACNET_OCTET_STRING * dest,
+8 -6
View File
@@ -83,24 +83,26 @@ extern "C" {
uint16_t bbmd_port, /* in network byte order */
uint16_t time_to_live_seconds);
struct sockaddr_in; /* Defined elsewhere, needed here. */
struct sockaddr_in; /* Defined elsewhere, needed here. */
/* Note any BVLC_RESULT code, or NAK the BVLL message in the unsupported cases. */
int bvlc_for_non_bbmd(
struct sockaddr_in * sout,
uint8_t * npdu,
uint16_t received_bytes);
struct sockaddr_in *sout,
uint8_t * npdu,
uint16_t received_bytes);
/* Returns the last BVLL Result we received, either as the result of a BBMD
* request we sent, or (if not a BBMD or Client), from trying to register
* as a foreign device. */
BACNET_BVLC_RESULT bvlc_get_last_result(void);
BACNET_BVLC_RESULT bvlc_get_last_result(
void);
/* Returns the current BVLL Function Code we are processing.
* We have to store this higher layer code for when the lower layers
* need to know what it is, especially to differentiate between
* BVLC_ORIGINAL_UNICAST_NPDU and BVLC_ORIGINAL_BROADCAST_NPDU. */
BACNET_BVLC_FUNCTION bvlc_get_function_code(void);
BACNET_BVLC_FUNCTION bvlc_get_function_code(
void);
#ifdef __cplusplus
}
+53 -53
View File
@@ -179,70 +179,70 @@
**/
#ifdef TEST
#define BACNET_SVC_I_HAVE_A 1
#define BACNET_SVC_WP_A 1
#define BACNET_SVC_RP_A 1
#define BACNET_SVC_RPM_A 1
#define BACNET_SVC_DCC_A 1
#define BACNET_SVC_RD_A 1
#define BACNET_SVC_TS_A 1
#define BACNET_SVC_SERVER 0
#define BACNET_USE_OCTETSTRING 1
#define BACNET_USE_DOUBLE 1
#define BACNET_USE_SIGNED 1
#else /* Otherwise define our working set - all enabled here to avoid breaking things */
#define BACNET_SVC_I_HAVE_A 1
#define BACNET_SVC_WP_A 1
#define BACNET_SVC_RP_A 1
#define BACNET_SVC_RPM_A 1
#define BACNET_SVC_DCC_A 1
#define BACNET_SVC_RD_A 1
#define BACNET_SVC_TS_A 1
#define BACNET_SVC_SERVER 0
#define BACNET_USE_OCTETSTRING 1
#define BACNET_USE_DOUBLE 1
#define BACNET_USE_SIGNED 1
#define BACNET_SVC_I_HAVE_A 1
#define BACNET_SVC_WP_A 1
#define BACNET_SVC_RP_A 1
#define BACNET_SVC_RPM_A 1
#define BACNET_SVC_DCC_A 1
#define BACNET_SVC_RD_A 1
#define BACNET_SVC_TS_A 1
#define BACNET_SVC_SERVER 0
#define BACNET_USE_OCTETSTRING 1
#define BACNET_USE_DOUBLE 1
#define BACNET_USE_SIGNED 1
#else /* Otherwise define our working set - all enabled here to avoid breaking things */
#define BACNET_SVC_I_HAVE_A 1
#define BACNET_SVC_WP_A 1
#define BACNET_SVC_RP_A 1
#define BACNET_SVC_RPM_A 1
#define BACNET_SVC_DCC_A 1
#define BACNET_SVC_RD_A 1
#define BACNET_SVC_TS_A 1
#define BACNET_SVC_SERVER 0
#define BACNET_USE_OCTETSTRING 1
#define BACNET_USE_DOUBLE 1
#define BACNET_USE_SIGNED 1
#endif
/* Do them one by one */
#ifndef BACNET_SVC_I_HAVE_A /* Do we send I_Have requests? */
#define BACNET_SVC_I_HAVE_A 0
#endif
#ifndef BACNET_SVC_I_HAVE_A /* Do we send I_Have requests? */
#define BACNET_SVC_I_HAVE_A 0
#endif
#ifndef BACNET_SVC_WP_A /* Do we send WriteProperty requests? */
#define BACNET_SVC_WP_A 0
#endif
#ifndef BACNET_SVC_WP_A /* Do we send WriteProperty requests? */
#define BACNET_SVC_WP_A 0
#endif
#ifndef BACNET_SVC_RP_A /* Do we send ReadProperty requests? */
#define BACNET_SVC_RP_A 0
#endif
#ifndef BACNET_SVC_RP_A /* Do we send ReadProperty requests? */
#define BACNET_SVC_RP_A 0
#endif
#ifndef BACNET_SVC_RPM_A /* Do we send ReadPropertyMultiple requests? */
#define BACNET_SVC_RPM_A 0
#endif
#ifndef BACNET_SVC_RPM_A /* Do we send ReadPropertyMultiple requests? */
#define BACNET_SVC_RPM_A 0
#endif
#ifndef BACNET_SVC_DCC_A /* Do we send DeviceCommunicationControl requests? */
#define BACNET_SVC_DCC_A 0
#endif
#ifndef BACNET_SVC_DCC_A /* Do we send DeviceCommunicationControl requests? */
#define BACNET_SVC_DCC_A 0
#endif
#ifndef BACNET_SVC_RD_A /* Do we send ReinitialiseDevice requests? */
#define BACNET_SVC_RD_A 0
#endif
#ifndef BACNET_SVC_RD_A /* Do we send ReinitialiseDevice requests? */
#define BACNET_SVC_RD_A 0
#endif
#ifndef BACNET_SVC_SERVER /* Are we a pure server type device? */
#define BACNET_SVC_SERVER 1
#endif
#ifndef BACNET_SVC_SERVER /* Are we a pure server type device? */
#define BACNET_SVC_SERVER 1
#endif
#ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */
#define BACNET_USE_OCTETSTRING 0
#endif
#ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */
#define BACNET_USE_OCTETSTRING 0
#endif
#ifndef BACNET_USE_DOUBLE /* Do we need any doubles? */
#define BACNET_USE_DOUBLE 0
#endif
#ifndef BACNET_USE_DOUBLE /* Do we need any doubles? */
#define BACNET_USE_DOUBLE 0
#endif
#ifndef BACNET_USE_SIGNED /* Do we need any signed integers */
#define BACNET_USE_SIGNED 0
#endif
#ifndef BACNET_USE_SIGNED /* Do we need any signed integers */
#define BACNET_USE_SIGNED 0
#endif
#endif
+2 -2
View File
@@ -73,7 +73,7 @@
#define datalink_get_broadcast_address bip_get_broadcast_address
#ifdef BAC_ROUTING
extern void routed_get_my_address(
BACNET_ADDRESS * my_address);
BACNET_ADDRESS * my_address);
#define datalink_get_my_address routed_get_my_address
#else
#define datalink_get_my_address bip_get_my_address
@@ -135,7 +135,7 @@ extern "C" {
* chosen at runtime from among these choices.
* - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN
* are not currently supported by this project.
*//** @defgroup DLTemplates DataLink Template Functions
*//** @defgroup DLTemplates DataLink Template Functions
* @ingroup DataLink
* Most of the functions in this group are function templates which are assigned
* to a specific DataLink network layer implementation either at compile time or
+2 -2
View File
@@ -94,7 +94,7 @@ extern "C" {
*
* The network management BIBBs prescribe the BACnet capabilities required to
* interoperably perform network management functions.
*//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC)
*//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC)
* @ingroup RDMS
* 16.1 DeviceCommunicationControl Service <br>
* The DeviceCommunicationControl service is used by a client BACnet-user to
@@ -107,7 +107,7 @@ extern "C" {
* "indefinite," meaning communication must be re-enabled by a
* DeviceCommunicationControl or, if supported, ReinitializeDevice service,
* not by time.
*//** @defgroup NMRC Network Management-Router Configuration (NM-RC)
*//** @defgroup NMRC Network Management-Router Configuration (NM-RC)
* @ingroup RDMS
* The A device may query and change the configuration of routers and
* half-routers.
+10 -6
View File
@@ -35,13 +35,17 @@ extern "C" {
void);
void dlenv_maintenance_timer(
uint16_t elapsed_seconds);
/* Simple setters and getter. */
void dlenv_bbmd_address_set( long address );
void dlenv_bbmd_port_set( int port );
void dlenv_bbmd_ttl_set( int ttl_secs );
int dlenv_bbmd_result( void );
void dlenv_bbmd_address_set(
long address);
void dlenv_bbmd_port_set(
int port);
void dlenv_bbmd_ttl_set(
int ttl_secs);
int dlenv_bbmd_result(
void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
+2 -2
View File
@@ -202,7 +202,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the alarm and event management functions enumerated in 22.2.1.2
* for the BACnet devices defined therein.
*//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N)
*//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N)
* @ingroup ALMEVNT
* 13.6 ConfirmedCOVNotification Service <br>
* The ConfirmedCOVNotification service is used to notify subscribers about
@@ -219,7 +219,7 @@ extern "C" {
* For unsubscribed notifications, the algorithm for determining when to issue
* this service is a local matter and may be based on a change of value,
* periodic updating, or some other criteria.
*//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK)
*//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK)
* @ingroup ALMEVNT
* 13.5 AcknowledgeAlarm Service <br>
* In some systems a device may need to know that an operator has seen the alarm
+1 -1
View File
@@ -51,7 +51,7 @@ extern "C" {
bool FIFO_Full(
FIFO_BUFFER const *b);
bool FIFO_Available (
bool FIFO_Available(
FIFO_BUFFER const *b,
unsigned count);
+2 -1
View File
@@ -215,7 +215,8 @@ extern "C" {
uint16_t service_len,
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data);
void handler_cov_task(void);
void handler_cov_task(
void);
void handler_cov_timer_seconds(
uint32_t elapsed_seconds);
void handler_cov_init(
+1 -1
View File
@@ -178,7 +178,7 @@ extern "C" {
volatile struct mstp_port_struct_t
*mstp_port);
void MSTP_Slave_Node_FSM(
volatile struct mstp_port_struct_t * mstp_port);
volatile struct mstp_port_struct_t *mstp_port);
/* returns true if line is active */
bool MSTP_Line_Active(
+5 -5
View File
@@ -37,11 +37,11 @@
extern "C" {
#endif /* __cplusplus */
unsigned property_list_count(
const int *pList);
void property_list_special(
BACNET_OBJECT_TYPE object_type,
struct special_property_list_t *pPropertyList);
unsigned property_list_count(
const int *pList);
void property_list_special(
BACNET_OBJECT_TYPE object_type,
struct special_property_list_t *pPropertyList);
#ifdef __cplusplus
}
+1 -1
View File
@@ -162,7 +162,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the trending functions enumerated in clause 22.2.1.4 for the
* BACnet devices defined therein.
*//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT)
*//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT)
* @ingroup Trend
* 15.8 ReadRange Service <br>
* The ReadRange service is used by a client BACnet-user to read a specific
+8 -8
View File
@@ -31,11 +31,11 @@
#include <stdbool.h>
struct ring_buffer_t {
volatile uint8_t * buffer; /* block of memory or array of data */
volatile uint8_t *buffer; /* block of memory or array of data */
unsigned element_size; /* how many bytes for each chunk */
unsigned element_count; /* number of chunks of data */
volatile unsigned head; /* where the writes go */
volatile unsigned tail; /* where the reads come from */
volatile unsigned head; /* where the writes go */
volatile unsigned tail; /* where the reads come from */
};
typedef struct ring_buffer_t RING_BUFFER;
@@ -43,9 +43,9 @@ typedef struct ring_buffer_t RING_BUFFER;
extern "C" {
#endif /* __cplusplus */
unsigned Ringbuf_Count (
unsigned Ringbuf_Count(
RING_BUFFER const *b);
bool Ringbuf_Full (
bool Ringbuf_Full(
RING_BUFFER const *b);
bool Ringbuf_Empty(
RING_BUFFER const *b);
@@ -55,13 +55,13 @@ extern "C" {
RING_BUFFER * b);
bool Ringbuf_Put(
RING_BUFFER * b, /* ring buffer structure */
volatile uint8_t *data_element); /* one element to add to the ring */
volatile uint8_t * data_element); /* one element to add to the ring */
volatile uint8_t *Ringbuf_Alloc(
RING_BUFFER *b);
RING_BUFFER * b);
/* Note: element_count must be a power of two */
void Ringbuf_Init(
RING_BUFFER * b, /* ring buffer structure */
volatile uint8_t * buffer, /* data block or array of data */
volatile uint8_t * buffer, /* data block or array of data */
unsigned element_size, /* size of one element in the data block */
unsigned element_count); /* number of elements in the data block */
+1 -1
View File
@@ -125,7 +125,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the data sharing functions enumerated in 22.2.1.1 for the BACnet
* devices defined therein.
*//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
*//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
* @ingroup DataShare
* 15.5 ReadProperty Service <br>
* The ReadProperty service is used by a client BACnet-user to request the
+1 -1
View File
@@ -37,7 +37,7 @@ typedef struct BACnet_Write_Property_Data {
BACNET_OBJECT_TYPE object_type;
uint32_t object_instance;
BACNET_PROPERTY_ID object_property;
uint32_t array_index; /* use BACNET_ARRAY_ALL when not setting */
uint32_t array_index; /* use BACNET_ARRAY_ALL when not setting */
uint8_t application_data[MAX_APDU];
int application_data_len;
uint8_t priority; /* use BACNET_NO_PRIORITY if no priority */
+7 -4
View File
@@ -49,13 +49,16 @@ extern "C" {
/* encode objects */
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id);
int wpm_encode_apdu_object_begin (
int wpm_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id);
int wpm_encode_apdu_object_begin(
uint8_t * apdu,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance);
int wpm_encode_apdu_object_end (uint8_t * apdu);
int wpm_encode_apdu_object_property (
int wpm_encode_apdu_object_end(
uint8_t * apdu);
int wpm_encode_apdu_object_property(
uint8_t * apdu,
BACNET_WRITE_PROPERTY_DATA * wpdata);
+2 -2
View File
@@ -360,8 +360,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index
(wp_data->object_instance);
Analog_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -271,8 +271,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+11 -11
View File
@@ -193,10 +193,10 @@ static int Read_Property_Common(
apdu_len = BACNET_STATUS_ERROR;
} else {
characterstring_init_ansi(&char_string, "");
if (pObject->Object_Name) {
(void) pObject->Object_Name(rpdata->object_instance,
&char_string);
}
if (pObject->Object_Name) {
(void) pObject->Object_Name(rpdata->object_instance,
&char_string);
}
apdu_len =
encode_application_character_string(&apdu[0],
&char_string);
@@ -615,7 +615,7 @@ bool Device_Valid_Object_Id(
}
bool Device_Object_Name_Copy(
BACNET_OBJECT_TYPE object_type,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name)
{
@@ -850,8 +850,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -903,13 +903,13 @@ bool Device_Write_Property_Local(
characterstring_encoding(&value.type.Character_String);
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
/* All the object names in a device must be unique. */
if (Device_Valid_Object_Name(&value.type.
Character_String, NULL, NULL)) {
if (Device_Valid_Object_Name(&value.
type.Character_String, NULL, NULL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else {
Device_Set_Object_Name(&value.type.
Character_String);
Device_Set_Object_Name(&value.
type.Character_String);
status = true;
}
} else {
+1 -2
View File
@@ -1119,8 +1119,7 @@ static bool MSTP_Master_Node_FSM(
Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false;
} else if ((Timer_Silence() > Treply_delay) ||
(pkt != NULL)) {
} else if ((Timer_Silence() > Treply_delay) || (pkt != NULL)) {
/* DeferredReply */
/* If no reply will be available from the higher layers */
/* within Treply_delay after the reception of the */
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+2 -2
View File
@@ -380,8 +380,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+1 -1
View File
@@ -49,7 +49,7 @@ static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
void Device_Init(
object_functions_t * object_table)
{
(void)object_table;
(void) object_table;
/* Reinitialize_State = BACNET_REINIT_IDLE; */
/* dcc_set_status_duration(COMMUNICATION_ENABLE, 0); */
/* FIXME: Get the data from the eeprom */
+9 -14
View File
@@ -60,22 +60,17 @@ bool bacnet_name_save(
char *str,
uint8_t length)
{
uint8_t buffer[NV_EEPROM_NAME_SIZE] = {0};
uint8_t buffer[NV_EEPROM_NAME_SIZE] = { 0 };
uint8_t i = 0;
if (bacnet_name_isvalid(encoding, length, str)) {
eeprom_bytes_write(
NV_EEPROM_NAME_LENGTH(offset),
&length, 1);
eeprom_bytes_write(
NV_EEPROM_NAME_ENCODING(offset),
(uint8_t *)&encoding, 1);
eeprom_bytes_write(NV_EEPROM_NAME_LENGTH(offset), &length, 1);
eeprom_bytes_write(NV_EEPROM_NAME_ENCODING(offset),
(uint8_t *) & encoding, 1);
for (i = 0; i < length; i++) {
buffer[i] = str[i];
}
eeprom_bytes_write(
NV_EEPROM_NAME_STRING(offset),
&buffer[0],
eeprom_bytes_write(NV_EEPROM_NAME_STRING(offset), &buffer[0],
NV_EEPROM_NAME_SIZE);
return true;
}
@@ -118,8 +113,8 @@ bool bacnet_name_write_unique(
} else if (length <= NV_EEPROM_NAME_SIZE) {
encoding = characterstring_encoding(char_string);
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
if (Device_Valid_Object_Name(char_string,
&duplicate_type, &duplicate_instance)) {
if (Device_Valid_Object_Name(char_string, &duplicate_type,
&duplicate_instance)) {
if ((duplicate_type == object_type) &&
(duplicate_instance == object_instance)) {
/* writing same name to same object */
@@ -185,8 +180,8 @@ void bacnet_name_init(
uint16_t offset,
char *default_string)
{
(void)bacnet_name_save(offset, CHARACTER_UTF8,
default_string, strlen(default_string));
(void) bacnet_name_save(offset, CHARACTER_UTF8, default_string,
strlen(default_string));
}
void bacnet_name(
+2 -2
View File
@@ -439,8 +439,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
Binary_Output_Present_Value_Set
(wp_data->object_instance, level, priority);
Binary_Output_Present_Value_Set(wp_data->
object_instance, level, priority);
} else if (priority == 6) {
status = false;
/* Command priority 6 is reserved for use by Minimum On/Off
+11 -13
View File
@@ -160,7 +160,7 @@ static int Read_Property_Common(
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = BACNET_STATUS_ERROR;
BACNET_CHARACTER_STRING char_string = {0};
BACNET_CHARACTER_STRING char_string = { 0 };
uint8_t *apdu = NULL;
if ((rpdata->application_data == NULL) ||
@@ -579,7 +579,7 @@ bool Device_Valid_Object_Name(
for (i = 0; i < max_objects; i++) {
check_id = Device_Object_List_Identifier(i, &type, &instance);
if (check_id) {
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)type);
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
@@ -605,7 +605,7 @@ bool Device_Valid_Object_Id(
bool status = false; /* return value */
struct my_object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)object_type);
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) object_type);
if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
status = pObject->Object_Valid_Instance(object_instance);
}
@@ -614,7 +614,7 @@ bool Device_Valid_Object_Id(
}
bool Device_Object_Name_Copy(
BACNET_OBJECT_TYPE object_type,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name)
{
@@ -650,7 +650,7 @@ int Device_Read_Property_Local(
}
apdu = rpdata->application_data;
switch (rpdata->object_property) {
/* object name, object id, object type are handled in Device object */
/* object name, object id, object type are handled in Device object */
case PROP_DESCRIPTION:
bacnet_name(NV_EEPROM_DEVICE_DESCRIPTION, &char_string,
"BACnet Development Kit");
@@ -856,8 +856,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
(uint8_t *) & value.type.Object_Id.instance, 4);
/* we could send an I-Am broadcast to let the world know */
@@ -902,12 +902,10 @@ bool Device_Write_Property_Local(
break;
case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = bacnet_name_write_unique(
NV_EEPROM_DEVICE_NAME,
value.type.Object_Id.type,
value.type.Object_Id.instance,
&value.type.Character_String,
&wp_data->error_class,
status =
bacnet_name_write_unique(NV_EEPROM_DEVICE_NAME,
value.type.Object_Id.type, value.type.Object_Id.instance,
&value.type.Character_String, &wp_data->error_class,
&wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+1 -1
View File
@@ -372,7 +372,7 @@ static void MSTP_Send_Frame(
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
uint16_t crc16 = 0xFFFF; /* used to calculate the crc value */
uint8_t buffer[8]; /* stores the header and header crc */
uint8_t buffer_crc[2]; /* stores the data crc */
uint8_t buffer_crc[2]; /* stores the data crc */
uint16_t i = 0; /* used to calculate CRC for data */
/* create the MS/TP header */
+5 -2
View File
@@ -273,8 +273,11 @@ typedef struct {
#endif
#elif defined (__CROSSWORKS_AVR)
/* use functions defined in crt0.s to mimic IAR macros */
void __uint8_eeprom_store(unsigned char byte, unsigned addr);
unsigned char __uint8_eeprom_load(unsigned addr);
void __uint8_eeprom_store(
unsigned char byte,
unsigned addr);
unsigned char __uint8_eeprom_load(
unsigned addr);
#define __EEPUT(addr, var) \
__uint8_eeprom_store((unsigned char)(var), (unsigned)(addr))
#define __EEGET(var, addr) \
+1 -1
View File
@@ -218,7 +218,7 @@ int seeprom_bytes_read(
the slave, or it can leave the SDA line high (NACK), indicating to
the slave that it is going to stop the transfer now.
Assertion of ACK is handled by setting the TWEA bit in TWCR when
starting the current transfer.*/
starting the current transfer. */
/* Next cycle(s): master receiver mode */
/* send repeated start condition */
TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);
+7 -4
View File
@@ -163,19 +163,22 @@ void test_task(
rs485_baud_rate_set(9600);
break;
case 'e':
seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) &id, 2);
seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2);
sprintf(Send_Buffer, "\r\n%04X", id);
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break;
case 'b':
sprintf(Send_Buffer, "\r\n%lubps",
(unsigned long) rs485_baud_rate());
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break;
case 'm':
sprintf(Send_Buffer, "\r\nMax:%u",
(unsigned) dlmstp_max_master());
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break;
default:
break;
+22 -45
View File
@@ -242,7 +242,7 @@ static void *dlmstp_master_fsm_task(
}
if (run_master) {
if (MSTP_Port.This_Station <= DEFAULT_MAX_MASTER) {
while (MSTP_Master_Node_FSM (&MSTP_Port)) {
while (MSTP_Master_Node_FSM(&MSTP_Port)) {
/* do nothing while immediate transitioning */
}
} else if (MSTP_Port.This_Station < 255) {
@@ -323,14 +323,9 @@ uint16_t MSTP_Get_Send(
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
/* convert the PDU into the MSTP Frame */
pdu_len = MSTP_Create_Frame(
&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize,
frame_type,
pkt->destination_mac,
mstp_port->This_Station,
(uint8_t *) & pkt->buffer[0],
pkt->length);
pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize, frame_type, pkt->destination_mac,
mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length);
return pdu_len;
}
@@ -369,8 +364,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.network_layer_message) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Request is Network message.\n");
"DLMSTP: DER Compare failed: " "Request is Network message.\n");
#endif
return false;
}
@@ -378,8 +372,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.pdu_type != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Not Confirmed Request.\n");
"DLMSTP: DER Compare failed: " "Not Confirmed Request.\n");
#endif
return false;
}
@@ -398,8 +391,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (reply.npdu_data.network_layer_message) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Reply is Network message.\n");
"DLMSTP: DER Compare failed: " "Reply is Network message.\n");
#endif
return false;
}
@@ -445,26 +437,23 @@ static bool dlmstp_compare_data_expecting_reply(
(reply.pdu_type == PDU_TYPE_ABORT)) {
if (request.invoke_id != reply.invoke_id) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Invoke ID mismatch.\n");
fprintf(stderr,
"DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n");
#endif
return false;
}
} else {
if (request.invoke_id != reply.invoke_id) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Invoke ID mismatch.\n");
fprintf(stderr,
"DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n");
#endif
return false;
}
if (request.service_choice != reply.service_choice) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Service choice mismatch.\n");
fprintf(stderr,
"DLMSTP: DER Compare failed: " "Service choice mismatch.\n");
#endif
return false;
}
@@ -480,16 +469,14 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.priority != reply.npdu_data.priority) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"NPDU Priority mismatch.\n");
"DLMSTP: DER Compare failed: " "NPDU Priority mismatch.\n");
#endif
return false;
}
if (!bacnet_address_same(&request.address, &reply.address)) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"BACnet Address mismatch.\n");
"DLMSTP: DER Compare failed: " "BACnet Address mismatch.\n");
#endif
return false;
}
@@ -514,13 +501,9 @@ uint16_t MSTP_Get_Reply(
pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue);
/* is this the reply to the DER? */
matched =
dlmstp_compare_data_expecting_reply(
&mstp_port->InputBuffer[0],
mstp_port->DataLength,
mstp_port->SourceAddress,
(uint8_t *) & pkt->buffer[0],
pkt->length,
pkt->destination_mac);
dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0],
mstp_port->DataLength, mstp_port->SourceAddress,
(uint8_t *) & pkt->buffer[0], pkt->length, pkt->destination_mac);
if (!matched) {
return 0;
}
@@ -531,14 +514,9 @@ uint16_t MSTP_Get_Reply(
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
/* convert the PDU into the MSTP Frame */
pdu_len = MSTP_Create_Frame(
&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize,
frame_type,
pkt->destination_mac,
mstp_port->This_Station,
(uint8_t *) & pkt->buffer[0],
pkt->length);
pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize, frame_type, pkt->destination_mac,
mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length);
return pdu_len;
}
@@ -678,8 +656,7 @@ bool dlmstp_init(
/* initialize PDU queue */
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
sizeof(struct mstp_pdu_packet),
MSTP_PDU_PACKET_COUNT);
sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT);
/* initialize packet queue */
Receive_Packet.ready = false;
Receive_Packet.pdu_len = 0;
+2 -2
View File
@@ -83,7 +83,7 @@ static void Timer_Silence_Reset(
/* functions used by the MS/TP state machine to put or get data */
uint16_t MSTP_Put_Receive(
volatile struct mstp_port_struct_t * mstp_port)
volatile struct mstp_port_struct_t *mstp_port)
{
(void) mstp_port;
@@ -203,7 +203,7 @@ static void snap_received_packet(
}
/* Ethernet length is data only - not address or length bytes */
encode_unsigned16(&mtu[12], mtu_len - 14);
(void)write(sockfd, &mtu[0], mtu_len);
(void) write(sockfd, &mtu[0], mtu_len);
}
+6 -6
View File
@@ -153,7 +153,7 @@ uint32_t RS485_Get_Baud_Rate(
baud = 200;
break;
case B300:
baud =300;
baud = 300;
break;
case B600:
baud = 600;
@@ -288,13 +288,13 @@ void RS485_Send_Frame(
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
uint32_t turnaround_time = Tturnaround * 1000;
uint32_t baud = RS485_Get_Baud_Rate ();
uint32_t baud = RS485_Get_Baud_Rate();
ssize_t written = 0;
int greska;
/* sleeping for turnaround time is necessary to give other devices
time to change from sending to receiving state. */
usleep(turnaround_time/baud);
usleep(turnaround_time / baud);
/*
On success, the number of bytes written are returned (zero indicates
nothing was written). On error, -1 is returned, and errno is set
@@ -354,9 +354,9 @@ void RS485_Check_UART_Data(
}
}
/* grab bytes and stuff them into the FIFO every time */
FD_ZERO (&input);
FD_SET (RS485_Handle, &input);
n = select (RS485_Handle + 1, &input, NULL, NULL, &waiter);
FD_ZERO(&input);
FD_SET(RS485_Handle, &input);
n = select(RS485_Handle + 1, &input, NULL, NULL, &waiter);
if (n < 0) {
return;
}
+2 -2
View File
@@ -325,8 +325,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index
(wp_data->object_instance);
Analog_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -237,8 +237,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+2 -2
View File
@@ -533,8 +533,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+3 -7
View File
@@ -115,13 +115,9 @@ int dlmstp_send_pdu(
return -4;
}
bytes_sent =
MSTP_Create_Frame(
(uint8_t *) & MSTP_Port.TxBuffer[0],
sizeof(MSTP_Port.TxBuffer),
MSTP_Port.TxFrameType,
MSTP_Port.TxDestination,
MSTP_Port.This_Station,
pdu, pdu_len);
MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0],
sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType,
MSTP_Port.TxDestination, MSTP_Port.This_Station, pdu, pdu_len);
MSTP_Port.TxLength = bytes_sent;
MSTP_Port.TxReady = true;
MSTP_Packets++;
+5 -9
View File
@@ -1145,13 +1145,10 @@ bool MSTP_Master_Node_FSM(
see if the message is that same APDU type
along with the matching src/dest and invoke ID */
matched =
mstp_compare_data_expecting_reply(
&mstp_port->InputBuffer[0],
mstp_port->DataLength,
mstp_port->SourceAddress,
&mstp_port->TxBuffer[0],
mstp_port->TxLength,
mstp_port->TxDestination);
mstp_compare_data_expecting_reply(&mstp_port->
InputBuffer[0], mstp_port->DataLength,
mstp_port->SourceAddress, &mstp_port->TxBuffer[0],
mstp_port->TxLength, mstp_port->TxDestination);
}
if (matched && mstp_port->TxReady) {
/* Reply */
@@ -1162,8 +1159,7 @@ bool MSTP_Master_Node_FSM(
/* then call MSTP_Create_And_Send_Frame to transmit the reply frame */
/* and enter the IDLE state to wait for the next frame. */
RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->TxBuffer[0],
mstp_port->TxLength);
(uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength);
mstp_port->TxReady = false;
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
} else {

Some files were not shown because too many files have changed in this diff Show More