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

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