Fixed EOL and performed standard indentation.
This commit is contained in:
@@ -304,9 +304,9 @@ static void Init_Service_Handlers(
|
||||
|
||||
bool PrettyPrintPropertyValue(
|
||||
FILE * stream,
|
||||
BACNET_OBJECT_PROPERTY_VALUE *object_value)
|
||||
BACNET_OBJECT_PROPERTY_VALUE * object_value)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE * value = NULL;
|
||||
BACNET_APPLICATION_DATA_VALUE *value = NULL;
|
||||
bool status = true; /*return value */
|
||||
size_t len = 0, i = 0, j = 0;
|
||||
BACNET_PROPERTY_ID property = PROP_ALL;
|
||||
@@ -383,7 +383,7 @@ void PrintReadPropertyData(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_REFERENCE * rpm_property)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_APPLICATION_DATA_VALUE *value, *old_value;
|
||||
bool print_brace = false;
|
||||
KEY object_list_element;
|
||||
@@ -406,9 +406,8 @@ void PrintReadPropertyData(
|
||||
if ((value != NULL) && (value->next != NULL)) {
|
||||
/* Then this is an array of values.
|
||||
* But are we showing Values? We (VTS3) want ? instead of {?,?} to show up. */
|
||||
switch( rpm_property->propertyIdentifier )
|
||||
{
|
||||
/* Screen the Properties that can be arrays or Sequences */
|
||||
switch (rpm_property->propertyIdentifier) {
|
||||
/* Screen the Properties that can be arrays or Sequences */
|
||||
case PROP_PRESENT_VALUE:
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
if (!ShowValues) {
|
||||
@@ -417,7 +416,8 @@ void PrintReadPropertyData(
|
||||
* print anything for them. To achieve this, swap
|
||||
* out the Property for a non-existent Property
|
||||
* and catch that below. */
|
||||
rpm_property->propertyIdentifier = PROP_PROTOCOL_CONFORMANCE_CLASS;
|
||||
rpm_property->propertyIdentifier =
|
||||
PROP_PROTOCOL_CONFORMANCE_CLASS;
|
||||
break;
|
||||
}
|
||||
/* Else, fall through to normal processing. */
|
||||
@@ -473,8 +473,8 @@ void PrintReadPropertyData(
|
||||
}
|
||||
|
||||
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
||||
if ( value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
assert(value->tag == BACNET_APPLICATION_TAG_OBJECT_ID); /* Something not right here */
|
||||
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
assert(value->tag == BACNET_APPLICATION_TAG_OBJECT_ID); /* Something not right here */
|
||||
break;
|
||||
}
|
||||
/* Store the object list so we can interrogate
|
||||
@@ -501,7 +501,7 @@ void PrintReadPropertyData(
|
||||
} else if (rpm_property->propertyIdentifier ==
|
||||
PROP_SUBORDINATE_LIST) {
|
||||
if (value->tag != BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
assert(value->tag == BACNET_APPLICATION_TAG_OBJECT_ID); /* Something not right here */
|
||||
assert(value->tag == BACNET_APPLICATION_TAG_OBJECT_ID); /* Something not right here */
|
||||
break;
|
||||
}
|
||||
/* TODO: handle Sequence of { Device ObjID, Object ID }, */
|
||||
@@ -531,7 +531,7 @@ void PrintReadPropertyData(
|
||||
PrettyPrintPropertyValue(stdout, &object_value);
|
||||
break;
|
||||
|
||||
/* Our special non-existent case; do nothing further here. */
|
||||
/* Our special non-existent case; do nothing further here. */
|
||||
case PROP_PROTOCOL_CONFORMANCE_CLASS:
|
||||
break;
|
||||
|
||||
@@ -730,10 +730,8 @@ EPICS_STATES ProcessRPMData(
|
||||
fprintf(stdout, " ");
|
||||
Print_Property_Identifier(rpm_property->propertyIdentifier);
|
||||
fprintf(stdout, ": ");
|
||||
PrintReadPropertyData(
|
||||
rpm_data->object_type,
|
||||
rpm_data->object_instance,
|
||||
rpm_property);
|
||||
PrintReadPropertyData(rpm_data->object_type,
|
||||
rpm_data->object_instance, rpm_property);
|
||||
}
|
||||
old_rpm_property = rpm_property;
|
||||
rpm_property = rpm_property->next;
|
||||
@@ -893,7 +891,7 @@ int main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
{
|
||||
BACNET_ADDRESS src; /* address where message came from */
|
||||
BACNET_ADDRESS src; /* address where message came from */
|
||||
uint16_t pdu_len = 0;
|
||||
unsigned timeout = 100; /* milliseconds */
|
||||
unsigned max_apdu = 0;
|
||||
@@ -909,7 +907,7 @@ int main(
|
||||
KEY nextKey;
|
||||
|
||||
CheckCommandLineArgs(argc, argv); /* Won't return if there is an issue. */
|
||||
memset(&src, 0, sizeof( BACNET_ADDRESS));
|
||||
memset(&src, 0, sizeof(BACNET_ADDRESS));
|
||||
|
||||
/* setup my info */
|
||||
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
|
||||
@@ -984,7 +982,7 @@ int main(
|
||||
fprintf(stderr,
|
||||
"\rError: Unable to bind"
|
||||
" after waiting %ld seconds.\r\n",
|
||||
(long int)elapsed_seconds);
|
||||
(long int) elapsed_seconds);
|
||||
break;
|
||||
}
|
||||
/* else, loop back and try again */
|
||||
@@ -1044,7 +1042,7 @@ int main(
|
||||
elapsed_seconds = 0;
|
||||
invoke_id = 0;
|
||||
if (Error_Detected) {
|
||||
/* The normal case for Device Object */
|
||||
/* The normal case for Device Object */
|
||||
/* Was it because the Device can't do RPM? */
|
||||
if (Last_Error_Code ==
|
||||
ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) {
|
||||
@@ -1108,10 +1106,11 @@ int main(
|
||||
(invoke_id ==
|
||||
Read_Property_Multiple_Data.service_data.invoke_id)) {
|
||||
Read_Property_Multiple_Data.new_data = false;
|
||||
PrintReadPropertyData(
|
||||
Read_Property_Multiple_Data.rpm_data->object_type,
|
||||
PrintReadPropertyData(Read_Property_Multiple_Data.
|
||||
rpm_data->object_type,
|
||||
Read_Property_Multiple_Data.rpm_data->object_instance,
|
||||
Read_Property_Multiple_Data.rpm_data->listOfProperties);
|
||||
Read_Property_Multiple_Data.rpm_data->
|
||||
listOfProperties);
|
||||
if (tsm_invoke_id_free(invoke_id)) {
|
||||
invoke_id = 0;
|
||||
} else {
|
||||
@@ -1194,7 +1193,7 @@ int main(
|
||||
printf(" { \r\n");
|
||||
/* Test code:
|
||||
if ( myObject.type == OBJECT_STRUCTURED_VIEW )
|
||||
printf( " -- Structured View %d \n", myObject.instance );
|
||||
printf( " -- Structured View %d \n", myObject.instance );
|
||||
*/
|
||||
} else {
|
||||
/* Closing brace for the last Object */
|
||||
@@ -1224,7 +1223,7 @@ int main(
|
||||
elapsed_seconds += (current_seconds - last_seconds);
|
||||
if (elapsed_seconds > timeout_seconds) {
|
||||
fprintf(stderr, "\rError: APDU Timeout! (%lds)\r\n",
|
||||
(long int)elapsed_seconds);
|
||||
(long int) elapsed_seconds);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,8 +346,9 @@ static bool cov_send_request(
|
||||
value_list[1].next = NULL;
|
||||
switch (cov_subscription->monitoredObjectIdentifier.type) {
|
||||
case OBJECT_BINARY_INPUT:
|
||||
Binary_Input_Encode_Value_List(cov_subscription->
|
||||
monitoredObjectIdentifier.instance, &value_list[0]);
|
||||
Binary_Input_Encode_Value_List
|
||||
(cov_subscription->monitoredObjectIdentifier.instance,
|
||||
&value_list[0]);
|
||||
break;
|
||||
default:
|
||||
goto COV_FAILED;
|
||||
@@ -464,8 +465,8 @@ static bool cov_subscribe(
|
||||
|
||||
switch (cov_data->monitoredObjectIdentifier.type) {
|
||||
case OBJECT_BINARY_INPUT:
|
||||
if (Binary_Input_Valid_Instance(cov_data->
|
||||
monitoredObjectIdentifier.instance)) {
|
||||
if (Binary_Input_Valid_Instance
|
||||
(cov_data->monitoredObjectIdentifier.instance)) {
|
||||
status =
|
||||
cov_list_subscribe(src, cov_data, error_class, error_code);
|
||||
} else {
|
||||
@@ -546,8 +547,9 @@ void handler_cov_subscribe(
|
||||
}
|
||||
cov_data.error_class = ERROR_CLASS_OBJECT;
|
||||
cov_data.error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
success = cov_subscribe(src, &cov_data,
|
||||
&cov_data.error_class, &cov_data.error_code);
|
||||
success =
|
||||
cov_subscribe(src, &cov_data, &cov_data.error_class,
|
||||
&cov_data.error_code);
|
||||
if (success) {
|
||||
apdu_len =
|
||||
encode_simple_ack(&Handler_Transmit_Buffer[npdu_len],
|
||||
|
||||
@@ -55,7 +55,7 @@ void npdu_handler(
|
||||
if (npdu_data.network_layer_message) {
|
||||
/*FIXME: network layer message received! Handle it! */
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,"NPDU: Network Layer Message discarded!\n");
|
||||
fprintf(stderr, "NPDU: Network Layer Message discarded!\n");
|
||||
#endif
|
||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||
if ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) {
|
||||
|
||||
@@ -88,7 +88,7 @@ void handler_read_property(
|
||||
npdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address,
|
||||
&npdu_data);
|
||||
if (service_data->segmented_message) {
|
||||
if (service_data->segmented_message) {
|
||||
/* we don't support segmentation - send an abort */
|
||||
len = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
void rp_ack_print_data(
|
||||
BACNET_READ_PROPERTY_DATA * data)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
|
||||
int len = 0;
|
||||
uint8_t *application_data;
|
||||
|
||||
@@ -227,10 +227,10 @@ void handler_read_property_multiple(
|
||||
len =
|
||||
rpm_decode_object_id(&service_request[decode_len],
|
||||
service_len - decode_len, &rpmdata);
|
||||
if (len >= 0) {
|
||||
if (len >= 0) {
|
||||
/* Got one so skip to next stage */
|
||||
decode_len += len;
|
||||
} else {
|
||||
} else {
|
||||
/* bad encoding - skip to error/reject/abort handling */
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Bad Encoding.\n");
|
||||
@@ -260,7 +260,7 @@ void handler_read_property_multiple(
|
||||
len =
|
||||
rpm_decode_object_property(&service_request[decode_len],
|
||||
service_len - decode_len, &rpmdata);
|
||||
if (len < 0) {
|
||||
if (len < 0) {
|
||||
/* bad encoding - skip to error/reject/abort handling */
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Bad Encoding.\n");
|
||||
@@ -378,7 +378,7 @@ void handler_read_property_multiple(
|
||||
break; /* finished with this property list */
|
||||
}
|
||||
}
|
||||
if (decode_len >= service_len) {
|
||||
if (decode_len >= service_len) {
|
||||
/* Reached the end so finish up */
|
||||
break;
|
||||
}
|
||||
@@ -386,8 +386,7 @@ void handler_read_property_multiple(
|
||||
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort */
|
||||
rpmdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Message too large. Sending Abort!\n");
|
||||
|
||||
@@ -202,7 +202,7 @@ int rpm_ack_decode_service_request(
|
||||
void rpm_ack_print_data(
|
||||
BACNET_READ_ACCESS_DATA * rpm_data)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_PROPERTY_REFERENCE *listOfProperties;
|
||||
BACNET_APPLICATION_DATA_VALUE *value;
|
||||
bool array_value = false;
|
||||
@@ -219,8 +219,8 @@ void rpm_ack_print_data(
|
||||
#if PRINT_ENABLED
|
||||
if (listOfProperties->propertyIdentifier < 512) {
|
||||
fprintf(stdout, " %s: ",
|
||||
bactext_property_name
|
||||
(listOfProperties->propertyIdentifier));
|
||||
bactext_property_name(listOfProperties->
|
||||
propertyIdentifier));
|
||||
} else {
|
||||
fprintf(stdout, " proprietary %u: ",
|
||||
(unsigned) listOfProperties->propertyIdentifier);
|
||||
@@ -241,17 +241,14 @@ void rpm_ack_print_data(
|
||||
array_value = false;
|
||||
}
|
||||
#endif
|
||||
object_value.object_type =
|
||||
rpm_data->object_type;
|
||||
object_value.object_instance =
|
||||
rpm_data->object_instance;
|
||||
object_value.object_type = rpm_data->object_type;
|
||||
object_value.object_instance = rpm_data->object_instance;
|
||||
while (value) {
|
||||
object_value.object_property =
|
||||
listOfProperties->propertyIdentifier;
|
||||
object_value.array_index =
|
||||
listOfProperties->propertyArrayIndex;
|
||||
object_value.value =
|
||||
listOfProperties->value;
|
||||
object_value.value = listOfProperties->value;
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
#if PRINT_ENABLED
|
||||
if (value->next) {
|
||||
@@ -270,10 +267,10 @@ void rpm_ack_print_data(
|
||||
#if PRINT_ENABLED
|
||||
/* AccessError */
|
||||
fprintf(stdout, "BACnet Error: %s: %s\r\n",
|
||||
bactext_error_class_name((int) listOfProperties->error.
|
||||
error_class),
|
||||
bactext_error_code_name((int) listOfProperties->error.
|
||||
error_code));
|
||||
bactext_error_class_name((int) listOfProperties->
|
||||
error.error_class),
|
||||
bactext_error_code_name((int) listOfProperties->
|
||||
error.error_code));
|
||||
#endif
|
||||
}
|
||||
listOfProperties = listOfProperties->next;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
static void PrintReadRangeData(
|
||||
BACNET_READ_RANGE_DATA * data)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
|
||||
int len = 0;
|
||||
uint8_t *application_data;
|
||||
|
||||
@@ -104,8 +104,8 @@ void handler_ucov_notification(
|
||||
fprintf(stderr, "UCOV: ");
|
||||
if (pProperty_value->propertyIdentifier < 512) {
|
||||
fprintf(stderr, "%s ",
|
||||
bactext_property_name(pProperty_value->
|
||||
propertyIdentifier));
|
||||
bactext_property_name
|
||||
(pProperty_value->propertyIdentifier));
|
||||
} else {
|
||||
fprintf(stderr, "proprietary %u ",
|
||||
pProperty_value->propertyIdentifier);
|
||||
|
||||
@@ -177,8 +177,8 @@ bool WPValidateString(
|
||||
(characterstring_length(&pValue->type.Character_String) ==
|
||||
0)) {
|
||||
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
} else if (characterstring_length(&pValue->type.
|
||||
Character_String) >= iMaxLen) {
|
||||
} else if (characterstring_length(&pValue->
|
||||
type.Character_String) >= iMaxLen) {
|
||||
*pErrorClass = ERROR_CLASS_RESOURCES;
|
||||
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||
} else
|
||||
|
||||
@@ -155,8 +155,9 @@ uint8_t Send_Write_Property_Request(
|
||||
#if PRINT_ENABLED_DEBUG
|
||||
fprintf(stderr, "WriteProperty service: " "%s tag=%d\n",
|
||||
(object_value->context_specific ? "context" : "application"),
|
||||
(int) (object_value->context_specific ? object_value->
|
||||
context_tag : object_value->tag));
|
||||
(int) (object_value->
|
||||
context_specific ? object_value->context_tag : object_value->
|
||||
tag));
|
||||
#endif
|
||||
len = bacapp_encode_data(&application_data[apdu_len], object_value);
|
||||
if ((len + apdu_len) < MAX_APDU) {
|
||||
|
||||
@@ -634,8 +634,8 @@ int main(
|
||||
packet_count++;
|
||||
}
|
||||
if (!(packet_count % 100)) {
|
||||
fprintf(stdout, "\r%hu packets, %hu invalid frames",
|
||||
packet_count, Invalid_Frame_Count);
|
||||
fprintf(stdout, "\r%hu packets, %hu invalid frames", packet_count,
|
||||
Invalid_Frame_Count);
|
||||
}
|
||||
if (packet_count >= 65535) {
|
||||
packet_statistics_save();
|
||||
@@ -645,4 +645,3 @@ int main(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -441,11 +441,11 @@ bool Analog_Output_Write_Property(
|
||||
if (status) {
|
||||
level = AO_LEVEL_NULL;
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Analog_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
status =
|
||||
Analog_Output_Present_Value_Relinquish(wp_data->
|
||||
object_instance, wp_data->priority);
|
||||
Analog_Output_Present_Value_Relinquish
|
||||
(wp_data->object_instance, wp_data->priority);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
|
||||
@@ -391,8 +391,8 @@ bool Analog_Value_Write_Property(
|
||||
if (status) {
|
||||
level = ANALOG_LEVEL_NULL;
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Analog_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
|
||||
@@ -370,8 +370,8 @@ bool Binary_Output_Write_Property(
|
||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||
level = (BACNET_BINARY_PV) value.type.Enumerated;
|
||||
object_index =
|
||||
Binary_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Binary_Output_Level[object_index][priority] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
@@ -397,8 +397,8 @@ bool Binary_Output_Write_Property(
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
object_index =
|
||||
Binary_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
|
||||
@@ -353,8 +353,8 @@ bool Binary_Value_Write_Property(
|
||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||
level = (BACNET_BINARY_PV) value.type.Enumerated;
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Binary_Value_Level[object_index][priority] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
@@ -380,8 +380,8 @@ bool Binary_Value_Write_Property(
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
|
||||
@@ -1241,8 +1241,8 @@ static bool Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* FIXME: we could send an I-Am broadcast to let the world know */
|
||||
} else {
|
||||
status = false;
|
||||
@@ -1275,8 +1275,8 @@ static bool Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_Vendor_Identifier((uint16_t) value.type.
|
||||
Unsigned_Int);
|
||||
Device_Set_Vendor_Identifier((uint16_t) value.
|
||||
type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
@@ -1303,8 +1303,8 @@ static bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Object_Name(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Object_Name(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1313,8 +1313,8 @@ static bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Location(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Location(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1324,8 +1324,8 @@ static bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Description(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Description(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1334,8 +1334,8 @@ static bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Model_Name(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Model_Name(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1347,8 +1347,8 @@ static bool Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
dlmstp_set_max_info_frames((uint8_t) value.type.
|
||||
Unsigned_Int);
|
||||
dlmstp_set_max_info_frames((uint8_t) value.
|
||||
type.Unsigned_Int);
|
||||
} else {
|
||||
status = false;
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
|
||||
object_index =
|
||||
Lighting_Output_Instance_To_Index(rpdata->object_instance);
|
||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Lighting_Output_Level[object_index][rpdata->
|
||||
array_index - 1] == LIGHTING_LEVEL_NULL)
|
||||
if (Lighting_Output_Level[object_index][rpdata->array_index
|
||||
- 1] == LIGHTING_LEVEL_NULL)
|
||||
apdu_len = encode_application_null(&apdu[0]);
|
||||
else {
|
||||
real_value = Lighting_Output_Level[object_index]
|
||||
@@ -549,11 +549,11 @@ bool Lighting_Output_Write_Property(
|
||||
if (status) {
|
||||
level = LIGHTING_LEVEL_NULL;
|
||||
object_index =
|
||||
Lighting_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Lighting_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
status =
|
||||
Lighting_Output_Present_Value_Relinquish(wp_data->
|
||||
object_instance, wp_data->priority);
|
||||
Lighting_Output_Present_Value_Relinquish
|
||||
(wp_data->object_instance, wp_data->priority);
|
||||
if (wp_data->priority == 6) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -580,8 +580,8 @@ bool Lighting_Output_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Lighting_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Lighting_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Lighting_Output_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -318,8 +318,8 @@ bool Life_Safety_Point_Write_Property(
|
||||
if (status) {
|
||||
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Life_Safety_Point_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Life_Safety_Point_Mode[object_index] =
|
||||
value.type.Enumerated;
|
||||
} else {
|
||||
@@ -335,8 +335,8 @@ bool Life_Safety_Point_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Life_Safety_Point_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Life_Safety_Point_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ int Multistate_Input_Read_Property(
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
object_index =
|
||||
Multistate_Input_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Input_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) {
|
||||
characterstring_init_ansi(&char_string,
|
||||
Multistate_Input_State_Text(rpdata->object_instance,
|
||||
@@ -422,8 +422,8 @@ int Multistate_Input_Read_Property(
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Multistate_Input_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Input_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
|
||||
characterstring_init_ansi(&char_string,
|
||||
Multistate_Input_State_Text(rpdata->object_instance,
|
||||
@@ -478,8 +478,8 @@ bool Multistate_Input_Write_Property(
|
||||
if (status) {
|
||||
if (Out_Of_Service[object_index]) {
|
||||
status =
|
||||
Multistate_Input_Present_Value_Set(wp_data->
|
||||
object_instance, value.type.Unsigned_Int);
|
||||
Multistate_Input_Present_Value_Set
|
||||
(wp_data->object_instance, value.type.Unsigned_Int);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
@@ -497,8 +497,8 @@ bool Multistate_Input_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Multistate_Input_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Input_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Out_Of_Service[object_index] = value.type.Boolean;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -266,8 +266,8 @@ int Multistate_Output_Read_Property(
|
||||
/* into one packet. */
|
||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
if (Multistate_Output_Level[object_index][i] ==
|
||||
@@ -292,8 +292,8 @@ int Multistate_Output_Read_Property(
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Multistate_Output_Level[object_index]
|
||||
[rpdata->array_index - 1] == MULTISTATE_NULL)
|
||||
@@ -369,8 +369,8 @@ bool Multistate_Output_Write_Property(
|
||||
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
|
||||
level = value.type.Unsigned_Int;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Multistate_Output_Level[object_index][priority] =
|
||||
(uint8_t) level;
|
||||
@@ -397,8 +397,8 @@ bool Multistate_Output_Write_Property(
|
||||
if (status) {
|
||||
level = MULTISTATE_NULL;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
@@ -424,8 +424,8 @@ bool Multistate_Output_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Multistate_Output_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -731,9 +731,9 @@ bool Trend_Log_Write_Property(
|
||||
if (wp_data->application_data_len != 0) {
|
||||
iOffset += len;
|
||||
len =
|
||||
bacapp_decode_context_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||
bacapp_decode_context_data(&wp_data->application_data
|
||||
[iOffset], wp_data->application_data_len, &value,
|
||||
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||
if ((len == 0) || ((value.context_tag != 2) &&
|
||||
(value.context_tag != 3))) {
|
||||
/* Bad decode or wrong tag */
|
||||
@@ -750,8 +750,8 @@ bool Trend_Log_Write_Property(
|
||||
if (wp_data->application_data_len != 0) {
|
||||
iOffset += len;
|
||||
len =
|
||||
bacapp_decode_context_data(&wp_data->
|
||||
application_data[iOffset],
|
||||
bacapp_decode_context_data
|
||||
(&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value,
|
||||
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||
if ((len == 0) || (value.context_tag != 3)) {
|
||||
@@ -1093,8 +1093,8 @@ int rr_trend_log_encode(
|
||||
pRequest->ItemCount = 0; /* Start out with nothing */
|
||||
|
||||
/* Bail out now if nowt - should never happen for a Trend Log but ... */
|
||||
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
|
||||
ulRecordCount == 0)
|
||||
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->
|
||||
object_instance)].ulRecordCount == 0)
|
||||
return (0);
|
||||
|
||||
if ((pRequest->RequestType == RR_BY_POSITION) ||
|
||||
|
||||
@@ -334,7 +334,7 @@ typedef enum {
|
||||
PROP_MAX_FAILED_ATTEMPTS = 285,
|
||||
PROP_MEMBERS = 286,
|
||||
PROP_MUSTER_POINT = 287,
|
||||
PROP_NEGATIVE_ACCESS_RULES = 288,
|
||||
PROP_NEGATIVE_ACCESS_RULES = 288,
|
||||
PROP_NUMBER_OF_AUTHENTICATION_POLICIES = 289,
|
||||
PROP_OCCUPANCY_COUNT = 290,
|
||||
PROP_OCCUPANCY_COUNT_ADJUST = 291,
|
||||
@@ -350,8 +350,8 @@ typedef enum {
|
||||
PROP_PASSBACK_TIMEOUT = 301,
|
||||
PROP_POSITIVE_ACCESS_RULES = 302,
|
||||
PROP_REASON_FOR_DISABLE = 303,
|
||||
PROP_SUPPORTED_FORMATS = 304,
|
||||
PROP_SUPPORTED_FORMAT_CLASSES = 305,
|
||||
PROP_SUPPORTED_FORMATS = 304,
|
||||
PROP_SUPPORTED_FORMAT_CLASSES = 305,
|
||||
PROP_THREAT_AUTHORITY = 306,
|
||||
PROP_THREAT_LEVEL = 307,
|
||||
PROP_TRACE_FLAG = 308,
|
||||
@@ -361,7 +361,7 @@ typedef enum {
|
||||
/* enumerations 312-313 are used in Addendum k to ANSI/ASHRAE 135-2004 */
|
||||
PROP_CHARACTER_SET = 312,
|
||||
PROP_STRICT_CHARACTER_MODE = 313,
|
||||
/* enumerations 314-316 are used in Addendum ? */
|
||||
/* enumerations 314-316 are used in Addendum ? */
|
||||
PROP_BACKUP_AND_RESTORE_STATE = 314,
|
||||
PROP_BACKUP_PREPARATION_TIME = 315,
|
||||
PROP_RESTORE_PREPARATION_TIME = 316,
|
||||
@@ -377,7 +377,7 @@ typedef enum {
|
||||
PROP_BINARY_ACTIVE_VALUE = 324,
|
||||
PROP_BINARY_INACTIVE_VALUE = 325,
|
||||
/* enumeration 326 is used in Addendum j to ANSI/ASHRAE 135-2004 */
|
||||
PROP_VERIFICATION_TIME = 326,
|
||||
PROP_VERIFICATION_TIME = 326,
|
||||
/* enumerations 342-344 are defined in Addendum 2008-w */
|
||||
PROP_BIT_MASK = 342,
|
||||
PROP_BIT_TEXT = 343,
|
||||
|
||||
@@ -139,9 +139,7 @@ extern "C" {
|
||||
* chosen at runtime from among these choices.
|
||||
* - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN
|
||||
* are not currently supported by this project.
|
||||
*/
|
||||
|
||||
/** @defgroup DLTemplates DataLink Template Functions
|
||||
*//** @defgroup DLTemplates DataLink Template Functions
|
||||
* @ingroup DataLink
|
||||
* Most of the functions in this group are function templates which are assigned
|
||||
* to a specific DataLink network layer implementation either at compile time or
|
||||
|
||||
@@ -101,9 +101,7 @@ extern "C" {
|
||||
* These device management BIBBs prescribe the BACnet capabilities required
|
||||
* to interoperably perform the device management functions enumerated in
|
||||
* 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
|
||||
* 16.1 DeviceCommunicationControl Service <br>
|
||||
* The DeviceCommunicationControl service is used by a client BACnet-user to
|
||||
|
||||
@@ -237,15 +237,11 @@ extern "C" {
|
||||
* - The interface between the implemented Objects and the BAC-stack services,
|
||||
* specifically the handlers, which are mediated through function calls to
|
||||
* the Device object.
|
||||
*/
|
||||
|
||||
/** @defgroup ObjHelpers Object Helper Functions
|
||||
*//** @defgroup ObjHelpers Object Helper Functions
|
||||
* @ingroup ObjFrmwk
|
||||
* This section describes the function templates for the helper functions that
|
||||
* provide common object support.
|
||||
*/
|
||||
|
||||
/** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||
* @ingroup ObjFrmwk
|
||||
* This section describes the fairly limited set of functions that link the
|
||||
* BAC-stack handlers to the BACnet Object instances. All of these calls are
|
||||
|
||||
@@ -122,7 +122,8 @@ extern "C" {
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t mstp_address);
|
||||
|
||||
bool dlmstp_sole_master(void);
|
||||
bool dlmstp_sole_master(
|
||||
void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -213,9 +213,7 @@ extern "C" {
|
||||
* These BIBBs prescribe the BACnet capabilities required to interoperably
|
||||
* perform the alarm and event management functions enumerated in 22.2.1.2
|
||||
* for the BACnet devices defined therein.
|
||||
*/
|
||||
|
||||
/** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N)
|
||||
*//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N)
|
||||
* @ingroup ALMEVNT
|
||||
* 13.6 ConfirmedCOVNotification Service <br>
|
||||
* The ConfirmedCOVNotification service is used to notify subscribers about
|
||||
@@ -232,9 +230,7 @@ extern "C" {
|
||||
* For unsubscribed notifications, the algorithm for determining when to issue
|
||||
* this service is a local matter and may be based on a change of value,
|
||||
* periodic updating, or some other criteria.
|
||||
*/
|
||||
|
||||
/** @defgroup ALMACK Alarm and Event-ACK (AE-ACK)
|
||||
*//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK)
|
||||
* @ingroup ALMEVNT
|
||||
* 13.5 AcknowledgeAlarm Service <br>
|
||||
* In some systems a device may need to know that an operator has seen the alarm
|
||||
|
||||
@@ -135,9 +135,7 @@ extern "C" {
|
||||
* These BIBBs prescribe the BACnet capabilities required to interoperably
|
||||
* perform the data sharing functions enumerated in 22.2.1.1 for the BACnet
|
||||
* devices defined therein.
|
||||
*/
|
||||
|
||||
/** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
|
||||
*//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
|
||||
* @ingroup DataShare
|
||||
* 15.5 ReadProperty Service <br>
|
||||
* The ReadProperty service is used by a client BACnet-user to request the
|
||||
|
||||
@@ -355,8 +355,8 @@ bool Analog_Value_Write_Property(
|
||||
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
|
||||
level = (uint8_t) value.type.Real;
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Analog_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Present_Value[object_index] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
|
||||
@@ -265,8 +265,8 @@ bool Binary_Value_Write_Property(
|
||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||
level = value.type.Enumerated;
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
/* NOTE: this Binary value has no priority array */
|
||||
Present_Value[object_index] = level;
|
||||
|
||||
@@ -824,8 +824,8 @@ bool Device_Write_Property_Local(
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
|
||||
@@ -200,11 +200,8 @@ bool dlmstp_init(
|
||||
(void) ifname;
|
||||
/* initialize hardware */
|
||||
RS485_Initialize();
|
||||
Ringbuf_Init(
|
||||
&PDU_Queue,
|
||||
(uint8_t *)&PDU_Buffer,
|
||||
sizeof(struct mstp_pdu_packet),
|
||||
MSTP_PDU_PACKET_COUNT);
|
||||
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
|
||||
sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -529,32 +526,34 @@ static void MSTP_Receive_Frame_FSM(
|
||||
/* wait for the start of the next frame. */
|
||||
Receive_State = MSTP_RECEIVE_STATE_IDLE;
|
||||
} else {
|
||||
if (DataLength == 0) {
|
||||
/* NoData */
|
||||
if ((DestinationAddress == This_Station) ||
|
||||
(DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
/* ForUs */
|
||||
/* indicate that a frame with
|
||||
no data has been received */
|
||||
MSTP_Flag.ReceivedValidFrame = true;
|
||||
} else {
|
||||
if (DataLength == 0) {
|
||||
/* NoData */
|
||||
if ((DestinationAddress == This_Station) ||
|
||||
(DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
/* ForUs */
|
||||
/* indicate that a frame with
|
||||
no data has been received */
|
||||
MSTP_Flag.ReceivedValidFrame = true;
|
||||
} else {
|
||||
/* NotForUs */
|
||||
MSTP_Flag.ReceivedValidFrameNotForUs = true;
|
||||
}
|
||||
}
|
||||
/* wait for the start of the next frame. */
|
||||
Receive_State = MSTP_RECEIVE_STATE_IDLE;
|
||||
} else {
|
||||
/* receive the data portion of the frame. */
|
||||
if ((DestinationAddress == This_Station) ||
|
||||
(DestinationAddress == MSTP_BROADCAST_ADDRESS)) {
|
||||
(DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
if (DataLength <= InputBufferSize) {
|
||||
/* Data */
|
||||
Receive_State = MSTP_RECEIVE_STATE_DATA;
|
||||
} else {
|
||||
/* FrameTooLong */
|
||||
Receive_State = MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
}
|
||||
} else {
|
||||
/* FrameTooLong */
|
||||
Receive_State =
|
||||
MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
}
|
||||
} else {
|
||||
/* NotForUs */
|
||||
Receive_State = MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
@@ -599,7 +598,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
/* DataOctet */
|
||||
DataCRC = CRC_Calc_Data(DataRegister, DataCRC);
|
||||
if (Index < InputBufferSize) {
|
||||
InputBuffer[Index] = DataRegister;
|
||||
InputBuffer[Index] = DataRegister;
|
||||
}
|
||||
Index++;
|
||||
} else if (Index == DataLength) {
|
||||
@@ -767,8 +766,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
transition_now = true;
|
||||
} else {
|
||||
uint8_t frame_type;
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Pop_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
|
||||
if (pkt->data_expecting_reply) {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||
} else {
|
||||
@@ -1089,12 +1087,11 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* Note: we could wait for up to Treply_delay */
|
||||
matched = false;
|
||||
if (!Ringbuf_Empty(&PDU_Queue)) {
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Get_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue);
|
||||
matched =
|
||||
dlmstp_compare_data_expecting_reply(&InputBuffer[0],
|
||||
DataLength, SourceAddress, &pkt->buffer[0],
|
||||
pkt->length, pkt->destination_mac);
|
||||
DataLength, SourceAddress, &pkt->buffer[0], pkt->length,
|
||||
pkt->destination_mac);
|
||||
}
|
||||
if (matched) {
|
||||
/* Reply */
|
||||
@@ -1105,8 +1102,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* then call MSTP_Send_Frame to transmit the reply frame */
|
||||
/* and enter the IDLE state to wait for the next frame. */
|
||||
uint8_t frame_type;
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Pop_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
|
||||
if (pkt->data_expecting_reply) {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||
} else {
|
||||
@@ -1151,7 +1147,7 @@ int dlmstp_send_pdu(
|
||||
struct mstp_pdu_packet *pkt;
|
||||
uint16_t i = 0;
|
||||
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Alloc(&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Alloc(&PDU_Queue);
|
||||
if (pkt) {
|
||||
pkt->data_expecting_reply = npdu_data->data_expecting_reply;
|
||||
for (i = 0; i < pdu_len; i++) {
|
||||
|
||||
@@ -206,8 +206,8 @@ bool Binary_Value_Write_Property(
|
||||
if ((value.type.Enumerated == BINARY_ACTIVE) ||
|
||||
(value.type.Enumerated == BINARY_INACTIVE)) {
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
/* NOTE: this Binary value has no priority array */
|
||||
Present_Value[object_index] =
|
||||
(BACNET_BINARY_PV) value.type.Enumerated;
|
||||
|
||||
@@ -375,8 +375,8 @@ bool Device_Write_Property(
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
|
||||
@@ -206,8 +206,8 @@ bool Binary_Value_Write_Property(
|
||||
if ((value.type.Enumerated == BINARY_ACTIVE) ||
|
||||
(value.type.Enumerated == BINARY_INACTIVE)) {
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
/* NOTE: this Binary value has no priority array */
|
||||
Present_Value[object_index] =
|
||||
(BACNET_BINARY_PV) value.type.Enumerated;
|
||||
|
||||
@@ -286,7 +286,7 @@ int Device_Encode_Property_APDU(
|
||||
/* assume next one is the same size as this one */
|
||||
/* can we all fit into the APDU? */
|
||||
if ((apdu_len + len) >= MAX_APDU) {
|
||||
*error_code =
|
||||
*error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
apdu_len = BACNET_STATUS_ABORT;
|
||||
break;
|
||||
|
||||
@@ -138,9 +138,9 @@ static BACNET_BINARY_PV Present_Value(
|
||||
|
||||
if (index < MAX_BINARY_OUTPUTS) {
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
current_value = (BACNET_BINARY_PV)Binary_Output_Level[index][i];
|
||||
current_value = (BACNET_BINARY_PV) Binary_Output_Level[index][i];
|
||||
if (current_value != BINARY_NULL) {
|
||||
value = (BACNET_BINARY_PV)Binary_Output_Level[index][i];
|
||||
value = (BACNET_BINARY_PV) Binary_Output_Level[index][i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -446,8 +446,8 @@ bool Binary_Output_Write_Property(
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
Binary_Output_Present_Value_Set(wp_data->
|
||||
object_instance, level, priority);
|
||||
Binary_Output_Present_Value_Set
|
||||
(wp_data->object_instance, level, priority);
|
||||
} else if (priority == 6) {
|
||||
status = false;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -480,7 +480,7 @@ bool Binary_Output_Write_Property(
|
||||
if (status) {
|
||||
if (value.type.Enumerated < MAX_POLARITY) {
|
||||
Binary_Output_Polarity_Set(wp_data->object_instance,
|
||||
(BACNET_POLARITY)value.type.Enumerated);
|
||||
(BACNET_POLARITY) value.type.Enumerated);
|
||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
||||
} else {
|
||||
status = false;
|
||||
|
||||
@@ -585,7 +585,7 @@ char *Device_Valid_Object_Id(
|
||||
char *name = NULL; /* return value */
|
||||
struct object_functions *pObject = NULL;
|
||||
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)object_type);
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) object_type);
|
||||
if ((pObject) && (pObject->Object_Name)) {
|
||||
name = pObject->Object_Name(object_instance);
|
||||
}
|
||||
@@ -662,7 +662,7 @@ int Device_Read_Property_Local(
|
||||
for (i = 0; i < MAX_BACNET_SERVICES_SUPPORTED; i++) {
|
||||
/* automatic lookup based on handlers set */
|
||||
bitstring_set_bit(&bit_string, (uint8_t) i,
|
||||
apdu_service_supported((BACNET_SERVICES_SUPPORTED)i));
|
||||
apdu_service_supported((BACNET_SERVICES_SUPPORTED) i));
|
||||
}
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
@@ -808,8 +808,8 @@ bool Device_Write_Property_Local(
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
@@ -869,8 +869,8 @@ bool Device_Write_Property_Local(
|
||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
|
||||
&small_length, 1);
|
||||
pCharString =
|
||||
characterstring_value(&value.type.
|
||||
Character_String);
|
||||
characterstring_value(&value.
|
||||
type.Character_String);
|
||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
|
||||
(uint8_t *) pCharString, length);
|
||||
status = true;
|
||||
|
||||
@@ -204,11 +204,8 @@ bool dlmstp_init(
|
||||
if (Nmax_master > 127) {
|
||||
Nmax_master = 127;
|
||||
}
|
||||
Ringbuf_Init(
|
||||
&PDU_Queue,
|
||||
(uint8_t *)&PDU_Buffer,
|
||||
sizeof(struct mstp_pdu_packet),
|
||||
MSTP_PDU_PACKET_COUNT);
|
||||
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
|
||||
sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -551,14 +548,16 @@ static void MSTP_Receive_Frame_FSM(
|
||||
} else {
|
||||
/* receive the data portion of the frame. */
|
||||
if ((DestinationAddress == This_Station) ||
|
||||
(DestinationAddress == MSTP_BROADCAST_ADDRESS)) {
|
||||
(DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
if (DataLength <= InputBufferSize) {
|
||||
/* Data */
|
||||
Receive_State = MSTP_RECEIVE_STATE_DATA;
|
||||
} else {
|
||||
/* FrameTooLong */
|
||||
Receive_State = MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
}
|
||||
} else {
|
||||
/* FrameTooLong */
|
||||
Receive_State =
|
||||
MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
}
|
||||
} else {
|
||||
/* NotForUs */
|
||||
Receive_State = MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
@@ -616,7 +615,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
/* STATE DATA CRC - no need for new state */
|
||||
/* indicate the complete reception of a valid frame */
|
||||
if (DataCRC == 0xF0B8) {
|
||||
if (Receive_State == MSTP_RECEIVE_STATE_DATA) {
|
||||
if (Receive_State == MSTP_RECEIVE_STATE_DATA) {
|
||||
/* ForUs */
|
||||
MSTP_Flag.ReceivedValidFrame = true;
|
||||
} else {
|
||||
@@ -789,8 +788,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
transition_now = true;
|
||||
} else {
|
||||
uint8_t frame_type;
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Pop_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
|
||||
if (pkt->data_expecting_reply) {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||
} else {
|
||||
@@ -1115,12 +1113,11 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* Note: we could wait for up to Treply_delay */
|
||||
matched = false;
|
||||
if (!Ringbuf_Empty(&PDU_Queue)) {
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Get_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue);
|
||||
matched =
|
||||
dlmstp_compare_data_expecting_reply(&InputBuffer[0],
|
||||
DataLength, SourceAddress, &pkt->buffer[0],
|
||||
pkt->length, pkt->destination_mac);
|
||||
DataLength, SourceAddress, &pkt->buffer[0], pkt->length,
|
||||
pkt->destination_mac);
|
||||
}
|
||||
if (matched) {
|
||||
/* Reply */
|
||||
@@ -1131,8 +1128,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* then call MSTP_Send_Frame to transmit the reply frame */
|
||||
/* and enter the IDLE state to wait for the next frame. */
|
||||
uint8_t frame_type;
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Pop_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
|
||||
if (pkt->data_expecting_reply) {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||
} else {
|
||||
@@ -1177,7 +1173,7 @@ int dlmstp_send_pdu(
|
||||
struct mstp_pdu_packet *pkt;
|
||||
uint16_t i = 0;
|
||||
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Alloc(&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Alloc(&PDU_Queue);
|
||||
if (pkt) {
|
||||
pkt->data_expecting_reply = npdu_data->data_expecting_reply;
|
||||
for (i = 0; i < pdu_len; i++) {
|
||||
@@ -1384,4 +1380,4 @@ char *dlmstp_master_state_text(
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -52,4 +52,7 @@
|
||||
#define SEEPROM_PAGE_SIZE 16
|
||||
#define SEEPROM_WORD_ADDRESS_16BIT 0
|
||||
|
||||
#define SEEPROM_I2C_ADDRESS 0xA0
|
||||
#define SEEPROM_I2C_CLOCK 400000L
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@ void stack_init(
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned stack_size(
|
||||
void)
|
||||
{
|
||||
@@ -104,4 +105,4 @@ unsigned stack_unused(
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,99 +1,104 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#include "hardware.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
#if defined(__ICCAVR__)
|
||||
#include <intrinsics.h>
|
||||
static inline void wdt_enable(int value)
|
||||
{
|
||||
__disable_interrupt();
|
||||
__watchdog_reset();
|
||||
/* Start timed equence */
|
||||
WDTCSR |= (1<<WDCE) | (1<<WDE);
|
||||
/* Set new prescaler(time-out) value = 64K cycles (~0.5 s) */
|
||||
WDTCSR = (1<<WDE) | (value);
|
||||
/* we aren't ready to enable interrupts here
|
||||
__enable_interrupt(); */
|
||||
}
|
||||
|
||||
static inline void wdt_disable(void)
|
||||
{
|
||||
__disable_interrupt();
|
||||
__watchdog_reset();
|
||||
/* Clear WDRF in MCUSR */
|
||||
MCUSR &= ~(1<<WDRF);
|
||||
/* Write logical one to WDCE and WDE */
|
||||
/* Keep old prescaler setting to prevent unintentional time-out */
|
||||
WDTCSR |= (1<<WDCE) | (1<<WDE);
|
||||
/* Turn off WDT */
|
||||
WDTCSR = 0x00;
|
||||
__enable_interrupt();
|
||||
}
|
||||
|
||||
static inline wdt_reset(void)
|
||||
{
|
||||
__watchdog_reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Reset the watchdog timer
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
void watchdog_reset(void)
|
||||
{
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Initialize the watchdog timer
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
void watchdog_init(unsigned milliseconds)
|
||||
{
|
||||
unsigned value = WDTO_15MS;
|
||||
if (milliseconds) {
|
||||
if (milliseconds <= 15) {
|
||||
value = WDTO_15MS;
|
||||
} else if (milliseconds <= 30) {
|
||||
value = WDTO_30MS;
|
||||
} else if (milliseconds <= 60) {
|
||||
value = WDTO_60MS;
|
||||
} else if (milliseconds <= 120) {
|
||||
value = WDTO_120MS;
|
||||
} else if (milliseconds <= 500) {
|
||||
value = WDTO_500MS;
|
||||
} else if (milliseconds <= 1000) {
|
||||
value = WDTO_1S;
|
||||
} else {
|
||||
value = WDTO_2S;
|
||||
}
|
||||
wdt_enable(value);
|
||||
} else {
|
||||
wdt_disable();
|
||||
}
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#include "hardware.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
#if defined(__ICCAVR__)
|
||||
#include <intrinsics.h>
|
||||
static inline void wdt_enable(
|
||||
int value)
|
||||
{
|
||||
__disable_interrupt();
|
||||
__watchdog_reset();
|
||||
/* Start timed equence */
|
||||
WDTCSR |= (1 << WDCE) | (1 << WDE);
|
||||
/* Set new prescaler(time-out) value = 64K cycles (~0.5 s) */
|
||||
WDTCSR = (1 << WDE) | (value);
|
||||
/* we aren't ready to enable interrupts here
|
||||
__enable_interrupt(); */
|
||||
}
|
||||
|
||||
static inline void wdt_disable(
|
||||
void)
|
||||
{
|
||||
__disable_interrupt();
|
||||
__watchdog_reset();
|
||||
/* Clear WDRF in MCUSR */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
/* Write logical one to WDCE and WDE */
|
||||
/* Keep old prescaler setting to prevent unintentional time-out */
|
||||
WDTCSR |= (1 << WDCE) | (1 << WDE);
|
||||
/* Turn off WDT */
|
||||
WDTCSR = 0x00;
|
||||
__enable_interrupt();
|
||||
}
|
||||
|
||||
static inline wdt_reset(
|
||||
void)
|
||||
{
|
||||
__watchdog_reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Reset the watchdog timer
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
void watchdog_reset(
|
||||
void)
|
||||
{
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Initialize the watchdog timer
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
void watchdog_init(
|
||||
unsigned milliseconds)
|
||||
{
|
||||
unsigned value = WDTO_15MS;
|
||||
if (milliseconds) {
|
||||
if (milliseconds <= 15) {
|
||||
value = WDTO_15MS;
|
||||
} else if (milliseconds <= 30) {
|
||||
value = WDTO_30MS;
|
||||
} else if (milliseconds <= 60) {
|
||||
value = WDTO_60MS;
|
||||
} else if (milliseconds <= 120) {
|
||||
value = WDTO_120MS;
|
||||
} else if (milliseconds <= 500) {
|
||||
value = WDTO_500MS;
|
||||
} else if (milliseconds <= 1000) {
|
||||
value = WDTO_1S;
|
||||
} else {
|
||||
value = WDTO_2S;
|
||||
}
|
||||
wdt_enable(value);
|
||||
} else {
|
||||
wdt_disable();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#ifndef WATCHDOG_H
|
||||
#define WATCHDOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void watchdog_reset(void);
|
||||
void watchdog_init(unsigned milliseconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#ifndef WATCHDOG_H
|
||||
#define WATCHDOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void watchdog_reset(
|
||||
void);
|
||||
void watchdog_init(
|
||||
unsigned milliseconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
@@ -320,8 +320,8 @@ bool Analog_Value_Write_Property(
|
||||
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
|
||||
level = (uint8_t) value.type.Real;
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Analog_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Present_Value[object_index] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
|
||||
@@ -232,8 +232,8 @@ bool Binary_Value_Write_Property(
|
||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||
level = value.type.Enumerated;
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
/* NOTE: this Binary value has no priority array */
|
||||
Present_Value[object_index] = level;
|
||||
|
||||
@@ -378,7 +378,7 @@ int Device_Encode_Property_APDU(
|
||||
/* assume next one is the same size as this one */
|
||||
/* can we all fit into the APDU? */
|
||||
if ((apdu_len + len) >= MAX_APDU) {
|
||||
*error_code =
|
||||
*error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
apdu_len = BACNET_STATUS_ABORT;
|
||||
break;
|
||||
@@ -505,8 +505,8 @@ bool Device_Write_Property(
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
|
||||
@@ -149,7 +149,8 @@ static struct Address_Cache_Entry *address_remove_oldest(
|
||||
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
if ((pMatch->
|
||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
ulTime = pMatch->TimeToLive;
|
||||
@@ -168,7 +169,8 @@ static struct Address_Cache_Entry *address_remove_oldest(
|
||||
/* Second pass - try in use and un bound as last resort */
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
if ((pMatch->
|
||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
BAC_ADDR_STATIC)) ==
|
||||
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
|
||||
+13
-13
@@ -820,7 +820,7 @@ int bacapp_data_len(
|
||||
#ifdef BACAPP_PRINT_ENABLED
|
||||
bool bacapp_print_value(
|
||||
FILE * stream,
|
||||
BACNET_OBJECT_PROPERTY_VALUE *object_value)
|
||||
BACNET_OBJECT_PROPERTY_VALUE * object_value)
|
||||
{
|
||||
bool status = true; /*return value */
|
||||
size_t len = 0, i = 0;
|
||||
@@ -896,8 +896,8 @@ bool bacapp_print_value(
|
||||
case PROP_OBJECT_TYPE:
|
||||
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_object_type_name(value->
|
||||
type.Enumerated));
|
||||
bactext_object_type_name(value->type.
|
||||
Enumerated));
|
||||
} else if (value->type.Enumerated < 128) {
|
||||
fprintf(stream, "reserved %lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
@@ -913,8 +913,8 @@ bool bacapp_print_value(
|
||||
case PROP_UNITS:
|
||||
if (value->type.Enumerated < 256) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_engineering_unit_name(value->type.
|
||||
Enumerated));
|
||||
bactext_engineering_unit_name(value->
|
||||
type.Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "proprietary %lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
@@ -922,14 +922,14 @@ bool bacapp_print_value(
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_polarity_name(value->type.
|
||||
Enumerated));
|
||||
bactext_binary_polarity_name(value->
|
||||
type.Enumerated));
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_present_value_name(
|
||||
value->type.Enumerated));
|
||||
bactext_binary_present_value_name(value->type.
|
||||
Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "%lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
@@ -941,8 +941,8 @@ bool bacapp_print_value(
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
fprintf(stream, "%s",
|
||||
bactext_device_status_name(value->type.
|
||||
Enumerated));
|
||||
bactext_device_status_name(value->
|
||||
type.Enumerated));
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
fprintf(stream, "%s",
|
||||
@@ -1313,8 +1313,8 @@ void testBACnetApplicationData_Safe(
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||
characterstring_init_ansi(&input_value[i].
|
||||
type.Character_String, "Hello There!");
|
||||
characterstring_init_ansi(&input_value[i].type.
|
||||
Character_String, "Hello There!");
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||
|
||||
@@ -944,8 +944,8 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
{PROP_BINARY_INACTIVE_VALUE, "binary-inactive-value"}
|
||||
,
|
||||
/* enumeration 326 is used in Addendum j to ANSI/ASHRAE 135-2004 */
|
||||
{PROP_VERIFICATION_TIME, "verification-time"}
|
||||
,
|
||||
{PROP_VERIFICATION_TIME, "verification-time"}
|
||||
,
|
||||
{PROP_BIT_MASK, "bit-mask"}
|
||||
,
|
||||
{PROP_BIT_TEXT, "bit-text"}
|
||||
|
||||
@@ -678,8 +678,8 @@ static void bvlc_bdt_forward_npdu(
|
||||
mask in the BDT entry and logically ORing it with the
|
||||
BBMD address of the same entry. */
|
||||
bip_dest.sin_addr.s_addr =
|
||||
htonl(((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
|
||||
dest_address.s_addr));
|
||||
htonl(((~BBMD_Table[i].broadcast_mask.
|
||||
s_addr) | BBMD_Table[i].dest_address.s_addr));
|
||||
bip_dest.sin_port = htons(BBMD_Table[i].dest_port);
|
||||
/* don't send to my broadcast address and same port */
|
||||
if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr()))
|
||||
|
||||
+139
-134
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 0,
|
||||
&data->notificationParams.changeOfBitstring.
|
||||
referencedBitString);
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.referencedBitString);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.changeOfBitstring.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.changeOfState.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfState.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 1);
|
||||
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
|
||||
case CHANGE_OF_VALUE_REAL:
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 1,
|
||||
data->notificationParams.changeOfValue.
|
||||
newValue.changeValue);
|
||||
data->notificationParams.
|
||||
changeOfValue.newValue.changeValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len],
|
||||
0,
|
||||
&data->notificationParams.changeOfValue.
|
||||
newValue.changedBits);
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changedBits);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.changeOfValue.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfValue.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 2);
|
||||
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 0,
|
||||
data->notificationParams.floatingLimit.
|
||||
referenceValue);
|
||||
data->notificationParams.
|
||||
floatingLimit.referenceValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.floatingLimit.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
floatingLimit.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 2,
|
||||
data->notificationParams.floatingLimit.
|
||||
setPointValue);
|
||||
data->notificationParams.
|
||||
floatingLimit.setPointValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 0,
|
||||
data->notificationParams.outOfRange.
|
||||
exceedingValue);
|
||||
data->notificationParams.
|
||||
outOfRange.exceedingValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
newState);
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.newState);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 1,
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
newMode);
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.newMode);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 2,
|
||||
&data->notificationParams.changeOfLifeSafety.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfLifeSafety.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 3,
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected);
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.operationExpected);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 8);
|
||||
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu
|
||||
[apdu_len], 0,
|
||||
&data->notificationParams.bufferReady.
|
||||
bufferProperty);
|
||||
&data->notificationParams.
|
||||
bufferReady.bufferProperty);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 1,
|
||||
data->notificationParams.bufferReady.
|
||||
previousNotification);
|
||||
data->notificationParams.
|
||||
bufferReady.previousNotification);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.bufferReady.
|
||||
currentNotification);
|
||||
data->notificationParams.
|
||||
bufferReady.currentNotification);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 10);
|
||||
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 0,
|
||||
data->notificationParams.unsignedRange.
|
||||
exceedingValue);
|
||||
data->notificationParams.
|
||||
unsignedRange.exceedingValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.unsignedRange.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
unsignedRange.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.unsignedRange.
|
||||
exceededLimit);
|
||||
data->notificationParams.
|
||||
unsignedRange.exceededLimit);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 11);
|
||||
@@ -595,16 +595,18 @@ int event_notify_decode_service_request(
|
||||
case EVENT_CHANGE_OF_BITSTRING:
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.referencedBitString))) {
|
||||
&data->
|
||||
notificationParams.changeOfBitstring.
|
||||
referencedBitString))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.statusFlags))) {
|
||||
&data->
|
||||
notificationParams.changeOfBitstring.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -615,16 +617,16 @@ int event_notify_decode_service_request(
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_property_state(&apdu
|
||||
[len], 0,
|
||||
&data->notificationParams.changeOfState.
|
||||
newState))) {
|
||||
&data->notificationParams.
|
||||
changeOfState.newState))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.changeOfState.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
changeOfState.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -642,8 +644,9 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changedBits))) {
|
||||
&data->
|
||||
notificationParams.changeOfValue.
|
||||
newValue.changedBits))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -654,8 +657,9 @@ int event_notify_decode_service_request(
|
||||
CHANGE_OF_VALUE_REAL)) {
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changeValue))) {
|
||||
&data->
|
||||
notificationParams.changeOfValue.
|
||||
newValue.changeValue))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -673,8 +677,8 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.changeOfValue.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
changeOfValue.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -683,31 +687,31 @@ int event_notify_decode_service_request(
|
||||
case EVENT_FLOATING_LIMIT:
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 0,
|
||||
&data->notificationParams.floatingLimit.
|
||||
referenceValue))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.referenceValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.floatingLimit.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 2,
|
||||
&data->notificationParams.floatingLimit.
|
||||
setPointValue))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.setPointValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 3,
|
||||
&data->notificationParams.floatingLimit.
|
||||
errorLimit))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.errorLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -716,31 +720,31 @@ int event_notify_decode_service_request(
|
||||
case EVENT_OUT_OF_RANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 0,
|
||||
&data->notificationParams.outOfRange.
|
||||
exceedingValue))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.exceedingValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.outOfRange.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 2,
|
||||
&data->notificationParams.outOfRange.
|
||||
deadband))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.deadband))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 3,
|
||||
&data->notificationParams.outOfRange.
|
||||
exceededLimit))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.exceededLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -768,8 +772,9 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
changeOfLifeSafety.statusFlags))) {
|
||||
&data->
|
||||
notificationParams.changeOfLifeSafety.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -779,8 +784,8 @@ int event_notify_decode_service_request(
|
||||
&value))) {
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected =
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.operationExpected =
|
||||
(BACNET_LIFE_SAFETY_OPERATION) value;
|
||||
len += section_length;
|
||||
break;
|
||||
@@ -789,24 +794,24 @@ int event_notify_decode_service_request(
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_device_obj_property_ref
|
||||
(&apdu[len], 0,
|
||||
&data->notificationParams.bufferReady.
|
||||
bufferProperty))) {
|
||||
&data->notificationParams.
|
||||
bufferReady.bufferProperty))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 1,
|
||||
&data->notificationParams.bufferReady.
|
||||
previousNotification))) {
|
||||
&data->notificationParams.
|
||||
bufferReady.previousNotification))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.bufferReady.
|
||||
currentNotification))) {
|
||||
&data->notificationParams.
|
||||
bufferReady.currentNotification))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -815,24 +820,24 @@ int event_notify_decode_service_request(
|
||||
case EVENT_UNSIGNED_RANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 0,
|
||||
&data->notificationParams.unsignedRange.
|
||||
exceedingValue))) {
|
||||
&data->notificationParams.
|
||||
unsignedRange.exceedingValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.unsignedRange.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
unsignedRange.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.unsignedRange.
|
||||
exceededLimit))) {
|
||||
&data->notificationParams.
|
||||
unsignedRange.exceededLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -1091,16 +1096,16 @@ void testEventEventState(
|
||||
|
||||
data.eventType = EVENT_CHANGE_OF_BITSTRING;
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 2, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 2, false);
|
||||
bitstring_init(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 2, true);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 2, false);
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
|
||||
|
||||
@@ -1186,16 +1191,16 @@ void testEventEventState(
|
||||
|
||||
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 2, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 3, false);
|
||||
bitstring_init(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 2, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 3, false);
|
||||
|
||||
memset(buffer, 0, MAX_APDU);
|
||||
inLen = event_notify_encode_service_request(&buffer[0], &data);
|
||||
@@ -1435,12 +1440,12 @@ void testEventEventState(
|
||||
data.notificationParams.bufferReady.currentNotification = 2345;
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
|
||||
OBJECT_DEVICE;
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance = 500;
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.instance = 500;
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
|
||||
OBJECT_ANALOG_INPUT;
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance = 100;
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance = 100;
|
||||
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
|
||||
PROP_PRESENT_VALUE;
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
|
||||
@@ -1465,34 +1470,34 @@ void testEventEventState(
|
||||
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
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);
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
propertyIdentifier ==
|
||||
deviceIndentifier.instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
propertyIdentifier);
|
||||
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,
|
||||
data.notificationParams.bufferReady.
|
||||
bufferProperty.propertyIdentifier ==
|
||||
data2.notificationParams.bufferReady.
|
||||
bufferProperty.propertyIdentifier);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
unsigned FIFO_Count(
|
||||
FIFO_BUFFER const *b)
|
||||
{
|
||||
unsigned head, tail; /* used to avoid volatile decision */
|
||||
unsigned head, tail; /* used to avoid volatile decision */
|
||||
|
||||
if (b) {
|
||||
head = b->head;
|
||||
tail = b->tail;
|
||||
return head-tail;
|
||||
return head - tail;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user