Indented using indent script.
This commit is contained in:
+124
-179
@@ -132,7 +132,8 @@ static void MyErrorHandler(
|
|||||||
(void) src;
|
(void) src;
|
||||||
(void) invoke_id;
|
(void) invoke_id;
|
||||||
#if PRINT_ERRORS
|
#if PRINT_ERRORS
|
||||||
printf("-- BACnet Error: %s: %s\r\n", bactext_error_class_name(error_class),
|
printf("-- BACnet Error: %s: %s\r\n",
|
||||||
|
bactext_error_class_name(error_class),
|
||||||
bactext_error_code_name(error_code));
|
bactext_error_code_name(error_code));
|
||||||
#else
|
#else
|
||||||
(void) error_class;
|
(void) error_class;
|
||||||
@@ -154,7 +155,8 @@ void MyAbortHandler(
|
|||||||
#if PRINT_ERRORS
|
#if PRINT_ERRORS
|
||||||
/* It is normal for this to fail, so don't print. */
|
/* It is normal for this to fail, so don't print. */
|
||||||
if ((myState != GET_ALL_RESPONSE) && !IsLongArray)
|
if ((myState != GET_ALL_RESPONSE) && !IsLongArray)
|
||||||
printf("-- BACnet Abort: %s ", bactext_abort_reason_name(abort_reason));
|
printf("-- BACnet Abort: %s ",
|
||||||
|
bactext_abort_reason_name(abort_reason));
|
||||||
#else
|
#else
|
||||||
(void) abort_reason;
|
(void) abort_reason;
|
||||||
#endif
|
#endif
|
||||||
@@ -198,9 +200,7 @@ void MyReadPropertyAckHandler(
|
|||||||
sizeof(BACNET_CONFIRMED_SERVICE_ACK_DATA));
|
sizeof(BACNET_CONFIRMED_SERVICE_ACK_DATA));
|
||||||
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);
|
||||||
@@ -229,9 +229,7 @@ void MyReadPropertyMultipleAckHandler(
|
|||||||
Read_Property_Multiple_Data.rpm_data = rpm_data;
|
Read_Property_Multiple_Data.rpm_data = rpm_data;
|
||||||
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);
|
||||||
@@ -289,40 +287,35 @@ static void Init_Service_Handlers(
|
|||||||
|
|
||||||
if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) &&
|
if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) &&
|
||||||
((property == PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED) ||
|
((property == PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED) ||
|
||||||
(property == PROP_PROTOCOL_SERVICES_SUPPORTED) ) )
|
(property == PROP_PROTOCOL_SERVICES_SUPPORTED))) {
|
||||||
{
|
|
||||||
len = bitstring_bits_used(&value->type.Bit_String);
|
len = bitstring_bits_used(&value->type.Bit_String);
|
||||||
fprintf(stream, "( \r\n ");
|
fprintf(stream, "( \r\n ");
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s", bitstring_bit(&value->type.Bit_String,
|
||||||
bitstring_bit(&value->type.Bit_String,
|
|
||||||
(uint8_t) i) ? "T" : "F");
|
(uint8_t) i) ? "T" : "F");
|
||||||
if (i < len - 1)
|
if (i < len - 1)
|
||||||
fprintf(stream, ",");
|
fprintf(stream, ",");
|
||||||
else
|
else
|
||||||
fprintf(stream, " ");
|
fprintf(stream, " ");
|
||||||
/* Tried with 8 per line, but with the comments, got way too long. */
|
/* Tried with 8 per line, but with the comments, got way too long. */
|
||||||
if ( (i == (len-1) ) || ( (i % 4) == 3 ) ) /* line break every 4 */
|
if ((i == (len - 1)) || ((i % 4) == 3)) { /* line break every 4 */
|
||||||
{
|
|
||||||
fprintf(stream, " -- "); /* EPICS comments begin with "--" */
|
fprintf(stream, " -- "); /* EPICS comments begin with "--" */
|
||||||
/* Now rerun the same 4 bits, but print labels for true ones */
|
/* Now rerun the same 4 bits, but print labels for true ones */
|
||||||
for ( j = i - (i%4); j <= i; j++)
|
for (j = i - (i % 4); j <= i; j++) {
|
||||||
{
|
if (bitstring_bit(&value->type.Bit_String, (uint8_t) j)) {
|
||||||
if ( bitstring_bit(&value->type.Bit_String, (uint8_t) j) )
|
|
||||||
{
|
|
||||||
if (property == PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED)
|
if (property == PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED)
|
||||||
fprintf( stream, " %s,", bactext_object_type_name(j) );
|
fprintf(stream, " %s,",
|
||||||
|
bactext_object_type_name(j));
|
||||||
/* PROP_PROTOCOL_SERVICES_SUPPORTED */
|
/* PROP_PROTOCOL_SERVICES_SUPPORTED */
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
bool bIsConfirmed;
|
bool bIsConfirmed;
|
||||||
size_t newIndex;
|
size_t newIndex;
|
||||||
if ( apdu_service_supported_to_index( j,
|
if (apdu_service_supported_to_index(j, &newIndex,
|
||||||
&newIndex, &bIsConfirmed ) )
|
&bIsConfirmed)) {
|
||||||
{
|
|
||||||
if (bIsConfirmed)
|
if (bIsConfirmed)
|
||||||
fprintf(stream, " %s,",
|
fprintf(stream, " %s,",
|
||||||
bactext_confirmed_service_name(newIndex) );
|
bactext_confirmed_service_name
|
||||||
|
(newIndex));
|
||||||
|
|
||||||
else
|
else
|
||||||
fprintf(stream, " %s,",
|
fprintf(stream, " %s,",
|
||||||
@@ -331,22 +324,18 @@ static void Init_Service_Handlers(
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else /* not supported */
|
||||||
else /* not supported */
|
|
||||||
fprintf(stream, ",");
|
fprintf(stream, ",");
|
||||||
}
|
}
|
||||||
fprintf(stream, "\r\n ");
|
fprintf(stream, "\r\n ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stream, ") \r\n");
|
fprintf(stream, ") \r\n");
|
||||||
}
|
} 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 */
|
||||||
status = bacapp_print_value(stdout, value, property);
|
status = bacapp_print_value(stdout, value, property);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
fprintf(stream, "? \r\n");
|
fprintf(stream, "? \r\n");
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@@ -369,36 +358,29 @@ void PrintReadPropertyData(
|
|||||||
KEY object_list_element;
|
KEY object_list_element;
|
||||||
bool isSequence = false; /* Ie, will need bracketing braces {} */
|
bool isSequence = false; /* Ie, will need bracketing braces {} */
|
||||||
|
|
||||||
if (rpm_property == NULL )
|
if (rpm_property == NULL) {
|
||||||
{
|
|
||||||
fprintf(stdout, " -- Null Property data \r\n");
|
fprintf(stdout, " -- Null Property data \r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value = rpm_property->value;
|
value = rpm_property->value;
|
||||||
if ( value == NULL )
|
if (value == NULL) {
|
||||||
{
|
|
||||||
/* Then we print the error information */
|
/* Then we print the error information */
|
||||||
fprintf(stdout, "? -- BACnet Error: %s: %s\r\n",
|
fprintf(stdout, "? -- BACnet Error: %s: %s\r\n",
|
||||||
bactext_error_class_name((int) rpm_property->error.error_class),
|
bactext_error_class_name((int) rpm_property->error.error_class),
|
||||||
bactext_error_code_name((int) rpm_property->error.error_code));
|
bactext_error_code_name((int) rpm_property->error.error_code));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (data->array_index == BACNET_ARRAY_ALL)
|
if (data->array_index == BACNET_ARRAY_ALL)
|
||||||
fprintf(stderr, "%s #%u %s\n",
|
fprintf(stderr, "%s #%u %s\n",
|
||||||
bactext_object_type_name(data->object_type),
|
bactext_object_type_name(data->object_type), data->object_instance,
|
||||||
data->object_instance,
|
|
||||||
bactext_property_name(data->object_property));
|
bactext_property_name(data->object_property));
|
||||||
else
|
else
|
||||||
fprintf(stderr, "%s #%u %s[%d]\n",
|
fprintf(stderr, "%s #%u %s[%d]\n",
|
||||||
bactext_object_type_name(data->object_type),
|
bactext_object_type_name(data->object_type), data->object_instance,
|
||||||
data->object_instance,
|
bactext_property_name(data->object_property), data->array_index);
|
||||||
bactext_property_name(data->object_property),
|
|
||||||
data->array_index);
|
|
||||||
#endif
|
#endif
|
||||||
if( ( value != NULL ) && ( value->next != NULL ) )
|
if ((value != NULL) && (value->next != NULL)) {
|
||||||
{
|
|
||||||
/* Then this is an array of values; open brace */
|
/* Then this is an array of values; open brace */
|
||||||
fprintf(stdout, "{ ");
|
fprintf(stdout, "{ ");
|
||||||
print_brace = true; /* remember to close it */
|
print_brace = true; /* remember to close it */
|
||||||
@@ -407,40 +389,34 @@ void PrintReadPropertyData(
|
|||||||
if (!Using_Walked_List)
|
if (!Using_Walked_List)
|
||||||
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
|
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
|
||||||
/* value(s) loop until there is no "next" ... */
|
/* value(s) loop until there is no "next" ... */
|
||||||
while ( value != NULL )
|
while (value != NULL) {
|
||||||
{
|
switch (rpm_property->propertyIdentifier) {
|
||||||
switch( rpm_property->propertyIdentifier )
|
|
||||||
{
|
|
||||||
/* These are all arrays, so they open and close with braces */
|
/* These are all arrays, so they open and close with braces */
|
||||||
case PROP_OBJECT_LIST:
|
case PROP_OBJECT_LIST:
|
||||||
case PROP_STATE_TEXT:
|
case PROP_STATE_TEXT:
|
||||||
case PROP_STRUCTURED_OBJECT_LIST:
|
case PROP_STRUCTURED_OBJECT_LIST:
|
||||||
case PROP_SUBORDINATE_ANNOTATIONS:
|
case PROP_SUBORDINATE_ANNOTATIONS:
|
||||||
case PROP_SUBORDINATE_LIST:
|
case PROP_SUBORDINATE_LIST:
|
||||||
if ( Using_Walked_List )
|
if (Using_Walked_List) {
|
||||||
{
|
|
||||||
if ((rpm_property->propertyArrayIndex == 0) &&
|
if ((rpm_property->propertyArrayIndex == 0) &&
|
||||||
(value->tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) )
|
(value->tag == BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||||
{
|
|
||||||
/* Grab the value of the Object List length - don't print it! */
|
/* Grab the value of the Object List length - don't print it! */
|
||||||
Walked_List_Length = value->type.Unsigned_Int;
|
Walked_List_Length = value->type.Unsigned_Int;
|
||||||
if ( rpm_property->propertyIdentifier == PROP_OBJECT_LIST)
|
if (rpm_property->propertyIdentifier ==
|
||||||
|
PROP_OBJECT_LIST)
|
||||||
Object_List_Length = value->type.Unsigned_Int;
|
Object_List_Length = value->type.Unsigned_Int;
|
||||||
break;
|
break;
|
||||||
}
|
} else
|
||||||
else
|
assert(Walked_List_Index ==
|
||||||
assert( Walked_List_Index == rpm_property->propertyArrayIndex);
|
rpm_property->propertyArrayIndex);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Walked_List_Index++;
|
Walked_List_Index++;
|
||||||
/* If we got the whole Object List array in one RP call, keep
|
/* If we got the whole Object List array in one RP call, keep
|
||||||
* the Index and List_Length in sync as we cycle through. */
|
* the Index and List_Length in sync as we cycle through. */
|
||||||
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST)
|
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST)
|
||||||
Object_List_Length = ++Object_List_Index;
|
Object_List_Length = ++Object_List_Index;
|
||||||
}
|
}
|
||||||
if ( Walked_List_Index == 1 )
|
if (Walked_List_Index == 1) {
|
||||||
{
|
|
||||||
/* Open this Array of Objects for the first entry (unless
|
/* Open this Array of Objects for the first entry (unless
|
||||||
* opening brace has already printed, since this is an array
|
* opening brace has already printed, since this is an array
|
||||||
* of values[] ) */
|
* of values[] ) */
|
||||||
@@ -450,8 +426,7 @@ void PrintReadPropertyData(
|
|||||||
fprintf(stdout, "\r\n ");
|
fprintf(stdout, "\r\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rpm_property->propertyIdentifier == PROP_OBJECT_LIST)
|
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
||||||
{
|
|
||||||
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||||
assert(false); /* Something not right here */
|
assert(false); /* Something not right here */
|
||||||
break;
|
break;
|
||||||
@@ -464,23 +439,21 @@ void PrintReadPropertyData(
|
|||||||
/* We don't have anything to put in the data pointer
|
/* We don't have anything to put in the data pointer
|
||||||
* yet, so just leave it null. The key is Key here. */
|
* yet, so just leave it null. The key is Key here. */
|
||||||
Keylist_Data_Add(Object_List, object_list_element, NULL);
|
Keylist_Data_Add(Object_List, object_list_element, NULL);
|
||||||
}
|
} else if (rpm_property->propertyIdentifier == PROP_STATE_TEXT) {
|
||||||
else if ( rpm_property->propertyIdentifier == PROP_STATE_TEXT )
|
|
||||||
{
|
|
||||||
/* Make sure it fits within 31 chars for original VTS3 limitation.
|
/* Make sure it fits within 31 chars for original VTS3 limitation.
|
||||||
* If longer, take first 15 dash, and last 15 chars. */
|
* If longer, take first 15 dash, and last 15 chars. */
|
||||||
if ( value->type.Character_String.length > 31 )
|
if (value->type.Character_String.length > 31) {
|
||||||
{
|
int iLast15idx =
|
||||||
int iLast15idx = value->type.Character_String.length - 15;
|
value->type.Character_String.length - 15;
|
||||||
value->type.Character_String.value[15] = '-';
|
value->type.Character_String.value[15] = '-';
|
||||||
memcpy(&value->type.Character_String.value[16],
|
memcpy(&value->type.Character_String.value[16],
|
||||||
&value->type.Character_String.value[iLast15idx], 15 );
|
&value->type.Character_String.value[iLast15idx],
|
||||||
|
15);
|
||||||
value->type.Character_String.value[31] = 0;
|
value->type.Character_String.value[31] = 0;
|
||||||
value->type.Character_String.length = 31;
|
value->type.Character_String.length = 31;
|
||||||
}
|
}
|
||||||
}
|
} else if (rpm_property->propertyIdentifier ==
|
||||||
else if ( rpm_property->propertyIdentifier == PROP_SUBORDINATE_LIST)
|
PROP_SUBORDINATE_LIST) {
|
||||||
{
|
|
||||||
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||||
assert(false); /* Something not right here */
|
assert(false); /* Something not right here */
|
||||||
break;
|
break;
|
||||||
@@ -492,13 +465,13 @@ void PrintReadPropertyData(
|
|||||||
/* If the object is a Sequence, it needs its own bracketing braces */
|
/* If the object is a Sequence, it needs its own bracketing braces */
|
||||||
if (isSequence)
|
if (isSequence)
|
||||||
fprintf(stdout, "{");
|
fprintf(stdout, "{");
|
||||||
bacapp_print_value(stdout, value, rpm_property->propertyIdentifier );
|
bacapp_print_value(stdout, value,
|
||||||
|
rpm_property->propertyIdentifier);
|
||||||
if (isSequence)
|
if (isSequence)
|
||||||
fprintf(stdout, "}");
|
fprintf(stdout, "}");
|
||||||
|
|
||||||
if ((Walked_List_Index < Walked_List_Length) ||
|
if ((Walked_List_Index < Walked_List_Length) ||
|
||||||
( value->next != NULL ) )
|
(value->next != NULL)) {
|
||||||
{
|
|
||||||
/* There are more. */
|
/* There are more. */
|
||||||
fprintf(stdout, ", ");
|
fprintf(stdout, ", ");
|
||||||
if (!(Walked_List_Index % 4))
|
if (!(Walked_List_Index % 4))
|
||||||
@@ -510,14 +483,14 @@ void PrintReadPropertyData(
|
|||||||
|
|
||||||
case PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED:
|
case PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED:
|
||||||
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
||||||
PrettyPrintPropertyValue(stdout, value, rpm_property->propertyIdentifier);
|
PrettyPrintPropertyValue(stdout, value,
|
||||||
|
rpm_property->propertyIdentifier);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* 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:
|
||||||
case PROP_DAYLIGHT_SAVINGS_STATUS:
|
case PROP_DAYLIGHT_SAVINGS_STATUS:
|
||||||
case PROP_LOCAL_DATE:
|
case PROP_LOCAL_DATE:
|
||||||
@@ -527,22 +500,20 @@ void PrintReadPropertyData(
|
|||||||
case PROP_RELIABILITY:
|
case PROP_RELIABILITY:
|
||||||
case PROP_UTC_OFFSET:
|
case PROP_UTC_OFFSET:
|
||||||
case PROP_DATABASE_REVISION:
|
case PROP_DATABASE_REVISION:
|
||||||
if ( !ShowValues )
|
if (!ShowValues) {
|
||||||
{
|
|
||||||
fprintf(stdout, "?");
|
fprintf(stdout, "?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Else, fall through and print value: */
|
/* Else, fall through and print value: */
|
||||||
default:
|
default:
|
||||||
bacapp_print_value(stdout, value, rpm_property->propertyIdentifier);
|
bacapp_print_value(stdout, value,
|
||||||
|
rpm_property->propertyIdentifier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (value->next != NULL) {
|
if (value->next != NULL) {
|
||||||
/* there's more! */
|
/* there's more! */
|
||||||
fprintf(stdout, ",");
|
fprintf(stdout, ",");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (print_brace) {
|
if (print_brace) {
|
||||||
/* Closing brace for this multi-valued array */
|
/* Closing brace for this multi-valued array */
|
||||||
fprintf(stdout, " }");
|
fprintf(stdout, " }");
|
||||||
@@ -576,8 +547,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;
|
||||||
|
|
||||||
if ( Property_List_Length == 0 )
|
if (Property_List_Length == 0) {
|
||||||
{
|
|
||||||
/* If we failed to get the Properties with RPM, just settle for what we
|
/* If we failed to get the Properties with RPM, just settle for what we
|
||||||
* know is the fixed list of Required (only) properties.
|
* know is the fixed list of Required (only) properties.
|
||||||
* In practice, this should only happen for simple devices that don't
|
* In practice, this should only happen for simple devices that don't
|
||||||
@@ -585,26 +555,20 @@ static uint8_t Read_Properties(
|
|||||||
*/
|
*/
|
||||||
Device_Objects_Property_List(pMyObject->type, &PropertyListStruct);
|
Device_Objects_Property_List(pMyObject->type, &PropertyListStruct);
|
||||||
pPropList = PropertyListStruct.Required.pList;
|
pPropList = PropertyListStruct.Required.pList;
|
||||||
if ( pPropList != NULL )
|
if (pPropList != NULL) {
|
||||||
{
|
|
||||||
Property_List_Length = PropertyListStruct.Required.count;
|
Property_List_Length = PropertyListStruct.Required.count;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stdout, " -- No Properties available for %s \r\n",
|
fprintf(stdout, " -- No Properties available for %s \r\n",
|
||||||
bactext_object_type_name(pMyObject->type));
|
bactext_object_type_name(pMyObject->type));
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
pPropList = Property_List;
|
pPropList = Property_List;
|
||||||
|
|
||||||
if ( (pPropList != NULL ) && ( pPropList[Property_List_Index] != -1) )
|
if ((pPropList != NULL) && (pPropList[Property_List_Index] != -1)) {
|
||||||
{
|
|
||||||
int prop = pPropList[Property_List_Index];
|
int prop = pPropList[Property_List_Index];
|
||||||
int32_t array_index;
|
int32_t array_index;
|
||||||
IsLongArray = false;
|
IsLongArray = false;
|
||||||
if ( Using_Walked_List )
|
if (Using_Walked_List) {
|
||||||
{
|
|
||||||
if (Walked_List_Length == 0) {
|
if (Walked_List_Length == 0) {
|
||||||
/* printf(" %s: ", bactext_property_name( prop ) ); */
|
/* printf(" %s: ", bactext_property_name( prop ) ); */
|
||||||
array_index = 0;
|
array_index = 0;
|
||||||
@@ -615,8 +579,7 @@ static uint8_t Read_Properties(
|
|||||||
printf(" %s: ", bactext_property_name(prop));
|
printf(" %s: ", bactext_property_name(prop));
|
||||||
array_index = BACNET_ARRAY_ALL;
|
array_index = BACNET_ARRAY_ALL;
|
||||||
|
|
||||||
switch( prop )
|
switch (prop) {
|
||||||
{
|
|
||||||
/* These are all potentially long arrays, so they may abort */
|
/* These are all potentially long arrays, so they may abort */
|
||||||
case PROP_OBJECT_LIST:
|
case PROP_OBJECT_LIST:
|
||||||
case PROP_STATE_TEXT:
|
case PROP_STATE_TEXT:
|
||||||
@@ -628,9 +591,8 @@ static uint8_t Read_Properties(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
invoke_id =
|
invoke_id =
|
||||||
Send_Read_Property_Request(device_instance,
|
Send_Read_Property_Request(device_instance, pMyObject->type,
|
||||||
pMyObject->type, pMyObject->instance,
|
pMyObject->instance, prop, array_index);
|
||||||
prop, array_index );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,16 +624,13 @@ EPICS_STATES ProcessRPMData(
|
|||||||
bool bHasObjectList = false;
|
bool bHasObjectList = false;
|
||||||
bool bHasStructuredViewList = false;
|
bool bHasStructuredViewList = false;
|
||||||
|
|
||||||
while (rpm_data)
|
while (rpm_data) {
|
||||||
{
|
|
||||||
rpm_property = rpm_data->listOfProperties;
|
rpm_property = rpm_data->listOfProperties;
|
||||||
while (rpm_property) {
|
while (rpm_property) {
|
||||||
/* For the GET_LIST_OF_ALL_RESPONSE case,
|
/* For the GET_LIST_OF_ALL_RESPONSE case,
|
||||||
* just keep what property this was */
|
* just keep what property this was */
|
||||||
if ( myState == GET_LIST_OF_ALL_RESPONSE )
|
if (myState == GET_LIST_OF_ALL_RESPONSE) {
|
||||||
{
|
switch (rpm_property->propertyIdentifier) {
|
||||||
switch ( rpm_property->propertyIdentifier )
|
|
||||||
{
|
|
||||||
case PROP_OBJECT_LIST:
|
case PROP_OBJECT_LIST:
|
||||||
bHasObjectList = true; /* Will append below */
|
bHasObjectList = true; /* Will append below */
|
||||||
break;
|
break;
|
||||||
@@ -691,11 +650,9 @@ EPICS_STATES ProcessRPMData(
|
|||||||
value = value->next;
|
value = value->next;
|
||||||
free(old_value);
|
free(old_value);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
printf(" %s: ",
|
||||||
{
|
bactext_property_name(rpm_property->propertyIdentifier));
|
||||||
printf(" %s: ", bactext_property_name(
|
|
||||||
rpm_property->propertyIdentifier) );
|
|
||||||
PrintReadPropertyData(rpm_property);
|
PrintReadPropertyData(rpm_property);
|
||||||
}
|
}
|
||||||
old_rpm_property = rpm_property;
|
old_rpm_property = rpm_property;
|
||||||
@@ -710,8 +667,7 @@ EPICS_STATES ProcessRPMData(
|
|||||||
/* Now determine the next state */
|
/* Now determine the next state */
|
||||||
if (bSuccess && (myState == GET_ALL_RESPONSE))
|
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 */
|
||||||
{
|
|
||||||
/* Now append the properties we waited on. */
|
/* Now append the properties we waited on. */
|
||||||
if (bHasStructuredViewList) {
|
if (bHasStructuredViewList) {
|
||||||
Property_List[Property_List_Index++] = PROP_STRUCTURED_OBJECT_LIST;
|
Property_List[Property_List_Index++] = PROP_STRUCTURED_OBJECT_LIST;
|
||||||
@@ -730,7 +686,8 @@ EPICS_STATES ProcessRPMData(
|
|||||||
return nextState;
|
return nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintUsage()
|
void PrintUsage(
|
||||||
|
)
|
||||||
{
|
{
|
||||||
printf("bacepics -- Generates Object and Property List for EPICS \r\n");
|
printf("bacepics -- Generates Object and Property List for EPICS \r\n");
|
||||||
printf("Usage: \r\n");
|
printf("Usage: \r\n");
|
||||||
@@ -739,7 +696,8 @@ void PrintUsage()
|
|||||||
printf("Insert the output in your EPICS file as the last section: \r\n");
|
printf("Insert the output in your EPICS file as the last section: \r\n");
|
||||||
printf("\"List of Objects in test device:\" \r\n");
|
printf("\"List of Objects in test device:\" \r\n");
|
||||||
printf("before the final statement: \r\n");
|
printf("before the final statement: \r\n");
|
||||||
printf("\"End of BACnet Protocol Implementation Conformance Statement\" \r\n");
|
printf
|
||||||
|
("\"End of BACnet Protocol Implementation Conformance Statement\" \r\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,22 +714,19 @@ int CheckCommandLineArgs(
|
|||||||
fprintf(stderr, "Must provide a device-instance \r\n\r\n");
|
fprintf(stderr, "Must provide a device-instance \r\n\r\n");
|
||||||
PrintUsage(); /* Will exit */
|
PrintUsage(); /* Will exit */
|
||||||
}
|
}
|
||||||
for ( i = 1; i < argc; i++ )
|
for (i = 1; i < argc; i++) {
|
||||||
{
|
|
||||||
char *anArg = argv[i];
|
char *anArg = argv[i];
|
||||||
if ( anArg[0] == '-' )
|
if (anArg[0] == '-') {
|
||||||
{
|
|
||||||
if (anArg[1] == 'v')
|
if (anArg[1] == 'v')
|
||||||
ShowValues = true;
|
ShowValues = true;
|
||||||
else
|
else
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* decode the Target Device Instance parameter */
|
/* decode the Target Device Instance parameter */
|
||||||
Target_Device_Object_Instance = strtol(anArg, NULL, 0);
|
Target_Device_Object_Instance = strtol(anArg, NULL, 0);
|
||||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
fprintf(stderr,
|
||||||
|
"device-instance=%u - it must be less than %u\r\n",
|
||||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE + 1);
|
Target_Device_Object_Instance, BACNET_MAX_INSTANCE + 1);
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
}
|
}
|
||||||
@@ -857,21 +812,21 @@ int main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* OK to proceed; see what we are up to now */
|
/* OK to proceed; see what we are up to now */
|
||||||
switch ( myState )
|
switch (myState) {
|
||||||
{
|
|
||||||
case INITIAL_BINDING:
|
case INITIAL_BINDING:
|
||||||
/* returns 0 bytes on timeout */
|
/* returns 0 bytes on timeout */
|
||||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
pdu_len =
|
||||||
|
datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
||||||
|
|
||||||
/* process; normally is some initial error */
|
/* process; normally is some initial error */
|
||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||||
}
|
}
|
||||||
/* will wait until the device is bound, or timeout and quit */
|
/* will wait until the device is bound, or timeout and quit */
|
||||||
found = address_bind_request(Target_Device_Object_Instance,
|
found =
|
||||||
|
address_bind_request(Target_Device_Object_Instance,
|
||||||
&max_apdu, &Target_Address);
|
&max_apdu, &Target_Address);
|
||||||
if ( !found )
|
if (!found) {
|
||||||
{
|
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds += (current_seconds - last_seconds);
|
elapsed_seconds += (current_seconds - last_seconds);
|
||||||
if (elapsed_seconds > timeout_seconds) {
|
if (elapsed_seconds > timeout_seconds) {
|
||||||
@@ -880,8 +835,7 @@ int main(
|
|||||||
}
|
}
|
||||||
/* else, loop back and try again */
|
/* else, loop back and try again */
|
||||||
continue;
|
continue;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
myState = GET_ALL_REQUEST;
|
myState = GET_ALL_REQUEST;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -906,8 +860,7 @@ int main(
|
|||||||
invoke_id =
|
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 ( invoke_id > 0 )
|
if (invoke_id > 0) {
|
||||||
{
|
|
||||||
if (myState == GET_LIST_OF_ALL_REQUEST)
|
if (myState == GET_LIST_OF_ALL_REQUEST)
|
||||||
myState = GET_LIST_OF_ALL_RESPONSE;
|
myState = GET_LIST_OF_ALL_RESPONSE;
|
||||||
else
|
else
|
||||||
@@ -918,7 +871,8 @@ int main(
|
|||||||
case GET_ALL_RESPONSE:
|
case GET_ALL_RESPONSE:
|
||||||
case GET_LIST_OF_ALL_RESPONSE:
|
case GET_LIST_OF_ALL_RESPONSE:
|
||||||
/* returns 0 bytes on timeout */
|
/* returns 0 bytes on timeout */
|
||||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
pdu_len =
|
||||||
|
datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
||||||
|
|
||||||
/* process */
|
/* process */
|
||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
@@ -926,29 +880,28 @@ int main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((Read_Property_Multiple_Data.new_data) &&
|
if ((Read_Property_Multiple_Data.new_data) &&
|
||||||
(invoke_id == Read_Property_Multiple_Data.service_data.invoke_id)) {
|
(invoke_id ==
|
||||||
|
Read_Property_Multiple_Data.service_data.invoke_id)) {
|
||||||
Read_Property_Multiple_Data.new_data = false;
|
Read_Property_Multiple_Data.new_data = false;
|
||||||
myState = ProcessRPMData( Read_Property_Multiple_Data.rpm_data,
|
myState =
|
||||||
|
ProcessRPMData(Read_Property_Multiple_Data.rpm_data,
|
||||||
myState);
|
myState);
|
||||||
if (tsm_invoke_id_free(invoke_id)) {
|
if (tsm_invoke_id_free(invoke_id)) {
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert(false); /* How can this be? */
|
assert(false); /* How can this be? */
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
}
|
}
|
||||||
} else if (tsm_invoke_id_free(invoke_id)) {
|
} else if (tsm_invoke_id_free(invoke_id)) {
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
if (Error_Detected) /* The normal case for Device Object */
|
if (Error_Detected) { /* The normal case for Device Object */
|
||||||
{
|
|
||||||
/* Try again, just to get a list of properties. */
|
/* Try again, just to get a list of properties. */
|
||||||
if (myState == GET_ALL_RESPONSE)
|
if (myState == GET_ALL_RESPONSE)
|
||||||
myState = GET_LIST_OF_ALL_REQUEST;
|
myState = GET_LIST_OF_ALL_REQUEST;
|
||||||
/* Else it may be that RPM is not implemented. */
|
/* Else it may be that RPM is not implemented. */
|
||||||
else
|
else
|
||||||
myState = GET_PROPERTY_REQUEST;
|
myState = GET_PROPERTY_REQUEST;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
myState = GET_ALL_REQUEST; /* Let's try again */
|
myState = GET_ALL_REQUEST; /* Let's try again */
|
||||||
} else if (tsm_invoke_id_failed(invoke_id)) {
|
} else if (tsm_invoke_id_failed(invoke_id)) {
|
||||||
fprintf(stderr, "\rError: TSM Timeout!\r\n");
|
fprintf(stderr, "\rError: TSM Timeout!\r\n");
|
||||||
@@ -968,18 +921,19 @@ int main(
|
|||||||
Error_Detected = false;
|
Error_Detected = false;
|
||||||
/* Update times; aids single-step debugging */
|
/* Update times; aids single-step debugging */
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
invoke_id = Read_Properties(Target_Device_Object_Instance, &myObject );
|
invoke_id =
|
||||||
|
Read_Properties(Target_Device_Object_Instance, &myObject);
|
||||||
if (invoke_id == 0) {
|
if (invoke_id == 0) {
|
||||||
/* Reached the end of the list. */
|
/* Reached the end of the list. */
|
||||||
myState = NEXT_OBJECT; /* Move on to the next. */
|
myState = NEXT_OBJECT; /* Move on to the next. */
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
myState = GET_PROPERTY_RESPONSE;
|
myState = GET_PROPERTY_RESPONSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_PROPERTY_RESPONSE:
|
case GET_PROPERTY_RESPONSE:
|
||||||
/* returns 0 bytes on timeout */
|
/* returns 0 bytes on timeout */
|
||||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
pdu_len =
|
||||||
|
datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
||||||
|
|
||||||
/* process */
|
/* process */
|
||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
@@ -987,28 +941,26 @@ int main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((Read_Property_Multiple_Data.new_data) &&
|
if ((Read_Property_Multiple_Data.new_data) &&
|
||||||
(invoke_id == Read_Property_Multiple_Data.service_data.invoke_id))
|
(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.rpm_data->listOfProperties );
|
PrintReadPropertyData(Read_Property_Multiple_Data.
|
||||||
|
rpm_data->listOfProperties);
|
||||||
if (tsm_invoke_id_free(invoke_id)) {
|
if (tsm_invoke_id_free(invoke_id)) {
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert(false); /* How can this be? */
|
assert(false); /* How can this be? */
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
}
|
}
|
||||||
/* Advance the property (or Array List) index */
|
/* Advance the property (or Array List) index */
|
||||||
if ( Using_Walked_List )
|
if (Using_Walked_List) {
|
||||||
{
|
|
||||||
Walked_List_Index++;
|
Walked_List_Index++;
|
||||||
if (Walked_List_Index > Walked_List_Length) {
|
if (Walked_List_Index > Walked_List_Length) {
|
||||||
/* go on to next property */
|
/* go on to next property */
|
||||||
Property_List_Index++;
|
Property_List_Index++;
|
||||||
Using_Walked_List = false;
|
Using_Walked_List = false;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
Property_List_Index++;
|
Property_List_Index++;
|
||||||
/* if ( pPropList[Property_List_Index] == PROP_OBJECT_LIST ) */
|
/* if ( pPropList[Property_List_Index] == PROP_OBJECT_LIST ) */
|
||||||
/* { */
|
/* { */
|
||||||
@@ -1019,20 +971,18 @@ int main(
|
|||||||
/* } */
|
/* } */
|
||||||
/* } */
|
/* } */
|
||||||
myState = GET_PROPERTY_REQUEST; /* Go fetch next Property */
|
myState = GET_PROPERTY_REQUEST; /* Go fetch next Property */
|
||||||
}
|
} else if (tsm_invoke_id_free(invoke_id)) {
|
||||||
else if (tsm_invoke_id_free(invoke_id)) {
|
|
||||||
invoke_id = 0;
|
invoke_id = 0;
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
{
|
|
||||||
if (IsLongArray) {
|
if (IsLongArray) {
|
||||||
/* Change to using a Walked List and retry this property */
|
/* Change to using a Walked List and retry this property */
|
||||||
Using_Walked_List = true;
|
Using_Walked_List = true;
|
||||||
Walked_List_Index = Walked_List_Length = 0;
|
Walked_List_Index = Walked_List_Length = 0;
|
||||||
}
|
} 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 %s \r\n",
|
fprintf(stdout, " -- Failed to get %s \r\n",
|
||||||
bactext_property_name(pPropList[Property_List_Index]) );
|
bactext_property_name(pPropList
|
||||||
|
[Property_List_Index]));
|
||||||
Property_List_Index++;
|
Property_List_Index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1050,25 +1000,22 @@ int main(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NEXT_OBJECT:
|
case NEXT_OBJECT:
|
||||||
if ( myObject.type == OBJECT_DEVICE )
|
if (myObject.type == OBJECT_DEVICE) {
|
||||||
{
|
printf(" -- Found %d Objects \r\n",
|
||||||
printf(" -- Found %d Objects \r\n", Keylist_Count( Object_List ) );
|
Keylist_Count(Object_List));
|
||||||
Object_List_Index = -1; /* start over (will be incr to 0) */
|
Object_List_Index = -1; /* start over (will be incr to 0) */
|
||||||
}
|
}
|
||||||
/* Advance to the next object, as long as it's not the Device object */
|
/* Advance to the next object, as long as it's not the Device object */
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
Object_List_Index++;
|
Object_List_Index++;
|
||||||
nextKey = Keylist_Key(Object_List, Object_List_Index);
|
nextKey = Keylist_Key(Object_List, Object_List_Index);
|
||||||
/* If done with all Objects, signal end of this while loop */
|
/* If done with all Objects, signal end of this while loop */
|
||||||
if ( ( nextKey == 0 ) || ( Object_List_Index >= Object_List_Length ) )
|
if ((nextKey == 0) ||
|
||||||
{
|
(Object_List_Index >= Object_List_Length)) {
|
||||||
/* Closing brace for the last Object */
|
/* Closing brace for the last Object */
|
||||||
printf(" } \r\n");
|
printf(" } \r\n");
|
||||||
myObject.type = MAX_BACNET_OBJECT_TYPE;
|
myObject.type = MAX_BACNET_OBJECT_TYPE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Closing brace for the previous Object */
|
/* Closing brace for the previous Object */
|
||||||
printf(" }, \r\n");
|
printf(" }, \r\n");
|
||||||
myObject.type = KEY_DECODE_TYPE(nextKey);
|
myObject.type = KEY_DECODE_TYPE(nextKey);
|
||||||
@@ -1092,8 +1039,7 @@ int main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for timeouts */
|
/* Check for timeouts */
|
||||||
if ( !found || ( invoke_id > 0 ) )
|
if (!found || (invoke_id > 0)) {
|
||||||
{
|
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds += (current_seconds - last_seconds);
|
elapsed_seconds += (current_seconds - last_seconds);
|
||||||
if (elapsed_seconds > timeout_seconds) {
|
if (elapsed_seconds > timeout_seconds) {
|
||||||
@@ -1111,4 +1057,3 @@ int main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*@}*//* End group BACEPICS */
|
/*@}*//* End group BACEPICS */
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ void dlenv_init(
|
|||||||
if (pEnv) {
|
if (pEnv) {
|
||||||
tsm_invokeID_set((uint8_t) strtol(pEnv, NULL, 0));
|
tsm_invokeID_set((uint8_t) strtol(pEnv, NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BACDL_BIP) && BBMD_ENABLED
|
#if defined(BACDL_BIP) && BBMD_ENABLED
|
||||||
pEnv = getenv("BACNET_BBMD_PORT");
|
pEnv = getenv("BACNET_BBMD_PORT");
|
||||||
if (pEnv) {
|
if (pEnv) {
|
||||||
|
|||||||
@@ -109,8 +109,9 @@ void handler_alarm_ack(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Alarm Ack Operation: Received acknowledge for object id %lu from %s for process id %lu for object %lu\n",
|
"Alarm Ack Operation: Received acknowledge for object id %lu from %s for process id %lu for object %lu\n",
|
||||||
(unsigned long)data.eventObjectIdentifier.instance, data.ackSource.value,
|
(unsigned long) data.eventObjectIdentifier.instance,
|
||||||
(unsigned long)data.ackProcessIdentifier, (unsigned long)data.eventObjectIdentifier.instance);
|
data.ackSource.value, (unsigned long) data.ackProcessIdentifier,
|
||||||
|
(unsigned long) data.eventObjectIdentifier.instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len =
|
len =
|
||||||
|
|||||||
@@ -344,9 +344,8 @@ static bool cov_send_request(
|
|||||||
value_list[1].next = NULL;
|
value_list[1].next = NULL;
|
||||||
switch (cov_subscription->monitoredObjectIdentifier.type) {
|
switch (cov_subscription->monitoredObjectIdentifier.type) {
|
||||||
case OBJECT_BINARY_INPUT:
|
case OBJECT_BINARY_INPUT:
|
||||||
Binary_Input_Encode_Value_List
|
Binary_Input_Encode_Value_List(cov_subscription->
|
||||||
(cov_subscription->monitoredObjectIdentifier.instance,
|
monitoredObjectIdentifier.instance, &value_list[0]);
|
||||||
&value_list[0]);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto COV_FAILED;
|
goto COV_FAILED;
|
||||||
@@ -463,8 +462,8 @@ static bool cov_subscribe(
|
|||||||
|
|
||||||
switch (cov_data->monitoredObjectIdentifier.type) {
|
switch (cov_data->monitoredObjectIdentifier.type) {
|
||||||
case OBJECT_BINARY_INPUT:
|
case OBJECT_BINARY_INPUT:
|
||||||
if (Binary_Input_Valid_Instance
|
if (Binary_Input_Valid_Instance(cov_data->
|
||||||
(cov_data->monitoredObjectIdentifier.instance)) {
|
monitoredObjectIdentifier.instance)) {
|
||||||
status =
|
status =
|
||||||
cov_list_subscribe(src, cov_data, error_class, error_code);
|
cov_list_subscribe(src, cov_data, error_class, error_code);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ void handler_i_am_add(
|
|||||||
#endif
|
#endif
|
||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, " from %lu, MAC = %d.%d.%d.%d.%d.%d\n", (unsigned long)device_id,
|
fprintf(stderr, " from %lu, MAC = %d.%d.%d.%d.%d.%d\n",
|
||||||
src->mac[0], src->mac[1], src->mac[2], src->mac[3], src->mac[4],
|
(unsigned long) device_id, src->mac[0], src->mac[1], src->mac[2],
|
||||||
src->mac[5]);
|
src->mac[3], src->mac[4], src->mac[5]);
|
||||||
#endif
|
#endif
|
||||||
address_add(device_id, max_apdu, src);
|
address_add(device_id, max_apdu, src);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ void handler_lso(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Life Safety Operation: Received operation %d from process id %lu for object %lu\n",
|
"Life Safety Operation: Received operation %d from process id %lu for object %lu\n",
|
||||||
data.operation, (unsigned long)data.processId, (unsigned long)data.targetObject.instance);
|
data.operation, (unsigned long) data.processId,
|
||||||
|
(unsigned long) data.targetObject.instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len =
|
len =
|
||||||
|
|||||||
@@ -100,10 +100,11 @@ void ProcessPT(
|
|||||||
/* Signal success */
|
/* Signal success */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK);
|
iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK);
|
||||||
/* Followed by the block number */
|
/* Followed by the block number */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen],
|
iLen +=
|
||||||
cBlockNumber);
|
encode_application_unsigned(&IOBufferPT[iLen], cBlockNumber);
|
||||||
/* And Then the block contents */
|
/* And Then the block contents */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen],
|
iLen +=
|
||||||
|
encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
MyData[(int8_t) cBlockNumber].cMyByte1);
|
MyData[(int8_t) cBlockNumber].cMyByte1);
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_unsigned(&IOBufferPT[iLen],
|
encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ void DecodeBlock(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
||||||
strncpy((char *)Response.sMyString, characterstring_value(&bsName), MY_MAX_STR);
|
strncpy((char *) Response.sMyString, characterstring_value(&bsName),
|
||||||
|
MY_MAX_STR);
|
||||||
Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
|
Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
|
||||||
|
|
||||||
printf("Private Transfer Read Block Response\n");
|
printf("Private Transfer Read Block Response\n");
|
||||||
@@ -168,7 +169,8 @@ void ProcessPTA(
|
|||||||
cBlockNumber = (char) ulTemp;
|
cBlockNumber = (char) ulTemp;
|
||||||
DecodeBlock(cBlockNumber, &data->serviceParameters[iLen]);
|
DecodeBlock(cBlockNumber, &data->serviceParameters[iLen]);
|
||||||
} else { /* Read error */
|
} else { /* Read error */
|
||||||
printf("Private Transfer read operation returned error code: %lu\n",
|
printf
|
||||||
|
("Private Transfer read operation returned error code: %lu\n",
|
||||||
(unsigned long) uiErrorCode);
|
(unsigned long) uiErrorCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ void handler_reinitialize_device(
|
|||||||
goto RD_ABORT;
|
goto RD_ABORT;
|
||||||
}
|
}
|
||||||
/* decode the service request only */
|
/* decode the service request only */
|
||||||
len = rd_decode_service_request(service_request, service_len,
|
len =
|
||||||
&rd_data.state,
|
rd_decode_service_request(service_request, service_len, &rd_data.state,
|
||||||
&rd_data.password);
|
&rd_data.password);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
@@ -143,8 +143,7 @@ void handler_reinitialize_device(
|
|||||||
service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
||||||
rd_data.error_class, rd_data.error_code);
|
rd_data.error_class, rd_data.error_code);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr, "ReinitializeDevice: Sending Error.\n");
|
||||||
"ReinitializeDevice: Sending Error.\n");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,10 +113,9 @@ void handler_read_property(
|
|||||||
}
|
}
|
||||||
/* assume that there is an error */
|
/* assume that there is an error */
|
||||||
error = true;
|
error = true;
|
||||||
apdu_len = rp_ack_encode_apdu_init(
|
apdu_len =
|
||||||
&Handler_Transmit_Buffer[npdu_len],
|
rp_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
|
||||||
service_data->invoke_id,
|
service_data->invoke_id, &rpdata);
|
||||||
&rpdata);
|
|
||||||
/* configure our storage */
|
/* configure our storage */
|
||||||
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len + apdu_len];
|
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len + apdu_len];
|
||||||
rpdata.application_data_len =
|
rpdata.application_data_len =
|
||||||
@@ -124,15 +123,16 @@ void handler_read_property(
|
|||||||
len = Device_Read_Property(&rpdata);
|
len = Device_Read_Property(&rpdata);
|
||||||
if (len >= 0) {
|
if (len >= 0) {
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
len = rp_ack_encode_apdu_object_property_end(
|
len =
|
||||||
&Handler_Transmit_Buffer[npdu_len+apdu_len]);
|
rp_ack_encode_apdu_object_property_end(&Handler_Transmit_Buffer
|
||||||
|
[npdu_len + apdu_len]);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
if (apdu_len > service_data->max_resp) {
|
if (apdu_len > service_data->max_resp) {
|
||||||
/* too big for the sender - send an abort */
|
/* too big for the sender - send an abort */
|
||||||
apdu_len =
|
apdu_len =
|
||||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
service_data->invoke_id,
|
||||||
true);
|
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "RP: Message too large. Sending Abort!\n");
|
fprintf(stderr, "RP: Message too large. Sending Abort!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -166,8 +166,7 @@ int rp_ack_fully_decode_service_request(
|
|||||||
int vlen, len;
|
int vlen, len;
|
||||||
|
|
||||||
decoded_len = rp_ack_decode_service_request(apdu, apdu_len, &rp1data);
|
decoded_len = rp_ack_decode_service_request(apdu, apdu_len, &rp1data);
|
||||||
if ( decoded_len > 0 )
|
if (decoded_len > 0) {
|
||||||
{
|
|
||||||
/* Then we have to transfer to the BACNET_READ_ACCESS_DATA structure
|
/* Then we have to transfer to the BACNET_READ_ACCESS_DATA structure
|
||||||
* and decode the value(s) portion
|
* and decode the value(s) portion
|
||||||
*/
|
*/
|
||||||
@@ -196,9 +195,7 @@ int rp_ack_fully_decode_service_request(
|
|||||||
bacapp_decode_context_data(vdata, vlen, value,
|
bacapp_decode_context_data(vdata, vlen, value,
|
||||||
rp1_property->propertyIdentifier);
|
rp1_property->propertyIdentifier);
|
||||||
} else {
|
} else {
|
||||||
len =
|
len = bacapp_decode_application_data(vdata, vlen, value);
|
||||||
bacapp_decode_application_data(vdata, vlen,
|
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
decoded_len += len;
|
decoded_len += len;
|
||||||
vlen -= len;
|
vlen -= len;
|
||||||
@@ -217,11 +214,9 @@ int rp_ack_fully_decode_service_request(
|
|||||||
read_access_data->listOfProperties = NULL;
|
read_access_data->listOfProperties = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ( vlen > 0 ) /* If more values */
|
if (vlen > 0) { /* If more values */
|
||||||
{
|
|
||||||
old_value = value;
|
old_value = value;
|
||||||
value =
|
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||||
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
|
||||||
old_value->next = value;
|
old_value->next = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,8 +219,8 @@ static void PrintReadPropertyMultipleData(
|
|||||||
#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);
|
||||||
@@ -261,10 +261,10 @@ static void PrintReadPropertyMultipleData(
|
|||||||
#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;
|
||||||
|
|||||||
@@ -64,18 +64,18 @@ int Encode_RR_payload(
|
|||||||
|
|
||||||
if ((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) { /* First index is 1 so can't accept 0 */
|
if ((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) { /* First index is 1 so can't accept 0 */
|
||||||
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
||||||
} else if(((PropInfo.RequestTypes & RR_ARRAY_OF_LISTS) == 0) && (pRequest->array_index != 0) && (pRequest->array_index != BACNET_ARRAY_ALL)) {
|
} else if (((PropInfo.RequestTypes & RR_ARRAY_OF_LISTS) == 0) &&
|
||||||
|
(pRequest->array_index != 0) &&
|
||||||
|
(pRequest->array_index != BACNET_ARRAY_ALL)) {
|
||||||
/* Array access attempted on a non array property */
|
/* Array access attempted on a non array property */
|
||||||
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
}
|
} else if ((pRequest->RequestType != RR_READ_ALL) &&
|
||||||
else if((pRequest->RequestType != RR_READ_ALL) && ((PropInfo.RequestTypes & pRequest->RequestType) == 0)) {
|
((PropInfo.RequestTypes & pRequest->RequestType) == 0)) {
|
||||||
/* By Time or By Sequence not supported - By Position is always required */
|
/* By Time or By Sequence not supported - By Position is always required */
|
||||||
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
||||||
}
|
} else if ((pRequest->Count == 0) && (pRequest->RequestType != RR_READ_ALL)) { /* Count cannot be zero */
|
||||||
else if((pRequest->Count == 0) && (pRequest->RequestType != RR_READ_ALL)) { /* Count cannot be zero */
|
|
||||||
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
||||||
}
|
} else if (PropInfo.Handler != NULL) {
|
||||||
else if(PropInfo.Handler != NULL) {
|
|
||||||
apdu_len = PropInfo.Handler(apdu, pRequest);
|
apdu_len = PropInfo.Handler(apdu, pRequest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -103,7 +103,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(pProperty_value->propertyIdentifier));
|
bactext_property_name(pProperty_value->
|
||||||
|
propertyIdentifier));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "proprietary %u ",
|
fprintf(stderr, "proprietary %u ",
|
||||||
pProperty_value->propertyIdentifier);
|
pProperty_value->propertyIdentifier);
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ void handler_write_property(
|
|||||||
if (len > 0)
|
if (len > 0)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n",
|
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n",
|
||||||
(unsigned long)wp_data.object_type, (unsigned long)wp_data.object_instance,
|
(unsigned long) wp_data.object_type,
|
||||||
(unsigned long)wp_data.object_property, (unsigned long)wp_data.priority, (long)wp_data.array_index);
|
(unsigned long) wp_data.object_instance,
|
||||||
|
(unsigned long) wp_data.object_property,
|
||||||
|
(unsigned long) wp_data.priority, (long) wp_data.array_index);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "WP: Unable to decode Request!\n");
|
fprintf(stderr, "WP: Unable to decode Request!\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -165,10 +167,14 @@ bool WPValidateString(
|
|||||||
*pErrorClass = ERROR_CLASS_PROPERTY;
|
*pErrorClass = ERROR_CLASS_PROPERTY;
|
||||||
|
|
||||||
if (pValue->tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
if (pValue->tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||||
if(characterstring_encoding(&pValue->type.Character_String) == CHARACTER_ANSI_X34) {
|
if (characterstring_encoding(&pValue->type.Character_String) ==
|
||||||
if((bEmptyAllowed == false) && (characterstring_length(&pValue->type.Character_String) == 0)) {
|
CHARACTER_ANSI_X34) {
|
||||||
|
if ((bEmptyAllowed == false) &&
|
||||||
|
(characterstring_length(&pValue->type.Character_String) ==
|
||||||
|
0)) {
|
||||||
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
} else if(characterstring_length(&pValue->type.Character_String) >= iMaxLen) {
|
} else if (characterstring_length(&pValue->type.
|
||||||
|
Character_String) >= iMaxLen) {
|
||||||
*pErrorClass = ERROR_CLASS_RESOURCES;
|
*pErrorClass = ERROR_CLASS_RESOURCES;
|
||||||
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -124,10 +124,9 @@ uint8_t Send_COV_Subscribe(
|
|||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
||||||
&npdu_data);
|
&npdu_data);
|
||||||
/* encode the APDU portion of the packet */
|
/* encode the APDU portion of the packet */
|
||||||
len = cov_subscribe_encode_adpu(
|
len =
|
||||||
&Handler_Transmit_Buffer[pdu_len],
|
cov_subscribe_encode_adpu(&Handler_Transmit_Buffer[pdu_len],
|
||||||
invoke_id,
|
invoke_id, cov_data);
|
||||||
cov_data);
|
|
||||||
pdu_len += len;
|
pdu_len += len;
|
||||||
/* will it fit in the sender?
|
/* will it fit in the sender?
|
||||||
note: if there is a bottleneck router in between
|
note: if there is a bottleneck router in between
|
||||||
@@ -158,4 +157,3 @@ uint8_t Send_COV_Subscribe(
|
|||||||
|
|
||||||
return invoke_id;
|
return invoke_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,9 +132,7 @@ int iam_unicast_encode_pdu(
|
|||||||
datalink_get_my_address(&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
/* 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);
|
||||||
npdu_len =
|
npdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data);
|
||||||
npdu_encode_pdu(&buffer[0], dest, &my_address,
|
|
||||||
npdu_data);
|
|
||||||
/* encode the APDU portion of the packet */
|
/* encode the APDU portion of the packet */
|
||||||
apdu_len =
|
apdu_len =
|
||||||
iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(),
|
iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(),
|
||||||
@@ -186,4 +184,3 @@ void Send_I_Am_Unicast(
|
|||||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,9 +155,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) {
|
||||||
|
|||||||
@@ -144,8 +144,7 @@ static void packet_statistics(
|
|||||||
if (dst > MSTP_Statistics[src].max_master) {
|
if (dst > MSTP_Statistics[src].max_master) {
|
||||||
MSTP_Statistics[src].max_master = dst;
|
MSTP_Statistics[src].max_master = dst;
|
||||||
}
|
}
|
||||||
if ((old_frame == FRAME_TYPE_POLL_FOR_MASTER) &&
|
if ((old_frame == FRAME_TYPE_POLL_FOR_MASTER) && (old_src == src)) {
|
||||||
(old_src == src)) {
|
|
||||||
/* Tusage_timeout */
|
/* Tusage_timeout */
|
||||||
delta = timeval_diff_ms(&old_tv, tv);
|
delta = timeval_diff_ms(&old_tv, tv);
|
||||||
if (delta > MSTP_Statistics[src].tusage_timeout) {
|
if (delta > MSTP_Statistics[src].tusage_timeout) {
|
||||||
@@ -212,9 +211,8 @@ static void packet_statistics_save(
|
|||||||
fprintf(stdout, "\r\n");
|
fprintf(stdout, "\r\n");
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
/* check for masters or slaves */
|
/* check for masters or slaves */
|
||||||
if ((MSTP_Statistics[i].token_count) ||
|
if ((MSTP_Statistics[i].token_count) || (MSTP_Statistics[i].der_reply)
|
||||||
(MSTP_Statistics[i].der_reply) ||
|
|| (MSTP_Statistics[i].pfm_count)) {
|
||||||
(MSTP_Statistics[i].pfm_count)) {
|
|
||||||
fprintf(stdout, "%u\t%u", i,
|
fprintf(stdout, "%u\t%u", i,
|
||||||
(unsigned) MSTP_Statistics[i].max_master);
|
(unsigned) MSTP_Statistics[i].max_master);
|
||||||
fprintf(stdout, "\t%lu\t%lu\t%lu\t%lu",
|
fprintf(stdout, "\t%lu\t%lu\t%lu\t%lu",
|
||||||
@@ -379,6 +377,7 @@ size_t data_write(
|
|||||||
}
|
}
|
||||||
return fwrite(ptr, size, nitems, pFile);
|
return fwrite(ptr, size, nitems, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t data_write_header(
|
size_t data_write_header(
|
||||||
const void *ptr,
|
const void *ptr,
|
||||||
size_t size,
|
size_t size,
|
||||||
@@ -425,9 +424,12 @@ 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) data_write_header(&magic_number, sizeof(magic_number), 1, pipe_enable);
|
(void) data_write_header(&magic_number, sizeof(magic_number), 1,
|
||||||
(void) data_write_header(&version_major, sizeof(version_major), 1, pipe_enable);
|
pipe_enable);
|
||||||
(void) data_write_header(&version_minor, sizeof(version_minor), 1, pipe_enable);
|
(void) data_write_header(&version_major, sizeof(version_major), 1,
|
||||||
|
pipe_enable);
|
||||||
|
(void) data_write_header(&version_minor, sizeof(version_minor), 1,
|
||||||
|
pipe_enable);
|
||||||
(void) data_write_header(&thiszone, sizeof(thiszone), 1, pipe_enable);
|
(void) data_write_header(&thiszone, sizeof(thiszone), 1, pipe_enable);
|
||||||
(void) data_write_header(&sigfigs, sizeof(sigfigs), 1, pipe_enable);
|
(void) data_write_header(&sigfigs, sizeof(sigfigs), 1, pipe_enable);
|
||||||
(void) data_write_header(&snaplen, sizeof(snaplen), 1, pipe_enable);
|
(void) data_write_header(&snaplen, sizeof(snaplen), 1, pipe_enable);
|
||||||
|
|||||||
@@ -177,8 +177,7 @@ int Analog_Input_Read_Property(
|
|||||||
BACNET_CHARACTER_STRING char_string;
|
BACNET_CHARACTER_STRING char_string;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -242,8 +241,7 @@ int Analog_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -284,8 +282,7 @@ void testAnalogInput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ char *Analog_Output_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_ANALOG_OUTPUTS) {
|
if (object_instance < MAX_ANALOG_OUTPUTS) {
|
||||||
sprintf(text_string, "ANALOG OUTPUT %lu", (unsigned long)object_instance);
|
sprintf(text_string, "ANALOG OUTPUT %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,8 +281,7 @@ int Analog_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -320,7 +320,8 @@ int Analog_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Analog_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Output_Out_Of_Service[object_index];
|
state = Analog_Output_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -361,12 +362,13 @@ int Analog_Output_Read_Property(
|
|||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Analog_Output_Level[object_index][rpdata->array_index - 1] ==
|
if (Analog_Output_Level[object_index][rpdata->array_index -
|
||||||
AO_LEVEL_NULL)
|
1] == AO_LEVEL_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Analog_Output_Level[object_index][rpdata->array_index - 1];
|
Analog_Output_Level[object_index][rpdata->
|
||||||
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -388,8 +390,7 @@ int Analog_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -435,17 +436,17 @@ bool Analog_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = AO_LEVEL_NULL;
|
level = AO_LEVEL_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
Analog_Output_Instance_To_Index(wp_data->
|
||||||
|
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;
|
||||||
@@ -454,10 +455,9 @@ bool Analog_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
||||||
@@ -502,8 +502,7 @@ void testAnalogOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,8 @@ char *Analog_Value_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_ANALOG_VALUES) {
|
if (object_instance < MAX_ANALOG_VALUES) {
|
||||||
sprintf(text_string, "ANALOG VALUE %lu", (unsigned long)object_instance);
|
sprintf(text_string, "ANALOG VALUE %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +229,7 @@ int Analog_Value_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,8 @@ int Analog_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Value_Out_Of_Service[object_index];
|
state = Analog_Value_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -283,7 +284,8 @@ int Analog_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. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->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 (Analog_Value_Level[object_index][i] ==
|
if (Analog_Value_Level[object_index][i] ==
|
||||||
@@ -306,14 +308,16 @@ int Analog_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Analog_Value_Level[object_index][rpdata->array_index - 1] ==
|
if (Analog_Value_Level[object_index][rpdata->array_index -
|
||||||
ANALOG_LEVEL_NULL)
|
1] == ANALOG_LEVEL_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Analog_Value_Level[object_index][rpdata->array_index - 1];
|
Analog_Value_Level[object_index][rpdata->
|
||||||
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -335,8 +339,7 @@ int Analog_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -383,14 +386,14 @@ bool Analog_Value_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = ANALOG_LEVEL_NULL;
|
level = ANALOG_LEVEL_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
Analog_Value_Instance_To_Index(wp_data->
|
||||||
|
object_instance);
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
@@ -410,10 +413,9 @@ bool Analog_Value_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
||||||
@@ -457,8 +459,7 @@ void testAnalog_Value(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -194,8 +194,7 @@ int bacfile_read_property(
|
|||||||
BACNET_TIME btime;
|
BACNET_TIME btime;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -207,7 +206,8 @@ int bacfile_read_property(
|
|||||||
rpdata->object_instance);
|
rpdata->object_instance);
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
sprintf(text_string, "FILE %lu", (unsigned long)rpdata->object_instance);
|
sprintf(text_string, "FILE %lu",
|
||||||
|
(unsigned long) rpdata->object_instance);
|
||||||
characterstring_init_ansi(&char_string, text_string);
|
characterstring_init_ansi(&char_string, text_string);
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
@@ -302,10 +302,9 @@ bool bacfile_write_property(
|
|||||||
property shall be logical TRUE only if no changes have been
|
property shall be logical TRUE only if no changes have been
|
||||||
made to the file data by internal processes or through File
|
made to the file data by internal processes or through File
|
||||||
Access Services since the last time the object was archived. */
|
Access Services since the last time the object was archived. */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Boolean) {
|
if (value.type.Boolean) {
|
||||||
/* FIXME: do something to wp_data->object_instance */
|
/* FIXME: do something to wp_data->object_instance */
|
||||||
@@ -318,10 +317,9 @@ bool bacfile_write_property(
|
|||||||
/* If the file size can be changed by writing to the file,
|
/* If the file size can be changed by writing to the file,
|
||||||
and File_Access_Method is STREAM_ACCESS, then this property
|
and File_Access_Method is STREAM_ACCESS, then this property
|
||||||
shall be writable. */
|
shall be writable. */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* FIXME: do something with value.type.Unsigned
|
/* FIXME: do something with value.type.Unsigned
|
||||||
to wp_data->object_instance */
|
to wp_data->object_instance */
|
||||||
|
|||||||
@@ -287,7 +287,8 @@ char *Binary_Input_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_INPUTS) {
|
if (object_instance < MAX_BINARY_INPUTS) {
|
||||||
sprintf(text_string, "BINARY INPUT %lu", (unsigned long)object_instance);
|
sprintf(text_string, "BINARY INPUT %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,8 +306,7 @@ int Binary_Input_Read_Property(
|
|||||||
BACNET_POLARITY polarity = POLARITY_NORMAL;
|
BACNET_POLARITY polarity = POLARITY_NORMAL;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -370,8 +370,7 @@ int Binary_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -396,10 +395,9 @@ bool Binary_Input_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
||||||
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
||||||
@@ -412,10 +410,9 @@ bool Binary_Input_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Binary_Input_Out_Of_Service_Set(wp_data->object_instance,
|
Binary_Input_Out_Of_Service_Set(wp_data->object_instance,
|
||||||
value.type.Boolean);
|
value.type.Boolean);
|
||||||
@@ -457,8 +454,7 @@ void testBinaryInput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ char *Binary_Output_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_OUTPUTS) {
|
if (object_instance < MAX_BINARY_OUTPUTS) {
|
||||||
sprintf(text_string, "BINARY OUTPUT %lu", (unsigned long)object_instance);
|
sprintf(text_string, "BINARY OUTPUT %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,8 +206,7 @@ int Binary_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,8 @@ int Binary_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], OBJECT_BINARY_OUTPUT);
|
encode_application_enumerated(&apdu[0], OBJECT_BINARY_OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Output_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -249,7 +250,8 @@ int Binary_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Binary_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Binary_Output_Out_Of_Service[object_index];
|
state = Binary_Output_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -290,12 +292,13 @@ int Binary_Output_Read_Property(
|
|||||||
object_index =
|
object_index =
|
||||||
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Binary_Output_Level[object_index][rpdata->array_index - 1] ==
|
if (Binary_Output_Level[object_index][rpdata->array_index -
|
||||||
BINARY_NULL)
|
1] == BINARY_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[apdu_len]);
|
apdu_len = encode_application_null(&apdu[apdu_len]);
|
||||||
else {
|
else {
|
||||||
present_value =
|
present_value =
|
||||||
Binary_Output_Level[object_index][rpdata->array_index - 1];
|
Binary_Output_Level[object_index][rpdata->
|
||||||
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_enumerated(&apdu[apdu_len],
|
encode_application_enumerated(&apdu[apdu_len],
|
||||||
present_value);
|
present_value);
|
||||||
@@ -329,8 +332,7 @@ int Binary_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -369,8 +371,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
|
||||||
@@ -390,14 +392,14 @@ bool Binary_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = BINARY_NULL;
|
level = BINARY_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
Binary_Output_Instance_To_Index(wp_data->
|
||||||
|
object_instance);
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
@@ -417,10 +419,9 @@ bool Binary_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
||||||
@@ -465,8 +466,7 @@ void testBinaryOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ char *Binary_Value_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_VALUES) {
|
if (object_instance < MAX_BINARY_VALUES) {
|
||||||
sprintf(text_string, "BINARY VALUE %lu", (unsigned long)object_instance);
|
sprintf(text_string, "BINARY VALUE %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,8 +202,7 @@ int Binary_Value_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,8 @@ int Binary_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Value_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Value_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -245,7 +246,8 @@ int Binary_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Binary_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Binary_Value_Out_Of_Service[object_index];
|
state = Binary_Value_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -257,7 +259,8 @@ int Binary_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. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
object_index = Binary_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(rpdata->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 (Binary_Value_Level[object_index][i] == BINARY_NULL)
|
if (Binary_Value_Level[object_index][i] == BINARY_NULL)
|
||||||
@@ -279,14 +282,16 @@ int Binary_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index = Binary_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Binary_Value_Level[object_index][rpdata->array_index] ==
|
if (Binary_Value_Level[object_index][rpdata->
|
||||||
BINARY_NULL)
|
array_index] == BINARY_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[apdu_len]);
|
apdu_len = encode_application_null(&apdu[apdu_len]);
|
||||||
else {
|
else {
|
||||||
present_value =
|
present_value =
|
||||||
Binary_Value_Level[object_index][rpdata->array_index];
|
Binary_Value_Level[object_index][rpdata->
|
||||||
|
array_index];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_enumerated(&apdu[apdu_len],
|
encode_application_enumerated(&apdu[apdu_len],
|
||||||
present_value);
|
present_value);
|
||||||
@@ -310,8 +315,7 @@ int Binary_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -350,8 +354,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
|
||||||
@@ -371,14 +375,14 @@ bool Binary_Value_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = BINARY_NULL;
|
level = BINARY_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Binary_Value_Instance_To_Index(wp_data->object_instance);
|
Binary_Value_Instance_To_Index(wp_data->
|
||||||
|
object_instance);
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
@@ -398,12 +402,12 @@ bool Binary_Value_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index = Binary_Value_Instance_To_Index(wp_data->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(wp_data->object_instance);
|
||||||
Binary_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
Binary_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -444,8 +448,7 @@ void testBinary_Value(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
+147
-242
@@ -95,154 +95,76 @@ static struct object_functions {
|
|||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
rr_info_function Object_RR_Info;
|
rr_info_function Object_RR_Info;
|
||||||
object_iterate_function Object_Iterator;
|
object_iterate_function Object_Iterator;
|
||||||
} Object_Table[] =
|
} Object_Table[] = {
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
OBJECT_DEVICE, NULL, Device_Count, Device_Index_To_Instance,
|
||||||
NULL,
|
Device_Valid_Object_Instance_Number, Device_Name,
|
||||||
Device_Count,
|
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||||
Device_Index_To_Instance,
|
Device_Property_Lists, DeviceGetRRInfo, NULL}, {
|
||||||
Device_Valid_Object_Instance_Number,
|
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||||
Device_Name,
|
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||||
Device_Read_Property_Local,
|
Analog_Input_Name, Analog_Input_Read_Property, NULL,
|
||||||
Device_Write_Property_Local,
|
Analog_Input_Property_Lists, NULL, NULL}, {
|
||||||
Device_Property_Lists,
|
OBJECT_ANALOG_OUTPUT, Analog_Output_Init, Analog_Output_Count,
|
||||||
DeviceGetRRInfo,
|
Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance,
|
||||||
NULL},
|
Analog_Output_Name, Analog_Output_Read_Property,
|
||||||
{OBJECT_ANALOG_INPUT,
|
Analog_Output_Write_Property, Analog_Output_Property_Lists,
|
||||||
Analog_Input_Init,
|
NULL, NULL}, {
|
||||||
Analog_Input_Count,
|
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||||
Analog_Input_Index_To_Instance,
|
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||||
Analog_Input_Valid_Instance,
|
Analog_Value_Name, Analog_Value_Read_Property,
|
||||||
Analog_Input_Name,
|
Analog_Value_Write_Property, Analog_Value_Property_Lists, NULL,
|
||||||
Analog_Input_Read_Property,
|
NULL}, {
|
||||||
NULL,
|
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||||
Analog_Input_Property_Lists,
|
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||||
NULL,
|
Binary_Input_Name, Binary_Input_Read_Property, NULL,
|
||||||
NULL},
|
Binary_Input_Property_Lists, NULL, NULL}, {
|
||||||
{OBJECT_ANALOG_OUTPUT,
|
OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count,
|
||||||
Analog_Output_Init,
|
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||||
Analog_Output_Count,
|
Binary_Output_Name, Binary_Output_Read_Property,
|
||||||
Analog_Output_Index_To_Instance,
|
Binary_Output_Write_Property, Binary_Output_Property_Lists,
|
||||||
Analog_Output_Valid_Instance,
|
NULL, NULL}, {
|
||||||
Analog_Output_Name,
|
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
|
||||||
Analog_Output_Read_Property,
|
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
|
||||||
Analog_Output_Write_Property,
|
Binary_Value_Name, Binary_Value_Read_Property,
|
||||||
Analog_Output_Property_Lists,
|
Binary_Value_Write_Property, Binary_Value_Property_Lists, NULL,
|
||||||
NULL,
|
NULL}, {
|
||||||
NULL},
|
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init,
|
||||||
{OBJECT_ANALOG_VALUE,
|
Life_Safety_Point_Count, Life_Safety_Point_Index_To_Instance,
|
||||||
Analog_Value_Init,
|
Life_Safety_Point_Valid_Instance, Life_Safety_Point_Name,
|
||||||
Analog_Value_Count,
|
|
||||||
Analog_Value_Index_To_Instance,
|
|
||||||
Analog_Value_Valid_Instance,
|
|
||||||
Analog_Value_Name,
|
|
||||||
Analog_Value_Read_Property,
|
|
||||||
Analog_Value_Write_Property,
|
|
||||||
Analog_Value_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_BINARY_INPUT,
|
|
||||||
Binary_Input_Init,
|
|
||||||
Binary_Input_Count,
|
|
||||||
Binary_Input_Index_To_Instance,
|
|
||||||
Binary_Input_Valid_Instance,
|
|
||||||
Binary_Input_Name,
|
|
||||||
Binary_Input_Read_Property,
|
|
||||||
NULL,
|
|
||||||
Binary_Input_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_BINARY_OUTPUT,
|
|
||||||
Binary_Output_Init,
|
|
||||||
Binary_Output_Count,
|
|
||||||
Binary_Output_Index_To_Instance,
|
|
||||||
Binary_Output_Valid_Instance,
|
|
||||||
Binary_Output_Name,
|
|
||||||
Binary_Output_Read_Property,
|
|
||||||
Binary_Output_Write_Property,
|
|
||||||
Binary_Output_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_BINARY_VALUE,
|
|
||||||
Binary_Value_Init,
|
|
||||||
Binary_Value_Count,
|
|
||||||
Binary_Value_Index_To_Instance,
|
|
||||||
Binary_Value_Valid_Instance,
|
|
||||||
Binary_Value_Name,
|
|
||||||
Binary_Value_Read_Property,
|
|
||||||
Binary_Value_Write_Property,
|
|
||||||
Binary_Value_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_LIFE_SAFETY_POINT,
|
|
||||||
Life_Safety_Point_Init,
|
|
||||||
Life_Safety_Point_Count,
|
|
||||||
Life_Safety_Point_Index_To_Instance,
|
|
||||||
Life_Safety_Point_Valid_Instance,
|
|
||||||
Life_Safety_Point_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, NULL}, {
|
||||||
NULL,
|
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count,
|
||||||
NULL},
|
Load_Control_Index_To_Instance, Load_Control_Valid_Instance,
|
||||||
{OBJECT_LOAD_CONTROL,
|
Load_Control_Name, Load_Control_Read_Property,
|
||||||
Load_Control_Init,
|
Load_Control_Write_Property, Load_Control_Property_Lists, NULL,
|
||||||
Load_Control_Count,
|
NULL}, {
|
||||||
Load_Control_Index_To_Instance,
|
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
|
||||||
Load_Control_Valid_Instance,
|
Multistate_Output_Count, Multistate_Output_Index_To_Instance,
|
||||||
Load_Control_Name,
|
Multistate_Output_Valid_Instance, Multistate_Output_Name,
|
||||||
Load_Control_Read_Property,
|
|
||||||
Load_Control_Write_Property,
|
|
||||||
Load_Control_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_MULTI_STATE_OUTPUT,
|
|
||||||
Multistate_Output_Init,
|
|
||||||
Multistate_Output_Count,
|
|
||||||
Multistate_Output_Index_To_Instance,
|
|
||||||
Multistate_Output_Valid_Instance,
|
|
||||||
Multistate_Output_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, NULL}, {
|
||||||
NULL,
|
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init,
|
||||||
NULL},
|
Multistate_Input_Count, Multistate_Input_Index_To_Instance,
|
||||||
{OBJECT_MULTI_STATE_INPUT,
|
Multistate_Input_Valid_Instance, Multistate_Input_Name,
|
||||||
Multistate_Input_Init,
|
|
||||||
Multistate_Input_Count,
|
|
||||||
Multistate_Input_Index_To_Instance,
|
|
||||||
Multistate_Input_Valid_Instance,
|
|
||||||
Multistate_Input_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, NULL}, {
|
||||||
NULL,
|
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
|
||||||
NULL},
|
Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance,
|
||||||
{OBJECT_TRENDLOG,
|
Trend_Log_Name, Trend_Log_Read_Property,
|
||||||
Trend_Log_Init,
|
Trend_Log_Write_Property, Trend_Log_Property_Lists,
|
||||||
Trend_Log_Count,
|
TrendLogGetRRInfo, NULL},
|
||||||
Trend_Log_Index_To_Instance,
|
|
||||||
Trend_Log_Valid_Instance,
|
|
||||||
Trend_Log_Name,
|
|
||||||
Trend_Log_Read_Property,
|
|
||||||
Trend_Log_Write_Property,
|
|
||||||
Trend_Log_Property_Lists,
|
|
||||||
TrendLogGetRRInfo,
|
|
||||||
NULL},
|
|
||||||
#if defined(BACFILE)
|
#if defined(BACFILE)
|
||||||
{OBJECT_FILE,
|
{
|
||||||
bacfile_init,
|
OBJECT_FILE, bacfile_init, bacfile_count, bacfile_index_to_instance,
|
||||||
bacfile_count,
|
bacfile_valid_instance, bacfile_name, bacfile_read_property,
|
||||||
bacfile_index_to_instance,
|
bacfile_write_property, BACfile_Property_Lists, NULL},
|
||||||
bacfile_valid_instance,
|
|
||||||
bacfile_name,
|
|
||||||
bacfile_read_property,
|
|
||||||
bacfile_write_property,
|
|
||||||
BACfile_Property_Lists,
|
|
||||||
NULL},
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Glue function to let the Device object, when called by a handler,
|
/** Glue function to let the Device object, when called by a handler,
|
||||||
@@ -281,7 +203,6 @@ static struct object_functions * Device_Objects_Find_Functions(
|
|||||||
*/
|
*/
|
||||||
rr_info_function Device_Objects_RR_Info(
|
rr_info_function Device_Objects_RR_Info(
|
||||||
BACNET_OBJECT_TYPE object_type)
|
BACNET_OBJECT_TYPE object_type)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
|
|
||||||
@@ -332,21 +253,22 @@ void Device_Objects_Property_List(
|
|||||||
|
|
||||||
pObject = Device_Objects_Find_Functions(object_type);
|
pObject = Device_Objects_Find_Functions(object_type);
|
||||||
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
||||||
pObject->Object_RPM_List(
|
pObject->Object_RPM_List(&pPropertyList->Required.pList,
|
||||||
&pPropertyList->Required.pList,
|
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||||
&pPropertyList->Optional.pList,
|
|
||||||
&pPropertyList->Proprietary.pList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch the counts if available otherwise zero them */
|
/* Fetch the counts if available otherwise zero them */
|
||||||
pPropertyList->Required.count = pPropertyList->Required.pList == NULL
|
pPropertyList->Required.count =
|
||||||
? 0 : property_list_count(pPropertyList->Required.pList);
|
pPropertyList->Required.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Required.pList);
|
||||||
|
|
||||||
pPropertyList->Optional.count = pPropertyList->Optional.pList == NULL
|
pPropertyList->Optional.count =
|
||||||
? 0 : property_list_count(pPropertyList->Optional.pList);
|
pPropertyList->Optional.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Optional.pList);
|
||||||
|
|
||||||
pPropertyList->Proprietary.count = pPropertyList->Proprietary.pList == NULL
|
pPropertyList->Proprietary.count =
|
||||||
? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
pPropertyList->Proprietary.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -517,7 +439,8 @@ static uint32_t Database_Revision = 0;
|
|||||||
/* Slave_Address_Binding */
|
/* Slave_Address_Binding */
|
||||||
/* Profile_Name */
|
/* Profile_Name */
|
||||||
|
|
||||||
unsigned Device_Count(void)
|
unsigned Device_Count(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -551,8 +474,7 @@ bool Device_Set_Object_Instance_Number(
|
|||||||
/* Make the change and update the database revision */
|
/* Make the change and update the database revision */
|
||||||
Object_Instance_Number = object_id;
|
Object_Instance_Number = object_id;
|
||||||
Device_Inc_Database_Revision();
|
Device_Inc_Database_Revision();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
status = false;
|
status = false;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@@ -897,7 +819,8 @@ bool Device_Object_List_Identifier(
|
|||||||
}
|
}
|
||||||
if (pObject->Object_Index_To_Instance) {
|
if (pObject->Object_Index_To_Instance) {
|
||||||
*object_type = pObject->Object_Type;
|
*object_type = pObject->Object_Type;
|
||||||
*instance = pObject->Object_Index_To_Instance(object_index);
|
*instance =
|
||||||
|
pObject->Object_Index_To_Instance(object_index);
|
||||||
status = true;
|
status = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -969,7 +892,8 @@ char *Device_Valid_Object_Id(
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Update_Current_Time(void)
|
static void Update_Current_Time(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
struct tm *tblock = NULL;
|
struct tm *tblock = NULL;
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
@@ -1000,25 +924,15 @@ int tm_isdst Daylight Savings flag.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tblock) {
|
if (tblock) {
|
||||||
datetime_set_date(
|
datetime_set_date(&Local_Date, (uint16_t) tblock->tm_year + 1900,
|
||||||
&Local_Date,
|
(uint8_t) tblock->tm_mon + 1, (uint8_t) tblock->tm_mday);
|
||||||
(uint16_t) tblock->tm_year+1900,
|
|
||||||
(uint8_t) tblock->tm_mon+1,
|
|
||||||
(uint8_t) tblock->tm_mday);
|
|
||||||
#if !defined(_MSC_VER)
|
#if !defined(_MSC_VER)
|
||||||
datetime_set_time(
|
datetime_set_time(&Local_Time, (uint8_t) tblock->tm_hour,
|
||||||
&Local_Time,
|
(uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec,
|
||||||
(uint8_t) tblock->tm_hour,
|
|
||||||
(uint8_t) tblock->tm_min,
|
|
||||||
(uint8_t) tblock->tm_sec,
|
|
||||||
(uint8_t) (tv.tv_usec / 10000));
|
(uint8_t) (tv.tv_usec / 10000));
|
||||||
#else
|
#else
|
||||||
datetime_set_time(
|
datetime_set_time(&Local_Time, (uint8_t) tblock->tm_hour,
|
||||||
&Local_Time,
|
(uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec, 0);
|
||||||
(uint8_t) tblock->tm_hour,
|
|
||||||
(uint8_t) tblock->tm_min,
|
|
||||||
(uint8_t) tblock->tm_sec,
|
|
||||||
0);
|
|
||||||
#endif
|
#endif
|
||||||
if (tblock->tm_isdst) {
|
if (tblock->tm_isdst) {
|
||||||
Daylight_Savings_Status = true;
|
Daylight_Savings_Status = true;
|
||||||
@@ -1051,8 +965,7 @@ static int Device_Read_Property_Local(
|
|||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1162,8 +1075,7 @@ static int Device_Read_Property_Local(
|
|||||||
|
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Count) &&
|
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
|
||||||
(pObject->Object_Count() > 0)) {
|
|
||||||
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
||||||
}
|
}
|
||||||
pObject++;
|
pObject++;
|
||||||
@@ -1181,9 +1093,8 @@ static int Device_Read_Property_Local(
|
|||||||
/* your maximum APDU size. */
|
/* your maximum APDU size. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
for (i = 1; i <= count; i++) {
|
for (i = 1; i <= count; i++) {
|
||||||
found = Device_Object_List_Identifier(
|
found =
|
||||||
i,
|
Device_Object_List_Identifier(i, &object_type,
|
||||||
&object_type,
|
|
||||||
&instance);
|
&instance);
|
||||||
if (found) {
|
if (found) {
|
||||||
len =
|
len =
|
||||||
@@ -1206,10 +1117,9 @@ static int Device_Read_Property_Local(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
found = Device_Object_List_Identifier(
|
found =
|
||||||
rpdata->array_index,
|
Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&object_type,
|
&object_type, &instance);
|
||||||
&instance);
|
|
||||||
if (found) {
|
if (found) {
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
@@ -1265,8 +1175,7 @@ static int Device_Read_Property_Local(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
|
||||||
(rpdata->object_property != PROP_OBJECT_LIST) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -1329,13 +1238,13 @@ static bool Device_Write_Property_Local(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_OBJECT_IDENTIFIER:
|
case PROP_OBJECT_IDENTIFIER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_OBJECT_ID,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_OBJECT_ID,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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.Object_Id.instance))) {
|
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||||
|
instance))) {
|
||||||
/* FIXME: we could send an I-Am broadcast to let the world know */
|
/* FIXME: we could send an I-Am broadcast to let the world know */
|
||||||
} else {
|
} else {
|
||||||
status = false;
|
status = false;
|
||||||
@@ -1345,41 +1254,37 @@ static bool Device_Write_Property_Local(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* FIXME: bounds check? */
|
/* FIXME: bounds check? */
|
||||||
apdu_retries_set((uint8_t) value.type.Unsigned_Int);
|
apdu_retries_set((uint8_t) value.type.Unsigned_Int);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_APDU_TIMEOUT:
|
case PROP_APDU_TIMEOUT:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* FIXME: bounds check? */
|
/* FIXME: bounds check? */
|
||||||
apdu_timeout_set((uint16_t) value.type.Unsigned_Int);
|
apdu_timeout_set((uint16_t) value.type.Unsigned_Int);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_VENDOR_IDENTIFIER:
|
case PROP_VENDOR_IDENTIFIER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
temp = Device_Set_System_Status((BACNET_DEVICE_STATUS)
|
temp = Device_Set_System_Status((BACNET_DEVICE_STATUS)
|
||||||
value.type.Enumerated, false);
|
value.type.Enumerated, false);
|
||||||
@@ -1389,62 +1294,63 @@ static bool Device_Write_Property_Local(
|
|||||||
if (temp == -1) {
|
if (temp == -1) {
|
||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_code = ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_NAME_LEN,
|
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
|
||||||
false,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_class,
|
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Device_Set_Object_Name(characterstring_value(&value.type.Character_String), characterstring_length(&value.type.Character_String));
|
Device_Set_Object_Name(characterstring_value(&value.type.
|
||||||
|
Character_String),
|
||||||
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_LOC_LEN,
|
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
|
||||||
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.type.Character_String), characterstring_length(&value.type.Character_String));
|
Device_Set_Location(characterstring_value(&value.type.
|
||||||
|
Character_String),
|
||||||
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DESCRIPTION:
|
case PROP_DESCRIPTION:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_DESC_LEN,
|
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
|
||||||
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.type.Character_String), characterstring_length(&value.type.Character_String));
|
Device_Set_Description(characterstring_value(&value.type.
|
||||||
|
Character_String),
|
||||||
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_MODEL_NAME:
|
case PROP_MODEL_NAME:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_MOD_LEN,
|
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
|
||||||
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.type.Character_String), characterstring_length(&value.type.Character_String));
|
Device_Set_Model_Name(characterstring_value(&value.type.
|
||||||
|
Character_String),
|
||||||
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(BACDL_MSTP)
|
#if defined(BACDL_MSTP)
|
||||||
case PROP_MAX_INFO_FRAMES:
|
case PROP_MAX_INFO_FRAMES:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
@@ -1453,10 +1359,9 @@ static bool Device_Write_Property_Local(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_MASTER:
|
case PROP_MAX_MASTER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if ((value.type.Unsigned_Int > 0) &&
|
if ((value.type.Unsigned_Int > 0) &&
|
||||||
(value.type.Unsigned_Int <= 127)) {
|
(value.type.Unsigned_Int <= 127)) {
|
||||||
@@ -1538,8 +1443,8 @@ void Device_Init(
|
|||||||
|
|
||||||
bool DeviceGetRRInfo(
|
bool DeviceGetRRInfo(
|
||||||
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
RR_PROP_INFO *pInfo) /* Where to put the response */
|
RR_PROP_INFO * pInfo)
|
||||||
{
|
{ /* Where to put the response */
|
||||||
bool status = false; /* return value */
|
bool status = false; /* return value */
|
||||||
|
|
||||||
switch (pRequest->object_property) {
|
switch (pRequest->object_property) {
|
||||||
|
|||||||
@@ -692,8 +692,7 @@ int Load_Control_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -980,23 +979,22 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_START_TIME:
|
case PROP_START_TIME:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_DATE,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_DATE,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* don't continue if we don't have a valid date */
|
/* don't continue if we don't have a valid date */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Hold the date until we are sure the time is also there */
|
/* Hold the date until we are sure the time is also there */
|
||||||
TempDate = value.type.Date;
|
TempDate = value.type.Date;
|
||||||
len = bacapp_decode_application_data(wp_data->application_data + len,
|
len =
|
||||||
|
bacapp_decode_application_data(wp_data->application_data + len,
|
||||||
wp_data->application_data_len - len, &value);
|
wp_data->application_data_len - len, &value);
|
||||||
if (len) {
|
if (len) {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_TIME,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_TIME,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* Write time and date and set written flag */
|
/* Write time and date and set written flag */
|
||||||
Start_Time[object_index].date = TempDate;
|
Start_Time[object_index].date = TempDate;
|
||||||
@@ -1011,10 +1009,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SHED_DURATION:
|
case PROP_SHED_DURATION:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
||||||
Load_Control_Request_Written[object_index] = true;
|
Load_Control_Request_Written[object_index] = true;
|
||||||
@@ -1022,10 +1019,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DUTY_WINDOW:
|
case PROP_DUTY_WINDOW:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Duty_Window[object_index] = value.type.Unsigned_Int;
|
Duty_Window[object_index] = value.type.Unsigned_Int;
|
||||||
Load_Control_Request_Written[object_index] = true;
|
Load_Control_Request_Written[object_index] = true;
|
||||||
@@ -1033,10 +1029,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SHED_LEVELS:
|
case PROP_SHED_LEVELS:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* re-write the size of the array? */
|
/* re-write the size of the array? */
|
||||||
if (wp_data->array_index == 0) {
|
if (wp_data->array_index == 0) {
|
||||||
@@ -1059,10 +1054,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ENABLE:
|
case PROP_ENABLE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Load_Control_Enable[object_index] = value.type.Boolean;
|
Load_Control_Enable[object_index] = value.type.Boolean;
|
||||||
}
|
}
|
||||||
@@ -1485,8 +1479,7 @@ void testLoadControl(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -371,8 +371,7 @@ int Lighting_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -398,11 +397,13 @@ int Lighting_Output_Read_Property(
|
|||||||
OBJECT_LIGHTING_OUTPUT);
|
OBJECT_LIGHTING_OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
real_value = Lighting_Output_Present_Value(rpdata->object_instance);
|
real_value =
|
||||||
|
Lighting_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_real(&apdu[0], real_value);
|
apdu_len = encode_application_real(&apdu[0], real_value);
|
||||||
break;
|
break;
|
||||||
case PROP_PROGRESS_VALUE:
|
case PROP_PROGRESS_VALUE:
|
||||||
real_value = Lighting_Output_Progress_Value(rpdata->object_instance);
|
real_value =
|
||||||
|
Lighting_Output_Progress_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_real(&apdu[0], real_value);
|
apdu_len = encode_application_real(&apdu[0], real_value);
|
||||||
break;
|
break;
|
||||||
case PROP_LIGHTING_COMMAND:
|
case PROP_LIGHTING_COMMAND:
|
||||||
@@ -423,7 +424,8 @@ int Lighting_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Lighting_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Lighting_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Lighting_Output_Out_Of_Service[object_index];
|
state = Lighting_Output_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -465,13 +467,13 @@ 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 - 1] ==
|
if (Lighting_Output_Level[object_index][rpdata->
|
||||||
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 =
|
real_value =
|
||||||
Lighting_Output_Level[object_index][rpdata->array_index -
|
Lighting_Output_Level[object_index][rpdata->
|
||||||
1];
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -494,8 +496,7 @@ int Lighting_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -541,18 +542,17 @@ bool Lighting_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
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
|
||||||
@@ -574,14 +574,13 @@ bool Lighting_Output_Write_Property(
|
|||||||
&Lighting_Command[wp_data->object_instance]);
|
&Lighting_Command[wp_data->object_instance]);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
}
|
}
|
||||||
@@ -623,8 +622,7 @@ void testLightingOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -203,8 +203,7 @@ int Life_Safety_Point_Read_Property(
|
|||||||
BACNET_RELIABILITY reliability = RELIABILITY_NO_FAULT_DETECTED;
|
BACNET_RELIABILITY reliability = RELIABILITY_NO_FAULT_DETECTED;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -228,7 +227,8 @@ int Life_Safety_Point_Read_Property(
|
|||||||
OBJECT_LIFE_SAFETY_POINT);
|
OBJECT_LIFE_SAFETY_POINT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Life_Safety_Point_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Life_Safety_Point_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -286,8 +286,7 @@ int Life_Safety_Point_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -313,15 +312,14 @@ bool Life_Safety_Point_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
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 {
|
||||||
@@ -332,14 +330,13 @@ bool Life_Safety_Point_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
}
|
}
|
||||||
@@ -381,8 +378,7 @@ void testLifeSafetyPoint(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -330,8 +330,7 @@ int Multistate_Input_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -362,7 +361,8 @@ int Multistate_Input_Read_Property(
|
|||||||
OBJECT_MULTI_STATE_INPUT);
|
OBJECT_MULTI_STATE_INPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Multistate_Input_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Multistate_Input_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -380,7 +380,8 @@ int Multistate_Input_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Multistate_Input_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Multistate_Input_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;
|
||||||
@@ -399,10 +400,12 @@ 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(rpdata->object_instance);
|
Multistate_Input_Instance_To_Index(rpdata->
|
||||||
|
object_instance);
|
||||||
for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) {
|
for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) {
|
||||||
characterstring_init_ansi(&char_string,
|
characterstring_init_ansi(&char_string,
|
||||||
Multistate_Input_State_Text(rpdata->object_instance, i));
|
Multistate_Input_State_Text(rpdata->object_instance,
|
||||||
|
i));
|
||||||
/* FIXME: this might go beyond MAX_APDU length! */
|
/* FIXME: this might go beyond MAX_APDU length! */
|
||||||
len =
|
len =
|
||||||
encode_application_character_string(&apdu[apdu_len],
|
encode_application_character_string(&apdu[apdu_len],
|
||||||
@@ -419,7 +422,8 @@ int Multistate_Input_Read_Property(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index =
|
object_index =
|
||||||
Multistate_Input_Instance_To_Index(rpdata->object_instance);
|
Multistate_Input_Instance_To_Index(rpdata->
|
||||||
|
object_instance);
|
||||||
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
|
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,
|
||||||
@@ -441,8 +445,7 @@ int Multistate_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_STATE_TEXT) &&
|
||||||
(rpdata->object_property != PROP_STATE_TEXT) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -469,15 +472,14 @@ bool Multistate_Input_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (Out_Of_Service[object_index]) {
|
if (Out_Of_Service[object_index]) {
|
||||||
status = Multistate_Input_Present_Value_Set(
|
status =
|
||||||
wp_data->object_instance,
|
Multistate_Input_Present_Value_Set(wp_data->
|
||||||
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;
|
||||||
@@ -490,14 +492,13 @@ bool Multistate_Input_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Multistate_Input_Instance_To_Index
|
Multistate_Input_Instance_To_Index(wp_data->
|
||||||
(wp_data->object_instance);
|
object_instance);
|
||||||
Out_Of_Service[object_index] = value.type.Boolean;
|
Out_Of_Service[object_index] = value.type.Boolean;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -538,8 +539,7 @@ void testMultistateInput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -207,8 +207,7 @@ int Multistate_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -234,7 +233,8 @@ int Multistate_Output_Read_Property(
|
|||||||
OBJECT_MULTI_STATE_OUTPUT);
|
OBJECT_MULTI_STATE_OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Multistate_Output_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Multistate_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -266,7 +266,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(rpdata->object_instance);
|
Multistate_Output_Instance_To_Index(rpdata->
|
||||||
|
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] ==
|
||||||
@@ -291,15 +292,16 @@ int Multistate_Output_Read_Property(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index =
|
object_index =
|
||||||
Multistate_Output_Instance_To_Index(rpdata->object_instance);
|
Multistate_Output_Instance_To_Index(rpdata->
|
||||||
|
object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Multistate_Output_Level[object_index][rpdata->array_index -
|
if (Multistate_Output_Level[object_index][rpdata->
|
||||||
1] == MULTISTATE_NULL)
|
array_index - 1] == MULTISTATE_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
present_value =
|
present_value =
|
||||||
Multistate_Output_Level[object_index][rpdata->array_index -
|
Multistate_Output_Level[object_index][rpdata->
|
||||||
1];
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_unsigned(&apdu[0],
|
encode_application_unsigned(&apdu[0],
|
||||||
present_value);
|
present_value);
|
||||||
@@ -329,8 +331,7 @@ int Multistate_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -369,8 +370,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;
|
||||||
@@ -391,15 +392,14 @@ bool Multistate_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
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--;
|
||||||
@@ -420,14 +420,13 @@ bool Multistate_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
}
|
}
|
||||||
@@ -469,8 +468,7 @@ void testMultistateOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
+282
-161
@@ -205,7 +205,8 @@ void Trend_Log_Init(
|
|||||||
for (iEntry = 0; iEntry < TL_MAX_ENTRIES; iEntry++) {
|
for (iEntry = 0; iEntry < TL_MAX_ENTRIES; iEntry++) {
|
||||||
Logs[iLog][iEntry].tTimeStamp = tClock;
|
Logs[iLog][iEntry].tTimeStamp = tClock;
|
||||||
Logs[iLog][iEntry].ucRecType = TL_TYPE_REAL;
|
Logs[iLog][iEntry].ucRecType = TL_TYPE_REAL;
|
||||||
Logs[iLog][iEntry].Datum.fReal = (float)(iEntry + (iLog * TL_MAX_ENTRIES));
|
Logs[iLog][iEntry].Datum.fReal =
|
||||||
|
(float) (iEntry + (iLog * TL_MAX_ENTRIES));
|
||||||
/* Put status flags with every second log */
|
/* Put status flags with every second log */
|
||||||
if ((iLog & 1) == 0)
|
if ((iLog & 1) == 0)
|
||||||
Logs[iLog][iEntry].ucStatus = 128;
|
Logs[iLog][iEntry].ucStatus = 128;
|
||||||
@@ -228,17 +229,22 @@ void Trend_Log_Init(
|
|||||||
LogInfo[iLog].ulRecordCount = 1000;
|
LogInfo[iLog].ulRecordCount = 1000;
|
||||||
LogInfo[iLog].ulTotalRecordCount = 10000;
|
LogInfo[iLog].ulTotalRecordCount = 10000;
|
||||||
|
|
||||||
LogInfo[iLog].Source.deviceIndentifier.instance = Device_Object_Instance_Number();
|
LogInfo[iLog].Source.deviceIndentifier.instance =
|
||||||
|
Device_Object_Instance_Number();
|
||||||
LogInfo[iLog].Source.deviceIndentifier.type = OBJECT_DEVICE;
|
LogInfo[iLog].Source.deviceIndentifier.type = OBJECT_DEVICE;
|
||||||
LogInfo[iLog].Source.objectIdentifier.instance = iLog;
|
LogInfo[iLog].Source.objectIdentifier.instance = iLog;
|
||||||
LogInfo[iLog].Source.objectIdentifier.type = OBJECT_ANALOG_INPUT;
|
LogInfo[iLog].Source.objectIdentifier.type = OBJECT_ANALOG_INPUT;
|
||||||
LogInfo[iLog].Source.arrayIndex = BACNET_ARRAY_ALL;
|
LogInfo[iLog].Source.arrayIndex = BACNET_ARRAY_ALL;
|
||||||
LogInfo[iLog].Source.propertyIdentifier = PROP_PRESENT_VALUE;
|
LogInfo[iLog].Source.propertyIdentifier = PROP_PRESENT_VALUE;
|
||||||
|
|
||||||
datetime_set_values(&LogInfo[iLog].StartTime, 2009, 1, 1, 0, 0, 0, 0);
|
datetime_set_values(&LogInfo[iLog].StartTime, 2009, 1, 1, 0, 0, 0,
|
||||||
LogInfo[iLog].tStartTime = TL_BAC_Time_To_Local(&LogInfo[iLog].StartTime);
|
0);
|
||||||
datetime_set_values(&LogInfo[iLog].StopTime, 2009, 12, 22, 23, 59, 59, 99);
|
LogInfo[iLog].tStartTime =
|
||||||
LogInfo[iLog].tStopTime = TL_BAC_Time_To_Local(&LogInfo[iLog].StopTime);
|
TL_BAC_Time_To_Local(&LogInfo[iLog].StartTime);
|
||||||
|
datetime_set_values(&LogInfo[iLog].StopTime, 2009, 12, 22, 23, 59,
|
||||||
|
59, 99);
|
||||||
|
LogInfo[iLog].tStopTime =
|
||||||
|
TL_BAC_Time_To_Local(&LogInfo[iLog].StopTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,8 +283,7 @@ int Trend_Log_Read_Property(
|
|||||||
TL_LOG_INFO *CurrentLog;
|
TL_LOG_INFO *CurrentLog;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -293,21 +298,26 @@ int Trend_Log_Read_Property(
|
|||||||
|
|
||||||
case PROP_DESCRIPTION:
|
case PROP_DESCRIPTION:
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
characterstring_init_ansi(&char_string, Trend_Log_Name(rpdata->object_instance));
|
characterstring_init_ansi(&char_string,
|
||||||
|
Trend_Log_Name(rpdata->object_instance));
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_OBJECT_TYPE:
|
case PROP_OBJECT_TYPE:
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], OBJECT_TRENDLOG);
|
apdu_len =
|
||||||
|
encode_application_enumerated(&apdu[0], OBJECT_TRENDLOG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ENABLE:
|
case PROP_ENABLE:
|
||||||
apdu_len = encode_application_boolean(&apdu[0], CurrentLog->bEnable);
|
apdu_len =
|
||||||
|
encode_application_boolean(&apdu[0], CurrentLog->bEnable);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_STOP_WHEN_FULL:
|
case PROP_STOP_WHEN_FULL:
|
||||||
apdu_len = encode_application_boolean(&apdu[0], CurrentLog->bStopWhenFull);
|
apdu_len =
|
||||||
|
encode_application_boolean(&apdu[0],
|
||||||
|
CurrentLog->bStopWhenFull);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_BUFFER_SIZE:
|
case PROP_BUFFER_SIZE:
|
||||||
@@ -322,20 +332,27 @@ int Trend_Log_Read_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_RECORD_COUNT:
|
case PROP_RECORD_COUNT:
|
||||||
apdu_len += encode_application_unsigned(&apdu[0], CurrentLog->ulRecordCount);
|
apdu_len +=
|
||||||
|
encode_application_unsigned(&apdu[0],
|
||||||
|
CurrentLog->ulRecordCount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_TOTAL_RECORD_COUNT:
|
case PROP_TOTAL_RECORD_COUNT:
|
||||||
apdu_len += encode_application_unsigned(&apdu[0], CurrentLog->ulTotalRecordCount);
|
apdu_len +=
|
||||||
|
encode_application_unsigned(&apdu[0],
|
||||||
|
CurrentLog->ulTotalRecordCount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_EVENT_STATE:
|
case PROP_EVENT_STATE:
|
||||||
/* note: see the details in the standard on how to use this */
|
/* note: see the details in the standard on how to use this */
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
apdu_len =
|
||||||
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_LOGGING_TYPE:
|
case PROP_LOGGING_TYPE:
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], CurrentLog->LoggingType);
|
apdu_len =
|
||||||
|
encode_application_enumerated(&apdu[0],
|
||||||
|
CurrentLog->LoggingType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -349,19 +366,21 @@ int Trend_Log_Read_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_START_TIME:
|
case PROP_START_TIME:
|
||||||
len = encode_application_date(&apdu[0],
|
len =
|
||||||
&CurrentLog->StartTime.date);
|
encode_application_date(&apdu[0], &CurrentLog->StartTime.date);
|
||||||
apdu_len = len;
|
apdu_len = len;
|
||||||
len = encode_application_time(&apdu[apdu_len],
|
len =
|
||||||
|
encode_application_time(&apdu[apdu_len],
|
||||||
&CurrentLog->StartTime.time);
|
&CurrentLog->StartTime.time);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_STOP_TIME:
|
case PROP_STOP_TIME:
|
||||||
len = encode_application_date(&apdu[0],
|
len =
|
||||||
&CurrentLog->StopTime.date);
|
encode_application_date(&apdu[0], &CurrentLog->StopTime.date);
|
||||||
apdu_len = len;
|
apdu_len = len;
|
||||||
len = encode_application_time(&apdu[apdu_len],
|
len =
|
||||||
|
encode_application_time(&apdu[apdu_len],
|
||||||
&CurrentLog->StopTime.time);
|
&CurrentLog->StopTime.time);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
@@ -377,25 +396,34 @@ int Trend_Log_Read_Property(
|
|||||||
* deviceIdentifier [3] BACnetObjectIdentifier OPTIONAL
|
* deviceIdentifier [3] BACnetObjectIdentifier OPTIONAL
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
apdu_len += bacapp_encode_device_obj_property_ref(&apdu[0], &CurrentLog->Source);
|
apdu_len +=
|
||||||
|
bacapp_encode_device_obj_property_ref(&apdu[0],
|
||||||
|
&CurrentLog->Source);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_LOG_INTERVAL:
|
case PROP_LOG_INTERVAL:
|
||||||
/* We only log to 1 sec accuracy so must multiply by 100 before passing it on */
|
/* We only log to 1 sec accuracy so must multiply by 100 before passing it on */
|
||||||
apdu_len += encode_application_unsigned(&apdu[0], CurrentLog->ulLogInterval * 100);
|
apdu_len +=
|
||||||
|
encode_application_unsigned(&apdu[0],
|
||||||
|
CurrentLog->ulLogInterval * 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ALIGN_INTERVALS:
|
case PROP_ALIGN_INTERVALS:
|
||||||
apdu_len = encode_application_boolean(&apdu[0], CurrentLog->bAlignIntervals);
|
apdu_len =
|
||||||
|
encode_application_boolean(&apdu[0],
|
||||||
|
CurrentLog->bAlignIntervals);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_INTERVAL_OFFSET:
|
case PROP_INTERVAL_OFFSET:
|
||||||
/* We only log to 1 sec accuracy so must multiply by 100 before passing it on */
|
/* We only log to 1 sec accuracy so must multiply by 100 before passing it on */
|
||||||
apdu_len += encode_application_unsigned(&apdu[0], CurrentLog->ulIntervalOffset * 100);
|
apdu_len +=
|
||||||
|
encode_application_unsigned(&apdu[0],
|
||||||
|
CurrentLog->ulIntervalOffset * 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_TRIGGER:
|
case PROP_TRIGGER:
|
||||||
apdu_len = encode_application_boolean(&apdu[0], CurrentLog->bTrigger);
|
apdu_len =
|
||||||
|
encode_application_boolean(&apdu[0], CurrentLog->bTrigger);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -405,9 +433,8 @@ int Trend_Log_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_EVENT_TIME_STAMPS)
|
||||||
(rpdata->object_property != PROP_EVENT_TIME_STAMPS) &&
|
&& (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -443,10 +470,9 @@ bool Trend_Log_Write_Property(
|
|||||||
|
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_ENABLE:
|
case PROP_ENABLE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* Section 12.25.5 can't enable a full log with stop when full set */
|
/* Section 12.25.5 can't enable a full log with stop when full set */
|
||||||
if ((CurrentLog->bEnable == false) &&
|
if ((CurrentLog->bEnable == false) &&
|
||||||
@@ -485,10 +511,9 @@ bool Trend_Log_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_STOP_WHEN_FULL:
|
case PROP_STOP_WHEN_FULL:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* Only trigger this on a change of state */
|
/* Only trigger this on a change of state */
|
||||||
if (CurrentLog->bStopWhenFull != value.type.Boolean) {
|
if (CurrentLog->bStopWhenFull != value.type.Boolean) {
|
||||||
@@ -502,7 +527,8 @@ bool Trend_Log_Write_Property(
|
|||||||
* disable the log and record the fact - see 135-2008 12.25.12
|
* disable the log and record the fact - see 135-2008 12.25.12
|
||||||
*/
|
*/
|
||||||
CurrentLog->bEnable = false;
|
CurrentLog->bEnable = false;
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_LOG_DISABLED, true);
|
TL_Insert_Status_Rec(log_index,
|
||||||
|
LOG_STATUS_LOG_DISABLED, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -518,16 +544,16 @@ bool Trend_Log_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_RECORD_COUNT:
|
case PROP_RECORD_COUNT:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Unsigned_Int == 0) {
|
if (value.type.Unsigned_Int == 0) {
|
||||||
/* Time to clear down the log */
|
/* Time to clear down the log */
|
||||||
CurrentLog->ulRecordCount = 0;
|
CurrentLog->ulRecordCount = 0;
|
||||||
CurrentLog->iIndex = 0;
|
CurrentLog->iIndex = 0;
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_BUFFER_PURGED, true);
|
TL_Insert_Status_Rec(log_index, LOG_STATUS_BUFFER_PURGED,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -536,10 +562,9 @@ bool Trend_Log_Write_Property(
|
|||||||
/* logic
|
/* logic
|
||||||
* triggered and polled options.
|
* triggered and polled options.
|
||||||
*/
|
*/
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Enumerated != LOGGING_TYPE_COV) {
|
if (value.type.Enumerated != LOGGING_TYPE_COV) {
|
||||||
CurrentLog->LoggingType = value.type.Enumerated;
|
CurrentLog->LoggingType = value.type.Enumerated;
|
||||||
@@ -557,30 +582,30 @@ bool Trend_Log_Write_Property(
|
|||||||
/* We don't currently support COV */
|
/* We don't currently support COV */
|
||||||
status = false;
|
status = false;
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_START_TIME:
|
case PROP_START_TIME:
|
||||||
/* Copy the date part to safe place */
|
/* Copy the date part to safe place */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_DATE,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_DATE,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TempDate = value.type.Date;
|
TempDate = value.type.Date;
|
||||||
/* Then decode the time part */
|
/* Then decode the time part */
|
||||||
len = bacapp_decode_application_data(wp_data->application_data + len,
|
len =
|
||||||
|
bacapp_decode_application_data(wp_data->application_data + len,
|
||||||
wp_data->application_data_len - len, &value);
|
wp_data->application_data_len - len, &value);
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_TIME,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_TIME,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -596,17 +621,20 @@ bool Trend_Log_Write_Property(
|
|||||||
} else {
|
} else {
|
||||||
/* Clear wild card flag and set time in local format */
|
/* Clear wild card flag and set time in local format */
|
||||||
CurrentLog->ucTimeFlags &= ~TL_T_START_WILD;
|
CurrentLog->ucTimeFlags &= ~TL_T_START_WILD;
|
||||||
CurrentLog->tStartTime = TL_BAC_Time_To_Local(&CurrentLog->StartTime);
|
CurrentLog->tStartTime =
|
||||||
|
TL_BAC_Time_To_Local(&CurrentLog->StartTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bEffectiveEnable != TL_Is_Enabled(log_index)) {
|
if (bEffectiveEnable != TL_Is_Enabled(log_index)) {
|
||||||
/* Enable status has changed because of time update */
|
/* Enable status has changed because of time update */
|
||||||
if (bEffectiveEnable == true) {
|
if (bEffectiveEnable == true) {
|
||||||
/* Say we went from enabled to disabled */
|
/* Say we went from enabled to disabled */
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_LOG_DISABLED, true);
|
TL_Insert_Status_Rec(log_index,
|
||||||
|
LOG_STATUS_LOG_DISABLED, true);
|
||||||
} else {
|
} else {
|
||||||
/* Say we went from disabled to enabled */
|
/* Say we went from disabled to enabled */
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_LOG_DISABLED, false);
|
TL_Insert_Status_Rec(log_index,
|
||||||
|
LOG_STATUS_LOG_DISABLED, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -614,23 +642,22 @@ bool Trend_Log_Write_Property(
|
|||||||
|
|
||||||
case PROP_STOP_TIME:
|
case PROP_STOP_TIME:
|
||||||
/* Copy the date part to safe place */
|
/* Copy the date part to safe place */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_DATE,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_DATE,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TempDate = value.type.Date;
|
TempDate = value.type.Date;
|
||||||
/* Then decode the time part */
|
/* Then decode the time part */
|
||||||
len = bacapp_decode_application_data(wp_data->application_data + len,
|
len =
|
||||||
|
bacapp_decode_application_data(wp_data->application_data + len,
|
||||||
wp_data->application_data_len - len, &value);
|
wp_data->application_data_len - len, &value);
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_TIME,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_TIME,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -646,17 +673,20 @@ bool Trend_Log_Write_Property(
|
|||||||
} else {
|
} else {
|
||||||
/* Clear wild card flag and set time in local format */
|
/* Clear wild card flag and set time in local format */
|
||||||
CurrentLog->ucTimeFlags &= ~TL_T_STOP_WILD;
|
CurrentLog->ucTimeFlags &= ~TL_T_STOP_WILD;
|
||||||
CurrentLog->tStopTime = TL_BAC_Time_To_Local(&CurrentLog->StopTime);
|
CurrentLog->tStopTime =
|
||||||
|
TL_BAC_Time_To_Local(&CurrentLog->StopTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bEffectiveEnable != TL_Is_Enabled(log_index)) {
|
if (bEffectiveEnable != TL_Is_Enabled(log_index)) {
|
||||||
/* Enable status has changed because of time update */
|
/* Enable status has changed because of time update */
|
||||||
if (bEffectiveEnable == true) {
|
if (bEffectiveEnable == true) {
|
||||||
/* Say we went from enabled to disabled */
|
/* Say we went from enabled to disabled */
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_LOG_DISABLED, true);
|
TL_Insert_Status_Rec(log_index,
|
||||||
|
LOG_STATUS_LOG_DISABLED, true);
|
||||||
} else {
|
} else {
|
||||||
/* Say we went from disabled to enabled */
|
/* Say we went from disabled to enabled */
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_LOG_DISABLED, false);
|
TL_Insert_Status_Rec(log_index,
|
||||||
|
LOG_STATUS_LOG_DISABLED, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -667,8 +697,12 @@ bool Trend_Log_Write_Property(
|
|||||||
TempSource.arrayIndex = BACNET_ARRAY_ALL; /* Need this so if no array index set we read properties in full */
|
TempSource.arrayIndex = BACNET_ARRAY_ALL; /* Need this so if no array index set we read properties in full */
|
||||||
|
|
||||||
/* First up is the object ID */
|
/* First up is the object ID */
|
||||||
len = bacapp_decode_context_data(wp_data->application_data, wp_data->application_data_len, &value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
len =
|
||||||
if((len == 0) || (value.context_tag != 0) || ((wp_data->application_data_len - len) == 0)) {
|
bacapp_decode_context_data(wp_data->application_data,
|
||||||
|
wp_data->application_data_len, &value,
|
||||||
|
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||||
|
if ((len == 0) || (value.context_tag != 0) ||
|
||||||
|
((wp_data->application_data_len - len) == 0)) {
|
||||||
/* Bad decode, wrong tag or following required parameter missing */
|
/* Bad decode, wrong tag or following required parameter missing */
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_OTHER;
|
wp_data->error_code = ERROR_CODE_OTHER;
|
||||||
@@ -679,7 +713,10 @@ bool Trend_Log_Write_Property(
|
|||||||
wp_data->application_data_len -= len;
|
wp_data->application_data_len -= len;
|
||||||
iOffset = len;
|
iOffset = len;
|
||||||
/* Second up is the property id */
|
/* Second up is the property id */
|
||||||
len = bacapp_decode_context_data(&wp_data->application_data[iOffset], wp_data->application_data_len, &value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
len =
|
||||||
|
bacapp_decode_context_data(&wp_data->application_data[iOffset],
|
||||||
|
wp_data->application_data_len, &value,
|
||||||
|
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||||
if ((len == 0) || (value.context_tag != 1)) {
|
if ((len == 0) || (value.context_tag != 1)) {
|
||||||
/* Bad decode or wrong tag */
|
/* Bad decode or wrong tag */
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
@@ -693,8 +730,12 @@ bool Trend_Log_Write_Property(
|
|||||||
/* If there is still more to come */
|
/* If there is still more to come */
|
||||||
if (wp_data->application_data_len != 0) {
|
if (wp_data->application_data_len != 0) {
|
||||||
iOffset += len;
|
iOffset += len;
|
||||||
len = bacapp_decode_context_data(&wp_data->application_data[iOffset], wp_data->application_data_len, &value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
len =
|
||||||
if((len == 0) || ((value.context_tag != 2) && (value.context_tag != 3))) {
|
bacapp_decode_context_data(&wp_data->
|
||||||
|
application_data[iOffset], wp_data->application_data_len,
|
||||||
|
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||||
|
if ((len == 0) || ((value.context_tag != 2) &&
|
||||||
|
(value.context_tag != 3))) {
|
||||||
/* Bad decode or wrong tag */
|
/* Bad decode or wrong tag */
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_OTHER;
|
wp_data->error_code = ERROR_CODE_OTHER;
|
||||||
@@ -708,7 +749,11 @@ bool Trend_Log_Write_Property(
|
|||||||
/* Still some remaining so fetch potential device ID */
|
/* Still some remaining so fetch potential device ID */
|
||||||
if (wp_data->application_data_len != 0) {
|
if (wp_data->application_data_len != 0) {
|
||||||
iOffset += len;
|
iOffset += len;
|
||||||
len = bacapp_decode_context_data(&wp_data->application_data[iOffset], wp_data->application_data_len, &value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
len =
|
||||||
|
bacapp_decode_context_data(&wp_data->
|
||||||
|
application_data[iOffset],
|
||||||
|
wp_data->application_data_len, &value,
|
||||||
|
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||||
if ((len == 0) || (value.context_tag != 3)) {
|
if ((len == 0) || (value.context_tag != 3)) {
|
||||||
/* Bad decode or wrong tag */
|
/* Bad decode or wrong tag */
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
@@ -721,24 +766,29 @@ bool Trend_Log_Write_Property(
|
|||||||
if (value.context_tag == 3) {
|
if (value.context_tag == 3) {
|
||||||
/* Got a device ID so deal with it */
|
/* Got a device ID so deal with it */
|
||||||
TempSource.deviceIndentifier = value.type.Object_Id;
|
TempSource.deviceIndentifier = value.type.Object_Id;
|
||||||
if((TempSource.deviceIndentifier.instance != Device_Object_Instance_Number()) ||
|
if ((TempSource.deviceIndentifier.instance !=
|
||||||
|
Device_Object_Instance_Number()) ||
|
||||||
(TempSource.deviceIndentifier.type != OBJECT_DEVICE)) {
|
(TempSource.deviceIndentifier.type != OBJECT_DEVICE)) {
|
||||||
/* Not our ID so can't handle it at the moment */
|
/* Not our ID so can't handle it at the moment */
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Make sure device ID is set to ours in case not supplied */
|
/* Make sure device ID is set to ours in case not supplied */
|
||||||
TempSource.deviceIndentifier.type = OBJECT_DEVICE;
|
TempSource.deviceIndentifier.type = OBJECT_DEVICE;
|
||||||
TempSource.deviceIndentifier.instance = Device_Object_Instance_Number();
|
TempSource.deviceIndentifier.instance =
|
||||||
|
Device_Object_Instance_Number();
|
||||||
/* Quick comparison if structures are packed ... */
|
/* Quick comparison if structures are packed ... */
|
||||||
if(memcmp(&TempSource, &CurrentLog->Source, sizeof(BACNET_OBJECT_ID)) != 0) {
|
if (memcmp(&TempSource, &CurrentLog->Source,
|
||||||
|
sizeof(BACNET_OBJECT_ID)) != 0) {
|
||||||
/* Clear buffer if property being logged is changed */
|
/* Clear buffer if property being logged is changed */
|
||||||
CurrentLog->ulRecordCount = 0;
|
CurrentLog->ulRecordCount = 0;
|
||||||
CurrentLog->iIndex = 0;
|
CurrentLog->iIndex = 0;
|
||||||
TL_Insert_Status_Rec(log_index, LOG_STATUS_BUFFER_PURGED, true);
|
TL_Insert_Status_Rec(log_index, LOG_STATUS_BUFFER_PURGED,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
CurrentLog->Source = TempSource;
|
CurrentLog->Source = TempSource;
|
||||||
status = true;
|
status = true;
|
||||||
@@ -751,17 +801,17 @@ bool Trend_Log_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
|
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
|
||||||
(value.type.Unsigned_Int == 0)) {
|
(value.type.Unsigned_Int == 0)) {
|
||||||
/* We don't support COV at the moment so don't allow switching
|
/* We don't support COV at the moment so don't allow switching
|
||||||
* to it by clearing interval whilst in polling mode */
|
* to it by clearing interval whilst in polling mode */
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||||
status = false;
|
status = false;
|
||||||
} else {
|
} else {
|
||||||
/* We only log to 1 sec accuracy so must divide by 100 before passing it on */
|
/* We only log to 1 sec accuracy so must divide by 100 before passing it on */
|
||||||
@@ -771,10 +821,9 @@ bool Trend_Log_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ALIGN_INTERVALS:
|
case PROP_ALIGN_INTERVALS:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
CurrentLog->bAlignIntervals = value.type.Boolean;
|
CurrentLog->bAlignIntervals = value.type.Boolean;
|
||||||
}
|
}
|
||||||
@@ -782,20 +831,18 @@ bool Trend_Log_Write_Property(
|
|||||||
|
|
||||||
case PROP_INTERVAL_OFFSET:
|
case PROP_INTERVAL_OFFSET:
|
||||||
/* We only log to 1 sec accuracy so must divide by 100 before passing it on */
|
/* We only log to 1 sec accuracy so must divide by 100 before passing it on */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
CurrentLog->ulIntervalOffset = value.type.Unsigned_Int / 100;
|
CurrentLog->ulIntervalOffset = value.type.Unsigned_Int / 100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_TRIGGER:
|
case PROP_TRIGGER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* We will not allow triggered operation if polling with aligning
|
/* We will not allow triggered operation if polling with aligning
|
||||||
* to the clock as that will produce non aligned readings which
|
* to the clock as that will produce non aligned readings which
|
||||||
@@ -804,7 +851,8 @@ bool Trend_Log_Write_Property(
|
|||||||
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
|
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
|
||||||
(CurrentLog->bAlignIntervals == true)) {
|
(CurrentLog->bAlignIntervals == true)) {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_NOT_CONFIGURED_FOR_TRIGGERED_LOGGING;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_NOT_CONFIGURED_FOR_TRIGGERED_LOGGING;
|
||||||
status = false;
|
status = false;
|
||||||
} else {
|
} else {
|
||||||
CurrentLog->bTrigger = value.type.Boolean;
|
CurrentLog->bTrigger = value.type.Boolean;
|
||||||
@@ -823,8 +871,8 @@ bool Trend_Log_Write_Property(
|
|||||||
|
|
||||||
bool TrendLogGetRRInfo(
|
bool TrendLogGetRRInfo(
|
||||||
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
RR_PROP_INFO *pInfo) /* Where to put the information */
|
RR_PROP_INFO * pInfo)
|
||||||
{
|
{ /* Where to put the information */
|
||||||
int log_index;
|
int log_index;
|
||||||
|
|
||||||
log_index = Trend_Log_Instance_To_Index(pRequest->object_instance);
|
log_index = Trend_Log_Instance_To_Index(pRequest->object_instance);
|
||||||
@@ -850,8 +898,10 @@ bool TrendLogGetRRInfo(
|
|||||||
* pushed out of the log to make room. *
|
* pushed out of the log to make room. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
void TL_Insert_Status_Rec(int iLog, BACNET_LOG_STATUS eStatus, bool bState)
|
void TL_Insert_Status_Rec(
|
||||||
|
int iLog,
|
||||||
|
BACNET_LOG_STATUS eStatus,
|
||||||
|
bool bState)
|
||||||
{
|
{
|
||||||
TL_LOG_INFO *CurrentLog;
|
TL_LOG_INFO *CurrentLog;
|
||||||
TL_DATA_REC TempRec;
|
TL_DATA_REC TempRec;
|
||||||
@@ -895,7 +945,8 @@ void TL_Insert_Status_Rec(int iLog, BACNET_LOG_STATUS eStatus, bool bState)
|
|||||||
* if the log is really enabled now. See 135-2008 sections 12.25.5 - 12.25.7 *
|
* if the log is really enabled now. See 135-2008 sections 12.25.5 - 12.25.7 *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
bool TL_Is_Enabled(int iLog)
|
bool TL_Is_Enabled(
|
||||||
|
int iLog)
|
||||||
{
|
{
|
||||||
TL_LOG_INFO *CurrentLog;
|
TL_LOG_INFO *CurrentLog;
|
||||||
time_t tNow;
|
time_t tNow;
|
||||||
@@ -904,19 +955,26 @@ bool TL_Is_Enabled(int iLog)
|
|||||||
bStatus = true;
|
bStatus = true;
|
||||||
CurrentLog = &LogInfo[iLog];
|
CurrentLog = &LogInfo[iLog];
|
||||||
#if 0
|
#if 0
|
||||||
printf("\nFlags - %u, Start - %u, Stop - %u\n", (unsigned int)CurrentLog->ucTimeFlags,(unsigned int)CurrentLog->tStartTime, (unsigned int)CurrentLog->tStopTime);
|
printf("\nFlags - %u, Start - %u, Stop - %u\n",
|
||||||
|
(unsigned int) CurrentLog->ucTimeFlags,
|
||||||
|
(unsigned int) CurrentLog->tStartTime,
|
||||||
|
(unsigned int) CurrentLog->tStopTime);
|
||||||
#endif
|
#endif
|
||||||
if (CurrentLog->bEnable == false) {
|
if (CurrentLog->bEnable == false) {
|
||||||
/* Not enabled so time is irrelevant */
|
/* Not enabled so time is irrelevant */
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
} else if((CurrentLog->ucTimeFlags == 0) && (CurrentLog->tStopTime < CurrentLog->tStartTime)) {
|
} else if ((CurrentLog->ucTimeFlags == 0) &&
|
||||||
|
(CurrentLog->tStopTime < CurrentLog->tStartTime)) {
|
||||||
/* Start time was after stop time as per 12.25.6 and 12.25.7 */
|
/* Start time was after stop time as per 12.25.6 and 12.25.7 */
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
} else if (CurrentLog->ucTimeFlags != (TL_T_START_WILD | TL_T_STOP_WILD)) {
|
} else if (CurrentLog->ucTimeFlags != (TL_T_START_WILD | TL_T_STOP_WILD)) {
|
||||||
/* enabled and either 1 wild card or none */
|
/* enabled and either 1 wild card or none */
|
||||||
tNow = time(NULL);
|
tNow = time(NULL);
|
||||||
#if 0
|
#if 0
|
||||||
printf("\nFlags - %u, Current - %u, Start - %u, Stop - %u\n", (unsigned int)CurrentLog->ucTimeFlags,(unsigned int)Now, (unsigned int)CurrentLog->tStartTime, (unsigned int)CurrentLog->tStopTime);
|
printf("\nFlags - %u, Current - %u, Start - %u, Stop - %u\n",
|
||||||
|
(unsigned int) CurrentLog->ucTimeFlags, (unsigned int) Now,
|
||||||
|
(unsigned int) CurrentLog->tStartTime,
|
||||||
|
(unsigned int) CurrentLog->tStopTime);
|
||||||
#endif
|
#endif
|
||||||
if ((CurrentLog->ucTimeFlags & TL_T_START_WILD) != 0) {
|
if ((CurrentLog->ucTimeFlags & TL_T_START_WILD) != 0) {
|
||||||
/* wild card start time */
|
/* wild card start time */
|
||||||
@@ -928,10 +986,13 @@ bool TL_Is_Enabled(int iLog)
|
|||||||
bStatus = false;
|
bStatus = false;
|
||||||
} else {
|
} else {
|
||||||
#if 0
|
#if 0
|
||||||
printf("\nCurrent - %u, Start - %u, Stop - %u\n", (unsigned int)Now, (unsigned int)CurrentLog->tStartTime, (unsigned int)CurrentLog->tStopTime);
|
printf("\nCurrent - %u, Start - %u, Stop - %u\n",
|
||||||
|
(unsigned int) Now, (unsigned int) CurrentLog->tStartTime,
|
||||||
|
(unsigned int) CurrentLog->tStopTime);
|
||||||
#endif
|
#endif
|
||||||
/* No wildcards so use both times */
|
/* No wildcards so use both times */
|
||||||
if((tNow < CurrentLog->tStartTime) || (tNow > CurrentLog->tStopTime))
|
if ((tNow < CurrentLog->tStartTime) ||
|
||||||
|
(tNow > CurrentLog->tStopTime))
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -943,7 +1004,8 @@ bool TL_Is_Enabled(int iLog)
|
|||||||
* Convert a BACnet time into a local time in seconds since the local epoch *
|
* Convert a BACnet time into a local time in seconds since the local epoch *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
time_t TL_BAC_Time_To_Local(BACNET_DATE_TIME *SourceTime)
|
time_t TL_BAC_Time_To_Local(
|
||||||
|
BACNET_DATE_TIME * SourceTime)
|
||||||
{
|
{
|
||||||
struct tm LocalTime;
|
struct tm LocalTime;
|
||||||
int iTemp;
|
int iTemp;
|
||||||
@@ -953,7 +1015,8 @@ time_t TL_BAC_Time_To_Local(BACNET_DATE_TIME *SourceTime)
|
|||||||
* even though this is not a valid date. Pick this up here and
|
* even though this is not a valid date. Pick this up here and
|
||||||
* correct the day and month for the local time functions.
|
* correct the day and month for the local time functions.
|
||||||
*/
|
*/
|
||||||
iTemp = SourceTime->date.year + SourceTime->date.month +SourceTime->date.day;
|
iTemp =
|
||||||
|
SourceTime->date.year + SourceTime->date.month + SourceTime->date.day;
|
||||||
if (iTemp == 1900) {
|
if (iTemp == 1900) {
|
||||||
LocalTime.tm_mon = 0;
|
LocalTime.tm_mon = 0;
|
||||||
LocalTime.tm_mday = 1;
|
LocalTime.tm_mday = 1;
|
||||||
@@ -973,7 +1036,9 @@ time_t TL_BAC_Time_To_Local(BACNET_DATE_TIME *SourceTime)
|
|||||||
* Convert a local time in seconds since the local epoch into a BACnet time *
|
* Convert a local time in seconds since the local epoch into a BACnet time *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
void TL_Local_Time_To_BAC(BACNET_DATE_TIME *DestTime, time_t SourceTime)
|
void TL_Local_Time_To_BAC(
|
||||||
|
BACNET_DATE_TIME * DestTime,
|
||||||
|
time_t SourceTime)
|
||||||
{
|
{
|
||||||
struct tm *TempTime;
|
struct tm *TempTime;
|
||||||
|
|
||||||
@@ -1028,10 +1093,12 @@ 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->object_instance)].ulRecordCount == 0)
|
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
|
||||||
|
ulRecordCount == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if((pRequest->RequestType == RR_BY_POSITION) || (pRequest->RequestType == RR_READ_ALL))
|
if ((pRequest->RequestType == RR_BY_POSITION) ||
|
||||||
|
(pRequest->RequestType == RR_READ_ALL))
|
||||||
return (TL_encode_by_position(apdu, pRequest));
|
return (TL_encode_by_position(apdu, pRequest));
|
||||||
else if (pRequest->RequestType == RR_BY_SEQUENCE)
|
else if (pRequest->RequestType == RR_BY_SEQUENCE)
|
||||||
return (TL_encode_by_sequence(apdu, pRequest));
|
return (TL_encode_by_sequence(apdu, pRequest));
|
||||||
@@ -1093,8 +1160,7 @@ int TL_encode_by_position(
|
|||||||
if (iTemp < 1) { /* if count is too much, return from 1 to start index */
|
if (iTemp < 1) { /* if count is too much, return from 1 to start index */
|
||||||
pRequest->Count = pRequest->Range.RefIndex;
|
pRequest->Count = pRequest->Range.RefIndex;
|
||||||
pRequest->Range.RefIndex = 1;
|
pRequest->Range.RefIndex = 1;
|
||||||
}
|
} else { /* Otherwise adjust the start index and make count +ve */
|
||||||
else { /* Otherwise adjust the start index and make count +ve */
|
|
||||||
pRequest->Range.RefIndex = iTemp;
|
pRequest->Range.RefIndex = iTemp;
|
||||||
pRequest->Count = -pRequest->Count;
|
pRequest->Count = -pRequest->Count;
|
||||||
}
|
}
|
||||||
@@ -1117,7 +1183,8 @@ int TL_encode_by_position(
|
|||||||
* Can't fit any more in! We just set the result flag to say there
|
* Can't fit any more in! We just set the result flag to say there
|
||||||
* was more and drop out of the loop early
|
* was more and drop out of the loop early
|
||||||
*/
|
*/
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS,
|
||||||
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1132,7 +1199,8 @@ int TL_encode_by_position(
|
|||||||
|
|
||||||
/* Set remaining result flags if necessary */
|
/* Set remaining result flags if necessary */
|
||||||
if (uiFirst == 1)
|
if (uiFirst == 1)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM,
|
||||||
|
true);
|
||||||
|
|
||||||
if (uiLast == CurrentLog->ulRecordCount)
|
if (uiLast == CurrentLog->ulRecordCount)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
||||||
@@ -1174,7 +1242,8 @@ int TL_encode_by_sequence(
|
|||||||
log_index = Trend_Log_Instance_To_Index(pRequest->object_instance);
|
log_index = Trend_Log_Instance_To_Index(pRequest->object_instance);
|
||||||
CurrentLog = &LogInfo[log_index];
|
CurrentLog = &LogInfo[log_index];
|
||||||
/* Figure out the sequence number for the first record, last is ulTotalRecordCount */
|
/* Figure out the sequence number for the first record, last is ulTotalRecordCount */
|
||||||
uiFirstSeq = CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1);
|
uiFirstSeq =
|
||||||
|
CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1);
|
||||||
|
|
||||||
/* Calculate start and end sequence numbers from request */
|
/* Calculate start and end sequence numbers from request */
|
||||||
if (pRequest->Count < 0) {
|
if (pRequest->Count < 0) {
|
||||||
@@ -1248,7 +1317,8 @@ int TL_encode_by_sequence(
|
|||||||
* Can't fit any more in! We just set the result flag to say there
|
* Can't fit any more in! We just set the result flag to say there
|
||||||
* was more and drop out of the loop early
|
* was more and drop out of the loop early
|
||||||
*/
|
*/
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS,
|
||||||
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1264,7 +1334,8 @@ int TL_encode_by_sequence(
|
|||||||
|
|
||||||
/* Set remaining result flags if necessary */
|
/* Set remaining result flags if necessary */
|
||||||
if (uiFirst == 1)
|
if (uiFirst == 1)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM,
|
||||||
|
true);
|
||||||
|
|
||||||
if (uiLast == CurrentLog->ulRecordCount)
|
if (uiLast == CurrentLog->ulRecordCount)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
||||||
@@ -1318,7 +1389,8 @@ int TL_encode_by_time(
|
|||||||
/* Start out with the sequence number for the last record */
|
/* Start out with the sequence number for the last record */
|
||||||
uiFirstSeq = CurrentLog->ulTotalRecordCount;
|
uiFirstSeq = CurrentLog->ulTotalRecordCount;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if(Logs[pRequest->object_instance][(uiIndex + iCount) % TL_MAX_ENTRIES].tTimeStamp < tRefTime)
|
if (Logs[pRequest->object_instance][(uiIndex +
|
||||||
|
iCount) % TL_MAX_ENTRIES].tTimeStamp < tRefTime)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
uiFirstSeq--;
|
uiFirstSeq--;
|
||||||
@@ -1352,9 +1424,11 @@ int TL_encode_by_time(
|
|||||||
*/
|
*/
|
||||||
iCount = 0;
|
iCount = 0;
|
||||||
/* Figure out the sequence number for the first record, last is ulTotalRecordCount */
|
/* Figure out the sequence number for the first record, last is ulTotalRecordCount */
|
||||||
uiFirstSeq = CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1);
|
uiFirstSeq =
|
||||||
|
CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if(Logs[pRequest->object_instance][(uiIndex + iCount) % TL_MAX_ENTRIES].tTimeStamp > tRefTime)
|
if (Logs[pRequest->object_instance][(uiIndex +
|
||||||
|
iCount) % TL_MAX_ENTRIES].tTimeStamp > tRefTime)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
uiFirstSeq++;
|
uiFirstSeq++;
|
||||||
@@ -1375,7 +1449,8 @@ int TL_encode_by_time(
|
|||||||
* Can't fit any more in! We just set the result flag to say there
|
* Can't fit any more in! We just set the result flag to say there
|
||||||
* was more and drop out of the loop early
|
* was more and drop out of the loop early
|
||||||
*/
|
*/
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS,
|
||||||
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1394,7 +1469,8 @@ int TL_encode_by_time(
|
|||||||
|
|
||||||
/* Set remaining result flags if necessary */
|
/* Set remaining result flags if necessary */
|
||||||
if (uiFirst == 1)
|
if (uiFirst == 1)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM,
|
||||||
|
true);
|
||||||
|
|
||||||
if (uiLast == CurrentLog->ulRecordCount)
|
if (uiLast == CurrentLog->ulRecordCount)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
||||||
@@ -1405,7 +1481,10 @@ int TL_encode_by_time(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
int TL_encode_entry(
|
||||||
|
uint8_t * apdu,
|
||||||
|
int iLog,
|
||||||
|
int iEntry)
|
||||||
{
|
{
|
||||||
int iLen = 0;
|
int iLen = 0;
|
||||||
TL_DATA_REC *pSource = NULL;
|
TL_DATA_REC *pSource = NULL;
|
||||||
@@ -1419,7 +1498,8 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
|||||||
if (LogInfo[iLog].ulRecordCount < TL_MAX_ENTRIES)
|
if (LogInfo[iLog].ulRecordCount < TL_MAX_ENTRIES)
|
||||||
pSource = &Logs[iLog][(iEntry - 1) % TL_MAX_ENTRIES];
|
pSource = &Logs[iLog][(iEntry - 1) % TL_MAX_ENTRIES];
|
||||||
else
|
else
|
||||||
pSource = &Logs[iLog][(LogInfo[iLog].iIndex + iEntry - 1) % TL_MAX_ENTRIES];
|
pSource =
|
||||||
|
&Logs[iLog][(LogInfo[iLog].iIndex + iEntry - 1) % TL_MAX_ENTRIES];
|
||||||
|
|
||||||
iLen = 0;
|
iLen = 0;
|
||||||
/* First stick the time stamp in with tag [0] */
|
/* First stick the time stamp in with tag [0] */
|
||||||
@@ -1435,27 +1515,39 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
|||||||
bitstring_init(&TempBits);
|
bitstring_init(&TempBits);
|
||||||
bitstring_set_bits_used(&TempBits, 1, 5);
|
bitstring_set_bits_used(&TempBits, 1, 5);
|
||||||
bitstring_set_octet(&TempBits, 0, pSource->Datum.ucLogStatus);
|
bitstring_set_octet(&TempBits, 0, pSource->Datum.ucLogStatus);
|
||||||
iLen += encode_context_bitstring(&apdu[iLen], pSource->ucRecType, &TempBits);
|
iLen +=
|
||||||
|
encode_context_bitstring(&apdu[iLen], pSource->ucRecType,
|
||||||
|
&TempBits);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_BOOL:
|
case TL_TYPE_BOOL:
|
||||||
iLen += encode_context_boolean(&apdu[iLen], pSource->ucRecType, pSource->Datum.ucBoolean);
|
iLen +=
|
||||||
|
encode_context_boolean(&apdu[iLen], pSource->ucRecType,
|
||||||
|
pSource->Datum.ucBoolean);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_REAL:
|
case TL_TYPE_REAL:
|
||||||
iLen += encode_context_real(&apdu[iLen], pSource->ucRecType, pSource->Datum.fReal);
|
iLen +=
|
||||||
|
encode_context_real(&apdu[iLen], pSource->ucRecType,
|
||||||
|
pSource->Datum.fReal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_ENUM:
|
case TL_TYPE_ENUM:
|
||||||
iLen += encode_context_enumerated(&apdu[iLen], pSource->ucRecType, pSource->Datum.ulEnum);
|
iLen +=
|
||||||
|
encode_context_enumerated(&apdu[iLen], pSource->ucRecType,
|
||||||
|
pSource->Datum.ulEnum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_UNSIGN:
|
case TL_TYPE_UNSIGN:
|
||||||
iLen += encode_context_unsigned(&apdu[iLen], pSource->ucRecType, pSource->Datum.ulUValue);
|
iLen +=
|
||||||
|
encode_context_unsigned(&apdu[iLen], pSource->ucRecType,
|
||||||
|
pSource->Datum.ulUValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_SIGN:
|
case TL_TYPE_SIGN:
|
||||||
iLen += encode_context_signed(&apdu[iLen], pSource->ucRecType, pSource->Datum.lSValue);
|
iLen +=
|
||||||
|
encode_context_signed(&apdu[iLen], pSource->ucRecType,
|
||||||
|
pSource->Datum.lSValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_BITS:
|
case TL_TYPE_BITS:
|
||||||
@@ -1463,11 +1555,16 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
|||||||
* have limited to 32 bits maximum as allowed by the standard
|
* have limited to 32 bits maximum as allowed by the standard
|
||||||
*/
|
*/
|
||||||
bitstring_init(&TempBits);
|
bitstring_init(&TempBits);
|
||||||
bitstring_set_bits_used(&TempBits, (pSource->Datum.Bits.ucLen >> 4) & 0x0F, pSource->Datum.Bits.ucLen & 0x0F);
|
bitstring_set_bits_used(&TempBits,
|
||||||
|
(pSource->Datum.Bits.ucLen >> 4) & 0x0F,
|
||||||
|
pSource->Datum.Bits.ucLen & 0x0F);
|
||||||
for (iCount = pSource->Datum.Bits.ucLen >> 4; iCount > 0; iCount--)
|
for (iCount = pSource->Datum.Bits.ucLen >> 4; iCount > 0; iCount--)
|
||||||
bitstring_set_octet(&TempBits, iCount - 1, pSource->Datum.Bits.ucStore[iCount-1]);
|
bitstring_set_octet(&TempBits, iCount - 1,
|
||||||
|
pSource->Datum.Bits.ucStore[iCount - 1]);
|
||||||
|
|
||||||
iLen += encode_context_bitstring(&apdu[iLen], pSource->ucRecType, &TempBits);
|
iLen +=
|
||||||
|
encode_context_bitstring(&apdu[iLen], pSource->ucRecType,
|
||||||
|
&TempBits);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_NULL:
|
case TL_TYPE_NULL:
|
||||||
@@ -1476,13 +1573,19 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
|
|||||||
|
|
||||||
case TL_TYPE_ERROR:
|
case TL_TYPE_ERROR:
|
||||||
iLen += encode_opening_tag(&apdu[iLen], TL_TYPE_ERROR);
|
iLen += encode_opening_tag(&apdu[iLen], TL_TYPE_ERROR);
|
||||||
iLen += encode_application_enumerated(&apdu[iLen], pSource->Datum.Error.usClass);
|
iLen +=
|
||||||
iLen += encode_application_enumerated(&apdu[iLen], pSource->Datum.Error.usCode);
|
encode_application_enumerated(&apdu[iLen],
|
||||||
|
pSource->Datum.Error.usClass);
|
||||||
|
iLen +=
|
||||||
|
encode_application_enumerated(&apdu[iLen],
|
||||||
|
pSource->Datum.Error.usCode);
|
||||||
iLen += encode_closing_tag(&apdu[iLen], TL_TYPE_ERROR);
|
iLen += encode_closing_tag(&apdu[iLen], TL_TYPE_ERROR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_DELTA:
|
case TL_TYPE_DELTA:
|
||||||
iLen += encode_context_real(&apdu[iLen], pSource->ucRecType, pSource->Datum.fTime);
|
iLen +=
|
||||||
|
encode_context_real(&apdu[iLen], pSource->ucRecType,
|
||||||
|
pSource->Datum.fTime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TL_TYPE_ANY:
|
case TL_TYPE_ANY:
|
||||||
@@ -1509,7 +1612,6 @@ static int local_read_property(
|
|||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * Source,
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * Source,
|
||||||
BACNET_ERROR_CLASS * error_class,
|
BACNET_ERROR_CLASS * error_class,
|
||||||
BACNET_ERROR_CODE * error_code)
|
BACNET_ERROR_CODE * error_code)
|
||||||
|
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
BACNET_READ_PROPERTY_DATA rpdata;
|
BACNET_READ_PROPERTY_DATA rpdata;
|
||||||
@@ -1552,8 +1654,8 @@ static int local_read_property(
|
|||||||
* Attempt to fetch the logged property and store it in the Trend Log *
|
* Attempt to fetch the logged property and store it in the Trend Log *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void TL_fetch_property(int iLog)
|
void TL_fetch_property(
|
||||||
|
int iLog)
|
||||||
{
|
{
|
||||||
uint8_t ValueBuf[MAX_APDU]; /* This is a big buffer in case someone selects the device object list for example */
|
uint8_t ValueBuf[MAX_APDU]; /* This is a big buffer in case someone selects the device object list for example */
|
||||||
uint8_t StatusBuf[3]; /* Should be tag, bits unused in last octet and 1 byte of data */
|
uint8_t StatusBuf[3]; /* Should be tag, bits unused in last octet and 1 byte of data */
|
||||||
@@ -1575,7 +1677,9 @@ void TL_fetch_property(int iLog)
|
|||||||
CurrentLog->tLastDataTime = TempRec.tTimeStamp;
|
CurrentLog->tLastDataTime = TempRec.tTimeStamp;
|
||||||
TempRec.ucStatus = 0;
|
TempRec.ucStatus = 0;
|
||||||
|
|
||||||
iLen = local_read_property(ValueBuf, StatusBuf, &LogInfo[iLog].Source, &error_class, &error_code);
|
iLen =
|
||||||
|
local_read_property(ValueBuf, StatusBuf, &LogInfo[iLog].Source,
|
||||||
|
&error_class, &error_code);
|
||||||
if (iLen < 0) {
|
if (iLen < 0) {
|
||||||
/* Insert error code into log */
|
/* Insert error code into log */
|
||||||
TempRec.Datum.Error.usClass = error_class;
|
TempRec.Datum.Error.usClass = error_class;
|
||||||
@@ -1583,7 +1687,9 @@ void TL_fetch_property(int iLog)
|
|||||||
TempRec.ucRecType = TL_TYPE_ERROR;
|
TempRec.ucRecType = TL_TYPE_ERROR;
|
||||||
} else {
|
} else {
|
||||||
/* Decode data returned and see if we can fit it into the log */
|
/* Decode data returned and see if we can fit it into the log */
|
||||||
iLen = decode_tag_number_and_value(ValueBuf, &tag_number, &len_value_type);
|
iLen =
|
||||||
|
decode_tag_number_and_value(ValueBuf, &tag_number,
|
||||||
|
&len_value_type);
|
||||||
switch (tag_number) {
|
switch (tag_number) {
|
||||||
case BACNET_APPLICATION_TAG_NULL:
|
case BACNET_APPLICATION_TAG_NULL:
|
||||||
TempRec.ucRecType = TL_TYPE_NULL;
|
TempRec.ucRecType = TL_TYPE_NULL;
|
||||||
@@ -1596,17 +1702,20 @@ void TL_fetch_property(int iLog)
|
|||||||
|
|
||||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||||
TempRec.ucRecType = TL_TYPE_UNSIGN;
|
TempRec.ucRecType = TL_TYPE_UNSIGN;
|
||||||
decode_unsigned(&ValueBuf[iLen], len_value_type, &TempRec.Datum.ulUValue);
|
decode_unsigned(&ValueBuf[iLen], len_value_type,
|
||||||
|
&TempRec.Datum.ulUValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||||
TempRec.ucRecType = TL_TYPE_SIGN;
|
TempRec.ucRecType = TL_TYPE_SIGN;
|
||||||
decode_signed(&ValueBuf[iLen], len_value_type, &TempRec.Datum.lSValue);
|
decode_signed(&ValueBuf[iLen], len_value_type,
|
||||||
|
&TempRec.Datum.lSValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_REAL:
|
case BACNET_APPLICATION_TAG_REAL:
|
||||||
TempRec.ucRecType = TL_TYPE_REAL;
|
TempRec.ucRecType = TL_TYPE_REAL;
|
||||||
decode_real_safe(&ValueBuf[iLen], len_value_type, &TempRec.Datum.fReal);
|
decode_real_safe(&ValueBuf[iLen], len_value_type,
|
||||||
|
&TempRec.Datum.fReal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||||
@@ -1615,22 +1724,28 @@ void TL_fetch_property(int iLog)
|
|||||||
/* We truncate any bitstrings at 32 bits to conserve space */
|
/* We truncate any bitstrings at 32 bits to conserve space */
|
||||||
if (bitstring_bits_used(&TempBits) < 32) {
|
if (bitstring_bits_used(&TempBits) < 32) {
|
||||||
/* Store the bytes used and the bits free in the last byte */
|
/* Store the bytes used and the bits free in the last byte */
|
||||||
TempRec.Datum.Bits.ucLen = bitstring_bytes_used(&TempBits) << 4;
|
TempRec.Datum.Bits.ucLen =
|
||||||
TempRec.Datum.Bits.ucLen |= (8 - (bitstring_bits_used(&TempBits) % 8)) & 7;
|
bitstring_bytes_used(&TempBits) << 4;
|
||||||
|
TempRec.Datum.Bits.ucLen |=
|
||||||
|
(8 - (bitstring_bits_used(&TempBits) % 8)) & 7;
|
||||||
/* Fetch the octets with the bits directly */
|
/* Fetch the octets with the bits directly */
|
||||||
for(iCount = 0; iCount < bitstring_bytes_used(&TempBits); iCount++)
|
for (iCount = 0; iCount < bitstring_bytes_used(&TempBits);
|
||||||
TempRec.Datum.Bits.ucStore[iCount] = bitstring_octet(&TempBits, iCount);
|
iCount++)
|
||||||
|
TempRec.Datum.Bits.ucStore[iCount] =
|
||||||
|
bitstring_octet(&TempBits, iCount);
|
||||||
} else {
|
} else {
|
||||||
/* We will only use the first 4 octets to save space */
|
/* We will only use the first 4 octets to save space */
|
||||||
TempRec.Datum.Bits.ucLen = 4 << 4;
|
TempRec.Datum.Bits.ucLen = 4 << 4;
|
||||||
for (iCount = 0; iCount < 4; iCount++)
|
for (iCount = 0; iCount < 4; iCount++)
|
||||||
TempRec.Datum.Bits.ucStore[iCount] = bitstring_octet(&TempBits, iCount);
|
TempRec.Datum.Bits.ucStore[iCount] =
|
||||||
|
bitstring_octet(&TempBits, iCount);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||||
TempRec.ucRecType = TL_TYPE_ENUM;
|
TempRec.ucRecType = TL_TYPE_ENUM;
|
||||||
decode_enumerated(&ValueBuf[iLen], len_value_type, &TempRec.Datum.ulEnum);
|
decode_enumerated(&ValueBuf[iLen], len_value_type,
|
||||||
|
&TempRec.Datum.ulEnum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1641,7 +1756,9 @@ void TL_fetch_property(int iLog)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Finally insert the status flags into the record */
|
/* Finally insert the status flags into the record */
|
||||||
iLen = decode_tag_number_and_value(StatusBuf, &tag_number, &len_value_type);
|
iLen =
|
||||||
|
decode_tag_number_and_value(StatusBuf, &tag_number,
|
||||||
|
&len_value_type);
|
||||||
decode_bitstring(&StatusBuf[iLen], len_value_type, &TempBits);
|
decode_bitstring(&StatusBuf[iLen], len_value_type, &TempBits);
|
||||||
TempRec.ucStatus = 128 | bitstring_octet(&TempBits, 0);
|
TempRec.ucStatus = 128 | bitstring_octet(&TempBits, 0);
|
||||||
}
|
}
|
||||||
@@ -1687,12 +1804,15 @@ void trend_log_timer(
|
|||||||
*/
|
*/
|
||||||
/* if(((tNow % CurrentLog->ulLogInterval) >= (CurrentLog->ulIntervalOffset % CurrentLog->ulLogInterval)) && */
|
/* if(((tNow % CurrentLog->ulLogInterval) >= (CurrentLog->ulIntervalOffset % CurrentLog->ulLogInterval)) && */
|
||||||
/* ((tNow - CurrentLog->tLastDataTime) >= CurrentLog->ulLogInterval)) { */
|
/* ((tNow - CurrentLog->tLastDataTime) >= CurrentLog->ulLogInterval)) { */
|
||||||
if((tNow % CurrentLog->ulLogInterval) == (CurrentLog->ulIntervalOffset % CurrentLog->ulLogInterval)) {
|
if ((tNow % CurrentLog->ulLogInterval) ==
|
||||||
|
(CurrentLog->ulIntervalOffset %
|
||||||
|
CurrentLog->ulLogInterval)) {
|
||||||
/* Record value if time synchronised trigger condition is met
|
/* Record value if time synchronised trigger condition is met
|
||||||
* and at least one period has elapsed.
|
* and at least one period has elapsed.
|
||||||
*/
|
*/
|
||||||
TL_fetch_property(iCount);
|
TL_fetch_property(iCount);
|
||||||
} else if((tNow - CurrentLog->tLastDataTime) > CurrentLog->ulLogInterval) {
|
} else if ((tNow - CurrentLog->tLastDataTime) >
|
||||||
|
CurrentLog->ulLogInterval) {
|
||||||
/* Also record value if we have waited more than a period
|
/* Also record value if we have waited more than a period
|
||||||
* since the last reading. This ensures we take a reading as
|
* since the last reading. This ensures we take a reading as
|
||||||
* soon as possible after a power down if we have been off for
|
* soon as possible after a power down if we have been off for
|
||||||
@@ -1700,7 +1820,8 @@ void trend_log_timer(
|
|||||||
*/
|
*/
|
||||||
TL_fetch_property(iCount);
|
TL_fetch_property(iCount);
|
||||||
}
|
}
|
||||||
} else if(((tNow - CurrentLog->tLastDataTime) >= CurrentLog->ulLogInterval) ||
|
} else if (((tNow - CurrentLog->tLastDataTime) >=
|
||||||
|
CurrentLog->ulLogInterval) ||
|
||||||
(CurrentLog->bTrigger == true)) {
|
(CurrentLog->bTrigger == true)) {
|
||||||
/* If not aligned take a reading when we have either waited long
|
/* If not aligned take a reading when we have either waited long
|
||||||
* enough or a trigger is set.
|
* enough or a trigger is set.
|
||||||
|
|||||||
@@ -281,13 +281,15 @@ int main(
|
|||||||
/* at least one second has passed */
|
/* at least one second has passed */
|
||||||
if (current_seconds != last_seconds) {
|
if (current_seconds != last_seconds) {
|
||||||
putchar('.'); /* Just to show that time is passing... */
|
putchar('.'); /* Just to show that time is passing... */
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds -
|
||||||
|
last_seconds) * 1000));
|
||||||
address_cache_timer(current_seconds - last_seconds);
|
address_cache_timer(current_seconds - last_seconds);
|
||||||
trend_log_timer(current_seconds - last_seconds);
|
trend_log_timer(current_seconds - last_seconds);
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
/* Change the analog input PVs for testing purposes */
|
/* Change the analog input PVs for testing purposes */
|
||||||
for (iCount = 0; iCount < Analog_Input_Count(); iCount++) {
|
for (iCount = 0; iCount < Analog_Input_Count(); iCount++) {
|
||||||
Analog_Input_Present_Value_Set(iCount, iSecondsRun * (iCount + 1));
|
Analog_Input_Present_Value_Set(iCount,
|
||||||
|
iSecondsRun * (iCount + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
iSecondsRun++;
|
iSecondsRun++;
|
||||||
@@ -326,7 +328,8 @@ int main(
|
|||||||
}
|
}
|
||||||
/* 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));
|
||||||
address_cache_timer(current_seconds - last_seconds);
|
address_cache_timer(current_seconds - last_seconds);
|
||||||
trend_log_timer(current_seconds - last_seconds);
|
trend_log_timer(current_seconds - last_seconds);
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
@@ -346,8 +349,10 @@ int main(
|
|||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -356,8 +361,10 @@ int main(
|
|||||||
Request.Range.RefSeqNum = 3;
|
Request.Range.RefSeqNum = 3;
|
||||||
Request.Count = -2;
|
Request.Count = -2;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -374,8 +381,10 @@ int main(
|
|||||||
|
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -384,8 +393,10 @@ int main(
|
|||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 1;
|
Request.array_index = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -394,8 +405,10 @@ int main(
|
|||||||
Request.Range.RefSeqNum = 1;
|
Request.Range.RefSeqNum = 1;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -412,24 +425,30 @@ int main(
|
|||||||
|
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 1;
|
Request.array_index = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: /* Pass - should try to return all entries */
|
case 6: /* Pass - should try to return all entries */
|
||||||
Request.RequestType = RR_READ_ALL;
|
Request.RequestType = RR_READ_ALL;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: /* Fail - array not supported */
|
case 7: /* Fail - array not supported */
|
||||||
Request.RequestType = RR_READ_ALL;
|
Request.RequestType = RR_READ_ALL;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 1;
|
Request.array_index = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -438,8 +457,10 @@ int main(
|
|||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 1;
|
Request.Count = 1;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -448,8 +469,10 @@ int main(
|
|||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 2;
|
Request.Count = 2;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -458,8 +481,10 @@ int main(
|
|||||||
Request.Range.RefIndex = 2;
|
Request.Range.RefIndex = 2;
|
||||||
Request.Count = 2;
|
Request.Count = 2;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -468,8 +493,10 @@ int main(
|
|||||||
Request.Range.RefIndex = 2;
|
Request.Range.RefIndex = 2;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
|
Request.object_property =
|
||||||
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
Request.array_index = 0;
|
Request.array_index = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,8 +160,7 @@ int main(
|
|||||||
}
|
}
|
||||||
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,
|
cov_data.monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE);
|
||||||
MAX_BACNET_OBJECT_TYPE);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DLBIP BACnet/IP DataLink Network Layer
|
/** @defgroup DLBIP BACnet/IP DataLink Network Layer
|
||||||
* @ingroup DataLink
|
* @ingroup DataLink
|
||||||
* Implementation of the Network Layer using BACnet/IP as the transport, as
|
* Implementation of the Network Layer using BACnet/IP as the transport, as
|
||||||
@@ -131,5 +130,4 @@ extern "C" {
|
|||||||
* DataLink level by serving as the implementation of the function templates.
|
* DataLink level by serving as the implementation of the function templates.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DSCOV Data Sharing - Change of Value Service (DS-COV)
|
/** @defgroup DSCOV Data Sharing - Change of Value Service (DS-COV)
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 13.1 Change of Value Reporting <br>
|
* 13.1 Change of Value Reporting <br>
|
||||||
@@ -140,5 +139,4 @@ extern "C" {
|
|||||||
* devices or to operators or logging devices. Any object, proprietary or
|
* devices or to operators or logging devices. Any object, proprietary or
|
||||||
* standard, may support COV reporting at the implementor's option.
|
* standard, may support COV reporting at the implementor's option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @defgroup DataLink The BACnet Network (DataLink) Layer
|
/** @defgroup DataLink The BACnet Network (DataLink) Layer
|
||||||
* <b>6 THE NETWORK LAYER </b><br>
|
* <b>6 THE NETWORK LAYER </b><br>
|
||||||
* The purpose of the BACnet network layer is to provide the means by which
|
* The purpose of the BACnet network layer is to provide the means by which
|
||||||
@@ -140,13 +139,10 @@ 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
|
||||||
* at runtime.
|
* at runtime.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -97,14 +97,11 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup RDMS Remote Device Management Services BIBBs
|
/** @defgroup RDMS Remote Device Management Services BIBBs
|
||||||
* These device management BIBBs prescribe the BACnet capabilities required
|
* These device management BIBBs prescribe the BACnet capabilities required
|
||||||
* to interoperably perform the device management functions enumerated in
|
* to interoperably perform the device management functions enumerated in
|
||||||
* 22.2.1.5 for the BACnet devices defined therein.
|
* 22.2.1.5 for the BACnet devices defined therein.
|
||||||
*/
|
*//** @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
|
||||||
@@ -118,5 +115,4 @@ extern "C" {
|
|||||||
* DeviceCommunicationControl or, if supported, ReinitializeDevice service,
|
* DeviceCommunicationControl or, if supported, ReinitializeDevice service,
|
||||||
* not by time.
|
* not by time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ extern "C" {
|
|||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
||||||
|
|
||||||
BACNET_REINITIALIZED_STATE Device_Reinitialized_State(void);
|
BACNET_REINITIALIZED_STATE Device_Reinitialized_State(
|
||||||
|
void);
|
||||||
|
|
||||||
rr_info_function Device_Objects_RR_Info(
|
rr_info_function Device_Objects_RR_Info(
|
||||||
BACNET_OBJECT_TYPE object_type);
|
BACNET_OBJECT_TYPE object_type);
|
||||||
@@ -146,7 +147,8 @@ extern "C" {
|
|||||||
int *object_type,
|
int *object_type,
|
||||||
uint32_t * instance);
|
uint32_t * instance);
|
||||||
|
|
||||||
unsigned Device_Count(void);
|
unsigned Device_Count(
|
||||||
|
void);
|
||||||
uint32_t Device_Index_To_Instance(
|
uint32_t Device_Index_To_Instance(
|
||||||
unsigned index);
|
unsigned index);
|
||||||
char *Device_Name(
|
char *Device_Name(
|
||||||
@@ -233,7 +235,6 @@ extern "C" {
|
|||||||
#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
|
||||||
@@ -243,15 +244,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
|
||||||
@@ -266,6 +263,4 @@ extern "C" {
|
|||||||
* eg Object_Read_Property() for the RP handler.
|
* eg Object_Read_Property() for the RP handler.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -209,14 +209,11 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup ALMEVNT Alarm and Event Management BIBBs
|
/** @defgroup ALMEVNT Alarm and Event Management BIBBs
|
||||||
* 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
|
||||||
@@ -233,9 +230,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
|
||||||
@@ -246,5 +241,4 @@ extern "C" {
|
|||||||
* This service may be used in conjunction with either the
|
* This service may be used in conjunction with either the
|
||||||
* ConfirmedEventNotification service or the UnconfirmedEventNotification service.
|
* ConfirmedEventNotification service or the UnconfirmedEventNotification service.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif /* BACNET_EVENT_H_ */
|
#endif /* BACNET_EVENT_H_ */
|
||||||
|
|||||||
@@ -256,10 +256,7 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup MISCHNDLR Miscellaneous Handler Utilities
|
/** @defgroup MISCHNDLR Miscellaneous Handler Utilities
|
||||||
* Various utilities and functions to support the Handlers.
|
* Various utilities and functions to support the Handlers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DMRD Device Management-ReinitializeDevice (DM-RD)
|
/** @defgroup DMRD Device Management-ReinitializeDevice (DM-RD)
|
||||||
* @ingroup RDMS
|
* @ingroup RDMS
|
||||||
* 16.4 ReinitializeDevice Service <br>
|
* 16.4 ReinitializeDevice Service <br>
|
||||||
@@ -98,5 +97,4 @@ extern "C" {
|
|||||||
* to executing the service.
|
* to executing the service.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ typedef enum {
|
|||||||
information in it. The function is responsible for applying the request
|
information in it. The function is responsible for applying the request
|
||||||
to the property in question and returning the response. */
|
to the property in question and returning the response. */
|
||||||
|
|
||||||
typedef int (*rr_handler_function) (
|
typedef int (
|
||||||
|
*rr_handler_function) (
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_READ_RANGE_DATA * pRequest);
|
BACNET_READ_RANGE_DATA * pRequest);
|
||||||
|
|
||||||
@@ -131,7 +132,8 @@ typedef struct rrpropertyinfo {
|
|||||||
* @param pInfo [out] Where to write the response to.
|
* @param pInfo [out] Where to write the response to.
|
||||||
* @return True on success, False on error or failure.
|
* @return True on success, False on error or failure.
|
||||||
*/
|
*/
|
||||||
typedef bool (*rr_info_function) (
|
typedef bool(
|
||||||
|
*rr_info_function) (
|
||||||
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
RR_PROP_INFO * pInfo); /* Where to write the response to */
|
RR_PROP_INFO * pInfo); /* Where to write the response to */
|
||||||
|
|
||||||
@@ -176,4 +178,3 @@ uint8_t Send_ReadRange_Request(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -131,19 +131,15 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DataShare Data Sharing BIBBs
|
/** @defgroup DataShare Data Sharing BIBBs
|
||||||
* 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
|
||||||
* value of one property of one BACnet Object. This service allows read access
|
* value of one property of one BACnet Object. This service allows read access
|
||||||
* to any property of any object, whether a BACnet-defined object or not.
|
* to any property of any object, whether a BACnet-defined object or not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -201,7 +201,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DSRPM Data Sharing -Read Property Multiple Service (DS-RPM)
|
/** @defgroup DSRPM Data Sharing -Read Property Multiple Service (DS-RPM)
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 15.7 ReadPropertyMultiple Service <br>
|
* 15.7 ReadPropertyMultiple Service <br>
|
||||||
@@ -214,5 +213,4 @@ extern "C" {
|
|||||||
* A 'Read Access Specification' with the property identifier ALL can be used to
|
* A 'Read Access Specification' with the property identifier ALL can be used to
|
||||||
* learn the implemented properties of an object along with their values.
|
* learn the implemented properties of an object along with their values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ extern "C" {
|
|||||||
/* use these in tandem */
|
/* use these in tandem */
|
||||||
uint8_t tsm_next_free_invokeID(
|
uint8_t tsm_next_free_invokeID(
|
||||||
void);
|
void);
|
||||||
void tsm_invokeID_set(uint8_t invokeID);
|
void tsm_invokeID_set(
|
||||||
|
uint8_t invokeID);
|
||||||
/* returns the same invoke ID that was given */
|
/* returns the same invoke ID that was given */
|
||||||
void tsm_set_confirmed_unsegmented_transaction(
|
void tsm_set_confirmed_unsegmented_transaction(
|
||||||
uint8_t invokeID,
|
uint8_t invokeID,
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DMDOB Device Management-Dynamic Object Binding (DM-DOB)
|
/** @defgroup DMDOB Device Management-Dynamic Object Binding (DM-DOB)
|
||||||
* @ingroup RDMS
|
* @ingroup RDMS
|
||||||
* 16.9 Who-Has and I-Have Services <br>
|
* 16.9 Who-Has and I-Have Services <br>
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DMDDB Device Management-Dynamic Device Binding (DM-DDB)
|
/** @defgroup DMDDB Device Management-Dynamic Device Binding (DM-DDB)
|
||||||
* @ingroup RDMS
|
* @ingroup RDMS
|
||||||
* 16.10 Who-Is and I-Am Services <br>
|
* 16.10 Who-Is and I-Am Services <br>
|
||||||
@@ -87,5 +86,4 @@ extern "C" {
|
|||||||
* issuing the request is on the local network, or from the NPCI if the device
|
* issuing the request is on the local network, or from the NPCI if the device
|
||||||
* is on a remote network.
|
* is on a remote network.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DSWP Data Sharing - Write Property Service (DS-WP)
|
/** @defgroup DSWP Data Sharing - Write Property Service (DS-WP)
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 15.9 WriteProperty Service <br>
|
* 15.9 WriteProperty Service <br>
|
||||||
@@ -114,5 +113,4 @@ extern "C" {
|
|||||||
* to modify a restricted property shall result in the return of an error of
|
* to modify a restricted property shall result in the return of an error of
|
||||||
* 'Error Class' PROPERTY and 'Error Code' WRITE_ACCESS_DENIED.
|
* 'Error Class' PROPERTY and 'Error Code' WRITE_ACCESS_DENIED.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ int Analog_Input_Read_Property(
|
|||||||
BACNET_CHARACTER_STRING char_string;
|
BACNET_CHARACTER_STRING char_string;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -205,8 +204,7 @@ int Analog_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -195,8 +195,7 @@ int Analog_Value_Read_Property(
|
|||||||
#endif
|
#endif
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -236,7 +235,8 @@ int Analog_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
#if 0
|
#if 0
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Value_Out_Of_Service[object_index];
|
state = Analog_Value_Out_Of_Service[object_index];
|
||||||
#endif
|
#endif
|
||||||
apdu_len = encode_application_boolean(&apdu[0], false);
|
apdu_len = encode_application_boolean(&apdu[0], false);
|
||||||
@@ -253,7 +253,8 @@ int Analog_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. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->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 (Present_Value[object_index][i] == ANALOG_LEVEL_NULL)
|
if (Present_Value[object_index][i] == ANALOG_LEVEL_NULL)
|
||||||
@@ -282,7 +283,8 @@ int Analog_Value_Read_Property(
|
|||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Present_Value[object_index][rpdata->array_index - 1];
|
Present_Value[object_index][rpdata->array_index -
|
||||||
|
1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -353,8 +355,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
|
||||||
@@ -420,4 +422,3 @@ bool Analog_Value_Write_Property(
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,8 +169,7 @@ int Binary_Input_Read_Property(
|
|||||||
BACNET_BINARY_PV value = BINARY_INACTIVE;
|
BACNET_BINARY_PV value = BINARY_INACTIVE;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -224,8 +223,7 @@ int Binary_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -233,4 +231,3 @@ int Binary_Input_Read_Property(
|
|||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,8 +164,7 @@ int Binary_Value_Read_Property(
|
|||||||
|
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -190,7 +189,8 @@ int Binary_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Value_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Value_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -221,8 +221,7 @@ int Binary_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -266,8 +265,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;
|
||||||
@@ -312,4 +311,3 @@ bool Binary_Value_Write_Property(
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,7 @@
|
|||||||
static uint32_t Object_Instance_Number = 12345;
|
static uint32_t Object_Instance_Number = 12345;
|
||||||
static char My_Object_Name[32] = "ARM7 Device";
|
static char My_Object_Name[32] = "ARM7 Device";
|
||||||
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
||||||
static BACNET_REINITIALIZED_STATE Reinitialize_State =
|
static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
|
||||||
BACNET_REINIT_IDLE;
|
|
||||||
|
|
||||||
/* forward prototypes */
|
/* forward prototypes */
|
||||||
int Device_Read_Property_Local(
|
int Device_Read_Property_Local(
|
||||||
@@ -70,55 +69,30 @@ static struct object_functions {
|
|||||||
read_property_function Object_Read_Property;
|
read_property_function Object_Read_Property;
|
||||||
write_property_function Object_Write_Property;
|
write_property_function Object_Write_Property;
|
||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
} Object_Table[] =
|
} Object_Table[] = {
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||||
NULL,/* don't init - recursive! */
|
Device_Count, Device_Index_To_Instance,
|
||||||
Device_Count,
|
Device_Valid_Object_Instance_Number, Device_Name,
|
||||||
Device_Index_To_Instance,
|
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||||
Device_Valid_Object_Instance_Number,
|
Device_Property_Lists}, {
|
||||||
Device_Name,
|
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||||
Device_Read_Property_Local,
|
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||||
Device_Write_Property_Local,
|
Analog_Input_Name, Analog_Input_Read_Property, NULL,
|
||||||
Device_Property_Lists},
|
Analog_Input_Property_Lists}, {
|
||||||
{OBJECT_ANALOG_INPUT,
|
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||||
Analog_Input_Init,
|
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||||
Analog_Input_Count,
|
Analog_Value_Name, Analog_Value_Read_Property,
|
||||||
Analog_Input_Index_To_Instance,
|
Analog_Value_Write_Property, Analog_Value_Property_Lists}, {
|
||||||
Analog_Input_Valid_Instance,
|
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||||
Analog_Input_Name,
|
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||||
Analog_Input_Read_Property,
|
Binary_Input_Name, Binary_Input_Read_Property, NULL,
|
||||||
NULL,
|
Binary_Input_Property_Lists}, {
|
||||||
Analog_Input_Property_Lists},
|
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
|
||||||
{OBJECT_ANALOG_VALUE,
|
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
|
||||||
Analog_Value_Init,
|
Binary_Value_Name, Binary_Value_Read_Property,
|
||||||
Analog_Value_Count,
|
Binary_Value_Write_Property, Binary_Value_Property_Lists}, {
|
||||||
Analog_Value_Index_To_Instance,
|
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||||
Analog_Value_Valid_Instance,
|
|
||||||
Analog_Value_Name,
|
|
||||||
Analog_Value_Read_Property,
|
|
||||||
Analog_Value_Write_Property,
|
|
||||||
Analog_Value_Property_Lists},
|
|
||||||
{OBJECT_BINARY_INPUT,
|
|
||||||
Binary_Input_Init,
|
|
||||||
Binary_Input_Count,
|
|
||||||
Binary_Input_Index_To_Instance,
|
|
||||||
Binary_Input_Valid_Instance,
|
|
||||||
Binary_Input_Name,
|
|
||||||
Binary_Input_Read_Property,
|
|
||||||
NULL,
|
|
||||||
Binary_Input_Property_Lists},
|
|
||||||
{OBJECT_BINARY_VALUE,
|
|
||||||
Binary_Value_Init,
|
|
||||||
Binary_Value_Count,
|
|
||||||
Binary_Value_Index_To_Instance,
|
|
||||||
Binary_Value_Valid_Instance,
|
|
||||||
Binary_Value_Name,
|
|
||||||
Binary_Value_Read_Property,
|
|
||||||
Binary_Value_Write_Property,
|
|
||||||
Binary_Value_Property_Lists},
|
|
||||||
|
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||||
@@ -294,10 +268,8 @@ void Device_Objects_Property_List(
|
|||||||
pObject = &Object_Table[index];
|
pObject = &Object_Table[index];
|
||||||
}
|
}
|
||||||
if (found && object_property_list) {
|
if (found && object_property_list) {
|
||||||
object_property_list(
|
object_property_list(&pPropertyList->Required.pList,
|
||||||
&pPropertyList->Required.pList,
|
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||||
&pPropertyList->Optional.pList,
|
|
||||||
&pPropertyList->Proprietary.pList);
|
|
||||||
}
|
}
|
||||||
/* fill the count */
|
/* fill the count */
|
||||||
if (pPropertyList->Required.pList) {
|
if (pPropertyList->Required.pList) {
|
||||||
@@ -363,8 +335,7 @@ bool Device_Object_List_Identifier(
|
|||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Count &&
|
if (pObject->Object_Count && pObject->Object_Index_To_Instance) {
|
||||||
pObject->Object_Index_To_Instance) {
|
|
||||||
object_index -= count;
|
object_index -= count;
|
||||||
count = pObject->Object_Count();
|
count = pObject->Object_Count();
|
||||||
if (object_index < count) {
|
if (object_index < count) {
|
||||||
@@ -425,8 +396,7 @@ char *Device_Valid_Object_Id(
|
|||||||
|
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Type == object_type) &&
|
if ((pObject->Object_Type == object_type) && (pObject->Object_Name)) {
|
||||||
(pObject->Object_Name)) {
|
|
||||||
name = pObject->Object_Name(object_instance);
|
name = pObject->Object_Name(object_instance);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -437,7 +407,8 @@ char *Device_Valid_Object_Id(
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Device_Count(void)
|
unsigned Device_Count(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -604,8 +575,7 @@ int Device_Read_Property_Local(
|
|||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -702,8 +672,7 @@ int Device_Read_Property_Local(
|
|||||||
i = 0;
|
i = 0;
|
||||||
pObject = &Object_Table[i];
|
pObject = &Object_Table[i];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Count) &&
|
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
|
||||||
(pObject->Object_Count() > 0)) {
|
|
||||||
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -722,7 +691,8 @@ int Device_Read_Property_Local(
|
|||||||
/* your maximum APDU size. */
|
/* your maximum APDU size. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
for (i = 1; i <= count; i++) {
|
for (i = 1; i <= count; i++) {
|
||||||
found = Device_Object_List_Identifier(i, &object_type,
|
found =
|
||||||
|
Device_Object_List_Identifier(i, &object_type,
|
||||||
&instance);
|
&instance);
|
||||||
if (found) {
|
if (found) {
|
||||||
len =
|
len =
|
||||||
@@ -733,7 +703,8 @@ int Device_Read_Property_Local(
|
|||||||
/* can we all fit into the APDU? */
|
/* can we all fit into the APDU? */
|
||||||
if ((apdu_len + len) >= MAX_APDU) {
|
if ((apdu_len + len) >= MAX_APDU) {
|
||||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
rpdata->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -746,8 +717,8 @@ int Device_Read_Property_Local(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Device_Object_List_Identifier(rpdata->array_index, &object_type,
|
if (Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&instance))
|
&object_type, &instance))
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
instance);
|
instance);
|
||||||
@@ -825,8 +796,7 @@ int Device_Read_Property_Local(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
|
||||||
(rpdata->object_property != PROP_OBJECT_LIST) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -858,8 +828,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 {
|
||||||
@@ -918,11 +888,13 @@ bool Device_Write_Property_Local(
|
|||||||
the device. */
|
the device. */
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ static inline void bacnet_init(
|
|||||||
/* set up our confirmed service unrecognized service handler - required! */
|
/* set up our confirmed service unrecognized service handler - required! */
|
||||||
apdu_set_unrecognized_service_handler_handler
|
apdu_set_unrecognized_service_handler_handler
|
||||||
(handler_unrecognized_service);
|
(handler_unrecognized_service);
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
|
||||||
handler_who_has);
|
|
||||||
/* we need to handle who-is to support dynamic device binding */
|
/* we need to handle who-is to support dynamic device binding */
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||||
/* Set the handlers for any confirmed services that we support. */
|
/* Set the handlers for any confirmed services that we support. */
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ int Analog_Input_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ int Analog_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -169,8 +169,7 @@ int Binary_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -207,8 +206,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;
|
||||||
|
|||||||
@@ -337,8 +337,7 @@ int Device_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (property != PROP_OBJECT_LIST) &&
|
||||||
(property != PROP_OBJECT_LIST) &&
|
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
(array_index != BACNET_ARRAY_ALL)) {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -372,8 +371,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 {
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ int Analog_Input_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ int Analog_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -169,8 +169,7 @@ int Binary_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -207,8 +206,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;
|
||||||
|
|||||||
@@ -328,8 +328,7 @@ int Device_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (property != PROP_OBJECT_LIST) &&
|
||||||
(property != PROP_OBJECT_LIST) &&
|
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
(array_index != BACNET_ARRAY_ALL)) {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ int Analog_Input_Read_Property(
|
|||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -190,8 +189,7 @@ int Analog_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -233,7 +233,8 @@ int Analog_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
#if 0
|
#if 0
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Value_Out_Of_Service[object_index];
|
state = Analog_Value_Out_Of_Service[object_index];
|
||||||
#endif
|
#endif
|
||||||
apdu_len = encode_application_boolean(&apdu[0], false);
|
apdu_len = encode_application_boolean(&apdu[0], false);
|
||||||
@@ -272,14 +273,16 @@ int Analog_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Present_Value[object_index][rpdata->array_index - 1] ==
|
if (Present_Value[object_index][rpdata->array_index - 1] ==
|
||||||
ANALOG_LEVEL_NULL)
|
ANALOG_LEVEL_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Present_Value[object_index][rpdata->array_index - 1];
|
Present_Value[object_index][rpdata->array_index -
|
||||||
|
1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -336,13 +339,12 @@ bool Analog_Value_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_REAL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
status = Analog_Value_Present_Value_Set(
|
status =
|
||||||
wp_data->object_instance,
|
Analog_Value_Present_Value_Set(wp_data->object_instance,
|
||||||
value.type.Real, wp_data->priority);
|
value.type.Real, wp_data->priority);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
if (wp_data->priority == 6) {
|
if (wp_data->priority == 6) {
|
||||||
@@ -370,10 +372,9 @@ bool Analog_Value_Write_Property(
|
|||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
||||||
|
|||||||
@@ -219,8 +219,7 @@ int Binary_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -201,8 +201,8 @@ static void Binary_Output_Level_Sync(
|
|||||||
bool Binary_Output_Present_Value_Set(
|
bool Binary_Output_Present_Value_Set(
|
||||||
uint32_t instance,
|
uint32_t instance,
|
||||||
BACNET_BINARY_PV binary_value,
|
BACNET_BINARY_PV binary_value,
|
||||||
unsigned priority) /* 0..15 */
|
unsigned priority)
|
||||||
{
|
{ /* 0..15 */
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
if (instance < MAX_BINARY_OUTPUTS) {
|
if (instance < MAX_BINARY_OUTPUTS) {
|
||||||
@@ -239,8 +239,7 @@ void Binary_Output_Out_Of_Service_Set(
|
|||||||
if (instance < MAX_BINARY_OUTPUTS) {
|
if (instance < MAX_BINARY_OUTPUTS) {
|
||||||
Out_Of_Service[instance] = flag;
|
Out_Of_Service[instance] = flag;
|
||||||
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(instance,
|
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(instance,
|
||||||
NV_SEEPROM_BO_OUT_OF_SERVICE), &Out_Of_Service[instance],
|
NV_SEEPROM_BO_OUT_OF_SERVICE), &Out_Of_Service[instance], 1);
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +279,8 @@ int Binary_Output_Read_Property(
|
|||||||
switch (rpdata->object_property) {
|
switch (rpdata->object_property) {
|
||||||
/* object id, object name, object type are handled in Device object */
|
/* object id, object name, object type are handled in Device object */
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Output_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -298,12 +298,14 @@ int Binary_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Binary_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Output_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;
|
||||||
case PROP_POLARITY:
|
case PROP_POLARITY:
|
||||||
object_index = Binary_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_enumerated(&apdu[0],
|
encode_application_enumerated(&apdu[0],
|
||||||
Polarity[object_index]);
|
Polarity[object_index]);
|
||||||
@@ -343,7 +345,8 @@ int Binary_Output_Read_Property(
|
|||||||
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
present_value =
|
present_value =
|
||||||
Binary_Output_Level[object_index][rpdata->array_index - 1];
|
Binary_Output_Level[object_index][rpdata->array_index -
|
||||||
|
1];
|
||||||
if (present_value == BINARY_NULL) {
|
if (present_value == BINARY_NULL) {
|
||||||
apdu_len = encode_application_null(&apdu[apdu_len]);
|
apdu_len = encode_application_null(&apdu[apdu_len]);
|
||||||
} else {
|
} else {
|
||||||
@@ -379,8 +382,7 @@ int Binary_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -408,10 +410,9 @@ bool Binary_Output_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
@@ -422,8 +423,7 @@ 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;
|
||||||
priority--;
|
priority--;
|
||||||
Binary_Output_Present_Value_Set(
|
Binary_Output_Present_Value_Set(wp_data->object_instance,
|
||||||
wp_data->object_instance,
|
|
||||||
level, priority);
|
level, priority);
|
||||||
} else if (priority == 6) {
|
} else if (priority == 6) {
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
@@ -438,18 +438,16 @@ bool Binary_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = BINARY_NULL;
|
level = BINARY_NULL;
|
||||||
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,
|
object_instance, level, priority);
|
||||||
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
|
||||||
@@ -466,26 +464,22 @@ bool Binary_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Binary_Output_Out_Of_Service_Set(
|
Binary_Output_Out_Of_Service_Set(wp_data->object_instance,
|
||||||
wp_data->object_instance,
|
|
||||||
value.type.Boolean);
|
value.type.Boolean);
|
||||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
Binary_Output_Level_Sync(wp_data->object_instance);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_POLARITY:
|
case PROP_POLARITY:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Enumerated < MAX_POLARITY) {
|
if (value.type.Enumerated < MAX_POLARITY) {
|
||||||
Binary_Output_Polarity_Set(
|
Binary_Output_Polarity_Set(wp_data->object_instance,
|
||||||
wp_data->object_instance,
|
|
||||||
value.type.Enumerated);
|
value.type.Enumerated);
|
||||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
Binary_Output_Level_Sync(wp_data->object_instance);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -62,55 +62,30 @@ static struct object_functions {
|
|||||||
read_property_function Object_Read_Property;
|
read_property_function Object_Read_Property;
|
||||||
write_property_function Object_Write_Property;
|
write_property_function Object_Write_Property;
|
||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
} Object_Table[] =
|
} Object_Table[] = {
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||||
NULL,/* don't init - recursive! */
|
Device_Count, Device_Index_To_Instance,
|
||||||
Device_Count,
|
Device_Valid_Object_Instance_Number, Device_Name,
|
||||||
Device_Index_To_Instance,
|
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||||
Device_Valid_Object_Instance_Number,
|
Device_Property_Lists}, {
|
||||||
Device_Name,
|
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||||
Device_Read_Property_Local,
|
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||||
Device_Write_Property_Local,
|
Analog_Input_Name, Analog_Input_Read_Property, NULL,
|
||||||
Device_Property_Lists},
|
Analog_Input_Property_Lists}, {
|
||||||
{OBJECT_ANALOG_INPUT,
|
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||||
Analog_Input_Init,
|
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||||
Analog_Input_Count,
|
Analog_Value_Name, Analog_Value_Read_Property,
|
||||||
Analog_Input_Index_To_Instance,
|
Analog_Value_Write_Property, Analog_Value_Property_Lists}, {
|
||||||
Analog_Input_Valid_Instance,
|
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||||
Analog_Input_Name,
|
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||||
Analog_Input_Read_Property,
|
Binary_Input_Name, Binary_Input_Read_Property, NULL,
|
||||||
NULL,
|
Binary_Input_Property_Lists}, {
|
||||||
Analog_Input_Property_Lists},
|
OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count,
|
||||||
{OBJECT_ANALOG_VALUE,
|
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||||
Analog_Value_Init,
|
Binary_Output_Name, Binary_Output_Read_Property,
|
||||||
Analog_Value_Count,
|
Binary_Output_Write_Property, Binary_Output_Property_Lists}, {
|
||||||
Analog_Value_Index_To_Instance,
|
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||||
Analog_Value_Valid_Instance,
|
|
||||||
Analog_Value_Name,
|
|
||||||
Analog_Value_Read_Property,
|
|
||||||
Analog_Value_Write_Property,
|
|
||||||
Analog_Value_Property_Lists},
|
|
||||||
{OBJECT_BINARY_INPUT,
|
|
||||||
Binary_Input_Init,
|
|
||||||
Binary_Input_Count,
|
|
||||||
Binary_Input_Index_To_Instance,
|
|
||||||
Binary_Input_Valid_Instance,
|
|
||||||
Binary_Input_Name,
|
|
||||||
Binary_Input_Read_Property,
|
|
||||||
NULL,
|
|
||||||
Binary_Input_Property_Lists},
|
|
||||||
{OBJECT_BINARY_OUTPUT,
|
|
||||||
Binary_Output_Init,
|
|
||||||
Binary_Output_Count,
|
|
||||||
Binary_Output_Index_To_Instance,
|
|
||||||
Binary_Output_Valid_Instance,
|
|
||||||
Binary_Output_Name,
|
|
||||||
Binary_Output_Read_Property,
|
|
||||||
Binary_Output_Write_Property,
|
|
||||||
Binary_Output_Property_Lists},
|
|
||||||
|
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* note: you really only need to define variables for
|
/* note: you really only need to define variables for
|
||||||
@@ -120,8 +95,7 @@ static struct object_functions {
|
|||||||
static uint32_t Object_Instance_Number;
|
static uint32_t Object_Instance_Number;
|
||||||
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
||||||
|
|
||||||
static BACNET_REINITIALIZED_STATE Reinitialize_State =
|
static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
|
||||||
BACNET_REINIT_IDLE;
|
|
||||||
|
|
||||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||||
static const int Device_Properties_Required[] = {
|
static const int Device_Properties_Required[] = {
|
||||||
@@ -199,8 +173,7 @@ static int Read_Property_Common(
|
|||||||
rpdata->object_instance = Object_Instance_Number;
|
rpdata->object_instance = Object_Instance_Number;
|
||||||
}
|
}
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0],
|
encode_application_object_id(&apdu[0], rpdata->object_type,
|
||||||
rpdata->object_type,
|
|
||||||
rpdata->object_instance);
|
rpdata->object_instance);
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
@@ -212,8 +185,8 @@ static int Read_Property_Common(
|
|||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_TYPE:
|
case PROP_OBJECT_TYPE:
|
||||||
apdu_len = encode_application_enumerated(&apdu[0],
|
apdu_len =
|
||||||
rpdata->object_type);
|
encode_application_enumerated(&apdu[0], rpdata->object_type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (pObject->Object_Read_Property) {
|
if (pObject->Object_Read_Property) {
|
||||||
@@ -313,21 +286,22 @@ void Device_Objects_Property_List(
|
|||||||
|
|
||||||
pObject = Device_Objects_Find_Functions(object_type);
|
pObject = Device_Objects_Find_Functions(object_type);
|
||||||
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
||||||
pObject->Object_RPM_List(
|
pObject->Object_RPM_List(&pPropertyList->Required.pList,
|
||||||
&pPropertyList->Required.pList,
|
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||||
&pPropertyList->Optional.pList,
|
|
||||||
&pPropertyList->Proprietary.pList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch the counts if available otherwise zero them */
|
/* Fetch the counts if available otherwise zero them */
|
||||||
pPropertyList->Required.count = pPropertyList->Required.pList == NULL
|
pPropertyList->Required.count =
|
||||||
? 0 : property_list_count(pPropertyList->Required.pList);
|
pPropertyList->Required.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Required.pList);
|
||||||
|
|
||||||
pPropertyList->Optional.count = pPropertyList->Optional.pList == NULL
|
pPropertyList->Optional.count =
|
||||||
? 0 : property_list_count(pPropertyList->Optional.pList);
|
pPropertyList->Optional.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Optional.pList);
|
||||||
|
|
||||||
pPropertyList->Proprietary.count = pPropertyList->Proprietary.pList == NULL
|
pPropertyList->Proprietary.count =
|
||||||
? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
pPropertyList->Proprietary.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -347,7 +321,8 @@ void Device_Property_Lists(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Device_Count(void)
|
unsigned Device_Count(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -372,14 +347,12 @@ char *Device_Name(
|
|||||||
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & name,
|
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & name,
|
||||||
NV_EEPROM_DEVICE_NAME_SIZE);
|
NV_EEPROM_DEVICE_NAME_SIZE);
|
||||||
if ((encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
if ((encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
||||||
(length > NV_EEPROM_DEVICE_NAME_SIZE) ||
|
(length > NV_EEPROM_DEVICE_NAME_SIZE) || (length < 1)) {
|
||||||
(length < 1)) {
|
|
||||||
encoding = CHARACTER_ANSI_X34;
|
encoding = CHARACTER_ANSI_X34;
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING, &encoding, 1);
|
||||||
&encoding, 1);
|
|
||||||
sprintf(name, "DEVICE-%lu", Object_Instance_Number);
|
sprintf(name, "DEVICE-%lu", Object_Instance_Number);
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & name[0],
|
||||||
(uint8_t *) & name[0], NV_EEPROM_DEVICE_NAME_SIZE);
|
NV_EEPROM_DEVICE_NAME_SIZE);
|
||||||
length = strlen(name);
|
length = strlen(name);
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &length, 1);
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &length, 1);
|
||||||
}
|
}
|
||||||
@@ -549,8 +522,7 @@ bool Device_Object_List_Identifier(
|
|||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Count &&
|
if (pObject->Object_Count && pObject->Object_Index_To_Instance) {
|
||||||
pObject->Object_Index_To_Instance) {
|
|
||||||
object_index -= count;
|
object_index -= count;
|
||||||
count = pObject->Object_Count();
|
count = pObject->Object_Count();
|
||||||
if (object_index < count) {
|
if (object_index < count) {
|
||||||
@@ -652,8 +624,7 @@ int Device_Read_Property_Local(
|
|||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_VENDOR_IDENTIFIER:
|
case PROP_VENDOR_IDENTIFIER:
|
||||||
apdu_len =
|
apdu_len = encode_application_unsigned(&apdu[0], BACNET_VENDOR_ID);
|
||||||
encode_application_unsigned(&apdu[0], BACNET_VENDOR_ID);
|
|
||||||
break;
|
break;
|
||||||
case PROP_MODEL_NAME:
|
case PROP_MODEL_NAME:
|
||||||
characterstring_init_ansi(&char_string, "bdk-atxx4-mstp");
|
characterstring_init_ansi(&char_string, "bdk-atxx4-mstp");
|
||||||
@@ -671,12 +642,10 @@ int Device_Read_Property_Local(
|
|||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_PROTOCOL_VERSION:
|
case PROP_PROTOCOL_VERSION:
|
||||||
apdu_len =
|
apdu_len = encode_application_unsigned(&apdu[0], 1);
|
||||||
encode_application_unsigned(&apdu[0], 1);
|
|
||||||
break;
|
break;
|
||||||
case PROP_PROTOCOL_REVISION:
|
case PROP_PROTOCOL_REVISION:
|
||||||
apdu_len =
|
apdu_len = encode_application_unsigned(&apdu[0], 5);
|
||||||
encode_application_unsigned(&apdu[0], 5);
|
|
||||||
break;
|
break;
|
||||||
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
||||||
/* Note: list of services that are executed, not initiated. */
|
/* Note: list of services that are executed, not initiated. */
|
||||||
@@ -701,8 +670,7 @@ int Device_Read_Property_Local(
|
|||||||
i = 0;
|
i = 0;
|
||||||
pObject = &Object_Table[i];
|
pObject = &Object_Table[i];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Count) &&
|
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
|
||||||
(pObject->Object_Count() > 0)) {
|
|
||||||
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
||||||
}
|
}
|
||||||
pObject++;
|
pObject++;
|
||||||
@@ -730,7 +698,8 @@ int Device_Read_Property_Local(
|
|||||||
/* can we all fit into the APDU? */
|
/* can we all fit into the APDU? */
|
||||||
if ((apdu_len + len) >= MAX_APDU) {
|
if ((apdu_len + len) >= MAX_APDU) {
|
||||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
rpdata->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -743,8 +712,8 @@ int Device_Read_Property_Local(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Device_Object_List_Identifier(rpdata->array_index, &object_type,
|
if (Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&instance))
|
&object_type, &instance))
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
instance);
|
instance);
|
||||||
@@ -803,8 +772,7 @@ int Device_Read_Property_Local(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
|
||||||
(rpdata->object_property != PROP_OBJECT_LIST) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -831,8 +799,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 {
|
||||||
@@ -892,18 +860,20 @@ bool Device_Write_Property_Local(
|
|||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
|
||||||
&small_length, 1);
|
&small_length, 1);
|
||||||
pCharString =
|
pCharString =
|
||||||
characterstring_value(&value.
|
characterstring_value(&value.type.
|
||||||
type.Character_String);
|
Character_String);
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
|
||||||
(uint8_t *) pCharString, length);
|
(uint8_t *) pCharString, length);
|
||||||
status = true;
|
status = true;
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
|||||||
@@ -102,10 +102,8 @@ static void bacnet_init(
|
|||||||
apdu_set_unrecognized_service_handler_handler
|
apdu_set_unrecognized_service_handler_handler
|
||||||
(handler_unrecognized_service);
|
(handler_unrecognized_service);
|
||||||
/* we need to handle who-is to support dynamic device binding */
|
/* we need to handle who-is to support dynamic device binding */
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||||
handler_who_is);
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
|
||||||
handler_who_has);
|
|
||||||
/* Set the handlers for any confirmed services that we support. */
|
/* Set the handlers for any confirmed services that we support. */
|
||||||
/* We must implement read property - it's required! */
|
/* We must implement read property - it's required! */
|
||||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ static FIFO_BUFFER Receive_Buffer;
|
|||||||
|
|
||||||
static struct etimer Silence_Timer;
|
static struct etimer Silence_Timer;
|
||||||
|
|
||||||
bool rs485_silence_time_elapsed(uint32_t milliseconds)
|
bool rs485_silence_time_elapsed(
|
||||||
|
uint32_t milliseconds)
|
||||||
{
|
{
|
||||||
return timer_elapsed_milliseconds(&Silence_Timer, milliseconds);
|
return timer_elapsed_milliseconds(&Silence_Timer, milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs485_silence_time_reset(void)
|
void rs485_silence_time_reset(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
timer_elapsed_start(&Silence_Timer);
|
timer_elapsed_start(&Silence_Timer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ extern "C" {
|
|||||||
|
|
||||||
void rs485_turnaround_delay(
|
void rs485_turnaround_delay(
|
||||||
void);
|
void);
|
||||||
void rs485_silence_time_reset(void);
|
void rs485_silence_time_reset(
|
||||||
bool rs485_silence_time_elapsed(uint32_t milliseconds);
|
void);
|
||||||
|
bool rs485_silence_time_elapsed(
|
||||||
|
uint32_t milliseconds);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,8 +427,8 @@ int seeprom_bytes_write_page(
|
|||||||
int seeprom_bytes_write(
|
int seeprom_bytes_write(
|
||||||
uint16_t off, /* SEEPROM starting memory address */
|
uint16_t off, /* SEEPROM starting memory address */
|
||||||
uint8_t * buf, /* data to send */
|
uint8_t * buf, /* data to send */
|
||||||
int len) /* number of bytes of data */
|
int len)
|
||||||
{
|
{ /* number of bytes of data */
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,8 @@ void timer_interval_restart(
|
|||||||
|
|
||||||
static uint32_t Milliseconds;
|
static uint32_t Milliseconds;
|
||||||
|
|
||||||
uint32_t timer_milliseconds(void)
|
uint32_t timer_milliseconds(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return Milliseconds;
|
return Milliseconds;
|
||||||
}
|
}
|
||||||
@@ -364,4 +365,3 @@ int main(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ extern "C" {
|
|||||||
/* these 3 functions are created in the hardware specific module */
|
/* these 3 functions are created in the hardware specific module */
|
||||||
void timer_init(
|
void timer_init(
|
||||||
void);
|
void);
|
||||||
uint32_t timer_milliseconds(void);
|
uint32_t timer_milliseconds(
|
||||||
|
void);
|
||||||
uint32_t timer_milliseconds_set(
|
uint32_t timer_milliseconds_set(
|
||||||
uint32_t value);
|
uint32_t value);
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ uint32_t timer_milliseconds_set(
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
uint32_t timer_milliseconds(void)
|
uint32_t timer_milliseconds(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint32_t timer_value = 0; /* return value */
|
uint32_t timer_value = 0; /* return value */
|
||||||
uint8_t sreg = 0; /* holds interrupts pending */
|
uint8_t sreg = 0; /* holds interrupts pending */
|
||||||
@@ -93,7 +94,8 @@ uint32_t timer_milliseconds(void)
|
|||||||
* Returns: none
|
* Returns: none
|
||||||
* Notes: none
|
* Notes: none
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void timer_init(void)
|
void timer_init(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
/* Normal Operation */
|
/* Normal Operation */
|
||||||
TCCR2A = 0;
|
TCCR2A = 0;
|
||||||
|
|||||||
@@ -102,4 +102,3 @@ extern int bip_get_local_netmask(
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ int Analog_Input_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -320,8 +320,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
|
||||||
|
|||||||
@@ -185,8 +185,7 @@ int Binary_Input_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -186,8 +186,7 @@ int Binary_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -233,8 +232,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;
|
||||||
|
|||||||
@@ -50,8 +50,7 @@
|
|||||||
static uint32_t Object_Instance_Number = 12345;
|
static uint32_t Object_Instance_Number = 12345;
|
||||||
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
||||||
|
|
||||||
BACNET_REINITIALIZED_STATE Reinitialize_State =
|
BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
|
||||||
BACNET_REINIT_IDLE;
|
|
||||||
|
|
||||||
void Device_Reinit(
|
void Device_Reinit(
|
||||||
void)
|
void)
|
||||||
@@ -476,8 +475,7 @@ int Device_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (property != PROP_OBJECT_LIST) &&
|
||||||
(property != PROP_OBJECT_LIST) &&
|
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
(array_index != BACNET_ARRAY_ALL)) {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -511,8 +509,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 {
|
||||||
|
|||||||
@@ -664,7 +664,8 @@ bool dlmstp_init(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "MS/TP MAC: %02X\n", MSTP_Port.This_Station);
|
fprintf(stderr, "MS/TP MAC: %02X\n", MSTP_Port.This_Station);
|
||||||
fprintf(stderr, "MS/TP Max_Master: %02X\n", MSTP_Port.Nmax_master);
|
fprintf(stderr, "MS/TP Max_Master: %02X\n", MSTP_Port.Nmax_master);
|
||||||
fprintf(stderr, "MS/TP Max_Info_Frames: %u\n", (unsigned)MSTP_Port.Nmax_info_frames);
|
fprintf(stderr, "MS/TP Max_Info_Frames: %u\n",
|
||||||
|
(unsigned) MSTP_Port.Nmax_info_frames);
|
||||||
#endif
|
#endif
|
||||||
/* start the threads */
|
/* start the threads */
|
||||||
hThread = _beginthread(dlmstp_millisecond_task, 4096, &arg_value);
|
hThread = _beginthread(dlmstp_millisecond_task, 4096, &arg_value);
|
||||||
|
|||||||
+25
-20
@@ -149,8 +149,7 @@ struct Address_Cache_Entry *address_remove_oldest(
|
|||||||
|
|
||||||
pMatch = Address_Cache;
|
pMatch = Address_Cache;
|
||||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||||
if ((pMatch->
|
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
|
||||||
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
|
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
|
||||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||||
ulTime = pMatch->TimeToLive;
|
ulTime = pMatch->TimeToLive;
|
||||||
@@ -169,8 +168,7 @@ struct Address_Cache_Entry *address_remove_oldest(
|
|||||||
/* Second pass - try in use and un bound as last resort */
|
/* Second pass - try in use and un bound as last resort */
|
||||||
pMatch = Address_Cache;
|
pMatch = Address_Cache;
|
||||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||||
if ((pMatch->
|
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
|
||||||
BAC_ADDR_STATIC)) ==
|
BAC_ADDR_STATIC)) ==
|
||||||
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
||||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||||
@@ -580,7 +578,8 @@ unsigned address_count(
|
|||||||
pMatch = Address_Cache;
|
pMatch = Address_Cache;
|
||||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||||
/* Only count bound entries */
|
/* Only count bound entries */
|
||||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == BAC_ADDR_IN_USE)
|
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) ==
|
||||||
|
BAC_ADDR_IN_USE)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
pMatch++;
|
pMatch++;
|
||||||
@@ -719,8 +718,7 @@ int rr_address_list_encode(
|
|||||||
if (iTemp < 1) { /* if count is too much, return from 1 to start index */
|
if (iTemp < 1) { /* if count is too much, return from 1 to start index */
|
||||||
pRequest->Count = pRequest->Range.RefIndex;
|
pRequest->Count = pRequest->Range.RefIndex;
|
||||||
pRequest->Range.RefIndex = 1;
|
pRequest->Range.RefIndex = 1;
|
||||||
}
|
} else { /* Otherwise adjust the start index and make count +ve */
|
||||||
else { /* Otherwise adjust the start index and make count +ve */
|
|
||||||
pRequest->Range.RefIndex = iTemp;
|
pRequest->Range.RefIndex = iTemp;
|
||||||
pRequest->Count = -pRequest->Count;
|
pRequest->Count = -pRequest->Count;
|
||||||
}
|
}
|
||||||
@@ -745,8 +743,7 @@ int rr_address_list_encode(
|
|||||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == BAC_ADDR_IN_USE) { /* Only count bound entries */
|
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == BAC_ADDR_IN_USE) { /* Only count bound entries */
|
||||||
pMatch++;
|
pMatch++;
|
||||||
uiIndex++;
|
uiIndex++;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
pMatch++;
|
pMatch++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,25 +754,32 @@ int rr_address_list_encode(
|
|||||||
* Can't fit any more in! We just set the result flag to say there
|
* Can't fit any more in! We just set the result flag to say there
|
||||||
* was more and drop out of the loop early
|
* was more and drop out of the loop early
|
||||||
*/
|
*/
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS,
|
||||||
|
true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
iTemp = (int32_t)encode_application_object_id(&apdu[iLen],
|
iTemp =
|
||||||
OBJECT_DEVICE,
|
(int32_t) encode_application_object_id(&apdu[iLen], OBJECT_DEVICE,
|
||||||
pMatch->device_id);
|
pMatch->device_id);
|
||||||
iTemp += encode_application_unsigned(&apdu[iLen + iTemp],
|
iTemp +=
|
||||||
|
encode_application_unsigned(&apdu[iLen + iTemp],
|
||||||
pMatch->address.net);
|
pMatch->address.net);
|
||||||
|
|
||||||
/* pick the appropriate type of entry from the cache */
|
/* pick the appropriate type of entry from the cache */
|
||||||
|
|
||||||
if (pMatch->address.len != 0) {
|
if (pMatch->address.len != 0) {
|
||||||
octetstring_init(&MAC_Address, pMatch->address.adr, pMatch->address.len);
|
octetstring_init(&MAC_Address, pMatch->address.adr,
|
||||||
iTemp += encode_application_octet_string(&apdu[iLen + iTemp], &MAC_Address);
|
pMatch->address.len);
|
||||||
}
|
iTemp +=
|
||||||
else {
|
encode_application_octet_string(&apdu[iLen + iTemp],
|
||||||
octetstring_init(&MAC_Address, pMatch->address.mac, pMatch->address.mac_len);
|
&MAC_Address);
|
||||||
iTemp += encode_application_octet_string(&apdu[iLen + iTemp], &MAC_Address);
|
} else {
|
||||||
|
octetstring_init(&MAC_Address, pMatch->address.mac,
|
||||||
|
pMatch->address.mac_len);
|
||||||
|
iTemp +=
|
||||||
|
encode_application_octet_string(&apdu[iLen + iTemp],
|
||||||
|
&MAC_Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiRemaining -= iTemp; /* Reduce the remaining space */
|
uiRemaining -= iTemp; /* Reduce the remaining space */
|
||||||
@@ -792,7 +796,8 @@ int rr_address_list_encode(
|
|||||||
|
|
||||||
/* Set remaining result flags if necessary */
|
/* Set remaining result flags if necessary */
|
||||||
if (uiFirst == 1)
|
if (uiFirst == 1)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM,
|
||||||
|
true);
|
||||||
|
|
||||||
if (uiLast == uiTotal)
|
if (uiLast == uiTotal)
|
||||||
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true);
|
||||||
|
|||||||
+16
-14
@@ -837,7 +837,8 @@ bool bacapp_print_value(
|
|||||||
fprintf(stream, "%s", value->type.Boolean ? "TRUE" : "FALSE");
|
fprintf(stream, "%s", value->type.Boolean ? "TRUE" : "FALSE");
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||||
fprintf(stream, "%lu", (unsigned long)value->type.Unsigned_Int);
|
fprintf(stream, "%lu",
|
||||||
|
(unsigned long) value->type.Unsigned_Int);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||||
fprintf(stream, "%ld", (long) value->type.Signed_Int);
|
fprintf(stream, "%ld", (long) value->type.Signed_Int);
|
||||||
@@ -890,8 +891,8 @@ bool bacapp_print_value(
|
|||||||
case PROP_OBJECT_TYPE:
|
case PROP_OBJECT_TYPE:
|
||||||
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
|
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
bactext_object_type_name(value->type.
|
bactext_object_type_name(value->
|
||||||
Enumerated));
|
type.Enumerated));
|
||||||
} else if (value->type.Enumerated < 128) {
|
} else if (value->type.Enumerated < 128) {
|
||||||
fprintf(stream, "reserved %lu",
|
fprintf(stream, "reserved %lu",
|
||||||
(unsigned long) value->type.Enumerated);
|
(unsigned long) value->type.Enumerated);
|
||||||
@@ -907,8 +908,8 @@ bool bacapp_print_value(
|
|||||||
case PROP_UNITS:
|
case PROP_UNITS:
|
||||||
if (value->type.Enumerated < 256) {
|
if (value->type.Enumerated < 256) {
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
bactext_engineering_unit_name(value->
|
bactext_engineering_unit_name(value->type.
|
||||||
type.Enumerated));
|
Enumerated));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "proprietary %lu",
|
fprintf(stream, "proprietary %lu",
|
||||||
(unsigned long) value->type.Enumerated);
|
(unsigned long) value->type.Enumerated);
|
||||||
@@ -916,13 +917,13 @@ bool bacapp_print_value(
|
|||||||
break;
|
break;
|
||||||
case PROP_POLARITY:
|
case PROP_POLARITY:
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
bactext_binary_polarity_name(value->
|
bactext_binary_polarity_name(value->type.
|
||||||
type.Enumerated));
|
Enumerated));
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
bactext_binary_present_value_name(value->
|
bactext_binary_present_value_name(value->type.
|
||||||
type.Enumerated));
|
Enumerated));
|
||||||
break;
|
break;
|
||||||
case PROP_RELIABILITY:
|
case PROP_RELIABILITY:
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
@@ -930,8 +931,8 @@ bool bacapp_print_value(
|
|||||||
break;
|
break;
|
||||||
case PROP_SYSTEM_STATUS:
|
case PROP_SYSTEM_STATUS:
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
bactext_device_status_name(value->
|
bactext_device_status_name(value->type.
|
||||||
type.Enumerated));
|
Enumerated));
|
||||||
break;
|
break;
|
||||||
case PROP_SEGMENTATION_SUPPORTED:
|
case PROP_SEGMENTATION_SUPPORTED:
|
||||||
fprintf(stream, "%s",
|
fprintf(stream, "%s",
|
||||||
@@ -942,7 +943,8 @@ bool bacapp_print_value(
|
|||||||
bactext_node_type_name(value->type.Enumerated));
|
bactext_node_type_name(value->type.Enumerated));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stream, "%lu", (unsigned long)value->type.Enumerated);
|
fprintf(stream, "%lu",
|
||||||
|
(unsigned long) value->type.Enumerated);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1301,8 +1303,8 @@ void testBACnetApplicationData_Safe(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||||
characterstring_init_ansi(&input_value[i].type.
|
characterstring_init_ansi(&input_value[i].
|
||||||
Character_String, "Hello There!");
|
type.Character_String, "Hello There!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||||
|
|||||||
@@ -2010,7 +2010,8 @@ void testBACDCodeUnsignedValue(
|
|||||||
len = decode_unsigned(&array[len], len_value, &decoded_value);
|
len = decode_unsigned(&array[len], len_value, &decoded_value);
|
||||||
ct_test(pTest, decoded_value == value);
|
ct_test(pTest, decoded_value == value);
|
||||||
if (decoded_value != value) {
|
if (decoded_value != value) {
|
||||||
printf("value=%lu decoded_value=%lu\n", (unsigned long)value, (unsigned long)decoded_value);
|
printf("value=%lu decoded_value=%lu\n", (unsigned long) value,
|
||||||
|
(unsigned long) decoded_value);
|
||||||
print_apdu(&array[0], sizeof(array));
|
print_apdu(&array[0], sizeof(array));
|
||||||
}
|
}
|
||||||
encode_application_unsigned(&encoded_array[0], decoded_value);
|
encode_application_unsigned(&encoded_array[0], decoded_value);
|
||||||
@@ -2078,14 +2079,16 @@ void testBACDCodeSignedValue(
|
|||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_SIGNED_INT);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||||
ct_test(pTest, decoded_value == value);
|
ct_test(pTest, decoded_value == value);
|
||||||
if (decoded_value != value) {
|
if (decoded_value != value) {
|
||||||
printf("value=%ld decoded_value=%ld\n", (long)value, (long)decoded_value);
|
printf("value=%ld decoded_value=%ld\n", (long) value,
|
||||||
|
(long) decoded_value);
|
||||||
print_apdu(&array[0], sizeof(array));
|
print_apdu(&array[0], sizeof(array));
|
||||||
}
|
}
|
||||||
encode_application_signed(&encoded_array[0], decoded_value);
|
encode_application_signed(&encoded_array[0], decoded_value);
|
||||||
diff = memcmp(&array[0], &encoded_array[0], sizeof(array));
|
diff = memcmp(&array[0], &encoded_array[0], sizeof(array));
|
||||||
ct_test(pTest, diff == 0);
|
ct_test(pTest, diff == 0);
|
||||||
if (diff) {
|
if (diff) {
|
||||||
printf("value=%ld decoded_value=%ld\n", (long)value, (long)decoded_value);
|
printf("value=%ld decoded_value=%ld\n", (long) value,
|
||||||
|
(long) decoded_value);
|
||||||
print_apdu(&array[0], sizeof(array));
|
print_apdu(&array[0], sizeof(array));
|
||||||
print_apdu(&encoded_array[0], sizeof(array));
|
print_apdu(&encoded_array[0], sizeof(array));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,8 +264,7 @@ int bacapp_decode_context_device_obj_ref(
|
|||||||
|
|
||||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||||
len++;
|
len++;
|
||||||
section_length =
|
section_length = bacapp_decode_device_obj_ref(&apdu[len], value);
|
||||||
bacapp_decode_device_obj_ref(&apdu[len], value);
|
|
||||||
|
|
||||||
if (section_length == -1) {
|
if (section_length == -1) {
|
||||||
len = -1;
|
len = -1;
|
||||||
|
|||||||
@@ -677,8 +677,8 @@ static void bvlc_bdt_forward_npdu(
|
|||||||
mask in the BDT entry and logically ORing it with the
|
mask in the BDT entry and logically ORing it with the
|
||||||
BBMD address of the same entry. */
|
BBMD address of the same entry. */
|
||||||
bip_dest.sin_addr.s_addr =
|
bip_dest.sin_addr.s_addr =
|
||||||
htonl(((~BBMD_Table[i].broadcast_mask.
|
htonl(((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
|
||||||
s_addr) | BBMD_Table[i].dest_address.s_addr));
|
dest_address.s_addr));
|
||||||
bip_dest.sin_port = htons(BBMD_Table[i].dest_port);
|
bip_dest.sin_port = htons(BBMD_Table[i].dest_port);
|
||||||
/* don't send to my broadcast address and same port */
|
/* don't send to my broadcast address and same port */
|
||||||
if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr()))
|
if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr()))
|
||||||
|
|||||||
@@ -412,8 +412,8 @@ bool datetime_wildcard_present(
|
|||||||
if (bdatetime) {
|
if (bdatetime) {
|
||||||
if ((bdatetime->date.year == (1900 + 0xFF)) ||
|
if ((bdatetime->date.year == (1900 + 0xFF)) ||
|
||||||
(bdatetime->date.month > 12) || (bdatetime->date.day > 31) ||
|
(bdatetime->date.month > 12) || (bdatetime->date.day > 31) ||
|
||||||
(bdatetime->time.hour == 0xFF) ||
|
(bdatetime->time.hour == 0xFF) || (bdatetime->time.min == 0xFF) ||
|
||||||
(bdatetime->time.min == 0xFF) || (bdatetime->time.sec == 0xFF) ||
|
(bdatetime->time.sec == 0xFF) ||
|
||||||
(bdatetime->time.hundredths == 0xFF)) {
|
(bdatetime->time.hundredths == 0xFF)) {
|
||||||
wildcard_present = true;
|
wildcard_present = true;
|
||||||
}
|
}
|
||||||
@@ -421,6 +421,7 @@ bool datetime_wildcard_present(
|
|||||||
|
|
||||||
return wildcard_present;
|
return wildcard_present;
|
||||||
}
|
}
|
||||||
|
|
||||||
void datetime_date_wildcard_set(
|
void datetime_date_wildcard_set(
|
||||||
BACNET_DATE * bdate)
|
BACNET_DATE * bdate)
|
||||||
{
|
{
|
||||||
|
|||||||
+134
-139
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 0,
|
encode_context_bitstring(&apdu[apdu_len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.referencedBitString);
|
referencedBitString);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.statusFlags);
|
statusFlags);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||||
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfState.
|
||||||
changeOfState.statusFlags);
|
statusFlags);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], 1);
|
len = encode_closing_tag(&apdu[apdu_len], 1);
|
||||||
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
|
|||||||
case CHANGE_OF_VALUE_REAL:
|
case CHANGE_OF_VALUE_REAL:
|
||||||
len =
|
len =
|
||||||
encode_context_real(&apdu[apdu_len], 1,
|
encode_context_real(&apdu[apdu_len], 1,
|
||||||
data->notificationParams.
|
data->notificationParams.changeOfValue.
|
||||||
changeOfValue.newValue.changeValue);
|
newValue.changeValue);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
|
|||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len],
|
encode_context_bitstring(&apdu[apdu_len],
|
||||||
0,
|
0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfValue.
|
||||||
changeOfValue.newValue.changedBits);
|
newValue.changedBits);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfValue.
|
||||||
changeOfValue.statusFlags);
|
statusFlags);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], 2);
|
len = encode_closing_tag(&apdu[apdu_len], 2);
|
||||||
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_real(&apdu[apdu_len], 0,
|
encode_context_real(&apdu[apdu_len], 0,
|
||||||
data->notificationParams.
|
data->notificationParams.floatingLimit.
|
||||||
floatingLimit.referenceValue);
|
referenceValue);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.floatingLimit.
|
||||||
floatingLimit.statusFlags);
|
statusFlags);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_real(&apdu[apdu_len], 2,
|
encode_context_real(&apdu[apdu_len], 2,
|
||||||
data->notificationParams.
|
data->notificationParams.floatingLimit.
|
||||||
floatingLimit.setPointValue);
|
setPointValue);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_real(&apdu[apdu_len], 0,
|
encode_context_real(&apdu[apdu_len], 0,
|
||||||
data->notificationParams.
|
data->notificationParams.outOfRange.
|
||||||
outOfRange.exceedingValue);
|
exceedingValue);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_enumerated(&apdu[apdu_len], 0,
|
encode_context_enumerated(&apdu[apdu_len], 0,
|
||||||
data->notificationParams.
|
data->notificationParams.changeOfLifeSafety.
|
||||||
changeOfLifeSafety.newState);
|
newState);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_enumerated(&apdu[apdu_len], 1,
|
encode_context_enumerated(&apdu[apdu_len], 1,
|
||||||
data->notificationParams.
|
data->notificationParams.changeOfLifeSafety.
|
||||||
changeOfLifeSafety.newMode);
|
newMode);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 2,
|
encode_context_bitstring(&apdu[apdu_len], 2,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfLifeSafety.
|
||||||
changeOfLifeSafety.statusFlags);
|
statusFlags);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_enumerated(&apdu[apdu_len], 3,
|
encode_context_enumerated(&apdu[apdu_len], 3,
|
||||||
data->notificationParams.
|
data->notificationParams.changeOfLifeSafety.
|
||||||
changeOfLifeSafety.operationExpected);
|
operationExpected);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], 8);
|
len = encode_closing_tag(&apdu[apdu_len], 8);
|
||||||
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
|
|||||||
len =
|
len =
|
||||||
bacapp_encode_context_device_obj_property_ref(&apdu
|
bacapp_encode_context_device_obj_property_ref(&apdu
|
||||||
[apdu_len], 0,
|
[apdu_len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.bufferReady.
|
||||||
bufferReady.bufferProperty);
|
bufferProperty);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_unsigned(&apdu[apdu_len], 1,
|
encode_context_unsigned(&apdu[apdu_len], 1,
|
||||||
data->notificationParams.
|
data->notificationParams.bufferReady.
|
||||||
bufferReady.previousNotification);
|
previousNotification);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||||
data->notificationParams.
|
data->notificationParams.bufferReady.
|
||||||
bufferReady.currentNotification);
|
currentNotification);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], 10);
|
len = encode_closing_tag(&apdu[apdu_len], 10);
|
||||||
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
|
|||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_unsigned(&apdu[apdu_len], 0,
|
encode_context_unsigned(&apdu[apdu_len], 0,
|
||||||
data->notificationParams.
|
data->notificationParams.unsignedRange.
|
||||||
unsignedRange.exceedingValue);
|
exceedingValue);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.unsignedRange.
|
||||||
unsignedRange.statusFlags);
|
statusFlags);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len =
|
len =
|
||||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||||
data->notificationParams.
|
data->notificationParams.unsignedRange.
|
||||||
unsignedRange.exceededLimit);
|
exceededLimit);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], 11);
|
len = encode_closing_tag(&apdu[apdu_len], 11);
|
||||||
@@ -595,18 +595,16 @@ int event_notify_decode_service_request(
|
|||||||
case EVENT_CHANGE_OF_BITSTRING:
|
case EVENT_CHANGE_OF_BITSTRING:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 0,
|
decode_context_bitstring(&apdu[len], 0,
|
||||||
&data->
|
&data->notificationParams.
|
||||||
notificationParams.changeOfBitstring.
|
changeOfBitstring.referencedBitString))) {
|
||||||
referencedBitString))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->
|
&data->notificationParams.
|
||||||
notificationParams.changeOfBitstring.
|
changeOfBitstring.statusFlags))) {
|
||||||
statusFlags))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -617,16 +615,16 @@ int event_notify_decode_service_request(
|
|||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
bacapp_decode_context_property_state(&apdu
|
bacapp_decode_context_property_state(&apdu
|
||||||
[len], 0,
|
[len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfState.
|
||||||
changeOfState.newState))) {
|
newState))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfState.
|
||||||
changeOfState.statusFlags))) {
|
statusFlags))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -644,9 +642,8 @@ int event_notify_decode_service_request(
|
|||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 0,
|
decode_context_bitstring(&apdu[len], 0,
|
||||||
&data->
|
&data->notificationParams.
|
||||||
notificationParams.changeOfValue.
|
changeOfValue.newValue.changedBits))) {
|
||||||
newValue.changedBits))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,9 +654,8 @@ int event_notify_decode_service_request(
|
|||||||
CHANGE_OF_VALUE_REAL)) {
|
CHANGE_OF_VALUE_REAL)) {
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 1,
|
decode_context_real(&apdu[len], 1,
|
||||||
&data->
|
&data->notificationParams.
|
||||||
notificationParams.changeOfValue.
|
changeOfValue.newValue.changeValue))) {
|
||||||
newValue.changeValue))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,8 +673,8 @@ int event_notify_decode_service_request(
|
|||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.changeOfValue.
|
||||||
changeOfValue.statusFlags))) {
|
statusFlags))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -687,31 +683,31 @@ int event_notify_decode_service_request(
|
|||||||
case EVENT_FLOATING_LIMIT:
|
case EVENT_FLOATING_LIMIT:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 0,
|
decode_context_real(&apdu[len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.floatingLimit.
|
||||||
floatingLimit.referenceValue))) {
|
referenceValue))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.floatingLimit.
|
||||||
floatingLimit.statusFlags))) {
|
statusFlags))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 2,
|
decode_context_real(&apdu[len], 2,
|
||||||
&data->notificationParams.
|
&data->notificationParams.floatingLimit.
|
||||||
floatingLimit.setPointValue))) {
|
setPointValue))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 3,
|
decode_context_real(&apdu[len], 3,
|
||||||
&data->notificationParams.
|
&data->notificationParams.floatingLimit.
|
||||||
floatingLimit.errorLimit))) {
|
errorLimit))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -720,31 +716,31 @@ int event_notify_decode_service_request(
|
|||||||
case EVENT_OUT_OF_RANGE:
|
case EVENT_OUT_OF_RANGE:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 0,
|
decode_context_real(&apdu[len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.outOfRange.
|
||||||
outOfRange.exceedingValue))) {
|
exceedingValue))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.outOfRange.
|
||||||
outOfRange.statusFlags))) {
|
statusFlags))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 2,
|
decode_context_real(&apdu[len], 2,
|
||||||
&data->notificationParams.
|
&data->notificationParams.outOfRange.
|
||||||
outOfRange.deadband))) {
|
deadband))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_real(&apdu[len], 3,
|
decode_context_real(&apdu[len], 3,
|
||||||
&data->notificationParams.
|
&data->notificationParams.outOfRange.
|
||||||
outOfRange.exceededLimit))) {
|
exceededLimit))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -772,9 +768,8 @@ int event_notify_decode_service_request(
|
|||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 2,
|
decode_context_bitstring(&apdu[len], 2,
|
||||||
&data->
|
&data->notificationParams.
|
||||||
notificationParams.changeOfLifeSafety.
|
changeOfLifeSafety.statusFlags))) {
|
||||||
statusFlags))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -784,8 +779,8 @@ int event_notify_decode_service_request(
|
|||||||
&value))) {
|
&value))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
data->notificationParams.
|
data->notificationParams.changeOfLifeSafety.
|
||||||
changeOfLifeSafety.operationExpected =
|
operationExpected =
|
||||||
(BACNET_LIFE_SAFETY_OPERATION) value;
|
(BACNET_LIFE_SAFETY_OPERATION) value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
break;
|
break;
|
||||||
@@ -794,24 +789,24 @@ int event_notify_decode_service_request(
|
|||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
bacapp_decode_context_device_obj_property_ref
|
bacapp_decode_context_device_obj_property_ref
|
||||||
(&apdu[len], 0,
|
(&apdu[len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.bufferReady.
|
||||||
bufferReady.bufferProperty))) {
|
bufferProperty))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_unsigned(&apdu[len], 1,
|
decode_context_unsigned(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.bufferReady.
|
||||||
bufferReady.previousNotification))) {
|
previousNotification))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_unsigned(&apdu[len], 2,
|
decode_context_unsigned(&apdu[len], 2,
|
||||||
&data->notificationParams.
|
&data->notificationParams.bufferReady.
|
||||||
bufferReady.currentNotification))) {
|
currentNotification))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -820,24 +815,24 @@ int event_notify_decode_service_request(
|
|||||||
case EVENT_UNSIGNED_RANGE:
|
case EVENT_UNSIGNED_RANGE:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_unsigned(&apdu[len], 0,
|
decode_context_unsigned(&apdu[len], 0,
|
||||||
&data->notificationParams.
|
&data->notificationParams.unsignedRange.
|
||||||
unsignedRange.exceedingValue))) {
|
exceedingValue))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.unsignedRange.
|
||||||
unsignedRange.statusFlags))) {
|
statusFlags))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_unsigned(&apdu[len], 2,
|
decode_context_unsigned(&apdu[len], 2,
|
||||||
&data->notificationParams.
|
&data->notificationParams.unsignedRange.
|
||||||
unsignedRange.exceededLimit))) {
|
exceededLimit))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
@@ -1096,16 +1091,16 @@ void testEventEventState(
|
|||||||
|
|
||||||
data.eventType = EVENT_CHANGE_OF_BITSTRING;
|
data.eventType = EVENT_CHANGE_OF_BITSTRING;
|
||||||
|
|
||||||
bitstring_init(&data.notificationParams.
|
bitstring_init(&data.notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.referencedBitString);
|
referencedBitString);
|
||||||
bitstring_set_bit(&data.notificationParams.
|
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.referencedBitString, 0, true);
|
referencedBitString, 0, true);
|
||||||
bitstring_set_bit(&data.notificationParams.
|
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.referencedBitString, 1, false);
|
referencedBitString, 1, false);
|
||||||
bitstring_set_bit(&data.notificationParams.
|
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.referencedBitString, 2, true);
|
referencedBitString, 2, true);
|
||||||
bitstring_set_bit(&data.notificationParams.
|
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||||
changeOfBitstring.referencedBitString, 2, false);
|
referencedBitString, 2, false);
|
||||||
|
|
||||||
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
|
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
|
||||||
|
|
||||||
@@ -1191,16 +1186,16 @@ void testEventEventState(
|
|||||||
|
|
||||||
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
|
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
|
||||||
|
|
||||||
bitstring_init(&data.notificationParams.changeOfValue.
|
bitstring_init(&data.notificationParams.changeOfValue.newValue.
|
||||||
newValue.changedBits);
|
changedBits);
|
||||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||||
newValue.changedBits, 0, true);
|
changedBits, 0, true);
|
||||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||||
newValue.changedBits, 1, false);
|
changedBits, 1, false);
|
||||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||||
newValue.changedBits, 2, false);
|
changedBits, 2, false);
|
||||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||||
newValue.changedBits, 3, false);
|
changedBits, 3, false);
|
||||||
|
|
||||||
memset(buffer, 0, MAX_APDU);
|
memset(buffer, 0, MAX_APDU);
|
||||||
inLen = event_notify_encode_service_request(&buffer[0], &data);
|
inLen = event_notify_encode_service_request(&buffer[0], &data);
|
||||||
@@ -1440,12 +1435,12 @@ void testEventEventState(
|
|||||||
data.notificationParams.bufferReady.currentNotification = 2345;
|
data.notificationParams.bufferReady.currentNotification = 2345;
|
||||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
|
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
|
||||||
OBJECT_DEVICE;
|
OBJECT_DEVICE;
|
||||||
data.notificationParams.bufferReady.bufferProperty.
|
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||||
deviceIndentifier.instance = 500;
|
instance = 500;
|
||||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
|
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
|
||||||
OBJECT_ANALOG_INPUT;
|
OBJECT_ANALOG_INPUT;
|
||||||
data.notificationParams.bufferReady.bufferProperty.
|
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||||
objectIdentifier.instance = 100;
|
instance = 100;
|
||||||
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
|
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
|
||||||
PROP_PRESENT_VALUE;
|
PROP_PRESENT_VALUE;
|
||||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
|
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
|
||||||
@@ -1470,34 +1465,34 @@ void testEventEventState(
|
|||||||
|
|
||||||
|
|
||||||
ct_test(pTest,
|
ct_test(pTest,
|
||||||
data.notificationParams.bufferReady.bufferProperty.
|
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||||
deviceIndentifier.type ==
|
type ==
|
||||||
data2.notificationParams.bufferReady.bufferProperty.
|
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||||
deviceIndentifier.type);
|
type);
|
||||||
|
|
||||||
|
ct_test(pTest,
|
||||||
|
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||||
|
instance ==
|
||||||
|
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||||
|
instance);
|
||||||
|
|
||||||
|
ct_test(pTest,
|
||||||
|
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||||
|
instance ==
|
||||||
|
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||||
|
instance);
|
||||||
|
|
||||||
|
ct_test(pTest,
|
||||||
|
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||||
|
type ==
|
||||||
|
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||||
|
type);
|
||||||
|
|
||||||
ct_test(pTest,
|
ct_test(pTest,
|
||||||
data.notificationParams.bufferReady.bufferProperty.
|
data.notificationParams.bufferReady.bufferProperty.
|
||||||
deviceIndentifier.instance ==
|
propertyIdentifier ==
|
||||||
data2.notificationParams.bufferReady.bufferProperty.
|
data2.notificationParams.bufferReady.bufferProperty.
|
||||||
deviceIndentifier.instance);
|
propertyIdentifier);
|
||||||
|
|
||||||
ct_test(pTest,
|
|
||||||
data.notificationParams.bufferReady.bufferProperty.
|
|
||||||
objectIdentifier.instance ==
|
|
||||||
data2.notificationParams.bufferReady.bufferProperty.
|
|
||||||
objectIdentifier.instance);
|
|
||||||
|
|
||||||
ct_test(pTest,
|
|
||||||
data.notificationParams.bufferReady.bufferProperty.
|
|
||||||
objectIdentifier.type ==
|
|
||||||
data2.notificationParams.bufferReady.bufferProperty.
|
|
||||||
objectIdentifier.type);
|
|
||||||
|
|
||||||
ct_test(pTest,
|
|
||||||
data.notificationParams.bufferReady.
|
|
||||||
bufferProperty.propertyIdentifier ==
|
|
||||||
data2.notificationParams.bufferReady.
|
|
||||||
bufferProperty.propertyIdentifier);
|
|
||||||
|
|
||||||
ct_test(pTest,
|
ct_test(pTest,
|
||||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
|
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
|
||||||
|
|||||||
@@ -262,8 +262,7 @@ int getevent_ack_decode_service_request(
|
|||||||
len +=
|
len +=
|
||||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||||
&len_value);
|
&len_value);
|
||||||
len +=
|
len += decode_enumerated(&apdu[len], len_value, &enum_value);
|
||||||
decode_enumerated(&apdu[len], len_value, &enum_value);
|
|
||||||
event_data->notifyType = enum_value;
|
event_data->notifyType = enum_value;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -430,13 +429,15 @@ void testGetEventInformationAck(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
ct_test(pTest, len != -1);
|
ct_test(pTest, len != -1);
|
||||||
apdu_len = len;
|
apdu_len = len;
|
||||||
len = getevent_ack_encode_apdu_data(&apdu[apdu_len],
|
len =
|
||||||
sizeof(apdu)-apdu_len, &event_data);
|
getevent_ack_encode_apdu_data(&apdu[apdu_len], sizeof(apdu) - apdu_len,
|
||||||
|
&event_data);
|
||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
ct_test(pTest, len != -1);
|
ct_test(pTest, len != -1);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
len = getevent_ack_encode_apdu_end(&apdu[apdu_len],
|
len =
|
||||||
sizeof(apdu)-apdu_len, moreEvents);
|
getevent_ack_encode_apdu_end(&apdu[apdu_len], sizeof(apdu) - apdu_len,
|
||||||
|
moreEvents);
|
||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
ct_test(pTest, len != -1);
|
ct_test(pTest, len != -1);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|||||||
@@ -449,7 +449,8 @@ void MSTP_Receive_Frame_FSM(
|
|||||||
/* NoData */
|
/* NoData */
|
||||||
else if (mstp_port->DataLength == 0) {
|
else if (mstp_port->DataLength == 0) {
|
||||||
printf_receive_data("%s",
|
printf_receive_data("%s",
|
||||||
mstptext_frame_type((unsigned)mstp_port->FrameType));
|
mstptext_frame_type((unsigned) mstp_port->
|
||||||
|
FrameType));
|
||||||
if ((mstp_port->DestinationAddress ==
|
if ((mstp_port->DestinationAddress ==
|
||||||
mstp_port->This_Station)
|
mstp_port->This_Station)
|
||||||
|| (mstp_port->DestinationAddress ==
|
|| (mstp_port->DestinationAddress ==
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ int ptransfer_encode_apdu(
|
|||||||
apdu[3] = SERVICE_CONFIRMED_PRIVATE_TRANSFER;
|
apdu[3] = SERVICE_CONFIRMED_PRIVATE_TRANSFER;
|
||||||
apdu_len = 4;
|
apdu_len = 4;
|
||||||
len =
|
len =
|
||||||
pt_encode_apdu(&apdu[apdu_len], (uint16_t)(MAX_APDU - apdu_len), private_data);
|
pt_encode_apdu(&apdu[apdu_len], (uint16_t) (MAX_APDU - apdu_len),
|
||||||
|
private_data);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,8 @@ int uptransfer_encode_apdu(
|
|||||||
apdu[1] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
|
apdu[1] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
|
||||||
apdu_len = 2;
|
apdu_len = 2;
|
||||||
len =
|
len =
|
||||||
pt_encode_apdu(&apdu[apdu_len], (uint16_t)(MAX_APDU - apdu_len), private_data);
|
pt_encode_apdu(&apdu[apdu_len], (uint16_t) (MAX_APDU - apdu_len),
|
||||||
|
private_data);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-13
@@ -87,7 +87,8 @@ uint8_t *Ringbuf_Get_Front(
|
|||||||
RING_BUFFER const *b)
|
RING_BUFFER const *b)
|
||||||
{
|
{
|
||||||
if (b) {
|
if (b) {
|
||||||
return (!Ringbuf_Empty(b) ? &(b->data[(b->tail % b->element_count) * b->element_size]) : NULL);
|
return (!Ringbuf_Empty(b) ? &(b->data[(b->tail % b->element_count) *
|
||||||
|
b->element_size]) : NULL);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -128,7 +129,8 @@ bool Ringbuf_Put(
|
|||||||
if (b && data_element) {
|
if (b && data_element) {
|
||||||
/* limit the amount of elements that we accept */
|
/* limit the amount of elements that we accept */
|
||||||
if (!Ringbuf_Full(b)) {
|
if (!Ringbuf_Full(b)) {
|
||||||
ring_data = b->data + ((b->head % b->element_count) * b->element_size);
|
ring_data =
|
||||||
|
b->data + ((b->head % b->element_count) * b->element_size);
|
||||||
for (i = 0; i < b->element_size; i++) {
|
for (i = 0; i < b->element_size; i++) {
|
||||||
ring_data[i] = data_element[i];
|
ring_data[i] = data_element[i];
|
||||||
}
|
}
|
||||||
@@ -154,7 +156,8 @@ uint8_t *Ringbuf_Alloc(
|
|||||||
if (b) {
|
if (b) {
|
||||||
/* limit the amount of elements that we accept */
|
/* limit the amount of elements that we accept */
|
||||||
if (!Ringbuf_Full(b)) {
|
if (!Ringbuf_Full(b)) {
|
||||||
ring_data = b->data + ((b->head % b->element_count) * b->element_size);
|
ring_data =
|
||||||
|
b->data + ((b->head % b->element_count) * b->element_size);
|
||||||
b->head++;
|
b->head++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,8 +276,7 @@ void testRingBuf(
|
|||||||
for (index = 0; index < element_count; index++) {
|
for (index = 0; index < element_count; index++) {
|
||||||
for (count = 1; count < 4; count++) {
|
for (count = 1; count < 4; count++) {
|
||||||
dummy = index * count;
|
dummy = index * count;
|
||||||
for (data_index = 0; data_index < element_size;
|
for (data_index = 0; data_index < element_size; data_index++) {
|
||||||
data_index++) {
|
|
||||||
data_element[data_index] = dummy;
|
data_element[data_index] = dummy;
|
||||||
}
|
}
|
||||||
status = Ringbuf_Put(&test_buffer, data_element);
|
status = Ringbuf_Put(&test_buffer, data_element);
|
||||||
@@ -286,8 +288,7 @@ void testRingBuf(
|
|||||||
test_data = Ringbuf_Get_Front(&test_buffer);
|
test_data = Ringbuf_Get_Front(&test_buffer);
|
||||||
ct_test(pTest, test_data);
|
ct_test(pTest, test_data);
|
||||||
if (test_data) {
|
if (test_data) {
|
||||||
for (data_index = 0; data_index < element_size;
|
for (data_index = 0; data_index < element_size; data_index++) {
|
||||||
data_index++) {
|
|
||||||
ct_test(pTest, test_data[data_index] == dummy);
|
ct_test(pTest, test_data[data_index] == dummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,8 +296,7 @@ void testRingBuf(
|
|||||||
test_data = Ringbuf_Pop_Front(&test_buffer);
|
test_data = Ringbuf_Pop_Front(&test_buffer);
|
||||||
ct_test(pTest, test_data);
|
ct_test(pTest, test_data);
|
||||||
if (test_data) {
|
if (test_data) {
|
||||||
for (data_index = 0; data_index < element_size;
|
for (data_index = 0; data_index < element_size; data_index++) {
|
||||||
data_index++) {
|
|
||||||
ct_test(pTest, test_data[data_index] == dummy);
|
ct_test(pTest, test_data[data_index] == dummy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,8 +314,7 @@ void testRingBufSize16(
|
|||||||
uint8_t data_element[5];
|
uint8_t data_element[5];
|
||||||
uint8_t data_store[sizeof(data_element) * 16];
|
uint8_t data_store[sizeof(data_element) * 16];
|
||||||
|
|
||||||
testRingBuf(pTest,data_store,data_element,
|
testRingBuf(pTest, data_store, data_element, sizeof(data_element),
|
||||||
sizeof(data_element),
|
|
||||||
sizeof(data_store) / sizeof(data_element));
|
sizeof(data_store) / sizeof(data_element));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,8 +324,7 @@ void testRingBufSize32(
|
|||||||
uint8_t data_element[16];
|
uint8_t data_element[16];
|
||||||
uint8_t data_store[sizeof(data_element) * 32];
|
uint8_t data_store[sizeof(data_element) * 32];
|
||||||
|
|
||||||
testRingBuf(pTest,data_store,data_element,
|
testRingBuf(pTest, data_store, data_element, sizeof(data_element),
|
||||||
sizeof(data_element),
|
|
||||||
sizeof(data_store) / sizeof(data_element));
|
sizeof(data_store) / sizeof(data_element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ uint8_t tsm_transaction_idle_count(
|
|||||||
|
|
||||||
/* sets the invokeID */
|
/* sets the invokeID */
|
||||||
|
|
||||||
void tsm_invokeID_set(uint8_t invokeID)
|
void tsm_invokeID_set(
|
||||||
|
uint8_t invokeID)
|
||||||
{
|
{
|
||||||
if (invokeID == 0) {
|
if (invokeID == 0) {
|
||||||
invokeID = 1;
|
invokeID = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user