indented to standard from script

This commit is contained in:
skarg
2012-05-13 15:07:12 +00:00
parent 173e9fb9a9
commit 48e2c60ce2
130 changed files with 1931 additions and 2014 deletions
+45 -40
View File
@@ -129,7 +129,8 @@ static int32_t Property_List[MAX_PROPS + 2];
#define INIT_ID_PROPLIST_SIZE 5 #define INIT_ID_PROPLIST_SIZE 5
/* Define Enums to match the property and value arrays below */ /* Define Enums to match the property and value arrays below */
enum init_ids { INIT_VENDOR_NAME, INIT_MODEL_NAME, INIT_DESCRIPTION, INIT_OBJ_TYPES }; enum init_ids { INIT_VENDOR_NAME, INIT_MODEL_NAME, INIT_DESCRIPTION,
INIT_OBJ_TYPES };
static int32_t InitIdPropList[INIT_ID_PROPLIST_SIZE] = { static int32_t InitIdPropList[INIT_ID_PROPLIST_SIZE] = {
PROP_VENDOR_NAME, PROP_VENDOR_NAME,
PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */ PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */
@@ -137,6 +138,7 @@ static int32_t InitIdPropList[INIT_ID_PROPLIST_SIZE] = {
PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED, PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED,
-1 -1
}; };
/* Will hold GET_HEADING_RESPONSE results here: */ /* Will hold GET_HEADING_RESPONSE results here: */
static BACNET_APPLICATION_DATA_VALUE *InitIdValues[INIT_ID_PROPLIST_SIZE] = static BACNET_APPLICATION_DATA_VALUE *InitIdValues[INIT_ID_PROPLIST_SIZE] =
{ NULL, NULL, NULL, NULL, NULL }; { NULL, NULL, NULL, NULL, NULL };
@@ -245,8 +247,8 @@ void MyReadPropertyAckHandler(
rp_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA)); rp_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
if (rp_data) { if (rp_data) {
len = len =
rp_ack_fully_decode_service_request(service_request, service_len, rp_ack_fully_decode_service_request(service_request,
rp_data); service_len, rp_data);
} }
if (len > 0) { if (len > 0) {
memmove(&Read_Property_Multiple_Data.service_data, service_data, memmove(&Read_Property_Multiple_Data.service_data, service_data,
@@ -303,8 +305,7 @@ static void Init_Service_Handlers(
/* Put this client Device into the Routing table (first entry) */ /* Put this client Device into the Routing table (first entry) */
Object_Instance = Device_Object_Instance_Number(); Object_Instance = Device_Object_Instance_Number();
Device_Object_Name(Object_Instance, &name_string); Device_Object_Name(Object_Instance, &name_string);
Add_Routed_Device(Object_Instance, &name_string, Add_Routed_Device(Object_Instance, &name_string, Device_Description());
Device_Description());
#endif #endif
/* we need to handle who-is /* we need to handle who-is
@@ -442,10 +443,8 @@ bool PrettyPrintPropertyValue(
* clearer, international form. */ * clearer, international form. */
strncpy(short_month, bactext_month_name(value->type.Date.month), 3); strncpy(short_month, bactext_month_name(value->type.Date.month), 3);
short_month[3] = 0; short_month[3] = 0;
fprintf(stream, "(%u-%3s-%u, %u)", fprintf(stream, "(%u-%3s-%u, %u)", (unsigned) value->type.Date.day,
(unsigned) value->type.Date.day, short_month, (unsigned) value->type.Date.year,
short_month,
(unsigned) value->type.Date.year,
(unsigned) value->type.Date.wday); (unsigned) value->type.Date.wday);
} else if (value != NULL) { } else if (value != NULL) {
assert(false); /* How did I get here? Fix your code. */ assert(false); /* How did I get here? Fix your code. */
@@ -637,8 +636,8 @@ void PrintReadPropertyData(
default: default:
/* First, if this is a date type, it needs a different format /* First, if this is a date type, it needs a different format
* for VTS, so pretty print it. */ * for VTS, so pretty print it. */
if (ShowValues && (object_value.value->tag == BACNET_APPLICATION_TAG_DATE)) if (ShowValues &&
{ (object_value.value->tag == BACNET_APPLICATION_TAG_DATE)) {
/* This would be PROP_LOCAL_DATE, or OBJECT_DATETIME_VALUE, /* This would be PROP_LOCAL_DATE, or OBJECT_DATETIME_VALUE,
* or OBJECT_DATE_VALUE */ * or OBJECT_DATE_VALUE */
PrettyPrintPropertyValue(stdout, &object_value); PrettyPrintPropertyValue(stdout, &object_value);
@@ -712,7 +711,9 @@ void Print_Property_Identifier(
* @param rpm_object [out] The structure holding our linked list of properties to request. * @param rpm_object [out] The structure holding our linked list of properties to request.
* @param propList [in] Simple list of properties (ptr to array), terminated with -1 * @param propList [in] Simple list of properties (ptr to array), terminated with -1
*/ */
void BuildPropRequest( BACNET_READ_ACCESS_DATA *rpm_object, int32_t *propList ) void BuildPropRequest(
BACNET_READ_ACCESS_DATA * rpm_object,
int32_t * propList)
{ {
int i; int i;
/* To start with, StartNextObject() has prepopulated one propEntry, /* To start with, StartNextObject() has prepopulated one propEntry,
@@ -720,8 +721,7 @@ void BuildPropRequest( BACNET_READ_ACCESS_DATA *rpm_object, int32_t *propList )
*/ */
BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties; BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties;
BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties; BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties;
for( i = 0; propList[i] != -1; i++ ) for (i = 0; propList[i] != -1; i++) {
{
if (propEntry == NULL) { if (propEntry == NULL) {
propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE)); propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
assert(propEntry); assert(propEntry);
@@ -761,7 +761,8 @@ static uint8_t Read_Properties(
*/ */
property_list_special(pMyObject->type, &PropertyListStruct); property_list_special(pMyObject->type, &PropertyListStruct);
if (Optional_Properties) { if (Optional_Properties) {
Property_List_Length = PropertyListStruct.Required.count + Property_List_Length =
PropertyListStruct.Required.count +
PropertyListStruct.Optional.count; PropertyListStruct.Optional.count;
} else { } else {
Property_List_Length = PropertyListStruct.Required.count; Property_List_Length = PropertyListStruct.Required.count;
@@ -923,7 +924,8 @@ EPICS_STATES ProcessRPMData(
void PrintUsage( void PrintUsage(
) )
{ {
printf("bacepics -- Generates Full EPICS file, including Object and Property List \r\n"); printf
("bacepics -- Generates Full EPICS file, including Object and Property List \r\n");
printf("Usage: \r\n"); printf("Usage: \r\n");
printf printf
(" bacepics [-v] [-p sport] [-t target_mac [-n dnet]] device-instance \r\n"); (" bacepics [-v] [-p sport] [-t target_mac [-n dnet]] device-instance \r\n");
@@ -935,13 +937,12 @@ void PrintUsage(
(" -t: declare target's MAC instead of using Who-Is to bind to \r\n"); (" -t: declare target's MAC instead of using Who-Is to bind to \r\n");
printf printf
(" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n"); (" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n");
printf printf(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n");
(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n"); printf(" -n: specify target's DNET if not local BACnet network \r\n");
printf
(" -n: specify target's DNET if not local BACnet network \r\n");
printf(" or on routed Virtual Network \r\n"); printf(" or on routed Virtual Network \r\n");
printf("\r\n"); printf("\r\n");
printf("You may want to redirect the output to a .tpi file for VTS use,\r\n"); printf
("You may want to redirect the output to a .tpi file for VTS use,\r\n");
printf(" eg, bacepics -v 2701876 > epics-2701876.tpi \r\n"); printf(" eg, bacepics -v 2701876 > epics-2701876.tpi \r\n");
printf("\r\n"); printf("\r\n");
exit(0); exit(0);
@@ -1040,7 +1041,8 @@ int CheckCommandLineArgs(
} }
void PrintHeading( ) void PrintHeading(
)
{ {
BACNET_APPLICATION_DATA_VALUE *value; BACNET_APPLICATION_DATA_VALUE *value;
char *relation = "for"; /* Text for Gateways */ char *relation = "for"; /* Text for Gateways */
@@ -1058,15 +1060,18 @@ void PrintHeading( )
value = InitIdValues[INIT_VENDOR_NAME]; value = InitIdValues[INIT_VENDOR_NAME];
if (value != NULL) if (value != NULL)
printf("Vendor Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) ); printf("Vendor Name: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
else else
printf("Vendor Name: \"bacnet-stack\"\r\n"); printf("Vendor Name: \"bacnet-stack\"\r\n");
value = InitIdValues[INIT_MODEL_NAME]; value = InitIdValues[INIT_MODEL_NAME];
/* Best we can do with Product Name and Model Number is use the same text */ /* Best we can do with Product Name and Model Number is use the same text */
if (value != NULL) { if (value != NULL) {
printf("Product Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) ); printf("Product Name: \"%s\"\r\n",
printf("Product Model Number: \"%s\"\r\n", characterstring_value( &value->type.Character_String) ); characterstring_value(&value->type.Character_String));
printf("Product Model Number: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
} else { } else {
printf("Product Name: \"bacnet-stack Device\"\r\n"); printf("Product Name: \"bacnet-stack Device\"\r\n");
printf("Product Model Number: \"Model XXX\"\r\n"); printf("Product Model Number: \"Model XXX\"\r\n");
@@ -1074,7 +1079,8 @@ void PrintHeading( )
value = InitIdValues[INIT_DESCRIPTION]; value = InitIdValues[INIT_DESCRIPTION];
if (value != NULL) if (value != NULL)
printf("Product Description: \"%s\"\r\n\r\n", characterstring_value( &value->type.Character_String) ); printf("Product Description: \"%s\"\r\n\r\n",
characterstring_value(&value->type.Character_String));
else else
printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n"); printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n");
@@ -1113,8 +1119,7 @@ void PrintHeading( )
printf(" I-Am Initiate\r\n"); printf(" I-Am Initiate\r\n");
printf(" ReinitializeDevice Execute\r\n"); printf(" ReinitializeDevice Execute\r\n");
#ifdef BAC_ROUTING #ifdef BAC_ROUTING
if ( Target_Address.net == 0 ) if (Target_Address.net == 0) {
{
printf(" -- Note: The following Routing Services are Supported:\r\n"); printf(" -- Note: The following Routing Services are Supported:\r\n");
printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n"); printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n");
printf(" -- I-Am-Router-To-Network Initiate Execute\r\n"); printf(" -- I-Am-Router-To-Network Initiate Execute\r\n");
@@ -1143,8 +1148,7 @@ void PrintHeading( )
/* We have to process this bit string and determine which Object Types we have, /* We have to process this bit string and determine which Object Types we have,
* and show them * and show them
*/ */
if ( ( value != NULL ) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) ) if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING)) {
{
int i, len = bitstring_bits_used(&value->type.Bit_String); int i, len = bitstring_bits_used(&value->type.Bit_String);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (bitstring_bit(&value->type.Bit_String, (uint8_t) i)) if (bitstring_bit(&value->type.Bit_String, (uint8_t) i))
@@ -1500,11 +1504,11 @@ int main(
(Request_Invoke_ID == (Request_Invoke_ID ==
Read_Property_Multiple_Data.service_data.invoke_id)) { Read_Property_Multiple_Data.service_data.invoke_id)) {
Read_Property_Multiple_Data.new_data = false; Read_Property_Multiple_Data.new_data = false;
PrintReadPropertyData(Read_Property_Multiple_Data. PrintReadPropertyData
rpm_data->object_type, (Read_Property_Multiple_Data.rpm_data->object_type,
Read_Property_Multiple_Data.rpm_data->object_instance, Read_Property_Multiple_Data.rpm_data->object_instance,
Read_Property_Multiple_Data.rpm_data-> Read_Property_Multiple_Data.
listOfProperties); rpm_data->listOfProperties);
if (tsm_invoke_id_free(Request_Invoke_ID)) { if (tsm_invoke_id_free(Request_Invoke_ID)) {
Request_Invoke_ID = 0; Request_Invoke_ID = 0;
} else { } else {
@@ -1538,12 +1542,13 @@ int main(
} else { } else {
/* OK, skip this one and try the next property. */ /* OK, skip this one and try the next property. */
fprintf(stdout, " -- Failed to get "); fprintf(stdout, " -- Failed to get ");
Print_Property_Identifier( Print_Property_Identifier(Property_List
Property_List[Property_List_Index]); [Property_List_Index]);
fprintf(stdout, " \r\n"); fprintf(stdout, " \r\n");
Error_Count++; Error_Count++;
Property_List_Index++; Property_List_Index++;
if (Property_List_Index >= Property_List_Length) { if (Property_List_Index >=
Property_List_Length) {
/* Give up and move on to the next. */ /* Give up and move on to the next. */
myState = NEXT_OBJECT; myState = NEXT_OBJECT;
} }
@@ -1636,10 +1641,10 @@ int main(
fprintf(stdout, "\r-- Found %d Errors \r\n", Error_Count); fprintf(stdout, "\r-- Found %d Errors \r\n", Error_Count);
/* Closing brace for all Objects, if we got any, and closing footer */ /* Closing brace for all Objects, if we got any, and closing footer */
if (myState != INITIAL_BINDING) if (myState != INITIAL_BINDING) {
{
printf("} \r\n"); printf("} \r\n");
printf("End of BACnet Protocol Implementation Conformance Statement\r\n"); printf
("End of BACnet Protocol Implementation Conformance Statement\r\n");
printf("\r\n"); printf("\r\n");
} }
+1 -2
View File
@@ -132,8 +132,7 @@ static void Init_Service_Handlers(
*/ */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
handler_who_is_unicast); handler_who_is_unicast);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
handler_who_has);
/* set the handler for all the services we don't implement */ /* set the handler for all the services we don't implement */
/* It is required to send the proper reject message... */ /* It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler apdu_set_unrecognized_service_handler_handler
+13 -10
View File
@@ -55,7 +55,8 @@ static int bbmd_result = 0;
* @param address - IPv4 address (long) of BBMD to register with, * @param address - IPv4 address (long) of BBMD to register with,
* in network byte order. * in network byte order.
*/ */
void dlenv_bbmd_address_set( long address ) void dlenv_bbmd_address_set(
long address)
{ {
bbmd_address = address; bbmd_address = address;
} }
@@ -64,7 +65,8 @@ void dlenv_bbmd_address_set( long address )
* Default if not set is 0xBAC0. * Default if not set is 0xBAC0.
* @param port - The port number (provided in network byte order). * @param port - The port number (provided in network byte order).
*/ */
void dlenv_bbmd_port_set( int port ) void dlenv_bbmd_port_set(
int port)
{ {
bbmd_port = port; bbmd_port = port;
} }
@@ -73,7 +75,8 @@ void dlenv_bbmd_port_set( int port )
* Default if not set is 60000 (1000 minutes). * Default if not set is 60000 (1000 minutes).
* @param ttl_secs - The Lease Time, in seconds. * @param ttl_secs - The Lease Time, in seconds.
*/ */
void dlenv_bbmd_ttl_set( int ttl_secs ) void dlenv_bbmd_ttl_set(
int ttl_secs)
{ {
bbmd_timetolive_seconds = ttl_secs; bbmd_timetolive_seconds = ttl_secs;
} }
@@ -86,7 +89,8 @@ void dlenv_bbmd_ttl_set( int ttl_secs )
* 0 if no registration request was made, or * 0 if no registration request was made, or
* -1 if registration attempt failed. * -1 if registration attempt failed.
*/ */
int dlenv_bbmd_result( void ) int dlenv_bbmd_result(
void)
{ {
if ((bbmd_result > 0) && if ((bbmd_result > 0) &&
(bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK)) (bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK))
@@ -138,15 +142,14 @@ int dlenv_register_as_foreign_device(
if (bbmd_address) { if (bbmd_address) {
struct in_addr addr; struct in_addr addr;
addr.s_addr = bbmd_address; addr.s_addr = bbmd_address;
fprintf(stderr, fprintf(stderr, "Registering with BBMD at %s:%ld for %ld seconds\n",
"Registering with BBMD at %s:%ld for %ld seconds\n",
inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds);
retval = bvlc_register_with_bbmd(bbmd_address, retval =
htons((uint16_t) bbmd_port), bvlc_register_with_bbmd(bbmd_address, htons((uint16_t) bbmd_port),
(uint16_t) bbmd_timetolive_seconds); (uint16_t) bbmd_timetolive_seconds);
if (retval < 0) if (retval < 0)
fprintf(stderr, fprintf(stderr, "FAILED to Register with BBMD at %s \n",
"FAILED to Register with BBMD at %s \n", inet_ntoa(addr) ); inet_ntoa(addr));
BBMD_Timer_Seconds = bbmd_timetolive_seconds; BBMD_Timer_Seconds = bbmd_timetolive_seconds;
} }
+4 -3
View File
@@ -106,7 +106,8 @@ void handler_ccov_notification(
fprintf(stderr, "CCOV: Segmented message. Sending Abort!\n"); fprintf(stderr, "CCOV: Segmented message. Sending Abort!\n");
#endif #endif
goto CCOV_ABORT; goto CCOV_ABORT;
} /* decode the service request only */ }
/* decode the service request only */
/* decode the service request only */ /* decode the service request only */
len = len =
cov_notify_decode_service_request(service_request, service_len, cov_notify_decode_service_request(service_request, service_len,
@@ -125,8 +126,8 @@ void handler_ccov_notification(
fprintf(stderr, "CCOV: "); fprintf(stderr, "CCOV: ");
if (pProperty_value->propertyIdentifier < 512) { if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ", fprintf(stderr, "%s ",
bactext_property_name bactext_property_name(pProperty_value->
(pProperty_value->propertyIdentifier)); propertyIdentifier));
} else { } else {
fprintf(stderr, "proprietary %u ", fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier); pProperty_value->propertyIdentifier);
+22 -18
View File
@@ -390,8 +390,8 @@ static void cov_lifetime_expiration_handler(
if (lifetime_seconds >= elapsed_seconds) { if (lifetime_seconds >= elapsed_seconds) {
COV_Subscriptions[index].lifetime -= elapsed_seconds; COV_Subscriptions[index].lifetime -= elapsed_seconds;
#if 0 #if 0
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n", fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n", index,
index, (unsigned long) COV_Subscriptions[index].lifetime); (unsigned long) COV_Subscriptions[index].lifetime);
#endif #endif
} else { } else {
COV_Subscriptions[index].lifetime = 0; COV_Subscriptions[index].lifetime = 0;
@@ -443,8 +443,7 @@ void handler_cov_timer_seconds(
lifetime_seconds = COV_Subscriptions[index].lifetime; lifetime_seconds = COV_Subscriptions[index].lifetime;
if (lifetime_seconds) { if (lifetime_seconds) {
/* only expire COV with definite lifetimes */ /* only expire COV with definite lifetimes */
cov_lifetime_expiration_handler(index, cov_lifetime_expiration_handler(index, elapsed_seconds,
elapsed_seconds,
lifetime_seconds); lifetime_seconds);
} }
} }
@@ -452,7 +451,8 @@ void handler_cov_timer_seconds(
} }
} }
void handler_cov_task(void) void handler_cov_task(
void)
{ {
static int index = 0; static int index = 0;
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE; BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
@@ -461,8 +461,7 @@ void handler_cov_task(void)
bool send = false; bool send = false;
BACNET_PROPERTY_VALUE value_list[2]; BACNET_PROPERTY_VALUE value_list[2];
/* states for transmitting */ /* states for transmitting */
static enum static enum {
{
COV_STATE_IDLE = 0, COV_STATE_IDLE = 0,
COV_STATE_MARK, COV_STATE_MARK,
COV_STATE_CLEAR, COV_STATE_CLEAR,
@@ -481,7 +480,8 @@ void handler_cov_task(void)
object_type = (BACNET_OBJECT_TYPE) object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type; COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance = object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance; COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
status = Device_COV(object_type, object_instance); status = Device_COV(object_type, object_instance);
if (status) { if (status) {
COV_Subscriptions[index].flag.send_requested = true; COV_Subscriptions[index].flag.send_requested = true;
@@ -500,7 +500,8 @@ void handler_cov_task(void)
object_type = (BACNET_OBJECT_TYPE) object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type; COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance = object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance; COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
Device_COV_Clear(object_type, object_instance); Device_COV_Clear(object_type, object_instance);
} }
index++; index++;
@@ -516,8 +517,8 @@ void handler_cov_task(void)
(COV_Subscriptions[index].invokeID)) { (COV_Subscriptions[index].invokeID)) {
if (tsm_invoke_id_free(COV_Subscriptions[index].invokeID)) { if (tsm_invoke_id_free(COV_Subscriptions[index].invokeID)) {
COV_Subscriptions[index].invokeID = 0; COV_Subscriptions[index].invokeID = 0;
} else if (tsm_invoke_id_failed( } else if (tsm_invoke_id_failed(COV_Subscriptions[index].
COV_Subscriptions[index].invokeID)) { invokeID)) {
tsm_free_invoke_id(COV_Subscriptions[index].invokeID); tsm_free_invoke_id(COV_Subscriptions[index].invokeID);
COV_Subscriptions[index].invokeID = 0; COV_Subscriptions[index].invokeID = 0;
} }
@@ -545,16 +546,18 @@ void handler_cov_task(void)
} }
if (send) { if (send) {
object_type = (BACNET_OBJECT_TYPE) object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type; COV_Subscriptions[index].monitoredObjectIdentifier.
type;
object_instance = object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance; COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
/* configure the linked list for the two properties */ /* configure the linked list for the two properties */
value_list[0].next = &value_list[1]; value_list[0].next = &value_list[1];
value_list[1].next = NULL; value_list[1].next = NULL;
(void)Device_Encode_Value_List(object_type, object_instance, (void) Device_Encode_Value_List(object_type,
&value_list[0]); object_instance, &value_list[0]);
status = cov_send_request( status =
&COV_Subscriptions[index], cov_send_request(&COV_Subscriptions[index],
&value_list[0]); &value_list[0]);
if (status) { if (status) {
COV_Subscriptions[index].flag.send_requested = false; COV_Subscriptions[index].flag.send_requested = false;
@@ -584,7 +587,8 @@ static bool cov_subscribe(
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE; BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
uint32_t object_instance = 0; uint32_t object_instance = 0;
object_type = (BACNET_OBJECT_TYPE)cov_data->monitoredObjectIdentifier.type; object_type =
(BACNET_OBJECT_TYPE) cov_data->monitoredObjectIdentifier.type;
object_instance = cov_data->monitoredObjectIdentifier.instance; object_instance = cov_data->monitoredObjectIdentifier.instance;
status = Device_Valid_Object_Id(object_type, object_instance); status = Device_Valid_Object_Id(object_type, object_instance);
if (status) { if (status) {
+3 -2
View File
@@ -157,8 +157,9 @@ void handler_device_communication_control(
} else { } else {
#if BAC_ROUTING #if BAC_ROUTING
/* Check to see if the current Device supports this service. */ /* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval( len =
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state, Routed_Device_Service_Approval
(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id); &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
if (len > 0) if (len > 0)
goto DCC_ABORT; goto DCC_ABORT;
+10 -13
View File
@@ -90,9 +90,9 @@ void handler_get_alarm_summary(
} }
/* init header */ /* init header */
apdu_len = get_alarm_summary_ack_encode_apdu_init( apdu_len =
&Handler_Transmit_Buffer[pdu_len], get_alarm_summary_ack_encode_apdu_init(&Handler_Transmit_Buffer
service_data->invoke_id); [pdu_len], service_data->invoke_id);
for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) { for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) {
@@ -100,18 +100,16 @@ void handler_get_alarm_summary(
for (j = 0; j < 0xffff; j++) { for (j = 0; j < 0xffff; j++) {
alarm_value = Get_Alarm_Summary[i] (j, &getalarm_data); alarm_value = Get_Alarm_Summary[i] (j, &getalarm_data);
if (alarm_value > 0) { if (alarm_value > 0) {
len = get_alarm_sumary_ack_encode_apdu_data( len =
&Handler_Transmit_Buffer[pdu_len + apdu_len], get_alarm_sumary_ack_encode_apdu_data
service_data->max_resp - apdu_len, (&Handler_Transmit_Buffer[pdu_len + apdu_len],
&getalarm_data); service_data->max_resp - apdu_len, &getalarm_data);
if (len <= 0) { if (len <= 0) {
error = true; error = true;
goto GET_ALARM_SUMMARY_ERROR; goto GET_ALARM_SUMMARY_ERROR;
} } else
else
apdu_len += len; apdu_len += len;
} } else if (alarm_value < 0) {
else if (alarm_value < 0) {
break; break;
} }
} }
@@ -135,8 +133,7 @@ GET_ALARM_SUMMARY_ERROR:
fprintf(stderr, fprintf(stderr,
"GetAlarmSummary: Reply too big to fit into APDU!\n"); "GetAlarmSummary: Reply too big to fit into APDU!\n");
#endif #endif
} } else {
else {
apdu_len = apdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_GET_ALARM_SUMMARY, service_data->invoke_id, SERVICE_CONFIRMED_GET_ALARM_SUMMARY,
+3 -2
View File
@@ -131,8 +131,9 @@ void handler_reinitialize_device(
} else { } else {
#if BAC_ROUTING #if BAC_ROUTING
/* Check to see if the current Device supports this service. */ /* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval( len =
SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state, Routed_Device_Service_Approval
(SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id); &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
if (len > 0) if (len > 0)
goto RD_ABORT; goto RD_ABORT;
+2 -1
View File
@@ -296,7 +296,8 @@ void handler_read_property_multiple(
&Temp_Buf[0], apdu_len, len, MAX_APDU); &Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) { if (copy_len == 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Too full to encode property!\r\n"); fprintf(stderr,
"RPM: Too full to encode property!\r\n");
#endif #endif
rpmdata.error_code = rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
+6 -6
View File
@@ -221,8 +221,8 @@ void rpm_ack_print_data(
#if PRINT_ENABLED #if PRINT_ENABLED
if (listOfProperties->propertyIdentifier < 512) { if (listOfProperties->propertyIdentifier < 512) {
fprintf(stdout, " %s: ", fprintf(stdout, " %s: ",
bactext_property_name(listOfProperties-> bactext_property_name
propertyIdentifier)); (listOfProperties->propertyIdentifier));
} else { } else {
fprintf(stdout, " proprietary %u: ", fprintf(stdout, " proprietary %u: ",
(unsigned) listOfProperties->propertyIdentifier); (unsigned) listOfProperties->propertyIdentifier);
@@ -269,10 +269,10 @@ void rpm_ack_print_data(
#if PRINT_ENABLED #if PRINT_ENABLED
/* AccessError */ /* AccessError */
fprintf(stdout, "BACnet Error: %s: %s\r\n", fprintf(stdout, "BACnet Error: %s: %s\r\n",
bactext_error_class_name((int) listOfProperties-> bactext_error_class_name((int) listOfProperties->error.
error.error_class), error_class),
bactext_error_code_name((int) listOfProperties-> bactext_error_code_name((int) listOfProperties->error.
error.error_code)); error_code));
#endif #endif
} }
listOfProperties = listOfProperties->next; listOfProperties = listOfProperties->next;
+2 -2
View File
@@ -104,8 +104,8 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: "); fprintf(stderr, "UCOV: ");
if (pProperty_value->propertyIdentifier < 512) { if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ", fprintf(stderr, "%s ",
bactext_property_name bactext_property_name(pProperty_value->
(pProperty_value->propertyIdentifier)); propertyIdentifier));
} else { } else {
fprintf(stderr, "proprietary %u ", fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier); pProperty_value->propertyIdentifier);
+3 -3
View File
@@ -56,8 +56,9 @@ void handler_unconfirmed_private_transfer(
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n"); fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
#endif #endif
len = ptransfer_decode_service_request( len =
service_request, service_len, &private_data); ptransfer_decode_service_request(service_request, service_len,
&private_data);
if (len >= 0) { if (len >= 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
printf("PrivateTransfer:vendorID=%u\r\n", printf("PrivateTransfer:vendorID=%u\r\n",
@@ -107,4 +108,3 @@ void handler_unconfirmed_private_transfer(
#endif #endif
} }
} }
+2 -3
View File
@@ -65,9 +65,8 @@ static void match_name_or_object(
} else { } else {
/* valid object_name copy in my device? */ /* valid object_name copy in my device? */
found = found =
Device_Object_Name_Copy( Device_Object_Name_Copy((BACNET_OBJECT_TYPE) data->object.
(BACNET_OBJECT_TYPE)data->object.identifier.type, identifier.type, data->object.identifier.instance, &object_name);
data->object.identifier.instance, &object_name);
if (found) { if (found) {
Send_I_Have(Device_Object_Instance_Number(), Send_I_Have(Device_Object_Instance_Number(),
(BACNET_OBJECT_TYPE) data->object.identifier.type, (BACNET_OBJECT_TYPE) data->object.identifier.type,
+2 -2
View File
@@ -181,8 +181,8 @@ bool WPValidateString(
(!characterstring_printable(&pValue->type.Character_String))) { (!characterstring_printable(&pValue->type.Character_String))) {
/* assumption: non-empty also means must be "printable" */ /* assumption: non-empty also means must be "printable" */
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE; *pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (characterstring_length(&pValue-> } else if (characterstring_length(&pValue->type.Character_String) >
type.Character_String) > iMaxLen) { iMaxLen) {
*pErrorClass = ERROR_CLASS_RESOURCES; *pErrorClass = ERROR_CLASS_RESOURCES;
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY; *pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
} else } else
+2 -3
View File
@@ -157,9 +157,8 @@ uint8_t Send_Write_Property_Request(
#if PRINT_ENABLED_DEBUG #if PRINT_ENABLED_DEBUG
fprintf(stderr, "WriteProperty service: " "%s tag=%d\n", fprintf(stderr, "WriteProperty service: " "%s tag=%d\n",
(object_value->context_specific ? "context" : "application"), (object_value->context_specific ? "context" : "application"),
(int) (object_value-> (int) (object_value->context_specific ? object_value->
context_specific ? object_value->context_tag : object_value-> context_tag : object_value->tag));
tag));
#endif #endif
len = bacapp_encode_data(&application_data[apdu_len], object_value); len = bacapp_encode_data(&application_data[apdu_len], object_value);
if ((len + apdu_len) < MAX_APDU) { if ((len + apdu_len) < MAX_APDU) {
+10 -5
View File
@@ -73,7 +73,9 @@ static FILE *pFile = NULL; /* stream pointer */
* RETURN: number of arguments parsed * RETURN: number of arguments parsed
* NOTES: none * NOTES: none
******************************************************************/ ******************************************************************/
static void Parse_Arguments(int argc, char *argv[]) static void Parse_Arguments(
int argc,
char *argv[])
{ {
int i = 0; int i = 0;
long long_value = 0; long long_value = 0;
@@ -173,7 +175,9 @@ static void write_global_header(
} }
} }
static void write_received_packet(uint8_t *buffer, unsigned length) static void write_received_packet(
uint8_t * buffer,
unsigned length)
{ {
uint32_t ts_sec; /* timestamp seconds */ uint32_t ts_sec; /* timestamp seconds */
uint32_t ts_usec; /* timestamp microseconds */ uint32_t ts_usec; /* timestamp microseconds */
@@ -197,7 +201,9 @@ static void write_received_packet(uint8_t *buffer, unsigned length)
} }
} }
static void Write_Pcap(uint8_t *buffer, unsigned length) static void Write_Pcap(
uint8_t * buffer,
unsigned length)
{ {
filename_create(&Capture_Filename[0]); filename_create(&Capture_Filename[0]);
write_global_header(&Capture_Filename[0]); write_global_header(&Capture_Filename[0]);
@@ -220,8 +226,7 @@ int main(
/* initialize our interface */ /* initialize our interface */
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) { if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
printf("mstpcrc [options] <00 00 00 00...>\r\n" printf("mstpcrc [options] <00 00 00 00...>\r\n"
"perform MS/TP CRC on data bytes.\r\n" "perform MS/TP CRC on data bytes.\r\n" "options:\r\n"
"options:\r\n"
"[-x] interprete the arguments as ascii hex (default)\r\n" "[-x] interprete the arguments as ascii hex (default)\r\n"
"[-d] interprete the argument as ascii decimal\r\n" "[-d] interprete the argument as ascii decimal\r\n"
"[-m] Write the bytes to Wireshark capture file\r\n" "[-m] Write the bytes to Wireshark capture file\r\n"
+73 -66
View File
@@ -352,11 +352,11 @@ int Analog_Input_Read_Property(
case PROP_LIMIT_ENABLE: case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0, bitstring_set_bit(&bit_string, 0,
(CurrentAI-> (CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true :
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false); false);
bitstring_set_bit(&bit_string, 1, bitstring_set_bit(&bit_string, 1,
(CurrentAI-> (CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true :
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false); false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string); apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break; break;
@@ -364,14 +364,14 @@ int Analog_Input_Read_Property(
case PROP_EVENT_ENABLE: case PROP_EVENT_ENABLE:
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAI-> (CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAI-> (CurrentAI->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAI-> (CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string); apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break; break;
@@ -379,8 +379,8 @@ int Analog_Input_Read_Property(
case PROP_ACKED_TRANSITIONS: case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. CurrentAI->
bIsAcked); Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
@@ -909,17 +909,17 @@ void Analog_Input_Intrinsic_Reporting(
event_data.notificationParams.outOfRange.exceedingValue = event_data.notificationParams.outOfRange.exceedingValue =
PresentVal; PresentVal;
/* Status_Flags of the referenced object. */ /* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange. bitstring_init(&event_data.notificationParams.
statusFlags); outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_IN_ALARM, outOfRange.statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAI->Event_State ? true : false); CurrentAI->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_FAULT, false); outOfRange.statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_OVERRIDDEN, false); outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE, outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAI->Out_Of_Service); CurrentAI->Out_Of_Service);
/* Deadband used for limit checking. */ /* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband = event_data.notificationParams.outOfRange.deadband =
@@ -939,24 +939,30 @@ void Analog_Input_Intrinsic_Reporting(
case EVENT_STATE_OFFNORMAL: case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_LOW_LIMIT:
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. CurrentAI->
bIsAcked = false; Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. false;
Time_Stamp = event_data.timeStamp.value.dateTime; CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break; break;
case EVENT_STATE_FAULT: case EVENT_STATE_FAULT:
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT]. CurrentAI->
bIsAcked = false; Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT]. false;
Time_Stamp = event_data.timeStamp.value.dateTime; CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
break; break;
case EVENT_STATE_NORMAL: case EVENT_STATE_NORMAL:
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL]. CurrentAI->
bIsAcked = false; Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL]. false;
Time_Stamp = event_data.timeStamp.value.dateTime; CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break; break;
} }
} }
@@ -983,12 +989,12 @@ int Analog_Input_Event_Information(
/* Acked_Transitions property, which has at least one of the bits /* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */ (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions = IsNotAckedTransitions =
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. (AI_Descr[index].
bIsAcked == Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT]. false) | (AI_Descr[index].
bIsAcked == Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL]. false) | (AI_Descr[index].
bIsAcked == false); Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
} else } else
return -1; /* end of list */ return -1; /* end of list */
@@ -1003,8 +1009,8 @@ int Analog_Input_Event_Information(
bitstring_init(&getevent_data->acknowledgedTransitions); bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL, TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. AI_Descr[index].
bIsAcked); Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT, TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
@@ -1022,14 +1028,14 @@ int Analog_Input_Event_Information(
/* Event Enable */ /* Event Enable */
bitstring_init(&getevent_data->eventEnable); bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL, bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AI_Descr[index]. (AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT, bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AI_Descr[index]. (AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL, bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AI_Descr[index]. (AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); false);
/* Event Priorities */ /* Event Priorities */
Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class, Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class,
getevent_data->eventPriorities); getevent_data->eventPriorities);
@@ -1049,8 +1055,8 @@ int Analog_Input_Alarm_Ack(
object_index = object_index =
Analog_Input_Instance_To_Index(alarmack_data->eventObjectIdentifier. Analog_Input_Instance_To_Index(alarmack_data->
instance); eventObjectIdentifier.instance);
if (object_index < MAX_ANALOG_INPUTS) if (object_index < MAX_ANALOG_INPUTS)
CurrentAI = &AI_Descr[object_index]; CurrentAI = &AI_Descr[object_index];
@@ -1063,22 +1069,22 @@ int Analog_Input_Alarm_Ack(
case EVENT_STATE_OFFNORMAL: case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_LOW_LIMIT:
if (CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. if (CurrentAI->
bIsAcked == false) { Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) { if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
if (datetime_compare(&CurrentAI-> if (datetime_compare(&CurrentAI->Acked_Transitions
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp, [TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) { &alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
/* FIXME: Send ack notification */ /* FIXME: Send ack notification */
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. CurrentAI->
bIsAcked = true; Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} else { } else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE; *error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1; return -1;
@@ -1092,8 +1098,8 @@ int Analog_Input_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
if (datetime_compare(&CurrentAI-> if (datetime_compare(&CurrentAI->Acked_Transitions
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp, [TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) { &alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
@@ -1115,8 +1121,8 @@ int Analog_Input_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
if (datetime_compare(&CurrentAI-> if (datetime_compare(&CurrentAI->Acked_Transitions
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp, [TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) { &alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
@@ -1159,18 +1165,19 @@ int Analog_Input_Alarm_Summary(
bitstring_init(&getalarm_data->acknowledgedTransitions); bitstring_init(&getalarm_data->acknowledgedTransitions);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions, bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL, TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. AI_Descr[index].
bIsAcked); Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions, bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_FAULT, TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions, bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL, TRANSITION_TO_NORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked); AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked);
return 1; /* active alarm */ return 1; /* active alarm */
} } else
else
return 0; /* no active alarm at this index */ return 0; /* no active alarm at this index */
} else } else
return -1; /* end of list */ return -1; /* end of list */
-1
View File
@@ -149,5 +149,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+4 -4
View File
@@ -447,11 +447,11 @@ bool Analog_Output_Write_Property(
if (status) { if (status) {
level = AO_LEVEL_NULL; level = AO_LEVEL_NULL;
object_index = object_index =
Analog_Output_Instance_To_Index Analog_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
status = status =
Analog_Output_Present_Value_Relinquish Analog_Output_Present_Value_Relinquish(wp_data->
(wp_data->object_instance, wp_data->priority); object_instance, wp_data->priority);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -100,5 +100,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+73 -66
View File
@@ -424,11 +424,11 @@ int Analog_Value_Read_Property(
case PROP_LIMIT_ENABLE: case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0, bitstring_set_bit(&bit_string, 0,
(CurrentAV-> (CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true :
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false); false);
bitstring_set_bit(&bit_string, 1, bitstring_set_bit(&bit_string, 1,
(CurrentAV-> (CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true :
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false); false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string); apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break; break;
@@ -436,14 +436,14 @@ int Analog_Value_Read_Property(
case PROP_EVENT_ENABLE: case PROP_EVENT_ENABLE:
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAV-> (CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAV-> (CurrentAV->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAV-> (CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string); apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break; break;
@@ -451,8 +451,8 @@ int Analog_Value_Read_Property(
case PROP_ACKED_TRANSITIONS: case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string); bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. CurrentAV->
bIsAcked); Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
@@ -1004,17 +1004,17 @@ void Analog_Value_Intrinsic_Reporting(
event_data.notificationParams.outOfRange.exceedingValue = event_data.notificationParams.outOfRange.exceedingValue =
PresentVal; PresentVal;
/* Status_Flags of the referenced object. */ /* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange. bitstring_init(&event_data.notificationParams.
statusFlags); outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_IN_ALARM, outOfRange.statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAV->Event_State ? true : false); CurrentAV->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_FAULT, false); outOfRange.statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_OVERRIDDEN, false); outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange. bitstring_set_bit(&event_data.notificationParams.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE, outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAV->Out_Of_Service); CurrentAV->Out_Of_Service);
/* Deadband used for limit checking. */ /* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband = event_data.notificationParams.outOfRange.deadband =
@@ -1034,24 +1034,30 @@ void Analog_Value_Intrinsic_Reporting(
case EVENT_STATE_OFFNORMAL: case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_LOW_LIMIT:
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. CurrentAV->
bIsAcked = false; Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. false;
Time_Stamp = event_data.timeStamp.value.dateTime; CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break; break;
case EVENT_STATE_FAULT: case EVENT_STATE_FAULT:
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT]. CurrentAV->
bIsAcked = false; Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT]. false;
Time_Stamp = event_data.timeStamp.value.dateTime; CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
break; break;
case EVENT_STATE_NORMAL: case EVENT_STATE_NORMAL:
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL]. CurrentAV->
bIsAcked = false; Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL]. false;
Time_Stamp = event_data.timeStamp.value.dateTime; CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break; break;
} }
} }
@@ -1078,12 +1084,12 @@ int Analog_Value_Event_Information(
/* Acked_Transitions property, which has at least one of the bits /* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */ (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions = IsNotAckedTransitions =
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. (AV_Descr[index].
bIsAcked == Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT]. false) | (AV_Descr[index].
bIsAcked == Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL]. false) | (AV_Descr[index].
bIsAcked == false); Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
} else } else
return -1; /* end of list */ return -1; /* end of list */
@@ -1098,8 +1104,8 @@ int Analog_Value_Event_Information(
bitstring_init(&getevent_data->acknowledgedTransitions); bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL, TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. AV_Descr[index].
bIsAcked); Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions, bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT, TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
@@ -1117,14 +1123,14 @@ int Analog_Value_Event_Information(
/* Event Enable */ /* Event Enable */
bitstring_init(&getevent_data->eventEnable); bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL, bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AV_Descr[index]. (AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT, bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AV_Descr[index]. (AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL, bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AV_Descr[index]. (AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); false);
/* Event Priorities */ /* Event Priorities */
Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class, Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class,
getevent_data->eventPriorities); getevent_data->eventPriorities);
@@ -1143,8 +1149,8 @@ int Analog_Value_Alarm_Ack(
object_index = object_index =
Analog_Value_Instance_To_Index(alarmack_data->eventObjectIdentifier. Analog_Value_Instance_To_Index(alarmack_data->
instance); eventObjectIdentifier.instance);
if (object_index < MAX_ANALOG_VALUES) if (object_index < MAX_ANALOG_VALUES)
CurrentAV = &AV_Descr[object_index]; CurrentAV = &AV_Descr[object_index];
@@ -1157,22 +1163,22 @@ int Analog_Value_Alarm_Ack(
case EVENT_STATE_OFFNORMAL: case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_LOW_LIMIT:
if (CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. if (CurrentAV->
bIsAcked == false) { Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) { if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
if (datetime_compare(&CurrentAV-> if (datetime_compare(&CurrentAV->Acked_Transitions
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp, [TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) { &alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
/* Clean transitions flag. */ /* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. CurrentAV->
bIsAcked = true; Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} else { } else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE; *error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1; return -1;
@@ -1186,8 +1192,8 @@ int Analog_Value_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
if (datetime_compare(&CurrentAV-> if (datetime_compare(&CurrentAV->Acked_Transitions
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp, [TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) { &alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
@@ -1209,8 +1215,8 @@ int Analog_Value_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
} }
if (datetime_compare(&CurrentAV-> if (datetime_compare(&CurrentAV->Acked_Transitions
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp, [TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) { &alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP; *error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1; return -1;
@@ -1258,18 +1264,19 @@ int Analog_Value_Alarm_Summary(
bitstring_init(&getalarm_data->acknowledgedTransitions); bitstring_init(&getalarm_data->acknowledgedTransitions);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions, bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL, TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. AV_Descr[index].
bIsAcked); Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions, bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_FAULT, TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions, bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL, TRANSITION_TO_NORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked); AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked);
return 1; /* active alarm */ return 1; /* active alarm */
} } else
else
return 0; /* no active alarm at this index */ return 0; /* no active alarm at this index */
} else } else
return -1; /* end of list */ return -1; /* end of list */
-1
View File
@@ -132,5 +132,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+2 -1
View File
@@ -474,7 +474,8 @@ bool bacfile_write_stream_data(
} }
if (pFile) { if (pFile) {
if (data->type.stream.fileStartPosition != -1) { if (data->type.stream.fileStartPosition != -1) {
(void) fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET); (void) fseek(pFile, data->type.stream.fileStartPosition,
SEEK_SET);
} }
if (fwrite(octetstring_value(&data->fileData), if (fwrite(octetstring_value(&data->fileData),
octetstring_length(&data->fileData), 1, pFile) != 1) { octetstring_length(&data->fileData), 1, pFile) != 1) {
-1
View File
@@ -98,5 +98,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
-1
View File
@@ -114,5 +114,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+4 -4
View File
@@ -376,8 +376,8 @@ bool Binary_Output_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated; level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index = object_index =
Binary_Output_Instance_To_Index Binary_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Binary_Output_Level[object_index][priority] = level; Binary_Output_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
@@ -403,8 +403,8 @@ bool Binary_Output_Write_Property(
if (status) { if (status) {
level = BINARY_NULL; level = BINARY_NULL;
object_index = object_index =
Binary_Output_Instance_To_Index Binary_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
-1
View File
@@ -116,5 +116,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+4 -4
View File
@@ -359,8 +359,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated; level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Binary_Value_Level[object_index][priority] = level; Binary_Value_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
@@ -386,8 +386,8 @@ bool Binary_Value_Write_Property(
if (status) { if (status) {
level = BINARY_NULL; level = BINARY_NULL;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
-1
View File
@@ -71,5 +71,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+10 -14
View File
@@ -152,9 +152,7 @@ bool CharacterString_Value_Present_Value(
index = CharacterString_Value_Instance_To_Index(object_instance); index = CharacterString_Value_Instance_To_Index(object_instance);
if (object_name && (index < MAX_CHARACTERSTRING_VALUES)) { if (object_name && (index < MAX_CHARACTERSTRING_VALUES)) {
status = characterstring_copy( status = characterstring_copy(object_name, &Present_Value[index]);
object_name,
&Present_Value[index]);
} }
return status; return status;
@@ -169,9 +167,7 @@ bool CharacterString_Value_Present_Value_Set(
index = CharacterString_Value_Instance_To_Index(object_instance); index = CharacterString_Value_Instance_To_Index(object_instance);
if (index < MAX_CHARACTERSTRING_VALUES) { if (index < MAX_CHARACTERSTRING_VALUES) {
status = characterstring_copy( status = characterstring_copy(&Present_Value[index], object_name);
&Present_Value[index],
object_name);
} }
return status; return status;
@@ -361,7 +357,8 @@ int CharacterString_Value_Read_Property(
break; break;
case PROP_OUT_OF_SERVICE: case PROP_OUT_OF_SERVICE:
object_index = object_index =
CharacterString_Value_Instance_To_Index(rpdata->object_instance); CharacterString_Value_Instance_To_Index(rpdata->
object_instance);
state = Out_Of_Service[object_index]; state = Out_Of_Service[object_index];
apdu_len = encode_application_boolean(&apdu[0], state); apdu_len = encode_application_boolean(&apdu[0], state);
break; break;
@@ -405,13 +402,12 @@ bool CharacterString_Value_Write_Property(
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
status = status =
WPValidateArgType(&value, WPValidateArgType(&value,
BACNET_APPLICATION_TAG_CHARACTER_STRING, BACNET_APPLICATION_TAG_CHARACTER_STRING, &wp_data->error_class,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_code);
if (status) { if (status) {
status = status =
CharacterString_Value_Present_Value_Set CharacterString_Value_Present_Value_Set(wp_data->
(wp_data->object_instance, object_instance, &value.type.Character_String);
&value.type.Character_String);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -423,8 +419,8 @@ bool CharacterString_Value_Write_Property(
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN, WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
CharacterString_Value_Out_Of_Service_Set( CharacterString_Value_Out_Of_Service_Set(wp_data->
wp_data->object_instance, value.type.Boolean); object_instance, value.type.Boolean);
} }
break; break;
default: default:
-1
View File
@@ -92,5 +92,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+1 -2
View File
@@ -906,6 +906,7 @@ bool Device_Write_Property(
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
return (status); return (status);
} }
/* Ditto for the local version; always returns false */ /* Ditto for the local version; always returns false */
bool Device_Write_Property_Local( bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data) BACNET_WRITE_PROPERTY_DATA * wp_data)
@@ -941,5 +942,3 @@ void Device_Init(
pObject++; pObject++;
} }
} }
+13 -14
View File
@@ -1419,8 +1419,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */ /* FIXME: we could send an I-Am broadcast to let the world know */
} else { } else {
status = false; status = false;
@@ -1453,8 +1453,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t) value. Device_Set_Vendor_Identifier((uint16_t) value.type.
type.Unsigned_Int); Unsigned_Int);
} }
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
@@ -1500,8 +1500,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true, WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Location(characterstring_value(&value. Device_Set_Location(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1511,8 +1511,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true, WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Description(characterstring_value(&value. Device_Set_Description(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1521,8 +1521,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_MOD_LEN, true, WPValidateString(&value, MAX_DEV_MOD_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Model_Name(characterstring_value(&value. Device_Set_Model_Name(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1534,8 +1534,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if (value.type.Unsigned_Int <= 255) { if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames((uint8_t) value. dlmstp_set_max_info_frames((uint8_t) value.type.
type.Unsigned_Int); Unsigned_Int);
} else { } else {
status = false; status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1650,8 +1650,7 @@ bool Device_COV(
if (pObject->Object_Valid_Instance && if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) { pObject->Object_Valid_Instance(object_instance)) {
if (pObject->Object_COV) { if (pObject->Object_COV) {
status = pObject->Object_COV( status = pObject->Object_COV(object_instance);
object_instance);
} }
} }
} }
+2 -7
View File
@@ -431,7 +431,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
/** @defgroup ObjFrmwk Object Framework /** @defgroup ObjFrmwk Object Framework
* The modules in this section describe the BACnet-stack's framework for * The modules in this section describe the BACnet-stack's framework for
* BACnet-defined Objects (Device, Analog Input, etc). There are two submodules * BACnet-defined Objects (Device, Analog Input, etc). There are two submodules
@@ -441,15 +440,11 @@ extern "C" {
* - The interface between the implemented Objects and the BAC-stack services, * - The interface between the implemented Objects and the BAC-stack services,
* specifically the handlers, which are mediated through function calls to * specifically the handlers, which are mediated through function calls to
* the Device object. * the Device object.
*/ *//** @defgroup ObjHelpers Object Helper Functions
/** @defgroup ObjHelpers Object Helper Functions
* @ingroup ObjFrmwk * @ingroup ObjFrmwk
* This section describes the function templates for the helper functions that * This section describes the function templates for the helper functions that
* provide common object support. * provide common object support.
*/ *//** @defgroup ObjIntf Handler-to-Object Interface Functions
/** @defgroup ObjIntf Handler-to-Object Interface Functions
* @ingroup ObjFrmwk * @ingroup ObjFrmwk
* This section describes the fairly limited set of functions that link the * This section describes the fairly limited set of functions that link the
* BAC-stack handlers to the BACnet Object instances. All of these calls are * BAC-stack handlers to the BACnet Object instances. All of these calls are
+13 -11
View File
@@ -407,7 +407,8 @@ bool Routed_Device_Name(
{ {
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if (object_instance == pDev->bacObj.Object_Instance_Number) { if (object_instance == pDev->bacObj.Object_Instance_Number) {
return characterstring_init_ansi(object_name, pDev->bacObj.Object_Name); return characterstring_init_ansi(object_name,
pDev->bacObj.Object_Name);
} }
return NULL; return NULL;
@@ -485,8 +486,8 @@ bool Routed_Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Routed_Device_Set_Object_Instance_Number(value.type. (Routed_Device_Set_Object_Instance_Number(value.
Object_Id.instance))) { type.Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */ /* FIXME: we could send an I-Am broadcast to let the world know */
} else { } else {
status = false; status = false;
@@ -500,8 +501,8 @@ bool Routed_Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false, WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Routed_Device_Set_Object_Name(characterstring_encoding(&value. Routed_Device_Set_Object_Name(characterstring_encoding
type.Character_String), (&value.type.Character_String),
characterstring_value(&value.type.Character_String), characterstring_value(&value.type.Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
@@ -617,14 +618,14 @@ int Routed_Device_Service_Approval(
uint8_t invoke_id) uint8_t invoke_id)
{ {
int len = 0; int len = 0;
switch(service) switch (service) {
{
case SERVICE_CONFIRMED_REINITIALIZE_DEVICE: case SERVICE_CONFIRMED_REINITIALIZE_DEVICE:
/* If not the gateway device, we don't support RD */ /* If not the gateway device, we don't support RD */
if (iCurrent_Device_Idx > 0) { if (iCurrent_Device_Idx > 0) {
if (apdu_buff != NULL) if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff, len =
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE); reject_encode_apdu(apdu_buff, invoke_id,
REJECT_REASON_UNRECOGNIZED_SERVICE);
else else
len = 1; /* Non-zero return */ len = 1; /* Non-zero return */
} }
@@ -633,8 +634,9 @@ int Routed_Device_Service_Approval(
/* If not the gateway device, we don't support DCC */ /* If not the gateway device, we don't support DCC */
if (iCurrent_Device_Idx > 0) { if (iCurrent_Device_Idx > 0) {
if (apdu_buff != NULL) if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff, len =
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE); reject_encode_apdu(apdu_buff, invoke_id,
REJECT_REASON_UNRECOGNIZED_SERVICE);
else else
len = 1; /* Non-zero return */ len = 1; /* Non-zero return */
} }
-1
View File
@@ -76,5 +76,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+8 -8
View File
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
object_index = object_index =
Lighting_Output_Instance_To_Index(rpdata->object_instance); Lighting_Output_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Lighting_Output_Level[object_index][rpdata->array_index if (Lighting_Output_Level[object_index][rpdata->
- 1] == LIGHTING_LEVEL_NULL) array_index - 1] == LIGHTING_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]); apdu_len = encode_application_null(&apdu[0]);
else { else {
real_value = Lighting_Output_Level[object_index] real_value = Lighting_Output_Level[object_index]
@@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property(
if (status) { if (status) {
level = LIGHTING_LEVEL_NULL; level = LIGHTING_LEVEL_NULL;
object_index = object_index =
Lighting_Output_Instance_To_Index Lighting_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
status = status =
Lighting_Output_Present_Value_Relinquish Lighting_Output_Present_Value_Relinquish(wp_data->
(wp_data->object_instance, wp_data->priority); object_instance, wp_data->priority);
if (wp_data->priority == 6) { if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any algorithm and may not be used for other purposes in any
@@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Lighting_Output_Instance_To_Index Lighting_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Lighting_Output_Out_Of_Service[object_index] = Lighting_Output_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+4 -4
View File
@@ -332,8 +332,8 @@ bool Life_Safety_Point_Write_Property(
if (status) { if (status) {
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) { if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
object_index = object_index =
Life_Safety_Point_Instance_To_Index Life_Safety_Point_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Life_Safety_Point_Mode[object_index] = Life_Safety_Point_Mode[object_index] =
value.type.Enumerated; value.type.Enumerated;
} else { } else {
@@ -349,8 +349,8 @@ bool Life_Safety_Point_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Life_Safety_Point_Instance_To_Index Life_Safety_Point_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Life_Safety_Point_Out_Of_Service[object_index] = Life_Safety_Point_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
-1
View File
@@ -69,5 +69,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+6 -6
View File
@@ -436,8 +436,8 @@ int Multistate_Input_Read_Property(
/* if no index was specified, then try to encode the entire list */ /* if no index was specified, then try to encode the entire list */
/* into one packet. */ /* into one packet. */
object_index = object_index =
Multistate_Input_Instance_To_Index Multistate_Input_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) { for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance, Multistate_Input_State_Text(rpdata->object_instance,
@@ -458,8 +458,8 @@ int Multistate_Input_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Input_Instance_To_Index Multistate_Input_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) { if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance, Multistate_Input_State_Text(rpdata->object_instance,
@@ -517,8 +517,8 @@ bool Multistate_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
status = status =
Multistate_Input_Present_Value_Set Multistate_Input_Present_Value_Set(wp_data->
(wp_data->object_instance, value.type.Unsigned_Int); object_instance, value.type.Unsigned_Int);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -103,5 +103,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+10 -10
View File
@@ -268,8 +268,8 @@ int Multistate_Output_Read_Property(
/* into one packet. */ /* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) { else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */ /* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] == if (Multistate_Output_Level[object_index][i] ==
@@ -294,8 +294,8 @@ int Multistate_Output_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Multistate_Output_Level[object_index] if (Multistate_Output_Level[object_index]
[rpdata->array_index - 1] == MULTISTATE_NULL) [rpdata->array_index - 1] == MULTISTATE_NULL)
@@ -377,8 +377,8 @@ bool Multistate_Output_Write_Property(
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) { (value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
level = value.type.Unsigned_Int; level = value.type.Unsigned_Int;
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Multistate_Output_Level[object_index][priority] = Multistate_Output_Level[object_index][priority] =
(uint8_t) level; (uint8_t) level;
@@ -405,8 +405,8 @@ bool Multistate_Output_Write_Property(
if (status) { if (status) {
level = MULTISTATE_NULL; level = MULTISTATE_NULL;
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
@@ -432,8 +432,8 @@ bool Multistate_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Multistate_Output_Out_Of_Service[object_index] = Multistate_Output_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
-1
View File
@@ -71,5 +71,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+6 -6
View File
@@ -438,8 +438,8 @@ int Multistate_Value_Read_Property(
/* if no index was specified, then try to encode the entire list */ /* if no index was specified, then try to encode the entire list */
/* into one packet. */ /* into one packet. */
object_index = object_index =
Multistate_Value_Instance_To_Index Multistate_Value_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) { for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Value_State_Text(rpdata->object_instance, Multistate_Value_State_Text(rpdata->object_instance,
@@ -460,8 +460,8 @@ int Multistate_Value_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Value_Instance_To_Index Multistate_Value_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) { if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Value_State_Text(rpdata->object_instance, Multistate_Value_State_Text(rpdata->object_instance,
@@ -519,8 +519,8 @@ bool Multistate_Value_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
status = status =
Multistate_Value_Present_Value_Set Multistate_Value_Present_Value_Set(wp_data->
(wp_data->object_instance, value.type.Unsigned_Int); object_instance, value.type.Unsigned_Int);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -103,5 +103,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+56 -61
View File
@@ -189,8 +189,8 @@ int Notification_Class_Read_Property(
apdu = rpdata->application_data; apdu = rpdata->application_data;
CurrentNotify = CurrentNotify =
&NC_Info[Notification_Class_Instance_To_Index(rpdata-> &NC_Info[Notification_Class_Instance_To_Index
object_instance)]; (rpdata->object_instance)];
switch (rpdata->object_property) { switch (rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
@@ -400,8 +400,8 @@ bool Notification_Class_Write_Property(
CurrentNotify = CurrentNotify =
&NC_Info[Notification_Class_Instance_To_Index(wp_data-> &NC_Info[Notification_Class_Instance_To_Index
object_instance)]; (wp_data->object_instance)];
/* decode the some of the request /* decode the some of the request
*/ */
@@ -455,9 +455,8 @@ bool Notification_Class_Write_Property(
while (iOffset < wp_data->application_data_len) { while (iOffset < wp_data->application_data_len) {
/* Decode Valid Days */ /* Decode Valid Days */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value);
&value);
if ((len == 0) || if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) { (value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
@@ -480,9 +479,8 @@ bool Notification_Class_Write_Property(
iOffset += len; iOffset += len;
/* Decode From Time */ /* Decode From Time */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value);
&value);
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) { if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
/* Bad decode, wrong tag or following required parameter missing */ /* Bad decode, wrong tag or following required parameter missing */
@@ -496,9 +494,8 @@ bool Notification_Class_Write_Property(
iOffset += len; iOffset += len;
/* Decode To Time */ /* Decode To Time */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value);
&value);
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) { if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
/* Bad decode, wrong tag or following required parameter missing */ /* Bad decode, wrong tag or following required parameter missing */
@@ -517,9 +514,8 @@ bool Notification_Class_Write_Property(
RECIPIENT_TYPE_DEVICE; RECIPIENT_TYPE_DEVICE;
/* Decode Network Number */ /* Decode Network Number */
len = len =
bacapp_decode_context_data(&wp_data-> bacapp_decode_context_data(&wp_data->application_data
application_data[iOffset], [iOffset], wp_data->application_data_len, &value,
wp_data->application_data_len, &value,
PROP_RECIPIENT_LIST); PROP_RECIPIENT_LIST);
if ((len == 0) || if ((len == 0) ||
@@ -530,21 +526,21 @@ bool Notification_Class_Write_Property(
return false; return false;
} }
/* store value */ /* store value */
TmpNotify.Recipient_List[idx].Recipient._. TmpNotify.Recipient_List[idx].Recipient.
DeviceIdentifier = value.type.Object_Id.instance; _.DeviceIdentifier = value.type.Object_Id.instance;
iOffset += len; iOffset += len;
} }
/* opening tag [1] - Recipient */ /* opening tag [1] - Recipient */
else if (decode_is_opening_tag_number(&wp_data-> else if (decode_is_opening_tag_number
application_data[iOffset], 1)) { (&wp_data->application_data[iOffset], 1)) {
iOffset++; iOffset++;
TmpNotify.Recipient_List[idx].Recipient.RecipientType = TmpNotify.Recipient_List[idx].Recipient.RecipientType =
RECIPIENT_TYPE_ADDRESS; RECIPIENT_TYPE_ADDRESS;
/* Decode Network Number */ /* Decode Network Number */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data
application_data[iOffset], (&wp_data->application_data[iOffset],
wp_data->application_data_len, &value); wp_data->application_data_len, &value);
if ((len == 0) || if ((len == 0) ||
@@ -561,8 +557,8 @@ bool Notification_Class_Write_Property(
iOffset += len; iOffset += len;
/* Decode Address */ /* Decode Address */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data
application_data[iOffset], (&wp_data->application_data[iOffset],
wp_data->application_data_len, &value); wp_data->application_data_len, &value);
if ((len == 0) || if ((len == 0) ||
@@ -573,16 +569,16 @@ bool Notification_Class_Write_Property(
return false; return false;
} }
/* store value */ /* store value */
if (TmpNotify.Recipient_List[idx].Recipient._.Address. if (TmpNotify.Recipient_List[idx].Recipient._.
net == 0) { Address.net == 0) {
memcpy(TmpNotify.Recipient_List[idx].Recipient._. memcpy(TmpNotify.Recipient_List[idx].Recipient.
Address.mac, value.type.Octet_String.value, _.Address.mac, value.type.Octet_String.value,
value.type.Octet_String.length); value.type.Octet_String.length);
TmpNotify.Recipient_List[idx].Recipient._.Address. TmpNotify.Recipient_List[idx].Recipient._.
mac_len = value.type.Octet_String.length; Address.mac_len = value.type.Octet_String.length;
} else { } else {
memcpy(TmpNotify.Recipient_List[idx].Recipient._. memcpy(TmpNotify.Recipient_List[idx].Recipient.
Address.adr, value.type.Octet_String.value, _.Address.adr, value.type.Octet_String.value,
value.type.Octet_String.length); value.type.Octet_String.length);
TmpNotify.Recipient_List[idx].Recipient._.Address.len = TmpNotify.Recipient_List[idx].Recipient._.Address.len =
value.type.Octet_String.length; value.type.Octet_String.length;
@@ -590,8 +586,8 @@ bool Notification_Class_Write_Property(
iOffset += len; iOffset += len;
/* closing tag [1] - Recipient */ /* closing tag [1] - Recipient */
if (decode_is_closing_tag_number(&wp_data-> if (decode_is_closing_tag_number(&wp_data->application_data
application_data[iOffset], 1)) [iOffset], 1))
iOffset++; iOffset++;
else { else {
/* Bad decode, wrong tag or following required parameter missing */ /* Bad decode, wrong tag or following required parameter missing */
@@ -608,9 +604,8 @@ bool Notification_Class_Write_Property(
/* Process Identifier */ /* Process Identifier */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value);
&value);
if ((len == 0) || if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) { (value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
@@ -626,9 +621,8 @@ bool Notification_Class_Write_Property(
iOffset += len; iOffset += len;
/* Issue Confirmed Notifications */ /* Issue Confirmed Notifications */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value);
&value);
if ((len == 0) || if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) { (value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) {
@@ -644,9 +638,8 @@ bool Notification_Class_Write_Property(
iOffset += len; iOffset += len;
/* Transitions */ /* Transitions */
len = len =
bacapp_decode_application_data(&wp_data-> bacapp_decode_application_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value);
&value);
if ((len == 0) || if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) { (value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
@@ -687,16 +680,16 @@ bool Notification_Class_Write_Property(
CurrentNotify->Recipient_List[idx] = CurrentNotify->Recipient_List[idx] =
TmpNotify.Recipient_List[idx]; TmpNotify.Recipient_List[idx];
if (CurrentNotify->Recipient_List[idx].Recipient. if (CurrentNotify->Recipient_List[idx].
RecipientType == RECIPIENT_TYPE_DEVICE) { Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) {
/* copy Device_ID */ /* copy Device_ID */
DeviceID = DeviceID =
CurrentNotify->Recipient_List[idx].Recipient._. CurrentNotify->Recipient_List[idx].Recipient.
DeviceIdentifier; _.DeviceIdentifier;
address_bind_request(DeviceID, &max_apdu, &src); address_bind_request(DeviceID, &max_apdu, &src);
} else if (CurrentNotify->Recipient_List[idx].Recipient. } else if (CurrentNotify->Recipient_List[idx].
RecipientType == RECIPIENT_TYPE_ADDRESS) { Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
/* copy Address */ /* copy Address */
/* src = CurrentNotify->Recipient_List[idx].Recipient._.Address; */ /* src = CurrentNotify->Recipient_List[idx].Recipient._.Address; */
/* address_bind_request(BACNET_MAX_INSTANCE, &max_apdu, &src); */ /* address_bind_request(BACNET_MAX_INSTANCE, &max_apdu, &src); */
@@ -816,17 +809,19 @@ void Notification_Class_common_reporting_function(
/* Priority and AckRequired */ /* Priority and AckRequired */
switch (event_data->toState) { switch (event_data->toState) {
case EVENT_STATE_NORMAL: case EVENT_STATE_NORMAL:
event_data->priority = CurrentNotify->Priority[TRANSITION_TO_NORMAL]; event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_NORMAL];
event_data->ackRequired = event_data->ackRequired =
(CurrentNotify-> (CurrentNotify->Ack_Required & TRANSITION_TO_NORMAL_MASKED) ?
Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? true : false; true : false;
break; break;
case EVENT_STATE_FAULT: case EVENT_STATE_FAULT:
event_data->priority = CurrentNotify->Priority[TRANSITION_TO_FAULT]; event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_FAULT];
event_data->ackRequired = event_data->ackRequired =
(CurrentNotify-> (CurrentNotify->Ack_Required & TRANSITION_TO_FAULT_MASKED) ?
Ack_Required & TRANSITION_TO_FAULT_MASKED) ? true : false; true : false;
break; break;
case EVENT_STATE_OFFNORMAL: case EVENT_STATE_OFFNORMAL:
@@ -835,8 +830,8 @@ void Notification_Class_common_reporting_function(
event_data->priority = event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL]; CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL];
event_data->ackRequired = event_data->ackRequired =
(CurrentNotify-> (CurrentNotify->Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED)
Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false; ? true : false;
break; break;
default: /* shouldn't happen */ default: /* shouldn't happen */
@@ -911,13 +906,13 @@ void Notification_Class_find_recipient(
RECIPIENT_TYPE_DEVICE) { RECIPIENT_TYPE_DEVICE) {
/* Device ID */ /* Device ID */
DeviceID = DeviceID =
CurrentNotify->Recipient_List[idx].Recipient._. CurrentNotify->Recipient_List[idx].Recipient.
DeviceIdentifier; _.DeviceIdentifier;
/* Send who_ is request only when address of device is unknown. */ /* Send who_ is request only when address of device is unknown. */
if (!address_bind_request(DeviceID, &max_apdu, &src)) if (!address_bind_request(DeviceID, &max_apdu, &src))
Send_WhoIs(DeviceID, DeviceID); Send_WhoIs(DeviceID, DeviceID);
} else if (CurrentNotify->Recipient_List[idx].Recipient. } else if (CurrentNotify->Recipient_List[idx].
RecipientType == RECIPIENT_TYPE_ADDRESS) { Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
} }
} }
-1
View File
@@ -138,5 +138,4 @@ BACnetRecipient ::= CHOICE {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* NC_H */ #endif /* NC_H */
+7 -7
View File
@@ -736,9 +736,9 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) { if (wp_data->application_data_len != 0) {
iOffset += len; iOffset += len;
len = len =
bacapp_decode_context_data(&wp_data->application_data bacapp_decode_context_data(&wp_data->
[iOffset], wp_data->application_data_len, &value, application_data[iOffset], wp_data->application_data_len,
PROP_LOG_DEVICE_OBJECT_PROPERTY); &value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || ((value.context_tag != 2) && if ((len == 0) || ((value.context_tag != 2) &&
(value.context_tag != 3))) { (value.context_tag != 3))) {
/* Bad decode or wrong tag */ /* Bad decode or wrong tag */
@@ -755,8 +755,8 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) { if (wp_data->application_data_len != 0) {
iOffset += len; iOffset += len;
len = len =
bacapp_decode_context_data bacapp_decode_context_data(&wp_data->
(&wp_data->application_data[iOffset], application_data[iOffset],
wp_data->application_data_len, &value, wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY); PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || (value.context_tag != 3)) { if ((len == 0) || (value.context_tag != 3)) {
@@ -1098,8 +1098,8 @@ int rr_trend_log_encode(
pRequest->ItemCount = 0; /* Start out with nothing */ pRequest->ItemCount = 0; /* Start out with nothing */
/* Bail out now if nowt - should never happen for a Trend Log but ... */ /* Bail out now if nowt - should never happen for a Trend Log but ... */
if (LogInfo[Trend_Log_Instance_To_Index(pRequest-> if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
object_instance)].ulRecordCount == 0) ulRecordCount == 0)
return (0); return (0);
if ((pRequest->RequestType == RR_BY_POSITION) || if ((pRequest->RequestType == RR_BY_POSITION) ||
-1
View File
@@ -197,5 +197,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+194 -214
View File
@@ -27,18 +27,24 @@ static bool isAtomicReadFileHandlerRegistered = false;
#define MAX_ERROR_STRING 128 #define MAX_ERROR_STRING 128
#define NO_ERROR "No Error" #define NO_ERROR "No Error"
static char Last_Error[MAX_ERROR_STRING] = NO_ERROR; static char Last_Error[MAX_ERROR_STRING] = NO_ERROR;
static void LogError(const char *msg) static void LogError(
const char *msg)
{ {
strcpy(Last_Error, msg); strcpy(Last_Error, msg);
Error_Detected = true; Error_Detected = true;
} }
void BacnetGetError(SV *errorMsg)
void BacnetGetError(
SV * errorMsg)
{ {
sv_setpv(errorMsg, Last_Error); sv_setpv(errorMsg, Last_Error);
strcpy(Last_Error, NO_ERROR); strcpy(Last_Error, NO_ERROR);
Error_Detected = false; Error_Detected = false;
} }
static void __LogAnswer(const char *msg, unsigned append)
static void __LogAnswer(
const char *msg,
unsigned append)
{ {
dSP; dSP;
ENTER; ENTER;
@@ -63,10 +69,10 @@ static void MyAbortHandler(
{ {
(void) server; (void) server;
if (address_match(&Target_Address, src) && if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) (invoke_id == Request_Invoke_ID)) {
{
char msg[MAX_ERROR_STRING]; char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Abort: %s", bactext_abort_reason_name((int) abort_reason)); sprintf(msg, "BACnet Abort: %s",
bactext_abort_reason_name((int) abort_reason));
LogError(msg); LogError(msg);
} }
} }
@@ -77,10 +83,10 @@ static void MyRejectHandler(
uint8_t reject_reason) uint8_t reject_reason)
{ {
if (address_match(&Target_Address, src) && if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) (invoke_id == Request_Invoke_ID)) {
{
char msg[MAX_ERROR_STRING]; char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Reject: %s", bactext_reject_reason_name((int) reject_reason)); sprintf(msg, "BACnet Reject: %s",
bactext_reject_reason_name((int) reject_reason));
LogError(msg); LogError(msg);
} }
} }
@@ -92,10 +98,11 @@ static void My_Error_Handler(
BACNET_ERROR_CODE error_code) BACNET_ERROR_CODE error_code)
{ {
if (address_match(&Target_Address, src) && if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) (invoke_id == Request_Invoke_ID)) {
{
char msg[MAX_ERROR_STRING]; char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Error: %s: %s", bactext_error_class_name((int) error_class), bactext_error_code_name((int) error_code)); sprintf(msg, "BACnet Error: %s: %s",
bactext_error_class_name((int) error_class),
bactext_error_code_name((int) error_code));
LogError(msg); LogError(msg);
} }
} }
@@ -108,7 +115,8 @@ static void My_Error_Handler(
// Decode the ReadProperty Ack and pass to perl // Decode the ReadProperty Ack and pass to perl
/****************************************/ /****************************************/
#define MAX_ACK_STRING 512 #define MAX_ACK_STRING 512
void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data) void rp_ack_extract_data(
BACNET_READ_PROPERTY_DATA * data)
{ {
char ackString[MAX_ACK_STRING] = ""; char ackString[MAX_ACK_STRING] = "";
char *pAckString = &ackString[0]; char *pAckString = &ackString[0];
@@ -120,8 +128,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
bool first_value = true; bool first_value = true;
bool print_brace = false; bool print_brace = false;
if (data) if (data) {
{
application_data = data->application_data; application_data = data->application_data;
application_data_len = data->application_data_len; application_data_len = data->application_data_len;
/* FIXME: what if application_data_len is bigger than 255? */ /* FIXME: what if application_data_len is bigger than 255? */
@@ -130,8 +137,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
len = len =
bacapp_decode_application_data(application_data, bacapp_decode_application_data(application_data,
(uint8_t) application_data_len, &value); (uint8_t) application_data_len, &value);
if (first_value && (len < application_data_len)) if (first_value && (len < application_data_len)) {
{
first_value = false; first_value = false;
strncat(pAckString, "{", 1); strncat(pAckString, "{", 1);
pAckString += 1; pAckString += 1;
@@ -142,7 +148,8 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
object_value.object_property = data->object_property; object_value.object_property = data->object_property;
object_value.array_index = data->array_index; object_value.array_index = data->array_index;
object_value.value = &value; object_value.value = &value;
bacapp_snprintf_value(pAckString, MAX_ACK_STRING - (pAckString - ackString), &object_value); bacapp_snprintf_value(pAckString,
MAX_ACK_STRING - (pAckString - ackString), &object_value);
if (len > 0) { if (len > 0) {
if (len < application_data_len) { if (len < application_data_len) {
application_data += len; application_data += len;
@@ -157,12 +164,10 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
break; break;
} }
} }
if (print_brace) if (print_brace) {
{
strncat(pAckString, "}", 1); strncat(pAckString, "}", 1);
pAckString += 1; pAckString += 1;
} }
// Now let's call a Perl function to display the data // Now let's call a Perl function to display the data
__LogAnswer(ackString, 0); __LogAnswer(ackString, 0);
} }
@@ -171,7 +176,8 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
/*****************************************/ /*****************************************/
// Decode the ReadPropertyMultiple Ack and pass to perl // Decode the ReadPropertyMultiple Ack and pass to perl
/****************************************/ /****************************************/
void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data) void rpm_ack_extract_data(
BACNET_READ_ACCESS_DATA * rpm_data)
{ {
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */ BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
BACNET_PROPERTY_REFERENCE *listOfProperties; BACNET_PROPERTY_REFERENCE *listOfProperties;
@@ -195,10 +201,14 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
object_value.object_type = rpm_data->object_type; object_value.object_type = rpm_data->object_type;
object_value.object_instance = rpm_data->object_instance; object_value.object_instance = rpm_data->object_instance;
while (value) { while (value) {
object_value.object_property = listOfProperties->propertyIdentifier; object_value.object_property =
object_value.array_index = listOfProperties->propertyArrayIndex; listOfProperties->propertyIdentifier;
object_value.array_index =
listOfProperties->propertyArrayIndex;
object_value.value = value; object_value.value = value;
bacapp_snprintf_value(pAckString, MAX_ACK_STRING - (pAckString - ackString), &object_value); bacapp_snprintf_value(pAckString,
MAX_ACK_STRING - (pAckString - ackString),
&object_value);
if (value->next) { if (value->next) {
strncat(pAckString, ",", 1); strncat(pAckString, ",", 1);
pAckString++; pAckString++;
@@ -213,10 +223,10 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
} else { } else {
/* AccessError */ /* AccessError */
sprintf(ackString, "BACnet Error: %s: %s", sprintf(ackString, "BACnet Error: %s: %s",
bactext_error_class_name((int) listOfProperties-> bactext_error_class_name((int) listOfProperties->error.
error.error_class), error_class),
bactext_error_code_name((int) listOfProperties-> bactext_error_code_name((int) listOfProperties->error.
error.error_code)); error_code));
LogError(ackString); LogError(ackString);
} }
listOfProperties = listOfProperties->next; listOfProperties = listOfProperties->next;
@@ -241,31 +251,30 @@ static void AtomicReadFileAckHandler(
int len = 0; int len = 0;
BACNET_ATOMIC_READ_FILE_DATA data; BACNET_ATOMIC_READ_FILE_DATA data;
if (address_match(&Target_Address, src) && (service_data->invoke_id == Request_Invoke_ID)) if (address_match(&Target_Address, src) &&
{ (service_data->invoke_id == Request_Invoke_ID)) {
len = arf_ack_decode_service_request(service_request, service_len, &data); len =
if (len > 0) arf_ack_decode_service_request(service_request, service_len,
{ &data);
if (len > 0) {
/* validate the parameters before storing data */ /* validate the parameters before storing data */
if ((data.access == FILE_STREAM_ACCESS) && (service_data->invoke_id == Request_Invoke_ID)) if ((data.access == FILE_STREAM_ACCESS) &&
{ (service_data->invoke_id == Request_Invoke_ID)) {
char msg[32]; char msg[32];
uint8_t *pFileData; uint8_t *pFileData;
int i; int i;
sprintf(msg, "EOF=%d,start=%d,", data.endOfFile, data.type.stream.fileStartPosition); sprintf(msg, "EOF=%d,start=%d,", data.endOfFile,
data.type.stream.fileStartPosition);
__LogAnswer(msg, 0); __LogAnswer(msg, 0);
pFileData = octetstring_value(&data.fileData); pFileData = octetstring_value(&data.fileData);
for (i=0; i<octetstring_length(&data.fileData); i++) for (i = 0; i < octetstring_length(&data.fileData); i++) {
{
sprintf(msg, "%02x ", *pFileData); sprintf(msg, "%02x ", *pFileData);
__LogAnswer(msg, 1); __LogAnswer(msg, 1);
pFileData++; pFileData++;
} }
} } else {
else
{
LogError("Bad stream access reported"); LogError("Bad stream access reported");
} }
} }
@@ -295,9 +304,9 @@ static void My_Read_Property_Ack_Handler(
if (address_match(&Target_Address, src) && if (address_match(&Target_Address, src) &&
(service_data->invoke_id == Request_Invoke_ID)) { (service_data->invoke_id == Request_Invoke_ID)) {
len = rp_ack_decode_service_request(service_request, service_len, &data); len =
if (len > 0) rp_ack_decode_service_request(service_request, service_len, &data);
{ if (len > 0) {
rp_ack_extract_data(&data); rp_ack_extract_data(&data);
} }
} }
@@ -383,14 +392,14 @@ void My_Write_Property_SimpleAck_Handler(
uint8_t invoke_id) uint8_t invoke_id)
{ {
if (address_match(&Target_Address, src) && if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) (invoke_id == Request_Invoke_ID)) {
{
__LogAnswer("WriteProperty Acknowledged!", 0); __LogAnswer("WriteProperty Acknowledged!", 0);
} }
} }
static void Init_Service_Handlers() static void Init_Service_Handlers(
)
{ {
Device_Init(NULL); Device_Init(NULL);
@@ -402,23 +411,26 @@ static void Init_Service_Handlers()
/* set the handler for all the services we don't implement /* set the handler for all the services we don't implement
It is required to send the proper reject message... */ It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler (handler_unrecognized_service); apdu_set_unrecognized_service_handler_handler
(handler_unrecognized_service);
/* we must implement read property - it's required! */ /* we must implement read property - it's required! */
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property); apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
handler_read_property);
/* handle generic errors coming back */ /* handle generic errors coming back */
apdu_set_abort_handler(MyAbortHandler); apdu_set_abort_handler(MyAbortHandler);
apdu_set_reject_handler(MyRejectHandler); apdu_set_reject_handler(MyRejectHandler);
} }
typedef enum typedef enum {
{
waitAnswer, waitAnswer,
waitBind, waitBind,
} waitAction; } waitAction;
static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action) static void Wait_For_Answer_Or_Timeout(
unsigned timeout_ms,
waitAction action)
{ {
// Wait for timeout, failure, or success // Wait for timeout, failure, or success
time_t last_seconds = time(NULL); time_t last_seconds = time(NULL);
@@ -428,59 +440,46 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
BACNET_ADDRESS src = { 0 }; /* address where message came from */ BACNET_ADDRESS src = { 0 }; /* address where message came from */
uint8_t Rx_Buf[MAX_MPDU] = { 0 }; uint8_t Rx_Buf[MAX_MPDU] = { 0 };
while (true) while (true) {
{
time_t current_seconds = time(NULL); time_t current_seconds = time(NULL);
// If error was detected then bail out // If error was detected then bail out
if (Error_Detected) if (Error_Detected) {
{
LogError("Some other error occurred"); LogError("Some other error occurred");
break; break;
} }
if (elapsed_seconds > timeout_seconds) if (elapsed_seconds > timeout_seconds) {
{
LogError("APDU Timeout"); LogError("APDU Timeout");
break; break;
} }
/* Process PDU if one comes in */ /* Process PDU if one comes in */
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout_ms); pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout_ms);
if (pdu_len) if (pdu_len) {
{
npdu_handler(&src, &Rx_Buf[0], pdu_len); npdu_handler(&src, &Rx_Buf[0], pdu_len);
} }
/* at least one second has passed */ /* at least one second has passed */
if (current_seconds != last_seconds) if (current_seconds != last_seconds) {
{
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000)); tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
} }
if (action == waitAnswer) if (action == waitAnswer) {
{
// Response was received. Exit. // Response was received. Exit.
if (tsm_invoke_id_free(Request_Invoke_ID)) if (tsm_invoke_id_free(Request_Invoke_ID)) {
{
break; break;
} } else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
else if (tsm_invoke_id_failed(Request_Invoke_ID))
{
LogError("TSM Timeout!"); LogError("TSM Timeout!");
tsm_free_invoke_id(Request_Invoke_ID); tsm_free_invoke_id(Request_Invoke_ID);
break; break;
} }
} } else if (action == waitBind) {
else if (action == waitBind) if (address_bind_request(Target_Device_Object_Instance,
{ &Target_Max_APDU, &Target_Address)) {
if (address_bind_request(Target_Device_Object_Instance, &Target_Max_APDU, &Target_Address))
{
break; break;
} }
} } else {
else
{
LogError("Invalid waitAction requested"); LogError("Invalid waitAction requested");
break; break;
} }
@@ -498,7 +497,8 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
/****************************************************/ /****************************************************/
// This is the most fundamental setup needed to start communication // This is the most fundamental setup needed to start communication
/****************************************************/ /****************************************************/
void BacnetPrepareComm() void BacnetPrepareComm(
)
{ {
/* setup my info */ /* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
@@ -511,7 +511,8 @@ void BacnetPrepareComm()
// Try to bind to a device. If successful, return zero. If failure, return // Try to bind to a device. If successful, return zero. If failure, return
// non-zero and log the error details // non-zero and log the error details
/****************************************************/ /****************************************************/
int BacnetBindToDevice(int deviceInstanceNumber) int BacnetBindToDevice(
int deviceInstanceNumber)
{ {
int isFailure = 0; int isFailure = 0;
@@ -520,14 +521,14 @@ int BacnetBindToDevice(int deviceInstanceNumber)
Target_Device_Object_Instance = deviceInstanceNumber; Target_Device_Object_Instance = deviceInstanceNumber;
/* try to bind with the device */ /* try to bind with the device */
if (! address_bind_request(deviceInstanceNumber, &Target_Max_APDU, &Target_Address)) if (!address_bind_request(deviceInstanceNumber, &Target_Max_APDU,
{ &Target_Address)) {
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
// Wait for timeout, failure, or success // Wait for timeout, failure, or success
Wait_For_Answer_Or_Timeout(100, waitBind); Wait_For_Answer_Or_Timeout(100, waitBind);
} }
// Clean up after ourselves // Clean up after ourselves
isFailure = Error_Detected; isFailure = Error_Detected;
Error_Detected = false; Error_Detected = false;
@@ -537,22 +538,29 @@ int BacnetBindToDevice(int deviceInstanceNumber)
/****************************************************/ /****************************************************/
// This is the interface to ReadProperty // This is the interface to ReadProperty
/****************************************************/ /****************************************************/
int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInstanceNumber, int objectProperty, int objectIndex) int BacnetReadProperty(
{ int deviceInstanceNumber,
if (!isReadPropertyHandlerRegistered) int objectType,
int objectInstanceNumber,
int objectProperty,
int objectIndex)
{ {
if (!isReadPropertyHandlerRegistered) {
/* handle the data coming back from confirmed requests */ /* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY, My_Read_Property_Ack_Handler); apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY,
My_Read_Property_Ack_Handler);
/* handle any errors coming back */ /* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, My_Error_Handler); apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY,
My_Error_Handler);
// indicate that handlers are now registered // indicate that handlers are now registered
isReadPropertyHandlerRegistered = true; isReadPropertyHandlerRegistered = true;
} }
// Send the message out // Send the message out
Request_Invoke_ID = Send_Read_Property_Request(deviceInstanceNumber, objectType, objectInstanceNumber, objectProperty, objectIndex); Request_Invoke_ID =
Send_Read_Property_Request(deviceInstanceNumber, objectType,
objectInstanceNumber, objectProperty, objectIndex);
Wait_For_Answer_Or_Timeout(100, waitAnswer); Wait_For_Answer_Or_Timeout(100, waitAnswer);
int isFailure = Error_Detected; int isFailure = Error_Detected;
@@ -563,34 +571,31 @@ int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInsta
/************************************************/ /************************************************/
// This is the interface to ReadPropertyMultiple // This is the interface to ReadPropertyMultiple
/************************************************/ /************************************************/
int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... ) int BacnetReadPropertyMultiple(
int deviceInstanceNumber,
...)
{ {
// Get the variable argument list from the stack // Get the variable argument list from the stack
Inline_Stack_Vars; Inline_Stack_Vars;
int rpmIndex = 1; int rpmIndex = 1;
BACNET_READ_ACCESS_DATA *rpm_object = calloc(1, sizeof(BACNET_READ_ACCESS_DATA)); BACNET_READ_ACCESS_DATA *rpm_object =
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
BACNET_READ_ACCESS_DATA *Read_Access_Data = rpm_object; BACNET_READ_ACCESS_DATA *Read_Access_Data = rpm_object;
BACNET_PROPERTY_REFERENCE *rpm_property; BACNET_PROPERTY_REFERENCE *rpm_property;
uint8_t buffer[MAX_PDU] = { 0 }; uint8_t buffer[MAX_PDU] = { 0 };
while (rpmIndex < Inline_Stack_Items) while (rpmIndex < Inline_Stack_Items) {
{
SV *pSV = Inline_Stack_Item(rpmIndex++); SV *pSV = Inline_Stack_Item(rpmIndex++);
// Make sure the argument is an Array Reference // Make sure the argument is an Array Reference
if (SvTYPE(SvRV(pSV)) != SVt_PVAV) if (SvTYPE(SvRV(pSV)) != SVt_PVAV) {
{
LogError("Argument is not an Array reference"); LogError("Argument is not an Array reference");
break; break;
} }
// Make sure we can access the memory // Make sure we can access the memory
if (rpm_object) if (rpm_object) {
{
rpm_object->listOfProperties = NULL; rpm_object->listOfProperties = NULL;
} } else {
else
{
LogError("Memory Allocation Issue"); LogError("Memory Allocation Issue");
break; break;
} }
@@ -600,107 +605,84 @@ int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
// The 0th argument is the object type // The 0th argument is the object type
ppSV = av_fetch(pAV, 0, 0); ppSV = av_fetch(pAV, 0, 0);
if (ppSV) if (ppSV) {
{
rpm_object->object_type = SvIV(*ppSV); rpm_object->object_type = SvIV(*ppSV);
} } else {
else
{
LogError("Problem parsing the Array of arguments"); LogError("Problem parsing the Array of arguments");
break; break;
} }
// The 1st argument is the object instance // The 1st argument is the object instance
ppSV = av_fetch(pAV, 1, 0); ppSV = av_fetch(pAV, 1, 0);
if (ppSV) if (ppSV) {
{
rpm_object->object_instance = SvIV(*ppSV); rpm_object->object_instance = SvIV(*ppSV);
} } else {
else
{
LogError("Problem parsing the Array of arguments"); LogError("Problem parsing the Array of arguments");
break; break;
} }
// The 2nd argument is the property type // The 2nd argument is the property type
ppSV = av_fetch(pAV, 2, 0); ppSV = av_fetch(pAV, 2, 0);
if (ppSV) if (ppSV) {
{
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE)); rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
rpm_object->listOfProperties = rpm_property; rpm_object->listOfProperties = rpm_property;
if (rpm_property) if (rpm_property) {
{
rpm_property->propertyIdentifier = SvIV(*ppSV); rpm_property->propertyIdentifier = SvIV(*ppSV);
} } else {
else
{
LogError("Memory allocation error"); LogError("Memory allocation error");
break; break;
} }
} } else {
else
{
LogError("Problem parsing the Array of arguments"); LogError("Problem parsing the Array of arguments");
break; break;
} }
// The 3rd argument is the property index // The 3rd argument is the property index
ppSV = av_fetch(pAV, 3, 0); ppSV = av_fetch(pAV, 3, 0);
if (ppSV) if (ppSV) {
{
rpm_property->propertyArrayIndex = SvIV(*ppSV); rpm_property->propertyArrayIndex = SvIV(*ppSV);
} } else {
else
{
LogError("Problem parsing the Array of arguments"); LogError("Problem parsing the Array of arguments");
break; break;
} }
// Advance to the next RPM index // Advance to the next RPM index
if (rpmIndex < Inline_Stack_Items) if (rpmIndex < Inline_Stack_Items) {
{
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA)); rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
rpm_object = rpm_object->next; rpm_object = rpm_object->next;
} } else {
else
{
rpm_object->next = NULL; rpm_object->next = NULL;
} }
} }
if (!isReadPropertyMultipleHandlerRegistered) if (!isReadPropertyMultipleHandlerRegistered) {
{
/* handle the data coming back from confirmed requests */ /* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE, apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
My_Read_Property_Multiple_Ack_Handler); My_Read_Property_Multiple_Ack_Handler);
/* handle any errors coming back */ /* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE, My_Error_Handler); apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
My_Error_Handler);
// indicate that handlers are now registered // indicate that handlers are now registered
isReadPropertyMultipleHandlerRegistered = true; isReadPropertyMultipleHandlerRegistered = true;
} }
// Send the message out // Send the message out
if (!Error_Detected) if (!Error_Detected) {
{ Request_Invoke_ID =
Request_Invoke_ID = Send_Read_Property_Multiple_Request( Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer),
&buffer[0], sizeof(buffer),
deviceInstanceNumber, Read_Access_Data); deviceInstanceNumber, Read_Access_Data);
Wait_For_Answer_Or_Timeout(100, waitAnswer); Wait_For_Answer_Or_Timeout(100, waitAnswer);
} }
// Clean up allocated memory // Clean up allocated memory
BACNET_READ_ACCESS_DATA *old_rpm_object; BACNET_READ_ACCESS_DATA *old_rpm_object;
BACNET_PROPERTY_REFERENCE *old_rpm_property; BACNET_PROPERTY_REFERENCE *old_rpm_property;
rpm_object = Read_Access_Data; rpm_object = Read_Access_Data;
old_rpm_object = rpm_object; old_rpm_object = rpm_object;
while (rpm_object) while (rpm_object) {
{
rpm_property = rpm_object->listOfProperties; rpm_property = rpm_object->listOfProperties;
while (rpm_property) while (rpm_property) {
{
old_rpm_property = rpm_property; old_rpm_property = rpm_property;
rpm_property = rpm_property->next; rpm_property = rpm_property->next;
free(old_rpm_property); free(old_rpm_property);
@@ -719,7 +701,8 @@ int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
/****************************************************/ /****************************************************/
// This is the interface to WriteProperty // This is the interface to WriteProperty
/****************************************************/ /****************************************************/
int BacnetWriteProperty(int deviceInstanceNumber, int BacnetWriteProperty(
int deviceInstanceNumber,
int objectType, int objectType,
int objectInstanceNumber, int objectInstanceNumber,
int objectProperty, int objectProperty,
@@ -731,51 +714,46 @@ int BacnetWriteProperty(int deviceInstanceNumber,
char msg[MAX_ERROR_STRING]; char msg[MAX_ERROR_STRING];
int isFailure = 1; int isFailure = 1;
if (!isWritePropertyHandlerRegistered) if (!isWritePropertyHandlerRegistered) {
{
/* handle the ack coming back */ /* handle the ack coming back */
apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, My_Write_Property_SimpleAck_Handler); apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
My_Write_Property_SimpleAck_Handler);
/* handle any errors coming back */ /* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, My_Error_Handler); apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
My_Error_Handler);
// indicate that handlers are now registered // indicate that handlers are now registered
isWritePropertyHandlerRegistered = true; isWritePropertyHandlerRegistered = true;
} }
if (objectIndex == -1) if (objectIndex == -1) {
{
objectIndex = BACNET_ARRAY_ALL; objectIndex = BACNET_ARRAY_ALL;
} }
// Loop for eary exit; // Loop for eary exit;
do do {
{
// Handle the tag/value pair // Handle the tag/value pair
uint8_t context_tag = 0; uint8_t context_tag = 0;
BACNET_APPLICATION_TAG property_tag; BACNET_APPLICATION_TAG property_tag;
BACNET_APPLICATION_DATA_VALUE propertyValue; BACNET_APPLICATION_DATA_VALUE propertyValue;
if (toupper(tag[0]) == 'C') if (toupper(tag[0]) == 'C') {
{
context_tag = strtol(&tag[1], NULL, 0); context_tag = strtol(&tag[1], NULL, 0);
propertyValue.context_tag = context_tag; propertyValue.context_tag = context_tag;
propertyValue.context_specific = true; propertyValue.context_specific = true;
} } else {
else
{
propertyValue.context_specific = false; propertyValue.context_specific = false;
} }
property_tag = strtol(tag, NULL, 0); property_tag = strtol(tag, NULL, 0);
if (property_tag >= MAX_BACNET_APPLICATION_TAG) if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
{ sprintf(msg, "Error: tag=%u - it must be less than %u",
sprintf(msg, "Error: tag=%u - it must be less than %u", property_tag, MAX_BACNET_APPLICATION_TAG); property_tag, MAX_BACNET_APPLICATION_TAG);
LogError(msg); LogError(msg);
break; break;
} }
if (!bacapp_parse_application_data(property_tag, value, &propertyValue)) if (!bacapp_parse_application_data(property_tag, value,
{ &propertyValue)) {
sprintf(msg, "Error: unable to parse the tag value"); sprintf(msg, "Error: unable to parse the tag value");
LogError(msg); LogError(msg);
break; break;
@@ -783,10 +761,10 @@ int BacnetWriteProperty(int deviceInstanceNumber,
propertyValue.next = NULL; propertyValue.next = NULL;
// Send out the message // Send out the message
Request_Invoke_ID = Send_Write_Property_Request( Request_Invoke_ID =
deviceInstanceNumber, Send_Write_Property_Request(deviceInstanceNumber, objectType,
objectType, objectInstanceNumber, objectInstanceNumber, objectProperty, &propertyValue,
objectProperty, &propertyValue, objectPriority, objectIndex); objectPriority, objectIndex);
Wait_For_Answer_Or_Timeout(100, waitAnswer); Wait_For_Answer_Or_Timeout(100, waitAnswer);
// If we get here, then there were no explicit failures. However, there // If we get here, then there were no explicit failures. However, there
@@ -800,7 +778,8 @@ int BacnetWriteProperty(int deviceInstanceNumber,
} }
int BacnetAtomicWriteFile (int deviceInstanceNumber, int BacnetAtomicWriteFile(
int deviceInstanceNumber,
int fileInstanceNumber, int fileInstanceNumber,
int blockStartAddr, int blockStartAddr,
int blockNumBytes, int blockNumBytes,
@@ -811,31 +790,24 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
uint8_t byteValue; uint8_t byteValue;
unsigned char nibbleValue; unsigned char nibbleValue;
if (!isAtomicWriteFileHandlerRegistered) if (!isAtomicWriteFileHandlerRegistered) {
{
/* handle any errors coming back */ /* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE, My_Error_Handler); apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE,
My_Error_Handler);
// indicate that handlers are now registered // indicate that handlers are now registered
isAtomicWriteFileHandlerRegistered = true; isAtomicWriteFileHandlerRegistered = true;
} }
for (i=0; i<blockNumBytes; i++) for (i = 0; i < blockNumBytes; i++) {
{
byteValue = 0; byteValue = 0;
for (nibble=0; nibble<2; nibble++) for (nibble = 0; nibble < 2; nibble++) {
{
nibbleValue = toupper(nibbleBuffer[i * 2 + nibble]); nibbleValue = toupper(nibbleBuffer[i * 2 + nibble]);
if ( (nibbleValue >= '0') && (nibbleValue <= '9') ) if ((nibbleValue >= '0') && (nibbleValue <= '9')) {
{
byteValue += (nibbleValue - '0') << (4 * (1 - nibble)); byteValue += (nibbleValue - '0') << (4 * (1 - nibble));
} } else if ((nibbleValue >= 'A') && (nibbleValue <= 'F')) {
else if ( (nibbleValue >= 'A') && (nibbleValue <= 'F') )
{
byteValue += (nibbleValue - 'A' + 10) << (4 * (1 - nibble)); byteValue += (nibbleValue - 'A' + 10) << (4 * (1 - nibble));
} } else {
else
{
LogError("Bad data in buffer."); LogError("Bad data in buffer.");
} }
} }
@@ -844,13 +816,10 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
octetstring_truncate(&fileData, blockNumBytes); octetstring_truncate(&fileData, blockNumBytes);
// Send out the message and wait for answer // Send out the message and wait for answer
if (!Error_Detected) if (!Error_Detected) {
{ Request_Invoke_ID =
Request_Invoke_ID = Send_Atomic_Write_File_Stream( Send_Atomic_Write_File_Stream(deviceInstanceNumber,
deviceInstanceNumber, fileInstanceNumber, blockStartAddr, &fileData);
fileInstanceNumber,
blockStartAddr,
&fileData);
Wait_For_Answer_Or_Timeout(100, waitAnswer); Wait_For_Answer_Or_Timeout(100, waitAnswer);
} }
@@ -859,7 +828,8 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
return isFailure; return isFailure;
} }
int BacnetGetMaxApdu() int BacnetGetMaxApdu(
)
{ {
unsigned requestedOctetCount = 0; unsigned requestedOctetCount = 0;
uint16_t my_max_apdu = 0; uint16_t my_max_apdu = 0;
@@ -887,7 +857,8 @@ int BacnetGetMaxApdu()
return requestedOctetCount; return requestedOctetCount;
} }
int BacnetTimeSync(int deviceInstanceNumber, int BacnetTimeSync(
int deviceInstanceNumber,
int year, int year,
int month, int month,
int day, int day,
@@ -896,7 +867,6 @@ int BacnetTimeSync(int deviceInstanceNumber,
int second, int second,
int isUTC, int isUTC,
int UTCOffset) int UTCOffset)
{ {
BACNET_DATE bdate; BACNET_DATE bdate;
BACNET_TIME btime; BACNET_TIME btime;
@@ -934,10 +904,8 @@ int BacnetTimeSync(int deviceInstanceNumber,
uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 }; uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 };
// Loop for eary exit // Loop for eary exit
do do {
{ if (!dcc_communication_enabled()) {
if (!dcc_communication_enabled())
{
LogError("DCC communicaiton is not enabled"); LogError("DCC communicaiton is not enabled");
break; break;
} }
@@ -945,18 +913,25 @@ int BacnetTimeSync(int deviceInstanceNumber,
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
datalink_get_my_address(&my_address); datalink_get_my_address(&my_address);
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &Target_Address, &my_address, &npdu_data); pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &Target_Address,
&my_address, &npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &bdate, &btime); len =
timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &bdate,
&btime);
pdu_len += len; pdu_len += len;
/* send it out the datalink */ /* send it out the datalink */
bytes_sent = datalink_send_pdu(&Target_Address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); bytes_sent =
if (bytes_sent <= 0) datalink_send_pdu(&Target_Address, &npdu_data,
{ &Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0) {
char errorMsg[64]; char errorMsg[64];
sprintf(errorMsg, "Failed to Send Time-Synchronization Request (%s)!", strerror(errno)); sprintf(errorMsg,
"Failed to Send Time-Synchronization Request (%s)!",
strerror(errno));
LogError(errorMsg); LogError(errorMsg);
break; break;
} }
@@ -972,26 +947,31 @@ int BacnetTimeSync(int deviceInstanceNumber,
/****************************************************/ /****************************************************/
// This is the interface to AtomicReadFile // This is the interface to AtomicReadFile
/****************************************************/ /****************************************************/
int BacnetAtomicReadFile(int deviceInstanceNumber, int fileInstanceNumber, int startOffset, int numBytes) int BacnetAtomicReadFile(
{ int deviceInstanceNumber,
if (!isAtomicReadFileHandlerRegistered) int fileInstanceNumber,
int startOffset,
int numBytes)
{ {
if (!isAtomicReadFileHandlerRegistered) {
/* handle the data coming back from confirmed requests */ /* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE, AtomicReadFileAckHandler); apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
AtomicReadFileAckHandler);
/* handle any errors coming back */ /* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE, My_Error_Handler); apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
My_Error_Handler);
// indicate that handlers are now registered // indicate that handlers are now registered
isAtomicReadFileHandlerRegistered = true; isAtomicReadFileHandlerRegistered = true;
} }
// Send the message out // Send the message out
Request_Invoke_ID = Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber, startOffset, numBytes); Request_Invoke_ID =
Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber,
startOffset, numBytes);
Wait_For_Answer_Or_Timeout(100, waitAnswer); Wait_For_Answer_Or_Timeout(100, waitAnswer);
int isFailure = Error_Detected; int isFailure = Error_Detected;
Error_Detected = 0; Error_Detected = 0;
return isFailure; return isFailure;
} }
+7 -7
View File
@@ -298,8 +298,7 @@ int main(
"%s 123 1 99 85,87[0],87\r\n" "%s 123 1 99 85,87[0],87\r\n"
"If you want read the PRESENT_VALUE property in objects\r\n" "If you want read the PRESENT_VALUE property in objects\r\n"
"Analog Input 77 and Analog Input 78 in Device 123\r\n" "Analog Input 77 and Analog Input 78 in Device 123\r\n"
"use the following command:\r\n" "use the following command:\r\n" "%s 123 0 77 85 0 78 85\r\n"
"%s 123 0 77 85 0 78 85\r\n"
"If you want read the ALL property in\r\n" "If you want read the ALL property in\r\n"
"Device object 123, you would use the following command:\r\n" "Device object 123, you would use the following command:\r\n"
"%s 123 8 123 8\r\n" "%s 123 8 123 8\r\n"
@@ -308,8 +307,8 @@ int main(
"%s 123 8 123 80\r\n" "%s 123 8 123 80\r\n"
"If you want read the REQUIRED property in\r\n" "If you want read the REQUIRED property in\r\n"
"Device object 123, you would use the following command:\r\n" "Device object 123, you would use the following command:\r\n"
"%s 123 8 123 105\r\n", "%s 123 8 123 105\r\n", filename, filename, filename, filename,
filename, filename, filename, filename, filename); filename);
} }
return 0; return 0;
} }
@@ -356,13 +355,14 @@ int main(
property_token = strtok(argv[tag_value_arg], ","); property_token = strtok(argv[tag_value_arg], ",");
/* add all the properties and optional index to our list */ /* add all the properties and optional index to our list */
while (rpm_property) { while (rpm_property) {
scan_count = sscanf(property_token, "%u[%u]", scan_count =
&property_id, sscanf(property_token, "%u[%u]", &property_id,
&property_array_index); &property_array_index);
if (scan_count > 0) { if (scan_count > 0) {
rpm_property->propertyIdentifier = property_id; rpm_property->propertyIdentifier = property_id;
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) { if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
fprintf(stderr, "property=%u - it must be less than %u\r\n", fprintf(stderr,
"property=%u - it must be less than %u\r\n",
rpm_property->propertyIdentifier, rpm_property->propertyIdentifier,
MAX_BACNET_PROPERTY_ID + 1); MAX_BACNET_PROPERTY_ID + 1);
return 1; return 1;
+17 -30
View File
@@ -187,40 +187,30 @@ int main(
if (print_usage_terse) { if (print_usage_terse) {
filename = filename_remove_path(argv[0]); filename = filename_remove_path(argv[0]);
printf("Usage: %s device-id object-type object-instance " printf("Usage: %s device-id object-type object-instance "
"process-id <[un]confirmed lifetime|cancel>\r\n", "process-id <[un]confirmed lifetime|cancel>\r\n", filename);
filename);
if (!print_usage_verbose) { if (!print_usage_verbose) {
return 0; return 0;
} }
} }
if (print_usage_verbose) { if (print_usage_verbose) {
printf("\r\n" printf("\r\n" "device-id:\r\n"
"device-id:\r\n" "The subscriber BACnet Device Object Instance number.\r\n" "\r\n"
"The subscriber BACnet Device Object Instance number.\r\n"
"\r\n"
"object-type:\r\n" "object-type:\r\n"
"The monitored object type is the integer value of the\r\n" "The monitored object type is the integer value of the\r\n"
"enumeration BACNET_OBJECT_TYPE in bacenum.h. For example,\r\n" "enumeration BACNET_OBJECT_TYPE in bacenum.h. For example,\r\n"
"if you were monitoring Analog Output 2, the object-type\r\n" "if you were monitoring Analog Output 2, the object-type\r\n"
"would be 1.\r\n" "would be 1.\r\n" "\r\n" "object-instance:\r\n"
"\r\n" "The monitored object instance number.\r\n" "\r\n"
"object-instance:\r\n"
"The monitored object instance number.\r\n"
"\r\n"
"process-id:\r\n" "process-id:\r\n"
"Process Identifier for this COV subscription.\r\n" "Process Identifier for this COV subscription.\r\n" "\r\n"
"\r\n"
"confirmed:\r\n" "confirmed:\r\n"
"Optional flag to subscribe using Confirmed notifications.\r\n" "Optional flag to subscribe using Confirmed notifications.\r\n"
"Use the word \'confirmed\' or \'unconfirmed\'.\r\n" "Use the word \'confirmed\' or \'unconfirmed\'.\r\n" "\r\n"
"\r\n"
"lifetime:\r\n" "lifetime:\r\n"
"Optional subscription lifetime is conveyed in seconds.\r\n" "Optional subscription lifetime is conveyed in seconds.\r\n" "\r\n"
"\r\n"
"cancel:\r\n" "cancel:\r\n"
"Use the word \'cancel\' instead of confirm and lifetime.\r\n" "Use the word \'cancel\' instead of confirm and lifetime.\r\n"
"This shall indicate a cancellation request.\r\n" "This shall indicate a cancellation request.\r\n" "\r\n"
"\r\n"
"Example:\r\n" "Example:\r\n"
"If you want subscribe to Device 123 Analog Input 9 object\r\n" "If you want subscribe to Device 123 Analog Input 9 object\r\n"
"using confirmed COV notifications for 5 minutes,\r\n" "using confirmed COV notifications for 5 minutes,\r\n"
@@ -230,8 +220,7 @@ int main(
"notifications, send the following command:\r\n" "notifications, send the following command:\r\n"
"%s 123 0 9 1 unconfirmed 600\r\n" "%s 123 0 9 1 unconfirmed 600\r\n"
"To cancel the same COV subscription request,\r\n" "To cancel the same COV subscription request,\r\n"
"send the following command:\r\n" "send the following command:\r\n" "%s 123 0 9 1 cancel\r\n",
"%s 123 0 9 1 cancel\r\n",
filename, filename, filename); filename, filename, filename);
return 0; return 0;
} }
@@ -247,11 +236,11 @@ int main(
cov_data = COV_Subscribe_Data; cov_data = COV_Subscribe_Data;
argi = 2; argi = 2;
while (cov_data) { while (cov_data) {
cov_data->monitoredObjectIdentifier.type = cov_data->monitoredObjectIdentifier.type = strtol(argv[argi], NULL, 0);
strtol(argv[argi], NULL, 0);
if (cov_data->monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) { if (cov_data->monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
fprintf(stderr, "object-type=%u - it must be less than %u\r\n", fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
cov_data->monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE); cov_data->monitoredObjectIdentifier.type,
MAX_BACNET_OBJECT_TYPE);
return 1; return 1;
} }
argi++; argi++;
@@ -264,8 +253,7 @@ int main(
return 1; return 1;
} }
argi++; argi++;
cov_data->subscriberProcessIdentifier = cov_data->subscriberProcessIdentifier = strtol(argv[argi], NULL, 0);
strtol(argv[argi], NULL, 0);
argi++; argi++;
if (strcmp(argv[argi], "cancel") == 0) { if (strcmp(argv[argi], "cancel") == 0) {
cov_data->cancellationRequest = true; cov_data->cancellationRequest = true;
@@ -277,8 +265,7 @@ int main(
} else if (strcmp(argv[argi], "unconfirmed") == 0) { } else if (strcmp(argv[argi], "unconfirmed") == 0) {
cov_data->issueConfirmedNotifications = false; cov_data->issueConfirmedNotifications = false;
} else { } else {
fprintf(stderr, "unknown option: %s\r\n", fprintf(stderr, "unknown option: %s\r\n", argv[argi]);
argv[argi]);
return 1; return 1;
} }
argi++; argi++;
@@ -342,8 +329,8 @@ int main(
if (Request_Invoke_ID == 0) { if (Request_Invoke_ID == 0) {
Target_Device_Process_Identifier = Target_Device_Process_Identifier =
cov_data->subscriberProcessIdentifier; cov_data->subscriberProcessIdentifier;
Request_Invoke_ID = Send_COV_Subscribe( Request_Invoke_ID =
Target_Device_Object_Instance, Send_COV_Subscribe(Target_Device_Object_Instance,
cov_data); cov_data);
if (!cov_data->cancellationRequest && if (!cov_data->cancellationRequest &&
(timeout_seconds < cov_data->lifetime)) { (timeout_seconds < cov_data->lifetime)) {
+9 -17
View File
@@ -179,34 +179,26 @@ int main(
"to try and bind with the device using Who-Is and\r\n" "to try and bind with the device using Who-Is and\r\n"
"I-Am services. For example, if you were transferring to\r\n" "I-Am services. For example, if you were transferring to\r\n"
"Device Object 123, the device-instance would be 123.\r\n" "Device Object 123, the device-instance would be 123.\r\n"
"\r\n" "\r\n" "vendor_id:\r\n"
"vendor_id:\r\n"
"the unique vendor identification code for the type of\r\n" "the unique vendor identification code for the type of\r\n"
"vendor proprietary service to be performed.\r\n" "vendor proprietary service to be performed.\r\n" "\r\n"
"\r\n"
"service-number (Unsigned32):\r\n" "service-number (Unsigned32):\r\n"
"the desired proprietary service to be performed.\r\n" "the desired proprietary service to be performed.\r\n" "\r\n"
"\r\n" "tag:\r\n" "Tag is the integer value of the enumeration \r\n"
"tag:\r\n"
"Tag is the integer value of the enumeration \r\n"
"BACNET_APPLICATION_TAG in bacenum.h.\r\n" "BACNET_APPLICATION_TAG in bacenum.h.\r\n"
"It is the data type of the value that you are sending.\r\n" "It is the data type of the value that you are sending.\r\n"
"For example, if you were transfering a REAL value, you would \r\n" "For example, if you were transfering a REAL value, you would \r\n"
"use a tag of 4.\r\n" "use a tag of 4.\r\n"
"Context tags are created using two tags in a row.\r\n" "Context tags are created using two tags in a row.\r\n"
"The context tag is preceded by a C. Ctag tag.\r\n" "The context tag is preceded by a C. Ctag tag.\r\n"
"C2 4 creates a context 2 tagged REAL.\r\n" "C2 4 creates a context 2 tagged REAL.\r\n" "\r\n" "value:\r\n"
"\r\n"
"value:\r\n"
"The value is an ASCII representation of some type of data\r\n" "The value is an ASCII representation of some type of data\r\n"
"that you are transfering.\r\n" "that you are transfering.\r\n"
"It is encoded using the tag information provided.\r\n" "It is encoded using the tag information provided.\r\n"
"For example, if you were transferring a REAL value of 100.0,\r\n" "For example, if you were transferring a REAL value of 100.0,\r\n"
"you would use 100.0 as the value.\r\n" "you would use 100.0 as the value.\r\n"
"If you were transferring an object identifier for Device 123,\r\n" "If you were transferring an object identifier for Device 123,\r\n"
"you would use 8:123 as the value.\r\n" "you would use 8:123 as the value.\r\n" "\r\n" "Example:\r\n"
"\r\n"
"Example:\r\n"
"If you want to transfer a REAL value of 1.1 to service 23 of \r\n" "If you want to transfer a REAL value of 1.1 to service 23 of \r\n"
"vendor 260 in Device 99, you could send the following command:\r\n" "vendor 260 in Device 99, you could send the following command:\r\n"
"%s 99 260 23 4 1.1\r\n", filename); "%s 99 260 23 4 1.1\r\n", filename);
@@ -310,14 +302,14 @@ int main(
} }
if (!sent_message) { if (!sent_message) {
if (found) { if (found) {
len = bacapp_encode_data(&Service_Parameters[0], len =
bacapp_encode_data(&Service_Parameters[0],
&Target_Object_Property_Value[0]); &Target_Object_Property_Value[0]);
private_data.serviceParameters = &Service_Parameters[0]; private_data.serviceParameters = &Service_Parameters[0];
private_data.serviceParametersLen = len; private_data.serviceParametersLen = len;
private_data.vendorID = Target_Vendor_Identifier; private_data.vendorID = Target_Vendor_Identifier;
private_data.serviceNumber = Target_Service_Number; private_data.serviceNumber = Target_Service_Number;
Send_UnconfirmedPrivateTransfer( Send_UnconfirmedPrivateTransfer(&Target_Address,
&Target_Address,
&private_data); &private_data);
printf("Sent PrivateTransfer. Waiting %u seconds.\r\n", printf("Sent PrivateTransfer. Waiting %u seconds.\r\n",
(unsigned) (timeout_seconds - elapsed_seconds)); (unsigned) (timeout_seconds - elapsed_seconds));
-1
View File
@@ -311,4 +311,3 @@ int main(
} }
return 0; return 0;
} }
+4 -2
View File
@@ -94,13 +94,15 @@ struct sockaddr_in; /* Defined elsewhere, needed here. */
/* Returns the last BVLL Result we received, either as the result of a BBMD /* Returns the last BVLL Result we received, either as the result of a BBMD
* request we sent, or (if not a BBMD or Client), from trying to register * request we sent, or (if not a BBMD or Client), from trying to register
* as a foreign device. */ * as a foreign device. */
BACNET_BVLC_RESULT bvlc_get_last_result(void); BACNET_BVLC_RESULT bvlc_get_last_result(
void);
/* Returns the current BVLL Function Code we are processing. /* Returns the current BVLL Function Code we are processing.
* We have to store this higher layer code for when the lower layers * We have to store this higher layer code for when the lower layers
* need to know what it is, especially to differentiate between * need to know what it is, especially to differentiate between
* BVLC_ORIGINAL_UNICAST_NPDU and BVLC_ORIGINAL_BROADCAST_NPDU. */ * BVLC_ORIGINAL_UNICAST_NPDU and BVLC_ORIGINAL_BROADCAST_NPDU. */
BACNET_BVLC_FUNCTION bvlc_get_function_code(void); BACNET_BVLC_FUNCTION bvlc_get_function_code(
void);
#ifdef __cplusplus #ifdef __cplusplus
} }
+8 -4
View File
@@ -37,10 +37,14 @@ extern "C" {
uint16_t elapsed_seconds); uint16_t elapsed_seconds);
/* Simple setters and getter. */ /* Simple setters and getter. */
void dlenv_bbmd_address_set( long address ); void dlenv_bbmd_address_set(
void dlenv_bbmd_port_set( int port ); long address);
void dlenv_bbmd_ttl_set( int ttl_secs ); void dlenv_bbmd_port_set(
int dlenv_bbmd_result( void ); int port);
void dlenv_bbmd_ttl_set(
int ttl_secs);
int dlenv_bbmd_result(
void);
#ifdef __cplusplus #ifdef __cplusplus
} }
+2 -1
View File
@@ -215,7 +215,8 @@ extern "C" {
uint16_t service_len, uint16_t service_len,
BACNET_ADDRESS * src, BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data); BACNET_CONFIRMED_SERVICE_DATA * service_data);
void handler_cov_task(void); void handler_cov_task(
void);
void handler_cov_timer_seconds( void handler_cov_timer_seconds(
uint32_t elapsed_seconds); uint32_t elapsed_seconds);
void handler_cov_init( void handler_cov_init(
+5 -2
View File
@@ -49,12 +49,15 @@ extern "C" {
/* encode objects */ /* encode objects */
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id); int wpm_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id);
int wpm_encode_apdu_object_begin( int wpm_encode_apdu_object_begin(
uint8_t * apdu, uint8_t * apdu,
BACNET_OBJECT_TYPE object_type, BACNET_OBJECT_TYPE object_type,
uint32_t object_instance); uint32_t object_instance);
int wpm_encode_apdu_object_end (uint8_t * apdu); int wpm_encode_apdu_object_end(
uint8_t * apdu);
int wpm_encode_apdu_object_property( int wpm_encode_apdu_object_property(
uint8_t * apdu, uint8_t * apdu,
BACNET_WRITE_PROPERTY_DATA * wpdata); BACNET_WRITE_PROPERTY_DATA * wpdata);
+2 -2
View File
@@ -360,8 +360,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real; level = (uint8_t) value.type.Real;
object_index = object_index =
Analog_Value_Instance_To_Index Analog_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Present_Value[object_index] = level; Present_Value[object_index] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
+2 -2
View File
@@ -271,8 +271,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated; level = value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level; Present_Value[object_index] = level;
+6 -6
View File
@@ -850,8 +850,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
@@ -903,13 +903,13 @@ bool Device_Write_Property_Local(
characterstring_encoding(&value.type.Character_String); characterstring_encoding(&value.type.Character_String);
if (encoding < MAX_CHARACTER_STRING_ENCODING) { if (encoding < MAX_CHARACTER_STRING_ENCODING) {
/* All the object names in a device must be unique. */ /* All the object names in a device must be unique. */
if (Device_Valid_Object_Name(&value.type. if (Device_Valid_Object_Name(&value.
Character_String, NULL, NULL)) { type.Character_String, NULL, NULL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME; wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else { } else {
Device_Set_Object_Name(&value.type. Device_Set_Object_Name(&value.
Character_String); type.Character_String);
status = true; status = true;
} }
} else { } else {
+1 -2
View File
@@ -1119,8 +1119,7 @@ static bool MSTP_Master_Node_FSM(
Master_State = MSTP_MASTER_STATE_IDLE; Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */ /* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false; MSTP_Flag.ReceivedValidFrame = false;
} else if ((Timer_Silence() > Treply_delay) || } else if ((Timer_Silence() > Treply_delay) || (pkt != NULL)) {
(pkt != NULL)) {
/* DeferredReply */ /* DeferredReply */
/* If no reply will be available from the higher layers */ /* If no reply will be available from the higher layers */
/* within Treply_delay after the reception of the */ /* within Treply_delay after the reception of the */
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) || if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) { (value.type.Enumerated == BINARY_INACTIVE)) {
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated; (BACNET_BINARY_PV) value.type.Enumerated;
+2 -2
View File
@@ -380,8 +380,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) || if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) { (value.type.Enumerated == BINARY_INACTIVE)) {
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated; (BACNET_BINARY_PV) value.type.Enumerated;
+7 -12
View File
@@ -64,18 +64,13 @@ bool bacnet_name_save(
uint8_t i = 0; uint8_t i = 0;
if (bacnet_name_isvalid(encoding, length, str)) { if (bacnet_name_isvalid(encoding, length, str)) {
eeprom_bytes_write( eeprom_bytes_write(NV_EEPROM_NAME_LENGTH(offset), &length, 1);
NV_EEPROM_NAME_LENGTH(offset), eeprom_bytes_write(NV_EEPROM_NAME_ENCODING(offset),
&length, 1);
eeprom_bytes_write(
NV_EEPROM_NAME_ENCODING(offset),
(uint8_t *) & encoding, 1); (uint8_t *) & encoding, 1);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
buffer[i] = str[i]; buffer[i] = str[i];
} }
eeprom_bytes_write( eeprom_bytes_write(NV_EEPROM_NAME_STRING(offset), &buffer[0],
NV_EEPROM_NAME_STRING(offset),
&buffer[0],
NV_EEPROM_NAME_SIZE); NV_EEPROM_NAME_SIZE);
return true; return true;
} }
@@ -118,8 +113,8 @@ bool bacnet_name_write_unique(
} else if (length <= NV_EEPROM_NAME_SIZE) { } else if (length <= NV_EEPROM_NAME_SIZE) {
encoding = characterstring_encoding(char_string); encoding = characterstring_encoding(char_string);
if (encoding < MAX_CHARACTER_STRING_ENCODING) { if (encoding < MAX_CHARACTER_STRING_ENCODING) {
if (Device_Valid_Object_Name(char_string, if (Device_Valid_Object_Name(char_string, &duplicate_type,
&duplicate_type, &duplicate_instance)) { &duplicate_instance)) {
if ((duplicate_type == object_type) && if ((duplicate_type == object_type) &&
(duplicate_instance == object_instance)) { (duplicate_instance == object_instance)) {
/* writing same name to same object */ /* writing same name to same object */
@@ -185,8 +180,8 @@ void bacnet_name_init(
uint16_t offset, uint16_t offset,
char *default_string) char *default_string)
{ {
(void)bacnet_name_save(offset, CHARACTER_UTF8, (void) bacnet_name_save(offset, CHARACTER_UTF8, default_string,
default_string, strlen(default_string)); strlen(default_string));
} }
void bacnet_name( void bacnet_name(
+2 -2
View File
@@ -439,8 +439,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
Binary_Output_Present_Value_Set Binary_Output_Present_Value_Set(wp_data->
(wp_data->object_instance, level, priority); object_instance, level, priority);
} else if (priority == 6) { } else if (priority == 6) {
status = false; status = false;
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
+6 -8
View File
@@ -856,8 +856,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
eeprom_bytes_write(NV_EEPROM_DEVICE_0, eeprom_bytes_write(NV_EEPROM_DEVICE_0,
(uint8_t *) & value.type.Object_Id.instance, 4); (uint8_t *) & value.type.Object_Id.instance, 4);
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
@@ -902,12 +902,10 @@ bool Device_Write_Property_Local(
break; break;
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) { if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = bacnet_name_write_unique( status =
NV_EEPROM_DEVICE_NAME, bacnet_name_write_unique(NV_EEPROM_DEVICE_NAME,
value.type.Object_Id.type, value.type.Object_Id.type, value.type.Object_Id.instance,
value.type.Object_Id.instance, &value.type.Character_String, &wp_data->error_class,
&value.type.Character_String,
&wp_data->error_class,
&wp_data->error_code); &wp_data->error_code);
} else { } else {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
+5 -2
View File
@@ -273,8 +273,11 @@ typedef struct {
#endif #endif
#elif defined (__CROSSWORKS_AVR) #elif defined (__CROSSWORKS_AVR)
/* use functions defined in crt0.s to mimic IAR macros */ /* use functions defined in crt0.s to mimic IAR macros */
void __uint8_eeprom_store(unsigned char byte, unsigned addr); void __uint8_eeprom_store(
unsigned char __uint8_eeprom_load(unsigned addr); unsigned char byte,
unsigned addr);
unsigned char __uint8_eeprom_load(
unsigned addr);
#define __EEPUT(addr, var) \ #define __EEPUT(addr, var) \
__uint8_eeprom_store((unsigned char)(var), (unsigned)(addr)) __uint8_eeprom_store((unsigned char)(var), (unsigned)(addr))
#define __EEGET(var, addr) \ #define __EEGET(var, addr) \
+6 -3
View File
@@ -165,17 +165,20 @@ void test_task(
case 'e': case 'e':
seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2); seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2);
sprintf(Send_Buffer, "\r\n%04X", id); sprintf(Send_Buffer, "\r\n%04X", id);
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer)); serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break; break;
case 'b': case 'b':
sprintf(Send_Buffer, "\r\n%lubps", sprintf(Send_Buffer, "\r\n%lubps",
(unsigned long) rs485_baud_rate()); (unsigned long) rs485_baud_rate());
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer)); serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break; break;
case 'm': case 'm':
sprintf(Send_Buffer, "\r\nMax:%u", sprintf(Send_Buffer, "\r\nMax:%u",
(unsigned) dlmstp_max_master()); (unsigned) dlmstp_max_master());
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer)); serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break; break;
default: default:
break; break;
+18 -41
View File
@@ -323,14 +323,9 @@ uint16_t MSTP_Get_Send(
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
} }
/* convert the PDU into the MSTP Frame */ /* convert the PDU into the MSTP Frame */
pdu_len = MSTP_Create_Frame( pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */
&mstp_port->OutputBuffer[0], /* <-- loading this */ mstp_port->OutputBufferSize, frame_type, pkt->destination_mac,
mstp_port->OutputBufferSize, mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length);
frame_type,
pkt->destination_mac,
mstp_port->This_Station,
(uint8_t *) & pkt->buffer[0],
pkt->length);
return pdu_len; return pdu_len;
} }
@@ -369,8 +364,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.network_layer_message) { if (request.npdu_data.network_layer_message) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "Request is Network message.\n");
"Request is Network message.\n");
#endif #endif
return false; return false;
} }
@@ -378,8 +372,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.pdu_type != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) { if (request.pdu_type != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "Not Confirmed Request.\n");
"Not Confirmed Request.\n");
#endif #endif
return false; return false;
} }
@@ -398,8 +391,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (reply.npdu_data.network_layer_message) { if (reply.npdu_data.network_layer_message) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "Reply is Network message.\n");
"Reply is Network message.\n");
#endif #endif
return false; return false;
} }
@@ -446,8 +438,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.invoke_id != reply.invoke_id) { if (request.invoke_id != reply.invoke_id) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n");
"Invoke ID mismatch.\n");
#endif #endif
return false; return false;
} }
@@ -455,16 +446,14 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.invoke_id != reply.invoke_id) { if (request.invoke_id != reply.invoke_id) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n");
"Invoke ID mismatch.\n");
#endif #endif
return false; return false;
} }
if (request.service_choice != reply.service_choice) { if (request.service_choice != reply.service_choice) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "Service choice mismatch.\n");
"Service choice mismatch.\n");
#endif #endif
return false; return false;
} }
@@ -480,16 +469,14 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.priority != reply.npdu_data.priority) { if (request.npdu_data.priority != reply.npdu_data.priority) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "NPDU Priority mismatch.\n");
"NPDU Priority mismatch.\n");
#endif #endif
return false; return false;
} }
if (!bacnet_address_same(&request.address, &reply.address)) { if (!bacnet_address_same(&request.address, &reply.address)) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"DLMSTP: DER Compare failed: " "DLMSTP: DER Compare failed: " "BACnet Address mismatch.\n");
"BACnet Address mismatch.\n");
#endif #endif
return false; return false;
} }
@@ -514,13 +501,9 @@ uint16_t MSTP_Get_Reply(
pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue);
/* is this the reply to the DER? */ /* is this the reply to the DER? */
matched = matched =
dlmstp_compare_data_expecting_reply( dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0],
&mstp_port->InputBuffer[0], mstp_port->DataLength, mstp_port->SourceAddress,
mstp_port->DataLength, (uint8_t *) & pkt->buffer[0], pkt->length, pkt->destination_mac);
mstp_port->SourceAddress,
(uint8_t *) & pkt->buffer[0],
pkt->length,
pkt->destination_mac);
if (!matched) { if (!matched) {
return 0; return 0;
} }
@@ -531,14 +514,9 @@ uint16_t MSTP_Get_Reply(
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
} }
/* convert the PDU into the MSTP Frame */ /* convert the PDU into the MSTP Frame */
pdu_len = MSTP_Create_Frame( pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */
&mstp_port->OutputBuffer[0], /* <-- loading this */ mstp_port->OutputBufferSize, frame_type, pkt->destination_mac,
mstp_port->OutputBufferSize, mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length);
frame_type,
pkt->destination_mac,
mstp_port->This_Station,
(uint8_t *) & pkt->buffer[0],
pkt->length);
return pdu_len; return pdu_len;
} }
@@ -678,8 +656,7 @@ bool dlmstp_init(
/* initialize PDU queue */ /* initialize PDU queue */
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer, Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
sizeof(struct mstp_pdu_packet), sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT);
MSTP_PDU_PACKET_COUNT);
/* initialize packet queue */ /* initialize packet queue */
Receive_Packet.ready = false; Receive_Packet.ready = false;
Receive_Packet.pdu_len = 0; Receive_Packet.pdu_len = 0;
+2 -2
View File
@@ -325,8 +325,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real; level = (uint8_t) value.type.Real;
object_index = object_index =
Analog_Value_Instance_To_Index Analog_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Present_Value[object_index] = level; Present_Value[object_index] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
+2 -2
View File
@@ -237,8 +237,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated; level = value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level; Present_Value[object_index] = level;
+2 -2
View File
@@ -533,8 +533,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+3 -7
View File
@@ -115,13 +115,9 @@ int dlmstp_send_pdu(
return -4; return -4;
} }
bytes_sent = bytes_sent =
MSTP_Create_Frame( MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0],
(uint8_t *) & MSTP_Port.TxBuffer[0], sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType,
sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxDestination, MSTP_Port.This_Station, pdu, pdu_len);
MSTP_Port.TxFrameType,
MSTP_Port.TxDestination,
MSTP_Port.This_Station,
pdu, pdu_len);
MSTP_Port.TxLength = bytes_sent; MSTP_Port.TxLength = bytes_sent;
MSTP_Port.TxReady = true; MSTP_Port.TxReady = true;
MSTP_Packets++; MSTP_Packets++;
+5 -9
View File
@@ -1145,13 +1145,10 @@ bool MSTP_Master_Node_FSM(
see if the message is that same APDU type see if the message is that same APDU type
along with the matching src/dest and invoke ID */ along with the matching src/dest and invoke ID */
matched = matched =
mstp_compare_data_expecting_reply( mstp_compare_data_expecting_reply(&mstp_port->
&mstp_port->InputBuffer[0], InputBuffer[0], mstp_port->DataLength,
mstp_port->DataLength, mstp_port->SourceAddress, &mstp_port->TxBuffer[0],
mstp_port->SourceAddress, mstp_port->TxLength, mstp_port->TxDestination);
&mstp_port->TxBuffer[0],
mstp_port->TxLength,
mstp_port->TxDestination);
} }
if (matched && mstp_port->TxReady) { if (matched && mstp_port->TxReady) {
/* Reply */ /* Reply */
@@ -1162,8 +1159,7 @@ bool MSTP_Master_Node_FSM(
/* then call MSTP_Create_And_Send_Frame to transmit the reply frame */ /* then call MSTP_Create_And_Send_Frame to transmit the reply frame */
/* and enter the IDLE state to wait for the next frame. */ /* and enter the IDLE state to wait for the next frame. */
RS485_Send_Frame(mstp_port, RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->TxBuffer[0], (uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength);
mstp_port->TxLength);
mstp_port->TxReady = false; mstp_port->TxReady = false;
mstp_port->master_state = MSTP_MASTER_STATE_IDLE; mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
} else { } else {
+1 -2
View File
@@ -261,8 +261,7 @@ bool bip_init(
bip_set_port(htons((0xBAC0)); bip_set_port(htons((0xBAC0));
/* assumes that the driver has already been initialized */ /* assumes that the driver has already been initialized */
sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP); sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP);
bip_set_socket(sock_fd); bip_set_socket(sock_fd); if (sock_fd < 0)
if (sock_fd < 0)
return false; return false;
/* bind the socket to the local port number and IP address */ /* bind the socket to the local port number and IP address */
sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY);
+2 -2
View File
@@ -429,8 +429,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
Binary_Output_Present_Value_Set Binary_Output_Present_Value_Set(wp_data->
(wp_data->object_instance, level, priority); object_instance, level, priority);
} else if (priority == 6) { } else if (priority == 6) {
status = false; status = false;
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
+8 -8
View File
@@ -833,8 +833,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
@@ -868,8 +868,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false, WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Object_Name(characterstring_value(&value. Device_Set_Object_Name(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -878,8 +878,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true, WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Location(characterstring_value(&value. Device_Set_Location(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -889,8 +889,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true, WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Description(characterstring_value(&value. Device_Set_Description(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
+2 -2
View File
@@ -430,8 +430,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
Binary_Output_Present_Value_Set Binary_Output_Present_Value_Set(wp_data->
(wp_data->object_instance, level, priority); object_instance, level, priority);
} else if (priority == 6) { } else if (priority == 6) {
status = false; status = false;
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
+6 -6
View File
@@ -836,8 +836,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
@@ -889,13 +889,13 @@ bool Device_Write_Property_Local(
characterstring_encoding(&value.type.Character_String); characterstring_encoding(&value.type.Character_String);
if (encoding < MAX_CHARACTER_STRING_ENCODING) { if (encoding < MAX_CHARACTER_STRING_ENCODING) {
/* All the object names in a device must be unique. */ /* All the object names in a device must be unique. */
if (Device_Valid_Object_Name(&value.type. if (Device_Valid_Object_Name(&value.
Character_String, NULL, NULL)) { type.Character_String, NULL, NULL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME; wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else { } else {
Device_Set_Object_Name(&value.type. Device_Set_Object_Name(&value.
Character_String); type.Character_String);
status = true; status = true;
} }
} else { } else {
+2 -4
View File
@@ -378,8 +378,7 @@ static bool MSTP_Transmit_FSM(
case MSTP_TX_STATE_IDLE: case MSTP_TX_STATE_IDLE:
if (!Ringbuf_Empty(&Transmit_Queue)) { if (!Ringbuf_Empty(&Transmit_Queue)) {
/* get the packet - but don't remove it from queue */ /* get the packet - but don't remove it from queue */
pkt = pkt = (struct mstp_tx_packet *)
(struct mstp_tx_packet *)
Ringbuf_Get_Front(&Transmit_Queue); Ringbuf_Get_Front(&Transmit_Queue);
state = MSTP_TX_STATE_SILENCE_WAIT; state = MSTP_TX_STATE_SILENCE_WAIT;
} }
@@ -1235,8 +1234,7 @@ static bool MSTP_Master_Node_FSM(
Master_State = MSTP_MASTER_STATE_IDLE; Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */ /* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false; MSTP_Flag.ReceivedValidFrame = false;
} else if (rs485_silence_elapsed(Treply_delay) || } else if (rs485_silence_elapsed(Treply_delay) || (pkt != NULL)) {
(pkt != NULL)) {
/* DeferredReply */ /* DeferredReply */
/* If no reply will be available from the higher layers */ /* If no reply will be available from the higher layers */
/* within Treply_delay after the reception of the */ /* within Treply_delay after the reception of the */
+1 -2
View File
@@ -63,8 +63,7 @@ BACNET_ABORT_REASON abort_convert_error_code(
abort_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED; abort_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED;
break; break;
case ERROR_CODE_ABORT_PROPRIETARY: case ERROR_CODE_ABORT_PROPRIETARY:
abort_code = abort_code = (BACNET_ABORT_REASON) FIRST_PROPRIETARY_ABORT_REASON;
(BACNET_ABORT_REASON)FIRST_PROPRIETARY_ABORT_REASON;
break; break;
case ERROR_CODE_ABORT_OTHER: case ERROR_CODE_ABORT_OTHER:
default: default:
+7 -7
View File
@@ -149,8 +149,7 @@ static struct Address_Cache_Entry *address_remove_oldest(
pMatch = Address_Cache; pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch-> if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) { BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
ulTime = pMatch->TimeToLive; ulTime = pMatch->TimeToLive;
@@ -169,8 +168,7 @@ static struct Address_Cache_Entry *address_remove_oldest(
/* Second pass - try in use and un bound as last resort */ /* Second pass - try in use and un bound as last resort */
pMatch = Address_Cache; pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch-> if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) == BAC_ADDR_STATIC)) ==
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) { ((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
@@ -208,7 +206,8 @@ static void address_file_init(
unsigned max_apdu = 0; unsigned max_apdu = 0;
unsigned mac[6] = { 0 }; unsigned mac[6] = { 0 };
int count = 0; int count = 0;
char mac_string[80] = {""}, sadr_string[80] = {""}; char mac_string[80] = { "" }, sadr_string[80] = {
""};
BACNET_ADDRESS src = { 0 }; BACNET_ADDRESS src = { 0 };
int index = 0; int index = 0;
@@ -230,8 +229,9 @@ static void address_file_init(
src.net = (uint16_t) snet; src.net = (uint16_t) snet;
if (snet) { if (snet) {
count = count =
sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x", &mac[0], sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x",
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); &mac[0], &mac[1], &mac[2], &mac[3], &mac[4],
&mac[5]);
src.len = (uint8_t) count; src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) { for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = (uint8_t) mac[index]; src.adr[index] = (uint8_t) mac[index];
+3 -2
View File
@@ -156,8 +156,9 @@ bool apdu_service_supported(
if (Confirmed_Function[i] != NULL) { if (Confirmed_Function[i] != NULL) {
#if BAC_ROUTING #if BAC_ROUTING
/* Check to see if the current Device supports this service. */ /* Check to see if the current Device supports this service. */
int len = Routed_Device_Service_Approval( int len =
service_supported, 0, NULL, 0); Routed_Device_Service_Approval(service_supported, 0,
NULL, 0);
if (len > 0) if (len > 0)
break; /* Not supported - return false */ break; /* Not supported - return false */
#endif #endif
+74 -66
View File
@@ -264,8 +264,7 @@ int bacapp_decode_data(
} }
} }
if ((len == 0) && if ((len == 0) && (tag_data_type != BACNET_APPLICATION_TAG_NULL) &&
(tag_data_type != BACNET_APPLICATION_TAG_NULL) &&
(tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) && (tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) &&
(tag_data_type != BACNET_APPLICATION_TAG_OCTET_STRING)) { (tag_data_type != BACNET_APPLICATION_TAG_OCTET_STRING)) {
/* indicate that we were not able to decode the value */ /* indicate that we were not able to decode the value */
@@ -739,8 +738,7 @@ int bacapp_decode_context_data(
} else { } else {
apdu_len = BACNET_STATUS_ERROR; apdu_len = BACNET_STATUS_ERROR;
} }
} } else if (tag_len == 1) /* and is a Closing tag */
else if ( tag_len == 1 ) /* and is a Closing tag */
apdu_len = 0; /* Don't advance over that closing tag. */ apdu_len = 0; /* Don't advance over that closing tag. */
} }
@@ -961,7 +959,10 @@ int bacapp_data_len(
} }
#ifdef BACAPP_SNPRINTF_ENABLED #ifdef BACAPP_SNPRINTF_ENABLED
static bool append_str(char **str, size_t *rem_str_len, const char *add_str) static bool append_str(
char **str,
size_t * rem_str_len,
const char *add_str)
{ {
bool retval; bool retval;
int bytes_written; int bytes_written;
@@ -970,9 +971,7 @@ static bool append_str(char **str, size_t *rem_str_len, const char *add_str)
if ((bytes_written < 0) || (bytes_written >= *rem_str_len)) { if ((bytes_written < 0) || (bytes_written >= *rem_str_len)) {
/* If there was an error or output was truncated, return error */ /* If there was an error or output was truncated, return error */
retval = false; retval = false;
} } else {
else
{
/* Successfully wrote the contents to the string. Let's advance the /* Successfully wrote the contents to the string. Let's advance the
* string pointer to the end, and account for the used space */ * string pointer to the end, and account for the used space */
*str += bytes_written; *str += bytes_written;
@@ -1016,26 +1015,27 @@ int bacapp_snprintf_value(
ret_val = snprintf(str, str_len, "Null"); ret_val = snprintf(str, str_len, "Null");
break; break;
case BACNET_APPLICATION_TAG_BOOLEAN: case BACNET_APPLICATION_TAG_BOOLEAN:
ret_val = (value->type.Boolean) ? ret_val =
snprintf(str, str_len, "TRUE") : (value->type.Boolean) ? snprintf(str, str_len,
snprintf(str, str_len, "FALSE"); "TRUE") : snprintf(str, str_len, "FALSE");
break; break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT: case BACNET_APPLICATION_TAG_UNSIGNED_INT:
ret_val = snprintf(str, str_len, "%lu", ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Unsigned_Int); (unsigned long) value->type.Unsigned_Int);
break; break;
case BACNET_APPLICATION_TAG_SIGNED_INT: case BACNET_APPLICATION_TAG_SIGNED_INT:
ret_val = snprintf(str, str_len, "%ld", ret_val =
snprintf(str, str_len, "%ld",
(long) value->type.Signed_Int); (long) value->type.Signed_Int);
break; break;
case BACNET_APPLICATION_TAG_REAL: case BACNET_APPLICATION_TAG_REAL:
ret_val = snprintf(str, str_len, "%f", ret_val =
(double) value->type.Real); snprintf(str, str_len, "%f", (double) value->type.Real);
break; break;
#if defined (BACAPP_DOUBLE) #if defined (BACAPP_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE: case BACNET_APPLICATION_TAG_DOUBLE:
ret_val = snprintf(str, str_len, "%f", ret_val = snprintf(str, str_len, "%f", value->type.Double);
value->type.Double);
break; break;
#endif #endif
case BACNET_APPLICATION_TAG_OCTET_STRING: case BACNET_APPLICATION_TAG_OCTET_STRING:
@@ -1047,15 +1047,15 @@ int bacapp_snprintf_value(
break; break;
octet_str++; octet_str++;
} }
if (i == len) if (i == len) {
{
// Everything went fine // Everything went fine
ret_val = str_len - rem_str_len; ret_val = str_len - rem_str_len;
} }
break; break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING: case BACNET_APPLICATION_TAG_CHARACTER_STRING:
len = characterstring_length(&value->type.Character_String); len = characterstring_length(&value->type.Character_String);
char_str = characterstring_value(&value->type.Character_String); char_str =
characterstring_value(&value->type.Character_String);
if (!append_str(&p_str, &rem_str_len, "\"")) if (!append_str(&p_str, &rem_str_len, "\""))
break; break;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
@@ -1068,10 +1068,8 @@ int bacapp_snprintf_value(
break; break;
char_str++; char_str++;
} }
if ( (i == len) && if ((i == len) && append_str(&p_str, &rem_str_len, "\"")
append_str(&p_str, &rem_str_len, "\"") ) {
)
{
// Everything is fine. Indicate how many bytes were // Everything is fine. Indicate how many bytes were
// written // written
ret_val = str_len - rem_str_len; ret_val = str_len - rem_str_len;
@@ -1087,16 +1085,13 @@ int bacapp_snprintf_value(
(uint8_t) i) ? "true" : "false"); (uint8_t) i) ? "true" : "false");
if (!append_str(&p_str, &rem_str_len, temp_str)) if (!append_str(&p_str, &rem_str_len, temp_str))
break; break;
if (i < len - 1) if (i < len - 1) {
{
if (!append_str(&p_str, &rem_str_len, ",")) if (!append_str(&p_str, &rem_str_len, ","))
break; break;
} }
} }
if ( (i == len) && if ((i == len) && append_str(&p_str, &rem_str_len, "}")
append_str(&p_str, &rem_str_len, "}") ) {
)
{
// Everything is fine. Indicate how many bytes were // Everything is fine. Indicate how many bytes were
// written // written
ret_val = str_len - rem_str_len; ret_val = str_len - rem_str_len;
@@ -1106,66 +1101,80 @@ int bacapp_snprintf_value(
switch (property) { switch (property) {
case PROP_OBJECT_TYPE: case PROP_OBJECT_TYPE:
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) { if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
ret_val = snprintf(str, str_len, "%s", ret_val =
bactext_object_type_name(value->type. snprintf(str, str_len, "%s",
Enumerated)); bactext_object_type_name(value->
type.Enumerated));
} else if (value->type.Enumerated < 128) { } else if (value->type.Enumerated < 128) {
ret_val = snprintf(str, str_len, "reserved %lu", ret_val =
snprintf(str, str_len, "reserved %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
} else { } else {
ret_val = snprintf(str, str_len, "proprietary %lu", ret_val =
snprintf(str, str_len, "proprietary %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
} }
break; break;
case PROP_EVENT_STATE: case PROP_EVENT_STATE:
ret_val = snprintf(str, str_len, "%s", ret_val =
snprintf(str, str_len, "%s",
bactext_event_state_name(value->type.Enumerated)); bactext_event_state_name(value->type.Enumerated));
break; break;
case PROP_UNITS: case PROP_UNITS:
if (value->type.Enumerated < 256) { if (value->type.Enumerated < 256) {
ret_val = snprintf(str, str_len, "%s", ret_val =
bactext_engineering_unit_name(value-> snprintf(str, str_len, "%s",
type.Enumerated)); bactext_engineering_unit_name(value->type.
Enumerated));
} else { } else {
ret_val = snprintf(str, str_len, "proprietary %lu", ret_val =
snprintf(str, str_len, "proprietary %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
} }
break; break;
case PROP_POLARITY: case PROP_POLARITY:
ret_val = snprintf(str, str_len, "%s", ret_val =
bactext_binary_polarity_name(value-> snprintf(str, str_len, "%s",
type.Enumerated)); bactext_binary_polarity_name(value->type.
Enumerated));
break; break;
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
case PROP_RELINQUISH_DEFAULT: case PROP_RELINQUISH_DEFAULT:
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) { if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
ret_val = snprintf(str, str_len, "%s", ret_val =
bactext_binary_present_value_name(value->type. snprintf(str, str_len, "%s",
Enumerated)); bactext_binary_present_value_name(value->
type.Enumerated));
} else { } else {
ret_val = snprintf(str, str_len, "%lu", ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
} }
break; break;
case PROP_RELIABILITY: case PROP_RELIABILITY:
ret_val = snprintf(str, str_len, "%s", ret_val =
snprintf(str, str_len, "%s",
bactext_reliability_name(value->type.Enumerated)); bactext_reliability_name(value->type.Enumerated));
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
ret_val = snprintf(str, str_len, "%s", ret_val =
bactext_device_status_name(value-> snprintf(str, str_len, "%s",
type.Enumerated)); bactext_device_status_name(value->type.
Enumerated));
break; break;
case PROP_SEGMENTATION_SUPPORTED: case PROP_SEGMENTATION_SUPPORTED:
ret_val = snprintf(str, str_len, "%s", ret_val =
snprintf(str, str_len, "%s",
bactext_segmentation_name(value->type.Enumerated)); bactext_segmentation_name(value->type.Enumerated));
break; break;
case PROP_NODE_TYPE: case PROP_NODE_TYPE:
ret_val = snprintf(str, str_len, "%s", ret_val =
snprintf(str, str_len, "%s",
bactext_node_type_name(value->type.Enumerated)); bactext_node_type_name(value->type.Enumerated));
break; break;
default: default:
ret_val = snprintf(str, str_len, "%lu", ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
break; break;
} }
@@ -1252,7 +1261,8 @@ int bacapp_snprintf_value(
break; break;
if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) { if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) {
if (!append_str(&p_str, &rem_str_len, if (!append_str(&p_str, &rem_str_len,
bactext_object_type_name(value->type.Object_Id.type) bactext_object_type_name(value->type.Object_Id.
type)
) )
) )
break; break;
@@ -1313,8 +1323,7 @@ bool bacapp_print_value(
size_t str_len = 32; size_t str_len = 32;
int status; int status;
while (true) while (true) {
{
// Try to allocate memory for the output string. Give up if unable. // Try to allocate memory for the output string. Give up if unable.
str = (char *) calloc(sizeof(char), str_len); str = (char *) calloc(sizeof(char), str_len);
if (!str) if (!str)
@@ -1323,12 +1332,10 @@ bool bacapp_print_value(
// Try to extract the value into allocated memory. If unable, try again // Try to extract the value into allocated memory. If unable, try again
// another time with a string that is twice as large. // another time with a string that is twice as large.
status = bacapp_snprintf_value(str, str_len, object_value); status = bacapp_snprintf_value(str, str_len, object_value);
if ( (status < 0 ) || (status >= str_len) ) if ((status < 0) || (status >= str_len)) {
{
free(str); free(str);
str_len *= 2; str_len *= 2;
} } else if (status == 0) {
else if (status == 0) {
free(str); free(str);
break; break;
} else { } else {
@@ -1413,7 +1420,8 @@ bool bacapp_parse_application_data(
break; break;
case BACNET_APPLICATION_TAG_DATE: case BACNET_APPLICATION_TAG_DATE:
count = count =
sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day, &wday); sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day,
&wday);
if (count == 3) { if (count == 3) {
datetime_set_date(&value->type.Date, (uint16_t) year, datetime_set_date(&value->type.Date, (uint16_t) year,
(uint8_t) month, (uint8_t) day); (uint8_t) month, (uint8_t) day);
@@ -1637,8 +1645,8 @@ void testBACnetApplicationData_Safe(
break; break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING: case BACNET_APPLICATION_TAG_CHARACTER_STRING:
characterstring_init_ansi(&input_value[i].type. characterstring_init_ansi(&input_value[i].
Character_String, "Hello There!"); type.Character_String, "Hello There!");
break; break;
case BACNET_APPLICATION_TAG_BIT_STRING: case BACNET_APPLICATION_TAG_BIT_STRING:
@@ -2113,8 +2121,8 @@ void testBACnetApplicationData(
ct_test(pTest, testBACnetApplicationDataValue(&value)); ct_test(pTest, testBACnetApplicationDataValue(&value));
/* test empty string */ /* test empty string */
status = status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, "",
"", &value); &value);
ct_test(pTest, status == true); ct_test(pTest, status == true);
ct_test(pTest, testBACnetApplicationDataValue(&value)); ct_test(pTest, testBACnetApplicationDataValue(&value));
+2 -1
View File
@@ -929,7 +929,8 @@ INDTEXT_DATA bacnet_property_names[] = {
, ,
{PROP_LAST_KEY_SERVER, "last-key-server"} {PROP_LAST_KEY_SERVER, "last-key-server"}
, ,
{PROP_NETWORK_ACCESS_SECURITY_ALGORITHMS, "network-access-security-algorithms"} {PROP_NETWORK_ACCESS_SECURITY_ALGORITHMS,
"network-access-security-algorithms"}
, ,
{PROP_PACKET_REORDER_TIME, "packet-reorder-time"} {PROP_PACKET_REORDER_TIME, "packet-reorder-time"}
, ,
+1 -2
View File
@@ -262,8 +262,7 @@ uint16_t bip_receive(
if (pdu[0] != BVLL_TYPE_BACNET_IP) if (pdu[0] != BVLL_TYPE_BACNET_IP)
return 0; return 0;
if ( bvlc_for_non_bbmd(&sin, pdu, received_bytes) > 0 ) if (bvlc_for_non_bbmd(&sin, pdu, received_bytes) > 0) {
{
/* Handled, usually with a NACK. */ /* Handled, usually with a NACK. */
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "BIP: BVLC discarded!\n"); fprintf(stderr, "BIP: BVLC discarded!\n");
+6 -4
View File
@@ -665,8 +665,8 @@ static void bvlc_bdt_forward_npdu(
mask in the BDT entry and logically ORing it with the mask in the BDT entry and logically ORing it with the
BBMD address of the same entry. */ BBMD address of the same entry. */
bip_dest.sin_addr.s_addr = bip_dest.sin_addr.s_addr =
((~BBMD_Table[i].broadcast_mask. ((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
s_addr) | BBMD_Table[i].dest_address.s_addr); dest_address.s_addr);
bip_dest.sin_port = BBMD_Table[i].dest_port; bip_dest.sin_port = BBMD_Table[i].dest_port;
/* don't send to my broadcast address and same port */ /* don't send to my broadcast address and same port */
if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr()) if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr())
@@ -1304,7 +1304,8 @@ int bvlc_for_non_bbmd(
* BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK if registration failed, * BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK if registration failed,
* or one of the other codes (if we are a BBMD). * or one of the other codes (if we are a BBMD).
*/ */
BACNET_BVLC_RESULT bvlc_get_last_result(void) BACNET_BVLC_RESULT bvlc_get_last_result(
void)
{ {
return BVLC_Result_Code; return BVLC_Result_Code;
} }
@@ -1316,7 +1317,8 @@ BACNET_BVLC_RESULT bvlc_get_last_result(void)
* *
* @return A BVLC_ code, such as BVLC_ORIGINAL_UNICAST_NPDU. * @return A BVLC_ code, such as BVLC_ORIGINAL_UNICAST_NPDU.
*/ */
BACNET_BVLC_FUNCTION bvlc_get_function_code(void) BACNET_BVLC_FUNCTION bvlc_get_function_code(
void)
{ {
return BVLC_Function_Code; return BVLC_Function_Code;
} }
+1
View File
@@ -127,6 +127,7 @@ bool dcc_set_status_duration(
return valid; return valid;
} }
#if BACNET_SVC_DCC_A #if BACNET_SVC_DCC_A
/* encode service */ /* encode service */
int dcc_encode_apdu( int dcc_encode_apdu(
+138 -143
View File
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], 0, encode_context_bitstring(&apdu[apdu_len], 0,
&data->notificationParams. &data->notificationParams.changeOfBitstring.
changeOfBitstring.referencedBitString); referencedBitString);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams. &data->notificationParams.changeOfBitstring.
changeOfBitstring.statusFlags); statusFlags);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 0); len = encode_closing_tag(&apdu[apdu_len], 0);
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams. &data->notificationParams.changeOfState.
changeOfState.statusFlags); statusFlags);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 1); len = encode_closing_tag(&apdu[apdu_len], 1);
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
case CHANGE_OF_VALUE_REAL: case CHANGE_OF_VALUE_REAL:
len = len =
encode_context_real(&apdu[apdu_len], 1, encode_context_real(&apdu[apdu_len], 1,
data->notificationParams. data->notificationParams.changeOfValue.
changeOfValue.newValue.changeValue); newValue.changeValue);
apdu_len += len; apdu_len += len;
break; break;
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], encode_context_bitstring(&apdu[apdu_len],
0, 0,
&data->notificationParams. &data->notificationParams.changeOfValue.
changeOfValue.newValue.changedBits); newValue.changedBits);
apdu_len += len; apdu_len += len;
break; break;
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams. &data->notificationParams.changeOfValue.
changeOfValue.statusFlags); statusFlags);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 2); len = encode_closing_tag(&apdu[apdu_len], 2);
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
len = len =
encode_context_real(&apdu[apdu_len], 0, encode_context_real(&apdu[apdu_len], 0,
data->notificationParams. data->notificationParams.floatingLimit.
floatingLimit.referenceValue); referenceValue);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams. &data->notificationParams.floatingLimit.
floatingLimit.statusFlags); statusFlags);
apdu_len += len; apdu_len += len;
len = len =
encode_context_real(&apdu[apdu_len], 2, encode_context_real(&apdu[apdu_len], 2,
data->notificationParams. data->notificationParams.floatingLimit.
floatingLimit.setPointValue); setPointValue);
apdu_len += len; apdu_len += len;
len = len =
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_real(&apdu[apdu_len], 0, encode_context_real(&apdu[apdu_len], 0,
data->notificationParams. data->notificationParams.outOfRange.
outOfRange.exceedingValue); exceedingValue);
apdu_len += len; apdu_len += len;
len = len =
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
len = len =
encode_context_enumerated(&apdu[apdu_len], 0, encode_context_enumerated(&apdu[apdu_len], 0,
data->notificationParams. data->notificationParams.changeOfLifeSafety.
changeOfLifeSafety.newState); newState);
apdu_len += len; apdu_len += len;
len = len =
encode_context_enumerated(&apdu[apdu_len], 1, encode_context_enumerated(&apdu[apdu_len], 1,
data->notificationParams. data->notificationParams.changeOfLifeSafety.
changeOfLifeSafety.newMode); newMode);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 2, encode_context_bitstring(&apdu[apdu_len], 2,
&data->notificationParams. &data->notificationParams.changeOfLifeSafety.
changeOfLifeSafety.statusFlags); statusFlags);
apdu_len += len; apdu_len += len;
len = len =
encode_context_enumerated(&apdu[apdu_len], 3, encode_context_enumerated(&apdu[apdu_len], 3,
data->notificationParams. data->notificationParams.changeOfLifeSafety.
changeOfLifeSafety.operationExpected); operationExpected);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 8); len = encode_closing_tag(&apdu[apdu_len], 8);
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
len = len =
bacapp_encode_context_device_obj_property_ref(&apdu bacapp_encode_context_device_obj_property_ref(&apdu
[apdu_len], 0, [apdu_len], 0,
&data->notificationParams. &data->notificationParams.bufferReady.
bufferReady.bufferProperty); bufferProperty);
apdu_len += len; apdu_len += len;
len = len =
encode_context_unsigned(&apdu[apdu_len], 1, encode_context_unsigned(&apdu[apdu_len], 1,
data->notificationParams. data->notificationParams.bufferReady.
bufferReady.previousNotification); previousNotification);
apdu_len += len; apdu_len += len;
len = len =
encode_context_unsigned(&apdu[apdu_len], 2, encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams. data->notificationParams.bufferReady.
bufferReady.currentNotification); currentNotification);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 10); len = encode_closing_tag(&apdu[apdu_len], 10);
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
len = len =
encode_context_unsigned(&apdu[apdu_len], 0, encode_context_unsigned(&apdu[apdu_len], 0,
data->notificationParams. data->notificationParams.unsignedRange.
unsignedRange.exceedingValue); exceedingValue);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams. &data->notificationParams.unsignedRange.
unsignedRange.statusFlags); statusFlags);
apdu_len += len; apdu_len += len;
len = len =
encode_context_unsigned(&apdu[apdu_len], 2, encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams. data->notificationParams.unsignedRange.
unsignedRange.exceededLimit); exceededLimit);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 11); len = encode_closing_tag(&apdu[apdu_len], 11);
@@ -595,18 +595,16 @@ int event_notify_decode_service_request(
case EVENT_CHANGE_OF_BITSTRING: case EVENT_CHANGE_OF_BITSTRING:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0, decode_context_bitstring(&apdu[len], 0,
&data-> &data->notificationParams.
notificationParams.changeOfBitstring. changeOfBitstring.referencedBitString))) {
referencedBitString))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data-> &data->notificationParams.
notificationParams.changeOfBitstring. changeOfBitstring.statusFlags))) {
statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -617,16 +615,16 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
bacapp_decode_context_property_state(&apdu bacapp_decode_context_property_state(&apdu
[len], 0, [len], 0,
&data->notificationParams. &data->notificationParams.changeOfState.
changeOfState.newState))) { newState))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams. &data->notificationParams.changeOfState.
changeOfState.statusFlags))) { statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -644,9 +642,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0, decode_context_bitstring(&apdu[len], 0,
&data-> &data->notificationParams.
notificationParams.changeOfValue. changeOfValue.newValue.changedBits))) {
newValue.changedBits))) {
return -1; return -1;
} }
@@ -657,9 +654,8 @@ int event_notify_decode_service_request(
CHANGE_OF_VALUE_REAL)) { CHANGE_OF_VALUE_REAL)) {
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 1, decode_context_real(&apdu[len], 1,
&data-> &data->notificationParams.
notificationParams.changeOfValue. changeOfValue.newValue.changeValue))) {
newValue.changeValue))) {
return -1; return -1;
} }
@@ -677,8 +673,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams. &data->notificationParams.changeOfValue.
changeOfValue.statusFlags))) { statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -687,31 +683,31 @@ int event_notify_decode_service_request(
case EVENT_FLOATING_LIMIT: case EVENT_FLOATING_LIMIT:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 0, decode_context_real(&apdu[len], 0,
&data->notificationParams. &data->notificationParams.floatingLimit.
floatingLimit.referenceValue))) { referenceValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams. &data->notificationParams.floatingLimit.
floatingLimit.statusFlags))) { statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 2, decode_context_real(&apdu[len], 2,
&data->notificationParams. &data->notificationParams.floatingLimit.
floatingLimit.setPointValue))) { setPointValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 3, decode_context_real(&apdu[len], 3,
&data->notificationParams. &data->notificationParams.floatingLimit.
floatingLimit.errorLimit))) { errorLimit))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -720,31 +716,31 @@ int event_notify_decode_service_request(
case EVENT_OUT_OF_RANGE: case EVENT_OUT_OF_RANGE:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 0, decode_context_real(&apdu[len], 0,
&data->notificationParams. &data->notificationParams.outOfRange.
outOfRange.exceedingValue))) { exceedingValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams. &data->notificationParams.outOfRange.
outOfRange.statusFlags))) { statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 2, decode_context_real(&apdu[len], 2,
&data->notificationParams. &data->notificationParams.outOfRange.
outOfRange.deadband))) { deadband))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 3, decode_context_real(&apdu[len], 3,
&data->notificationParams. &data->notificationParams.outOfRange.
outOfRange.exceededLimit))) { exceededLimit))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -772,9 +768,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 2, decode_context_bitstring(&apdu[len], 2,
&data-> &data->notificationParams.
notificationParams.changeOfLifeSafety. changeOfLifeSafety.statusFlags))) {
statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -784,8 +779,8 @@ int event_notify_decode_service_request(
&value))) { &value))) {
return -1; return -1;
} }
data->notificationParams. data->notificationParams.changeOfLifeSafety.
changeOfLifeSafety.operationExpected = operationExpected =
(BACNET_LIFE_SAFETY_OPERATION) value; (BACNET_LIFE_SAFETY_OPERATION) value;
len += section_length; len += section_length;
break; break;
@@ -794,24 +789,24 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
bacapp_decode_context_device_obj_property_ref bacapp_decode_context_device_obj_property_ref
(&apdu[len], 0, (&apdu[len], 0,
&data->notificationParams. &data->notificationParams.bufferReady.
bufferReady.bufferProperty))) { bufferProperty))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 1, decode_context_unsigned(&apdu[len], 1,
&data->notificationParams. &data->notificationParams.bufferReady.
bufferReady.previousNotification))) { previousNotification))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2, decode_context_unsigned(&apdu[len], 2,
&data->notificationParams. &data->notificationParams.bufferReady.
bufferReady.currentNotification))) { currentNotification))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -820,24 +815,24 @@ int event_notify_decode_service_request(
case EVENT_UNSIGNED_RANGE: case EVENT_UNSIGNED_RANGE:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 0, decode_context_unsigned(&apdu[len], 0,
&data->notificationParams. &data->notificationParams.unsignedRange.
unsignedRange.exceedingValue))) { exceedingValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams. &data->notificationParams.unsignedRange.
unsignedRange.statusFlags))) { statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2, decode_context_unsigned(&apdu[len], 2,
&data->notificationParams. &data->notificationParams.unsignedRange.
unsignedRange.exceededLimit))) { exceededLimit))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -1083,16 +1078,16 @@ void testEventEventState(
data.eventType = EVENT_CHANGE_OF_BITSTRING; data.eventType = EVENT_CHANGE_OF_BITSTRING;
bitstring_init(&data.notificationParams. bitstring_init(&data.notificationParams.changeOfBitstring.
changeOfBitstring.referencedBitString); referencedBitString);
bitstring_set_bit(&data.notificationParams. bitstring_set_bit(&data.notificationParams.changeOfBitstring.
changeOfBitstring.referencedBitString, 0, true); referencedBitString, 0, true);
bitstring_set_bit(&data.notificationParams. bitstring_set_bit(&data.notificationParams.changeOfBitstring.
changeOfBitstring.referencedBitString, 1, false); referencedBitString, 1, false);
bitstring_set_bit(&data.notificationParams. bitstring_set_bit(&data.notificationParams.changeOfBitstring.
changeOfBitstring.referencedBitString, 2, true); referencedBitString, 2, true);
bitstring_set_bit(&data.notificationParams. bitstring_set_bit(&data.notificationParams.changeOfBitstring.
changeOfBitstring.referencedBitString, 2, false); referencedBitString, 2, false);
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags); bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
@@ -1116,8 +1111,8 @@ void testEventEventState(
testBaseEventState(pTest); testBaseEventState(pTest);
ct_test(pTest, ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfBitstring. bitstring_same(&data.notificationParams.
referencedBitString, changeOfBitstring.referencedBitString,
&data2.notificationParams.changeOfBitstring.referencedBitString)); &data2.notificationParams.changeOfBitstring.referencedBitString));
ct_test(pTest, ct_test(pTest,
@@ -1180,16 +1175,16 @@ void testEventEventState(
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS; data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
bitstring_init(&data.notificationParams.changeOfValue. bitstring_init(&data.notificationParams.changeOfValue.newValue.
newValue.changedBits); changedBits);
bitstring_set_bit(&data.notificationParams.changeOfValue. bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
newValue.changedBits, 0, true); changedBits, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfValue. bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
newValue.changedBits, 1, false); changedBits, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfValue. bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
newValue.changedBits, 2, false); changedBits, 2, false);
bitstring_set_bit(&data.notificationParams.changeOfValue. bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
newValue.changedBits, 3, false); changedBits, 3, false);
memset(buffer, 0, MAX_APDU); memset(buffer, 0, MAX_APDU);
inLen = event_notify_encode_service_request(&buffer[0], &data); inLen = event_notify_encode_service_request(&buffer[0], &data);
@@ -1210,8 +1205,8 @@ void testEventEventState(
data2.notificationParams.changeOfValue.tag); data2.notificationParams.changeOfValue.tag);
ct_test(pTest, ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfValue.newValue. bitstring_same(&data.notificationParams.changeOfValue.
changedBits, newValue.changedBits,
&data2.notificationParams.changeOfValue.newValue.changedBits)); &data2.notificationParams.changeOfValue.newValue.changedBits));
/**********************************************************************************/ /**********************************************************************************/
@@ -1434,12 +1429,12 @@ void testEventEventState(
data.notificationParams.bufferReady.currentNotification = 2345; data.notificationParams.bufferReady.currentNotification = 2345;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type = data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
OBJECT_DEVICE; OBJECT_DEVICE;
data.notificationParams.bufferReady.bufferProperty. data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
deviceIndentifier.instance = 500; instance = 500;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type = data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
OBJECT_ANALOG_INPUT; OBJECT_ANALOG_INPUT;
data.notificationParams.bufferReady.bufferProperty. data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
objectIdentifier.instance = 100; instance = 100;
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier = data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
PROP_PRESENT_VALUE; PROP_PRESENT_VALUE;
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0; data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
@@ -1464,34 +1459,34 @@ void testEventEventState(
ct_test(pTest, ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty. data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
deviceIndentifier.type == type ==
data2.notificationParams.bufferReady.bufferProperty. data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
deviceIndentifier.type); type);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance ==
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance ==
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
type ==
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
type);
ct_test(pTest, ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty. data.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.instance == propertyIdentifier ==
data2.notificationParams.bufferReady.bufferProperty. data2.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.instance); propertyIdentifier);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance ==
data2.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.type ==
data2.notificationParams.bufferReady.bufferProperty.
objectIdentifier.type);
ct_test(pTest,
data.notificationParams.bufferReady.
bufferProperty.propertyIdentifier ==
data2.notificationParams.bufferReady.
bufferProperty.propertyIdentifier);
ct_test(pTest, ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.arrayIndex == data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
+8 -7
View File
@@ -54,20 +54,21 @@ int get_alarm_sumary_ack_encode_apdu_data(
if (!apdu) { if (!apdu) {
apdu_len = BACNET_STATUS_ERROR; apdu_len = BACNET_STATUS_ERROR;
} } else if (max_apdu >= 10) {
else if(max_apdu >= 10) {
/* tag 0 - Object Identifier */ /* tag 0 - Object Identifier */
apdu_len += encode_application_object_id(&apdu[apdu_len], apdu_len +=
encode_application_object_id(&apdu[apdu_len],
(int) get_alarm_data->objectIdentifier.type, (int) get_alarm_data->objectIdentifier.type,
get_alarm_data->objectIdentifier.instance); get_alarm_data->objectIdentifier.instance);
/* tag 1 - Alarm State */ /* tag 1 - Alarm State */
apdu_len += encode_application_enumerated(&apdu[apdu_len], apdu_len +=
encode_application_enumerated(&apdu[apdu_len],
get_alarm_data->alarmState); get_alarm_data->alarmState);
/* tag 2 - Acknowledged Transitions */ /* tag 2 - Acknowledged Transitions */
apdu_len += encode_application_bitstring(&apdu[apdu_len], apdu_len +=
encode_application_bitstring(&apdu[apdu_len],
&get_alarm_data->acknowledgedTransitions); &get_alarm_data->acknowledgedTransitions);
} } else {
else {
apdu_len = BACNET_STATUS_ABORT; apdu_len = BACNET_STATUS_ABORT;
} }
+3 -7
View File
@@ -1140,13 +1140,9 @@ void MSTP_Slave_Node_FSM(
break; break;
case FRAME_TYPE_TEST_REQUEST: case FRAME_TYPE_TEST_REQUEST:
mstp_port->ReceivedValidFrame = false; mstp_port->ReceivedValidFrame = false;
MSTP_Create_And_Send_Frame( MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_RESPONSE,
mstp_port, mstp_port->SourceAddress, mstp_port->This_Station,
FRAME_TYPE_TEST_RESPONSE, &mstp_port->InputBuffer[0], mstp_port->DataLength);
mstp_port->SourceAddress,
mstp_port->This_Station,
&mstp_port->InputBuffer[0],
mstp_port->DataLength);
break; break;
case FRAME_TYPE_TOKEN: case FRAME_TYPE_TOKEN:
case FRAME_TYPE_POLL_FOR_MASTER: case FRAME_TYPE_POLL_FOR_MASTER:
+26 -52
View File
@@ -708,71 +708,49 @@ void property_list_special(
pPropertyList->Proprietary.pList = NULL; pPropertyList->Proprietary.pList = NULL;
switch (object_type) { switch (object_type) {
case OBJECT_DEVICE: case OBJECT_DEVICE:
pPropertyList->Required.pList = pPropertyList->Required.pList = Device_Properties_Required;
Device_Properties_Required; pPropertyList->Optional.pList = Device_Properties_Optional;
pPropertyList->Optional.pList =
Device_Properties_Optional;
break; break;
break; break;
case OBJECT_ACCUMULATOR: case OBJECT_ACCUMULATOR:
pPropertyList->Required.pList = pPropertyList->Required.pList = Accumulator_Properties_Required;
Accumulator_Properties_Required; pPropertyList->Optional.pList = Accumulator_Properties_Optional;
pPropertyList->Optional.pList =
Accumulator_Properties_Optional;
break; break;
case OBJECT_ANALOG_INPUT: case OBJECT_ANALOG_INPUT:
pPropertyList->Required.pList = pPropertyList->Required.pList = Analog_Input_Properties_Required;
Analog_Input_Properties_Required; pPropertyList->Optional.pList = Analog_Input_Properties_Optional;
pPropertyList->Optional.pList =
Analog_Input_Properties_Optional;
break; break;
case OBJECT_ANALOG_OUTPUT: case OBJECT_ANALOG_OUTPUT:
pPropertyList->Required.pList = pPropertyList->Required.pList = Analog_Output_Properties_Required;
Analog_Output_Properties_Required; pPropertyList->Optional.pList = Analog_Output_Properties_Optional;
pPropertyList->Optional.pList =
Analog_Output_Properties_Optional;
break; break;
case OBJECT_ANALOG_VALUE: case OBJECT_ANALOG_VALUE:
pPropertyList->Required.pList = pPropertyList->Required.pList = Analog_Value_Properties_Required;
Analog_Value_Properties_Required; pPropertyList->Optional.pList = Analog_Value_Properties_Optional;
pPropertyList->Optional.pList =
Analog_Value_Properties_Optional;
break; break;
case OBJECT_AVERAGING: case OBJECT_AVERAGING:
pPropertyList->Required.pList = pPropertyList->Required.pList = Averaging_Properties_Required;
Averaging_Properties_Required; pPropertyList->Optional.pList = Averaging_Properties_Optional;
pPropertyList->Optional.pList =
Averaging_Properties_Optional;
break; break;
case OBJECT_BINARY_INPUT: case OBJECT_BINARY_INPUT:
pPropertyList->Required.pList = pPropertyList->Required.pList = Binary_Input_Properties_Required;
Binary_Input_Properties_Required; pPropertyList->Optional.pList = Binary_Input_Properties_Optional;
pPropertyList->Optional.pList =
Binary_Input_Properties_Optional;
break; break;
case OBJECT_BINARY_OUTPUT: case OBJECT_BINARY_OUTPUT:
pPropertyList->Required.pList = pPropertyList->Required.pList = Binary_Output_Properties_Required;
Binary_Output_Properties_Required; pPropertyList->Optional.pList = Binary_Output_Properties_Optional;
pPropertyList->Optional.pList =
Binary_Output_Properties_Optional;
break; break;
case OBJECT_BINARY_VALUE: case OBJECT_BINARY_VALUE:
pPropertyList->Required.pList = pPropertyList->Required.pList = Binary_Value_Properties_Required;
Binary_Value_Properties_Required; pPropertyList->Optional.pList = Binary_Value_Properties_Optional;
pPropertyList->Optional.pList =
Binary_Value_Properties_Optional;
break; break;
case OBJECT_CALENDAR: case OBJECT_CALENDAR:
pPropertyList->Required.pList = pPropertyList->Required.pList = Calendar_Properties_Required;
Calendar_Properties_Required; pPropertyList->Optional.pList = Calendar_Properties_Optional;
pPropertyList->Optional.pList =
Calendar_Properties_Optional;
break; break;
case OBJECT_COMMAND: case OBJECT_COMMAND:
pPropertyList->Required.pList = pPropertyList->Required.pList = Command_Properties_Required;
Command_Properties_Required; pPropertyList->Optional.pList = Command_Properties_Optional;
pPropertyList->Optional.pList =
Command_Properties_Optional;
break; break;
case OBJECT_CHARACTERSTRING_VALUE: case OBJECT_CHARACTERSTRING_VALUE:
pPropertyList->Required.pList = pPropertyList->Required.pList =
@@ -781,10 +759,8 @@ void property_list_special(
CharacterString_Value_Properties_Optional; CharacterString_Value_Properties_Optional;
break; break;
case OBJECT_LOAD_CONTROL: case OBJECT_LOAD_CONTROL:
pPropertyList->Required.pList = pPropertyList->Required.pList = Load_Control_Properties_Required;
Load_Control_Properties_Required; pPropertyList->Optional.pList = Load_Control_Properties_Optional;
pPropertyList->Optional.pList =
Load_Control_Properties_Optional;
break; break;
case OBJECT_LIFE_SAFETY_POINT: case OBJECT_LIFE_SAFETY_POINT:
pPropertyList->Required.pList = pPropertyList->Required.pList =
@@ -817,10 +793,8 @@ void property_list_special(
Notification_Class_Properties_Optional; Notification_Class_Properties_Optional;
break; break;
case OBJECT_TRENDLOG: case OBJECT_TRENDLOG:
pPropertyList->Required.pList = pPropertyList->Required.pList = Trend_Log_Properties_Required;
Trend_Log_Properties_Required; pPropertyList->Optional.pList = Trend_Log_Properties_Optional;
pPropertyList->Optional.pList =
Trend_Log_Properties_Optional;
break; break;
case OBJECT_EVENT_ENROLLMENT: case OBJECT_EVENT_ENROLLMENT:
case OBJECT_FILE: case OBJECT_FILE:
+8 -5
View File
@@ -490,7 +490,8 @@ void test_Private_Transfer_Ack(
private_data.vendorID = BACNET_VENDOR_ID; private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1; private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value); &private_data_chunk[0], &data_value);
ct_test(pTest, status == true); ct_test(pTest, status == true);
private_data_len = private_data_len =
@@ -543,7 +544,8 @@ void test_Private_Transfer_Error(
private_data.vendorID = BACNET_VENDOR_ID; private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1; private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value); &private_data_chunk[0], &data_value);
ct_test(pTest, status == true); ct_test(pTest, status == true);
private_data_len = private_data_len =
@@ -594,7 +596,8 @@ void test_Private_Transfer_Request(
private_data.vendorID = BACNET_VENDOR_ID; private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1; private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value); &private_data_chunk[0], &data_value);
ct_test(pTest, status == true); ct_test(pTest, status == true);
private_data_len = private_data_len =
@@ -638,8 +641,8 @@ void test_Unconfirmed_Private_Transfer_Request(
private_data.vendorID = BACNET_VENDOR_ID; private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1; private_data.serviceNumber = 1;
status = bacapp_parse_application_data( status =
BACNET_APPLICATION_TAG_CHARACTER_STRING, bacapp_parse_application_data(BACNET_APPLICATION_TAG_CHARACTER_STRING,
&private_data_chunk[0], &data_value); &private_data_chunk[0], &data_value);
ct_test(pTest, status == true); ct_test(pTest, status == true);
private_data_len = private_data_len =
+1 -2
View File
@@ -158,8 +158,7 @@ int rp_ack_encode_apdu_init(
/* service ack follows */ /* service ack follows */
len = len =
encode_context_object_id(&apdu[apdu_len], 0, encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
rpdata->object_type,
rpdata->object_instance); rpdata->object_instance);
apdu_len += len; apdu_len += len;
len = len =
+15 -10
View File
@@ -67,12 +67,14 @@ int wpm_decode_object_id(
apdu_len -= len; apdu_len -= len;
if (apdu_len >= 4) { if (apdu_len >= 4) {
len += len +=
decode_object_id(&apdu[len], &object_type, &object_instance); decode_object_id(&apdu[len], &object_type,
&object_instance);
wp_data->object_type = object_type; wp_data->object_type = object_type;
wp_data->object_instance = object_instance; wp_data->object_instance = object_instance;
apdu_len -= len; apdu_len -= len;
} else { } else {
wp_data->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER; wp_data->error_code =
ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
} else { } else {
@@ -174,7 +176,9 @@ int wpm_decode_object_property(
} }
/* encode functions */ /* encode functions */
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id) int wpm_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id)
{ {
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
@@ -198,8 +202,9 @@ int wpm_encode_apdu_object_begin (
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
if (apdu) { if (apdu) {
apdu_len = encode_context_object_id ( apdu_len =
&apdu[0], 0, object_type, object_instance); encode_context_object_id(&apdu[0], 0, object_type,
object_instance);
/* Tag 1: sequence of WriteAccessSpecification */ /* Tag 1: sequence of WriteAccessSpecification */
apdu_len += encode_opening_tag(&apdu[apdu_len], 1); apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
} }
@@ -207,7 +212,8 @@ int wpm_encode_apdu_object_begin (
return apdu_len; return apdu_len;
} }
int wpm_encode_apdu_object_end (uint8_t * apdu) int wpm_encode_apdu_object_end(
uint8_t * apdu)
{ {
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
@@ -226,8 +232,8 @@ int wpm_encode_apdu_object_property (
int len = 0; int len = 0;
if (apdu) { if (apdu) {
apdu_len = encode_context_enumerated (&apdu[0], 0, apdu_len =
wpdata->object_property); encode_context_enumerated(&apdu[0], 0, wpdata->object_property);
/* optional array index */ /* optional array index */
if (wpdata->array_index != BACNET_ARRAY_ALL) { if (wpdata->array_index != BACNET_ARRAY_ALL) {
apdu_len += apdu_len +=
@@ -241,8 +247,7 @@ int wpm_encode_apdu_object_property (
} }
apdu_len += encode_closing_tag(&apdu[apdu_len], 2); apdu_len += encode_closing_tag(&apdu[apdu_len], 2);
if (wpdata->priority != BACNET_NO_PRIORITY) { if (wpdata->priority != BACNET_NO_PRIORITY) {
encode_context_unsigned (&apdu[apdu_len], 3, encode_context_unsigned(&apdu[apdu_len], 3, wpdata->priority);
wpdata->priority);
} }
} }