Indented project.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,22 +130,26 @@ 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));
|
||||
@@ -154,16 +157,17 @@ void handler_alarm_ack(
|
||||
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
|
||||
@@ -173,7 +177,7 @@ void handler_alarm_ack(
|
||||
}
|
||||
|
||||
|
||||
AA_ABORT:
|
||||
AA_ABORT:
|
||||
pdu_len += len;
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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],
|
||||
len =
|
||||
wpm_decode_object_id(&service_request[decode_len],
|
||||
service_len - decode_len, &wp_data);
|
||||
if (len > 0)
|
||||
{
|
||||
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,16 +122,14 @@ 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) */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "WPM: Bad Encoding!\n");
|
||||
#endif
|
||||
@@ -143,23 +140,20 @@ void handler_write_property_multiple(
|
||||
}
|
||||
|
||||
/* 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) */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "WPM: Bad Encoding!\n");
|
||||
#endif
|
||||
@@ -169,35 +163,38 @@ void handler_write_property_multiple(
|
||||
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_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],
|
||||
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],
|
||||
} 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],
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,7 +637,7 @@ static bool read_received_packet(
|
||||
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 */
|
||||
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;
|
||||
|
||||
+196
-163
@@ -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;
|
||||
@@ -283,44 +282,55 @@ int Analog_Input_Read_Property(
|
||||
#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],
|
||||
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,7 +371,8 @@ int Analog_Input_Read_Property(
|
||||
case PROP_ACKED_TRANSITIONS:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
@@ -366,26 +382,32 @@ int Analog_Input_Read_Property(
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
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],
|
||||
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],
|
||||
len =
|
||||
encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len += encode_application_date(&apdu[apdu_len + len],
|
||||
len +=
|
||||
encode_application_date(&apdu[apdu_len + len],
|
||||
&CurrentAI->Event_Time_Stamps[i].date);
|
||||
len += encode_application_time(&apdu[apdu_len + len],
|
||||
len +=
|
||||
encode_application_time(&apdu[apdu_len + len],
|
||||
&CurrentAI->Event_Time_Stamps[i].time);
|
||||
len += encode_closing_tag(&apdu[apdu_len + len],
|
||||
len +=
|
||||
encode_closing_tag(&apdu[apdu_len + len],
|
||||
TIME_STAMP_DATETIME);
|
||||
|
||||
/* add it if we have room */
|
||||
@@ -398,18 +420,18 @@ int Analog_Input_Read_Property(
|
||||
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],
|
||||
} 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],
|
||||
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 {
|
||||
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;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
@@ -436,9 +458,8 @@ 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;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
@@ -485,8 +506,7 @@ bool Analog_Input_Write_Property(
|
||||
if (CurrentAI->Out_Of_Service == true) {
|
||||
Analog_Input_Present_Value_Set(wp_data->object_instance,
|
||||
value.type.Real);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
status = false;
|
||||
@@ -570,10 +590,9 @@ 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 {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
@@ -587,10 +606,9 @@ 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 {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
@@ -604,10 +622,9 @@ 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 {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
@@ -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;
|
||||
@@ -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,14 +687,11 @@ 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)
|
||||
{
|
||||
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
|
||||
@@ -685,10 +699,11 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
(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--;
|
||||
@@ -701,10 +716,11 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
(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--;
|
||||
@@ -721,11 +737,12 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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)
|
||||
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--;
|
||||
@@ -743,11 +760,12 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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)
|
||||
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--;
|
||||
@@ -763,33 +781,28 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
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 {
|
||||
} else {
|
||||
ExceededLimit = CurrentAI->Low_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Back to normal state from low limit");
|
||||
@@ -803,8 +816,8 @@ 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_object_type_name(OBJECT_ANALOG_INPUT), object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
@@ -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,8 +841,7 @@ 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] =
|
||||
@@ -871,21 +882,27 @@ 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 */
|
||||
@@ -893,28 +910,29 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* Ack required */
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true))
|
||||
{
|
||||
switch (event_data.toState)
|
||||
{
|
||||
(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,7 +942,8 @@ 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)
|
||||
{
|
||||
bool IsNotAckedTransitions;
|
||||
@@ -939,26 +958,34 @@ 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
|
||||
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,
|
||||
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,
|
||||
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++) {
|
||||
@@ -971,31 +998,35 @@ int Analog_Input_Event_Information(unsigned index,
|
||||
/* 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);
|
||||
|
||||
return 1; /* active event */
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 0; /* no active event at this index */
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct analog_input_descr {
|
||||
uint8_t Event_State : 3;
|
||||
uint8_t Event_State:3;
|
||||
float Present_Value;
|
||||
BACNET_RELIABILITY Reliability;
|
||||
bool Out_Of_Service;
|
||||
@@ -53,9 +53,9 @@ extern "C" {
|
||||
float High_Limit;
|
||||
float Low_Limit;
|
||||
float Deadband;
|
||||
uint8_t Limit_Enable : 2;
|
||||
uint8_t Event_Enable : 3;
|
||||
uint8_t Notify_Type : 1;
|
||||
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);
|
||||
@@ -113,13 +113,16 @@ extern "C" {
|
||||
|
||||
/* note: header of Intrinsic_Reporting function is required
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance);
|
||||
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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+195
-166
@@ -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;
|
||||
@@ -316,18 +314,20 @@ int Analog_Value_Read_Property(
|
||||
#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],
|
||||
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:
|
||||
@@ -374,8 +375,8 @@ int Analog_Value_Read_Property(
|
||||
== 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,7 +448,8 @@ int Analog_Value_Read_Property(
|
||||
case PROP_ACKED_TRANSITIONS:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
@@ -448,26 +459,32 @@ int Analog_Value_Read_Property(
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
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],
|
||||
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],
|
||||
len =
|
||||
encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len += encode_application_date(&apdu[apdu_len + len],
|
||||
len +=
|
||||
encode_application_date(&apdu[apdu_len + len],
|
||||
&CurrentAV->Event_Time_Stamps[i].date);
|
||||
len += encode_application_time(&apdu[apdu_len + len],
|
||||
len +=
|
||||
encode_application_time(&apdu[apdu_len + len],
|
||||
&CurrentAV->Event_Time_Stamps[i].time);
|
||||
len += encode_closing_tag(&apdu[apdu_len + len],
|
||||
len +=
|
||||
encode_closing_tag(&apdu[apdu_len + len],
|
||||
TIME_STAMP_DATETIME);
|
||||
|
||||
/* add it if we have room */
|
||||
@@ -480,18 +497,18 @@ int Analog_Value_Read_Property(
|
||||
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],
|
||||
} 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],
|
||||
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 {
|
||||
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;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
@@ -506,8 +523,7 @@ int Analog_Value_Read_Property(
|
||||
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;
|
||||
@@ -677,10 +693,9 @@ 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 {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
@@ -694,10 +709,9 @@ 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 {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
@@ -711,10 +725,9 @@ 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 {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
@@ -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;
|
||||
@@ -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,14 +790,11 @@ 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)
|
||||
{
|
||||
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
|
||||
@@ -792,10 +802,11 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
(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--;
|
||||
@@ -808,10 +819,11 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
(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--;
|
||||
@@ -828,11 +840,12 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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)
|
||||
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--;
|
||||
@@ -850,11 +863,12 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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)
|
||||
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--;
|
||||
@@ -870,33 +884,28 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
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 {
|
||||
} else {
|
||||
ExceededLimit = CurrentAV->Low_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Back to normal state from low limit");
|
||||
@@ -910,8 +919,8 @@ 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_object_type_name(OBJECT_ANALOG_VALUE), object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
@@ -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,8 +944,7 @@ 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] =
|
||||
@@ -978,21 +985,27 @@ 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 */
|
||||
@@ -1000,28 +1013,29 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* Ack required */
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true))
|
||||
{
|
||||
switch (event_data.toState)
|
||||
{
|
||||
(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,7 +1045,8 @@ 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)
|
||||
{
|
||||
bool IsNotAckedTransitions;
|
||||
@@ -1046,26 +1061,34 @@ 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
|
||||
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,
|
||||
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,
|
||||
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++) {
|
||||
@@ -1078,30 +1101,34 @@ int Analog_Value_Event_Information(unsigned index,
|
||||
/* 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);
|
||||
|
||||
return 1; /* active event */
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 0; /* no active event at this index */
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct analog_value_descr {
|
||||
uint8_t Event_State : 3;
|
||||
uint8_t Event_State:3;
|
||||
bool Out_Of_Service;
|
||||
uint8_t Units;
|
||||
/* Here is our Priority Array. They are supposed to be Real, but */
|
||||
@@ -57,9 +57,9 @@ extern "C" {
|
||||
float High_Limit;
|
||||
float Low_Limit;
|
||||
float Deadband;
|
||||
uint8_t Limit_Enable : 2;
|
||||
uint8_t Event_Enable : 3;
|
||||
uint8_t Notify_Type : 1;
|
||||
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);
|
||||
@@ -106,10 +106,12 @@ extern "C" {
|
||||
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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -112,14 +112,19 @@ static object_functions_t Object_Table[] = {
|
||||
Binary_Value_Write_Property, Binary_Value_Property_Lists,
|
||||
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,
|
||||
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}, {
|
||||
@@ -128,13 +133,17 @@ static object_functions_t Object_Table[] = {
|
||||
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,
|
||||
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,
|
||||
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}, {
|
||||
@@ -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)
|
||||
{
|
||||
@@ -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,8 +1335,7 @@ bool Device_Write_Property_Local(
|
||||
case PROP_OBJECT_NAME:
|
||||
status =
|
||||
WPValidateString(&value,
|
||||
characterstring_capacity(&My_Object_Name),
|
||||
false,
|
||||
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.
|
||||
@@ -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;
|
||||
@@ -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,7 +1496,8 @@ bool Device_Encode_Value_List(
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
void Device_local_reporting(void)
|
||||
void Device_local_reporting(
|
||||
void)
|
||||
{
|
||||
struct object_functions *pObject;
|
||||
uint32_t objects_count;
|
||||
@@ -1499,18 +1508,15 @@ void Device_local_reporting(void)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ 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,7 +116,7 @@ typedef bool(
|
||||
* @ingroup ObjHelpers
|
||||
* @param [in] Object instance.
|
||||
*/
|
||||
typedef void(
|
||||
typedef void (
|
||||
*object_intrinsic_reporting_function) (
|
||||
uint32_t object_instance);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+229
-189
@@ -51,8 +51,7 @@
|
||||
static NOTIFICATION_CLASS_INFO NC_Info[MAX_NOTIFICATION_CLASSES];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Notification_Properties_Required[] =
|
||||
{
|
||||
static const int Notification_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
@@ -63,14 +62,12 @@ static const int Notification_Properties_Required[] =
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Notification_Properties_Optional[] =
|
||||
{
|
||||
static const int Notification_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Notification_Properties_Proprietary[] =
|
||||
{
|
||||
static const int Notification_Properties_Proprietary[] = {
|
||||
-1
|
||||
};
|
||||
|
||||
@@ -88,12 +85,12 @@ void Notification_Class_Property_Lists(
|
||||
return;
|
||||
}
|
||||
|
||||
void Notification_Class_Init(void)
|
||||
void Notification_Class_Init(
|
||||
void)
|
||||
{
|
||||
uint8_t NotifyIdx = 0;
|
||||
|
||||
for (NotifyIdx = 0; NotifyIdx < MAX_NOTIFICATION_CLASSES; NotifyIdx++)
|
||||
{
|
||||
for (NotifyIdx = 0; NotifyIdx < MAX_NOTIFICATION_CLASSES; NotifyIdx++) {
|
||||
/* init with zeros */
|
||||
memset(&NC_Info[NotifyIdx], 0x00, sizeof(NOTIFICATION_CLASS_INFO));
|
||||
/* set the basic parameters */
|
||||
@@ -124,7 +121,8 @@ bool Notification_Class_Valid_Instance(
|
||||
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then count how many you have */
|
||||
unsigned Notification_Class_Count(void)
|
||||
unsigned Notification_Class_Count(
|
||||
void)
|
||||
{
|
||||
return MAX_NOTIFICATION_CLASSES;
|
||||
}
|
||||
@@ -132,7 +130,8 @@ unsigned Notification_Class_Count(void)
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need to return the instance */
|
||||
/* that correlates to the correct index */
|
||||
uint32_t Notification_Class_Index_To_Instance(unsigned index)
|
||||
uint32_t Notification_Class_Index_To_Instance(
|
||||
unsigned index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
@@ -153,7 +152,7 @@ unsigned Notification_Class_Instance_To_Index(
|
||||
|
||||
bool Notification_Class_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;
|
||||
@@ -189,56 +188,58 @@ int Notification_Class_Read_Property(
|
||||
}
|
||||
|
||||
apdu = rpdata->application_data;
|
||||
CurrentNotify = &NC_Info[Notification_Class_Instance_To_Index(rpdata->object_instance)];
|
||||
CurrentNotify =
|
||||
&NC_Info[Notification_Class_Instance_To_Index(rpdata->
|
||||
object_instance)];
|
||||
|
||||
switch (rpdata->object_property)
|
||||
{
|
||||
switch (rpdata->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
apdu_len =
|
||||
encode_application_object_id(&apdu[0], OBJECT_NOTIFICATION_CLASS,
|
||||
rpdata->object_instance);
|
||||
encode_application_object_id(&apdu[0],
|
||||
OBJECT_NOTIFICATION_CLASS, rpdata->object_instance);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_DESCRIPTION:
|
||||
Notification_Class_Object_Name(rpdata->object_instance, &char_string);
|
||||
Notification_Class_Object_Name(rpdata->object_instance,
|
||||
&char_string);
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_TYPE:
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], OBJECT_NOTIFICATION_CLASS);
|
||||
encode_application_enumerated(&apdu[0],
|
||||
OBJECT_NOTIFICATION_CLASS);
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
apdu_len += encode_application_unsigned(&apdu[0], rpdata->object_instance);
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[0], rpdata->object_instance);
|
||||
break;
|
||||
|
||||
case PROP_PRIORITY:
|
||||
if (rpdata->array_index == 0)
|
||||
apdu_len += encode_application_unsigned(&apdu[0], 3);
|
||||
else
|
||||
{
|
||||
if (rpdata->array_index == BACNET_ARRAY_ALL)
|
||||
{
|
||||
else {
|
||||
if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
/* TO-OFFNORMAL */
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
CurrentNotify->Priority[0]);
|
||||
/* TO-FAULT */
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
CurrentNotify->Priority[1]);
|
||||
/* TO-NORMAL */
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
CurrentNotify->Priority[2]);
|
||||
}
|
||||
else if (rpdata->array_index <= 3)
|
||||
{
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len],
|
||||
} else if (rpdata->array_index <= 3) {
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
CurrentNotify->Priority[rpdata->array_index - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = -1;
|
||||
@@ -251,46 +252,49 @@ int Notification_Class_Read_Property(
|
||||
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
(u8Val & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false );
|
||||
(u8Val & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
(u8Val & TRANSITION_TO_FAULT_MASKED ) ? true : false );
|
||||
(u8Val & TRANSITION_TO_FAULT_MASKED) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
(u8Val & TRANSITION_TO_NORMAL_MASKED ) ? true : false );
|
||||
(u8Val & TRANSITION_TO_NORMAL_MASKED) ? true : false);
|
||||
/* encode bitstring */
|
||||
apdu_len += encode_application_bitstring(&apdu[apdu_len], &bit_string);
|
||||
apdu_len +=
|
||||
encode_application_bitstring(&apdu[apdu_len], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_RECIPIENT_LIST:
|
||||
/* encode all entry of Recipient_List */
|
||||
for (idx = 0; idx < NC_MAX_RECIPIENTS; idx++)
|
||||
{
|
||||
for (idx = 0; idx < NC_MAX_RECIPIENTS; idx++) {
|
||||
BACNET_DESTINATION *RecipientEntry;
|
||||
int i = 0;
|
||||
|
||||
/* get pointer of current element for Recipient_List - easier for use */
|
||||
RecipientEntry = &CurrentNotify->Recipient_List[idx];
|
||||
if (RecipientEntry->Recipient.RecipientType != RECIPIENT_TYPE_NOTINITIALIZED)
|
||||
{
|
||||
if (RecipientEntry->Recipient.RecipientType !=
|
||||
RECIPIENT_TYPE_NOTINITIALIZED) {
|
||||
/* Valid Days - BACnetDaysOfWeek - [bitstring] monday-sunday */
|
||||
u8Val = 0x01;
|
||||
bitstring_init(&bit_string);
|
||||
|
||||
for (i = 0; i < MAX_BACNET_DAYS_OF_WEEK; i++)
|
||||
{
|
||||
for (i = 0; i < MAX_BACNET_DAYS_OF_WEEK; i++) {
|
||||
if (RecipientEntry->ValidDays & u8Val)
|
||||
bitstring_set_bit(&bit_string, i, true);
|
||||
else
|
||||
bitstring_set_bit(&bit_string, i, false);
|
||||
u8Val <<= 1; /* next day */
|
||||
}
|
||||
apdu_len += encode_application_bitstring(&apdu[apdu_len],&bit_string);
|
||||
apdu_len +=
|
||||
encode_application_bitstring(&apdu[apdu_len],
|
||||
&bit_string);
|
||||
|
||||
/* From Time */
|
||||
apdu_len += encode_application_time(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_time(&apdu[apdu_len],
|
||||
&RecipientEntry->FromTime);
|
||||
|
||||
/* To Time */
|
||||
apdu_len += encode_application_time(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_time(&apdu[apdu_len],
|
||||
&RecipientEntry->ToTime);
|
||||
|
||||
/*
|
||||
@@ -300,47 +304,51 @@ int Notification_Class_Read_Property(
|
||||
} */
|
||||
|
||||
/* CHOICE - device [0] BACnetObjectIdentifier */
|
||||
if (RecipientEntry->Recipient.RecipientType == RECIPIENT_TYPE_DEVICE)
|
||||
{
|
||||
apdu_len += encode_context_object_id(&apdu[apdu_len], 0, OBJECT_DEVICE,
|
||||
if (RecipientEntry->Recipient.RecipientType ==
|
||||
RECIPIENT_TYPE_DEVICE) {
|
||||
apdu_len +=
|
||||
encode_context_object_id(&apdu[apdu_len], 0,
|
||||
OBJECT_DEVICE,
|
||||
RecipientEntry->Recipient._.DeviceIdentifier);
|
||||
}
|
||||
/* CHOICE - address [1] BACnetAddress */
|
||||
else if (RecipientEntry->Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS)
|
||||
{
|
||||
else if (RecipientEntry->Recipient.RecipientType ==
|
||||
RECIPIENT_TYPE_ADDRESS) {
|
||||
/* opening tag 1 */
|
||||
apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
|
||||
/* network-number Unsigned16, */
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
RecipientEntry->Recipient._.Address.net);
|
||||
|
||||
/* mac-address OCTET STRING */
|
||||
if (RecipientEntry->Recipient._.Address.net)
|
||||
{
|
||||
if (RecipientEntry->Recipient._.Address.net) {
|
||||
octetstring_init(&octet_string,
|
||||
RecipientEntry->Recipient._.Address.adr,
|
||||
RecipientEntry->Recipient._.Address.len);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
octetstring_init(&octet_string,
|
||||
RecipientEntry->Recipient._.Address.mac,
|
||||
RecipientEntry->Recipient._.Address.mac_len);
|
||||
}
|
||||
apdu_len += encode_application_octet_string(&apdu[apdu_len], &octet_string);
|
||||
apdu_len +=
|
||||
encode_application_octet_string(&apdu[apdu_len],
|
||||
&octet_string);
|
||||
|
||||
/* closing tag 1 */
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 1);
|
||||
|
||||
}
|
||||
else {;} /* shouldn't happen */
|
||||
} else {;
|
||||
} /* shouldn't happen */
|
||||
|
||||
/* Process Identifier - Unsigned32 */
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
RecipientEntry->ProcessIdentifier);
|
||||
|
||||
/* Issue Confirmed Notifications - boolean */
|
||||
apdu_len += encode_application_boolean(&apdu[apdu_len],
|
||||
apdu_len +=
|
||||
encode_application_boolean(&apdu[apdu_len],
|
||||
RecipientEntry->ConfirmedNotify);
|
||||
|
||||
/* Transitions - BACnet Event Transition Bits [bitstring] */
|
||||
@@ -348,13 +356,16 @@ int Notification_Class_Read_Property(
|
||||
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
(u8Val & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false );
|
||||
(u8Val & TRANSITION_TO_OFFNORMAL_MASKED) ? true :
|
||||
false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
(u8Val & TRANSITION_TO_FAULT_MASKED ) ? true : false );
|
||||
(u8Val & TRANSITION_TO_FAULT_MASKED) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
(u8Val & TRANSITION_TO_NORMAL_MASKED ) ? true : false );
|
||||
(u8Val & TRANSITION_TO_NORMAL_MASKED) ? true : false);
|
||||
|
||||
apdu_len += encode_application_bitstring(&apdu[apdu_len], &bit_string);
|
||||
apdu_len +=
|
||||
encode_application_bitstring(&apdu[apdu_len],
|
||||
&bit_string);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -368,8 +379,7 @@ int Notification_Class_Read_Property(
|
||||
|
||||
/* only array properties can have array options */
|
||||
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY) &&
|
||||
(rpdata->array_index != BACNET_ARRAY_ALL))
|
||||
{
|
||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
@@ -392,15 +402,17 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
|
||||
|
||||
CurrentNotify = &NC_Info[Notification_Class_Instance_To_Index(wp_data->object_instance)];
|
||||
CurrentNotify =
|
||||
&NC_Info[Notification_Class_Instance_To_Index(wp_data->
|
||||
object_instance)];
|
||||
|
||||
/* decode the some of the request
|
||||
*/
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
len =
|
||||
bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
|
||||
switch (wp_data->object_property)
|
||||
{
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRIORITY:
|
||||
status =
|
||||
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||
@@ -410,15 +422,12 @@ bool Notification_Class_Write_Property(
|
||||
if (wp_data->array_index == 0) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
}
|
||||
else if (wp_data->array_index == BACNET_ARRAY_ALL) {
|
||||
} else if (wp_data->array_index == BACNET_ARRAY_ALL) {
|
||||
/* FIXME: wite all array */
|
||||
}
|
||||
else if (wp_data->array_index <= 3) {
|
||||
} else if (wp_data->array_index <= 3) {
|
||||
CurrentNotify->Priority[wp_data->array_index - 1] =
|
||||
value.type.Unsigned_Int;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
}
|
||||
@@ -434,8 +443,7 @@ bool Notification_Class_Write_Property(
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentNotify->Ack_Required =
|
||||
value.type.Bit_String.value[0];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
@@ -447,14 +455,15 @@ bool Notification_Class_Write_Property(
|
||||
memset(&TmpNotify, 0x00, sizeof(NOTIFICATION_CLASS_INFO));
|
||||
|
||||
/* decode all packed */
|
||||
while (iOffset < wp_data->application_data_len)
|
||||
{
|
||||
while (iOffset < wp_data->application_data_len) {
|
||||
/* Decode Valid Days */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -463,7 +472,8 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
if (value.type.Bit_String.bits_used == MAX_BACNET_DAYS_OF_WEEK)
|
||||
/* store value */
|
||||
TmpNotify.Recipient_List[idx].ValidDays = value.type.Bit_String.value[0];
|
||||
TmpNotify.Recipient_List[idx].ValidDays =
|
||||
value.type.Bit_String.value[0];
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_OTHER;
|
||||
@@ -472,9 +482,10 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
iOffset += len;
|
||||
/* Decode From Time */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
@@ -487,9 +498,10 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
iOffset += len;
|
||||
/* Decode To Time */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
@@ -502,69 +514,78 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
iOffset += len;
|
||||
/* context tag [0] - Device */
|
||||
if (decode_is_context_tag(&wp_data->application_data[iOffset], 0))
|
||||
{
|
||||
TmpNotify.Recipient_List[idx].Recipient.RecipientType = RECIPIENT_TYPE_DEVICE;
|
||||
if (decode_is_context_tag(&wp_data->application_data[iOffset],
|
||||
0)) {
|
||||
TmpNotify.Recipient_List[idx].Recipient.RecipientType =
|
||||
RECIPIENT_TYPE_DEVICE;
|
||||
/* Decode Network Number */
|
||||
len = bacapp_decode_context_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
len =
|
||||
bacapp_decode_context_data(&wp_data->
|
||||
application_data[iOffset],
|
||||
wp_data->application_data_len, &value,
|
||||
PROP_RECIPIENT_LIST);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_OBJECT_ID)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_OBJECT_ID)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
/* store value */
|
||||
TmpNotify.Recipient_List[idx].Recipient._.DeviceIdentifier =
|
||||
value.type.Object_Id.instance;
|
||||
TmpNotify.Recipient_List[idx].Recipient._.
|
||||
DeviceIdentifier = value.type.Object_Id.instance;
|
||||
|
||||
iOffset += len;
|
||||
}
|
||||
/* opening tag [1] - Recipient */
|
||||
else if (decode_is_opening_tag_number(&wp_data->application_data[iOffset], 1))
|
||||
{
|
||||
else if (decode_is_opening_tag_number(&wp_data->
|
||||
application_data[iOffset], 1)) {
|
||||
iOffset++;
|
||||
TmpNotify.Recipient_List[idx].Recipient.RecipientType = RECIPIENT_TYPE_ADDRESS;
|
||||
TmpNotify.Recipient_List[idx].Recipient.RecipientType =
|
||||
RECIPIENT_TYPE_ADDRESS;
|
||||
/* Decode Network Number */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
/* store value */
|
||||
TmpNotify.Recipient_List[idx].Recipient._.Address.net = value.type.Unsigned_Int;
|
||||
TmpNotify.Recipient_List[idx].Recipient._.Address.net =
|
||||
value.type.Unsigned_Int;
|
||||
|
||||
iOffset += len;
|
||||
/* Decode Address */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_OCTET_STRING)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_OCTET_STRING)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
/* store value */
|
||||
if (TmpNotify.Recipient_List[idx].Recipient._.Address.net == 0) {
|
||||
memcpy(TmpNotify.Recipient_List[idx].Recipient._.Address.mac,
|
||||
value.type.Octet_String.value,
|
||||
if (TmpNotify.Recipient_List[idx].Recipient._.Address.
|
||||
net == 0) {
|
||||
memcpy(TmpNotify.Recipient_List[idx].Recipient._.
|
||||
Address.mac, value.type.Octet_String.value,
|
||||
value.type.Octet_String.length);
|
||||
TmpNotify.Recipient_List[idx].Recipient._.Address.mac_len =
|
||||
value.type.Octet_String.length;
|
||||
}
|
||||
else {
|
||||
memcpy(TmpNotify.Recipient_List[idx].Recipient._.Address.adr,
|
||||
value.type.Octet_String.value,
|
||||
TmpNotify.Recipient_List[idx].Recipient._.Address.
|
||||
mac_len = value.type.Octet_String.length;
|
||||
} else {
|
||||
memcpy(TmpNotify.Recipient_List[idx].Recipient._.
|
||||
Address.adr, value.type.Octet_String.value,
|
||||
value.type.Octet_String.length);
|
||||
TmpNotify.Recipient_List[idx].Recipient._.Address.len =
|
||||
value.type.Octet_String.length;
|
||||
@@ -572,7 +593,8 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
iOffset += len;
|
||||
/* closing tag [1] - Recipient */
|
||||
if (decode_is_closing_tag_number(&wp_data->application_data[iOffset], 1))
|
||||
if (decode_is_closing_tag_number(&wp_data->
|
||||
application_data[iOffset], 1))
|
||||
iOffset++;
|
||||
else {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
@@ -580,8 +602,7 @@ bool Notification_Class_Write_Property(
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -589,50 +610,60 @@ bool Notification_Class_Write_Property(
|
||||
}
|
||||
|
||||
/* Process Identifier */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
/* store value */
|
||||
TmpNotify.Recipient_List[idx].ProcessIdentifier = value.type.Unsigned_Int;
|
||||
TmpNotify.Recipient_List[idx].ProcessIdentifier =
|
||||
value.type.Unsigned_Int;
|
||||
|
||||
iOffset += len;
|
||||
/* Issue Confirmed Notifications */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
/* store value */
|
||||
TmpNotify.Recipient_List[idx].ConfirmedNotify = value.type.Boolean;
|
||||
TmpNotify.Recipient_List[idx].ConfirmedNotify =
|
||||
value.type.Boolean;
|
||||
|
||||
iOffset += len;
|
||||
/* Transitions */
|
||||
len = bacapp_decode_application_data(
|
||||
&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value);
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
|
||||
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.type.Bit_String.bits_used == MAX_BACNET_EVENT_TRANSITION)
|
||||
if (value.type.Bit_String.bits_used ==
|
||||
MAX_BACNET_EVENT_TRANSITION)
|
||||
/* store value */
|
||||
TmpNotify.Recipient_List[idx].Transitions = value.type.Bit_String.value[0];
|
||||
TmpNotify.Recipient_List[idx].Transitions =
|
||||
value.type.Bit_String.value[0];
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_OTHER;
|
||||
@@ -643,28 +674,32 @@ bool Notification_Class_Write_Property(
|
||||
/* Increasing element of list */
|
||||
if (++idx >= NC_MAX_RECIPIENTS) {
|
||||
wp_data->error_class = ERROR_CLASS_RESOURCES;
|
||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decoded all recipient list */
|
||||
/* copy elements from temporary object */
|
||||
for (idx = 0; idx < NC_MAX_RECIPIENTS; idx++)
|
||||
{
|
||||
BACNET_ADDRESS src = {0};
|
||||
for (idx = 0; idx < NC_MAX_RECIPIENTS; idx++) {
|
||||
BACNET_ADDRESS src = { 0 };
|
||||
unsigned max_apdu = 0;
|
||||
int32_t DeviceID;
|
||||
|
||||
CurrentNotify->Recipient_List[idx] = TmpNotify.Recipient_List[idx];
|
||||
CurrentNotify->Recipient_List[idx] =
|
||||
TmpNotify.Recipient_List[idx];
|
||||
|
||||
if (CurrentNotify->Recipient_List[idx].Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) {
|
||||
if (CurrentNotify->Recipient_List[idx].Recipient.
|
||||
RecipientType == RECIPIENT_TYPE_DEVICE) {
|
||||
/* copy Device_ID */
|
||||
DeviceID = CurrentNotify->Recipient_List[idx].Recipient._.DeviceIdentifier;
|
||||
DeviceID =
|
||||
CurrentNotify->Recipient_List[idx].Recipient._.
|
||||
DeviceIdentifier;
|
||||
address_bind_request(DeviceID, &max_apdu, &src);
|
||||
|
||||
}
|
||||
else if (CurrentNotify->Recipient_List[idx].Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
|
||||
} else if (CurrentNotify->Recipient_List[idx].Recipient.
|
||||
RecipientType == RECIPIENT_TYPE_ADDRESS) {
|
||||
/* copy Address */
|
||||
/* src = CurrentNotify->Recipient_List[idx].Recipient._.Address; */
|
||||
/* address_bind_request(BACNET_MAX_INSTANCE, &max_apdu, &src); */
|
||||
@@ -686,7 +721,8 @@ bool Notification_Class_Write_Property(
|
||||
|
||||
|
||||
void Notification_Class_Get_Priorities(
|
||||
uint32_t Object_Instance, uint32_t *pPriorityArray)
|
||||
uint32_t Object_Instance,
|
||||
uint32_t * pPriorityArray)
|
||||
{
|
||||
NOTIFICATION_CLASS_INFO *CurrentNotify;
|
||||
uint32_t object_index;
|
||||
@@ -707,13 +743,14 @@ void Notification_Class_Get_Priorities(
|
||||
}
|
||||
|
||||
|
||||
static bool IsRecipientActive(BACNET_DESTINATION * pBacDest, uint8_t EventToState)
|
||||
static bool IsRecipientActive(
|
||||
BACNET_DESTINATION * pBacDest,
|
||||
uint8_t EventToState)
|
||||
{
|
||||
BACNET_DATE_TIME DateTime;
|
||||
|
||||
/* valid Transitions */
|
||||
switch (EventToState)
|
||||
{
|
||||
switch (EventToState) {
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
@@ -765,8 +802,8 @@ void Notification_Class_common_reporting_function(
|
||||
uint8_t index;
|
||||
|
||||
|
||||
notify_index = Notification_Class_Instance_To_Index(
|
||||
event_data->notificationClass);
|
||||
notify_index =
|
||||
Notification_Class_Instance_To_Index(event_data->notificationClass);
|
||||
|
||||
if (notify_index < MAX_NOTIFICATION_CLASSES)
|
||||
CurrentNotify = &NC_Info[notify_index];
|
||||
@@ -779,21 +816,20 @@ void Notification_Class_common_reporting_function(
|
||||
event_data->initiatingObjectIdentifier.instance =
|
||||
Device_Object_Instance_Number();
|
||||
|
||||
/* Priority and AckRequired*/
|
||||
switch (event_data->toState)
|
||||
{
|
||||
/* Priority and AckRequired */
|
||||
switch (event_data->toState) {
|
||||
case EVENT_STATE_NORMAL:
|
||||
event_data->priority =
|
||||
CurrentNotify->Priority[EVENT_STATE_NORMAL];
|
||||
event_data->ackRequired = (CurrentNotify->Ack_Required &
|
||||
TRANSITION_TO_NORMAL_MASKED) ? true : false;
|
||||
event_data->priority = CurrentNotify->Priority[EVENT_STATE_NORMAL];
|
||||
event_data->ackRequired =
|
||||
(CurrentNotify->
|
||||
Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? true : false;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
event_data->priority =
|
||||
CurrentNotify->Priority[EVENT_STATE_FAULT];
|
||||
event_data->ackRequired = (CurrentNotify->Ack_Required &
|
||||
TRANSITION_TO_FAULT_MASKED) ? true : false;
|
||||
event_data->priority = CurrentNotify->Priority[EVENT_STATE_FAULT];
|
||||
event_data->ackRequired =
|
||||
(CurrentNotify->
|
||||
Ack_Required & TRANSITION_TO_FAULT_MASKED) ? true : false;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
@@ -801,8 +837,9 @@ void Notification_Class_common_reporting_function(
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
event_data->priority =
|
||||
CurrentNotify->Priority[EVENT_STATE_OFFNORMAL];
|
||||
event_data->ackRequired = (CurrentNotify->Ack_Required &
|
||||
TRANSITION_TO_OFFNORMAL_MASKED) ? true : false;
|
||||
event_data->ackRequired =
|
||||
(CurrentNotify->
|
||||
Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false;
|
||||
break;
|
||||
|
||||
default: /* shouldn't happen */
|
||||
@@ -812,14 +849,12 @@ void Notification_Class_common_reporting_function(
|
||||
/* send notifications for active recipients */
|
||||
/* pointer to first recipient */
|
||||
pBacDest = &CurrentNotify->Recipient_List[0];
|
||||
for (index = 0; index < NC_MAX_RECIPIENTS; index++, pBacDest++)
|
||||
{
|
||||
for (index = 0; index < NC_MAX_RECIPIENTS; index++, pBacDest++) {
|
||||
/* check if recipient is defined */
|
||||
if (pBacDest->Recipient.RecipientType == RECIPIENT_TYPE_NOTINITIALIZED)
|
||||
break; /* recipient doesn't defined - end of list */
|
||||
|
||||
if (IsRecipientActive(pBacDest, event_data->toState) == true)
|
||||
{
|
||||
if (IsRecipientActive(pBacDest, event_data->toState) == true) {
|
||||
BACNET_ADDRESS dest;
|
||||
uint32_t device_id;
|
||||
unsigned max_apdu;
|
||||
@@ -835,17 +870,18 @@ void Notification_Class_common_reporting_function(
|
||||
if (pBacDest->ConfirmedNotify == true)
|
||||
Send_CEvent_Notify(device_id, event_data);
|
||||
else if (address_get_by_device(device_id, &max_apdu, &dest))
|
||||
Send_UEvent_Notify(Handler_Transmit_Buffer, event_data, &dest);
|
||||
}
|
||||
else if (pBacDest->Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
|
||||
Send_UEvent_Notify(Handler_Transmit_Buffer, event_data,
|
||||
&dest);
|
||||
} else if (pBacDest->Recipient.RecipientType ==
|
||||
RECIPIENT_TYPE_ADDRESS) {
|
||||
/* send notification to the address indicated */
|
||||
if (pBacDest->ConfirmedNotify == true) {
|
||||
if (address_get_device_id(&dest, &device_id))
|
||||
Send_CEvent_Notify(device_id, event_data);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dest = pBacDest->Recipient._.Address;
|
||||
Send_UEvent_Notify(Handler_Transmit_Buffer, event_data, &dest);
|
||||
Send_UEvent_Notify(Handler_Transmit_Buffer, event_data,
|
||||
&dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -854,33 +890,37 @@ void Notification_Class_common_reporting_function(
|
||||
|
||||
/* This function tries to find the addresses of the defined devices. */
|
||||
/* It should be called periodically (example once per minute). */
|
||||
void Notification_Class_find_recipient(void)
|
||||
void Notification_Class_find_recipient(
|
||||
void)
|
||||
{
|
||||
NOTIFICATION_CLASS_INFO *CurrentNotify;
|
||||
BACNET_DESTINATION *pBacDest;
|
||||
BACNET_ADDRESS src = {0};
|
||||
BACNET_ADDRESS src = { 0 };
|
||||
unsigned max_apdu = 0;
|
||||
uint32_t notify_index;
|
||||
uint32_t DeviceID;
|
||||
uint8_t idx;
|
||||
|
||||
|
||||
for (notify_index = 0; notify_index < MAX_NOTIFICATION_CLASSES; notify_index++)
|
||||
{
|
||||
for (notify_index = 0; notify_index < MAX_NOTIFICATION_CLASSES;
|
||||
notify_index++) {
|
||||
/* pointer to current notification */
|
||||
CurrentNotify = &NC_Info[Notification_Class_Instance_To_Index(notify_index)];
|
||||
CurrentNotify =
|
||||
&NC_Info[Notification_Class_Instance_To_Index(notify_index)];
|
||||
/* pointer to first recipient */
|
||||
pBacDest = &CurrentNotify->Recipient_List[0];
|
||||
for (idx = 0; idx < NC_MAX_RECIPIENTS; idx++, pBacDest++)
|
||||
{
|
||||
if (CurrentNotify->Recipient_List[idx].Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) {
|
||||
for (idx = 0; idx < NC_MAX_RECIPIENTS; idx++, pBacDest++) {
|
||||
if (CurrentNotify->Recipient_List[idx].Recipient.RecipientType ==
|
||||
RECIPIENT_TYPE_DEVICE) {
|
||||
/* Device ID */
|
||||
DeviceID = CurrentNotify->Recipient_List[idx].Recipient._.DeviceIdentifier;
|
||||
DeviceID =
|
||||
CurrentNotify->Recipient_List[idx].Recipient._.
|
||||
DeviceIdentifier;
|
||||
/* Send who_ is request only when address of device is unknown. */
|
||||
if (!address_bind_request(DeviceID, &max_apdu, &src))
|
||||
Send_WhoIs(DeviceID, DeviceID);
|
||||
}
|
||||
else if (CurrentNotify->Recipient_List[idx].Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
|
||||
} else if (CurrentNotify->Recipient_List[idx].Recipient.
|
||||
RecipientType == RECIPIENT_TYPE_ADDRESS) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ extern "C" {
|
||||
/* max "length" of recipient_list */
|
||||
#define NC_MAX_RECIPIENTS 10
|
||||
/* Recipient types */
|
||||
typedef enum {
|
||||
typedef enum {
|
||||
RECIPIENT_TYPE_NOTINITIALIZED = 0,
|
||||
RECIPIENT_TYPE_DEVICE = 1,
|
||||
RECIPIENT_TYPE_ADDRESS = 2
|
||||
} NC_RECIPIENT_TYPE;
|
||||
} NC_RECIPIENT_TYPE;
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
@@ -53,17 +53,17 @@ BACnetRecipient ::= CHOICE {
|
||||
address [1] BACnetAddress
|
||||
}
|
||||
*/
|
||||
typedef struct BACnet_Recipient {
|
||||
typedef struct BACnet_Recipient {
|
||||
uint8_t RecipientType; /* Type of Recipient */
|
||||
union {
|
||||
uint32_t DeviceIdentifier;
|
||||
BACNET_ADDRESS Address;
|
||||
} _;
|
||||
} BACNET_RECIPIENT;
|
||||
} BACNET_RECIPIENT;
|
||||
|
||||
|
||||
/* BACnetDestination structure */
|
||||
typedef struct BACnet_Destination {
|
||||
typedef struct BACnet_Destination {
|
||||
uint8_t ValidDays;
|
||||
BACNET_TIME FromTime;
|
||||
BACNET_TIME ToTime;
|
||||
@@ -71,29 +71,29 @@ typedef struct BACnet_Destination {
|
||||
uint32_t ProcessIdentifier;
|
||||
uint8_t Transitions;
|
||||
bool ConfirmedNotify;
|
||||
} BACNET_DESTINATION;
|
||||
} BACNET_DESTINATION;
|
||||
|
||||
|
||||
/* Structure containing configuration for a Notification Class */
|
||||
typedef struct 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;
|
||||
} NOTIFICATION_CLASS_INFO;
|
||||
|
||||
|
||||
/* Indicates whether the transaction has been confirmed */
|
||||
typedef struct 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;
|
||||
BACNET_DATE_TIME Time_Stamp; /* time stamp of when a alarm was generated */
|
||||
} ACKED_INFO;
|
||||
|
||||
|
||||
/* Information needed to send AckNotification */
|
||||
typedef struct Ack_Notification {
|
||||
typedef struct Ack_Notification {
|
||||
bool bSendAckNotify; /* true if need to send AckNotification */
|
||||
uint8_t EventState;
|
||||
} ACK_NOTIFICATION;
|
||||
} ACK_NOTIFICATION;
|
||||
|
||||
|
||||
|
||||
@@ -102,17 +102,20 @@ 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);
|
||||
unsigned Notification_Class_Count(
|
||||
void);
|
||||
uint32_t Notification_Class_Index_To_Instance(
|
||||
unsigned index);
|
||||
unsigned Notification_Class_Instance_To_Index(
|
||||
uint32_t object_instance);
|
||||
bool Notification_Class_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
int Notification_Class_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
@@ -121,24 +124,24 @@ typedef struct Ack_Notification {
|
||||
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);
|
||||
|
||||
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 */
|
||||
|
||||
@@ -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) ||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -38,18 +38,25 @@ extern "C" {
|
||||
|
||||
|
||||
/* decode the service request only */
|
||||
int wpm_decode_object_id(uint8_t * apdu, uint16_t apdu_len,
|
||||
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,
|
||||
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,
|
||||
int wpm_error_ack_encode_apdu(
|
||||
uint8_t * apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, "");
|
||||
@@ -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 */
|
||||
|
||||
@@ -400,7 +399,7 @@ void Device_Init(
|
||||
|
||||
/* 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)
|
||||
{
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -72,18 +72,18 @@ void adc_enable(
|
||||
* Notes: none
|
||||
**************************************************/
|
||||
uint8_t adc_result_8bit(
|
||||
uint8_t channel) /* 0..7 = ADC0..ADC7, respectively */
|
||||
{
|
||||
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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
@@ -86,35 +96,40 @@ static int utf8_isvalid(const char *str, int length)
|
||||
switch (ab) {
|
||||
/* Check for xx00 000x */
|
||||
case 1:
|
||||
if ((c & 0x3e) == 0) return 0;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -422,7 +420,7 @@ void Device_Init(
|
||||
|
||||
/* 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)
|
||||
{
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
#include "led.h"
|
||||
|
||||
/** Main function of BACnet demo for RX62N evaluation board */
|
||||
int main(void)
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
InitialiseLCD();
|
||||
ClearLCD();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -93,14 +95,8 @@ void timer_init(
|
||||
|
||||
/* 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
|
||||
);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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,7 +137,8 @@ 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 next_station = 255; /* return value */
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -175,8 +175,7 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +342,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;
|
||||
|
||||
@@ -387,7 +386,7 @@ void Device_Init(
|
||||
{
|
||||
struct my_object_functions *pObject = NULL;
|
||||
|
||||
(void)object_table;
|
||||
(void) object_table;
|
||||
pObject = &Object_Table[0];
|
||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||
if (pObject->Object_Init) {
|
||||
@@ -525,7 +524,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)
|
||||
{
|
||||
@@ -541,7 +540,7 @@ bool Device_Valid_Object_Name(
|
||||
for (i = 0; i < max_objects; i++) {
|
||||
check_id = Device_Object_List_Identifier(i, &type, &instance);
|
||||
if (check_id) {
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)type);
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) type);
|
||||
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
|
||||
(pObject->Object_Name(instance, &object_name2) &&
|
||||
characterstring_same(object_name1, &object_name2))) {
|
||||
@@ -567,7 +566,7 @@ bool Device_Valid_Object_Id(
|
||||
bool status = false; /* return value */
|
||||
struct my_object_functions *pObject = NULL;
|
||||
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)object_type);
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) object_type);
|
||||
if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
|
||||
status = pObject->Object_Valid_Instance(object_instance);
|
||||
}
|
||||
@@ -578,7 +577,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;
|
||||
@@ -591,7 +590,7 @@ bool Device_Object_Name_Copy(
|
||||
for (i = 0; i < max_objects; i++) {
|
||||
check_id = Device_Object_List_Identifier(i, &type, &instance);
|
||||
if (check_id) {
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)type);
|
||||
pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) type);
|
||||
if ((pObject != NULL) && (pObject->Object_Name != NULL)) {
|
||||
found = pObject->Object_Name(instance, object_name);
|
||||
break;
|
||||
@@ -816,8 +815,8 @@ bool Device_Write_Property_Local(
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
@@ -869,8 +868,8 @@ bool Device_Write_Property_Local(
|
||||
uint8_t encoding =
|
||||
characterstring_encoding(&value.type.Character_String);
|
||||
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
|
||||
characterstring_copy(&My_Object_Name, &value.type.
|
||||
Character_String);
|
||||
characterstring_copy(&My_Object_Name,
|
||||
&value.type.Character_String);
|
||||
status = true;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -206,22 +206,17 @@ static RING_BUFFER PDU_Queue;
|
||||
/* node, its value shall be 1. */
|
||||
static uint8_t Nmax_info_frames = MSTP_PDU_PACKET_COUNT;
|
||||
|
||||
void dlmstp_automac_hander(void);
|
||||
void dlmstp_automac_hander(
|
||||
void);
|
||||
|
||||
bool dlmstp_init(
|
||||
char *ifname)
|
||||
{
|
||||
ifname = ifname;
|
||||
Ringbuf_Init(
|
||||
&Transmit_Queue,
|
||||
(uint8_t *)&Transmit_Buffer,
|
||||
sizeof(struct mstp_tx_packet),
|
||||
MSTP_TRANSMIT_PACKET_COUNT);
|
||||
Ringbuf_Init(
|
||||
&PDU_Queue,
|
||||
(uint8_t *)&PDU_Buffer,
|
||||
sizeof(struct mstp_pdu_packet),
|
||||
MSTP_PDU_PACKET_COUNT);
|
||||
Ringbuf_Init(&Transmit_Queue, (uint8_t *) & Transmit_Buffer,
|
||||
sizeof(struct mstp_tx_packet), MSTP_TRANSMIT_PACKET_COUNT);
|
||||
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
|
||||
sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT);
|
||||
rs485_init();
|
||||
automac_init();
|
||||
|
||||
@@ -366,14 +361,14 @@ static bool dlmstp_compare_data_expecting_reply(
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
MSTP_TX_STATE_IDLE,
|
||||
MSTP_TX_STATE_SILENCE_WAIT,
|
||||
MSTP_TX_STATE_SEND_WAIT,
|
||||
MSTP_TX_STATE_STOP
|
||||
} MSTP_TX_STATE;
|
||||
static bool MSTP_Transmit_FSM(void)
|
||||
static bool MSTP_Transmit_FSM(
|
||||
void)
|
||||
{
|
||||
static MSTP_TX_STATE state = MSTP_TX_STATE_IDLE;
|
||||
static struct mstp_tx_packet *pkt;
|
||||
@@ -383,8 +378,9 @@ static bool MSTP_Transmit_FSM(void)
|
||||
case MSTP_TX_STATE_IDLE:
|
||||
if (!Ringbuf_Empty(&Transmit_Queue)) {
|
||||
/* get the packet - but don't remove it from queue */
|
||||
pkt = (struct mstp_tx_packet *)Ringbuf_Get_Front(
|
||||
&Transmit_Queue);
|
||||
pkt =
|
||||
(struct mstp_tx_packet *)
|
||||
Ringbuf_Get_Front(&Transmit_Queue);
|
||||
state = MSTP_TX_STATE_SILENCE_WAIT;
|
||||
}
|
||||
break;
|
||||
@@ -415,7 +411,7 @@ static bool MSTP_Transmit_FSM(void)
|
||||
if (rs485_byte_sent() && rs485_frame_sent()) {
|
||||
rs485_rts_enable(false);
|
||||
/* remove the packet from the queue */
|
||||
(void)Ringbuf_Pop_Front(&Transmit_Queue);
|
||||
(void) Ringbuf_Pop_Front(&Transmit_Queue);
|
||||
state = MSTP_TX_STATE_IDLE;
|
||||
}
|
||||
break;
|
||||
@@ -452,8 +448,7 @@ static void MSTP_Send_Frame(
|
||||
static struct mstp_tx_packet *pkt;
|
||||
uint16_t i = 0; /* used to calculate CRC for data */
|
||||
|
||||
pkt = (struct mstp_tx_packet *)Ringbuf_Alloc(
|
||||
&Transmit_Queue);
|
||||
pkt = (struct mstp_tx_packet *) Ringbuf_Alloc(&Transmit_Queue);
|
||||
if (pkt) {
|
||||
/* create the MS/TP header */
|
||||
pkt->buffer[0] = 0x55;
|
||||
@@ -474,11 +469,11 @@ static void MSTP_Send_Frame(
|
||||
/* calculate CRC for any data */
|
||||
for (i = 0; i < data_len; i++) {
|
||||
crc16 = CRC_Calc_Data(data[i], crc16);
|
||||
pkt->buffer[8+i] = data[i];
|
||||
pkt->buffer[8 + i] = data[i];
|
||||
}
|
||||
crc16 = ~crc16;
|
||||
pkt->buffer[8+data_len] = (crc16 & 0x00FF);
|
||||
pkt->buffer[8+data_len+1] = ((crc16 & 0xFF00) >> 8);
|
||||
pkt->buffer[8 + data_len] = (crc16 & 0x00FF);
|
||||
pkt->buffer[8 + data_len + 1] = ((crc16 & 0xFF00) >> 8);
|
||||
pkt->length += data_len;
|
||||
pkt->length += 2;
|
||||
}
|
||||
@@ -630,13 +625,15 @@ static void MSTP_Receive_Frame_FSM(
|
||||
} else {
|
||||
/* receive the data portion of the frame. */
|
||||
if ((DestinationAddress == This_Station) ||
|
||||
(DestinationAddress == MSTP_BROADCAST_ADDRESS)) {
|
||||
(DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
if (DataLength <= InputBufferSize) {
|
||||
/* Data */
|
||||
Receive_State = MSTP_RECEIVE_STATE_DATA;
|
||||
} else {
|
||||
/* FrameTooLong */
|
||||
Receive_State = MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
Receive_State =
|
||||
MSTP_RECEIVE_STATE_SKIP_DATA;
|
||||
}
|
||||
} else {
|
||||
/* NotForUs */
|
||||
@@ -877,8 +874,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
transition_now = true;
|
||||
} else {
|
||||
uint8_t frame_type;
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Pop_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
|
||||
if (pkt->data_expecting_reply) {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||
} else {
|
||||
@@ -987,8 +983,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* then the next station to which the token
|
||||
should be sent is unknown - so PollForMaster */
|
||||
Poll_Station = next_this_station;
|
||||
MSTP_Send_Frame(
|
||||
FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
|
||||
This_Station, NULL, 0);
|
||||
RetryCount = 0;
|
||||
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
|
||||
@@ -1214,12 +1209,11 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* Note: we could wait for up to Treply_delay */
|
||||
matched = false;
|
||||
if (!Ringbuf_Empty(&PDU_Queue)) {
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Get_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue);
|
||||
matched =
|
||||
dlmstp_compare_data_expecting_reply(&InputBuffer[0],
|
||||
DataLength, SourceAddress, &pkt->buffer[0],
|
||||
pkt->length, pkt->destination_mac);
|
||||
DataLength, SourceAddress, &pkt->buffer[0], pkt->length,
|
||||
pkt->destination_mac);
|
||||
}
|
||||
if (matched) {
|
||||
/* Reply */
|
||||
@@ -1230,8 +1224,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* then call MSTP_Send_Frame to transmit the reply frame */
|
||||
/* and enter the IDLE state to wait for the next frame. */
|
||||
uint8_t frame_type;
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Pop_Front(
|
||||
&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Pop_Front(&PDU_Queue);
|
||||
if (pkt->data_expecting_reply) {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY;
|
||||
} else {
|
||||
@@ -1276,7 +1269,7 @@ int dlmstp_send_pdu(
|
||||
struct mstp_pdu_packet *pkt;
|
||||
uint16_t i = 0;
|
||||
|
||||
pkt = (struct mstp_pdu_packet *)Ringbuf_Alloc(&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Alloc(&PDU_Queue);
|
||||
if (pkt) {
|
||||
pkt->data_expecting_reply = npdu_data->data_expecting_reply;
|
||||
for (i = 0; i < pdu_len; i++) {
|
||||
@@ -1300,7 +1293,8 @@ typedef enum {
|
||||
} AUTOMAC_STATE;
|
||||
/* buffer used to send and validate a response - size is min APDU size */
|
||||
static uint8_t AutoMAC_Test_Buffer[50];
|
||||
void dlmstp_automac_hander(void)
|
||||
void dlmstp_automac_hander(
|
||||
void)
|
||||
{
|
||||
static AUTOMAC_STATE state = AUTOMAC_STATE_IDLE;
|
||||
uint8_t mac = 0;
|
||||
@@ -1360,7 +1354,8 @@ void dlmstp_automac_hander(void)
|
||||
automac_init();
|
||||
state = AUTOMAC_STATE_IDLE;
|
||||
} else if (mac == DestinationAddress) {
|
||||
MSTP_Send_Frame(FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER,
|
||||
MSTP_Send_Frame
|
||||
(FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER,
|
||||
SourceAddress, mac, NULL, 0);
|
||||
state = AUTOMAC_STATE_TOKEN;
|
||||
}
|
||||
@@ -1433,9 +1428,8 @@ void dlmstp_automac_hander(void)
|
||||
encode_unsigned16(&AutoMAC_Test_Buffer[0], vendor_id);
|
||||
serial_number = Device_Object_Instance_Number();
|
||||
encode_unsigned32(&AutoMAC_Test_Buffer[2], serial_number);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TEST_REQUEST,
|
||||
SourceAddress, mac, &AutoMAC_Test_Buffer[0],
|
||||
6);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TEST_REQUEST, SourceAddress, mac,
|
||||
&AutoMAC_Test_Buffer[0], 6);
|
||||
state = AUTOMAC_STATE_CONFIRM;
|
||||
break;
|
||||
case AUTOMAC_STATE_CONFIRM:
|
||||
@@ -1448,8 +1442,7 @@ void dlmstp_automac_hander(void)
|
||||
MSTP_Flag.ReceivedValidFrame = false;
|
||||
MSTP_Flag.ReceivedValidFrameNotForUs = false;
|
||||
mac = automac_address();
|
||||
if ((mac == DestinationAddress) &&
|
||||
(DataLength >= 6)) {
|
||||
if ((mac == DestinationAddress) && (DataLength >= 6)) {
|
||||
decode_unsigned16(&InputBuffer[0], &vendor_id);
|
||||
decode_unsigned32(&InputBuffer[2], &serial_number);
|
||||
if ((vendor_id == Device_Vendor_Identifier()) &&
|
||||
@@ -1511,18 +1504,14 @@ uint16_t dlmstp_receive(
|
||||
/* only do receive state machine while we don't have a frame */
|
||||
if ((MSTP_Flag.ReceivedValidFrame == false) &&
|
||||
(MSTP_Flag.ReceivedValidFrameNotForUs == false) &&
|
||||
(MSTP_Flag.ReceivedInvalidFrame == false) &&
|
||||
(transmitting == false)) {
|
||||
(MSTP_Flag.ReceivedInvalidFrame == false) && (transmitting == false)) {
|
||||
MSTP_Receive_Frame_FSM();
|
||||
}
|
||||
/* only do master state machine while rx is idle */
|
||||
if ((Receive_State == MSTP_RECEIVE_STATE_IDLE) &&
|
||||
(transmitting == false)) {
|
||||
if ((This_Station != 255) &&
|
||||
(MSTP_Flag.ReceivedValidFrameNotForUs)) {
|
||||
if ((Receive_State == MSTP_RECEIVE_STATE_IDLE) && (transmitting == false)) {
|
||||
if ((This_Station != 255) && (MSTP_Flag.ReceivedValidFrameNotForUs)) {
|
||||
MSTP_Flag.ReceivedValidFrameNotForUs = false;
|
||||
if ((SourceAddress == This_Station) &&
|
||||
automac_enabled()) {
|
||||
if ((SourceAddress == This_Station) && automac_enabled()) {
|
||||
/* duplicate MAC on the wire */
|
||||
automac_init();
|
||||
This_Station = 255;
|
||||
@@ -1602,8 +1591,7 @@ void dlmstp_set_max_master(
|
||||
uint8_t max_master)
|
||||
{
|
||||
if (max_master <= 127) {
|
||||
if ((This_Station == 255) ||
|
||||
(This_Station <= max_master)) {
|
||||
if ((This_Station == 255) || (This_Station <= max_master)) {
|
||||
Nmax_master = max_master;
|
||||
}
|
||||
}
|
||||
@@ -1651,7 +1639,8 @@ void dlmstp_get_broadcast_address(
|
||||
return;
|
||||
}
|
||||
|
||||
bool dlmstp_sole_master(void)
|
||||
bool dlmstp_sole_master(
|
||||
void)
|
||||
{
|
||||
if (MSTP_Flag.SoleMaster) {
|
||||
return true;
|
||||
@@ -1659,4 +1648,3 @@ bool dlmstp_sole_master(void)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,8 @@ void led_rx_off(
|
||||
* Returns: true if on, false if off.
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool led_rx_state(void)
|
||||
bool led_rx_state(
|
||||
void)
|
||||
{
|
||||
return Rx_State;
|
||||
}
|
||||
@@ -99,7 +100,8 @@ bool led_rx_state(void)
|
||||
* Returns: true if on, false if off.
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool led_tx_state(void)
|
||||
bool led_tx_state(
|
||||
void)
|
||||
{
|
||||
return Tx_State;
|
||||
}
|
||||
@@ -109,7 +111,8 @@ bool led_tx_state(void)
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void led_tx_toggle(void)
|
||||
void led_tx_toggle(
|
||||
void)
|
||||
{
|
||||
if (led_tx_state()) {
|
||||
led_tx_off();
|
||||
@@ -123,7 +126,8 @@ void led_tx_toggle(void)
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void led_rx_toggle(void)
|
||||
void led_rx_toggle(
|
||||
void)
|
||||
{
|
||||
if (led_rx_state()) {
|
||||
led_rx_off();
|
||||
@@ -247,7 +251,8 @@ void led_ld3_off(
|
||||
* Returns: true if on, false if off.
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool led_ld3_state(void)
|
||||
bool led_ld3_state(
|
||||
void)
|
||||
{
|
||||
return LD3_State;
|
||||
}
|
||||
@@ -257,7 +262,8 @@ bool led_ld3_state(void)
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void led_ld3_toggle(void)
|
||||
void led_ld3_toggle(
|
||||
void)
|
||||
{
|
||||
if (led_ld3_state()) {
|
||||
led_ld3_off();
|
||||
|
||||
@@ -39,30 +39,40 @@ extern "C" {
|
||||
void);
|
||||
void led_ld4_off(
|
||||
void);
|
||||
bool led_ld3_state(void);
|
||||
void led_ld3_toggle(void);
|
||||
bool led_ld3_state(
|
||||
void);
|
||||
void led_ld3_toggle(
|
||||
void);
|
||||
|
||||
void led_tx_on(void);
|
||||
void led_rx_on(void);
|
||||
void led_tx_on(
|
||||
void);
|
||||
void led_rx_on(
|
||||
void);
|
||||
|
||||
void led_tx_on_interval(
|
||||
uint16_t interval_ms);
|
||||
void led_rx_on_interval(
|
||||
uint16_t interval_ms);
|
||||
|
||||
void led_tx_off(void);
|
||||
void led_rx_off(void);
|
||||
void led_tx_off(
|
||||
void);
|
||||
void led_rx_off(
|
||||
void);
|
||||
|
||||
void led_tx_off_delay(
|
||||
uint32_t delay_ms);
|
||||
void led_rx_off_delay(
|
||||
uint32_t delay_ms);
|
||||
|
||||
void led_tx_toggle(void);
|
||||
void led_rx_toggle(void);
|
||||
void led_tx_toggle(
|
||||
void);
|
||||
void led_rx_toggle(
|
||||
void);
|
||||
|
||||
bool led_tx_state(void);
|
||||
bool led_rx_state(void);
|
||||
bool led_tx_state(
|
||||
void);
|
||||
bool led_rx_state(
|
||||
void);
|
||||
|
||||
void led_task(
|
||||
void);
|
||||
|
||||
@@ -44,14 +44,15 @@ char *BACnet_Version = "1.0";
|
||||
* @param line: assert_param error line source number
|
||||
* @retval None
|
||||
*/
|
||||
void assert_failed(uint8_t* file, uint32_t line)
|
||||
void assert_failed(
|
||||
uint8_t * file,
|
||||
uint32_t line)
|
||||
{
|
||||
/* User can add his own implementation to report the file name and line number,
|
||||
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
|
||||
/* Infinite loop */
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -60,7 +61,8 @@ void assert_failed(uint8_t* file, uint32_t line)
|
||||
#define LSE_FAIL_FLAG 0x80
|
||||
#define LSE_PASS_FLAG 0x100
|
||||
|
||||
void lse_init(void)
|
||||
void lse_init(
|
||||
void)
|
||||
{
|
||||
uint32_t LSE_Delay = 0;
|
||||
struct etimer Delay_Timer;
|
||||
@@ -71,18 +73,15 @@ void lse_init(void)
|
||||
RCC_LSEConfig(RCC_LSE_ON);
|
||||
|
||||
/* Check the LSE Status */
|
||||
while(1)
|
||||
{
|
||||
if(LSE_Delay < LSE_FAIL_FLAG)
|
||||
{
|
||||
while (1) {
|
||||
if (LSE_Delay < LSE_FAIL_FLAG) {
|
||||
timer_elapsed_start(&Delay_Timer);
|
||||
while (!timer_elapsed_milliseconds(&Delay_Timer,500)) {
|
||||
while (!timer_elapsed_milliseconds(&Delay_Timer, 500)) {
|
||||
/* do nothing */
|
||||
}
|
||||
/* check whether LSE is ready, with 4 seconds timeout */
|
||||
LSE_Delay += 0x10;
|
||||
if(RCC_GetFlagStatus(RCC_FLAG_LSERDY) != RESET)
|
||||
{
|
||||
if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) != RESET) {
|
||||
/* Set flag: LSE PASS */
|
||||
LSE_Delay |= LSE_PASS_FLAG;
|
||||
led_ld4_off();
|
||||
@@ -93,10 +92,8 @@ void lse_init(void)
|
||||
}
|
||||
|
||||
/* LSE_FAIL_FLAG = 0x80 */
|
||||
else if(LSE_Delay >= LSE_FAIL_FLAG)
|
||||
{
|
||||
if(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
|
||||
{
|
||||
else if (LSE_Delay >= LSE_FAIL_FLAG) {
|
||||
if (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {
|
||||
/* Set flag: LSE FAIL */
|
||||
LSE_Delay |= LSE_FAIL_FLAG;
|
||||
led_ld4_on();
|
||||
@@ -121,10 +118,9 @@ int main(
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
||||
led_init();
|
||||
RCC_APB2PeriphClockCmd(
|
||||
RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
|
||||
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
|
||||
RCC_APB2Periph_GPIOE, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
|
||||
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE,
|
||||
ENABLE);
|
||||
timer_init();
|
||||
lse_init();
|
||||
led_init();
|
||||
|
||||
@@ -58,7 +58,8 @@ static uint32_t Baud_Rate = 38400;
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
void rs485_silence_reset(void)
|
||||
void rs485_silence_reset(
|
||||
void)
|
||||
{
|
||||
timer_elapsed_start(&Silence_Timer);
|
||||
}
|
||||
@@ -68,7 +69,8 @@ void rs485_silence_reset(void)
|
||||
* Returns: true if the amount of time has elapsed
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
bool rs485_silence_elapsed(uint32_t interval)
|
||||
bool rs485_silence_elapsed(
|
||||
uint32_t interval)
|
||||
{
|
||||
return timer_elapsed_milliseconds(&Silence_Timer, interval);
|
||||
}
|
||||
@@ -95,9 +97,7 @@ static uint16_t rs485_turnaround_time(
|
||||
bool rs485_turnaround_elapsed(
|
||||
void)
|
||||
{
|
||||
return timer_elapsed_milliseconds(
|
||||
&Silence_Timer,
|
||||
rs485_turnaround_time());
|
||||
return timer_elapsed_milliseconds(&Silence_Timer, rs485_turnaround_time());
|
||||
}
|
||||
|
||||
|
||||
@@ -112,20 +112,21 @@ bool rs485_receive_error(
|
||||
return false;
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
/*********************************************************************//**
|
||||
* @brief USARTx interrupt handler sub-routine
|
||||
* @param[in] None
|
||||
* @return None
|
||||
**********************************************************************/
|
||||
void USART2_IRQHandler(void)
|
||||
void USART2_IRQHandler(
|
||||
void)
|
||||
{
|
||||
uint8_t data_byte;
|
||||
|
||||
|
||||
if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) {
|
||||
if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) {
|
||||
/* Read one byte from the receive data register */
|
||||
data_byte = USART_ReceiveData(USART2);
|
||||
(void)FIFO_Put(&Receive_Buffer, data_byte);
|
||||
(void) FIFO_Put(&Receive_Buffer, data_byte);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +155,8 @@ bool rs485_byte_available(
|
||||
* RETURN: nothing
|
||||
* NOTES: none
|
||||
**************************************************************************/
|
||||
void rs485_byte_send(uint8_t tx_byte)
|
||||
void rs485_byte_send(
|
||||
uint8_t tx_byte)
|
||||
{
|
||||
led_tx_on_interval(10);
|
||||
USART_SendData(USART2, tx_byte);
|
||||
@@ -167,7 +169,8 @@ void rs485_byte_send(uint8_t tx_byte)
|
||||
* Returns: true if the USART register is empty
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
bool rs485_byte_sent(void)
|
||||
bool rs485_byte_sent(
|
||||
void)
|
||||
{
|
||||
return USART_GetFlagStatus(USART2, USART_FLAG_TXE);
|
||||
}
|
||||
@@ -177,7 +180,8 @@ bool rs485_byte_sent(void)
|
||||
* Returns: true if the USART FIFO is empty
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
bool rs485_frame_sent(void)
|
||||
bool rs485_frame_sent(
|
||||
void)
|
||||
{
|
||||
return USART_GetFlagStatus(USART2, USART_FLAG_TC);
|
||||
}
|
||||
@@ -189,8 +193,8 @@ bool rs485_frame_sent(void)
|
||||
**************************************************************************/
|
||||
void rs485_bytes_send(
|
||||
uint8_t * buffer, /* data to send */
|
||||
uint16_t nbytes) /* number of bytes of data */
|
||||
{
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data */
|
||||
uint8_t tx_byte;
|
||||
|
||||
while (nbytes) {
|
||||
@@ -295,7 +299,8 @@ void rs485_rts_enable(
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
void rs485_init(void)
|
||||
void rs485_init(
|
||||
void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
@@ -335,6 +340,6 @@ void rs485_init(void)
|
||||
USART_Cmd(USART2, ENABLE);
|
||||
|
||||
FIFO_Init(&Receive_Buffer, &Receive_Buffer_Data[0],
|
||||
(unsigned)sizeof(Receive_Buffer_Data));
|
||||
(unsigned) sizeof(Receive_Buffer_Data));
|
||||
timer_elapsed_start(&Silence_Timer);
|
||||
}
|
||||
|
||||
@@ -52,13 +52,17 @@ extern "C" {
|
||||
/* a granular approach */
|
||||
void rs485_byte_send(
|
||||
uint8_t data_register);
|
||||
bool rs485_byte_sent(void);
|
||||
bool rs485_frame_sent(void);
|
||||
bool rs485_byte_sent(
|
||||
void);
|
||||
bool rs485_frame_sent(
|
||||
void);
|
||||
bool rs485_turnaround_elapsed(
|
||||
void);
|
||||
|
||||
void rs485_silence_reset(void);
|
||||
bool rs485_silence_elapsed(uint32_t interval);
|
||||
void rs485_silence_reset(
|
||||
void);
|
||||
bool rs485_silence_elapsed(
|
||||
uint32_t interval);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -62,11 +62,13 @@
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
void assert_failed(
|
||||
uint8_t * file,
|
||||
uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* __STM32F10x_CONF_H */
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
void NMI_Handler(
|
||||
void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,11 +57,11 @@ void NMI_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
void HardFault_Handler(
|
||||
void)
|
||||
{
|
||||
/* Go to infinite loop when Hard Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +70,11 @@ void HardFault_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
void MemManage_Handler(
|
||||
void)
|
||||
{
|
||||
/* Go to infinite loop when Memory Manage exception occurs */
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +83,11 @@ void MemManage_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
void BusFault_Handler(
|
||||
void)
|
||||
{
|
||||
/* Go to infinite loop when Bus Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,11 +96,11 @@ void BusFault_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
void UsageFault_Handler(
|
||||
void)
|
||||
{
|
||||
/* Go to infinite loop when Usage Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +109,8 @@ void UsageFault_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SVC_Handler(void)
|
||||
void SVC_Handler(
|
||||
void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -117,7 +119,8 @@ void SVC_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
void DebugMon_Handler(
|
||||
void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -126,7 +129,8 @@ void DebugMon_Handler(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void PendSV_Handler(void)
|
||||
void PendSV_Handler(
|
||||
void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,22 @@
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void NMI_Handler(
|
||||
void);
|
||||
void HardFault_Handler(
|
||||
void);
|
||||
void MemManage_Handler(
|
||||
void);
|
||||
void BusFault_Handler(
|
||||
void);
|
||||
void UsageFault_Handler(
|
||||
void);
|
||||
void SVC_Handler(
|
||||
void);
|
||||
void DebugMon_Handler(
|
||||
void);
|
||||
void PendSV_Handler(
|
||||
void);
|
||||
|
||||
#endif /* __STM32F10x_IT_H */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,8 @@ static void timer_debug_off(
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_debug_toggle(void)
|
||||
void timer_debug_toggle(
|
||||
void)
|
||||
{
|
||||
static bool state = false;
|
||||
|
||||
@@ -79,7 +80,8 @@ void timer_debug_toggle(void)
|
||||
* Returns: nothing
|
||||
* Notes: reserved name for ISR handlers
|
||||
*************************************************************************/
|
||||
void SysTick_Handler(void)
|
||||
void SysTick_Handler(
|
||||
void)
|
||||
{
|
||||
/* increment the tick count */
|
||||
Millisecond_Counter++;
|
||||
@@ -91,7 +93,8 @@ void SysTick_Handler(void)
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_milliseconds(void)
|
||||
uint32_t timer_milliseconds(
|
||||
void)
|
||||
{
|
||||
return Millisecond_Counter;
|
||||
}
|
||||
@@ -101,7 +104,8 @@ uint32_t timer_milliseconds(void)
|
||||
* Returns: none
|
||||
* Notes: peripheral frequency defined in hardware.h
|
||||
*************************************************************************/
|
||||
void timer_init(void)
|
||||
void timer_init(
|
||||
void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
/* Offset between Windows epoch 1/1/1601 and
|
||||
Unix epoch 1/1/1970 in 100 nanosec units */
|
||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
||||
#else
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||
#endif
|
||||
|
||||
/* counter for the various timers */
|
||||
@@ -81,16 +81,16 @@ int gettimeofday(
|
||||
usec_timer <<= 32;
|
||||
usec_timer |= ft.dwLowDateTime;
|
||||
/*converting file time to unix epoch 1970 */
|
||||
usec_timer /= 10; /*convert into microseconds*/
|
||||
usec_timer /= 10; /*convert into microseconds */
|
||||
usec_timer -= DELTA_EPOCH_IN_MICROSECS;
|
||||
tp->tv_sec = (long)(usec_timer / 1000000UL);
|
||||
tp->tv_usec = (long)(usec_timer % 1000000UL);
|
||||
tp->tv_sec = (long) (usec_timer / 1000000UL);
|
||||
tp->tv_usec = (long) (usec_timer % 1000000UL);
|
||||
time_start = timeGetTime();
|
||||
} else {
|
||||
elapsed_milliseconds = timeGetTime() - time_start;
|
||||
usec_elapsed = usec_timer + (elapsed_milliseconds * 1000UL);
|
||||
tp->tv_sec = (long)(usec_elapsed / 1000000UL);
|
||||
tp->tv_usec = (long)(usec_elapsed % 1000000UL);
|
||||
tp->tv_sec = (long) (usec_elapsed / 1000000UL);
|
||||
tp->tv_usec = (long) (usec_elapsed % 1000000UL);
|
||||
}
|
||||
if (tzp) {
|
||||
if (!tzflag) {
|
||||
@@ -207,8 +207,9 @@ void timer_init(
|
||||
/* configure for 1ms resolution - if possible */
|
||||
Timer_Period = min(max(tc.wPeriodMin, 1L), tc.wPeriodMax);
|
||||
if (Timer_Period != 1L) {
|
||||
fprintf(stderr, "Failed to set timer to 1ms. "
|
||||
"Time period set to %ums\n", (unsigned)Timer_Period);
|
||||
fprintf(stderr,
|
||||
"Failed to set timer to 1ms. " "Time period set to %ums\n",
|
||||
(unsigned) Timer_Period);
|
||||
}
|
||||
timeBeginPeriod(Timer_Period);
|
||||
atexit(timer_cleanup);
|
||||
@@ -234,7 +235,7 @@ int main(
|
||||
{
|
||||
long now = 0, last = 0, delta = 0;
|
||||
struct timeval tv;
|
||||
struct timeval old_tv = {0};
|
||||
struct timeval old_tv = { 0 };
|
||||
|
||||
timer_init();
|
||||
printf("Testing granularity of timeGetTime()...\n");
|
||||
|
||||
@@ -149,7 +149,8 @@ static struct Address_Cache_Entry *address_remove_oldest(
|
||||
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
if ((pMatch->
|
||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
ulTime = pMatch->TimeToLive;
|
||||
@@ -168,7 +169,8 @@ static struct Address_Cache_Entry *address_remove_oldest(
|
||||
/* Second pass - try in use and un bound as last resort */
|
||||
pMatch = Address_Cache;
|
||||
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
if ((pMatch->
|
||||
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
|
||||
BAC_ADDR_STATIC)) ==
|
||||
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
|
||||
+12
-12
@@ -1008,8 +1008,8 @@ bool bacapp_print_value(
|
||||
case PROP_OBJECT_TYPE:
|
||||
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_object_type_name(value->
|
||||
type.Enumerated));
|
||||
bactext_object_type_name(value->type.
|
||||
Enumerated));
|
||||
} else if (value->type.Enumerated < 128) {
|
||||
fprintf(stream, "reserved %lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
@@ -1025,8 +1025,8 @@ bool bacapp_print_value(
|
||||
case PROP_UNITS:
|
||||
if (value->type.Enumerated < 256) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_engineering_unit_name(value->type.
|
||||
Enumerated));
|
||||
bactext_engineering_unit_name(value->
|
||||
type.Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "proprietary %lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
@@ -1034,14 +1034,14 @@ bool bacapp_print_value(
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_polarity_name(value->type.
|
||||
Enumerated));
|
||||
bactext_binary_polarity_name(value->
|
||||
type.Enumerated));
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_present_value_name(value->
|
||||
type.Enumerated));
|
||||
bactext_binary_present_value_name(value->type.
|
||||
Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "%lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
@@ -1053,8 +1053,8 @@ bool bacapp_print_value(
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
fprintf(stream, "%s",
|
||||
bactext_device_status_name(value->type.
|
||||
Enumerated));
|
||||
bactext_device_status_name(value->
|
||||
type.Enumerated));
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
fprintf(stream, "%s",
|
||||
@@ -1425,8 +1425,8 @@ void testBACnetApplicationData_Safe(
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||
characterstring_init_ansi(&input_value[i].
|
||||
type.Character_String, "Hello There!");
|
||||
characterstring_init_ansi(&input_value[i].type.
|
||||
Character_String, "Hello There!");
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||
|
||||
@@ -2277,8 +2277,7 @@ void testBACDCodeObject(
|
||||
uint32_t decoded_instance = 0;
|
||||
|
||||
encode_bacnet_object_id(&encoded_array[0], type, instance);
|
||||
decode_object_id(&encoded_array[0], &decoded_type,
|
||||
&decoded_instance);
|
||||
decode_object_id(&encoded_array[0], &decoded_type, &decoded_instance);
|
||||
ct_test(pTest, decoded_type == type);
|
||||
ct_test(pTest, decoded_instance == instance);
|
||||
encode_bacnet_object_id(&object_array[0], type, instance);
|
||||
|
||||
@@ -51,8 +51,7 @@ int bacapp_decode_property_state(
|
||||
uint8_t tagnum;
|
||||
|
||||
section_length =
|
||||
decode_tag_number_and_value(&apdu[len], &tagnum,
|
||||
&len_value_type);
|
||||
decode_tag_number_and_value(&apdu[len], &tagnum, &len_value_type);
|
||||
|
||||
if (-1 == section_length) {
|
||||
return -1;
|
||||
|
||||
+33
-18
@@ -496,26 +496,36 @@ bool characterstring_printable(
|
||||
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) {
|
||||
@@ -543,35 +553,40 @@ static int utf8_isvalid(const char *str, int length)
|
||||
switch (ab) {
|
||||
/* Check for xx00 000x */
|
||||
case 1:
|
||||
if ((c & 0x3e) == 0) return 0;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -656,8 +656,8 @@ static void bvlc_bdt_forward_npdu(
|
||||
mask in the BDT entry and logically ORing it with the
|
||||
BBMD address of the same entry. */
|
||||
bip_dest.sin_addr.s_addr =
|
||||
((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
|
||||
dest_address.s_addr);
|
||||
((~BBMD_Table[i].broadcast_mask.
|
||||
s_addr) | BBMD_Table[i].dest_address.s_addr);
|
||||
bip_dest.sin_port = BBMD_Table[i].dest_port;
|
||||
/* don't send to my broadcast address and same port */
|
||||
if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr())
|
||||
|
||||
+161
-154
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 0,
|
||||
&data->notificationParams.changeOfBitstring.
|
||||
referencedBitString);
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.referencedBitString);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.changeOfBitstring.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.changeOfState.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfState.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 1);
|
||||
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
|
||||
case CHANGE_OF_VALUE_REAL:
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 1,
|
||||
data->notificationParams.changeOfValue.
|
||||
newValue.changeValue);
|
||||
data->notificationParams.
|
||||
changeOfValue.newValue.changeValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len],
|
||||
0,
|
||||
&data->notificationParams.changeOfValue.
|
||||
newValue.changedBits);
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changedBits);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.changeOfValue.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfValue.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 2);
|
||||
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 0,
|
||||
data->notificationParams.floatingLimit.
|
||||
referenceValue);
|
||||
data->notificationParams.
|
||||
floatingLimit.referenceValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.floatingLimit.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
floatingLimit.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 2,
|
||||
data->notificationParams.floatingLimit.
|
||||
setPointValue);
|
||||
data->notificationParams.
|
||||
floatingLimit.setPointValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_real(&apdu[apdu_len], 0,
|
||||
data->notificationParams.outOfRange.
|
||||
exceedingValue);
|
||||
data->notificationParams.
|
||||
outOfRange.exceedingValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
newState);
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.newState);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 1,
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
newMode);
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.newMode);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 2,
|
||||
&data->notificationParams.changeOfLifeSafety.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
changeOfLifeSafety.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 3,
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected);
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.operationExpected);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 8);
|
||||
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu
|
||||
[apdu_len], 0,
|
||||
&data->notificationParams.bufferReady.
|
||||
bufferProperty);
|
||||
&data->notificationParams.
|
||||
bufferReady.bufferProperty);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 1,
|
||||
data->notificationParams.bufferReady.
|
||||
previousNotification);
|
||||
data->notificationParams.
|
||||
bufferReady.previousNotification);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.bufferReady.
|
||||
currentNotification);
|
||||
data->notificationParams.
|
||||
bufferReady.currentNotification);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 10);
|
||||
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 0,
|
||||
data->notificationParams.unsignedRange.
|
||||
exceedingValue);
|
||||
data->notificationParams.
|
||||
unsignedRange.exceedingValue);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.unsignedRange.
|
||||
statusFlags);
|
||||
&data->notificationParams.
|
||||
unsignedRange.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.unsignedRange.
|
||||
exceededLimit);
|
||||
data->notificationParams.
|
||||
unsignedRange.exceededLimit);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], 11);
|
||||
@@ -595,16 +595,18 @@ int event_notify_decode_service_request(
|
||||
case EVENT_CHANGE_OF_BITSTRING:
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.referencedBitString))) {
|
||||
&data->
|
||||
notificationParams.changeOfBitstring.
|
||||
referencedBitString))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfBitstring.statusFlags))) {
|
||||
&data->
|
||||
notificationParams.changeOfBitstring.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -615,16 +617,16 @@ int event_notify_decode_service_request(
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_property_state(&apdu
|
||||
[len], 0,
|
||||
&data->notificationParams.changeOfState.
|
||||
newState))) {
|
||||
&data->notificationParams.
|
||||
changeOfState.newState))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.changeOfState.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
changeOfState.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -642,8 +644,9 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 0,
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changedBits))) {
|
||||
&data->
|
||||
notificationParams.changeOfValue.
|
||||
newValue.changedBits))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -654,8 +657,9 @@ int event_notify_decode_service_request(
|
||||
CHANGE_OF_VALUE_REAL)) {
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
changeOfValue.newValue.changeValue))) {
|
||||
&data->
|
||||
notificationParams.changeOfValue.
|
||||
newValue.changeValue))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -673,8 +677,8 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.changeOfValue.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
changeOfValue.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -683,31 +687,31 @@ int event_notify_decode_service_request(
|
||||
case EVENT_FLOATING_LIMIT:
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 0,
|
||||
&data->notificationParams.floatingLimit.
|
||||
referenceValue))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.referenceValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.floatingLimit.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 2,
|
||||
&data->notificationParams.floatingLimit.
|
||||
setPointValue))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.setPointValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 3,
|
||||
&data->notificationParams.floatingLimit.
|
||||
errorLimit))) {
|
||||
&data->notificationParams.
|
||||
floatingLimit.errorLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -716,31 +720,31 @@ int event_notify_decode_service_request(
|
||||
case EVENT_OUT_OF_RANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 0,
|
||||
&data->notificationParams.outOfRange.
|
||||
exceedingValue))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.exceedingValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.outOfRange.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 2,
|
||||
&data->notificationParams.outOfRange.
|
||||
deadband))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.deadband))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_real(&apdu[len], 3,
|
||||
&data->notificationParams.outOfRange.
|
||||
exceededLimit))) {
|
||||
&data->notificationParams.
|
||||
outOfRange.exceededLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -768,8 +772,9 @@ int event_notify_decode_service_request(
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
changeOfLifeSafety.statusFlags))) {
|
||||
&data->
|
||||
notificationParams.changeOfLifeSafety.
|
||||
statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -779,8 +784,8 @@ int event_notify_decode_service_request(
|
||||
&value))) {
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected =
|
||||
data->notificationParams.
|
||||
changeOfLifeSafety.operationExpected =
|
||||
(BACNET_LIFE_SAFETY_OPERATION) value;
|
||||
len += section_length;
|
||||
break;
|
||||
@@ -789,24 +794,24 @@ int event_notify_decode_service_request(
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_device_obj_property_ref
|
||||
(&apdu[len], 0,
|
||||
&data->notificationParams.bufferReady.
|
||||
bufferProperty))) {
|
||||
&data->notificationParams.
|
||||
bufferReady.bufferProperty))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 1,
|
||||
&data->notificationParams.bufferReady.
|
||||
previousNotification))) {
|
||||
&data->notificationParams.
|
||||
bufferReady.previousNotification))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.bufferReady.
|
||||
currentNotification))) {
|
||||
&data->notificationParams.
|
||||
bufferReady.currentNotification))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -815,24 +820,24 @@ int event_notify_decode_service_request(
|
||||
case EVENT_UNSIGNED_RANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 0,
|
||||
&data->notificationParams.unsignedRange.
|
||||
exceedingValue))) {
|
||||
&data->notificationParams.
|
||||
unsignedRange.exceedingValue))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.unsignedRange.
|
||||
statusFlags))) {
|
||||
&data->notificationParams.
|
||||
unsignedRange.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.unsignedRange.
|
||||
exceededLimit))) {
|
||||
&data->notificationParams.
|
||||
unsignedRange.exceededLimit))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -1020,8 +1025,8 @@ void testEventEventState(
|
||||
data.notificationParams.changeOfState.newState.state.units ==
|
||||
data2.notificationParams.changeOfState.newState.state.units);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfState.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfState.statusFlags,
|
||||
&data2.notificationParams.changeOfState.statusFlags));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1078,16 +1083,16 @@ void testEventEventState(
|
||||
|
||||
data.eventType = EVENT_CHANGE_OF_BITSTRING;
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 2, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString, 2, false);
|
||||
bitstring_init(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 2, true);
|
||||
bitstring_set_bit(&data.notificationParams.
|
||||
changeOfBitstring.referencedBitString, 2, false);
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
|
||||
|
||||
@@ -1110,12 +1115,13 @@ void testEventEventState(
|
||||
ct_test(pTest, inLen == outLen);
|
||||
testBaseEventState(pTest);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfBitstring.referencedBitString,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfBitstring.
|
||||
referencedBitString,
|
||||
&data2.notificationParams.changeOfBitstring.referencedBitString));
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfBitstring.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfBitstring.statusFlags,
|
||||
&data2.notificationParams.changeOfBitstring.statusFlags));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1154,8 +1160,8 @@ void testEventEventState(
|
||||
ct_test(pTest, inLen == outLen);
|
||||
testBaseEventState(pTest);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfValue.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfValue.statusFlags,
|
||||
&data2.notificationParams.changeOfValue.statusFlags));
|
||||
|
||||
ct_test(pTest,
|
||||
@@ -1174,16 +1180,16 @@ void testEventEventState(
|
||||
|
||||
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
|
||||
|
||||
bitstring_init(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 2, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits, 3, false);
|
||||
bitstring_init(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 0, true);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 1, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 2, false);
|
||||
bitstring_set_bit(&data.notificationParams.changeOfValue.
|
||||
newValue.changedBits, 3, false);
|
||||
|
||||
memset(buffer, 0, MAX_APDU);
|
||||
inLen = event_notify_encode_service_request(&buffer[0], &data);
|
||||
@@ -1195,16 +1201,17 @@ void testEventEventState(
|
||||
ct_test(pTest, inLen == outLen);
|
||||
testBaseEventState(pTest);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfValue.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfValue.statusFlags,
|
||||
&data2.notificationParams.changeOfValue.statusFlags));
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.changeOfValue.tag ==
|
||||
data2.notificationParams.changeOfValue.tag);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfValue.newValue.changedBits,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfValue.newValue.
|
||||
changedBits,
|
||||
&data2.notificationParams.changeOfValue.newValue.changedBits));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1254,8 +1261,8 @@ void testEventEventState(
|
||||
ct_test(pTest,
|
||||
data.notificationParams.floatingLimit.errorLimit ==
|
||||
data2.notificationParams.floatingLimit.errorLimit);
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.floatingLimit.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.floatingLimit.statusFlags,
|
||||
&data2.notificationParams.floatingLimit.statusFlags));
|
||||
|
||||
|
||||
@@ -1306,8 +1313,8 @@ void testEventEventState(
|
||||
ct_test(pTest,
|
||||
data.notificationParams.outOfRange.exceedingValue ==
|
||||
data2.notificationParams.outOfRange.exceedingValue);
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.outOfRange.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.outOfRange.statusFlags,
|
||||
&data2.notificationParams.outOfRange.statusFlags));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1361,8 +1368,8 @@ void testEventEventState(
|
||||
data.notificationParams.changeOfLifeSafety.operationExpected ==
|
||||
data2.notificationParams.changeOfLifeSafety.operationExpected);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.changeOfLifeSafety.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.changeOfLifeSafety.statusFlags,
|
||||
&data2.notificationParams.changeOfLifeSafety.statusFlags));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1408,8 +1415,8 @@ void testEventEventState(
|
||||
data.notificationParams.unsignedRange.exceededLimit ==
|
||||
data2.notificationParams.unsignedRange.exceededLimit);
|
||||
|
||||
ct_test(pTest, bitstring_same(
|
||||
&data.notificationParams.unsignedRange.statusFlags,
|
||||
ct_test(pTest,
|
||||
bitstring_same(&data.notificationParams.unsignedRange.statusFlags,
|
||||
&data2.notificationParams.unsignedRange.statusFlags));
|
||||
|
||||
/**********************************************************************************/
|
||||
@@ -1427,12 +1434,12 @@ void testEventEventState(
|
||||
data.notificationParams.bufferReady.currentNotification = 2345;
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
|
||||
OBJECT_DEVICE;
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance = 500;
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.instance = 500;
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
|
||||
OBJECT_ANALOG_INPUT;
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance = 100;
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance = 100;
|
||||
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
|
||||
PROP_PRESENT_VALUE;
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
|
||||
@@ -1457,34 +1464,34 @@ void testEventEventState(
|
||||
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
|
||||
instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
|
||||
type);
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
deviceIndentifier.type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
propertyIdentifier ==
|
||||
deviceIndentifier.instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
propertyIdentifier);
|
||||
deviceIndentifier.instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.instance);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.type ==
|
||||
data2.notificationParams.bufferReady.bufferProperty.
|
||||
objectIdentifier.type);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.
|
||||
bufferProperty.propertyIdentifier ==
|
||||
data2.notificationParams.bufferReady.
|
||||
bufferProperty.propertyIdentifier);
|
||||
|
||||
ct_test(pTest,
|
||||
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
|
||||
|
||||
@@ -642,8 +642,7 @@ void test_Unconfirmed_Private_Transfer_Request(
|
||||
len = uptransfer_encode_apdu(&apdu[0], &private_data);
|
||||
ct_test(pTest, len != 0);
|
||||
apdu_len = len;
|
||||
len =
|
||||
uptransfer_decode_apdu(&apdu[0], apdu_len, &test_data);
|
||||
len = uptransfer_decode_apdu(&apdu[0], apdu_len, &test_data);
|
||||
ct_test(pTest, len != -1);
|
||||
ct_test(pTest, test_data.vendorID == private_data.vendorID);
|
||||
ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber);
|
||||
|
||||
@@ -198,7 +198,7 @@ void Ringbuf_Init(
|
||||
/* test the ring buffer */
|
||||
void testRingAroundBuffer(
|
||||
Test * pTest,
|
||||
RING_BUFFER *test_buffer,
|
||||
RING_BUFFER * test_buffer,
|
||||
uint8_t * data_element,
|
||||
unsigned element_size,
|
||||
unsigned element_count)
|
||||
@@ -319,22 +319,14 @@ void testRingBuf(
|
||||
}
|
||||
ct_test(pTest, Ringbuf_Empty(&test_buffer));
|
||||
|
||||
testRingAroundBuffer(
|
||||
pTest,
|
||||
&test_buffer,
|
||||
data_element,
|
||||
element_size,
|
||||
testRingAroundBuffer(pTest, &test_buffer, data_element, element_size,
|
||||
element_count);
|
||||
|
||||
/* adjust the internal index of Ringbuf to test unsigned wrapping */
|
||||
test_buffer.head = UINT_MAX-1;
|
||||
test_buffer.tail = UINT_MAX-1;
|
||||
test_buffer.head = UINT_MAX - 1;
|
||||
test_buffer.tail = UINT_MAX - 1;
|
||||
|
||||
testRingAroundBuffer(
|
||||
pTest,
|
||||
&test_buffer,
|
||||
data_element,
|
||||
element_size,
|
||||
testRingAroundBuffer(pTest, &test_buffer, data_element, element_size,
|
||||
element_count);
|
||||
|
||||
return;
|
||||
|
||||
+56
-51
@@ -33,7 +33,9 @@
|
||||
/** @file wpm.c Encode/Decode BACnet Write Property Multiple APDUs */
|
||||
|
||||
/* decode service */
|
||||
int wpm_decode_object_id(uint8_t * apdu, uint16_t apdu_len,
|
||||
int wpm_decode_object_id(
|
||||
uint8_t * apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_WRITE_PROPERTY_DATA * data)
|
||||
{
|
||||
uint8_t tag_number = 0;
|
||||
@@ -42,27 +44,26 @@ int wpm_decode_object_id(uint8_t * apdu, uint16_t apdu_len,
|
||||
uint16_t object_type = 0;
|
||||
uint16_t len = 0;
|
||||
|
||||
if((apdu )&& (apdu_len))
|
||||
{
|
||||
if ((apdu) && (apdu_len)) {
|
||||
/* Context tag 0 - Object ID */
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if(tag_number == 0)
|
||||
{
|
||||
len += decode_object_id(&apdu[len], &object_type, &object_instance);
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if (tag_number == 0) {
|
||||
len +=
|
||||
decode_object_id(&apdu[len], &object_type, &object_instance);
|
||||
data->object_type = object_type;
|
||||
data->object_instance = object_instance;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
int wpm_decode_object_property(uint8_t * apdu,
|
||||
int wpm_decode_object_property(
|
||||
uint8_t * apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||
{
|
||||
@@ -72,68 +73,70 @@ int wpm_decode_object_property(uint8_t * apdu,
|
||||
int len = 0, i = 0;
|
||||
|
||||
|
||||
if((apdu) && (apdu_len) && (wp_data))
|
||||
{
|
||||
if ((apdu) && (apdu_len) && (wp_data)) {
|
||||
wp_data->array_index = BACNET_ARRAY_ALL;
|
||||
wp_data->priority = BACNET_MAX_PRIORITY;
|
||||
wp_data->application_data_len = 0;
|
||||
|
||||
/* tag 0 - Property Identifier */
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if(tag_number == 0)
|
||||
{
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if (tag_number == 0) {
|
||||
len += decode_enumerated(&apdu[len], len_value, &ulVal);
|
||||
wp_data->object_property = ulVal;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
|
||||
/* tag 1 - Property Array Index - optional */
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if(tag_number == 1)
|
||||
{
|
||||
len += decode_unsigned(&apdu[len],len_value, &ulVal);
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if (tag_number == 1) {
|
||||
len += decode_unsigned(&apdu[len], len_value, &ulVal);
|
||||
wp_data->array_index = ulVal;
|
||||
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value);
|
||||
}
|
||||
/* tag 2 - Property Value */
|
||||
if((tag_number == 2) && (decode_is_opening_tag(&apdu[len-1])))
|
||||
{
|
||||
if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) {
|
||||
len--;
|
||||
wp_data->application_data_len = bacapp_data_len(&apdu[len],
|
||||
apdu_len - len, wp_data->object_property);
|
||||
wp_data->application_data_len =
|
||||
bacapp_data_len(&apdu[len], apdu_len - len,
|
||||
wp_data->object_property);
|
||||
len++;
|
||||
|
||||
/* copy application data */
|
||||
for(i = 0; i < wp_data->application_data_len; i++)
|
||||
wp_data->application_data[i] = apdu[len+i];
|
||||
for (i = 0; i < wp_data->application_data_len; i++)
|
||||
wp_data->application_data[i] = apdu[len + i];
|
||||
len += wp_data->application_data_len;
|
||||
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value);
|
||||
/* closing tag 2 */
|
||||
if((tag_number != 2) &&(decode_is_closing_tag(&apdu[len-1])))
|
||||
if ((tag_number != 2) && (decode_is_closing_tag(&apdu[len - 1])))
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
|
||||
/* tag 3 - Priority - optional */
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if(tag_number == 3) {
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if (tag_number == 3) {
|
||||
len += decode_unsigned(&apdu[len], len_value, &ulVal);
|
||||
wp_data->priority = ulVal;
|
||||
}
|
||||
else
|
||||
} else
|
||||
len--;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
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 len = 0;
|
||||
|
||||
@@ -146,13 +149,14 @@ int wpm_ack_encode_apdu_init(uint8_t * apdu, uint8_t invoke_id)
|
||||
return len;
|
||||
}
|
||||
|
||||
int wpm_error_ack_encode_apdu(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 len = 0;
|
||||
|
||||
if (apdu)
|
||||
{
|
||||
if (apdu) {
|
||||
apdu[len++] = PDU_TYPE_ERROR;
|
||||
apdu[len++] = invoke_id;
|
||||
apdu[len++] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE;
|
||||
@@ -163,15 +167,16 @@ int wpm_error_ack_encode_apdu(uint8_t * apdu, uint8_t invoke_id,
|
||||
len += encode_closing_tag(&apdu[len], 0);
|
||||
|
||||
len += encode_opening_tag(&apdu[len], 1);
|
||||
len += encode_context_object_id(&apdu[len], 0,
|
||||
wp_data->object_type, wp_data->object_instance);
|
||||
len += encode_context_enumerated(&apdu[len], 1,
|
||||
wp_data->object_property);
|
||||
len +=
|
||||
encode_context_object_id(&apdu[len], 0, wp_data->object_type,
|
||||
wp_data->object_instance);
|
||||
len +=
|
||||
encode_context_enumerated(&apdu[len], 1, wp_data->object_property);
|
||||
|
||||
if(wp_data->array_index != BACNET_ARRAY_ALL)
|
||||
len += encode_context_unsigned(&apdu[len], 2, wp_data->array_index);
|
||||
if (wp_data->array_index != BACNET_ARRAY_ALL)
|
||||
len +=
|
||||
encode_context_unsigned(&apdu[len], 2, wp_data->array_index);
|
||||
len += encode_closing_tag(&apdu[len], 1);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user