Indented project.

This commit is contained in:
skarg
2011-08-17 02:27:11 +00:00
parent 7e503510c7
commit 3e1cb1847f
125 changed files with 3548 additions and 3353 deletions
+1 -1
View File
@@ -55,7 +55,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+6 -6
View File
@@ -66,7 +66,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
@@ -840,7 +840,7 @@ int CheckCommandLineArgs(
if (++i < argc) {
#if defined(BACDL_BIP)
My_BIP_Port = (uint16_t) strtol(argv[i], NULL, 0);
/* Used strtol so sport can be either 0xBAC0 or 47808 */
/* Used strtol so sport can be either 0xBAC0 or 47808 */
#endif
}
break;
@@ -1172,11 +1172,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 {
+1 -1
View File
@@ -101,7 +101,7 @@ static object_functions_t Object_Table[] = {
{FILE_OBJ_FUNCTIONS},
#endif
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/** Buffer used for receiving */
+20 -16
View File
@@ -119,7 +119,6 @@ void handler_alarm_ack(
#endif
goto AA_ABORT;
}
#if PRINT_ENABLED
fprintf(stderr,
"Alarm Ack Operation: Received acknowledge for object id (%d, %lu) from %s for process id %lu \n",
@@ -131,49 +130,54 @@ void handler_alarm_ack(
if (Alarm_Ack[data.eventObjectIdentifier.type]) {
ack_result = Alarm_Ack[data.eventObjectIdentifier.type](&data, &error_code);
ack_result =
Alarm_Ack[data.eventObjectIdentifier.type] (&data, &error_code);
switch (ack_result)
{
switch (ack_result) {
case 1:
len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM);
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM);
#if PRINT_ENABLED
fprintf(stderr, "Alarm Acknowledge: " "Sending Simple Ack!\n");
#endif
break;
case -1:
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM,
ERROR_CLASS_OBJECT, error_code);
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, ERROR_CLASS_OBJECT,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "Alarm Acknowledge: error %s!\n",
bactext_error_code_name(error_code));
bactext_error_code_name(error_code));
#endif
break;
default:
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
len =
abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, ABORT_REASON_OTHER, true);
#if PRINT_ENABLED
fprintf(stderr, "Alarm Acknowledge: abort other!\n");
#endif
break;
}
}
else {
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM,
ERROR_CLASS_OBJECT, ERROR_CODE_NO_ALARM_CONFIGURED);
#if PRINT_ENABLED
fprintf(stderr, "Alarm Acknowledge: error %s!\n",
bactext_error_code_name(ERROR_CODE_NO_ALARM_CONFIGURED));
bactext_error_code_name(ERROR_CODE_NO_ALARM_CONFIGURED));
#endif
}
AA_ABORT:
AA_ABORT:
pdu_len += len;
bytes_sent =
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
+13 -17
View File
@@ -419,32 +419,31 @@ void handler_cov_task(
COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
status = Device_Encode_Value_List(
object_type,
object_instance,
status =
Device_Encode_Value_List(object_type, object_instance,
&value_list[0]);
if (status) {
COV_Subscriptions[index].send_requested = true;
}
if (COV_Subscriptions[index].send_requested) {
cov_send_request(
&COV_Subscriptions[index],
&value_list[0]);
cov_send_request(&COV_Subscriptions[index], &value_list[0]);
COV_Subscriptions[index].send_requested = false;
}
if (status && ((index+1) < MAX_COV_SUBCRIPTIONS)) {
if (status && ((index + 1) < MAX_COV_SUBCRIPTIONS)) {
/* if more than one subscription for this object instance */
for (index2 = index+1; index2 < MAX_COV_SUBCRIPTIONS; index2++) {
for (index2 = index + 1; index2 < MAX_COV_SUBCRIPTIONS;
index2++) {
object_type2 =
COV_Subscriptions[index2].monitoredObjectIdentifier.type;
COV_Subscriptions[index2].monitoredObjectIdentifier.
type;
object_instance2 =
COV_Subscriptions[index2].monitoredObjectIdentifier.instance;
COV_Subscriptions[index2].monitoredObjectIdentifier.
instance;
if ((COV_Subscriptions[index].lifetime) &&
(COV_Subscriptions[index].valid) &&
(object_type == object_type2) &&
(object_instance == object_instance2)) {
cov_send_request(
&COV_Subscriptions[index2],
cov_send_request(&COV_Subscriptions[index2],
&value_list[0]);
COV_Subscriptions[index2].send_requested = false;
}
@@ -470,11 +469,8 @@ static bool cov_subscribe(
if (status) {
status = Device_Value_List_Supported(object_type);
if (status) {
status = cov_list_subscribe(
src,
cov_data,
error_class,
error_code);
status =
cov_list_subscribe(src, cov_data, error_class, error_code);
} else {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
+10 -10
View File
@@ -59,7 +59,7 @@ void handler_get_event_information(
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
int len = 0;
int pdu_len = 0;
int pdu_len = 0;
int apdu_len = 0;
BACNET_NPDU_DATA npdu_data;
bool error = false;
@@ -116,8 +116,8 @@ void handler_get_event_information(
error = true;
goto GET_EVENT_ERROR;
}
pdu_len += len;
apdu_len = len;
pdu_len += len;
apdu_len = len;
for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) {
if (Get_Event_Info[i]) {
for (j = 0; j < 0xffff; j++) {
@@ -125,8 +125,10 @@ void handler_get_event_information(
if (valid_event > 0) {
/* encode GetEvent_data only when type of object_id has max value */
if (object_id.type != MAX_BACNET_OBJECT_TYPE) {
if ((object_id.type == getevent_data.objectIdentifier.type) &&
(object_id.instance == getevent_data.objectIdentifier.instance)) {
if ((object_id.type ==
getevent_data.objectIdentifier.type) &&
(object_id.instance ==
getevent_data.objectIdentifier.instance)) {
/* found 'Last Received Object Identifier'
so should set type of object_id to max value */
object_id.type = MAX_BACNET_OBJECT_TYPE;
@@ -147,16 +149,14 @@ void handler_get_event_information(
if (apdu_len >= service_data->max_resp - 2) {
/* Device must be able to fit minimum one event information.
Length of one event informations needs more than 50 octets. */
if (service_data->max_resp < 128){
if (service_data->max_resp < 128) {
len = BACNET_STATUS_ABORT;
error = true;
goto GET_EVENT_ERROR;
}
else
} else
more_events = true;
break;
}
else
} else
pdu_len += len;
} else if (valid_event < 0) {
break;
+1 -1
View File
@@ -128,7 +128,7 @@ void handler_read_property(
/* too big for the sender - send an abort
* Setting of error code needed here as read property processing may
* have overriden the default set at start */
rpdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
rpdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
len = BACNET_STATUS_ABORT;
#if PRINT_ENABLED
fprintf(stderr, "RP: Message too large.\n");
+6 -9
View File
@@ -319,9 +319,8 @@ void handler_read_property_multiple(
if (property_count == 0) {
/* handle the error code - but use the special property */
len =
RPM_Encode_Property(
&Handler_Transmit_Buffer[npdu_len],
(uint16_t) apdu_len, MAX_APDU,
RPM_Encode_Property(&Handler_Transmit_Buffer
[npdu_len], (uint16_t) apdu_len, MAX_APDU,
&rpmdata);
if (len > 0) {
apdu_len += len;
@@ -335,10 +334,9 @@ void handler_read_property_multiple(
RPM_Object_Property(&property_list,
special_object_property, index);
len =
RPM_Encode_Property(
&Handler_Transmit_Buffer[npdu_len],
(uint16_t) apdu_len,
MAX_APDU, &rpmdata);
RPM_Encode_Property(&Handler_Transmit_Buffer
[npdu_len], (uint16_t) apdu_len, MAX_APDU,
&rpmdata);
if (len > 0) {
apdu_len += len;
} else {
@@ -352,8 +350,7 @@ void handler_read_property_multiple(
/* handle an individual property */
len =
RPM_Encode_Property(&Handler_Transmit_Buffer[npdu_len],
(uint16_t) apdu_len,
MAX_APDU, &rpmdata);
(uint16_t) apdu_len, MAX_APDU, &rpmdata);
if (len > 0) {
apdu_len += len;
} else {
+6 -6
View File
@@ -220,8 +220,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);
@@ -268,10 +268,10 @@ void rpm_ack_print_data(
#if PRINT_ENABLED
/* AccessError */
fprintf(stdout, "BACnet Error: %s: %s\r\n",
bactext_error_class_name((int) listOfProperties->error.
error_class),
bactext_error_code_name((int) listOfProperties->error.
error_code));
bactext_error_class_name((int) listOfProperties->
error.error_class),
bactext_error_code_name((int) listOfProperties->
error.error_code));
#endif
}
listOfProperties = listOfProperties->next;
+2 -2
View File
@@ -104,8 +104,8 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: ");
if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ",
bactext_property_name(pProperty_value->
propertyIdentifier));
bactext_property_name
(pProperty_value->propertyIdentifier));
} else {
fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier);
+3 -4
View File
@@ -64,10 +64,9 @@ static void match_name_or_object(
}
} else {
/* valid object_name copy in my device? */
found = Device_Object_Name_Copy(
data->object.identifier.type,
data->object.identifier.instance,
&object_name);
found =
Device_Object_Name_Copy(data->object.identifier.type,
data->object.identifier.instance, &object_name);
if (found) {
Send_I_Have(Device_Object_Instance_Number(),
(BACNET_OBJECT_TYPE) data->object.identifier.type,
+2 -2
View File
@@ -181,8 +181,8 @@ bool WPValidateString(
(!characterstring_printable(&pValue->type.Character_String))) {
/* assumption: non-empty also means must be "printable" */
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (characterstring_length(&pValue->type.
Character_String) >= iMaxLen) {
} else if (characterstring_length(&pValue->
type.Character_String) >= iMaxLen) {
*pErrorClass = ERROR_CLASS_RESOURCES;
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
} else
+49 -52
View File
@@ -70,10 +70,10 @@ void handler_write_property_multiple(
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
int len = 0;
int apdu_len = 0;
int npdu_len = 0;
int pdu_len = 0;
int len = 0;
int apdu_len = 0;
int npdu_len = 0;
int pdu_len = 0;
int decode_len = 0;
bool error = false;
BACNET_WRITE_PROPERTY_DATA wp_data;
@@ -84,9 +84,10 @@ void handler_write_property_multiple(
if (service_data->segmented_message) {
len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
len =
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
true);
#if PRINT_ENABLED
fprintf(stderr, "WPM: Segmented message. Sending Abort!\n");
#endif
@@ -95,27 +96,25 @@ void handler_write_property_multiple(
/* decode service request */
decode_len = 0;
do
{
do {
/* decode Object Identifier */
len = wpm_decode_object_id(&service_request[decode_len],
service_len - decode_len, &wp_data);
if (len > 0)
{
len =
wpm_decode_object_id(&service_request[decode_len],
service_len - decode_len, &wp_data);
if (len > 0) {
uint8_t tag_number = 0;
decode_len += len;
/* Opening tag 1 - List of Properties */
if (decode_is_opening_tag_number(&service_request[decode_len++], 1))
{
do
{
if (decode_is_opening_tag_number(&service_request[decode_len++],
1)) {
do {
/* decode a 'Property Identifier'; (3) an optional 'Property Array Index' */
/* (4) a 'Property Value'; and (5) an optional 'Priority'. */
len = wpm_decode_object_property(&service_request[decode_len],
service_len - decode_len, &wp_data);
if (len > 0)
{
len =
wpm_decode_object_property(&service_request
[decode_len], service_len - decode_len, &wp_data);
if (len > 0) {
decode_len += len;
#if PRINT_ENABLED
fprintf(stderr,
@@ -123,81 +122,79 @@ void handler_write_property_multiple(
(unsigned long) wp_data.object_type,
(unsigned long) wp_data.object_instance,
(unsigned long) wp_data.object_property,
(unsigned long) wp_data.priority, (long) wp_data.array_index);
(unsigned long) wp_data.priority,
(long) wp_data.array_index);
#endif
if (Device_Write_Property(&wp_data) == false)
{
if (Device_Write_Property(&wp_data) == false) {
error = true;
break; /* do while (decoding List of Properties) */
break; /* do while (decoding List of Properties) */
}
}
else
{
} else {
#if PRINT_ENABLED
fprintf(stderr, "WPM: Bad Encoding!\n");
#endif
wp_data.error_class = ERROR_CLASS_PROPERTY;
wp_data.error_code = ERROR_CODE_OTHER;
wp_data.error_code = ERROR_CODE_OTHER;
error = true;
break; /* do while (decoding List of Properties) */
}
/* Closing tag 1 - List of Properties */
if (decode_is_closing_tag_number(&service_request[decode_len], 1))
{
if (decode_is_closing_tag_number(&service_request
[decode_len], 1)) {
tag_number = 1;
decode_len++;
}
else
} else
tag_number = 0; /* it was not tag 1, decode next Property Identifier ... */
}
while(tag_number != 1); /* end decoding List of Properties for "that" object */
while (tag_number != 1); /* end decoding List of Properties for "that" object */
if (error)
break; /*do while (decode service request) */
break; /*do while (decode service request) */
}
}
else
{
} else {
#if PRINT_ENABLED
fprintf(stderr, "WPM: Bad Encoding!\n");
#endif
wp_data.error_class = ERROR_CLASS_OBJECT;
wp_data.error_code = ERROR_CODE_OTHER;
wp_data.error_code = ERROR_CODE_OTHER;
error = true;
break; /*do while (decode service request) */
break; /*do while (decode service request) */
}
}
while(decode_len < service_len);
while (decode_len < service_len);
/* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address);
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
npdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address,
&npdu_data);
npdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address,
&npdu_data);
apdu_len = 0;
if (error == false) {
apdu_len = wpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id);
apdu_len =
wpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id);
#if PRINT_ENABLED
fprintf(stderr, "WPM: Sending Simple Ack!\n");
#endif
}
else {
apdu_len = wpm_error_ack_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, &wp_data);
} else {
apdu_len =
wpm_error_ack_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, &wp_data);
#if PRINT_ENABLED
fprintf(stderr, "WPM: Sending Error!\n");
#endif
}
WPM_ABORT:
WPM_ABORT:
pdu_len = npdu_len + apdu_len;
bytes_sent = datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len);
bytes_sent =
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len);
}
+1 -1
View File
@@ -57,7 +57,7 @@ void Send_I_Have(
uint32_t device_id,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
int len = 0;
int pdu_len = 0;
+3 -2
View File
@@ -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) {
+30 -31
View File
@@ -172,7 +172,8 @@ static void packet_statistics(
break;
case FRAME_TYPE_POLL_FOR_MASTER:
if (MSTP_Statistics[src].last_pfm_tokens) {
npoll = MSTP_Statistics[src].token_received_count -
npoll =
MSTP_Statistics[src].token_received_count -
MSTP_Statistics[src].last_pfm_tokens;
if (npoll > MSTP_Statistics[src].npoll) {
MSTP_Statistics[src].npoll = npoll;
@@ -252,10 +253,8 @@ static void packet_statistics_print(
fprintf(stdout, "\r\n");
fprintf(stdout, "==== MS/TP Frame Counts ====\r\n");
fprintf(stdout, "%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s",
"MAC",
"Tokens","PFM","RPFM","DER",
"Postpd","DNER","TestReq","TestRsp");
fprintf(stdout, "%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s", "MAC", "Tokens",
"PFM", "RPFM", "DER", "Postpd", "DNER", "TestReq", "TestRsp");
fprintf(stdout, "\r\n");
for (i = 0; i < 256; i++) {
/* check for masters or slaves */
@@ -280,9 +279,9 @@ static void packet_statistics_print(
node_count = 0;
fprintf(stdout, "\r\n");
fprintf(stdout, "==== MS/TP Usage and Timing Maximums ====\r\n");
fprintf(stdout, "%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-7s",
"MAC","MaxMstr","Retries","Npoll","Self",
"Treply","Tusage","Trpfm","Tder","Tpostpd");
fprintf(stdout, "%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-8s%-7s", "MAC",
"MaxMstr", "Retries", "Npoll", "Self", "Treply", "Tusage", "Trpfm",
"Tder", "Tpostpd");
fprintf(stdout, "\r\n");
for (i = 0; i < 256; i++) {
/* check for masters or slaves */
@@ -552,8 +551,8 @@ static void write_received_packet(
(void) data_write((char *) &mstp_port->DataCRCActualLSB, 1, 1);
}
} else {
fprintf(stderr, "mstpcap[packet]: failed to open %s: %s\n", Capture_Filename,
strerror(errno));
fprintf(stderr, "mstpcap[packet]: failed to open %s: %s\n",
Capture_Filename, strerror(errno));
}
}
@@ -561,61 +560,61 @@ static void write_received_packet(
static bool test_global_header(
const char *filename)
{
uint32_t magic_number = 0; /* magic number */
uint32_t magic_number = 0; /* magic number */
uint16_t version_major = 0; /* major version number */
uint16_t version_minor = 0; /* minor version number */
int32_t thiszone = 0; /* GMT to local correction */
uint32_t sigfigs = 0; /* accuracy of timestamps */
uint32_t snaplen = 0; /* max length of captured packets, in octets */
uint32_t network = 0; /* data link type - BACNET_MS_TP */
uint32_t snaplen = 0; /* max length of captured packets, in octets */
uint32_t network = 0; /* data link type - BACNET_MS_TP */
size_t count = 0;
/* create a new file. */
pFile = fopen(filename, "rb");
if (pFile) {
count = fread(&magic_number, sizeof(magic_number), 1, pFile);
count = fread(&magic_number, sizeof(magic_number), 1, pFile);
if ((count != 1) || (magic_number != 0xa1b2c3d4)) {
fprintf(stderr, "mstpcap: invalid magic number\n");
fclose(pFile);
pFile = NULL;
return false;
}
count = fread(&version_major, sizeof(version_major), 1, pFile);
count = fread(&version_major, sizeof(version_major), 1, pFile);
if ((count != 1) || (version_major != 2)) {
fprintf(stderr, "mstpcap: invalid major version\n");
fclose(pFile);
pFile = NULL;
return false;
}
count = fread(&version_minor, sizeof(version_minor), 1, pFile);
count = fread(&version_minor, sizeof(version_minor), 1, pFile);
if ((count != 1) || (version_minor != 4)) {
fprintf(stderr, "mstpcap: invalid minor version\n");
fclose(pFile);
pFile = NULL;
return false;
}
count = fread(&thiszone, sizeof(thiszone), 1, pFile);
count = fread(&thiszone, sizeof(thiszone), 1, pFile);
if ((count != 1) || (thiszone != 0)) {
fprintf(stderr, "mstpcap: invalid time zone\n");
fclose(pFile);
pFile = NULL;
return false;
}
count = fread(&sigfigs, sizeof(sigfigs), 1, pFile);
count = fread(&sigfigs, sizeof(sigfigs), 1, pFile);
if ((count != 1) || (sigfigs != 0)) {
fprintf(stderr, "mstpcap: invalid time stamp accuracy\n");
fclose(pFile);
pFile = NULL;
return false;
}
count = fread(&snaplen, sizeof(snaplen), 1, pFile);
count = fread(&snaplen, sizeof(snaplen), 1, pFile);
if ((count != 1) || (snaplen != 65535)) {
fprintf(stderr, "mstpcap: invalid length of captured packets\n");
fclose(pFile);
pFile = NULL;
return false;
}
count = fread(&network, sizeof(network), 1, pFile);
count = fread(&network, sizeof(network), 1, pFile);
if ((count != 1) || (network != 165)) {
fprintf(stderr, "mstpcap: invalid data link type (DLT)\n");
fclose(pFile);
@@ -634,11 +633,11 @@ static bool test_global_header(
static bool read_received_packet(
volatile struct mstp_port_struct_t *mstp_port)
{
uint32_t ts_sec = 0; /* timestamp seconds */
uint32_t ts_usec = 0; /* timestamp microseconds */
uint32_t incl_len = 0; /* number of octets of packet saved in file */
uint32_t orig_len = 0; /* actual length of packet */
uint8_t header[8] = {0}; /* MS/TP header */
uint32_t ts_sec = 0; /* timestamp seconds */
uint32_t ts_usec = 0; /* timestamp microseconds */
uint32_t incl_len = 0; /* number of octets of packet saved in file */
uint32_t orig_len = 0; /* actual length of packet */
uint8_t header[8] = { 0 }; /* MS/TP header */
struct timeval tv;
size_t count = 0;
@@ -678,12 +677,12 @@ static bool read_received_packet(
mstp_port->FrameType = header[2];
mstp_port->DestinationAddress = header[3];
mstp_port->SourceAddress = header[4];
mstp_port->DataLength = MAKE_WORD(header[6],header[5]);
mstp_port->DataLength = MAKE_WORD(header[6], header[5]);
mstp_port->HeaderCRCActual = header[7];
if (orig_len > 8) {
mstp_port->DataLength = orig_len - 8 - 2;
count = fread(mstp_port->InputBuffer,
mstp_port->DataLength, 1, pFile);
count =
fread(mstp_port->InputBuffer, mstp_port->DataLength, 1, pFile);
if (count != 1) {
fclose(pFile);
pFile = NULL;
@@ -811,9 +810,9 @@ int main(
if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) {
printf("mstpcap %s\r\n", BACNET_VERSION_TEXT);
printf("Copyright (C) 2011 by Steve Karg\r\n"
"This is free software; see the source for copying conditions.\r\n"
"There is NO warranty; not even for MERCHANTABILITY or\r\n"
"FITNESS FOR A PARTICULAR PURPOSE.\r\n");
"This is free software; see the source for copying conditions.\r\n"
"There is NO warranty; not even for MERCHANTABILITY or\r\n"
"FITNESS FOR A PARTICULAR PURPOSE.\r\n");
return 0;
}
if ((argc > 1) && (strcmp(argv[1], "--scan") == 0)) {
+264 -231
View File
@@ -108,7 +108,7 @@ void Analog_Input_Init(
unsigned i, j;
for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
AI_Descr[i].Present_Value = 0.0f;
AI_Descr[i].Present_Value = 0.0f;
AI_Descr[i].Out_Of_Service = false;
AI_Descr[i].Units = UNITS_PERCENT;
AI_Descr[i].Reliability = RELIABILITY_NO_FAULT_DETECTED;
@@ -127,8 +127,7 @@ void Analog_Input_Init(
handler_get_event_information_set(OBJECT_ANALOG_INPUT,
Analog_Input_Event_Information);
/* Set handler for AcknowledgeAlarm function */
handler_alarm_ack_set(OBJECT_ANALOG_INPUT,
Analog_Input_Alarm_Ack);
handler_alarm_ack_set(OBJECT_ANALOG_INPUT, Analog_Input_Alarm_Ack);
#endif
}
}
@@ -207,7 +206,7 @@ void Analog_Input_Present_Value_Set(
bool Analog_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
unsigned int index;
@@ -277,50 +276,61 @@ int Analog_Input_Read_Property(
bitstring_init(&bit_string);
#if defined(INTRINSIC_REPORTING)
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
CurrentAI->Event_State ? true : false);
CurrentAI->Event_State ? true : false);
#else
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
#endif
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAI->Out_Of_Service);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_EVENT_STATE:
#if defined(INTRINSIC_REPORTING)
apdu_len = encode_application_enumerated(&apdu[0],
CurrentAI->Event_State);
apdu_len =
encode_application_enumerated(&apdu[0],
CurrentAI->Event_State);
#else
apdu_len = encode_application_enumerated(&apdu[0],
EVENT_STATE_NORMAL);
apdu_len =
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
#endif
break;
case PROP_RELIABILITY:
apdu_len = encode_application_enumerated(&apdu[0], CurrentAI->Reliability);
apdu_len =
encode_application_enumerated(&apdu[0],
CurrentAI->Reliability);
break;
case PROP_OUT_OF_SERVICE:
apdu_len = encode_application_boolean(&apdu[0], CurrentAI->Out_Of_Service);
apdu_len =
encode_application_boolean(&apdu[0],
CurrentAI->Out_Of_Service);
break;
case PROP_UNITS:
apdu_len = encode_application_enumerated(&apdu[0], CurrentAI->Units);
apdu_len =
encode_application_enumerated(&apdu[0], CurrentAI->Units);
break;
#if defined(INTRINSIC_REPORTING)
case PROP_TIME_DELAY:
apdu_len = encode_application_unsigned(&apdu[0], CurrentAI->Time_Delay);
apdu_len =
encode_application_unsigned(&apdu[0], CurrentAI->Time_Delay);
break;
case PROP_NOTIFICATION_CLASS:
apdu_len = encode_application_unsigned(&apdu[0], CurrentAI->Notification_Class);
apdu_len =
encode_application_unsigned(&apdu[0],
CurrentAI->Notification_Class);
break;
case PROP_HIGH_LIMIT:
apdu_len = encode_application_real(&apdu[0], CurrentAI->High_Limit);
apdu_len =
encode_application_real(&apdu[0], CurrentAI->High_Limit);
break;
case PROP_LOW_LIMIT:
@@ -334,21 +344,26 @@ int Analog_Input_Read_Property(
case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0,
(CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE ) ? true : false );
(CurrentAI->
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
bitstring_set_bit(&bit_string, 1,
(CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false );
(CurrentAI->
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
apdu_len = encode_application_bitstring(&apdu[0],&bit_string);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_EVENT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -356,62 +371,69 @@ int Analog_Input_Read_Property(
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_NOTIFY_TYPE:
apdu_len = encode_application_enumerated(&apdu[0],
CurrentAI->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
apdu_len =
encode_application_enumerated(&apdu[0],
CurrentAI->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
break;
case PROP_EVENT_TIME_STAMPS:
/* Array element zero is the number of elements in the array */
if (rpdata->array_index == 0)
apdu_len = encode_application_unsigned(&apdu[0],
MAX_BACNET_EVENT_TRANSITION);
apdu_len =
encode_application_unsigned(&apdu[0],
MAX_BACNET_EVENT_TRANSITION);
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
for (i = 0; i < MAX_BACNET_EVENT_TRANSITION; i++) {;
len = encode_opening_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
len += encode_application_date(&apdu[apdu_len + len],
&CurrentAI->Event_Time_Stamps[i].date);
len += encode_application_time(&apdu[apdu_len + len],
&CurrentAI->Event_Time_Stamps[i].time);
len += encode_closing_tag(&apdu[apdu_len + len],
TIME_STAMP_DATETIME);
len =
encode_opening_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
len +=
encode_application_date(&apdu[apdu_len + len],
&CurrentAI->Event_Time_Stamps[i].date);
len +=
encode_application_time(&apdu[apdu_len + len],
&CurrentAI->Event_Time_Stamps[i].time);
len +=
encode_closing_tag(&apdu[apdu_len + len],
TIME_STAMP_DATETIME);
/* add it if we have room */
if ((apdu_len + len) < MAX_APDU)
apdu_len += len;
else {
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 = BACNET_STATUS_ERROR;
break;
}
}
}
else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
apdu_len = encode_opening_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
apdu_len += encode_application_date(&apdu[apdu_len],
&CurrentAI->Event_Time_Stamps[rpdata->array_index].date);
apdu_len += encode_application_time(&apdu[apdu_len],
&CurrentAI->Event_Time_Stamps[rpdata->array_index].time);
apdu_len += encode_closing_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
}
else {
} else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
apdu_len =
encode_opening_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
apdu_len +=
encode_application_date(&apdu[apdu_len],
&CurrentAI->Event_Time_Stamps[rpdata->array_index].date);
apdu_len +=
encode_application_time(&apdu[apdu_len],
&CurrentAI->Event_Time_Stamps[rpdata->array_index].time);
apdu_len +=
encode_closing_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
} else {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
apdu_len = BACNET_STATUS_ERROR;
}
break;
@@ -436,11 +458,10 @@ int Analog_Input_Read_Property(
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->object_property != PROP_EVENT_TIME_STAMPS) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
if ((apdu_len >= 0) && (rpdata->object_property != PROP_EVENT_TIME_STAMPS)
&& (rpdata->array_index != BACNET_ARRAY_ALL)) {
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 = BACNET_STATUS_ERROR;
}
@@ -449,7 +470,7 @@ int Analog_Input_Read_Property(
/* returns true if successful */
bool Analog_Input_Write_Property(
BACNET_WRITE_PROPERTY_DATA * wp_data)
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
bool status = false; /* return value */
unsigned int object_index = 0;
@@ -465,7 +486,7 @@ bool Analog_Input_Write_Property(
if (len < 0) {
/* error while decoding - a value larger than we can handle */
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;
return false;
}
@@ -484,11 +505,10 @@ bool Analog_Input_Write_Property(
if (status) {
if (CurrentAI->Out_Of_Service == true) {
Analog_Input_Present_Value_Set(wp_data->object_instance,
value.type.Real);
}
else {
value.type.Real);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
status = false;
}
}
@@ -570,13 +590,12 @@ bool Analog_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if(value.type.Bit_String.bits_used == 2) {
if (value.type.Bit_String.bits_used == 2) {
CurrentAI->Limit_Enable = value.type.Bit_String.value[0];
}
else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
}
}
break;
@@ -587,13 +606,12 @@ bool Analog_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if(value.type.Bit_String.bits_used == 3) {
if (value.type.Bit_String.bits_used == 3) {
CurrentAI->Event_Enable = value.type.Bit_String.value[0];
}
else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
}
}
break;
@@ -604,13 +622,12 @@ bool Analog_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if(value.type.Bit_String.bits_used > NOTIFY_EVENT) {
if (value.type.Bit_String.bits_used > NOTIFY_EVENT) {
CurrentAI->Event_Enable = value.type.Enumerated;
}
else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
}
}
break;
@@ -618,7 +635,7 @@ bool Analog_Input_Write_Property(
default:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
@@ -626,7 +643,8 @@ bool Analog_Input_Write_Property(
}
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
void Analog_Input_Intrinsic_Reporting(
uint32_t object_instance)
{
#if defined(INTRINSIC_REPORTING)
BACNET_EVENT_NOTIFICATION_DATA event_data;
@@ -637,7 +655,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
uint8_t ToState;
float ExceededLimit = 0.0f;
float PresentVal = 0.0f;
bool SendNotify = false;
bool SendNotify = false;
object_index = Analog_Input_Instance_To_Index(object_instance);
@@ -648,7 +666,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
/* check limits */
if (!CurrentAI->Limit_Enable)
return; /* limits are not configured */
return; /* limits are not configured */
if (CurrentAI->Ack_notify_data.bSendAckNotify) {
@@ -659,8 +677,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
#if PRINT_ENABLED
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
bactext_object_type_name(OBJECT_ANALOG_INPUT),
object_instance);
bactext_object_type_name(OBJECT_ANALOG_INPUT), object_instance);
#endif /* PRINT_ENABLED */
characterstring_init_ansi(&msgText, "AckNotification");
@@ -670,25 +687,23 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
/* Send EventNotification. */
SendNotify = true;
}
else
{
} else {
/* actual Present_Value */
PresentVal = Analog_Input_Present_Value(object_instance);
FromState = CurrentAI->Event_State;
switch (CurrentAI->Event_State)
{
FromState = CurrentAI->Event_State;
switch (CurrentAI->Event_State) {
case EVENT_STATE_NORMAL:
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the High_Limit for a minimum
period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
(a) the Present_Value must exceed the High_Limit for a minimum
period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAI->High_Limit) &&
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ==
EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ==
EVENT_ENABLE_TO_OFFNORMAL)) {
if (!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_HIGH_LIMIT;
else
CurrentAI->Remaining_Time_Delay--;
@@ -696,15 +711,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
}
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->Low_Limit) &&
((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ==
EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ==
EVENT_ENABLE_TO_OFFNORMAL)) {
if (!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_LOW_LIMIT;
else
CurrentAI->Remaining_Time_Delay--;
@@ -717,15 +733,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
case EVENT_STATE_HIGH_LIMIT:
/* Once exceeded, the Present_Value must fall below the High_Limit minus
the Deadband before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->High_Limit - CurrentAI->Deadband) &&
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
(a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->High_Limit - CurrentAI->Deadband)
&& ((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ==
EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) ==
EVENT_ENABLE_TO_NORMAL)) {
if (!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_NORMAL;
else
CurrentAI->Remaining_Time_Delay--;
@@ -739,15 +756,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
/* Once the Present_Value has fallen below the Low_Limit,
the Present_Value must exceed the Low_Limit plus the Deadband
before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAI->Low_Limit + CurrentAI->Deadband) &&
((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAI->Low_Limit + CurrentAI->Deadband)
&& ((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ==
EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) ==
EVENT_ENABLE_TO_NORMAL)) {
if (!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_NORMAL;
else
CurrentAI->Remaining_Time_Delay--;
@@ -758,41 +776,36 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
break;
default:
return; /* shouldn't happen */
} /* switch (FromState) */
return; /* shouldn't happen */
} /* switch (FromState) */
ToState = CurrentAI->Event_State;
if (FromState != ToState)
{
if (FromState != ToState) {
/* Event_State has changed.
Need to fill only the basic parameters of this type of event.
Other parameters will be filled in common function. */
switch (ToState)
{
switch (ToState) {
case EVENT_STATE_HIGH_LIMIT:
ExceededLimit = CurrentAI->High_Limit;
characterstring_init_ansi(&msgText,
"Goes to high limit");
characterstring_init_ansi(&msgText, "Goes to high limit");
break;
case EVENT_STATE_LOW_LIMIT:
ExceededLimit = CurrentAI->Low_Limit;
characterstring_init_ansi(&msgText,
"Goes to low limit");
characterstring_init_ansi(&msgText, "Goes to low limit");
break;
case EVENT_STATE_NORMAL:
if(FromState == EVENT_STATE_HIGH_LIMIT) {
if (FromState == EVENT_STATE_HIGH_LIMIT) {
ExceededLimit = CurrentAI->High_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from high limit");
}
else {
"Back to normal state from high limit");
} else {
ExceededLimit = CurrentAI->Low_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from low limit");
"Back to normal state from low limit");
}
break;
@@ -803,9 +816,9 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
#if PRINT_ENABLED
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
bactext_object_type_name(OBJECT_ANALOG_INPUT),
object_instance, bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
bactext_object_type_name(OBJECT_ANALOG_INPUT), object_instance,
bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
#endif /* PRINT_ENABLED */
/* Notify Type */
@@ -817,8 +830,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
}
if (SendNotify)
{
if (SendNotify) {
/* Event Object Identifier */
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT;
event_data.eventObjectIdentifier.instance = object_instance;
@@ -829,22 +841,21 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
/* fill Event_Time_Stamps */
switch (ToState)
{
switch (ToState) {
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
event_data.timeStamp.value.dateTime;
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT] =
event_data.timeStamp.value.dateTime;
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
event_data.timeStamp.value.dateTime;
event_data.timeStamp.value.dateTime;
break;
}
}
@@ -871,50 +882,57 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
/* Event Values */
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
/* Value that exceeded a limit. */
event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
event_data.notificationParams.outOfRange.exceedingValue =
PresentVal;
/* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_IN_ALARM, CurrentAI->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service);
bitstring_init(&event_data.notificationParams.outOfRange.
statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAI->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAI->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband = CurrentAI->Deadband;
event_data.notificationParams.outOfRange.deadband =
CurrentAI->Deadband;
/* Limit that was exceeded. */
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
event_data.notificationParams.outOfRange.exceededLimit =
ExceededLimit;
}
/* add data from notification class */
Notification_Class_common_reporting_function(&event_data);
/* Ack required */
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
(event_data.ackRequired == true))
{
switch (event_data.toState)
{
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
(event_data.ackRequired == true)) {
switch (event_data.toState) {
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
Time_Stamp = event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
break;
}
}
@@ -924,12 +942,13 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
#if defined(INTRINSIC_REPORTING)
int Analog_Input_Event_Information(unsigned index,
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
int Analog_Input_Event_Information(
unsigned index,
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
{
bool IsNotAckedTransitions;
bool IsActiveEvent;
int i;
int i;
/* check index */
@@ -939,63 +958,75 @@ int Analog_Input_Event_Information(unsigned index,
/* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions = (AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) |
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) |
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
}
else
return -1; /* end of list */
IsNotAckedTransitions =
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked == false);
} else
return -1; /* end of list */
if ((IsActiveEvent) || (IsNotAckedTransitions)) {
/* Object Identifier */
getevent_data->objectIdentifier.type = OBJECT_ANALOG_INPUT;
getevent_data->objectIdentifier.instance = Analog_Input_Index_To_Instance(index);
getevent_data->objectIdentifier.instance =
Analog_Input_Index_To_Instance(index);
/* Event State */
getevent_data->eventState = AI_Descr[index].Event_State;
/* Acknowledged Transitions */
bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_NORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
/* Event Time Stamps */
for (i = 0; i < 3; i++) {
getevent_data->eventTimeStamps[i].tag = TIME_STAMP_DATETIME;
getevent_data->eventTimeStamps[i].value.dateTime =
AI_Descr[index].Event_Time_Stamps[i];
AI_Descr[index].Event_Time_Stamps[i];
}
/* Notify Type */
getevent_data->notifyType = AI_Descr[index].Notify_Type;
/* Event Enable */
bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
/* Event Priorities */
Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class,
getevent_data->eventPriorities);
getevent_data->eventPriorities);
return 1; /* active event */
}
else
return 0; /* no active event at this index */
return 1; /* active event */
} else
return 0; /* no active event at this index */
}
int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
BACNET_ERROR_CODE * error_code)
int Analog_Input_Alarm_Ack(
BACNET_ALARM_ACK_DATA * alarmack_data,
BACNET_ERROR_CODE * error_code)
{
ANALOG_INPUT_DESCR *CurrentAI;
unsigned int object_index;
object_index = Analog_Input_Instance_To_Index(
alarmack_data->eventObjectIdentifier.instance);
object_index =
Analog_Input_Instance_To_Index(alarmack_data->eventObjectIdentifier.
instance);
if (object_index < MAX_ANALOG_INPUTS)
CurrentAI = &AI_Descr[object_index];
@@ -1004,71 +1035,73 @@ int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
return -1;
}
switch (alarmack_data->eventStateAcked)
{
switch (alarmack_data->eventStateAcked) {
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
if(CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
if (CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if(datetime_compare(&CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
{
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* FIXME: Send ack notification */
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
}
else {
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
}
break;
case EVENT_STATE_FAULT:
if(CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false) {
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
if (CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked ==
false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if(datetime_compare(&CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
{
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* FIXME: Send ack notification */
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
}
else {
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
}
break;
case EVENT_STATE_NORMAL:
if(CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) {
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
if (CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if(datetime_compare(&CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
{
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* FIXME: Send ack notification */
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
}
else {
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
}
+18 -15
View File
@@ -42,20 +42,20 @@ extern "C" {
#endif /* __cplusplus */
typedef struct analog_input_descr {
uint8_t Event_State : 3;
float Present_Value;
uint8_t Event_State:3;
float Present_Value;
BACNET_RELIABILITY Reliability;
bool Out_Of_Service;
uint8_t Units;
bool Out_Of_Service;
uint8_t Units;
#if defined(INTRINSIC_REPORTING)
uint32_t Time_Delay;
uint32_t Notification_Class;
float High_Limit;
float Low_Limit;
float Deadband;
uint8_t Limit_Enable : 2;
uint8_t Event_Enable : 3;
uint8_t Notify_Type : 1;
float High_Limit;
float Low_Limit;
float Deadband;
uint8_t Limit_Enable:2;
uint8_t Event_Enable:3;
uint8_t Notify_Type:1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */
@@ -83,7 +83,7 @@ extern "C" {
bool Analog_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool Analog_Input_Name_Set(
uint32_t object_instance,
char *new_name);
@@ -112,14 +112,17 @@ extern "C" {
float value);
/* note: header of Intrinsic_Reporting function is required
even when INTRINSIC_REPORTING is not defined */
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance);
even when INTRINSIC_REPORTING is not defined */
void Analog_Input_Intrinsic_Reporting(
uint32_t object_instance);
#if defined(INTRINSIC_REPORTING)
int Analog_Input_Event_Information(unsigned index,
int Analog_Input_Event_Information(
unsigned index,
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data);
int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
int Analog_Input_Alarm_Ack(
BACNET_ALARM_ACK_DATA * alarmack_data,
BACNET_ERROR_CODE * error_code);
#endif
+9 -9
View File
@@ -255,7 +255,7 @@ bool Analog_Output_Present_Value_Relinquish(
/* note: the object name must be unique within this device */
bool Analog_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -447,11 +447,11 @@ bool Analog_Output_Write_Property(
if (status) {
level = AO_LEVEL_NULL;
object_index =
Analog_Output_Instance_To_Index(wp_data->
object_instance);
Analog_Output_Instance_To_Index
(wp_data->object_instance);
status =
Analog_Output_Present_Value_Relinquish(wp_data->
object_instance, wp_data->priority);
Analog_Output_Present_Value_Relinquish
(wp_data->object_instance, wp_data->priority);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -491,10 +491,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -65,7 +65,7 @@ extern "C" {
bool Analog_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool Analog_Output_Name_Set(
uint32_t object_instance,
char *new_name);
+261 -232
View File
@@ -133,8 +133,7 @@ void Analog_Value_Init(
handler_get_event_information_set(OBJECT_ANALOG_VALUE,
Analog_Value_Event_Information);
/* Set handler for AcknowledgeAlarm function */
handler_alarm_ack_set(OBJECT_ANALOG_VALUE,
Analog_Value_Alarm_Ack);
handler_alarm_ack_set(OBJECT_ANALOG_VALUE, Analog_Value_Alarm_Ack);
#endif
}
}
@@ -196,8 +195,7 @@ bool Analog_Value_Present_Value_Set(
CurrentAV = &AV_Descr[index];
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
(priority != 6 /* reserved */ ) &&
(value >= 0.0) && (value <= 100.0))
{
(value >= 0.0) && (value <= 100.0)) {
CurrentAV->Priority_Array[priority - 1] = (uint8_t) value;
/* Note: you could set the physical output here to the next
highest priority, or to the relinquish default if no
@@ -240,7 +238,7 @@ float Analog_Value_Present_Value(
/* note: the object name must be unique within this device */
bool Analog_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -310,24 +308,26 @@ int Analog_Value_Read_Property(
bitstring_init(&bit_string);
#if defined(INTRINSIC_REPORTING)
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
CurrentAV->Event_State ? true : false);
CurrentAV->Event_State ? true : false);
#else
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
#endif
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAV->Out_Of_Service);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_EVENT_STATE:
#if defined(INTRINSIC_REPORTING)
apdu_len = encode_application_enumerated(&apdu[0],
CurrentAV->Event_State);
apdu_len =
encode_application_enumerated(&apdu[0],
CurrentAV->Event_State);
#else
apdu_len = encode_application_enumerated(&apdu[0],
EVENT_STATE_NORMAL);
apdu_len =
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
#endif
break;
@@ -337,7 +337,8 @@ int Analog_Value_Read_Property(
break;
case PROP_UNITS:
apdu_len = encode_application_enumerated(&apdu[0], CurrentAV->Units);
apdu_len =
encode_application_enumerated(&apdu[0], CurrentAV->Units);
break;
case PROP_PRIORITY_ARRAY:
@@ -363,7 +364,7 @@ int Analog_Value_Read_Property(
apdu_len += len;
else {
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 = BACNET_STATUS_ERROR;
break;
}
@@ -371,11 +372,11 @@ int Analog_Value_Read_Property(
} else {
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (CurrentAV->Priority_Array[rpdata->array_index - 1]
== ANALOG_LEVEL_NULL)
== ANALOG_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]);
else {
real_value = CurrentAV->Priority_Array
[rpdata->array_index - 1];
real_value =
CurrentAV->Priority_Array[rpdata->array_index - 1];
apdu_len =
encode_application_real(&apdu[0], real_value);
}
@@ -394,15 +395,19 @@ int Analog_Value_Read_Property(
#if defined(INTRINSIC_REPORTING)
case PROP_TIME_DELAY:
apdu_len = encode_application_unsigned(&apdu[0], CurrentAV->Time_Delay);
apdu_len =
encode_application_unsigned(&apdu[0], CurrentAV->Time_Delay);
break;
case PROP_NOTIFICATION_CLASS:
apdu_len = encode_application_unsigned(&apdu[0], CurrentAV->Notification_Class);
apdu_len =
encode_application_unsigned(&apdu[0],
CurrentAV->Notification_Class);
break;
case PROP_HIGH_LIMIT:
apdu_len = encode_application_real(&apdu[0], CurrentAV->High_Limit);
apdu_len =
encode_application_real(&apdu[0], CurrentAV->High_Limit);
break;
case PROP_LOW_LIMIT:
@@ -416,21 +421,26 @@ int Analog_Value_Read_Property(
case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0,
(CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE ) ? true : false );
(CurrentAV->
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
bitstring_set_bit(&bit_string, 1,
(CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false );
(CurrentAV->
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
apdu_len = encode_application_bitstring(&apdu[0],&bit_string);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_EVENT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -438,62 +448,69 @@ int Analog_Value_Read_Property(
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_NOTIFY_TYPE:
apdu_len = encode_application_enumerated(&apdu[0],
CurrentAV->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
apdu_len =
encode_application_enumerated(&apdu[0],
CurrentAV->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
break;
case PROP_EVENT_TIME_STAMPS:
/* Array element zero is the number of elements in the array */
if (rpdata->array_index == 0)
apdu_len = encode_application_unsigned(&apdu[0],
MAX_BACNET_EVENT_TRANSITION);
apdu_len =
encode_application_unsigned(&apdu[0],
MAX_BACNET_EVENT_TRANSITION);
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
for (i = 0; i < MAX_BACNET_EVENT_TRANSITION; i++) {;
len = encode_opening_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
len += encode_application_date(&apdu[apdu_len + len],
&CurrentAV->Event_Time_Stamps[i].date);
len += encode_application_time(&apdu[apdu_len + len],
&CurrentAV->Event_Time_Stamps[i].time);
len += encode_closing_tag(&apdu[apdu_len + len],
TIME_STAMP_DATETIME);
len =
encode_opening_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
len +=
encode_application_date(&apdu[apdu_len + len],
&CurrentAV->Event_Time_Stamps[i].date);
len +=
encode_application_time(&apdu[apdu_len + len],
&CurrentAV->Event_Time_Stamps[i].time);
len +=
encode_closing_tag(&apdu[apdu_len + len],
TIME_STAMP_DATETIME);
/* add it if we have room */
if ((apdu_len + len) < MAX_APDU)
apdu_len += len;
else {
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 = BACNET_STATUS_ERROR;
break;
}
}
}
else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
apdu_len = encode_opening_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
apdu_len += encode_application_date(&apdu[apdu_len],
&CurrentAV->Event_Time_Stamps[rpdata->array_index].date);
apdu_len += encode_application_time(&apdu[apdu_len],
&CurrentAV->Event_Time_Stamps[rpdata->array_index].time);
apdu_len += encode_closing_tag(&apdu[apdu_len],
TIME_STAMP_DATETIME);
}
else {
} else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
apdu_len =
encode_opening_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
apdu_len +=
encode_application_date(&apdu[apdu_len],
&CurrentAV->Event_Time_Stamps[rpdata->array_index].date);
apdu_len +=
encode_application_time(&apdu[apdu_len],
&CurrentAV->Event_Time_Stamps[rpdata->array_index].time);
apdu_len +=
encode_closing_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
} else {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
apdu_len = BACNET_STATUS_ERROR;
}
break;
@@ -501,17 +518,16 @@ int Analog_Value_Read_Property(
default:
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
apdu_len = BACNET_STATUS_ERROR;
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
(rpdata->object_property != PROP_EVENT_TIME_STAMPS) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
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 = BACNET_STATUS_ERROR;
}
@@ -677,13 +693,12 @@ bool Analog_Value_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if(value.type.Bit_String.bits_used == 2) {
if (value.type.Bit_String.bits_used == 2) {
CurrentAV->Limit_Enable = value.type.Bit_String.value[0];
}
else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
}
}
break;
@@ -694,13 +709,12 @@ bool Analog_Value_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if(value.type.Bit_String.bits_used == 3) {
if (value.type.Bit_String.bits_used == 3) {
CurrentAV->Event_Enable = value.type.Bit_String.value[0];
}
else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
}
}
break;
@@ -711,13 +725,12 @@ bool Analog_Value_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if(value.type.Bit_String.bits_used > NOTIFY_EVENT) {
if (value.type.Bit_String.bits_used > NOTIFY_EVENT) {
CurrentAV->Event_Enable = value.type.Enumerated;
}
else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
status = false;
}
}
break;
@@ -725,7 +738,7 @@ bool Analog_Value_Write_Property(
default:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
@@ -733,7 +746,8 @@ bool Analog_Value_Write_Property(
}
void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
void Analog_Value_Intrinsic_Reporting(
uint32_t object_instance)
{
#if defined(INTRINSIC_REPORTING)
BACNET_EVENT_NOTIFICATION_DATA event_data;
@@ -744,7 +758,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
uint8_t ToState;
float ExceededLimit = 0.0f;
float PresentVal = 0.0f;
bool SendNotify = false;
bool SendNotify = false;
object_index = Analog_Value_Instance_To_Index(object_instance);
@@ -755,7 +769,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
/* check limits */
if (!CurrentAV->Limit_Enable)
return; /* limits are not configured */
return; /* limits are not configured */
if (CurrentAV->Ack_notify_data.bSendAckNotify) {
@@ -766,8 +780,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
#if PRINT_ENABLED
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE),
object_instance);
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance);
#endif /* PRINT_ENABLED */
characterstring_init_ansi(&msgText, "AckNotification");
@@ -777,25 +790,23 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
/* Send EventNotification. */
SendNotify = true;
}
else
{
} else {
/* actual Present_Value */
PresentVal = Analog_Value_Present_Value(object_instance);
FromState = CurrentAV->Event_State;
switch (CurrentAV->Event_State)
{
FromState = CurrentAV->Event_State;
switch (CurrentAV->Event_State) {
case EVENT_STATE_NORMAL:
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the High_Limit for a minimum
period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
(a) the Present_Value must exceed the High_Limit for a minimum
period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAV->High_Limit) &&
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ==
EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ==
EVENT_ENABLE_TO_OFFNORMAL)) {
if (!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_HIGH_LIMIT;
else
CurrentAV->Remaining_Time_Delay--;
@@ -803,15 +814,16 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
}
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->Low_Limit) &&
((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ==
EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ==
EVENT_ENABLE_TO_OFFNORMAL)) {
if (!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_LOW_LIMIT;
else
CurrentAV->Remaining_Time_Delay--;
@@ -824,15 +836,16 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
case EVENT_STATE_HIGH_LIMIT:
/* Once exceeded, the Present_Value must fall below the High_Limit minus
the Deadband before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->High_Limit - CurrentAV->Deadband) &&
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
(a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->High_Limit - CurrentAV->Deadband)
&& ((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ==
EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ==
EVENT_ENABLE_TO_NORMAL)) {
if (!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_NORMAL;
else
CurrentAV->Remaining_Time_Delay--;
@@ -846,15 +859,16 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
/* Once the Present_Value has fallen below the Low_Limit,
the Present_Value must exceed the Low_Limit plus the Deadband
before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAV->Low_Limit + CurrentAV->Deadband) &&
((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAV->Low_Limit + CurrentAV->Deadband)
&& ((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ==
EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ==
EVENT_ENABLE_TO_NORMAL)) {
if (!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_NORMAL;
else
CurrentAV->Remaining_Time_Delay--;
@@ -865,41 +879,36 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
break;
default:
return; /* shouldn't happen */
} /* switch (FromState) */
return; /* shouldn't happen */
} /* switch (FromState) */
ToState = CurrentAV->Event_State;
if (FromState != ToState)
{
if (FromState != ToState) {
/* Event_State has changed.
Need to fill only the basic parameters of this type of event.
Other parameters will be filled in common function. */
switch (ToState)
{
switch (ToState) {
case EVENT_STATE_HIGH_LIMIT:
ExceededLimit = CurrentAV->High_Limit;
characterstring_init_ansi(&msgText,
"Goes to high limit");
characterstring_init_ansi(&msgText, "Goes to high limit");
break;
case EVENT_STATE_LOW_LIMIT:
ExceededLimit = CurrentAV->Low_Limit;
characterstring_init_ansi(&msgText,
"Goes to low limit");
characterstring_init_ansi(&msgText, "Goes to low limit");
break;
case EVENT_STATE_NORMAL:
if(FromState == EVENT_STATE_HIGH_LIMIT) {
if (FromState == EVENT_STATE_HIGH_LIMIT) {
ExceededLimit = CurrentAV->High_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from high limit");
}
else {
"Back to normal state from high limit");
} else {
ExceededLimit = CurrentAV->Low_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from low limit");
"Back to normal state from low limit");
}
break;
@@ -910,9 +919,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
#if PRINT_ENABLED
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE),
object_instance, bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance,
bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
#endif /* PRINT_ENABLED */
/* Notify Type */
@@ -924,8 +933,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
}
if (SendNotify)
{
if (SendNotify) {
/* Event Object Identifier */
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_VALUE;
event_data.eventObjectIdentifier.instance = object_instance;
@@ -936,22 +944,21 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
/* fill Event_Time_Stamps */
switch (ToState)
{
switch (ToState) {
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
event_data.timeStamp.value.dateTime;
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_FAULT] =
event_data.timeStamp.value.dateTime;
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
event_data.timeStamp.value.dateTime;
event_data.timeStamp.value.dateTime;
break;
}
}
@@ -978,50 +985,57 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
/* Event Values */
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
/* Value that exceeded a limit. */
event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
event_data.notificationParams.outOfRange.exceedingValue =
PresentVal;
/* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_IN_ALARM, CurrentAV->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service);
bitstring_init(&event_data.notificationParams.outOfRange.
statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAV->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAV->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband = CurrentAV->Deadband;
event_data.notificationParams.outOfRange.deadband =
CurrentAV->Deadband;
/* Limit that was exceeded. */
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
event_data.notificationParams.outOfRange.exceededLimit =
ExceededLimit;
}
/* add data from notification class */
Notification_Class_common_reporting_function(&event_data);
/* Ack required */
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
(event_data.ackRequired == true))
{
switch (event_data.toState)
{
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
(event_data.ackRequired == true)) {
switch (event_data.toState) {
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
Time_Stamp = event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
break;
}
}
@@ -1031,12 +1045,13 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
#if defined(INTRINSIC_REPORTING)
int Analog_Value_Event_Information(unsigned index,
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
int Analog_Value_Event_Information(
unsigned index,
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
{
bool IsNotAckedTransitions;
bool IsActiveEvent;
int i;
int i;
/* check index */
@@ -1046,62 +1061,74 @@ int Analog_Value_Event_Information(unsigned index,
/* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions = (AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) |
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) |
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
}
else
return -1; /* end of list */
IsNotAckedTransitions =
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked == false);
} else
return -1; /* end of list */
if ((IsActiveEvent) || (IsNotAckedTransitions)) {
/* Object Identifier */
getevent_data->objectIdentifier.type = OBJECT_ANALOG_VALUE;
getevent_data->objectIdentifier.instance = Analog_Value_Index_To_Instance(index);
getevent_data->objectIdentifier.instance =
Analog_Value_Index_To_Instance(index);
/* Event State */
getevent_data->eventState = AV_Descr[index].Event_State;
/* Acknowledged Transitions */
bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_NORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
/* Event Time Stamps */
for (i = 0; i < 3; i++) {
getevent_data->eventTimeStamps[i].tag = TIME_STAMP_DATETIME;
getevent_data->eventTimeStamps[i].value.dateTime =
AV_Descr[index].Event_Time_Stamps[i];
AV_Descr[index].Event_Time_Stamps[i];
}
/* Notify Type */
getevent_data->notifyType = AV_Descr[index].Notify_Type;
/* Event Enable */
bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
/* Event Priorities */
Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class,
getevent_data->eventPriorities);
getevent_data->eventPriorities);
return 1; /* active event */
}
else
return 0; /* no active event at this index */
return 1; /* active event */
} else
return 0; /* no active event at this index */
}
int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
BACNET_ERROR_CODE * error_code)
int Analog_Value_Alarm_Ack(
BACNET_ALARM_ACK_DATA * alarmack_data,
BACNET_ERROR_CODE * error_code)
{
ANALOG_VALUE_DESCR *CurrentAV;
unsigned int object_index;
object_index = Analog_Value_Instance_To_Index(
alarmack_data->eventObjectIdentifier.instance);
object_index =
Analog_Value_Instance_To_Index(alarmack_data->eventObjectIdentifier.
instance);
if (object_index < MAX_ANALOG_VALUES)
CurrentAV = &AV_Descr[object_index];
@@ -1110,71 +1137,73 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
return -1;
}
switch (alarmack_data->eventStateAcked)
{
switch (alarmack_data->eventStateAcked) {
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
if(CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
if (CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if(datetime_compare(&CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
{
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
}
else {
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
}
break;
case EVENT_STATE_FAULT:
if(CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false) {
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
if (CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked ==
false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if(datetime_compare(&CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
{
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
}
else {
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
}
break;
case EVENT_STATE_NORMAL:
if(CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) {
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
if (CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if(datetime_compare(&CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
{
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
}
else {
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
}
@@ -1205,10 +1234,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+17 -15
View File
@@ -43,23 +43,23 @@ extern "C" {
#endif /* __cplusplus */
typedef struct analog_value_descr {
uint8_t Event_State : 3;
bool Out_Of_Service;
uint8_t Units;
uint8_t Event_State:3;
bool Out_Of_Service;
uint8_t Units;
/* Here is our Priority Array. They are supposed to be Real, but */
/* we don't have that kind of memory, so we will use a single byte */
/* and load a Real for returning the value when asked. */
uint8_t Priority_Array[BACNET_MAX_PRIORITY];
float Relinquish_Default;
uint8_t Priority_Array[BACNET_MAX_PRIORITY];
float Relinquish_Default;
#if defined(INTRINSIC_REPORTING)
uint32_t Time_Delay;
uint32_t Notification_Class;
float High_Limit;
float Low_Limit;
float Deadband;
uint8_t Limit_Enable : 2;
uint8_t Event_Enable : 3;
uint8_t Notify_Type : 1;
float High_Limit;
float Low_Limit;
float Deadband;
uint8_t Limit_Enable:2;
uint8_t Event_Enable:3;
uint8_t Notify_Type:1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */
@@ -85,7 +85,7 @@ extern "C" {
bool Analog_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
int Analog_Value_Read_Property(
BACNET_READ_PROPERTY_DATA * rpdata);
@@ -101,15 +101,17 @@ extern "C" {
uint32_t object_instance);
/* note: header of Intrinsic_Reporting function is required
even when INTRINSIC_REPORTING is not defined */
even when INTRINSIC_REPORTING is not defined */
void Analog_Value_Intrinsic_Reporting(
uint32_t object_instance);
#if defined(INTRINSIC_REPORTING)
int Analog_Value_Event_Information(unsigned index,
int Analog_Value_Event_Information(
unsigned index,
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data);
int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
int Analog_Value_Alarm_Ack(
BACNET_ALARM_ACK_DATA * alarmack_data,
BACNET_ERROR_CODE * error_code);
#endif
+8 -10
View File
@@ -94,7 +94,7 @@ void BACfile_Property_Lists(
return;
}
static char * bacfile_name(
static char *bacfile_name(
uint32_t instance)
{
uint32_t index = 0;
@@ -114,7 +114,7 @@ static char * bacfile_name(
bool bacfile_object_name(
uint32_t instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
bool status = false;
char *filename = NULL;
@@ -491,15 +491,13 @@ bool bacfile_read_ack_stream_data(
found = true;
pFile = fopen(pFilename, "rb");
if (pFile) {
(void) fseek(pFile, data->type.stream.fileStartPosition,
SEEK_SET);
(void) fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
if (fwrite(octetstring_value(&data->fileData),
octetstring_length(&data->fileData), 1,
pFile) != 1) {
#if PRINT_ENABLED
fprintf(stderr, "Failed to write to %s (%lu)!\n",
pFilename, (unsigned long) instance);
#endif
octetstring_length(&data->fileData), 1, pFile) != 1) {
#if PRINT_ENABLED
fprintf(stderr, "Failed to write to %s (%lu)!\n", pFilename,
(unsigned long) instance);
#endif
}
fclose(pFile);
}
+1 -1
View File
@@ -54,7 +54,7 @@ extern "C" {
const int **pProprietary);
bool bacfile_object_name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool bacfile_valid_instance(
uint32_t object_instance);
uint32_t bacfile_count(
+9 -9
View File
@@ -233,10 +233,10 @@ bool Binary_Input_Encode_Value_List(
value_list->value.context_specific = false;
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
bitstring_init(&value_list->value.type.Bit_String);
bitstring_set_bit(&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM,
false);
bitstring_set_bit(&value_list->value.type.Bit_String, STATUS_FLAG_FAULT,
false);
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_IN_ALARM, false);
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_FAULT, false);
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_OVERRIDDEN, false);
if (Binary_Input_Out_Of_Service(object_instance)) {
@@ -292,7 +292,7 @@ static void Binary_Input_Out_Of_Service_Set(
bool Binary_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -494,10 +494,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -54,7 +54,7 @@ extern "C" {
bool Binary_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool Binary_Input_Name_Set(
uint32_t object_instance,
char *new_name);
+9 -9
View File
@@ -179,7 +179,7 @@ BACNET_BINARY_PV Binary_Output_Present_Value(
/* note: the object name must be unique within this device */
bool Binary_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -376,8 +376,8 @@ bool Binary_Output_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index =
Binary_Output_Instance_To_Index(wp_data->
object_instance);
Binary_Output_Instance_To_Index
(wp_data->object_instance);
priority--;
Binary_Output_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we
@@ -403,8 +403,8 @@ bool Binary_Output_Write_Property(
if (status) {
level = BINARY_NULL;
object_index =
Binary_Output_Instance_To_Index(wp_data->
object_instance);
Binary_Output_Instance_To_Index
(wp_data->object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
@@ -455,10 +455,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -57,7 +57,7 @@ extern "C" {
bool Binary_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool Binary_Output_Name_Set(
uint32_t object_instance,
char *new_name);
+9 -9
View File
@@ -176,7 +176,7 @@ static BACNET_BINARY_PV Binary_Value_Present_Value(
/* note: the object name must be unique within this device */
bool Binary_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -359,8 +359,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
Binary_Value_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we
@@ -386,8 +386,8 @@ bool Binary_Value_Write_Property(
if (status) {
level = BINARY_NULL;
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
@@ -437,10 +437,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -51,7 +51,7 @@ extern "C" {
bool Binary_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
void Binary_Value_Init(
void);
+88 -82
View File
@@ -38,7 +38,7 @@
#include "apdu.h"
#include "wp.h" /* WriteProperty handling */
#include "rp.h" /* ReadProperty handling */
#include "dcc.h" /* DeviceCommunicationControl handling */
#include "dcc.h" /* DeviceCommunicationControl handling */
#include "version.h"
#include "device.h" /* me */
#include "handlers.h"
@@ -86,72 +86,81 @@ extern bool Routed_Device_Write_Property_Local(
static object_functions_t Object_Table[] = {
{
OBJECT_DEVICE, NULL, Device_Count, /* don't init - recursive! */
OBJECT_DEVICE, NULL, Device_Count, /* don't init - recursive! */
Device_Index_To_Instance, Device_Valid_Object_Instance_Number,
Device_Object_Name, Device_Read_Property_Local,
Device_Write_Property_Local, Device_Property_Lists,
NULL, NULL, NULL, NULL}, {
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
NULL, NULL, NULL, NULL}, {
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
Analog_Input_Object_Name, Analog_Input_Read_Property,
Analog_Input_Write_Property, Analog_Input_Property_Lists,
NULL, NULL, NULL, Analog_Input_Intrinsic_Reporting}, {
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
NULL, NULL, NULL, Analog_Input_Intrinsic_Reporting}, {
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
Analog_Value_Object_Name, Analog_Value_Read_Property,
Analog_Value_Write_Property, Analog_Value_Property_Lists,
NULL, NULL, NULL, Analog_Value_Intrinsic_Reporting}, {
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
NULL, NULL, NULL, Analog_Value_Intrinsic_Reporting}, {
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
Binary_Input_Object_Name, Binary_Input_Read_Property,
NULL, Binary_Input_Property_Lists,
NULL, NULL, NULL, NULL}, {
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
NULL, NULL, NULL, NULL}, {
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
Binary_Value_Object_Name, Binary_Value_Read_Property,
Binary_Value_Write_Property, Binary_Value_Property_Lists,
NULL, NULL, NULL, NULL}, {
NULL, NULL, NULL, NULL}, {
#if defined(INTRINSIC_REPORTING)
OBJECT_NOTIFICATION_CLASS, Notification_Class_Init, Notification_Class_Count,
Notification_Class_Index_To_Instance, Notification_Class_Valid_Instance,
OBJECT_NOTIFICATION_CLASS, Notification_Class_Init,
Notification_Class_Count,
Notification_Class_Index_To_Instance,
Notification_Class_Valid_Instance,
Notification_Class_Object_Name, Notification_Class_Read_Property,
Notification_Class_Write_Property, Notification_Class_Property_Lists,
NULL, NULL, NULL, NULL}, {
Notification_Class_Write_Property,
Notification_Class_Property_Lists,
NULL, NULL, NULL, NULL}, {
#endif
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init, Life_Safety_Point_Count,
Life_Safety_Point_Index_To_Instance, Life_Safety_Point_Valid_Instance,
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init,
Life_Safety_Point_Count,
Life_Safety_Point_Index_To_Instance,
Life_Safety_Point_Valid_Instance,
Life_Safety_Point_Object_Name, Life_Safety_Point_Read_Property,
Life_Safety_Point_Write_Property, Life_Safety_Point_Property_Lists,
NULL, NULL, NULL, NULL}, {
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count,
NULL, NULL, NULL, NULL}, {
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count,
Load_Control_Index_To_Instance, Load_Control_Valid_Instance,
Load_Control_Object_Name, Load_Control_Read_Property,
Load_Control_Write_Property, Load_Control_Property_Lists,
NULL, NULL, NULL}, {
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init, Multistate_Output_Count,
Multistate_Output_Index_To_Instance, Multistate_Output_Valid_Instance,
NULL, NULL, NULL}, {
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
Multistate_Output_Count,
Multistate_Output_Index_To_Instance,
Multistate_Output_Valid_Instance,
Multistate_Output_Object_Name, Multistate_Output_Read_Property,
Multistate_Output_Write_Property, Multistate_Output_Property_Lists,
NULL, NULL, NULL, NULL}, {
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init, Multistate_Input_Count,
Multistate_Input_Index_To_Instance, Multistate_Input_Valid_Instance,
NULL, NULL, NULL, NULL}, {
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init,
Multistate_Input_Count,
Multistate_Input_Index_To_Instance,
Multistate_Input_Valid_Instance,
Multistate_Input_Object_Name, Multistate_Input_Read_Property,
Multistate_Input_Write_Property, Multistate_Input_Property_Lists,
NULL, NULL, NULL, NULL}, {
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
NULL, NULL, NULL, NULL}, {
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance,
Trend_Log_Object_Name, Trend_Log_Read_Property,
Trend_Log_Write_Property, Trend_Log_Property_Lists,
TrendLogGetRRInfo, NULL, NULL, NULL}, {
TrendLogGetRRInfo, NULL, NULL, NULL}, {
#if defined(BACFILE)
OBJECT_FILE, bacfile_init, bacfile_count,
OBJECT_FILE, bacfile_init, bacfile_count,
bacfile_index_to_instance, bacfile_valid_instance,
bacfile_object_name, bacfile_read_property,
bacfile_write_property, BACfile_Property_Lists,
NULL, NULL, NULL, NULL}, {
NULL, NULL, NULL, NULL}, {
#endif
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL}
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL}
};
@@ -474,7 +483,7 @@ bool Device_Valid_Object_Instance_Number(
bool Device_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
bool status = false;
@@ -486,7 +495,7 @@ bool Device_Object_Name(
}
bool Device_Set_Object_Name(
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
bool status = false; /*return value */
@@ -816,7 +825,7 @@ bool Device_Object_List_Identifier(
* @return True on success or else False if not found.
*/
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING *object_name1,
BACNET_CHARACTER_STRING * object_name1,
int *object_type,
uint32_t * object_instance)
{
@@ -835,7 +844,7 @@ bool Device_Valid_Object_Name(
pObject = Device_Objects_Find_Functions(type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
characterstring_same(object_name1, &object_name2))) {
found = true;
if (object_type) {
*object_type = type;
@@ -860,7 +869,7 @@ bool Device_Valid_Object_Id(
int object_type,
uint32_t object_instance)
{
bool status = false; /* return value */
bool status = false; /* return value */
struct object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
@@ -880,7 +889,7 @@ bool Device_Valid_Object_Id(
bool Device_Object_Name_Copy(
int object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
struct object_functions *pObject = NULL;
bool found = false;
@@ -960,7 +969,8 @@ int tm_isdst Daylight Savings flag.
}
}
void Device_getCurrentDateTime(BACNET_DATE_TIME * DateTime)
void Device_getCurrentDateTime(
BACNET_DATE_TIME * DateTime)
{
Update_Current_Time();
@@ -1265,8 +1275,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */
} else {
status = false;
@@ -1299,8 +1309,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
/* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t) value.type.
Unsigned_Int);
Device_Set_Vendor_Identifier((uint16_t) value.
type.Unsigned_Int);
}
break;
case PROP_SYSTEM_STATUS:
@@ -1325,15 +1335,14 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_NAME:
status =
WPValidateString(&value,
characterstring_capacity(&My_Object_Name),
false,
&wp_data->error_class, &wp_data->error_code);
characterstring_capacity(&My_Object_Name), false,
&wp_data->error_class, &wp_data->error_code);
if (status) {
/* All the object names in a device must be unique.
Disallow setting the Device Object Name to any objects in
the device. */
if (Device_Valid_Object_Name(&value.type.Character_String,
NULL, NULL)) {
NULL, NULL)) {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
@@ -1347,8 +1356,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Location(characterstring_value(&value.type.
Character_String),
Device_Set_Location(characterstring_value(&value.
type.Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1358,8 +1367,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Description(characterstring_value(&value.type.
Character_String),
Device_Set_Description(characterstring_value(&value.
type.Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1368,8 +1377,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Model_Name(characterstring_value(&value.type.
Character_String),
Device_Set_Model_Name(characterstring_value(&value.
type.Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1381,8 +1390,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames((uint8_t) value.type.
Unsigned_Int);
dlmstp_set_max_info_frames((uint8_t) value.
type.Unsigned_Int);
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1464,9 +1473,9 @@ bool Device_Write_Property(
* @return True if the object instance supports this feature and value changed.
*/
bool Device_Encode_Value_List(
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_PROPERTY_VALUE * value_list)
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_PROPERTY_VALUE * value_list)
{
bool status = false; /* Ever the pessamist! */
struct object_functions *pObject = NULL;
@@ -1476,9 +1485,8 @@ bool Device_Encode_Value_List(
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
if (pObject->Object_Value_List) {
status = pObject->Object_Value_List(
object_instance,
value_list);
status =
pObject->Object_Value_List(object_instance, value_list);
}
}
}
@@ -1488,29 +1496,27 @@ bool Device_Encode_Value_List(
#if defined(INTRINSIC_REPORTING)
void Device_local_reporting(void)
void Device_local_reporting(
void)
{
struct object_functions *pObject;
struct object_functions *pObject;
uint32_t objects_count;
uint32_t object_instance;
int object_type;
int object_type;
uint32_t idx;
objects_count = Device_Object_List_Count();
/* loop for all objects */
for (idx = 1; idx < objects_count; idx++)
{
Device_Object_List_Identifier(idx, &object_type,
&object_instance);
for (idx = 1; idx < objects_count; idx++) {
Device_Object_List_Identifier(idx, &object_type, &object_instance);
pObject = Device_Objects_Find_Functions(object_type);
if (pObject != NULL) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
if (pObject->Object_Intrinsic_Reporting) {
pObject->Object_Intrinsic_Reporting(
object_instance);
pObject->Object_Intrinsic_Reporting(object_instance);
}
}
}
@@ -1555,7 +1561,7 @@ void Device_Init(
characterstring_init_ansi(&My_Object_Name, "SimpleServer");
/* we don't use the object table passed in
since there is extra stuff we don't need in there. */
(void)object_table;
(void) object_table;
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Init) {
@@ -1653,10 +1659,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
@@ -1668,11 +1674,11 @@ bool WPValidateString(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
iMaxLen=iMaxLen;
bEmptyAllowed=bEmptyAllowed;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
iMaxLen = iMaxLen;
bEmptyAllowed = bEmptyAllowed;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
@@ -1681,8 +1687,8 @@ int handler_cov_encode_subscriptions(
uint8_t * apdu,
int max_apdu)
{
apdu=apdu;
max_apdu=max_apdu;
apdu = apdu;
max_apdu = max_apdu;
return 0;
}
+14 -12
View File
@@ -73,9 +73,9 @@ typedef uint32_t(
*/
typedef bool(
*object_name_function)
(
(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
/** Look in the table of objects of this type, and see if this is a valid
* instance number.
@@ -116,9 +116,9 @@ typedef bool(
* @ingroup ObjHelpers
* @param [in] Object instance.
*/
typedef void(
typedef void (
*object_intrinsic_reporting_function) (
uint32_t object_instance);
uint32_t object_instance);
/** Defines the group of object helper functions for any supported Object.
@@ -213,7 +213,8 @@ extern "C" {
rr_info_function Device_Objects_RR_Info(
BACNET_OBJECT_TYPE object_type);
void Device_getCurrentDateTime(BACNET_DATE_TIME * DateTime);
void Device_getCurrentDateTime(
BACNET_DATE_TIME * DateTime);
void Device_Property_Lists(
const int **pRequired,
@@ -250,14 +251,14 @@ extern "C" {
bool Device_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool Device_Set_Object_Name(
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
/* copy a child object name */
bool Device_Object_Name_Copy(
int object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
BACNET_DEVICE_STATUS Device_System_Status(
void);
@@ -316,7 +317,7 @@ extern "C" {
void);
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING *object_name,
BACNET_CHARACTER_STRING * object_name,
int *object_type,
uint32_t * object_instance);
bool Device_Valid_Object_Id(
@@ -338,7 +339,8 @@ extern "C" {
BACNET_WRITE_PROPERTY_DATA * wp_data);
#if defined(INTRINSIC_REPORTING)
void Device_local_reporting(void);
void Device_local_reporting(
void);
#endif
/* Prototypes for Routing functionality in the Device Object.
@@ -411,11 +413,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
+7 -12
View File
@@ -127,14 +127,10 @@ uint16_t Add_Routed_Device(
pDev->bacObj.mObject_Type = OBJECT_DEVICE;
pDev->bacObj.Object_Instance_Number = Object_Instance;
if (sObject_Name != NULL)
Routed_Device_Set_Object_Name(
CHARACTER_UTF8,
sObject_Name,
Routed_Device_Set_Object_Name(CHARACTER_UTF8, sObject_Name,
strlen(sObject_Name));
else
Routed_Device_Set_Object_Name(
CHARACTER_UTF8,
"No Name",
Routed_Device_Set_Object_Name(CHARACTER_UTF8, "No Name",
strlen("No Name"));
if (sDescription != NULL)
Routed_Device_Set_Description(sDescription, strlen(sDescription));
@@ -488,8 +484,8 @@ bool Routed_Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Routed_Device_Set_Object_Instance_Number(value.
type.Object_Id.instance))) {
(Routed_Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */
} else {
status = false;
@@ -503,8 +499,8 @@ bool Routed_Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Routed_Device_Set_Object_Name(
characterstring_encoding(&value.type.Character_String),
Routed_Device_Set_Object_Name(characterstring_encoding(&value.
type.Character_String),
characterstring_value(&value.type.Character_String),
characterstring_length(&value.type.Character_String));
}
@@ -559,8 +555,7 @@ bool Routed_Device_Set_Object_Name(
bool status = false; /*return value */
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if ((encoding == CHARACTER_UTF8) &&
(length < MAX_DEV_NAME_LEN)) {
if ((encoding == CHARACTER_UTF8) && (length < MAX_DEV_NAME_LEN)) {
/* Make the change and update the database revision */
memmove(pDev->bacObj.Object_Name, value, length);
pDev->bacObj.Object_Name[length] = 0;
+1 -1
View File
@@ -274,7 +274,7 @@ static BACNET_SHED_STATE Load_Control_Present_Value(
/* note: the object name must be unique within this device */
bool Load_Control_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
+1 -1
View File
@@ -54,7 +54,7 @@ extern "C" {
bool Load_Control_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
void Load_Control_Init(
void);
+12 -12
View File
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
object_index =
Lighting_Output_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Lighting_Output_Level[object_index][rpdata->
array_index - 1] == LIGHTING_LEVEL_NULL)
if (Lighting_Output_Level[object_index][rpdata->array_index
- 1] == LIGHTING_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]);
else {
real_value = Lighting_Output_Level[object_index]
@@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property(
if (status) {
level = LIGHTING_LEVEL_NULL;
object_index =
Lighting_Output_Instance_To_Index(wp_data->
object_instance);
Lighting_Output_Instance_To_Index
(wp_data->object_instance);
status =
Lighting_Output_Present_Value_Relinquish(wp_data->
object_instance, wp_data->priority);
Lighting_Output_Present_Value_Relinquish
(wp_data->object_instance, wp_data->priority);
if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Lighting_Output_Instance_To_Index(wp_data->
object_instance);
Lighting_Output_Instance_To_Index
(wp_data->object_instance);
Lighting_Output_Out_Of_Service[object_index] =
value.type.Boolean;
}
@@ -612,10 +612,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+11 -10
View File
@@ -175,7 +175,7 @@ static BACNET_LIFE_SAFETY_STATE Life_Safety_Point_Present_Value(
/* note: the object name must be unique within this device */
bool Life_Safety_Point_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -218,7 +218,8 @@ int Life_Safety_Point_Read_Property(
break;
case PROP_OBJECT_NAME:
case PROP_DESCRIPTION:
Life_Safety_Point_Object_Name(rpdata->object_instance, &char_string);
Life_Safety_Point_Object_Name(rpdata->object_instance,
&char_string);
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
break;
@@ -324,8 +325,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 {
@@ -341,8 +342,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;
}
@@ -368,10 +369,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -50,7 +50,7 @@ extern "C" {
uint32_t object_instance);
bool Life_Safety_Point_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
void Life_Safety_Point_Init(
void);
+15 -14
View File
@@ -227,7 +227,7 @@ bool Multistate_Input_Description_Set(
bool Multistate_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
unsigned index = 0; /* offset from instance lookup */
bool status = false;
@@ -348,7 +348,8 @@ int Multistate_Input_Read_Property(
/* note: Name and Description don't have to be the same.
You could make Description writable and different */
case PROP_OBJECT_NAME:
Multistate_Input_Object_Name(rpdata->object_instance, &char_string);
Multistate_Input_Object_Name(rpdata->object_instance,
&char_string);
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
break;
@@ -403,8 +404,8 @@ int Multistate_Input_Read_Property(
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
object_index =
Multistate_Input_Instance_To_Index(rpdata->
object_instance);
Multistate_Input_Instance_To_Index
(rpdata->object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance,
@@ -425,8 +426,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,
@@ -486,8 +487,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;
@@ -505,8 +506,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;
@@ -531,10 +532,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -62,7 +62,7 @@ extern "C" {
bool Multistate_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
bool Multistate_Input_Name_Set(
uint32_t object_instance,
char *new_name);
+17 -16
View File
@@ -182,7 +182,7 @@ static uint32_t Multistate_Output_Present_Value(
/* note: the object name must be unique within this device */
bool Multistate_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -224,7 +224,8 @@ int Multistate_Output_Read_Property(
You could make Description writable and different */
case PROP_OBJECT_NAME:
case PROP_DESCRIPTION:
Multistate_Output_Object_Name(rpdata->object_instance, &char_string);
Multistate_Output_Object_Name(rpdata->object_instance,
&char_string);
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
break;
@@ -267,8 +268,8 @@ int Multistate_Output_Read_Property(
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index =
Multistate_Output_Instance_To_Index(rpdata->
object_instance);
Multistate_Output_Instance_To_Index
(rpdata->object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] ==
@@ -293,8 +294,8 @@ int Multistate_Output_Read_Property(
}
} else {
object_index =
Multistate_Output_Instance_To_Index(rpdata->
object_instance);
Multistate_Output_Instance_To_Index
(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Multistate_Output_Level[object_index]
[rpdata->array_index - 1] == MULTISTATE_NULL)
@@ -376,8 +377,8 @@ bool Multistate_Output_Write_Property(
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
level = value.type.Unsigned_Int;
object_index =
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
priority--;
Multistate_Output_Level[object_index][priority] =
(uint8_t) level;
@@ -404,8 +405,8 @@ bool Multistate_Output_Write_Property(
if (status) {
level = MULTISTATE_NULL;
object_index =
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
@@ -431,8 +432,8 @@ bool Multistate_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Out_Of_Service[object_index] =
value.type.Boolean;
}
@@ -458,10 +459,10 @@ bool WPValidateArgType(
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
pValue=pValue;
ucExpectedTag=ucExpectedTag;
pErrorClass=pErrorClass;
pErrorCode=pErrorCode;
pValue = pValue;
ucExpectedTag = ucExpectedTag;
pErrorClass = pErrorClass;
pErrorCode = pErrorCode;
return false;
}
+1 -1
View File
@@ -51,7 +51,7 @@ extern "C" {
bool Multistate_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
void Multistate_Output_Init(
void);
File diff suppressed because it is too large Load Diff
+51 -48
View File
@@ -38,11 +38,11 @@ extern "C" {
/* max "length" of recipient_list */
#define NC_MAX_RECIPIENTS 10
/* Recipient types */
typedef enum {
RECIPIENT_TYPE_NOTINITIALIZED = 0,
RECIPIENT_TYPE_DEVICE = 1,
RECIPIENT_TYPE_ADDRESS = 2
} NC_RECIPIENT_TYPE;
typedef enum {
RECIPIENT_TYPE_NOTINITIALIZED = 0,
RECIPIENT_TYPE_DEVICE = 1,
RECIPIENT_TYPE_ADDRESS = 2
} NC_RECIPIENT_TYPE;
#if defined(INTRINSIC_REPORTING)
@@ -53,47 +53,47 @@ BACnetRecipient ::= CHOICE {
address [1] BACnetAddress
}
*/
typedef struct BACnet_Recipient {
uint8_t RecipientType; /* Type of Recipient */
union {
uint32_t DeviceIdentifier;
BACNET_ADDRESS Address;
} _;
} BACNET_RECIPIENT;
typedef struct BACnet_Recipient {
uint8_t RecipientType; /* Type of Recipient */
union {
uint32_t DeviceIdentifier;
BACNET_ADDRESS Address;
} _;
} BACNET_RECIPIENT;
/* BACnetDestination structure */
typedef struct BACnet_Destination {
uint8_t ValidDays;
BACNET_TIME FromTime;
BACNET_TIME ToTime;
BACNET_RECIPIENT Recipient;
uint32_t ProcessIdentifier;
uint8_t Transitions;
bool ConfirmedNotify;
} BACNET_DESTINATION;
typedef struct BACnet_Destination {
uint8_t ValidDays;
BACNET_TIME FromTime;
BACNET_TIME ToTime;
BACNET_RECIPIENT Recipient;
uint32_t ProcessIdentifier;
uint8_t Transitions;
bool ConfirmedNotify;
} BACNET_DESTINATION;
/* Structure containing configuration for a Notification Class */
typedef struct Notification_Class_info {
uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */
uint8_t Ack_Required; /* BACnetEventTransitionBits */
BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */
} NOTIFICATION_CLASS_INFO;
typedef struct Notification_Class_info {
uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */
uint8_t Ack_Required; /* BACnetEventTransitionBits */
BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */
} NOTIFICATION_CLASS_INFO;
/* Indicates whether the transaction has been confirmed */
typedef struct Acked_info {
bool bIsAcked; /* true when transitions is acked */
BACNET_DATE_TIME Time_Stamp;/* time stamp of when a alarm was generated */
} ACKED_INFO;
typedef struct Acked_info {
bool bIsAcked; /* true when transitions is acked */
BACNET_DATE_TIME Time_Stamp; /* time stamp of when a alarm was generated */
} ACKED_INFO;
/* Information needed to send AckNotification */
typedef struct Ack_Notification {
bool bSendAckNotify; /* true if need to send AckNotification */
uint8_t EventState;
} ACK_NOTIFICATION;
typedef struct Ack_Notification {
bool bSendAckNotify; /* true if need to send AckNotification */
uint8_t EventState;
} ACK_NOTIFICATION;
@@ -102,43 +102,46 @@ typedef struct Ack_Notification {
const int **pOptional,
const int **pProprietary);
void Notification_Class_Init(void);
void Notification_Class_Init(
void);
bool Notification_Class_Valid_Instance(
uint32_t object_instance);
unsigned Notification_Class_Count(void);
uint32_t Notification_Class_Index_To_Instance(unsigned index);
uint32_t object_instance);
unsigned Notification_Class_Count(
void);
uint32_t Notification_Class_Index_To_Instance(
unsigned index);
unsigned Notification_Class_Instance_To_Index(
uint32_t object_instance);
uint32_t object_instance);
bool Notification_Class_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
uint32_t object_instance,
BACNET_CHARACTER_STRING * object_name);
int Notification_Class_Read_Property(
BACNET_READ_PROPERTY_DATA * rpdata);
BACNET_READ_PROPERTY_DATA * rpdata);
bool Notification_Class_Write_Property(
BACNET_WRITE_PROPERTY_DATA * wp_data);
BACNET_WRITE_PROPERTY_DATA * wp_data);
void Notification_Class_Get_Priorities(
uint32_t Object_Instance, uint32_t *pPriorityArray);
uint32_t Object_Instance,
uint32_t * pPriorityArray);
void Notification_Class_common_reporting_function(
BACNET_EVENT_NOTIFICATION_DATA * event_data);
BACNET_EVENT_NOTIFICATION_DATA * event_data);
void Notification_Class_find_recipient(void);
void Notification_Class_find_recipient(
void);
#endif /* defined(INTRINSIC_REPORTING) */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#define NOTIFICATION_CLASS_OBJ_FUNCTIONS \
OBJECT_NOTIFICATION_CLASS, Notification_Class_Init, Notification_Class_Count, \
Notification_Class_Index_To_Instance, Notification_Class_Valid_Instance, \
Notification_Class_Object_Name, Notification_Class_Read_Property, \
Notification_Class_Write_Property, Notification_Class_Property_Lists, \
NULL, NULL, NULL
#endif /* NC_H */
+8 -8
View File
@@ -259,7 +259,7 @@ void Trend_Log_Init(
*/
bool Trend_Log_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
bool status = false;
@@ -736,9 +736,9 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) {
iOffset += len;
len =
bacapp_decode_context_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
bacapp_decode_context_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || ((value.context_tag != 2) &&
(value.context_tag != 3))) {
/* Bad decode or wrong tag */
@@ -755,8 +755,8 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) {
iOffset += len;
len =
bacapp_decode_context_data(&wp_data->
application_data[iOffset],
bacapp_decode_context_data
(&wp_data->application_data[iOffset],
wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || (value.context_tag != 3)) {
@@ -1098,8 +1098,8 @@ int rr_trend_log_encode(
pRequest->ItemCount = 0; /* Start out with nothing */
/* Bail out now if nowt - should never happen for a Trend Log but ... */
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
ulRecordCount == 0)
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->
object_instance)].ulRecordCount == 0)
return (0);
if ((pRequest->RequestType == RR_BY_POSITION) ||
+1 -1
View File
@@ -141,7 +141,7 @@ extern "C" {
bool Trend_Log_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
int Trend_Log_Read_Property(
BACNET_READ_PROPERTY_DATA * rpdata);
+1 -1
View File
@@ -70,7 +70,7 @@ uint8_t Send_Private_Transfer_Request(
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -54,7 +54,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -57,7 +57,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -58,7 +58,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -84,7 +84,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -55,7 +55,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+2 -2
View File
@@ -123,7 +123,7 @@ static void Init_Service_Handlers(
handler_alarm_ack);
apdu_set_confirmed_handler(SERVICE_CONFIRMED_GET_EVENT_INFORMATION,
handler_get_event_information);
#endif /* defined(INTRINSIC_REPORTING) */
#endif /* defined(INTRINSIC_REPORTING) */
}
/** Handler registered with atexit() inside main function to, well, cleanup.
@@ -156,7 +156,7 @@ int main(
0
}; /* address where message came from */
uint16_t pdu_len = 0;
unsigned timeout = 100; /* milliseconds */
unsigned timeout = 100; /* milliseconds */
time_t last_seconds = 0;
time_t current_seconds = 0;
uint32_t elapsed_seconds = 0;
+1 -1
View File
@@ -50,7 +50,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -54,7 +54,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
static void Init_Service_Handlers(
+1 -1
View File
@@ -54,7 +54,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -54,7 +54,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -54,7 +54,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -60,7 +60,7 @@
static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL}
NULL, NULL, NULL, NULL, NULL, NULL}
};
/* buffer used for receive */
+1 -1
View File
@@ -964,7 +964,7 @@ typedef enum {
} BACNET_VT_CLASS;
typedef enum {
CHARACTER_ANSI_X34 = 0, /* deprecated */
CHARACTER_ANSI_X34 = 0, /* deprecated */
CHARACTER_UTF8 = 0,
CHARACTER_MS_DBCS = 1,
CHARACTER_JISC_6226 = 2,
+1 -1
View File
@@ -97,7 +97,7 @@ extern "C" {
uint32_t device_id,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name);
BACNET_CHARACTER_STRING * object_name);
int Send_UCOV_Notify(
uint8_t * buffer,
+1 -1
View File
@@ -143,7 +143,7 @@ extern "C" {
* chosen at runtime from among these choices.
* - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN
* are not currently supported by this project.
*//** @defgroup DLTemplates DataLink Template Functions
*//** @defgroup DLTemplates DataLink Template Functions
* @ingroup DataLink
* Most of the functions in this group are function templates which are assigned
* to a specific DataLink network layer implementation either at compile time or
+2 -2
View File
@@ -104,7 +104,7 @@ extern "C" {
*
* The network management BIBBs prescribe the BACnet capabilities required to
* interoperably perform network management functions.
*//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC)
*//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC)
* @ingroup RDMS
* 16.1 DeviceCommunicationControl Service <br>
* The DeviceCommunicationControl service is used by a client BACnet-user to
@@ -117,7 +117,7 @@ extern "C" {
* "indefinite," meaning communication must be re-enabled by a
* DeviceCommunicationControl or, if supported, ReinitializeDevice service,
* not by time.
*//** @defgroup NMRC Network Management-Router Configuration (NM-RC)
*//** @defgroup NMRC Network Management-Router Configuration (NM-RC)
* @ingroup RDMS
* The A device may query and change the configuration of routers and
* half-routers.
+2 -2
View File
@@ -213,7 +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
@@ -230,7 +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
+1 -1
View File
@@ -172,7 +172,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the trending functions enumerated in clause 22.2.1.4 for the
* BACnet devices defined therein.
*//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT)
*//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT)
* @ingroup Trend
* 15.8 ReadRange Service <br>
* The ReadRange service is used by a client BACnet-user to read a specific
+1 -1
View File
@@ -135,7 +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
+1 -1
View File
@@ -41,7 +41,7 @@
typedef struct BACnet_Who_Has_Data {
int32_t low_limit; /* deviceInstanceRange */
int32_t high_limit;
bool is_object_name; /* true if a string */
bool is_object_name; /* true if a string */
union {
BACNET_OBJECT_ID identifier;
BACNET_CHARACTER_STRING name;
+16 -9
View File
@@ -38,19 +38,26 @@ extern "C" {
/* decode the service request only */
int wpm_decode_object_id(uint8_t * apdu, uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * data);
int wpm_decode_object_property(uint8_t * apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * wpm_data);
int wpm_decode_object_id(
uint8_t * apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * data);
int wpm_decode_object_property(
uint8_t * apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * wpm_data);
/* encode service */
int wpm_ack_encode_apdu_init(uint8_t *apdu, uint8_t invoke_id);
int wpm_ack_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id);
int wpm_error_ack_encode_apdu(uint8_t * apdu, uint8_t invoke_id,
BACNET_WRITE_PROPERTY_DATA * wp_data);
int wpm_error_ack_encode_apdu(
uint8_t * apdu,
uint8_t invoke_id,
BACNET_WRITE_PROPERTY_DATA * wp_data);
#ifdef __cplusplus
+1 -1
View File
@@ -109,7 +109,7 @@ uint32_t Analog_Input_Index_To_Instance(
bool Analog_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[16] = "AI-0"; /* okay for single thread */
bool status = false;
+3 -3
View File
@@ -167,7 +167,7 @@ float Analog_Value_Present_Value(
bool Analog_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[16] = "AV-0"; /* okay for single thread */
bool status = false;
@@ -360,8 +360,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index(wp_data->
object_instance);
Analog_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+1 -1
View File
@@ -146,7 +146,7 @@ BACNET_BINARY_PV Binary_Input_Present_Value(
bool Binary_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[16] = "BI-0"; /* okay for single thread */
bool status = false;
+3 -3
View File
@@ -141,7 +141,7 @@ static BACNET_BINARY_PV Binary_Value_Present_Value(
/* note: the object name must be unique within this device */
bool Binary_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[16] = "BV-0"; /* okay for single thread */
bool status = false;
@@ -271,8 +271,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+39 -42
View File
@@ -179,8 +179,7 @@ static int Read_Property_Common(
break;
case PROP_OBJECT_NAME:
if (pObject->Object_Name) {
(void)pObject->Object_Name(
rpdata->object_instance,
(void) pObject->Object_Name(rpdata->object_instance,
&char_string);
} else {
characterstring_init_ansi(&char_string, "");
@@ -213,13 +212,13 @@ int Device_Read_Property(
/* initialize the default return values */
pObject = Device_Objects_Find_Functions(rpdata->object_type);
if (pObject) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(rpdata->object_instance)) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(rpdata->object_instance)) {
apdu_len = Read_Property_Common(pObject, rpdata);
} else {
rpdata->error_class = ERROR_CLASS_OBJECT;
rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
}
} else {
rpdata->error_class = ERROR_CLASS_OBJECT;
rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
}
} else {
rpdata->error_class = ERROR_CLASS_OBJECT;
rpdata->error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE;
@@ -237,18 +236,18 @@ bool Device_Write_Property(
/* initialize the default return values */
pObject = Device_Objects_Find_Functions(wp_data->object_type);
if (pObject) {
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(wp_data->object_instance)) {
if (pObject->Object_Write_Property) {
status = pObject->Object_Write_Property(wp_data);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(wp_data->object_instance)) {
if (pObject->Object_Write_Property) {
status = pObject->Object_Write_Property(wp_data);
} else {
wp_data->error_class = ERROR_CLASS_OBJECT;
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
} else {
wp_data->error_class = ERROR_CLASS_OBJECT;
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
}
} else {
wp_data->error_class = ERROR_CLASS_OBJECT;
wp_data->error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE;
@@ -340,7 +339,7 @@ uint32_t Device_Index_To_Instance(
bool Device_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
bool status = false;
@@ -352,7 +351,7 @@ bool Device_Object_Name(
}
bool Device_Set_Object_Name(
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
bool status = false; /*return value */
@@ -394,13 +393,13 @@ BACNET_REINITIALIZED_STATE Device_Reinitialized_State(
}
void Device_Init(
object_functions_t * object_table)
object_functions_t * object_table)
{
struct my_object_functions *pObject = NULL;
/* we don't use the object table passed in
since there is extra stuff we don't need in there. */
(void)object_table;
(void) object_table;
/* our local object table */
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
@@ -440,7 +439,7 @@ bool Device_Valid_Object_Instance_Number(
/* BACnet allows for a wildcard instance number */
return ((Object_Instance_Number == object_id) ||
(object_id == BACNET_MAX_INSTANCE));
}
}
BACNET_DEVICE_STATUS Device_System_Status(
void)
@@ -461,25 +460,25 @@ int Device_Set_System_Status(
}
return result;
}
}
uint16_t Device_Vendor_Identifier(
void)
{
return BACNET_VENDOR_ID;
}
}
BACNET_SEGMENTATION Device_Segmentation_Supported(
void)
{
return SEGMENTATION_NONE;
}
}
uint32_t Device_Database_Revision(
void)
{
return Database_Revision;
}
}
void Device_Inc_Database_Revision(
void)
@@ -542,7 +541,7 @@ bool Device_Object_List_Identifier(
}
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING *object_name1,
BACNET_CHARACTER_STRING * object_name1,
int *object_type,
uint32_t * object_instance)
{
@@ -561,7 +560,7 @@ bool Device_Valid_Object_Name(
pObject = Device_Objects_Find_Functions(type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
characterstring_same(object_name1, &object_name2))) {
found = true;
if (object_type) {
*object_type = type;
@@ -581,7 +580,7 @@ bool Device_Valid_Object_Id(
int object_type,
uint32_t object_instance)
{
bool status = false; /* return value */
bool status = false; /* return value */
struct my_object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
@@ -595,7 +594,7 @@ bool Device_Valid_Object_Id(
bool Device_Object_Name_Copy(
int object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
struct my_object_functions *pObject = NULL;
bool found = false;
@@ -851,8 +850,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -895,22 +894,20 @@ bool Device_Write_Property_Local(
break;
case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
length = characterstring_length(
&value.type.Character_String);
length = characterstring_length(&value.type.Character_String);
if (length < characterstring_capacity(&My_Object_Name)) {
encoding = characterstring_encoding(
&value.type.Character_String);
encoding =
characterstring_encoding(&value.type.Character_String);
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
/* All the object names in a device must be unique. */
if (Device_Valid_Object_Name(
&value.type.Character_String,
NULL, NULL)) {
if (Device_Valid_Object_Name(&value.type.
Character_String, NULL, NULL)) {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else {
Device_Set_Object_Name(
&value.type.Character_String);
Device_Set_Object_Name(&value.type.
Character_String);
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+3 -3
View File
@@ -1177,9 +1177,9 @@ static void MSTP_Slave_Node_FSM(
} else if (MSTP_Flag.ReceivePacketPending) {
if (Ringbuf_Empty(&PDU_Queue)) {
/* If no reply will be available from the higher layers
within Treply_delay after the reception of the final octet
of the requesting frame (the mechanism used to determine
this is a local matter), then no reply is possible. */
within Treply_delay after the reception of the final octet
of the requesting frame (the mechanism used to determine
this is a local matter), then no reply is possible. */
MSTP_Flag.ReceivePacketPending = false;
} else {
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+2 -2
View File
@@ -380,8 +380,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+12 -11
View File
@@ -72,18 +72,18 @@ void adc_enable(
* Notes: none
**************************************************/
uint8_t adc_result_8bit(
uint8_t channel) /* 0..7 = ADC0..ADC7, respectively */
{
uint8_t value = 0; /* return value */
uint8_t channel)
{ /* 0..7 = ADC0..ADC7, respectively */
uint8_t value = 0; /* return value */
while ( ADCSRA & (1 << ADSC) ) ;
while (ADCSRA & (1 << ADSC));
ADMUX = channel | (1 << ADLAR) | (0 << REFS1) | (1 << REFS0);
/* Delay needed for the stabilization of the ADC input voltage */
_delay_us(10);
/* Start the analog to digital conversion */
ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADIF) | ADPS_8BIT;
/* Wait for the analog to digital conversion to complete */
while ( (ADCSRA & (1 << ADIF)) == 0 ) ;
while ((ADCSRA & (1 << ADIF)) == 0);
value = ADCH;
return value;
@@ -95,18 +95,18 @@ uint8_t adc_result_8bit(
* Notes: none
**************************************************/
uint16_t adc_result_10bit(
uint8_t channel) /* 0..7 = ADC0..ADC7, respectively */
{
uint8_t channel)
{ /* 0..7 = ADC0..ADC7, respectively */
uint16_t value = 0; /* return value */
while ( ADCSRA & (1 << ADSC) ) ;
while (ADCSRA & (1 << ADSC));
ADMUX = channel | (0 << ADLAR) | (0 << REFS1) | (1 << REFS0);
/* Delay needed for the stabilization of the ADC input voltage */
_delay_us(10);
/* Start the analog to digital conversion */
ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADIF) | ADPS_10BIT;
/* Wait for the analog to digital conversion to complete */
while ( (ADCSRA & (1 << ADIF)) == 0 ) ;
while ((ADCSRA & (1 << ADIF)) == 0);
value = ADCL;
value |= (ADCH << 8);
@@ -118,11 +118,12 @@ uint16_t adc_result_10bit(
* Returns: none
* Notes: none
**************************************************/
void adc_init(void)
void adc_init(
void)
{
/* configure ADC for Free Running Mode - ADTS = 000 */
/* AIN1 is applied to the negative input of the Analog Comparator - ACME */
BITMASK_CLEAR(ADCSRB, _BV(ACME)|_BV(ADTS2)|_BV(ADTS1)|_BV(ADTS0));
BITMASK_CLEAR(ADCSRB, _BV(ACME) | _BV(ADTS2) | _BV(ADTS1) | _BV(ADTS0));
/* Digital input not needed on ADC0, so disable it to save power */
BIT_SET(DIDR0, ADC0D);
/* Clear the Power Reduction bit to enable ADC */
+1 -1
View File
@@ -111,7 +111,7 @@ uint32_t Analog_Input_Index_To_Instance(
bool Analog_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32]; /* okay for single thread */
bool status = false;
+1 -1
View File
@@ -177,7 +177,7 @@ bool Analog_Value_Present_Value_Set(
/* note: the object name must be unique within this device */
bool Analog_Value_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32] = ""; /* okay for single thread */
unsigned index = 0;
+1 -1
View File
@@ -159,7 +159,7 @@ bool Binary_Input_Present_Value_Set(
bool Binary_Input_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32]; /* okay for single thread */
bool status = false;
+62 -53
View File
@@ -39,26 +39,36 @@
by Jeff Bezanson
placed in the public domain Fall 2005 */
static const char trailingBytesForUTF8[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4,
4, 4, 4, 5, 5, 5, 5
};
/* based on the valid_utf8 routine from the PCRE library by Philip Hazel
length is in bytes, since without knowing whether the string is valid
it's hard to know how many characters there are! */
static int utf8_isvalid(const char *str, int length)
static int utf8_isvalid(
const char *str,
int length)
{
const unsigned char *p, *pend = (unsigned char*)str + length;
const unsigned char *p, *pend = (unsigned char *) str + length;
unsigned char c;
int ab;
for (p = (unsigned char*)str; p < pend; p++) {
for (p = (unsigned char *) str; p < pend; p++) {
c = *p;
/* null in middle of string */
if (c == 0) {
@@ -84,37 +94,42 @@ static int utf8_isvalid(const char *str, int length)
}
/* Check for overlong sequences for each different length */
switch (ab) {
/* Check for xx00 000x */
case 1:
if ((c & 0x3e) == 0) return 0;
continue; /* We know there aren't any more bytes to check */
/* Check for xx00 000x */
case 1:
if ((c & 0x3e) == 0)
return 0;
continue; /* We know there aren't any more bytes to check */
/* Check for 1110 0000, xx0x xxxx */
case 2:
if (c == 0xe0 && (*p & 0x20) == 0) return 0;
break;
/* Check for 1110 0000, xx0x xxxx */
case 2:
if (c == 0xe0 && (*p & 0x20) == 0)
return 0;
break;
/* Check for 1111 0000, xx00 xxxx */
case 3:
if (c == 0xf0 && (*p & 0x30) == 0) return 0;
break;
/* Check for 1111 0000, xx00 xxxx */
case 3:
if (c == 0xf0 && (*p & 0x30) == 0)
return 0;
break;
/* Check for 1111 1000, xx00 0xxx */
case 4:
if (c == 0xf8 && (*p & 0x38) == 0) return 0;
break;
/* Check for 1111 1000, xx00 0xxx */
case 4:
if (c == 0xf8 && (*p & 0x38) == 0)
return 0;
break;
/* Check for leading 0xfe or 0xff,
and then for 1111 1100, xx00 00xx */
case 5:
if (c == 0xfe || c == 0xff ||
(c == 0xfc && (*p & 0x3c) == 0)) return 0;
break;
/* Check for leading 0xfe or 0xff,
and then for 1111 1100, xx00 00xx */
case 5:
if (c == 0xfe || c == 0xff || (c == 0xfc && (*p & 0x3c) == 0))
return 0;
break;
}
/* Check for valid bytes after the 2nd, if any; all must start 10 */
while (--ab > 0) {
if ((*(++p) & 0xc0) != 0x80) return 0;
if ((*(++p) & 0xc0) != 0x80)
return 0;
}
}
@@ -144,7 +159,7 @@ static bool bacnet_name_isvalid(
bool bacnet_name_set(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string)
BACNET_CHARACTER_STRING * char_string)
{
uint8_t encoding = 0;
uint8_t length = 0;
@@ -154,15 +169,9 @@ bool bacnet_name_set(
encoding = characterstring_encoding(char_string);
str = characterstring_value(char_string);
if (bacnet_name_isvalid(encoding, length, str)) {
seeprom_bytes_write(
NV_EEPROM_NAME_LENGTH(offset),
&length, 1);
seeprom_bytes_write(
NV_EEPROM_NAME_ENCODING(offset),
&encoding, 1);
seeprom_bytes_write(
NV_EEPROM_NAME_STRING(offset),
(uint8_t *)str,
seeprom_bytes_write(NV_EEPROM_NAME_LENGTH(offset), &length, 1);
seeprom_bytes_write(NV_EEPROM_NAME_ENCODING(offset), &encoding, 1);
seeprom_bytes_write(NV_EEPROM_NAME_STRING(offset), (uint8_t *) str,
length);
return true;
}
@@ -172,9 +181,9 @@ bool bacnet_name_set(
bool bacnet_name_write(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code)
{
bool status = false;
size_t length = 0;
@@ -215,9 +224,9 @@ bool bacnet_name_write(
/* no required minumum length or duplicate checking */
bool bacnet_name_write_other(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code)
{
bool status = false;
size_t length = 0;
@@ -247,16 +256,16 @@ bool bacnet_name_write_other(
void bacnet_name_init(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_CHARACTER_STRING * char_string,
char *default_string)
{
characterstring_init_ansi(char_string, default_string);
(void)bacnet_name_set(offset, char_string);
(void) bacnet_name_set(offset, char_string);
}
void bacnet_name(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_CHARACTER_STRING * char_string,
char *default_string)
{
uint8_t encoding = 0;
+9 -9
View File
@@ -33,26 +33,26 @@ extern "C" {
bool bacnet_name_set(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING *char_string);
BACNET_CHARACTER_STRING * char_string);
void bacnet_name_init(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_CHARACTER_STRING * char_string,
char *default_string);
void bacnet_name(
uint16_t eeprom_offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_CHARACTER_STRING * char_string,
char *default_string);
bool bacnet_name_write(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code);
BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
/* no required minumum length or duplicate checking */
bool bacnet_name_write_other(
uint16_t offset,
BACNET_CHARACTER_STRING *char_string,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code);
BACNET_CHARACTER_STRING * char_string,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code);
#ifdef __cplusplus
}
+3 -3
View File
@@ -231,7 +231,7 @@ bool Binary_Output_Out_Of_Service(
/* note: the object name must be unique within this device */
bool Binary_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[32]; /* okay for single thread */
bool status = false;
@@ -439,8 +439,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
Binary_Output_Present_Value_Set(wp_data->
object_instance, level, priority);
Binary_Output_Present_Value_Set
(wp_data->object_instance, level, priority);
} else if (priority == 6) {
status = false;
/* Command priority 6 is reserved for use by Minimum On/Off
+26 -35
View File
@@ -195,12 +195,12 @@ static int Read_Property_Common(
} else {
characterstring_init_ansi(&char_string, "");
if (pObject->Object_Name) {
(void)pObject->Object_Name(
rpdata->object_instance,
(void) pObject->Object_Name(rpdata->object_instance,
&char_string);
}
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
encode_application_character_string(&apdu[0],
&char_string);
}
break;
case PROP_OBJECT_TYPE:
@@ -361,7 +361,8 @@ uint32_t Device_Index_To_Instance(
return Object_Instance_Number;
}
static char *Device_Name_Default(void)
static char *Device_Name_Default(
void)
{
static char text_string[32]; /* okay for single thread */
@@ -372,15 +373,12 @@ static char *Device_Name_Default(void)
bool Device_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
bool status = false;
if (object_instance == Object_Instance_Number) {
bacnet_name(
NV_EEPROM_DEVICE_NAME,
object_name,
Device_Name_Default());
bacnet_name(NV_EEPROM_DEVICE_NAME, object_name, Device_Name_Default());
status = true;
}
@@ -416,13 +414,13 @@ BACNET_REINITIALIZED_STATE Device_Reinitialized_State(
}
void Device_Init(
object_functions_t * object_table)
object_functions_t * object_table)
{
struct my_object_functions *pObject = NULL;
/* we don't use the object table passed in
since there is extra stuff we don't need in there. */
(void)object_table;
(void) object_table;
/* our local object table */
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
@@ -574,7 +572,7 @@ bool Device_Object_List_Identifier(
}
bool Device_Valid_Object_Name(
BACNET_CHARACTER_STRING *object_name1,
BACNET_CHARACTER_STRING * object_name1,
int *object_type,
uint32_t * object_instance)
{
@@ -593,7 +591,7 @@ bool Device_Valid_Object_Name(
pObject = Device_Objects_Find_Functions(type);
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
(pObject->Object_Name(instance, &object_name2) &&
characterstring_same(object_name1, &object_name2))) {
characterstring_same(object_name1, &object_name2))) {
found = true;
if (object_type) {
*object_type = type;
@@ -613,7 +611,7 @@ bool Device_Valid_Object_Id(
int object_type,
uint32_t object_instance)
{
bool status = false; /* return value */
bool status = false; /* return value */
struct my_object_functions *pObject = NULL;
pObject = Device_Objects_Find_Functions(object_type);
@@ -627,7 +625,7 @@ bool Device_Valid_Object_Id(
bool Device_Object_Name_Copy(
int object_type,
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
struct my_object_functions *pObject = NULL;
bool found = false;
@@ -673,17 +671,13 @@ int Device_Read_Property_Local(
apdu = rpdata->application_data;
switch (rpdata->object_property) {
case PROP_DESCRIPTION:
bacnet_name(
NV_EEPROM_DEVICE_DESCRIPTION,
&char_string,
bacnet_name(NV_EEPROM_DEVICE_DESCRIPTION, &char_string,
"BACnet Development Kit");
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
break;
case PROP_LOCATION:
bacnet_name(
NV_EEPROM_DEVICE_LOCATION,
&char_string,
bacnet_name(NV_EEPROM_DEVICE_LOCATION, &char_string,
"default location");
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
@@ -881,8 +875,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 {
@@ -925,10 +919,9 @@ bool Device_Write_Property_Local(
break;
case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = bacnet_name_write(
NV_EEPROM_DEVICE_NAME,
&value.type.Character_String,
&wp_data->error_class,
status =
bacnet_name_write(NV_EEPROM_DEVICE_NAME,
&value.type.Character_String, &wp_data->error_class,
&wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -937,10 +930,9 @@ bool Device_Write_Property_Local(
break;
case PROP_DESCRIPTION:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = bacnet_name_write_other(
NV_EEPROM_DEVICE_DESCRIPTION,
&value.type.Character_String,
&wp_data->error_class,
status =
bacnet_name_write_other(NV_EEPROM_DEVICE_DESCRIPTION,
&value.type.Character_String, &wp_data->error_class,
&wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -949,10 +941,9 @@ bool Device_Write_Property_Local(
break;
case PROP_LOCATION:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = bacnet_name_write_other(
NV_EEPROM_DEVICE_LOCATION,
&value.type.Character_String,
&wp_data->error_class,
status =
bacnet_name_write_other(NV_EEPROM_DEVICE_LOCATION,
&value.type.Character_String, &wp_data->error_class,
&wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+50 -33
View File
@@ -91,7 +91,8 @@ static uint8_t Tusage_timeout = 60;
static struct timeval start;
static uint32_t Timer_Silence(void)
static uint32_t Timer_Silence(
void)
{
struct timeval now, tmp_diff;
int32_t res;
@@ -105,14 +106,16 @@ static uint32_t Timer_Silence(void)
return (res >= 0 ? res : -res);
}
static void Timer_Silence_Reset(void)
static void Timer_Silence_Reset(
void)
{
pthread_mutex_lock(&Timer_Mutex);
gettimeofday(&start, NULL);
pthread_mutex_unlock(&Timer_Mutex);
}
static void get_abstime(struct timespec *abstime,
static void get_abstime(
struct timespec *abstime,
unsigned long milliseconds)
{
struct timeval now, offset, result;
@@ -125,7 +128,8 @@ static void get_abstime(struct timespec *abstime,
abstime->tv_nsec = result.tv_usec * 1000;
}
void dlmstp_cleanup(void)
void dlmstp_cleanup(
void)
{
pthread_cond_destroy(&Received_Frame_Flag);
pthread_cond_destroy(&Receive_Packet_Flag);
@@ -137,12 +141,10 @@ void dlmstp_cleanup(void)
}
/* returns number of bytes sent on success, zero on failure */
int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
int dlmstp_send_pdu(
BACNET_ADDRESS * dest, /* destination address */
BACNET_NPDU_DATA * npdu_data, /* network information */
uint8_t * pdu, /* any data to be sent - may be null */
unsigned pdu_len)
{ /* number of bytes of data */
int bytes_sent = 0;
@@ -168,12 +170,10 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
return bytes_sent;
}
uint16_t dlmstp_receive(BACNET_ADDRESS * src, /* source address */
uint16_t dlmstp_receive(
BACNET_ADDRESS * src, /* source address */
uint8_t * pdu, /* PDU data */
uint16_t max_pdu, /* amount of space available in the PDU */
unsigned timeout)
{ /* milliseconds to wait for a packet */
uint16_t pdu_len = 0;
@@ -207,7 +207,8 @@ uint16_t dlmstp_receive(BACNET_ADDRESS * src, /* source address */
return pdu_len;
}
static void *dlmstp_master_fsm_task(void *pArg)
static void *dlmstp_master_fsm_task(
void *pArg)
{
uint32_t silence = 0;
bool run_master = false;
@@ -252,7 +253,8 @@ static void *dlmstp_master_fsm_task(void *pArg)
return NULL;
}
void dlmstp_fill_bacnet_address(BACNET_ADDRESS * src,
void dlmstp_fill_bacnet_address(
BACNET_ADDRESS * src,
uint8_t mstp_address)
{
int i = 0;
@@ -277,7 +279,8 @@ void dlmstp_fill_bacnet_address(BACNET_ADDRESS * src,
}
/* for the MS/TP state machine to use for putting received data */
uint16_t MSTP_Put_Receive(volatile struct mstp_port_struct_t *mstp_port)
uint16_t MSTP_Put_Receive(
volatile struct mstp_port_struct_t *mstp_port)
{
uint16_t pdu_len = 0;
@@ -300,7 +303,8 @@ uint16_t MSTP_Put_Receive(volatile struct mstp_port_struct_t *mstp_port)
/* for the MS/TP state machine to use for getting data to send */
/* Return: amount of PDU data */
uint16_t MSTP_Get_Send(volatile struct mstp_port_struct_t * mstp_port,
uint16_t MSTP_Get_Send(
volatile struct mstp_port_struct_t * mstp_port,
unsigned timeout)
{ /* milliseconds to wait for a packet */
uint16_t pdu_len = 0;
@@ -329,7 +333,8 @@ uint16_t MSTP_Get_Send(volatile struct mstp_port_struct_t * mstp_port,
return pdu_len;
}
static bool dlmstp_compare_data_expecting_reply(uint8_t * request_pdu,
static bool dlmstp_compare_data_expecting_reply(
uint8_t * request_pdu,
uint16_t request_pdu_len,
uint8_t src_address,
uint8_t * reply_pdu,
@@ -445,7 +450,8 @@ static bool dlmstp_compare_data_expecting_reply(uint8_t * request_pdu,
}
/* Get the reply to a DATA_EXPECTING_REPLY frame, or nothing */
uint16_t MSTP_Get_Reply(volatile struct mstp_port_struct_t * mstp_port,
uint16_t MSTP_Get_Reply(
volatile struct mstp_port_struct_t * mstp_port,
unsigned timeout)
{ /* milliseconds to wait for a packet */
uint16_t pdu_len = 0; /* return value */
@@ -484,7 +490,8 @@ uint16_t MSTP_Get_Reply(volatile struct mstp_port_struct_t * mstp_port,
return pdu_len;
}
void dlmstp_set_mac_address(uint8_t mac_address)
void dlmstp_set_mac_address(
uint8_t mac_address)
{
/* Master Nodes can only have address 0-127 */
if (mac_address <= 127) {
@@ -501,7 +508,8 @@ void dlmstp_set_mac_address(uint8_t mac_address)
return;
}
uint8_t dlmstp_mac_address(void)
uint8_t dlmstp_mac_address(
void)
{
return MSTP_Port.This_Station;
}
@@ -513,7 +521,8 @@ uint8_t dlmstp_mac_address(void)
/* nodes. This may be used to allocate more or less of the available link */
/* bandwidth to particular nodes. If Max_Info_Frames is not writable in a */
/* node, its value shall be 1. */
void dlmstp_set_max_info_frames(uint8_t max_info_frames)
void dlmstp_set_max_info_frames(
uint8_t max_info_frames)
{
if (max_info_frames >= 1) {
MSTP_Port.Nmax_info_frames = max_info_frames;
@@ -527,7 +536,8 @@ void dlmstp_set_max_info_frames(uint8_t max_info_frames)
return;
}
uint8_t dlmstp_max_info_frames(void)
uint8_t dlmstp_max_info_frames(
void)
{
return MSTP_Port.Nmax_info_frames;
}
@@ -537,7 +547,8 @@ uint8_t dlmstp_max_info_frames(void)
/* allowable address for master nodes. The value of Max_Master shall be */
/* less than or equal to 127. If Max_Master is not writable in a node, */
/* its value shall be 127. */
void dlmstp_set_max_master(uint8_t max_master)
void dlmstp_set_max_master(
uint8_t max_master)
{
if (max_master <= 127) {
if (MSTP_Port.This_Station <= max_master) {
@@ -553,23 +564,27 @@ void dlmstp_set_max_master(uint8_t max_master)
return;
}
uint8_t dlmstp_max_master(void)
uint8_t dlmstp_max_master(
void)
{
return MSTP_Port.Nmax_master;
}
/* RS485 Baud Rate 9600, 19200, 38400, 57600, 115200 */
void dlmstp_set_baud_rate(uint32_t baud)
void dlmstp_set_baud_rate(
uint32_t baud)
{
RS485_Set_Baud_Rate(baud);
}
uint32_t dlmstp_baud_rate(void)
uint32_t dlmstp_baud_rate(
void)
{
return RS485_Get_Baud_Rate();
}
void dlmstp_get_my_address(BACNET_ADDRESS * my_address)
void dlmstp_get_my_address(
BACNET_ADDRESS * my_address)
{
int i = 0; /* counter */
@@ -584,7 +599,8 @@ void dlmstp_get_my_address(BACNET_ADDRESS * my_address)
return;
}
void dlmstp_get_broadcast_address(BACNET_ADDRESS * dest)
void dlmstp_get_broadcast_address(
BACNET_ADDRESS * dest)
{ /* destination address */
int i = 0; /* counter */
@@ -601,7 +617,8 @@ void dlmstp_get_broadcast_address(BACNET_ADDRESS * dest)
return;
}
bool dlmstp_init(char *ifname)
bool dlmstp_init(
char *ifname)
{
unsigned long hThread = 0;
int rv = 0;
@@ -665,10 +682,9 @@ bool dlmstp_init(char *ifname)
#ifdef TEST_DLMSTP
#include <stdio.h>
void apdu_handler(BACNET_ADDRESS * src, /* source address */
void apdu_handler(
BACNET_ADDRESS * src, /* source address */
uint8_t * apdu, /* APDU data */
uint16_t pdu_len)
{ /* for confirmed messages */
(void) src;
@@ -678,7 +694,8 @@ void apdu_handler(BACNET_ADDRESS * src, /* source address */
static char *Network_Interface = NULL;
int main(int argc,
int main(
int argc,
char *argv[])
{
uint16_t pdu_len = 0;
+20 -12
View File
@@ -95,7 +95,8 @@ static pthread_mutex_t Reader_Mutex, IOMutex;
#define _POSIX_SOURCE 1 /* POSIX compliant source */
static void *rs485_read_task(void *arg)
static void *rs485_read_task(
void *arg)
{
uint8_t buf[1 << 11];
int count, n;
@@ -134,7 +135,8 @@ static void *rs485_read_task(void *arg)
* ALGORITHM: none
* NOTES: none
*********************************************************************/
void RS485_Set_Interface(char *ifname)
void RS485_Set_Interface(
char *ifname)
{
/* note: expects a constant char, or char from the heap */
if (ifname) {
@@ -148,7 +150,8 @@ void RS485_Set_Interface(char *ifname)
* ALGORITHM: none
* NOTES: none
*********************************************************************/
const char *RS485_Interface(void)
const char *RS485_Interface(
void)
{
return RS485_Port_Name;
}
@@ -159,7 +162,8 @@ const char *RS485_Interface(void)
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
uint32_t RS485_Get_Baud_Rate(void)
uint32_t RS485_Get_Baud_Rate(
void)
{
switch (RS485_Baud) {
case B19200:
@@ -182,7 +186,8 @@ uint32_t RS485_Get_Baud_Rate(void)
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
bool RS485_Set_Baud_Rate(uint32_t baud)
bool RS485_Set_Baud_Rate(
uint32_t baud)
{
bool valid = true;
@@ -215,10 +220,9 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
}
/* Transmits a Frame on the wire */
void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
void RS485_Send_Frame(
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
ssize_t written = 0;
@@ -246,7 +250,8 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port
}
/* called by timer, interrupt(?) or other thread */
void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
void RS485_Check_UART_Data(
volatile struct mstp_port_struct_t *mstp_port)
{
if (mstp_port->ReceiveError == true) {
/* wait for state machine to clear this */
@@ -266,7 +271,8 @@ void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
}
}
void RS485_Cleanup(void)
void RS485_Cleanup(
void)
{
/* restore the old port settings */
tcsetattr(RS485_Handle, TCSANOW, &RS485_oldtio);
@@ -276,7 +282,8 @@ void RS485_Cleanup(void)
}
void RS485_Initialize(void)
void RS485_Initialize(
void)
{
struct termios newtio;
unsigned long hThread = 0;
@@ -333,7 +340,8 @@ void RS485_Initialize(void)
#ifdef TEST_RS485
#include <string.h>
int main(int argc,
int main(
int argc,
char *argv[])
{
uint8_t buf[8];
+2 -2
View File
@@ -325,8 +325,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index(wp_data->
object_instance);
Analog_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -237,8 +237,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+2 -2
View File
@@ -510,8 +510,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -1
View File
@@ -261,7 +261,8 @@ bool bip_init(
bip_set_port(htons((0xBAC0));
/* assumes that the driver has already been initialized */
sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP);
bip_set_socket(sock_fd); if (sock_fd < 0)
bip_set_socket(sock_fd);
if (sock_fd < 0)
return false;
/* bind the socket to the local port number and IP address */
sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY);
+2 -2
View File
@@ -429,8 +429,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
+9 -9
View File
@@ -35,7 +35,7 @@
#include "apdu.h"
#include "wp.h" /* WriteProperty handling */
#include "rp.h" /* ReadProperty handling */
#include "dcc.h" /* DeviceCommunicationControl handling */
#include "dcc.h" /* DeviceCommunicationControl handling */
#include "version.h"
#include "device.h" /* me */
#include "handlers.h"
@@ -833,8 +833,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -868,8 +868,8 @@ 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;
@@ -878,8 +878,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Location(characterstring_value(&value.type.
Character_String),
Device_Set_Location(characterstring_value(&value.
type.Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -889,8 +889,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Description(characterstring_value(&value.type.
Character_String),
Device_Set_Description(characterstring_value(&value.
type.Character_String),
characterstring_length(&value.type.Character_String));
}
break;
+2 -2
View File
@@ -44,7 +44,7 @@ static uint8_t Ethernet_Broadcast[MAX_MAC_LEN] =
/* The OUI 00-00-5E has been allocated to IANA. */
/* my local device data - MAC address */
static uint8_t Ethernet_MAC_Address[MAX_MAC_LEN] =
{0x00, 0x00, 0x5E, 0x00, 0x00, 0x01};
{ 0x00, 0x00, 0x5E, 0x00, 0x00, 0x01 };
/* status of the link */
static int32_t Ethernet_Status = R_ETHER_ERROR;
@@ -167,7 +167,7 @@ uint16_t ethernet_receive(
if (!ethernet_valid())
return 0;
received_bytes = R_Ether_Read(0, (void *)buf);
received_bytes = R_Ether_Read(0, (void *) buf);
if (received_bytes == 0)
return 0;
+25 -25
View File
@@ -42,40 +42,40 @@ void led_on(
{
switch (index) {
case 4:
R_IO_PORT_Write( LED4, LED_ON );
R_IO_PORT_Write(LED4, LED_ON);
break;
case 5:
R_IO_PORT_Write( LED5, LED_ON );
R_IO_PORT_Write(LED5, LED_ON);
break;
case 6:
R_IO_PORT_Write( LED6, LED_ON );
R_IO_PORT_Write(LED6, LED_ON);
break;
case 7:
R_IO_PORT_Write( LED7, LED_ON );
R_IO_PORT_Write(LED7, LED_ON);
break;
case 8:
R_IO_PORT_Write( LED8, LED_ON );
R_IO_PORT_Write(LED8, LED_ON);
break;
case 9:
R_IO_PORT_Write( LED9, LED_ON );
R_IO_PORT_Write(LED9, LED_ON);
break;
case 10:
R_IO_PORT_Write( LED10, LED_ON );
R_IO_PORT_Write(LED10, LED_ON);
break;
case 11:
R_IO_PORT_Write( LED11, LED_ON );
R_IO_PORT_Write(LED11, LED_ON);
break;
case 12:
R_IO_PORT_Write( LED12, LED_ON );
R_IO_PORT_Write(LED12, LED_ON);
break;
case 13:
R_IO_PORT_Write( LED13, LED_ON );
R_IO_PORT_Write(LED13, LED_ON);
break;
case 14:
R_IO_PORT_Write( LED14, LED_ON );
R_IO_PORT_Write(LED14, LED_ON);
break;
case 15:
R_IO_PORT_Write( LED15, LED_ON );
R_IO_PORT_Write(LED15, LED_ON);
break;
default:
break;
@@ -96,40 +96,40 @@ void led_off(
{
switch (index) {
case 4:
R_IO_PORT_Write( LED4, LED_OFF );
R_IO_PORT_Write(LED4, LED_OFF);
break;
case 5:
R_IO_PORT_Write( LED5, LED_OFF );
R_IO_PORT_Write(LED5, LED_OFF);
break;
case 6:
R_IO_PORT_Write( LED6, LED_OFF );
R_IO_PORT_Write(LED6, LED_OFF);
break;
case 7:
R_IO_PORT_Write( LED7, LED_OFF );
R_IO_PORT_Write(LED7, LED_OFF);
break;
case 8:
R_IO_PORT_Write( LED8, LED_OFF );
R_IO_PORT_Write(LED8, LED_OFF);
break;
case 9:
R_IO_PORT_Write( LED9, LED_OFF );
R_IO_PORT_Write(LED9, LED_OFF);
break;
case 10:
R_IO_PORT_Write( LED10, LED_OFF );
R_IO_PORT_Write(LED10, LED_OFF);
break;
case 11:
R_IO_PORT_Write( LED11, LED_OFF );
R_IO_PORT_Write(LED11, LED_OFF);
break;
case 12:
R_IO_PORT_Write( LED12, LED_OFF );
R_IO_PORT_Write(LED12, LED_OFF);
break;
case 13:
R_IO_PORT_Write( LED13, LED_OFF );
R_IO_PORT_Write(LED13, LED_OFF);
break;
case 14:
R_IO_PORT_Write( LED14, LED_OFF );
R_IO_PORT_Write(LED14, LED_OFF);
break;
case 15:
R_IO_PORT_Write( LED15, LED_OFF );
R_IO_PORT_Write(LED15, LED_OFF);
break;
default:
break;
@@ -228,7 +228,7 @@ void led_init(
void)
{
unsigned i = 0;
for (i = 0; i < MAX_LEDS; i++) {
led_on_interval(i, 500);
}
+2 -1
View File
@@ -30,7 +30,8 @@
#include "led.h"
/** Main function of BACnet demo for RX62N evaluation board */
int main(void)
int main(
void)
{
InitialiseLCD();
ClearLCD();
+7 -11
View File
@@ -30,7 +30,8 @@
static volatile uint32_t Millisecond_Counter;
static volatile uint8_t Millisecond_Counter_Byte;
/* forward prototype for interrupt service routine */
void int_cmt0_isr(void);
void int_cmt0_isr(
void);
/*************************************************************************
* Description: Timer Interrupt Handler
@@ -49,7 +50,8 @@ static void timer_interrupt_handler(
* Returns: nothing
* Notes: none
*************************************************************************/
void int_cmt0_isr(void)
void int_cmt0_isr(
void)
{
timer_interrupt_handler();
}
@@ -92,15 +94,9 @@ void timer_init(
bool err = true;
/* CMT is configured for a 1ms interval, and executes the callback
function CB_CompareMatch on every compare match */
err &= R_CMT_Create(
3,
PDL_CMT_PERIOD,
1E-3,
int_cmt0_isr,
3
);
function CB_CompareMatch on every compare match */
err &= R_CMT_Create(3, PDL_CMT_PERIOD, 1E-3, int_cmt0_isr, 3);
/* Halt in while loop when RPDL errors detected */
while(!err);
while (!err);
}
+54 -42
View File
@@ -65,7 +65,8 @@ static bool Auto_Mode_Enabled;
* RETURN: true if automode enabled
* NOTES: none
*****************************************************************************/
bool automac_enabled(void)
bool automac_enabled(
void)
{
return Auto_Mode_Enabled;
}
@@ -75,7 +76,8 @@ bool automac_enabled(void)
* RETURN: nothing
* NOTES: none
*****************************************************************************/
void automac_enabled_set(bool status)
void automac_enabled_set(
bool status)
{
Auto_Mode_Enabled = status;
}
@@ -85,7 +87,8 @@ void automac_enabled_set(bool status)
* RETURN: true if full
* NOTES: none
*****************************************************************************/
bool automac_pfm_cycle_complete(void)
bool automac_pfm_cycle_complete(
void)
{
return PFM_Cycle_Complete;
}
@@ -95,13 +98,13 @@ bool automac_pfm_cycle_complete(void)
* RETURN: true if used
* NOTES: none
*****************************************************************************/
static bool automac_address_used(uint8_t mac)
static bool automac_address_used(
uint8_t mac)
{
bool status = false;
if (mac < MAC_SLOTS_MAX) {
if ((Auto_MAC_Data[mac].emitter) ||
(Auto_MAC_Data[mac].reserved) ||
if ((Auto_MAC_Data[mac].emitter) || (Auto_MAC_Data[mac].reserved) ||
(Auto_MAC_Data[mac].token)) {
status = true;
}
@@ -115,13 +118,13 @@ static bool automac_address_used(uint8_t mac)
* RETURN: true if valid
* NOTES: none
*****************************************************************************/
bool automac_free_address_valid(uint8_t mac)
bool automac_free_address_valid(
uint8_t mac)
{
bool status = false;
if (mac < MAC_SLOTS_MAX) {
if ((Auto_MAC_Data[mac].pfm) &&
(!automac_address_used(mac))) {
if ((Auto_MAC_Data[mac].pfm) && (!automac_address_used(mac))) {
status = true;
}
}
@@ -134,11 +137,12 @@ bool automac_free_address_valid(uint8_t mac)
* RETURN: Next_Station, or 255 if there are no next stations
* NOTES: none
*****************************************************************************/
uint8_t automac_next_station(uint8_t mac)
uint8_t automac_next_station(
uint8_t mac)
{
uint8_t i = 0; /* loop counter */
uint8_t i = 0; /* loop counter */
uint8_t next_station = 255; /* return value */
uint8_t test_station = 0; /* station number to test for token */
uint8_t test_station = 0; /* station number to test for token */
test_station = (mac + 1) % 128;
for (i = 0; i < MAC_SLOTS_MAX; i++) {
@@ -157,7 +161,8 @@ uint8_t automac_next_station(uint8_t mac)
* RETURN: Number of free MAC addresses
* NOTES: none
*****************************************************************************/
uint8_t automac_free_address_count(void)
uint8_t automac_free_address_count(
void)
{
uint8_t i = 0;
uint8_t slots = 0;
@@ -176,7 +181,8 @@ uint8_t automac_free_address_count(void)
* RETURN: Number of free MAC addresses
* NOTES: none
*****************************************************************************/
uint8_t automac_free_address_mac(uint8_t count)
uint8_t automac_free_address_mac(
uint8_t count)
{
uint8_t i = 0;
uint8_t slots = 0;
@@ -200,7 +206,8 @@ uint8_t automac_free_address_mac(uint8_t count)
* RETURN: free MAC addresses
* NOTES: none
*****************************************************************************/
uint8_t automac_free_address_random(void)
uint8_t automac_free_address_random(
void)
{
uint8_t count = 0;
uint8_t random_count = 0;
@@ -208,7 +215,7 @@ uint8_t automac_free_address_random(void)
count = automac_free_address_count();
if (count) {
random_count = rand()%count;
random_count = rand() % count;
mac = automac_free_address_mac(random_count);
}
@@ -220,7 +227,8 @@ uint8_t automac_free_address_random(void)
* RETURN: MAC addresses
* NOTES: none
*****************************************************************************/
uint8_t automac_address(void)
uint8_t automac_address(
void)
{
return My_MAC_Address;
}
@@ -230,7 +238,8 @@ uint8_t automac_address(void)
* RETURN: MAC addresses
* NOTES: none
*****************************************************************************/
void automac_address_set(uint8_t mac)
void automac_address_set(
uint8_t mac)
{
My_MAC_Address = mac;
}
@@ -240,7 +249,8 @@ void automac_address_set(uint8_t mac)
* RETURN: MAC addresses
* NOTES: none
*****************************************************************************/
uint16_t automac_time_slot(void)
uint16_t automac_time_slot(
void)
{
return My_Time_Slot;
}
@@ -250,12 +260,14 @@ uint16_t automac_time_slot(void)
* RETURN: MAC addresses
* NOTES: none
*****************************************************************************/
void automac_address_init(void)
void automac_address_init(
void)
{
My_MAC_Address = MAC_SLOTS_OFFSET + rand()%(MAC_SLOTS_MAX-MAC_SLOTS_OFFSET);
My_MAC_Address =
MAC_SLOTS_OFFSET + rand() % (MAC_SLOTS_MAX - MAC_SLOTS_OFFSET);
/* at least as long as a dropped token - worst case */
My_Time_Slot = Tno_token + (MAC_SLOTS_MAX * Tslot);
My_Time_Slot += (uint16_t)My_MAC_Address * Tslot;
My_Time_Slot += (uint16_t) My_MAC_Address *Tslot;
}
/****************************************************************************
@@ -263,7 +275,8 @@ void automac_address_init(void)
* RETURN: nothing
* NOTES: none
*****************************************************************************/
void automac_pfm_set(uint8_t mac)
void automac_pfm_set(
uint8_t mac)
{
if (mac < MAC_SLOTS_MAX) {
if (Auto_MAC_Data[mac].pfm) {
@@ -281,7 +294,8 @@ void automac_pfm_set(uint8_t mac)
* RETURN: nothing
* NOTES: none
*****************************************************************************/
void automac_token_set(uint8_t mac)
void automac_token_set(
uint8_t mac)
{
if (mac < MAC_SLOTS_MAX) {
Auto_MAC_Data[mac].token = true;
@@ -293,7 +307,8 @@ void automac_token_set(uint8_t mac)
* RETURN: nothing
* NOTES: none
*****************************************************************************/
void automac_emitter_set(uint8_t mac)
void automac_emitter_set(
uint8_t mac)
{
if (mac < MAC_SLOTS_MAX) {
Auto_MAC_Data[mac].emitter = true;
@@ -305,7 +320,8 @@ void automac_emitter_set(uint8_t mac)
* RETURN: nothing
* NOTES: none
*****************************************************************************/
void automac_init(void)
void automac_init(
void)
{
uint8_t i = 0;
@@ -359,34 +375,31 @@ void test_Auto_MAC(
srand(42);
mac = automac_free_address_random();
ct_test(pTest, mac == 255);
automac_pfm_set(MAC_SLOTS_OFFSET+1);
automac_pfm_set(MAC_SLOTS_OFFSET + 1);
mac = automac_free_address_mac(0);
ct_test(pTest, mac == (MAC_SLOTS_OFFSET+1));
ct_test(pTest, mac == (MAC_SLOTS_OFFSET + 1));
mac = automac_free_address_random();
ct_test(pTest, mac == (MAC_SLOTS_OFFSET+1));
ct_test(pTest, mac == (MAC_SLOTS_OFFSET + 1));
/* test 2 free addresses */
automac_pfm_set(MAC_SLOTS_OFFSET+2);
automac_pfm_set(MAC_SLOTS_OFFSET + 2);
mac = automac_free_address_mac(0);
ct_test(pTest, mac == (MAC_SLOTS_OFFSET+1));
ct_test(pTest, mac == (MAC_SLOTS_OFFSET + 1));
mac = automac_free_address_mac(1);
ct_test(pTest, mac == (MAC_SLOTS_OFFSET+2));
ct_test(pTest, mac == (MAC_SLOTS_OFFSET + 2));
mac = automac_free_address_random();
ct_test(pTest,
(mac == (MAC_SLOTS_OFFSET+1)) ||
(mac == (MAC_SLOTS_OFFSET+2)));
ct_test(pTest, (mac == (MAC_SLOTS_OFFSET + 1)) ||
(mac == (MAC_SLOTS_OFFSET + 2)));
/* test 3 free addresses */
automac_pfm_set(126);
mac = automac_free_address_mac(0);
ct_test(pTest, mac == (MAC_SLOTS_OFFSET+1));
ct_test(pTest, mac == (MAC_SLOTS_OFFSET + 1));
mac = automac_free_address_mac(1);
ct_test(pTest, mac == (MAC_SLOTS_OFFSET+2));
ct_test(pTest, mac == (MAC_SLOTS_OFFSET + 2));
mac = automac_free_address_mac(2);
ct_test(pTest, mac == 126);
mac = automac_free_address_random();
ct_test(pTest,
(mac == (MAC_SLOTS_OFFSET+1))||
(mac == (MAC_SLOTS_OFFSET+2))||
(mac == 126));
ct_test(pTest, (mac == (MAC_SLOTS_OFFSET + 1)) ||
(mac == (MAC_SLOTS_OFFSET + 2)) || (mac == 126));
/* test the stored address */
mac = automac_address();
ct_test(pTest, mac < MAC_SLOTS_MAX);
@@ -423,4 +436,3 @@ int main(
}
#endif
#endif
+32 -17
View File
@@ -34,26 +34,41 @@
extern "C" {
#endif /* __cplusplus */
void automac_init(void);
void automac_init(
void);
bool automac_free_address_valid(uint8_t mac);
uint8_t automac_free_address_count(void);
uint8_t automac_free_address_mac(uint8_t count);
uint8_t automac_free_address_random(void);
void automac_pfm_set(uint8_t mac);
void automac_token_set(uint8_t mac);
void automac_emitter_set(uint8_t mac);
uint8_t automac_next_station(uint8_t mac);
uint8_t automac_address(void);
void automac_address_set(uint8_t mac);
void automac_address_init(void);
uint16_t automac_time_slot(void);
bool automac_pfm_cycle_complete(void);
bool automac_enabled(void);
void automac_enabled_set(bool status);
bool automac_free_address_valid(
uint8_t mac);
uint8_t automac_free_address_count(
void);
uint8_t automac_free_address_mac(
uint8_t count);
uint8_t automac_free_address_random(
void);
void automac_pfm_set(
uint8_t mac);
void automac_token_set(
uint8_t mac);
void automac_emitter_set(
uint8_t mac);
uint8_t automac_next_station(
uint8_t mac);
uint8_t automac_address(
void);
void automac_address_set(
uint8_t mac);
void automac_address_init(
void);
uint16_t automac_time_slot(
void);
bool automac_pfm_cycle_complete(
void);
bool automac_enabled(
void);
void automac_enabled_set(
bool status);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+3 -3
View File
@@ -222,7 +222,7 @@ bool Binary_Output_Out_Of_Service(
/* note: the object name must be unique within this device */
bool Binary_Output_Object_Name(
uint32_t object_instance,
BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{
static char text_string[16] = "BO-0"; /* okay for single thread */
bool status = false;
@@ -430,8 +430,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

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