diff --git a/bacnet-stack/demo/epics/bacepics.h b/bacnet-stack/demo/epics/bacepics.h index 54efb86a..ea9a5990 100755 --- a/bacnet-stack/demo/epics/bacepics.h +++ b/bacnet-stack/demo/epics/bacepics.h @@ -88,7 +88,7 @@ typedef enum { /** Initial state to establish a binding with the target device. */ INITIAL_BINDING, - /** Get selected device information and put out the heading information. */ + /** Get selected device information and put out the heading information. */ GET_HEADING_INFO, GET_HEADING_RESPONSE, PRINT_HEADING, /** Getting ALL properties and values at once with RPM. */ GET_ALL_REQUEST, GET_ALL_RESPONSE, diff --git a/bacnet-stack/demo/epics/main.c b/bacnet-stack/demo/epics/main.c index bbad47ec..adf79650 100644 --- a/bacnet-stack/demo/epics/main.c +++ b/bacnet-stack/demo/epics/main.c @@ -129,17 +129,19 @@ static int32_t Property_List[MAX_PROPS + 2]; #define INIT_ID_PROPLIST_SIZE 5 /* 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] = { - PROP_VENDOR_NAME, - PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */ - PROP_DESCRIPTION, /* Optional, but hopefully available */ + PROP_VENDOR_NAME, + PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */ + PROP_DESCRIPTION, /* Optional, but hopefully available */ PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED, -1 }; + /* Will hold GET_HEADING_RESPONSE results here: */ -static BACNET_APPLICATION_DATA_VALUE * InitIdValues[INIT_ID_PROPLIST_SIZE] = -{ NULL, NULL, NULL, NULL, NULL }; +static BACNET_APPLICATION_DATA_VALUE *InitIdValues[INIT_ID_PROPLIST_SIZE] = + { NULL, NULL, NULL, NULL, NULL }; /* When we have to walk through an array of things, like ObjectIDs or @@ -245,8 +247,8 @@ void MyReadPropertyAckHandler( rp_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA)); if (rp_data) { len = - rp_ack_fully_decode_service_request(service_request, service_len, - rp_data); + rp_ack_fully_decode_service_request(service_request, + service_len, rp_data); } if (len > 0) { memmove(&Read_Property_Multiple_Data.service_data, service_data, @@ -254,7 +256,7 @@ void MyReadPropertyAckHandler( Read_Property_Multiple_Data.rpm_data = rp_data; Read_Property_Multiple_Data.new_data = true; } else { - if (len < 0) /* Eg, failed due to no segmentation */ + if (len < 0) /* Eg, failed due to no segmentation */ Error_Detected = true; free(rp_data); } @@ -285,7 +287,7 @@ void MyReadPropertyMultipleAckHandler( Read_Property_Multiple_Data.new_data = true; /* Will process and free the RPM data later */ } else { - if (len < 0) /* Eg, failed due to no segmentation */ + if (len < 0) /* Eg, failed due to no segmentation */ Error_Detected = true; free(rpm_data); } @@ -303,8 +305,7 @@ static void Init_Service_Handlers( /* Put this client Device into the Routing table (first entry) */ Object_Instance = Device_Object_Instance_Number(); Device_Object_Name(Object_Instance, &name_string); - Add_Routed_Device(Object_Instance, &name_string, - Device_Description()); + Add_Routed_Device(Object_Instance, &name_string, Device_Description()); #endif /* we need to handle who-is @@ -349,9 +350,9 @@ void CheckIsWritableProperty( BACNET_PROPERTY_REFERENCE * rpm_property) { bool bIsWritable = false; - if ( object_type == OBJECT_DEVICE ) { - if ( (rpm_property->propertyIdentifier == PROP_OBJECT_IDENTIFIER) || - (rpm_property->propertyIdentifier == PROP_OBJECT_NAME) ) + if (object_type == OBJECT_DEVICE) { + if ((rpm_property->propertyIdentifier == PROP_OBJECT_IDENTIFIER) || + (rpm_property->propertyIdentifier == PROP_OBJECT_NAME)) bIsWritable = true; } /* Add more checking here, eg for Time_Synchronization_Recipients, @@ -440,13 +441,11 @@ bool PrettyPrintPropertyValue( /* eg, property == PROP_LOCAL_DATE * VTS needs (3-Aug-2011,4) or (8/3/11,4), so we'll use the * 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; - fprintf(stream, "(%u-%3s-%u, %u)", - (unsigned) value->type.Date.day, - short_month, - (unsigned) value->type.Date.year, - (unsigned) value->type.Date.wday); + fprintf(stream, "(%u-%3s-%u, %u)", (unsigned) value->type.Date.day, + short_month, (unsigned) value->type.Date.year, + (unsigned) value->type.Date.wday); } else if (value != NULL) { assert(false); /* How did I get here? Fix your code. */ /* Meanwhile, a fallback plan */ @@ -511,7 +510,7 @@ void PrintReadPropertyData( break; } if (object_type == OBJECT_DATETIME_VALUE) - break; /* A special case - no braces for this pair */ + break; /* A special case - no braces for this pair */ /* Else, fall through to normal processing. */ default: /* Normal array: open brace */ @@ -637,40 +636,40 @@ void PrintReadPropertyData( default: /* First, if this is a date type, it needs a different format * 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, * or OBJECT_DATE_VALUE */ PrettyPrintPropertyValue(stdout, &object_value); } else { - /* Some properties are presented just as '?' in an EPICS; - * screen these out here, unless ShowValues is true. */ - switch (rpm_property->propertyIdentifier) { - case PROP_DEVICE_ADDRESS_BINDING: - /* Make it VTS3-friendly and don't show "Null" - * as a value. */ - if (value->tag == BACNET_APPLICATION_TAG_NULL) { - fprintf(stdout, "?"); + /* Some properties are presented just as '?' in an EPICS; + * screen these out here, unless ShowValues is true. */ + switch (rpm_property->propertyIdentifier) { + case PROP_DEVICE_ADDRESS_BINDING: + /* Make it VTS3-friendly and don't show "Null" + * as a value. */ + if (value->tag == BACNET_APPLICATION_TAG_NULL) { + fprintf(stdout, "?"); + break; + } + /* Else, fall through for normal processing. */ + case PROP_DAYLIGHT_SAVINGS_STATUS: + case PROP_LOCAL_TIME: + case PROP_LOCAL_DATE: /* Only if !ShowValues */ + case PROP_PRESENT_VALUE: + case PROP_PRIORITY_ARRAY: + case PROP_RELIABILITY: + case PROP_UTC_OFFSET: + case PROP_DATABASE_REVISION: + if (!ShowValues) { + fprintf(stdout, "?"); + break; + } + /* Else, fall through and print value: */ + default: + bacapp_print_value(stdout, &object_value); break; - } - /* Else, fall through for normal processing. */ - case PROP_DAYLIGHT_SAVINGS_STATUS: - case PROP_LOCAL_TIME: - case PROP_LOCAL_DATE: /* Only if !ShowValues */ - case PROP_PRESENT_VALUE: - case PROP_PRIORITY_ARRAY: - case PROP_RELIABILITY: - case PROP_UTC_OFFSET: - case PROP_DATABASE_REVISION: - if (!ShowValues) { - fprintf(stdout, "?"); - break; - } - /* Else, fall through and print value: */ - default: - bacapp_print_value(stdout, &object_value); - break; - } + } } if (value->next != NULL) { /* there's more! */ @@ -680,8 +679,8 @@ void PrintReadPropertyData( /* Closing brace for this multi-valued array */ fprintf(stdout, " }"); } - CheckIsWritableProperty(object_type, /* object_instance, */ - rpm_property); + CheckIsWritableProperty(object_type, /* object_instance, */ + rpm_property); fprintf(stdout, "\r\n"); } break; @@ -712,26 +711,27 @@ void Print_Property_Identifier( * @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 */ -void BuildPropRequest( BACNET_READ_ACCESS_DATA *rpm_object, int32_t *propList ) +void BuildPropRequest( + BACNET_READ_ACCESS_DATA * rpm_object, + int32_t * propList) { - int i; - /* To start with, StartNextObject() has prepopulated one propEntry, - * but we will overwrite it and link more to it - */ - BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties; - BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties; - for( i = 0; propList[i] != -1; i++ ) - { - if ( propEntry == NULL ) { - propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE)); - assert(propEntry); - oldEntry->next = propEntry; - } - propEntry->propertyIdentifier = propList[i]; - propEntry->propertyArrayIndex = BACNET_ARRAY_ALL; - oldEntry = propEntry; - propEntry = NULL; - } + int i; + /* To start with, StartNextObject() has prepopulated one propEntry, + * but we will overwrite it and link more to it + */ + BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties; + BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties; + for (i = 0; propList[i] != -1; i++) { + if (propEntry == NULL) { + propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE)); + assert(propEntry); + oldEntry->next = propEntry; + } + propEntry->propertyIdentifier = propList[i]; + propEntry->propertyArrayIndex = BACNET_ARRAY_ALL; + oldEntry = propEntry; + propEntry = NULL; + } } /** Send an RP request to read one property from the current Object. @@ -750,7 +750,7 @@ static uint8_t Read_Properties( { uint8_t invoke_id = 0; struct special_property_list_t PropertyListStruct; - unsigned int i = 0,j = 0; + unsigned int i = 0, j = 0; if ((!Has_RPM && (Property_List_Index == 0)) || (Property_List_Length == 0)) { @@ -761,7 +761,8 @@ static uint8_t Read_Properties( */ property_list_special(pMyObject->type, &PropertyListStruct); if (Optional_Properties) { - Property_List_Length = PropertyListStruct.Required.count + + Property_List_Length = + PropertyListStruct.Required.count + PropertyListStruct.Optional.count; } else { Property_List_Length = PropertyListStruct.Required.count; @@ -872,11 +873,11 @@ EPICS_STATES ProcessRPMData( value = value->next; free(old_value); } - } else if ( myState == GET_HEADING_RESPONSE ) { - InitIdValues[i++] = rpm_property->value; - /* copy this pointer. - * On error, the pointer will be null - * We won't free these values*/ + } else if (myState == GET_HEADING_RESPONSE) { + InitIdValues[i++] = rpm_property->value; + /* copy this pointer. + * On error, the pointer will be null + * We won't free these values*/ } else { fprintf(stdout, " "); Print_Property_Identifier(rpm_property->propertyIdentifier); @@ -894,9 +895,9 @@ EPICS_STATES ProcessRPMData( } /* Now determine the next state */ - if ( myState == GET_HEADING_RESPONSE ) - nextState = PRINT_HEADING; - /* press ahead with or without the data */ + if (myState == GET_HEADING_RESPONSE) + nextState = PRINT_HEADING; + /* press ahead with or without the data */ else if (bSuccess && (myState == GET_ALL_RESPONSE)) nextState = NEXT_OBJECT; else if (bSuccess) { /* and GET_LIST_OF_ALL_RESPONSE */ @@ -923,7 +924,8 @@ EPICS_STATES ProcessRPMData( 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 (" 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"); printf (" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n"); - printf - (" 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(" 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(" or on routed Virtual Network \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("\r\n"); exit(0); @@ -1040,166 +1041,169 @@ int CheckCommandLineArgs( } -void PrintHeading( ) +void PrintHeading( + ) { - BACNET_APPLICATION_DATA_VALUE *value; - char *relation = "for"; /* Text for Gateways */ - if ( Target_Address.net != 0 ) - relation = "provided by"; /* Text for child routed devices */ + BACNET_APPLICATION_DATA_VALUE *value; + char *relation = "for"; /* Text for Gateways */ + if (Target_Address.net != 0) + relation = "provided by"; /* Text for child routed devices */ - printf("PICS 0\r\n"); - printf("BACnet Protocol Implementation Conformance Statement\r\n\r\n"); + printf("PICS 0\r\n"); + printf("BACnet Protocol Implementation Conformance Statement\r\n\r\n"); - printf("--\r\n--\r\n"); - printf("-- BACnet/IP Interface for BACnet-stack Devices\r\n"); - printf("-- http://sourceforge.net/projects/bacnet/ \r\n"); - printf("-- \r\n-- \r\n\r\n"); + printf("--\r\n--\r\n"); + printf("-- BACnet/IP Interface for BACnet-stack Devices\r\n"); + printf("-- http://sourceforge.net/projects/bacnet/ \r\n"); + printf("-- \r\n-- \r\n\r\n"); /* InitIdValues , , , */ - value = InitIdValues[INIT_VENDOR_NAME]; - if ( value != NULL ) - printf("Vendor Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) ); - else - printf("Vendor Name: \"bacnet-stack\"\r\n"); + value = InitIdValues[INIT_VENDOR_NAME]; + if (value != NULL) + printf("Vendor Name: \"%s\"\r\n", + characterstring_value(&value->type.Character_String)); + else + printf("Vendor Name: \"bacnet-stack\"\r\n"); - value = InitIdValues[INIT_MODEL_NAME]; - /* Best we can do with Product Name and Model Number is use the same text */ - if ( value != NULL ) { - printf("Product Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) ); - printf("Product Model Number: \"%s\"\r\n", characterstring_value( &value->type.Character_String) ); - } else { - printf("Product Name: \"bacnet-stack Device\"\r\n"); - printf("Product Model Number: \"Model XXX\"\r\n"); - } + value = InitIdValues[INIT_MODEL_NAME]; + /* Best we can do with Product Name and Model Number is use the same text */ + if (value != NULL) { + printf("Product Name: \"%s\"\r\n", + characterstring_value(&value->type.Character_String)); + printf("Product Model Number: \"%s\"\r\n", + characterstring_value(&value->type.Character_String)); + } else { + printf("Product Name: \"bacnet-stack Device\"\r\n"); + printf("Product Model Number: \"Model XXX\"\r\n"); + } - value = InitIdValues[INIT_DESCRIPTION]; - if ( value != NULL ) - printf("Product Description: \"%s\"\r\n\r\n", characterstring_value( &value->type.Character_String) ); - else - printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n"); + value = InitIdValues[INIT_DESCRIPTION]; + if (value != NULL) + printf("Product Description: \"%s\"\r\n\r\n", + characterstring_value(&value->type.Character_String)); + else + printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n"); - printf("BIBBs Supported:\r\n"); - printf("{\r\n"); - printf(" DS-RP-B\r\n"); - printf(" DS-RPM-B\r\n"); - printf(" DS-WP-B\r\n"); - printf(" DM-DDB-B\r\n"); - printf(" DM-DOB-B\r\n"); - printf(" DM-DCC-B\r\n"); - printf(" DM-RD-B\r\n"); + printf("BIBBs Supported:\r\n"); + printf("{\r\n"); + printf(" DS-RP-B\r\n"); + printf(" DS-RPM-B\r\n"); + printf(" DS-WP-B\r\n"); + printf(" DM-DDB-B\r\n"); + printf(" DM-DOB-B\r\n"); + printf(" DM-DCC-B\r\n"); + printf(" DM-RD-B\r\n"); #ifdef BAC_ROUTING - /* Next line only for the gateway (ie, if not addressing a subNet) */ - if ( Target_Address.net == 0 ) - printf(" NM-RC-B\r\n"); + /* Next line only for the gateway (ie, if not addressing a subNet) */ + if (Target_Address.net == 0) + printf(" NM-RC-B\r\n"); #endif - printf("}\r\n\r\n"); - /* You might add some of: - * -- DS-COV-A DS-COV-B - * -- AE-N-A AE-N-I-B AE-N-E-B - * -- AE-ACK-A AE-ACK-B - * -- DM-UTC-B - */ - - printf("BACnet Standard Application Services Supported:\r\n"); - printf("{\r\n"); - /* You might change the "Initiate Execute" values, or edit the result. */ - printf(" ReadProperty Initiate Execute\r\n"); - printf(" ReadPropertyMultiple Execute\r\n"); - printf(" WriteProperty Execute\r\n"); - printf(" DeviceCommunicationControl Execute\r\n"); - printf(" Who-Has Execute\r\n"); - printf(" I-Have Initiate\r\n"); - printf(" Who-Is Initiate Execute\r\n"); - printf(" I-Am Initiate\r\n"); - printf(" ReinitializeDevice Execute\r\n"); -#ifdef BAC_ROUTING - if ( Target_Address.net == 0 ) - { - printf(" -- Note: The following Routing Services are Supported:\r\n"); - printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n"); - printf(" -- I-Am-Router-To-Network Initiate Execute\r\n"); - printf(" -- Initialize-Routing-Table Execute\r\n"); - printf(" -- Initialize-Routing-Table-Ack Initiate\r\n"); - } -#endif - printf("}\r\n\r\n"); - /* You might want to add some of: - * -- AcknowledgeAlarm Initiate Execute - * -- ConfirmedCOVNotification Initiate Execute - * -- UnconfirmedCOVNotification Initiate - * -- ConfirmedEventNotification Initiate Execute - * -- UnconfirmedEventNotification Initiate Execute - * -- GetAlarmSummary Initiate Execute - * -- GetEnrollmentSummary Initiate Execute - * -- WritePropertyMultiple Initiate Execute - * -- ReadRange Initiate Execute - * -- GetEventInformation Initiate Execute - * -- SubscribeCOVProperty Initiate Execute - */ - - printf("Standard Object-Types Supported:\r\n"); - printf("{\r\n"); - value = InitIdValues[INIT_OBJ_TYPES]; - /* We have to process this bit string and determine which Object Types we have, - * and show them - */ - if ( ( value != NULL ) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) ) - { - int i, len = bitstring_bits_used(&value->type.Bit_String); - for ( i = 0; i < len; i++) { - if ( bitstring_bit(&value->type.Bit_String, (uint8_t) i) ) - printf(" %s\r\n", bactext_object_type_name(i)); - } - } else { /* Else, just show the usual suspects */ - printf(" Analog Input\r\n"); - printf(" Analog Value\r\n"); - printf(" Binary Input\r\n"); - printf(" Binary Value\r\n"); - printf(" Device\r\n"); - printf(" Multi-state Input\r\n"); - printf(" Multi-state Value\r\n"); - printf(" Structured View\r\n"); - printf(" Characterstring Value\r\n"); - printf(" Datetime Value\r\n"); - printf(" Integer Value\r\n"); - printf(" Positive Integer Value\r\n"); - } - printf("}\r\n\r\n"); - /* You might add some of: - * -- Analog Output - * -- Binary Output - * -- Multi-state Output - * -- Trend Log Createable Deleteable - * -- Load Control - * -- Bitstring Value - * -- Date Pattern Value - * -- Date Value - * -- Datetime Pattern Value - * -- Large Analog Value - * -- Octetstring Value - * -- Time Pattern Value - * -- Time Value + printf("}\r\n\r\n"); + /* You might add some of: + * -- DS-COV-A DS-COV-B + * -- AE-N-A AE-N-I-B AE-N-E-B + * -- AE-ACK-A AE-ACK-B + * -- DM-UTC-B */ - printf("Data Link Layer Option:\r\n"); - printf("{\r\n"); - printf(" BACnet/IP, 'DIX' Ethernet\r\n"); - printf("}\r\n\r\n"); + printf("BACnet Standard Application Services Supported:\r\n"); + printf("{\r\n"); + /* You might change the "Initiate Execute" values, or edit the result. */ + printf(" ReadProperty Initiate Execute\r\n"); + printf(" ReadPropertyMultiple Execute\r\n"); + printf(" WriteProperty Execute\r\n"); + printf(" DeviceCommunicationControl Execute\r\n"); + printf(" Who-Has Execute\r\n"); + printf(" I-Have Initiate\r\n"); + printf(" Who-Is Initiate Execute\r\n"); + printf(" I-Am Initiate\r\n"); + printf(" ReinitializeDevice Execute\r\n"); +#ifdef BAC_ROUTING + if (Target_Address.net == 0) { + printf(" -- Note: The following Routing Services are Supported:\r\n"); + printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n"); + printf(" -- I-Am-Router-To-Network Initiate Execute\r\n"); + printf(" -- Initialize-Routing-Table Execute\r\n"); + printf(" -- Initialize-Routing-Table-Ack Initiate\r\n"); + } +#endif + printf("}\r\n\r\n"); + /* You might want to add some of: + * -- AcknowledgeAlarm Initiate Execute + * -- ConfirmedCOVNotification Initiate Execute + * -- UnconfirmedCOVNotification Initiate + * -- ConfirmedEventNotification Initiate Execute + * -- UnconfirmedEventNotification Initiate Execute + * -- GetAlarmSummary Initiate Execute + * -- GetEnrollmentSummary Initiate Execute + * -- WritePropertyMultiple Initiate Execute + * -- ReadRange Initiate Execute + * -- GetEventInformation Initiate Execute + * -- SubscribeCOVProperty Initiate Execute + */ - printf("Character Sets Supported:\r\n"); - printf("{\r\n"); - printf(" ANSI X3.4\r\n"); - printf("}\r\n\r\n"); + printf("Standard Object-Types Supported:\r\n"); + printf("{\r\n"); + value = InitIdValues[INIT_OBJ_TYPES]; + /* We have to process this bit string and determine which Object Types we have, + * and show them + */ + if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING)) { + int i, len = bitstring_bits_used(&value->type.Bit_String); + for (i = 0; i < len; i++) { + if (bitstring_bit(&value->type.Bit_String, (uint8_t) i)) + printf(" %s\r\n", bactext_object_type_name(i)); + } + } else { /* Else, just show the usual suspects */ + printf(" Analog Input\r\n"); + printf(" Analog Value\r\n"); + printf(" Binary Input\r\n"); + printf(" Binary Value\r\n"); + printf(" Device\r\n"); + printf(" Multi-state Input\r\n"); + printf(" Multi-state Value\r\n"); + printf(" Structured View\r\n"); + printf(" Characterstring Value\r\n"); + printf(" Datetime Value\r\n"); + printf(" Integer Value\r\n"); + printf(" Positive Integer Value\r\n"); + } + printf("}\r\n\r\n"); + /* You might add some of: + * -- Analog Output + * -- Binary Output + * -- Multi-state Output + * -- Trend Log Createable Deleteable + * -- Load Control + * -- Bitstring Value + * -- Date Pattern Value + * -- Date Value + * -- Datetime Pattern Value + * -- Large Analog Value + * -- Octetstring Value + * -- Time Pattern Value + * -- Time Value + */ - printf("Special Functionality:\r\n"); - printf("{\r\n"); - printf(" Maximum APDU size in octets: 1476\r\n"); - printf("}\r\n\r\n"); + printf("Data Link Layer Option:\r\n"); + printf("{\r\n"); + printf(" BACnet/IP, 'DIX' Ethernet\r\n"); + printf("}\r\n\r\n"); - printf("List of Objects in Test Device:\r\n"); - /* Print Opening brace, then kick off the Device Object */ - printf("{\r\n"); - printf(" {\r\n"); /* And opening brace for the first object */ + printf("Character Sets Supported:\r\n"); + printf("{\r\n"); + printf(" ANSI X3.4\r\n"); + printf("}\r\n\r\n"); + + printf("Special Functionality:\r\n"); + printf("{\r\n"); + printf(" Maximum APDU size in octets: 1476\r\n"); + printf("}\r\n\r\n"); + + printf("List of Objects in Test Device:\r\n"); + /* Print Opening brace, then kick off the Device Object */ + printf("{\r\n"); + printf(" {\r\n"); /* And opening brace for the first object */ } @@ -1354,22 +1358,22 @@ int main( case GET_HEADING_INFO: last_seconds = current_seconds; StartNextObject(rpm_object, &myObject); - BuildPropRequest( rpm_object, &InitIdPropList[0] ); + BuildPropRequest(rpm_object, &InitIdPropList[0]); Request_Invoke_ID = Send_Read_Property_Multiple_Request(buffer, MAX_PDU, Target_Device_Object_Instance, rpm_object); if (Request_Invoke_ID > 0) { elapsed_seconds = 0; } else { - /* We failed. Will hurt the header info we can show. */ - fprintf(stderr, "\r-- Failed to get Heading info \r\n"); + /* We failed. Will hurt the header info we can show. */ + fprintf(stderr, "\r-- Failed to get Heading info \r\n"); } myState = GET_HEADING_RESPONSE; break; case PRINT_HEADING: - /* Print out the header information */ - PrintHeading( ); + /* Print out the header information */ + PrintHeading(); myState = GET_ALL_REQUEST; /* Fall through now */ @@ -1421,9 +1425,9 @@ int main( } else if (tsm_invoke_id_free(Request_Invoke_ID)) { elapsed_seconds = 0; Request_Invoke_ID = 0; - if ( myState == GET_HEADING_RESPONSE ) - myState = PRINT_HEADING; - /* just press ahead without the data */ + if (myState == GET_HEADING_RESPONSE) + myState = PRINT_HEADING; + /* just press ahead without the data */ else if (Error_Detected) { if (Last_Error_Code == ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) { @@ -1432,7 +1436,7 @@ int main( Has_RPM = false; myState = GET_PROPERTY_REQUEST; } else if (Last_Error_Code == - ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED) { + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED) { myState = GET_PROPERTY_REQUEST; StartNextObject(rpm_object, &myObject); } else if (myState == GET_ALL_RESPONSE) @@ -1452,20 +1456,20 @@ int main( tsm_free_invoke_id(Request_Invoke_ID); Request_Invoke_ID = 0; elapsed_seconds = 0; - if ( myState == GET_HEADING_RESPONSE ) - myState = PRINT_HEADING; - /* just press ahead without the data */ + if (myState == GET_HEADING_RESPONSE) + myState = PRINT_HEADING; + /* just press ahead without the data */ else - myState = GET_ALL_REQUEST; /* Let's try again */ + myState = GET_ALL_REQUEST; /* Let's try again */ } else if (Error_Detected) { /* Don't think we'll ever actually reach this point. */ elapsed_seconds = 0; Request_Invoke_ID = 0; - if ( myState == GET_HEADING_RESPONSE ) - myState = PRINT_HEADING; - /* just press ahead without the data */ + if (myState == GET_HEADING_RESPONSE) + myState = PRINT_HEADING; + /* just press ahead without the data */ else - myState = NEXT_OBJECT; /* Give up and move on to the next. */ + myState = NEXT_OBJECT; /* Give up and move on to the next. */ Error_Count++; } break; @@ -1500,11 +1504,11 @@ int main( (Request_Invoke_ID == Read_Property_Multiple_Data.service_data.invoke_id)) { Read_Property_Multiple_Data.new_data = false; - PrintReadPropertyData(Read_Property_Multiple_Data. - rpm_data->object_type, + PrintReadPropertyData + (Read_Property_Multiple_Data.rpm_data->object_type, Read_Property_Multiple_Data.rpm_data->object_instance, - Read_Property_Multiple_Data.rpm_data-> - listOfProperties); + Read_Property_Multiple_Data. + rpm_data->listOfProperties); if (tsm_invoke_id_free(Request_Invoke_ID)) { Request_Invoke_ID = 0; } else { @@ -1538,12 +1542,13 @@ int main( } else { /* OK, skip this one and try the next property. */ fprintf(stdout, " -- Failed to get "); - Print_Property_Identifier( - Property_List[Property_List_Index]); + Print_Property_Identifier(Property_List + [Property_List_Index]); fprintf(stdout, " \r\n"); Error_Count++; 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. */ myState = NEXT_OBJECT; } @@ -1563,7 +1568,7 @@ int main( tsm_free_invoke_id(Request_Invoke_ID); elapsed_seconds = 0; Request_Invoke_ID = 0; - myState = 3; /* Let's try again, same Property */ + myState = 3; /* Let's try again, same Property */ } else if (Error_Detected) { /* Don't think we'll ever actually reach this point. */ elapsed_seconds = 0; @@ -1636,10 +1641,10 @@ int main( fprintf(stdout, "\r-- Found %d Errors \r\n", Error_Count); /* Closing brace for all Objects, if we got any, and closing footer */ - if (myState != INITIAL_BINDING) - { + if (myState != INITIAL_BINDING) { 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"); } diff --git a/bacnet-stack/demo/gateway/main.c b/bacnet-stack/demo/gateway/main.c index c34eeadf..4675b920 100644 --- a/bacnet-stack/demo/gateway/main.c +++ b/bacnet-stack/demo/gateway/main.c @@ -131,9 +131,8 @@ static void Init_Service_Handlers( * each device in turn. */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, - handler_who_is_unicast); - apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, - handler_who_has); + handler_who_is_unicast); + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has); /* set the handler for all the services we don't implement */ /* It is required to send the proper reject message... */ apdu_set_unrecognized_service_handler_handler diff --git a/bacnet-stack/demo/handler/dlenv.c b/bacnet-stack/demo/handler/dlenv.c index 51686d12..5bad2cbc 100644 --- a/bacnet-stack/demo/handler/dlenv.c +++ b/bacnet-stack/demo/handler/dlenv.c @@ -45,7 +45,7 @@ static uint16_t BBMD_Timer_Seconds; static long bbmd_timetolive_seconds = 60000; static long bbmd_port = 0xBAC0; static long bbmd_address = 0; -static int bbmd_result = 0; +static int bbmd_result = 0; /* Simple setters for BBMD registration variables. */ @@ -55,7 +55,8 @@ static int bbmd_result = 0; * @param address - IPv4 address (long) of BBMD to register with, * in network byte order. */ -void dlenv_bbmd_address_set( long address ) +void dlenv_bbmd_address_set( + long address) { bbmd_address = address; } @@ -64,7 +65,8 @@ void dlenv_bbmd_address_set( long address ) * Default if not set is 0xBAC0. * @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; } @@ -73,7 +75,8 @@ void dlenv_bbmd_port_set( int port ) * Default if not set is 60000 (1000 minutes). * @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; } @@ -86,10 +89,11 @@ void dlenv_bbmd_ttl_set( int ttl_secs ) * 0 if no registration request was made, or * -1 if registration attempt failed. */ -int dlenv_bbmd_result( void ) +int dlenv_bbmd_result( + void) { - if ( (bbmd_result > 0) && - (bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK) ) + if ((bbmd_result > 0) && + (bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK)) return -1; /* Else, show our send: */ return bbmd_result; @@ -113,7 +117,7 @@ int dlenv_bbmd_result( void ) int dlenv_register_as_foreign_device( void) { - int retval = 0; + int retval = 0; #if defined(BACDL_BIP) char *pEnv = NULL; @@ -138,15 +142,14 @@ int dlenv_register_as_foreign_device( if (bbmd_address) { struct in_addr addr; addr.s_addr = bbmd_address; - fprintf(stderr, - "Registering with BBMD at %s:%ld for %ld seconds\n", + fprintf(stderr, "Registering with BBMD at %s:%ld for %ld seconds\n", inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); - retval = bvlc_register_with_bbmd(bbmd_address, - htons((uint16_t) bbmd_port), - (uint16_t) bbmd_timetolive_seconds); - if ( retval < 0 ) - fprintf(stderr, - "FAILED to Register with BBMD at %s \n", inet_ntoa(addr) ); + retval = + bvlc_register_with_bbmd(bbmd_address, htons((uint16_t) bbmd_port), + (uint16_t) bbmd_timetolive_seconds); + if (retval < 0) + fprintf(stderr, "FAILED to Register with BBMD at %s \n", + inet_ntoa(addr)); BBMD_Timer_Seconds = bbmd_timetolive_seconds; } diff --git a/bacnet-stack/demo/handler/h_ccov.c b/bacnet-stack/demo/handler/h_ccov.c index d8f01969..a8be9072 100644 --- a/bacnet-stack/demo/handler/h_ccov.c +++ b/bacnet-stack/demo/handler/h_ccov.c @@ -106,7 +106,8 @@ void handler_ccov_notification( fprintf(stderr, "CCOV: Segmented message. Sending Abort!\n"); #endif goto CCOV_ABORT; - } /* decode the service request only */ + } + /* decode the service request only */ /* decode the service request only */ len = cov_notify_decode_service_request(service_request, service_len, @@ -125,8 +126,8 @@ void handler_ccov_notification( fprintf(stderr, "CCOV: "); if (pProperty_value->propertyIdentifier < 512) { fprintf(stderr, "%s ", - bactext_property_name - (pProperty_value->propertyIdentifier)); + bactext_property_name(pProperty_value-> + propertyIdentifier)); } else { fprintf(stderr, "proprietary %u ", pProperty_value->propertyIdentifier); diff --git a/bacnet-stack/demo/handler/h_cov.c b/bacnet-stack/demo/handler/h_cov.c index f8820e18..ca597ce9 100644 --- a/bacnet-stack/demo/handler/h_cov.c +++ b/bacnet-stack/demo/handler/h_cov.c @@ -50,7 +50,7 @@ of an object that have been specified in the standard. */ typedef struct BACnet_COV_Subscription_Flags { bool valid:1; - bool issueConfirmedNotifications:1; /* optional */ + bool issueConfirmedNotifications:1; /* optional */ bool send_requested:1; } BACNET_COV_SUBSCRIPTION_FLAGS; @@ -59,7 +59,7 @@ typedef struct BACnet_COV_Subscription { BACNET_ADDRESS dest; uint32_t subscriberProcessIdentifier; BACNET_OBJECT_ID monitoredObjectIdentifier; - uint8_t invokeID; /* for confirmed COV */ + uint8_t invokeID; /* for confirmed COV */ uint32_t lifetime; /* optional */ } BACNET_COV_SUBSCRIPTION; @@ -390,8 +390,8 @@ static void cov_lifetime_expiration_handler( if (lifetime_seconds >= elapsed_seconds) { COV_Subscriptions[index].lifetime -= elapsed_seconds; #if 0 - fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n", - index, (unsigned long) COV_Subscriptions[index].lifetime); + fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n", index, + (unsigned long) COV_Subscriptions[index].lifetime); #endif } else { COV_Subscriptions[index].lifetime = 0; @@ -443,8 +443,7 @@ void handler_cov_timer_seconds( lifetime_seconds = COV_Subscriptions[index].lifetime; if (lifetime_seconds) { /* only expire COV with definite lifetimes */ - cov_lifetime_expiration_handler(index, - elapsed_seconds, + cov_lifetime_expiration_handler(index, elapsed_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; BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE; @@ -461,8 +461,7 @@ void handler_cov_task(void) bool send = false; BACNET_PROPERTY_VALUE value_list[2]; /* states for transmitting */ - static enum - { + static enum { COV_STATE_IDLE = 0, COV_STATE_MARK, COV_STATE_CLEAR, @@ -481,7 +480,8 @@ void handler_cov_task(void) object_type = (BACNET_OBJECT_TYPE) COV_Subscriptions[index].monitoredObjectIdentifier.type; object_instance = - COV_Subscriptions[index].monitoredObjectIdentifier.instance; + COV_Subscriptions[index].monitoredObjectIdentifier. + instance; status = Device_COV(object_type, object_instance); if (status) { COV_Subscriptions[index].flag.send_requested = true; @@ -500,7 +500,8 @@ void handler_cov_task(void) object_type = (BACNET_OBJECT_TYPE) COV_Subscriptions[index].monitoredObjectIdentifier.type; object_instance = - COV_Subscriptions[index].monitoredObjectIdentifier.instance; + COV_Subscriptions[index].monitoredObjectIdentifier. + instance; Device_COV_Clear(object_type, object_instance); } index++; @@ -516,8 +517,8 @@ void handler_cov_task(void) (COV_Subscriptions[index].invokeID)) { if (tsm_invoke_id_free(COV_Subscriptions[index].invokeID)) { COV_Subscriptions[index].invokeID = 0; - } else if (tsm_invoke_id_failed( - COV_Subscriptions[index].invokeID)) { + } else if (tsm_invoke_id_failed(COV_Subscriptions[index]. + invokeID)) { tsm_free_invoke_id(COV_Subscriptions[index].invokeID); COV_Subscriptions[index].invokeID = 0; } @@ -545,16 +546,18 @@ void handler_cov_task(void) } if (send) { object_type = (BACNET_OBJECT_TYPE) - COV_Subscriptions[index].monitoredObjectIdentifier.type; + COV_Subscriptions[index].monitoredObjectIdentifier. + type; object_instance = - COV_Subscriptions[index].monitoredObjectIdentifier.instance; + COV_Subscriptions[index].monitoredObjectIdentifier. + instance; /* configure the linked list for the two properties */ value_list[0].next = &value_list[1]; value_list[1].next = NULL; - (void)Device_Encode_Value_List(object_type, object_instance, - &value_list[0]); - status = cov_send_request( - &COV_Subscriptions[index], + (void) Device_Encode_Value_List(object_type, + object_instance, &value_list[0]); + status = + cov_send_request(&COV_Subscriptions[index], &value_list[0]); if (status) { COV_Subscriptions[index].flag.send_requested = false; @@ -584,7 +587,8 @@ static bool cov_subscribe( BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE; 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; status = Device_Valid_Object_Id(object_type, object_instance); if (status) { diff --git a/bacnet-stack/demo/handler/h_dcc.c b/bacnet-stack/demo/handler/h_dcc.c index d38929c3..3d4441bf 100644 --- a/bacnet-stack/demo/handler/h_dcc.c +++ b/bacnet-stack/demo/handler/h_dcc.c @@ -157,13 +157,14 @@ void handler_device_communication_control( } else { #if BAC_ROUTING /* Check to see if the current Device supports this service. */ - len = Routed_Device_Service_Approval( - SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state, - &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id ); - if ( len > 0 ) + len = + Routed_Device_Service_Approval + (SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state, + &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id); + if (len > 0) goto DCC_ABORT; #endif - + if (characterstring_ansi_same(&password, My_Password)) { len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], diff --git a/bacnet-stack/demo/handler/h_get_alarm_sum.c b/bacnet-stack/demo/handler/h_get_alarm_sum.c index 64dc994e..66813dc7 100644 --- a/bacnet-stack/demo/handler/h_get_alarm_sum.c +++ b/bacnet-stack/demo/handler/h_get_alarm_sum.c @@ -57,9 +57,9 @@ void handler_get_alarm_summary( BACNET_CONFIRMED_SERVICE_DATA * service_data) { int len = 0; - int pdu_len = 0; + int pdu_len = 0; int apdu_len = 0; - int bytes_sent = 0; + int bytes_sent = 0; int alarm_value = 0; unsigned i = 0; unsigned j = 0; @@ -90,9 +90,9 @@ void handler_get_alarm_summary( } /* init header */ - apdu_len = get_alarm_summary_ack_encode_apdu_init( - &Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id); + apdu_len = + get_alarm_summary_ack_encode_apdu_init(&Handler_Transmit_Buffer + [pdu_len], service_data->invoke_id); for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) { @@ -100,18 +100,16 @@ void handler_get_alarm_summary( for (j = 0; j < 0xffff; j++) { alarm_value = Get_Alarm_Summary[i] (j, &getalarm_data); if (alarm_value > 0) { - len = get_alarm_sumary_ack_encode_apdu_data( - &Handler_Transmit_Buffer[pdu_len + apdu_len], - service_data->max_resp - apdu_len, - &getalarm_data); + len = + get_alarm_sumary_ack_encode_apdu_data + (&Handler_Transmit_Buffer[pdu_len + apdu_len], + service_data->max_resp - apdu_len, &getalarm_data); if (len <= 0) { error = true; goto GET_ALARM_SUMMARY_ERROR; - } - else + } else apdu_len += len; - } - else if (alarm_value < 0) { + } else if (alarm_value < 0) { break; } } @@ -123,7 +121,7 @@ void handler_get_alarm_summary( fprintf(stderr, "GetAlarmSummary: Sending response!\n"); #endif -GET_ALARM_SUMMARY_ERROR: + GET_ALARM_SUMMARY_ERROR: if (error) { if (len == BACNET_STATUS_ABORT) { /* BACnet APDU too small to fit data, so proper response is Abort */ @@ -135,8 +133,7 @@ GET_ALARM_SUMMARY_ERROR: fprintf(stderr, "GetAlarmSummary: Reply too big to fit into APDU!\n"); #endif - } - else { + } else { apdu_len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, SERVICE_CONFIRMED_GET_ALARM_SUMMARY, @@ -148,7 +145,7 @@ GET_ALARM_SUMMARY_ERROR: } - GET_ALARM_SUMMARY_ABORT: + GET_ALARM_SUMMARY_ABORT: pdu_len += apdu_len; bytes_sent = datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], diff --git a/bacnet-stack/demo/handler/h_rd.c b/bacnet-stack/demo/handler/h_rd.c index ea0ddc77..287d19ec 100644 --- a/bacnet-stack/demo/handler/h_rd.c +++ b/bacnet-stack/demo/handler/h_rd.c @@ -131,13 +131,14 @@ void handler_reinitialize_device( } else { #if BAC_ROUTING /* Check to see if the current Device supports this service. */ - len = Routed_Device_Service_Approval( - SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state, - &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id ); - if ( len > 0 ) + len = + Routed_Device_Service_Approval + (SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state, + &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id); + if (len > 0) goto RD_ABORT; #endif - + if (Device_Reinitialize(&rd_data)) { len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], diff --git a/bacnet-stack/demo/handler/h_routed_npdu.c b/bacnet-stack/demo/handler/h_routed_npdu.c index 1f298a74..cf99e849 100644 --- a/bacnet-stack/demo/handler/h_routed_npdu.c +++ b/bacnet-stack/demo/handler/h_routed_npdu.c @@ -210,17 +210,17 @@ static void routed_apdu_handler( * we don't try the standard path of asking Who-Is-Router-to-Network. */ #if defined(BACDL_BIP) /* If wasn't unicast to us, must have been one of the bcast types. - * Drop it. */ - if ( bvlc_get_function_code() != BVLC_ORIGINAL_UNICAST_NPDU ) + * Drop it. */ + if (bvlc_get_function_code() != BVLC_ORIGINAL_UNICAST_NPDU) return; #endif - /* Upper level handlers knew that this was sent as a bcast, + /* Upper level handlers knew that this was sent as a bcast, * but our only other way to guess at that here is if the dest->adr * is absent, then we know this is some sort of bcast. */ - if ( dest->len > 0 ) { + if (dest->len > 0) { Send_Reject_Message_To_Network(src, NETWORK_REJECT_NO_ROUTE, - dest->net); + dest->net); } /* else, silently drop it */ return; } diff --git a/bacnet-stack/demo/handler/h_rpm.c b/bacnet-stack/demo/handler/h_rpm.c index e0a85b94..38c6d0ee 100644 --- a/bacnet-stack/demo/handler/h_rpm.c +++ b/bacnet-stack/demo/handler/h_rpm.c @@ -296,7 +296,8 @@ void handler_read_property_multiple( &Temp_Buf[0], apdu_len, len, MAX_APDU); if (copy_len == 0) { #if PRINT_ENABLED - fprintf(stderr, "RPM: Too full to encode property!\r\n"); + fprintf(stderr, + "RPM: Too full to encode property!\r\n"); #endif rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; diff --git a/bacnet-stack/demo/handler/h_rpm_a.c b/bacnet-stack/demo/handler/h_rpm_a.c index 0669c966..0744fef4 100644 --- a/bacnet-stack/demo/handler/h_rpm_a.c +++ b/bacnet-stack/demo/handler/h_rpm_a.c @@ -221,8 +221,8 @@ void rpm_ack_print_data( #if PRINT_ENABLED if (listOfProperties->propertyIdentifier < 512) { fprintf(stdout, " %s: ", - bactext_property_name(listOfProperties-> - propertyIdentifier)); + bactext_property_name + (listOfProperties->propertyIdentifier)); } else { fprintf(stdout, " proprietary %u: ", (unsigned) listOfProperties->propertyIdentifier); @@ -269,10 +269,10 @@ void rpm_ack_print_data( #if PRINT_ENABLED /* AccessError */ fprintf(stdout, "BACnet Error: %s: %s\r\n", - bactext_error_class_name((int) listOfProperties-> - error.error_class), - bactext_error_code_name((int) listOfProperties-> - error.error_code)); + bactext_error_class_name((int) listOfProperties->error. + error_class), + bactext_error_code_name((int) listOfProperties->error. + error_code)); #endif } listOfProperties = listOfProperties->next; diff --git a/bacnet-stack/demo/handler/h_ucov.c b/bacnet-stack/demo/handler/h_ucov.c index f5c198e0..6b872b5a 100644 --- a/bacnet-stack/demo/handler/h_ucov.c +++ b/bacnet-stack/demo/handler/h_ucov.c @@ -104,8 +104,8 @@ void handler_ucov_notification( fprintf(stderr, "UCOV: "); if (pProperty_value->propertyIdentifier < 512) { fprintf(stderr, "%s ", - bactext_property_name - (pProperty_value->propertyIdentifier)); + bactext_property_name(pProperty_value-> + propertyIdentifier)); } else { fprintf(stderr, "proprietary %u ", pProperty_value->propertyIdentifier); diff --git a/bacnet-stack/demo/handler/h_upt.c b/bacnet-stack/demo/handler/h_upt.c index adb8bb71..20ee283a 100644 --- a/bacnet-stack/demo/handler/h_upt.c +++ b/bacnet-stack/demo/handler/h_upt.c @@ -56,14 +56,15 @@ void handler_unconfirmed_private_transfer( #if PRINT_ENABLED fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n"); #endif - len = ptransfer_decode_service_request( - service_request, service_len, &private_data); + len = + ptransfer_decode_service_request(service_request, service_len, + &private_data); if (len >= 0) { #if PRINT_ENABLED printf("PrivateTransfer:vendorID=%u\r\n", - (unsigned)private_data.vendorID); + (unsigned) private_data.vendorID); printf("PrivateTransfer:serviceNumber=%lu\r\n", - (unsigned long)private_data.serviceNumber); + (unsigned long) private_data.serviceNumber); #endif application_data = private_data.serviceParameters; application_data_len = private_data.serviceParametersLen; @@ -107,4 +108,3 @@ void handler_unconfirmed_private_transfer( #endif } } - diff --git a/bacnet-stack/demo/handler/h_whohas.c b/bacnet-stack/demo/handler/h_whohas.c index 37f61238..a817fe17 100644 --- a/bacnet-stack/demo/handler/h_whohas.c +++ b/bacnet-stack/demo/handler/h_whohas.c @@ -65,9 +65,8 @@ static void match_name_or_object( } else { /* valid object_name copy in my device? */ found = - Device_Object_Name_Copy( - (BACNET_OBJECT_TYPE)data->object.identifier.type, - data->object.identifier.instance, &object_name); + Device_Object_Name_Copy((BACNET_OBJECT_TYPE) data->object. + identifier.type, data->object.identifier.instance, &object_name); if (found) { Send_I_Have(Device_Object_Instance_Number(), (BACNET_OBJECT_TYPE) data->object.identifier.type, @@ -110,7 +109,7 @@ void handler_who_has( } -#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */ +#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */ /** Handler for Who-Has requests in the virtual routing setup, * with broadcast I-Have response. * Will respond if the device Object ID matches, and we have diff --git a/bacnet-stack/demo/handler/h_whois.c b/bacnet-stack/demo/handler/h_whois.c index 9e843cc0..4d456afa 100644 --- a/bacnet-stack/demo/handler/h_whois.c +++ b/bacnet-stack/demo/handler/h_whois.c @@ -113,7 +113,7 @@ void handler_who_is_unicast( } -#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */ +#ifdef DEPRECATED /* was for BAC_ROUTING - delete in 2/2012 if still unused */ /** Local function to check Who-Is requests against our Device IDs. * Will check the gateway (root Device) and all virtual routed * Devices against the range and respond for each that matches. diff --git a/bacnet-stack/demo/handler/h_wp.c b/bacnet-stack/demo/handler/h_wp.c index 942de8b6..09da8f1c 100644 --- a/bacnet-stack/demo/handler/h_wp.c +++ b/bacnet-stack/demo/handler/h_wp.c @@ -181,8 +181,8 @@ bool WPValidateString( (!characterstring_printable(&pValue->type.Character_String))) { /* assumption: non-empty also means must be "printable" */ *pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE; - } else if (characterstring_length(&pValue-> - type.Character_String) > iMaxLen) { + } else if (characterstring_length(&pValue->type.Character_String) > + iMaxLen) { *pErrorClass = ERROR_CLASS_RESOURCES; *pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY; } else diff --git a/bacnet-stack/demo/handler/h_wpm.c b/bacnet-stack/demo/handler/h_wpm.c index 1c4dae6c..493758e2 100644 --- a/bacnet-stack/demo/handler/h_wpm.c +++ b/bacnet-stack/demo/handler/h_wpm.c @@ -155,7 +155,7 @@ void handler_write_property_multiple( } } while (decode_len < service_len); -WPM_ABORT: + WPM_ABORT: /* encode the NPDU portion of the packet */ datalink_get_my_address(&my_address); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); diff --git a/bacnet-stack/demo/handler/s_wp.c b/bacnet-stack/demo/handler/s_wp.c index d65d4b57..80f8daeb 100644 --- a/bacnet-stack/demo/handler/s_wp.c +++ b/bacnet-stack/demo/handler/s_wp.c @@ -157,9 +157,8 @@ uint8_t Send_Write_Property_Request( #if PRINT_ENABLED_DEBUG fprintf(stderr, "WriteProperty service: " "%s tag=%d\n", (object_value->context_specific ? "context" : "application"), - (int) (object_value-> - context_specific ? object_value->context_tag : object_value-> - tag)); + (int) (object_value->context_specific ? object_value-> + context_tag : object_value->tag)); #endif len = bacapp_encode_data(&application_data[apdu_len], object_value); if ((len + apdu_len) < MAX_APDU) { diff --git a/bacnet-stack/demo/mstpcrc/main.c b/bacnet-stack/demo/mstpcrc/main.c index b0e11e9a..801b79b7 100644 --- a/bacnet-stack/demo/mstpcrc/main.c +++ b/bacnet-stack/demo/mstpcrc/main.c @@ -73,18 +73,20 @@ static FILE *pFile = NULL; /* stream pointer */ * RETURN: number of arguments parsed * NOTES: none ******************************************************************/ -static void Parse_Arguments(int argc, char *argv[]) +static void Parse_Arguments( + int argc, + char *argv[]) { int i = 0; long long_value = 0; - for (i=1;i 1) && (strcmp(argv[1], "--help") == 0)) { printf("mstpcrc [options] <00 00 00 00...>\r\n" - "perform MS/TP CRC on data bytes.\r\n" - "options:\r\n" + "perform MS/TP CRC on data bytes.\r\n" "options:\r\n" "[-x] interprete the arguments as ascii hex (default)\r\n" "[-d] interprete the argument as ascii decimal\r\n" "[-m] Write the bytes to Wireshark capture file\r\n" @@ -243,35 +248,35 @@ int main( if (MSTP_Cap) { Write_Pcap(CRC_Buffer, CRC_Buffer_Len); } else { - for (i = 0; i < CRC_Buffer_Len; i++) { + for (i = 0; i < CRC_Buffer_Len; i++) { + if (CRC_Size == 8) { + crc8 = CRC_Calc_Header(CRC_Buffer[i], crc8); + } else if (CRC_Size == 16) { + crc16 = CRC_Calc_Data(CRC_Buffer[i], crc16); + } + if (ASCII_Decimal) { + printf("%u\r\n", (unsigned) CRC_Buffer[i]); + } else { + printf("0x%02X\r\n", CRC_Buffer[i]); + } + } if (CRC_Size == 8) { - crc8 = CRC_Calc_Header(CRC_Buffer[i], crc8); + crc8 = ~crc8; + if (ASCII_Decimal) { + printf("%u Header CRC\r\n", (unsigned) crc8); + } else { + printf("0x%02X Header CRC\r\n", crc8); + } } else if (CRC_Size == 16) { - crc16 = CRC_Calc_Data(CRC_Buffer[i], crc16); + crc16 = ~crc16; + if (ASCII_Decimal) { + printf("%u Data CRC\r\n", (unsigned) (crc16 & 0xFF)); + printf("%u Data CRC\r\n", (unsigned) (crc16 >> 8)); + } else { + printf("0x%02X Data CRC\r\n", (crc16 & 0xFF)); + printf("0x%02X Data CRC\r\n", (crc16 >> 8)); + } } - if (ASCII_Decimal) { - printf("%u\r\n", (unsigned)CRC_Buffer[i]); - } else { - printf("0x%02X\r\n", CRC_Buffer[i]); - } - } - if (CRC_Size == 8) { - crc8 = ~crc8; - if (ASCII_Decimal) { - printf("%u Header CRC\r\n", (unsigned)crc8); - } else { - printf("0x%02X Header CRC\r\n", crc8); - } - } else if (CRC_Size == 16) { - crc16 = ~crc16; - if (ASCII_Decimal) { - printf("%u Data CRC\r\n", (unsigned)(crc16 & 0xFF)); - printf("%u Data CRC\r\n", (unsigned)(crc16 >> 8)); - } else { - printf("0x%02X Data CRC\r\n", (crc16 & 0xFF)); - printf("0x%02X Data CRC\r\n", (crc16 >> 8)); - } - } } } diff --git a/bacnet-stack/demo/object/ai.c b/bacnet-stack/demo/object/ai.c index 653d2782..c28ea980 100644 --- a/bacnet-stack/demo/object/ai.c +++ b/bacnet-stack/demo/object/ai.c @@ -352,11 +352,11 @@ int Analog_Input_Read_Property( case PROP_LIMIT_ENABLE: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, 0, - (CurrentAI-> - Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false); + (CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : + false); bitstring_set_bit(&bit_string, 1, - (CurrentAI-> - Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false); + (CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : + false); apdu_len = encode_application_bitstring(&apdu[0], &bit_string); break; @@ -364,14 +364,14 @@ int Analog_Input_Read_Property( case PROP_EVENT_ENABLE: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, - (CurrentAI-> - Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); + (CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : + false); bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, - (CurrentAI-> - Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); + (CurrentAI->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : + false); bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, - (CurrentAI-> - Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); + (CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : + false); apdu_len = encode_application_bitstring(&apdu[0], &bit_string); break; @@ -379,8 +379,8 @@ int Analog_Input_Read_Property( case PROP_ACKED_TRANSITIONS: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, - CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked); + CurrentAI-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, @@ -504,7 +504,7 @@ bool Analog_Input_Write_Property( else return false; - switch ((int)wp_data->object_property) { + switch ((int) wp_data->object_property) { case PROP_PRESENT_VALUE: status = WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL, @@ -909,17 +909,17 @@ void Analog_Input_Intrinsic_Reporting( event_data.notificationParams.outOfRange.exceedingValue = PresentVal; /* Status_Flags of the referenced object. */ - bitstring_init(&event_data.notificationParams.outOfRange. - statusFlags); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_IN_ALARM, + bitstring_init(&event_data.notificationParams. + outOfRange.statusFlags); + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_IN_ALARM, CurrentAI->Event_State ? true : false); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_FAULT, false); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_OUT_OF_SERVICE, + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_FAULT, false); + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service); /* Deadband used for limit checking. */ event_data.notificationParams.outOfRange.deadband = @@ -939,24 +939,30 @@ void Analog_Input_Intrinsic_Reporting( case EVENT_STATE_OFFNORMAL: case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_LOW_LIMIT: - CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked = false; - CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - Time_Stamp = event_data.timeStamp.value.dateTime; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = + false; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp = + event_data.timeStamp.value.dateTime; break; case EVENT_STATE_FAULT: - CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT]. - bIsAcked = false; - CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT]. - Time_Stamp = event_data.timeStamp.value.dateTime; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = + false; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp = + event_data.timeStamp.value.dateTime; break; case EVENT_STATE_NORMAL: - CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL]. - bIsAcked = false; - CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL]. - Time_Stamp = event_data.timeStamp.value.dateTime; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = + false; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp = + event_data.timeStamp.value.dateTime; break; } } @@ -983,12 +989,12 @@ int Analog_Input_Event_Information( /* Acked_Transitions property, which has at least one of the bits (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */ IsNotAckedTransitions = - (AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked == - false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT]. - bIsAcked == - false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL]. - bIsAcked == false); + (AI_Descr[index]. + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == + false) | (AI_Descr[index]. + Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == + false) | (AI_Descr[index]. + Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false); } else return -1; /* end of list */ @@ -1003,8 +1009,8 @@ int Analog_Input_Event_Information( bitstring_init(&getevent_data->acknowledgedTransitions); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL, - AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked); + AI_Descr[index]. + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT, AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); @@ -1022,14 +1028,14 @@ int Analog_Input_Event_Information( /* Event Enable */ bitstring_init(&getevent_data->eventEnable); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL, - (AI_Descr[index]. - Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); + (AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : + false); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT, - (AI_Descr[index]. - Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); + (AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : + false); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL, - (AI_Descr[index]. - Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); + (AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : + false); /* Event Priorities */ Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class, getevent_data->eventPriorities); @@ -1049,8 +1055,8 @@ int Analog_Input_Alarm_Ack( object_index = - Analog_Input_Instance_To_Index(alarmack_data->eventObjectIdentifier. - instance); + Analog_Input_Instance_To_Index(alarmack_data-> + eventObjectIdentifier.instance); if (object_index < MAX_ANALOG_INPUTS) CurrentAI = &AI_Descr[object_index]; @@ -1063,22 +1069,22 @@ int Analog_Input_Alarm_Ack( case EVENT_STATE_OFFNORMAL: case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_LOW_LIMIT: - if (CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked == false) { + if (CurrentAI-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) { if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } - if (datetime_compare(&CurrentAI-> - Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp, + if (datetime_compare(&CurrentAI->Acked_Transitions + [TRANSITION_TO_OFFNORMAL].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } /* FIXME: Send ack notification */ - CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked = true; + CurrentAI-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true; } else { *error_code = ERROR_CODE_INVALID_EVENT_STATE; return -1; @@ -1092,8 +1098,8 @@ int Analog_Input_Alarm_Ack( *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } - if (datetime_compare(&CurrentAI-> - Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp, + if (datetime_compare(&CurrentAI->Acked_Transitions + [TRANSITION_TO_NORMAL].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; @@ -1115,8 +1121,8 @@ int Analog_Input_Alarm_Ack( *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } - if (datetime_compare(&CurrentAI-> - Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp, + if (datetime_compare(&CurrentAI->Acked_Transitions + [TRANSITION_TO_FAULT].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; @@ -1147,31 +1153,32 @@ int Analog_Input_Alarm_Summary( if (index < MAX_ANALOG_INPUTS) { /* Event_State is not equal to NORMAL and Notify_Type property value is ALARM */ - if((AI_Descr[index].Event_State != EVENT_STATE_NORMAL) && - (AI_Descr[index].Notify_Type == NOTIFY_ALARM)){ + if ((AI_Descr[index].Event_State != EVENT_STATE_NORMAL) && + (AI_Descr[index].Notify_Type == NOTIFY_ALARM)) { /* Object Identifier */ getalarm_data->objectIdentifier.type = OBJECT_ANALOG_INPUT; getalarm_data->objectIdentifier.instance = - Analog_Input_Index_To_Instance(index); + Analog_Input_Index_To_Instance(index); /* Alarm State */ getalarm_data->alarmState = AI_Descr[index].Event_State; /* Acknowledged Transitions */ bitstring_init(&getalarm_data->acknowledgedTransitions); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL, - AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked); + AI_Descr[index]. + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, 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, 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 */ - } - else - return 0; /* no active alarm at this index */ + return 1; /* active alarm */ + } else + return 0; /* no active alarm at this index */ } else return -1; /* end of list */ } diff --git a/bacnet-stack/demo/object/ai.h b/bacnet-stack/demo/object/ai.h index 10b0c7b7..dce6732d 100644 --- a/bacnet-stack/demo/object/ai.h +++ b/bacnet-stack/demo/object/ai.h @@ -149,5 +149,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/ao.c b/bacnet-stack/demo/object/ao.c index ce69f817..93e13e48 100644 --- a/bacnet-stack/demo/object/ao.c +++ b/bacnet-stack/demo/object/ao.c @@ -447,11 +447,11 @@ bool Analog_Output_Write_Property( if (status) { level = AO_LEVEL_NULL; object_index = - Analog_Output_Instance_To_Index - (wp_data->object_instance); + Analog_Output_Instance_To_Index(wp_data-> + object_instance); status = - Analog_Output_Present_Value_Relinquish - (wp_data->object_instance, wp_data->priority); + Analog_Output_Present_Value_Relinquish(wp_data-> + object_instance, wp_data->priority); if (!status) { wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; diff --git a/bacnet-stack/demo/object/ao.h b/bacnet-stack/demo/object/ao.h index 688120a8..0e9c0772 100644 --- a/bacnet-stack/demo/object/ao.h +++ b/bacnet-stack/demo/object/ao.h @@ -100,5 +100,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/av.c b/bacnet-stack/demo/object/av.c index 017902f1..836406f4 100644 --- a/bacnet-stack/demo/object/av.c +++ b/bacnet-stack/demo/object/av.c @@ -424,11 +424,11 @@ int Analog_Value_Read_Property( case PROP_LIMIT_ENABLE: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, 0, - (CurrentAV-> - Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false); + (CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : + false); bitstring_set_bit(&bit_string, 1, - (CurrentAV-> - Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false); + (CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : + false); apdu_len = encode_application_bitstring(&apdu[0], &bit_string); break; @@ -436,14 +436,14 @@ int Analog_Value_Read_Property( case PROP_EVENT_ENABLE: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, - (CurrentAV-> - Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); + (CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : + false); bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, - (CurrentAV-> - Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); + (CurrentAV->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : + false); bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, - (CurrentAV-> - Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); + (CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : + false); apdu_len = encode_application_bitstring(&apdu[0], &bit_string); break; @@ -451,8 +451,8 @@ int Analog_Value_Read_Property( case PROP_ACKED_TRANSITIONS: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, - CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked); + CurrentAV-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, @@ -1004,17 +1004,17 @@ void Analog_Value_Intrinsic_Reporting( event_data.notificationParams.outOfRange.exceedingValue = PresentVal; /* Status_Flags of the referenced object. */ - bitstring_init(&event_data.notificationParams.outOfRange. - statusFlags); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_IN_ALARM, + bitstring_init(&event_data.notificationParams. + outOfRange.statusFlags); + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_IN_ALARM, CurrentAV->Event_State ? true : false); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_FAULT, false); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_OVERRIDDEN, false); - bitstring_set_bit(&event_data.notificationParams.outOfRange. - statusFlags, STATUS_FLAG_OUT_OF_SERVICE, + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_FAULT, false); + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); + bitstring_set_bit(&event_data.notificationParams. + outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service); /* Deadband used for limit checking. */ event_data.notificationParams.outOfRange.deadband = @@ -1034,24 +1034,30 @@ void Analog_Value_Intrinsic_Reporting( case EVENT_STATE_OFFNORMAL: case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_LOW_LIMIT: - CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked = false; - CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - Time_Stamp = event_data.timeStamp.value.dateTime; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = + false; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp = + event_data.timeStamp.value.dateTime; break; case EVENT_STATE_FAULT: - CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT]. - bIsAcked = false; - CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT]. - Time_Stamp = event_data.timeStamp.value.dateTime; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = + false; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp = + event_data.timeStamp.value.dateTime; break; case EVENT_STATE_NORMAL: - CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL]. - bIsAcked = false; - CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL]. - Time_Stamp = event_data.timeStamp.value.dateTime; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = + false; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp = + event_data.timeStamp.value.dateTime; break; } } @@ -1078,12 +1084,12 @@ int Analog_Value_Event_Information( /* Acked_Transitions property, which has at least one of the bits (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */ IsNotAckedTransitions = - (AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked == - false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT]. - bIsAcked == - false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL]. - bIsAcked == false); + (AV_Descr[index]. + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == + false) | (AV_Descr[index]. + Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == + false) | (AV_Descr[index]. + Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false); } else return -1; /* end of list */ @@ -1098,8 +1104,8 @@ int Analog_Value_Event_Information( bitstring_init(&getevent_data->acknowledgedTransitions); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL, - AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked); + AV_Descr[index]. + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT, AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); @@ -1117,14 +1123,14 @@ int Analog_Value_Event_Information( /* Event Enable */ bitstring_init(&getevent_data->eventEnable); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL, - (AV_Descr[index]. - Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); + (AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : + false); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT, - (AV_Descr[index]. - Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); + (AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : + false); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL, - (AV_Descr[index]. - Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); + (AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : + false); /* Event Priorities */ Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class, getevent_data->eventPriorities); @@ -1143,8 +1149,8 @@ int Analog_Value_Alarm_Ack( object_index = - Analog_Value_Instance_To_Index(alarmack_data->eventObjectIdentifier. - instance); + Analog_Value_Instance_To_Index(alarmack_data-> + eventObjectIdentifier.instance); if (object_index < MAX_ANALOG_VALUES) CurrentAV = &AV_Descr[object_index]; @@ -1157,22 +1163,22 @@ int Analog_Value_Alarm_Ack( case EVENT_STATE_OFFNORMAL: case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_LOW_LIMIT: - if (CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked == false) { + if (CurrentAV-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) { if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } - if (datetime_compare(&CurrentAV-> - Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp, + if (datetime_compare(&CurrentAV->Acked_Transitions + [TRANSITION_TO_OFFNORMAL].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } /* Clean transitions flag. */ - CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked = true; + CurrentAV-> + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true; } else { *error_code = ERROR_CODE_INVALID_EVENT_STATE; return -1; @@ -1186,8 +1192,8 @@ int Analog_Value_Alarm_Ack( *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } - if (datetime_compare(&CurrentAV-> - Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp, + if (datetime_compare(&CurrentAV->Acked_Transitions + [TRANSITION_TO_NORMAL].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; @@ -1209,8 +1215,8 @@ int Analog_Value_Alarm_Ack( *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; } - if (datetime_compare(&CurrentAV-> - Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp, + if (datetime_compare(&CurrentAV->Acked_Transitions + [TRANSITION_TO_FAULT].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; return -1; @@ -1246,31 +1252,32 @@ int Analog_Value_Alarm_Summary( if (index < MAX_ANALOG_VALUES) { /* Event_State is not equal to NORMAL and Notify_Type property value is ALARM */ - if((AV_Descr[index].Event_State != EVENT_STATE_NORMAL) && - (AV_Descr[index].Notify_Type == NOTIFY_ALARM)){ + if ((AV_Descr[index].Event_State != EVENT_STATE_NORMAL) && + (AV_Descr[index].Notify_Type == NOTIFY_ALARM)) { /* Object Identifier */ getalarm_data->objectIdentifier.type = OBJECT_ANALOG_VALUE; getalarm_data->objectIdentifier.instance = - Analog_Value_Index_To_Instance(index); + Analog_Value_Index_To_Instance(index); /* Alarm State */ getalarm_data->alarmState = AV_Descr[index].Event_State; /* Acknowledged Transitions */ bitstring_init(&getalarm_data->acknowledgedTransitions); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL, - AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL]. - bIsAcked); + AV_Descr[index]. + Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, 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, 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 */ - } - else - return 0; /* no active alarm at this index */ + return 1; /* active alarm */ + } else + return 0; /* no active alarm at this index */ } else return -1; /* end of list */ } diff --git a/bacnet-stack/demo/object/av.h b/bacnet-stack/demo/object/av.h index 1171fd9c..b5be8bb7 100644 --- a/bacnet-stack/demo/object/av.h +++ b/bacnet-stack/demo/object/av.h @@ -116,8 +116,8 @@ extern "C" { BACNET_ERROR_CODE * error_code); int Analog_Value_Alarm_Summary( - unsigned index, - BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data); + unsigned index, + BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data); #endif void Analog_Value_Init( @@ -132,5 +132,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index e0732973..fcffeeae 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -474,7 +474,8 @@ bool bacfile_write_stream_data( } if (pFile) { 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), octetstring_length(&data->fileData), 1, pFile) != 1) { diff --git a/bacnet-stack/demo/object/bacfile.h b/bacnet-stack/demo/object/bacfile.h index 4cd53a13..f934f86b 100644 --- a/bacnet-stack/demo/object/bacfile.h +++ b/bacnet-stack/demo/object/bacfile.h @@ -98,5 +98,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/bi.h b/bacnet-stack/demo/object/bi.h index dd0a9c9f..0d41ed31 100644 --- a/bacnet-stack/demo/object/bi.h +++ b/bacnet-stack/demo/object/bi.h @@ -114,5 +114,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/bo.c b/bacnet-stack/demo/object/bo.c index f68ed73c..1dce83b6 100644 --- a/bacnet-stack/demo/object/bo.c +++ b/bacnet-stack/demo/object/bo.c @@ -376,8 +376,8 @@ bool Binary_Output_Write_Property( (value.type.Enumerated <= MAX_BINARY_PV)) { level = (BACNET_BINARY_PV) value.type.Enumerated; object_index = - Binary_Output_Instance_To_Index - (wp_data->object_instance); + Binary_Output_Instance_To_Index(wp_data-> + object_instance); priority--; Binary_Output_Level[object_index][priority] = level; /* Note: you could set the physical output here if we @@ -403,8 +403,8 @@ bool Binary_Output_Write_Property( if (status) { level = BINARY_NULL; object_index = - Binary_Output_Instance_To_Index - (wp_data->object_instance); + Binary_Output_Instance_To_Index(wp_data-> + object_instance); priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; diff --git a/bacnet-stack/demo/object/bo.h b/bacnet-stack/demo/object/bo.h index 63f0ce48..2dbbcea1 100644 --- a/bacnet-stack/demo/object/bo.h +++ b/bacnet-stack/demo/object/bo.h @@ -116,5 +116,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/bv.c b/bacnet-stack/demo/object/bv.c index e77fc6f0..2826c9a3 100644 --- a/bacnet-stack/demo/object/bv.c +++ b/bacnet-stack/demo/object/bv.c @@ -359,8 +359,8 @@ bool Binary_Value_Write_Property( (value.type.Enumerated <= MAX_BINARY_PV)) { level = (BACNET_BINARY_PV) value.type.Enumerated; object_index = - Binary_Value_Instance_To_Index - (wp_data->object_instance); + Binary_Value_Instance_To_Index(wp_data-> + object_instance); priority--; Binary_Value_Level[object_index][priority] = level; /* Note: you could set the physical output here if we @@ -386,8 +386,8 @@ bool Binary_Value_Write_Property( if (status) { level = BINARY_NULL; object_index = - Binary_Value_Instance_To_Index - (wp_data->object_instance); + Binary_Value_Instance_To_Index(wp_data-> + object_instance); priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; diff --git a/bacnet-stack/demo/object/bv.h b/bacnet-stack/demo/object/bv.h index 8d437ac2..7fbb872b 100644 --- a/bacnet-stack/demo/object/bv.h +++ b/bacnet-stack/demo/object/bv.h @@ -71,5 +71,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/csv.c b/bacnet-stack/demo/object/csv.c index 0240500f..f8c6dd73 100644 --- a/bacnet-stack/demo/object/csv.c +++ b/bacnet-stack/demo/object/csv.c @@ -152,9 +152,7 @@ bool CharacterString_Value_Present_Value( index = CharacterString_Value_Instance_To_Index(object_instance); if (object_name && (index < MAX_CHARACTERSTRING_VALUES)) { - status = characterstring_copy( - object_name, - &Present_Value[index]); + status = characterstring_copy(object_name, &Present_Value[index]); } return status; @@ -169,9 +167,7 @@ bool CharacterString_Value_Present_Value_Set( index = CharacterString_Value_Instance_To_Index(object_instance); if (index < MAX_CHARACTERSTRING_VALUES) { - status = characterstring_copy( - &Present_Value[index], - object_name); + status = characterstring_copy(&Present_Value[index], object_name); } return status; @@ -361,7 +357,8 @@ int CharacterString_Value_Read_Property( break; case PROP_OUT_OF_SERVICE: object_index = - CharacterString_Value_Instance_To_Index(rpdata->object_instance); + CharacterString_Value_Instance_To_Index(rpdata-> + object_instance); state = Out_Of_Service[object_index]; apdu_len = encode_application_boolean(&apdu[0], state); break; @@ -405,13 +402,12 @@ bool CharacterString_Value_Write_Property( case PROP_PRESENT_VALUE: status = WPValidateArgType(&value, - BACNET_APPLICATION_TAG_CHARACTER_STRING, - &wp_data->error_class, &wp_data->error_code); + BACNET_APPLICATION_TAG_CHARACTER_STRING, &wp_data->error_class, + &wp_data->error_code); if (status) { status = - CharacterString_Value_Present_Value_Set - (wp_data->object_instance, - &value.type.Character_String); + CharacterString_Value_Present_Value_Set(wp_data-> + object_instance, &value.type.Character_String); if (!status) { wp_data->error_class = ERROR_CLASS_PROPERTY; 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, &wp_data->error_class, &wp_data->error_code); if (status) { - CharacterString_Value_Out_Of_Service_Set( - wp_data->object_instance, value.type.Boolean); + CharacterString_Value_Out_Of_Service_Set(wp_data-> + object_instance, value.type.Boolean); } break; default: diff --git a/bacnet-stack/demo/object/csv.h b/bacnet-stack/demo/object/csv.h index 66b74d0b..5813496c 100644 --- a/bacnet-stack/demo/object/csv.h +++ b/bacnet-stack/demo/object/csv.h @@ -92,5 +92,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/device-client.c b/bacnet-stack/demo/object/device-client.c index d0968faa..02565b49 100644 --- a/bacnet-stack/demo/object/device-client.c +++ b/bacnet-stack/demo/object/device-client.c @@ -104,35 +104,35 @@ extern bool Routed_Device_Write_Property_Local( /* All included BACnet objects */ static object_functions_t Object_Table[] = { {OBJECT_DEVICE, - NULL /* Init - don't init Device or it will recourse! */, - Device_Count, - Device_Index_To_Instance, - Device_Valid_Object_Instance_Number, - Device_Object_Name, - Device_Read_Property_Local, - NULL /* Write_Property */, - NULL /* Property_Lists */, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + NULL /* Init - don't init Device or it will recourse! */ , + Device_Count, + Device_Index_To_Instance, + Device_Valid_Object_Instance_Number, + Device_Object_Name, + Device_Read_Property_Local, + NULL /* Write_Property */ , + NULL /* Property_Lists */ , + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {MAX_BACNET_OBJECT_TYPE, - NULL /* Init */, - NULL /* Count */, - NULL /* Index_To_Instance */, - NULL /* Valid_Instance */, - NULL /* Object_Name */, - NULL /* Read_Property */, - NULL /* Write_Property */, - NULL /* Property_Lists */, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */} + NULL /* Init */ , + NULL /* Count */ , + NULL /* Index_To_Instance */ , + NULL /* Valid_Instance */ , + NULL /* Object_Name */ , + NULL /* Read_Property */ , + NULL /* Write_Property */ , + NULL /* Property_Lists */ , + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ } }; /** Glue function to let the Device object, when called by a handler, @@ -906,6 +906,7 @@ bool Device_Write_Property( wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; return (status); } + /* Ditto for the local version; always returns false */ bool Device_Write_Property_Local( BACNET_WRITE_PROPERTY_DATA * wp_data) @@ -941,5 +942,3 @@ void Device_Init( pObject++; } } - - diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index b9eace06..53d6539f 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -90,234 +90,234 @@ static object_functions_t *Object_Table; static object_functions_t My_Object_Table[] = { {OBJECT_DEVICE, - NULL /* Init - don't init Device or it will recourse! */, - Device_Count, - Device_Index_To_Instance, - Device_Valid_Object_Instance_Number, - Device_Object_Name, - Device_Read_Property_Local, - Device_Write_Property_Local, - Device_Property_Lists, - DeviceGetRRInfo, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + NULL /* Init - don't init Device or it will recourse! */ , + Device_Count, + Device_Index_To_Instance, + Device_Valid_Object_Instance_Number, + Device_Object_Name, + Device_Read_Property_Local, + Device_Write_Property_Local, + Device_Property_Lists, + DeviceGetRRInfo, + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_ANALOG_INPUT, - Analog_Input_Init, - Analog_Input_Count, - Analog_Input_Index_To_Instance, - Analog_Input_Valid_Instance, - Analog_Input_Object_Name, - Analog_Input_Read_Property, - Analog_Input_Write_Property, - Analog_Input_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, + Analog_Input_Init, + Analog_Input_Count, + Analog_Input_Index_To_Instance, + Analog_Input_Valid_Instance, + Analog_Input_Object_Name, + Analog_Input_Read_Property, + Analog_Input_Write_Property, + Analog_Input_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , Analog_Input_Intrinsic_Reporting}, {OBJECT_ANALOG_VALUE, - Analog_Value_Init, - Analog_Value_Count, - Analog_Value_Index_To_Instance, - Analog_Value_Valid_Instance, - Analog_Value_Object_Name, - Analog_Value_Read_Property, - Analog_Value_Write_Property, - Analog_Value_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, + Analog_Value_Init, + Analog_Value_Count, + Analog_Value_Index_To_Instance, + Analog_Value_Valid_Instance, + Analog_Value_Object_Name, + Analog_Value_Read_Property, + Analog_Value_Write_Property, + Analog_Value_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , Analog_Value_Intrinsic_Reporting}, {OBJECT_BINARY_INPUT, - Binary_Input_Init, - Binary_Input_Count, - Binary_Input_Index_To_Instance, - Binary_Input_Valid_Instance, - Binary_Input_Object_Name, - Binary_Input_Read_Property, - NULL /* Write Property */, - Binary_Input_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - Binary_Input_Encode_Value_List, - Binary_Input_Change_Of_Value, - Binary_Input_Change_Of_Value_Clear, - NULL /* Intrinsic Reporting */}, + Binary_Input_Init, + Binary_Input_Count, + Binary_Input_Index_To_Instance, + Binary_Input_Valid_Instance, + Binary_Input_Object_Name, + Binary_Input_Read_Property, + NULL /* Write Property */ , + Binary_Input_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + Binary_Input_Encode_Value_List, + Binary_Input_Change_Of_Value, + Binary_Input_Change_Of_Value_Clear, + NULL /* Intrinsic Reporting */ }, {OBJECT_BINARY_VALUE, - Binary_Value_Init, - Binary_Value_Count, - Binary_Value_Index_To_Instance, - Binary_Value_Valid_Instance, - Binary_Value_Object_Name, - Binary_Value_Read_Property, - Binary_Value_Write_Property, - Binary_Value_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Binary_Value_Init, + Binary_Value_Count, + Binary_Value_Index_To_Instance, + Binary_Value_Valid_Instance, + Binary_Value_Object_Name, + Binary_Value_Read_Property, + Binary_Value_Write_Property, + Binary_Value_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_CHARACTERSTRING_VALUE, - CharacterString_Value_Init, - CharacterString_Value_Count, - CharacterString_Value_Index_To_Instance, - CharacterString_Value_Valid_Instance, - CharacterString_Value_Object_Name, - CharacterString_Value_Read_Property, - CharacterString_Value_Write_Property, - CharacterString_Value_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + CharacterString_Value_Init, + CharacterString_Value_Count, + CharacterString_Value_Index_To_Instance, + CharacterString_Value_Valid_Instance, + CharacterString_Value_Object_Name, + CharacterString_Value_Read_Property, + CharacterString_Value_Write_Property, + CharacterString_Value_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, #if defined(INTRINSIC_REPORTING) {OBJECT_NOTIFICATION_CLASS, - Notification_Class_Init, - Notification_Class_Count, - Notification_Class_Index_To_Instance, - Notification_Class_Valid_Instance, - Notification_Class_Object_Name, - Notification_Class_Read_Property, - Notification_Class_Write_Property, - Notification_Class_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Notification_Class_Init, + Notification_Class_Count, + Notification_Class_Index_To_Instance, + Notification_Class_Valid_Instance, + Notification_Class_Object_Name, + Notification_Class_Read_Property, + Notification_Class_Write_Property, + Notification_Class_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, #endif {OBJECT_LIFE_SAFETY_POINT, - Life_Safety_Point_Init, - Life_Safety_Point_Count, - Life_Safety_Point_Index_To_Instance, - Life_Safety_Point_Valid_Instance, - Life_Safety_Point_Object_Name, - Life_Safety_Point_Read_Property, - Life_Safety_Point_Write_Property, - Life_Safety_Point_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Life_Safety_Point_Init, + Life_Safety_Point_Count, + Life_Safety_Point_Index_To_Instance, + Life_Safety_Point_Valid_Instance, + Life_Safety_Point_Object_Name, + Life_Safety_Point_Read_Property, + Life_Safety_Point_Write_Property, + Life_Safety_Point_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_LOAD_CONTROL, - Load_Control_Init, - Load_Control_Count, - Load_Control_Index_To_Instance, - Load_Control_Valid_Instance, - Load_Control_Object_Name, - Load_Control_Read_Property, - Load_Control_Write_Property, - Load_Control_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Load_Control_Init, + Load_Control_Count, + Load_Control_Index_To_Instance, + Load_Control_Valid_Instance, + Load_Control_Object_Name, + Load_Control_Read_Property, + Load_Control_Write_Property, + Load_Control_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_MULTI_STATE_INPUT, - Multistate_Input_Init, - Multistate_Input_Count, - Multistate_Input_Index_To_Instance, - Multistate_Input_Valid_Instance, - Multistate_Input_Object_Name, - Multistate_Input_Read_Property, - Multistate_Input_Write_Property, - Multistate_Input_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Multistate_Input_Init, + Multistate_Input_Count, + Multistate_Input_Index_To_Instance, + Multistate_Input_Valid_Instance, + Multistate_Input_Object_Name, + Multistate_Input_Read_Property, + Multistate_Input_Write_Property, + Multistate_Input_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_MULTI_STATE_OUTPUT, - Multistate_Output_Init, - Multistate_Output_Count, - Multistate_Output_Index_To_Instance, - Multistate_Output_Valid_Instance, - Multistate_Output_Object_Name, - Multistate_Output_Read_Property, - Multistate_Output_Write_Property, - Multistate_Output_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Multistate_Output_Init, + Multistate_Output_Count, + Multistate_Output_Index_To_Instance, + Multistate_Output_Valid_Instance, + Multistate_Output_Object_Name, + Multistate_Output_Read_Property, + Multistate_Output_Write_Property, + Multistate_Output_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_MULTI_STATE_VALUE, - Multistate_Value_Init, - Multistate_Value_Count, - Multistate_Value_Index_To_Instance, - Multistate_Value_Valid_Instance, - Multistate_Value_Object_Name, - Multistate_Value_Read_Property, - Multistate_Value_Write_Property, - Multistate_Value_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Multistate_Value_Init, + Multistate_Value_Count, + Multistate_Value_Index_To_Instance, + Multistate_Value_Valid_Instance, + Multistate_Value_Object_Name, + Multistate_Value_Read_Property, + Multistate_Value_Write_Property, + Multistate_Value_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, {OBJECT_TRENDLOG, - Trend_Log_Init, - Trend_Log_Count, - Trend_Log_Index_To_Instance, - Trend_Log_Valid_Instance, - Trend_Log_Object_Name, - Trend_Log_Read_Property, - Trend_Log_Write_Property, - Trend_Log_Property_Lists, - TrendLogGetRRInfo, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + Trend_Log_Init, + Trend_Log_Count, + Trend_Log_Index_To_Instance, + Trend_Log_Valid_Instance, + Trend_Log_Object_Name, + Trend_Log_Read_Property, + Trend_Log_Write_Property, + Trend_Log_Property_Lists, + TrendLogGetRRInfo, + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, #if defined(BACFILE) {OBJECT_FILE, - bacfile_init, - bacfile_count, - bacfile_index_to_instance, - bacfile_valid_instance, - bacfile_object_name, - bacfile_read_property, - bacfile_write_property, - BACfile_Property_Lists, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */}, + bacfile_init, + bacfile_count, + bacfile_index_to_instance, + bacfile_valid_instance, + bacfile_object_name, + bacfile_read_property, + bacfile_write_property, + BACfile_Property_Lists, + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ }, #endif {MAX_BACNET_OBJECT_TYPE, - NULL /* Init */, - NULL /* Count */, - NULL /* Index_To_Instance */, - NULL /* Valid_Instance */, - NULL /* Object_Name */, - NULL /* Read_Property */, - NULL /* Write_Property */, - NULL /* Property_Lists */, - NULL /* ReadRangeInfo */, - NULL /* Iterator */, - NULL /* Value_Lists */, - NULL /* COV */, - NULL /* COV Clear */, - NULL /* Intrinsic Reporting */} + NULL /* Init */ , + NULL /* Count */ , + NULL /* Index_To_Instance */ , + NULL /* Valid_Instance */ , + NULL /* Object_Name */ , + NULL /* Read_Property */ , + NULL /* Write_Property */ , + NULL /* Property_Lists */ , + NULL /* ReadRangeInfo */ , + NULL /* Iterator */ , + NULL /* Value_Lists */ , + NULL /* COV */ , + NULL /* COV Clear */ , + NULL /* Intrinsic Reporting */ } }; /** Glue function to let the Device object, when called by a handler, @@ -1419,8 +1419,8 @@ bool Device_Write_Property_Local( &wp_data->error_class, &wp_data->error_code); if (status) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { /* FIXME: we could send an I-Am broadcast to let the world know */ } else { status = false; @@ -1453,8 +1453,8 @@ bool Device_Write_Property_Local( &wp_data->error_class, &wp_data->error_code); if (status) { /* FIXME: bounds check? */ - Device_Set_Vendor_Identifier((uint16_t) value. - type.Unsigned_Int); + Device_Set_Vendor_Identifier((uint16_t) value.type. + Unsigned_Int); } break; case PROP_SYSTEM_STATUS: @@ -1500,8 +1500,8 @@ bool Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_LOC_LEN, true, &wp_data->error_class, &wp_data->error_code); if (status) { - Device_Set_Location(characterstring_value(&value. - type.Character_String), + Device_Set_Location(characterstring_value(&value.type. + Character_String), characterstring_length(&value.type.Character_String)); } break; @@ -1511,8 +1511,8 @@ bool Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_DESC_LEN, true, &wp_data->error_class, &wp_data->error_code); if (status) { - Device_Set_Description(characterstring_value(&value. - type.Character_String), + Device_Set_Description(characterstring_value(&value.type. + Character_String), characterstring_length(&value.type.Character_String)); } break; @@ -1521,8 +1521,8 @@ bool Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_MOD_LEN, true, &wp_data->error_class, &wp_data->error_code); if (status) { - Device_Set_Model_Name(characterstring_value(&value. - type.Character_String), + Device_Set_Model_Name(characterstring_value(&value.type. + Character_String), characterstring_length(&value.type.Character_String)); } break; @@ -1534,8 +1534,8 @@ bool Device_Write_Property_Local( &wp_data->error_class, &wp_data->error_code); if (status) { if (value.type.Unsigned_Int <= 255) { - dlmstp_set_max_info_frames((uint8_t) value. - type.Unsigned_Int); + dlmstp_set_max_info_frames((uint8_t) value.type. + Unsigned_Int); } else { status = false; wp_data->error_class = ERROR_CLASS_PROPERTY; @@ -1639,8 +1639,8 @@ bool Device_Encode_Value_List( } bool Device_COV( - BACNET_OBJECT_TYPE object_type, - uint32_t object_instance) + BACNET_OBJECT_TYPE object_type, + uint32_t object_instance) { bool status = false; /* Ever the pessamist! */ struct object_functions *pObject = NULL; @@ -1650,8 +1650,7 @@ bool Device_COV( if (pObject->Object_Valid_Instance && pObject->Object_Valid_Instance(object_instance)) { if (pObject->Object_COV) { - status = pObject->Object_COV( - object_instance); + status = pObject->Object_COV(object_instance); } } } @@ -1660,8 +1659,8 @@ bool Device_COV( } void Device_COV_Clear( - BACNET_OBJECT_TYPE object_type, - uint32_t object_instance) + BACNET_OBJECT_TYPE object_type, + uint32_t object_instance) { struct object_functions *pObject = NULL; diff --git a/bacnet-stack/demo/object/device.h b/bacnet-stack/demo/object/device.h index 3cca9002..85c222c8 100644 --- a/bacnet-stack/demo/object/device.h +++ b/bacnet-stack/demo/object/device.h @@ -126,7 +126,7 @@ typedef bool( * @ingroup ObjHelpers * @param [in] The object instance number to be looked up. */ -typedef void( +typedef void ( *object_cov_clear_function) ( uint32_t object_instance); @@ -282,7 +282,7 @@ extern "C" { BACNET_CHARACTER_STRING * object_name); /* Copy a child object name, given its ID. */ bool Device_Object_Name_Copy( - BACNET_OBJECT_TYPE object_type, + BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_CHARACTER_STRING * object_name); @@ -378,7 +378,7 @@ extern "C" { uint16_t Add_Routed_Device( uint32_t Object_Instance, - BACNET_CHARACTER_STRING *Object_Name, + BACNET_CHARACTER_STRING * Object_Name, const char *Description); DEVICE_OBJECT_DATA *Get_Routed_Device_Object( int idx); @@ -421,17 +421,16 @@ extern "C" { void Routed_Device_Inc_Database_Revision( void); int Routed_Device_Service_Approval( - BACNET_CONFIRMED_SERVICE service, - int service_argument, - uint8_t *apdu_buff, - uint8_t invoke_id ); + BACNET_CONFIRMED_SERVICE service, + int service_argument, + uint8_t * apdu_buff, + uint8_t invoke_id); #ifdef __cplusplus } #endif /* __cplusplus */ - /** @defgroup ObjFrmwk Object Framework * The modules in this section describe the BACnet-stack's framework for * 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, * specifically the handlers, which are mediated through function calls to * the Device object. - */ - -/** @defgroup ObjHelpers Object Helper Functions + *//** @defgroup ObjHelpers Object Helper Functions * @ingroup ObjFrmwk * This section describes the function templates for the helper functions that * provide common object support. - */ - -/** @defgroup ObjIntf Handler-to-Object Interface Functions + *//** @defgroup ObjIntf Handler-to-Object Interface Functions * @ingroup ObjFrmwk * This section describes the fairly limited set of functions that link the * BAC-stack handlers to the BACnet Object instances. All of these calls are diff --git a/bacnet-stack/demo/object/gw_device.c b/bacnet-stack/demo/object/gw_device.c index 979a5221..774dff3c 100644 --- a/bacnet-stack/demo/object/gw_device.c +++ b/bacnet-stack/demo/object/gw_device.c @@ -116,7 +116,7 @@ uint16_t iCurrent_Device_Idx = 0; */ uint16_t Add_Routed_Device( uint32_t Object_Instance, - BACNET_CHARACTER_STRING *sObject_Name, + BACNET_CHARACTER_STRING * sObject_Name, const char *sDescription) { int i = Num_Managed_Devices; @@ -127,8 +127,8 @@ uint16_t Add_Routed_Device( pDev->bacObj.mObject_Type = OBJECT_DEVICE; pDev->bacObj.Object_Instance_Number = Object_Instance; if (sObject_Name != NULL) - Routed_Device_Set_Object_Name(sObject_Name->encoding, - sObject_Name->value, sObject_Name->length); + Routed_Device_Set_Object_Name(sObject_Name->encoding, + sObject_Name->value, sObject_Name->length); else Routed_Device_Set_Object_Name(CHARACTER_UTF8, "No Name", strlen("No Name")); @@ -402,12 +402,13 @@ bool Routed_Device_Valid_Object_Instance_Number( } bool Routed_Device_Name( - uint32_t object_instance, - BACNET_CHARACTER_STRING * object_name) + uint32_t object_instance, + BACNET_CHARACTER_STRING * object_name) { DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; 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; @@ -485,8 +486,8 @@ bool Routed_Device_Write_Property_Local( &wp_data->error_class, &wp_data->error_code); if (status) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Routed_Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Routed_Device_Set_Object_Instance_Number(value. + type.Object_Id.instance))) { /* FIXME: we could send an I-Am broadcast to let the world know */ } else { status = false; @@ -500,8 +501,8 @@ bool Routed_Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_NAME_LEN, false, &wp_data->error_class, &wp_data->error_code); if (status) { - Routed_Device_Set_Object_Name(characterstring_encoding(&value. - type.Character_String), + Routed_Device_Set_Object_Name(characterstring_encoding + (&value.type.Character_String), characterstring_value(&value.type.Character_String), characterstring_length(&value.type.Character_String)); } @@ -611,32 +612,33 @@ void Routed_Device_Inc_Database_Revision( * else 0 if service is approved for the current device. */ int Routed_Device_Service_Approval( - BACNET_CONFIRMED_SERVICE service, - int service_argument, - uint8_t *apdu_buff, - uint8_t invoke_id ) + BACNET_CONFIRMED_SERVICE service, + int service_argument, + uint8_t * apdu_buff, + uint8_t invoke_id) { int len = 0; - switch(service) - { + switch (service) { case SERVICE_CONFIRMED_REINITIALIZE_DEVICE: /* If not the gateway device, we don't support RD */ - if ( iCurrent_Device_Idx > 0 ) { + if (iCurrent_Device_Idx > 0) { if (apdu_buff != NULL) - len = reject_encode_apdu(apdu_buff, - invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE); + len = + reject_encode_apdu(apdu_buff, invoke_id, + REJECT_REASON_UNRECOGNIZED_SERVICE); else - len = 1; /* Non-zero return */ + len = 1; /* Non-zero return */ } break; case SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL: /* If not the gateway device, we don't support DCC */ - if ( iCurrent_Device_Idx > 0 ) { + if (iCurrent_Device_Idx > 0) { if (apdu_buff != NULL) - len = reject_encode_apdu(apdu_buff, - invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE); + len = + reject_encode_apdu(apdu_buff, invoke_id, + REJECT_REASON_UNRECOGNIZED_SERVICE); else - len = 1; /* Non-zero return */ + len = 1; /* Non-zero return */ } break; default: diff --git a/bacnet-stack/demo/object/lc.h b/bacnet-stack/demo/object/lc.h index 02aec0a8..c1d199b4 100644 --- a/bacnet-stack/demo/object/lc.h +++ b/bacnet-stack/demo/object/lc.h @@ -76,5 +76,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/lo.c b/bacnet-stack/demo/object/lo.c index 697962a3..0b98692b 100644 --- a/bacnet-stack/demo/object/lo.c +++ b/bacnet-stack/demo/object/lo.c @@ -469,8 +469,8 @@ int Lighting_Output_Read_Property( object_index = Lighting_Output_Instance_To_Index(rpdata->object_instance); if (rpdata->array_index <= BACNET_MAX_PRIORITY) { - if (Lighting_Output_Level[object_index][rpdata->array_index - - 1] == LIGHTING_LEVEL_NULL) + if (Lighting_Output_Level[object_index][rpdata-> + array_index - 1] == LIGHTING_LEVEL_NULL) apdu_len = encode_application_null(&apdu[0]); else { real_value = Lighting_Output_Level[object_index] @@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property( if (status) { level = LIGHTING_LEVEL_NULL; object_index = - Lighting_Output_Instance_To_Index - (wp_data->object_instance); + Lighting_Output_Instance_To_Index(wp_data-> + object_instance); status = - Lighting_Output_Present_Value_Relinquish - (wp_data->object_instance, wp_data->priority); + Lighting_Output_Present_Value_Relinquish(wp_data-> + object_instance, wp_data->priority); if (wp_data->priority == 6) { /* Command priority 6 is reserved for use by Minimum On/Off algorithm and may not be used for other purposes in any @@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { object_index = - Lighting_Output_Instance_To_Index - (wp_data->object_instance); + Lighting_Output_Instance_To_Index(wp_data-> + object_instance); Lighting_Output_Out_Of_Service[object_index] = value.type.Boolean; } diff --git a/bacnet-stack/demo/object/lsp.c b/bacnet-stack/demo/object/lsp.c index 3f5c657d..8a956e3e 100644 --- a/bacnet-stack/demo/object/lsp.c +++ b/bacnet-stack/demo/object/lsp.c @@ -332,8 +332,8 @@ bool Life_Safety_Point_Write_Property( if (status) { if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) { object_index = - Life_Safety_Point_Instance_To_Index - (wp_data->object_instance); + Life_Safety_Point_Instance_To_Index(wp_data-> + object_instance); Life_Safety_Point_Mode[object_index] = value.type.Enumerated; } else { @@ -349,8 +349,8 @@ bool Life_Safety_Point_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { object_index = - Life_Safety_Point_Instance_To_Index - (wp_data->object_instance); + Life_Safety_Point_Instance_To_Index(wp_data-> + object_instance); Life_Safety_Point_Out_Of_Service[object_index] = value.type.Boolean; } diff --git a/bacnet-stack/demo/object/lsp.h b/bacnet-stack/demo/object/lsp.h index 0db654f7..ff7a0953 100644 --- a/bacnet-stack/demo/object/lsp.h +++ b/bacnet-stack/demo/object/lsp.h @@ -69,5 +69,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/ms-input.c b/bacnet-stack/demo/object/ms-input.c index 6c8a55ec..077e95b6 100644 --- a/bacnet-stack/demo/object/ms-input.c +++ b/bacnet-stack/demo/object/ms-input.c @@ -436,8 +436,8 @@ int Multistate_Input_Read_Property( /* if no index was specified, then try to encode the entire list */ /* into one packet. */ object_index = - Multistate_Input_Instance_To_Index - (rpdata->object_instance); + Multistate_Input_Instance_To_Index(rpdata-> + object_instance); for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) { characterstring_init_ansi(&char_string, Multistate_Input_State_Text(rpdata->object_instance, @@ -458,8 +458,8 @@ int Multistate_Input_Read_Property( } } else { object_index = - Multistate_Input_Instance_To_Index - (rpdata->object_instance); + Multistate_Input_Instance_To_Index(rpdata-> + object_instance); if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) { characterstring_init_ansi(&char_string, Multistate_Input_State_Text(rpdata->object_instance, @@ -517,8 +517,8 @@ bool Multistate_Input_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { status = - Multistate_Input_Present_Value_Set - (wp_data->object_instance, value.type.Unsigned_Int); + Multistate_Input_Present_Value_Set(wp_data-> + object_instance, value.type.Unsigned_Int); if (!status) { wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; diff --git a/bacnet-stack/demo/object/ms-input.h b/bacnet-stack/demo/object/ms-input.h index 85c7aeeb..5dadb2e2 100644 --- a/bacnet-stack/demo/object/ms-input.h +++ b/bacnet-stack/demo/object/ms-input.h @@ -103,5 +103,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/mso.c b/bacnet-stack/demo/object/mso.c index 979f7a05..84897dd2 100644 --- a/bacnet-stack/demo/object/mso.c +++ b/bacnet-stack/demo/object/mso.c @@ -268,8 +268,8 @@ int Multistate_Output_Read_Property( /* into one packet. */ else if (rpdata->array_index == BACNET_ARRAY_ALL) { object_index = - Multistate_Output_Instance_To_Index - (rpdata->object_instance); + Multistate_Output_Instance_To_Index(rpdata-> + object_instance); for (i = 0; i < BACNET_MAX_PRIORITY; i++) { /* FIXME: check if we have room before adding it to APDU */ if (Multistate_Output_Level[object_index][i] == @@ -294,8 +294,8 @@ int Multistate_Output_Read_Property( } } else { object_index = - Multistate_Output_Instance_To_Index - (rpdata->object_instance); + Multistate_Output_Instance_To_Index(rpdata-> + object_instance); if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (Multistate_Output_Level[object_index] [rpdata->array_index - 1] == MULTISTATE_NULL) @@ -377,8 +377,8 @@ bool Multistate_Output_Write_Property( (value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) { level = value.type.Unsigned_Int; object_index = - Multistate_Output_Instance_To_Index - (wp_data->object_instance); + Multistate_Output_Instance_To_Index(wp_data-> + object_instance); priority--; Multistate_Output_Level[object_index][priority] = (uint8_t) level; @@ -405,8 +405,8 @@ bool Multistate_Output_Write_Property( if (status) { level = MULTISTATE_NULL; object_index = - Multistate_Output_Instance_To_Index - (wp_data->object_instance); + Multistate_Output_Instance_To_Index(wp_data-> + object_instance); priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; @@ -432,8 +432,8 @@ bool Multistate_Output_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { object_index = - Multistate_Output_Instance_To_Index - (wp_data->object_instance); + Multistate_Output_Instance_To_Index(wp_data-> + object_instance); Multistate_Output_Out_Of_Service[object_index] = value.type.Boolean; } diff --git a/bacnet-stack/demo/object/mso.h b/bacnet-stack/demo/object/mso.h index fe9a642b..28c441dd 100644 --- a/bacnet-stack/demo/object/mso.h +++ b/bacnet-stack/demo/object/mso.h @@ -71,5 +71,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/msv.c b/bacnet-stack/demo/object/msv.c index c4a359e2..d050895f 100644 --- a/bacnet-stack/demo/object/msv.c +++ b/bacnet-stack/demo/object/msv.c @@ -438,8 +438,8 @@ int Multistate_Value_Read_Property( /* if no index was specified, then try to encode the entire list */ /* into one packet. */ object_index = - Multistate_Value_Instance_To_Index - (rpdata->object_instance); + Multistate_Value_Instance_To_Index(rpdata-> + object_instance); for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) { characterstring_init_ansi(&char_string, Multistate_Value_State_Text(rpdata->object_instance, @@ -460,8 +460,8 @@ int Multistate_Value_Read_Property( } } else { object_index = - Multistate_Value_Instance_To_Index - (rpdata->object_instance); + Multistate_Value_Instance_To_Index(rpdata-> + object_instance); if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) { characterstring_init_ansi(&char_string, Multistate_Value_State_Text(rpdata->object_instance, @@ -519,8 +519,8 @@ bool Multistate_Value_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { status = - Multistate_Value_Present_Value_Set - (wp_data->object_instance, value.type.Unsigned_Int); + Multistate_Value_Present_Value_Set(wp_data-> + object_instance, value.type.Unsigned_Int); if (!status) { wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; diff --git a/bacnet-stack/demo/object/msv.h b/bacnet-stack/demo/object/msv.h index 4f776e3b..70ebf0f7 100644 --- a/bacnet-stack/demo/object/msv.h +++ b/bacnet-stack/demo/object/msv.h @@ -103,5 +103,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/nc.c b/bacnet-stack/demo/object/nc.c index 220675e0..b2d167ee 100644 --- a/bacnet-stack/demo/object/nc.c +++ b/bacnet-stack/demo/object/nc.c @@ -95,9 +95,9 @@ void Notification_Class_Init( memset(&NC_Info[NotifyIdx], 0x00, sizeof(NOTIFICATION_CLASS_INFO)); /* set the basic parameters */ NC_Info[NotifyIdx].Ack_Required = 0; - NC_Info[NotifyIdx].Priority[TRANSITION_TO_OFFNORMAL] = 255; /* The lowest priority for Normal message. */ - NC_Info[NotifyIdx].Priority[TRANSITION_TO_FAULT] = 255; /* The lowest priority for Normal message. */ - NC_Info[NotifyIdx].Priority[TRANSITION_TO_NORMAL] = 255; /* The lowest priority for Normal message. */ + NC_Info[NotifyIdx].Priority[TRANSITION_TO_OFFNORMAL] = 255; /* The lowest priority for Normal message. */ + NC_Info[NotifyIdx].Priority[TRANSITION_TO_FAULT] = 255; /* The lowest priority for Normal message. */ + NC_Info[NotifyIdx].Priority[TRANSITION_TO_NORMAL] = 255; /* The lowest priority for Normal message. */ } return; @@ -189,8 +189,8 @@ int Notification_Class_Read_Property( apdu = rpdata->application_data; CurrentNotify = - &NC_Info[Notification_Class_Instance_To_Index(rpdata-> - object_instance)]; + &NC_Info[Notification_Class_Instance_To_Index + (rpdata->object_instance)]; switch (rpdata->object_property) { case PROP_OBJECT_IDENTIFIER: @@ -400,8 +400,8 @@ bool Notification_Class_Write_Property( CurrentNotify = - &NC_Info[Notification_Class_Instance_To_Index(wp_data-> - object_instance)]; + &NC_Info[Notification_Class_Instance_To_Index + (wp_data->object_instance)]; /* decode the some of the request */ @@ -455,9 +455,8 @@ bool Notification_Class_Write_Property( while (iOffset < wp_data->application_data_len) { /* Decode Valid Days */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], wp_data->application_data_len, - &value); + bacapp_decode_application_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value); if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) { @@ -480,9 +479,8 @@ bool Notification_Class_Write_Property( iOffset += len; /* Decode From Time */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], wp_data->application_data_len, - &value); + bacapp_decode_application_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value); if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) { /* Bad decode, wrong tag or following required parameter missing */ @@ -496,9 +494,8 @@ bool Notification_Class_Write_Property( iOffset += len; /* Decode To Time */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], wp_data->application_data_len, - &value); + bacapp_decode_application_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value); if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) { /* Bad decode, wrong tag or following required parameter missing */ @@ -517,9 +514,8 @@ bool Notification_Class_Write_Property( RECIPIENT_TYPE_DEVICE; /* Decode Network Number */ len = - bacapp_decode_context_data(&wp_data-> - application_data[iOffset], - wp_data->application_data_len, &value, + bacapp_decode_context_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value, PROP_RECIPIENT_LIST); if ((len == 0) || @@ -530,21 +526,21 @@ bool Notification_Class_Write_Property( return false; } /* store value */ - TmpNotify.Recipient_List[idx].Recipient._. - DeviceIdentifier = value.type.Object_Id.instance; + TmpNotify.Recipient_List[idx].Recipient. + _.DeviceIdentifier = value.type.Object_Id.instance; iOffset += len; } /* opening tag [1] - Recipient */ - else if (decode_is_opening_tag_number(&wp_data-> - application_data[iOffset], 1)) { + else if (decode_is_opening_tag_number + (&wp_data->application_data[iOffset], 1)) { iOffset++; TmpNotify.Recipient_List[idx].Recipient.RecipientType = RECIPIENT_TYPE_ADDRESS; /* Decode Network Number */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], + bacapp_decode_application_data + (&wp_data->application_data[iOffset], wp_data->application_data_len, &value); if ((len == 0) || @@ -561,8 +557,8 @@ bool Notification_Class_Write_Property( iOffset += len; /* Decode Address */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], + bacapp_decode_application_data + (&wp_data->application_data[iOffset], wp_data->application_data_len, &value); if ((len == 0) || @@ -573,16 +569,16 @@ bool Notification_Class_Write_Property( return false; } /* store value */ - if (TmpNotify.Recipient_List[idx].Recipient._.Address. - net == 0) { - memcpy(TmpNotify.Recipient_List[idx].Recipient._. - Address.mac, value.type.Octet_String.value, + if (TmpNotify.Recipient_List[idx].Recipient._. + Address.net == 0) { + memcpy(TmpNotify.Recipient_List[idx].Recipient. + _.Address.mac, value.type.Octet_String.value, value.type.Octet_String.length); - TmpNotify.Recipient_List[idx].Recipient._.Address. - mac_len = value.type.Octet_String.length; + TmpNotify.Recipient_List[idx].Recipient._. + Address.mac_len = value.type.Octet_String.length; } else { - memcpy(TmpNotify.Recipient_List[idx].Recipient._. - Address.adr, value.type.Octet_String.value, + memcpy(TmpNotify.Recipient_List[idx].Recipient. + _.Address.adr, value.type.Octet_String.value, value.type.Octet_String.length); TmpNotify.Recipient_List[idx].Recipient._.Address.len = value.type.Octet_String.length; @@ -590,8 +586,8 @@ bool Notification_Class_Write_Property( iOffset += len; /* closing tag [1] - Recipient */ - if (decode_is_closing_tag_number(&wp_data-> - application_data[iOffset], 1)) + if (decode_is_closing_tag_number(&wp_data->application_data + [iOffset], 1)) iOffset++; else { /* Bad decode, wrong tag or following required parameter missing */ @@ -608,9 +604,8 @@ bool Notification_Class_Write_Property( /* Process Identifier */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], wp_data->application_data_len, - &value); + bacapp_decode_application_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value); if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) { @@ -626,9 +621,8 @@ bool Notification_Class_Write_Property( iOffset += len; /* Issue Confirmed Notifications */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], wp_data->application_data_len, - &value); + bacapp_decode_application_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value); if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) { @@ -644,9 +638,8 @@ bool Notification_Class_Write_Property( iOffset += len; /* Transitions */ len = - bacapp_decode_application_data(&wp_data-> - application_data[iOffset], wp_data->application_data_len, - &value); + bacapp_decode_application_data(&wp_data->application_data + [iOffset], wp_data->application_data_len, &value); if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) { @@ -687,16 +680,16 @@ bool Notification_Class_Write_Property( CurrentNotify->Recipient_List[idx] = TmpNotify.Recipient_List[idx]; - if (CurrentNotify->Recipient_List[idx].Recipient. - RecipientType == RECIPIENT_TYPE_DEVICE) { + if (CurrentNotify->Recipient_List[idx]. + Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) { /* copy Device_ID */ DeviceID = - CurrentNotify->Recipient_List[idx].Recipient._. - DeviceIdentifier; + CurrentNotify->Recipient_List[idx].Recipient. + _.DeviceIdentifier; address_bind_request(DeviceID, &max_apdu, &src); - } else if (CurrentNotify->Recipient_List[idx].Recipient. - RecipientType == RECIPIENT_TYPE_ADDRESS) { + } else if (CurrentNotify->Recipient_List[idx]. + Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) { /* copy Address */ /* src = CurrentNotify->Recipient_List[idx].Recipient._.Address; */ /* address_bind_request(BACNET_MAX_INSTANCE, &max_apdu, &src); */ @@ -816,17 +809,19 @@ void Notification_Class_common_reporting_function( /* Priority and AckRequired */ switch (event_data->toState) { case EVENT_STATE_NORMAL: - event_data->priority = CurrentNotify->Priority[TRANSITION_TO_NORMAL]; + event_data->priority = + CurrentNotify->Priority[TRANSITION_TO_NORMAL]; event_data->ackRequired = - (CurrentNotify-> - Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? true : false; + (CurrentNotify->Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? + true : false; break; case EVENT_STATE_FAULT: - event_data->priority = CurrentNotify->Priority[TRANSITION_TO_FAULT]; + event_data->priority = + CurrentNotify->Priority[TRANSITION_TO_FAULT]; event_data->ackRequired = - (CurrentNotify-> - Ack_Required & TRANSITION_TO_FAULT_MASKED) ? true : false; + (CurrentNotify->Ack_Required & TRANSITION_TO_FAULT_MASKED) ? + true : false; break; case EVENT_STATE_OFFNORMAL: @@ -835,8 +830,8 @@ void Notification_Class_common_reporting_function( event_data->priority = CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL]; event_data->ackRequired = - (CurrentNotify-> - Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false; + (CurrentNotify->Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) + ? true : false; break; default: /* shouldn't happen */ @@ -911,13 +906,13 @@ void Notification_Class_find_recipient( RECIPIENT_TYPE_DEVICE) { /* Device ID */ DeviceID = - CurrentNotify->Recipient_List[idx].Recipient._. - DeviceIdentifier; + CurrentNotify->Recipient_List[idx].Recipient. + _.DeviceIdentifier; /* Send who_ is request only when address of device is unknown. */ if (!address_bind_request(DeviceID, &max_apdu, &src)) Send_WhoIs(DeviceID, DeviceID); - } else if (CurrentNotify->Recipient_List[idx].Recipient. - RecipientType == RECIPIENT_TYPE_ADDRESS) { + } else if (CurrentNotify->Recipient_List[idx]. + Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) { } } diff --git a/bacnet-stack/demo/object/nc.h b/bacnet-stack/demo/object/nc.h index ecd6e73f..243e644d 100644 --- a/bacnet-stack/demo/object/nc.h +++ b/bacnet-stack/demo/object/nc.h @@ -76,7 +76,7 @@ BACnetRecipient ::= CHOICE { /* Structure containing configuration for a Notification Class */ typedef struct Notification_Class_info { - uint8_t Priority[MAX_BACNET_EVENT_TRANSITION]; /* BACnetARRAY[3] of Unsigned */ + uint8_t Priority[MAX_BACNET_EVENT_TRANSITION]; /* BACnetARRAY[3] of Unsigned */ uint8_t Ack_Required; /* BACnetEventTransitionBits */ BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */ } NOTIFICATION_CLASS_INFO; @@ -138,5 +138,4 @@ BACnetRecipient ::= CHOICE { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif /* NC_H */ diff --git a/bacnet-stack/demo/object/trendlog.c b/bacnet-stack/demo/object/trendlog.c index 05e01f6f..cc7cefc2 100644 --- a/bacnet-stack/demo/object/trendlog.c +++ b/bacnet-stack/demo/object/trendlog.c @@ -736,9 +736,9 @@ bool Trend_Log_Write_Property( if (wp_data->application_data_len != 0) { iOffset += len; len = - bacapp_decode_context_data(&wp_data->application_data - [iOffset], wp_data->application_data_len, &value, - PROP_LOG_DEVICE_OBJECT_PROPERTY); + bacapp_decode_context_data(&wp_data-> + application_data[iOffset], wp_data->application_data_len, + &value, PROP_LOG_DEVICE_OBJECT_PROPERTY); if ((len == 0) || ((value.context_tag != 2) && (value.context_tag != 3))) { /* Bad decode or wrong tag */ @@ -755,8 +755,8 @@ bool Trend_Log_Write_Property( if (wp_data->application_data_len != 0) { iOffset += len; len = - bacapp_decode_context_data - (&wp_data->application_data[iOffset], + bacapp_decode_context_data(&wp_data-> + application_data[iOffset], wp_data->application_data_len, &value, PROP_LOG_DEVICE_OBJECT_PROPERTY); if ((len == 0) || (value.context_tag != 3)) { @@ -1098,8 +1098,8 @@ int rr_trend_log_encode( pRequest->ItemCount = 0; /* Start out with nothing */ /* Bail out now if nowt - should never happen for a Trend Log but ... */ - if (LogInfo[Trend_Log_Instance_To_Index(pRequest-> - object_instance)].ulRecordCount == 0) + if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)]. + ulRecordCount == 0) return (0); if ((pRequest->RequestType == RR_BY_POSITION) || diff --git a/bacnet-stack/demo/object/trendlog.h b/bacnet-stack/demo/object/trendlog.h index 1caef24e..b2d16659 100644 --- a/bacnet-stack/demo/object/trendlog.h +++ b/bacnet-stack/demo/object/trendlog.h @@ -197,5 +197,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/perl/perl_bindings.c b/bacnet-stack/demo/perl/perl_bindings.c index 5cd759f0..a74f3d63 100644 --- a/bacnet-stack/demo/perl/perl_bindings.c +++ b/bacnet-stack/demo/perl/perl_bindings.c @@ -27,18 +27,24 @@ static bool isAtomicReadFileHandlerRegistered = false; #define MAX_ERROR_STRING 128 #define NO_ERROR "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); Error_Detected = true; } -void BacnetGetError(SV *errorMsg) + +void BacnetGetError( + SV * errorMsg) { sv_setpv(errorMsg, Last_Error); strcpy(Last_Error, NO_ERROR); Error_Detected = false; } -static void __LogAnswer(const char *msg, unsigned append) + +static void __LogAnswer( + const char *msg, + unsigned append) { dSP; ENTER; @@ -63,10 +69,10 @@ static void MyAbortHandler( { (void) server; if (address_match(&Target_Address, src) && - (invoke_id == Request_Invoke_ID)) - { + (invoke_id == Request_Invoke_ID)) { 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); } } @@ -77,10 +83,10 @@ static void MyRejectHandler( uint8_t reject_reason) { if (address_match(&Target_Address, src) && - (invoke_id == Request_Invoke_ID)) - { + (invoke_id == Request_Invoke_ID)) { 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); } } @@ -92,10 +98,11 @@ static void My_Error_Handler( BACNET_ERROR_CODE error_code) { if (address_match(&Target_Address, src) && - (invoke_id == Request_Invoke_ID)) - { - 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)); + (invoke_id == Request_Invoke_ID)) { + 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)); LogError(msg); } } @@ -107,8 +114,9 @@ static void My_Error_Handler( /*****************************************/ // Decode the ReadProperty Ack and pass to perl /****************************************/ -#define MAX_ACK_STRING 512 -void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data) +#define MAX_ACK_STRING 512 +void rp_ack_extract_data( + BACNET_READ_PROPERTY_DATA * data) { char ackString[MAX_ACK_STRING] = ""; char *pAckString = &ackString[0]; @@ -120,8 +128,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data) bool first_value = true; bool print_brace = false; - if (data) - { + if (data) { application_data = data->application_data; application_data_len = data->application_data_len; /* 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 = bacapp_decode_application_data(application_data, (uint8_t) application_data_len, &value); - if (first_value && (len < application_data_len)) - { + if (first_value && (len < application_data_len)) { first_value = false; strncat(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.array_index = data->array_index; 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 < application_data_len) { application_data += len; @@ -157,12 +164,10 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data) break; } } - if (print_brace) - { + if (print_brace) { strncat(pAckString, "}", 1); pAckString += 1; } - // Now let's call a Perl function to display the data __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 /****************************************/ -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_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_instance = rpm_data->object_instance; while (value) { - object_value.object_property = listOfProperties->propertyIdentifier; - object_value.array_index = listOfProperties->propertyArrayIndex; + object_value.object_property = + listOfProperties->propertyIdentifier; + object_value.array_index = + listOfProperties->propertyArrayIndex; 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) { strncat(pAckString, ",", 1); pAckString++; @@ -213,10 +223,10 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data) } else { /* AccessError */ sprintf(ackString, "BACnet Error: %s: %s", - bactext_error_class_name((int) listOfProperties-> - error.error_class), - bactext_error_code_name((int) listOfProperties-> - error.error_code)); + bactext_error_class_name((int) listOfProperties->error. + error_class), + bactext_error_code_name((int) listOfProperties->error. + error_code)); LogError(ackString); } listOfProperties = listOfProperties->next; @@ -226,7 +236,7 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data) strncat(pAckString, "QQQ", 3); pAckString += 3; } - + // Now let's call a Perl function to display the data __LogAnswer(ackString, 1); } @@ -241,31 +251,30 @@ static void AtomicReadFileAckHandler( int len = 0; BACNET_ATOMIC_READ_FILE_DATA data; - if (address_match(&Target_Address, src) && (service_data->invoke_id == Request_Invoke_ID)) - { - len = arf_ack_decode_service_request(service_request, service_len, &data); - if (len > 0) - { + if (address_match(&Target_Address, src) && + (service_data->invoke_id == Request_Invoke_ID)) { + len = + arf_ack_decode_service_request(service_request, service_len, + &data); + if (len > 0) { /* 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]; uint8_t *pFileData; 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); pFileData = octetstring_value(&data.fileData); - for (i=0; iinvoke_id == Request_Invoke_ID)) { - len = rp_ack_decode_service_request(service_request, service_len, &data); - if (len > 0) - { + len = + rp_ack_decode_service_request(service_request, service_len, &data); + if (len > 0) { rp_ack_extract_data(&data); } } @@ -383,14 +392,14 @@ void My_Write_Property_SimpleAck_Handler( uint8_t invoke_id) { if (address_match(&Target_Address, src) && - (invoke_id == Request_Invoke_ID)) - { + (invoke_id == Request_Invoke_ID)) { __LogAnswer("WriteProperty Acknowledged!", 0); } } -static void Init_Service_Handlers() +static void Init_Service_Handlers( + ) { Device_Init(NULL); @@ -402,89 +411,79 @@ static void Init_Service_Handlers() /* set the handler for all the services we don't implement 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! */ - 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 */ apdu_set_abort_handler(MyAbortHandler); apdu_set_reject_handler(MyRejectHandler); } -typedef enum -{ +typedef enum { waitAnswer, waitBind, } 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 time_t last_seconds = time(NULL); time_t timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); time_t elapsed_seconds = 0; uint16_t pdu_len = 0; - 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 }; - while (true) - { + while (true) { time_t current_seconds = time(NULL); // If error was detected then bail out - if (Error_Detected) - { + if (Error_Detected) { LogError("Some other error occurred"); break; } - if (elapsed_seconds > timeout_seconds) - { + if (elapsed_seconds > timeout_seconds) { LogError("APDU Timeout"); break; } /* Process PDU if one comes in */ 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); } /* at least one second has passed */ - if (current_seconds != last_seconds) - { + if (current_seconds != last_seconds) { tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000)); } - if (action == waitAnswer) - { + if (action == waitAnswer) { // Response was received. Exit. - if (tsm_invoke_id_free(Request_Invoke_ID)) - { + if (tsm_invoke_id_free(Request_Invoke_ID)) { break; - } - else if (tsm_invoke_id_failed(Request_Invoke_ID)) - { + } else if (tsm_invoke_id_failed(Request_Invoke_ID)) { LogError("TSM Timeout!"); tsm_free_invoke_id(Request_Invoke_ID); break; } - } - else if (action == waitBind) - { - if (address_bind_request(Target_Device_Object_Instance, &Target_Max_APDU, &Target_Address)) - { + } else if (action == waitBind) { + if (address_bind_request(Target_Device_Object_Instance, + &Target_Max_APDU, &Target_Address)) { break; } - } - else - { + } else { LogError("Invalid waitAction requested"); break; } - + // Keep track of time elapsed_seconds += (current_seconds - last_seconds); last_seconds = current_seconds; @@ -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 /****************************************************/ -void BacnetPrepareComm() +void BacnetPrepareComm( + ) { /* setup my info */ 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 // non-zero and log the error details /****************************************************/ -int BacnetBindToDevice(int deviceInstanceNumber) +int BacnetBindToDevice( + int deviceInstanceNumber) { int isFailure = 0; @@ -520,39 +521,46 @@ int BacnetBindToDevice(int deviceInstanceNumber) Target_Device_Object_Instance = deviceInstanceNumber; /* try to bind with the device */ - if (! address_bind_request(deviceInstanceNumber, &Target_Max_APDU, &Target_Address)) - { - Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); + if (!address_bind_request(deviceInstanceNumber, &Target_Max_APDU, + &Target_Address)) { + Send_WhoIs(Target_Device_Object_Instance, + Target_Device_Object_Instance); // Wait for timeout, failure, or success Wait_For_Answer_Or_Timeout(100, waitBind); } - // Clean up after ourselves isFailure = Error_Detected; Error_Detected = false; return isFailure; -} +} /****************************************************/ // This is the interface to ReadProperty /****************************************************/ -int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInstanceNumber, int objectProperty, int objectIndex) +int BacnetReadProperty( + int deviceInstanceNumber, + int objectType, + int objectInstanceNumber, + int objectProperty, + int objectIndex) { - if (!isReadPropertyHandlerRegistered) - { + if (!isReadPropertyHandlerRegistered) { /* 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 */ - 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 isReadPropertyHandlerRegistered = true; } - // 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); int isFailure = Error_Detected; @@ -563,144 +571,118 @@ int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInsta /************************************************/ // This is the interface to ReadPropertyMultiple /************************************************/ -int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... ) +int BacnetReadPropertyMultiple( + int deviceInstanceNumber, + ...) { // Get the variable argument list from the stack Inline_Stack_Vars; 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_PROPERTY_REFERENCE *rpm_property; uint8_t buffer[MAX_PDU] = { 0 }; - while (rpmIndex < Inline_Stack_Items) - { + while (rpmIndex < Inline_Stack_Items) { SV *pSV = Inline_Stack_Item(rpmIndex++); - + // 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"); break; } - // Make sure we can access the memory - if (rpm_object) - { + if (rpm_object) { rpm_object->listOfProperties = NULL; - } - else - { + } else { LogError("Memory Allocation Issue"); break; } - - AV *pAV = (AV *)SvRV(pSV); + + AV *pAV = (AV *) SvRV(pSV); SV **ppSV; - + // The 0th argument is the object type ppSV = av_fetch(pAV, 0, 0); - if (ppSV) - { + if (ppSV) { rpm_object->object_type = SvIV(*ppSV); - } - else - { + } else { LogError("Problem parsing the Array of arguments"); break; } // The 1st argument is the object instance ppSV = av_fetch(pAV, 1, 0); - if (ppSV) - { + if (ppSV) { rpm_object->object_instance = SvIV(*ppSV); - } - else - { + } else { LogError("Problem parsing the Array of arguments"); break; } // The 2nd argument is the property type ppSV = av_fetch(pAV, 2, 0); - if (ppSV) - { + if (ppSV) { rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE)); rpm_object->listOfProperties = rpm_property; - if (rpm_property) - { + if (rpm_property) { rpm_property->propertyIdentifier = SvIV(*ppSV); - } - else - { + } else { LogError("Memory allocation error"); break; } - } - else - { + } else { LogError("Problem parsing the Array of arguments"); break; } // The 3rd argument is the property index ppSV = av_fetch(pAV, 3, 0); - if (ppSV) - { + if (ppSV) { rpm_property->propertyArrayIndex = SvIV(*ppSV); - } - else - { + } else { LogError("Problem parsing the Array of arguments"); break; } // 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 = rpm_object->next; - } - else - { + } else { rpm_object->next = NULL; } } - if (!isReadPropertyMultipleHandlerRegistered) - { + if (!isReadPropertyMultipleHandlerRegistered) { /* handle the data coming back from confirmed requests */ 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 */ - 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 isReadPropertyMultipleHandlerRegistered = true; } - // Send the message out - if (!Error_Detected) - { - Request_Invoke_ID = Send_Read_Property_Multiple_Request( - &buffer[0], sizeof(buffer), + if (!Error_Detected) { + Request_Invoke_ID = + Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer), deviceInstanceNumber, Read_Access_Data); Wait_For_Answer_Or_Timeout(100, waitAnswer); } - // Clean up allocated memory BACNET_READ_ACCESS_DATA *old_rpm_object; BACNET_PROPERTY_REFERENCE *old_rpm_property; rpm_object = Read_Access_Data; old_rpm_object = rpm_object; - while (rpm_object) - { + while (rpm_object) { rpm_property = rpm_object->listOfProperties; - while (rpm_property) - { + while (rpm_property) { old_rpm_property = rpm_property; rpm_property = rpm_property->next; free(old_rpm_property); @@ -719,80 +701,76 @@ int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... ) /****************************************************/ // This is the interface to WriteProperty /****************************************************/ -int BacnetWriteProperty(int deviceInstanceNumber, - int objectType, - int objectInstanceNumber, - int objectProperty, - int objectPriority, - int objectIndex, - const char *tag, - const char *value) +int BacnetWriteProperty( + int deviceInstanceNumber, + int objectType, + int objectInstanceNumber, + int objectProperty, + int objectPriority, + int objectIndex, + const char *tag, + const char *value) { char msg[MAX_ERROR_STRING]; int isFailure = 1; - if (!isWritePropertyHandlerRegistered) - { + if (!isWritePropertyHandlerRegistered) { /* 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 */ - 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 isWritePropertyHandlerRegistered = true; } - if (objectIndex == -1) - { + if (objectIndex == -1) { objectIndex = BACNET_ARRAY_ALL; } - // Loop for eary exit; - do - { + do { // Handle the tag/value pair uint8_t context_tag = 0; BACNET_APPLICATION_TAG property_tag; BACNET_APPLICATION_DATA_VALUE propertyValue; - if (toupper(tag[0]) == 'C') - { + if (toupper(tag[0]) == 'C') { context_tag = strtol(&tag[1], NULL, 0); propertyValue.context_tag = context_tag; propertyValue.context_specific = true; - } - else - { + } else { propertyValue.context_specific = false; } property_tag = strtol(tag, NULL, 0); - if (property_tag >= MAX_BACNET_APPLICATION_TAG) - { - sprintf(msg, "Error: tag=%u - it must be less than %u", property_tag, MAX_BACNET_APPLICATION_TAG); + if (property_tag >= MAX_BACNET_APPLICATION_TAG) { + sprintf(msg, "Error: tag=%u - it must be less than %u", + property_tag, MAX_BACNET_APPLICATION_TAG); LogError(msg); 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"); LogError(msg); break; } propertyValue.next = NULL; - + // Send out the message - Request_Invoke_ID = Send_Write_Property_Request( - deviceInstanceNumber, - objectType, objectInstanceNumber, - objectProperty, &propertyValue, objectPriority, objectIndex); + Request_Invoke_ID = + Send_Write_Property_Request(deviceInstanceNumber, objectType, + objectInstanceNumber, objectProperty, &propertyValue, + objectPriority, objectIndex); Wait_For_Answer_Or_Timeout(100, waitAnswer); // If we get here, then there were no explicit failures. However, there // could have been implicit failures. Let's look at those also. isFailure = Error_Detected; - } while(false); + } while (false); // Clean up after ourselves. Error_Detected = false; @@ -800,42 +778,36 @@ int BacnetWriteProperty(int deviceInstanceNumber, } -int BacnetAtomicWriteFile (int deviceInstanceNumber, - int fileInstanceNumber, - int blockStartAddr, - int blockNumBytes, - char *nibbleBuffer) +int BacnetAtomicWriteFile( + int deviceInstanceNumber, + int fileInstanceNumber, + int blockStartAddr, + int blockNumBytes, + char *nibbleBuffer) { BACNET_OCTET_STRING fileData; int i, nibble; uint8_t byteValue; unsigned char nibbleValue; - if (!isAtomicWriteFileHandlerRegistered) - { + if (!isAtomicWriteFileHandlerRegistered) { /* 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 isAtomicWriteFileHandlerRegistered = true; } - for (i=0; i= '0') && (nibbleValue <= '9') ) - { - byteValue += (nibbleValue-'0') << (4*(1-nibble)); - } - else if ( (nibbleValue >= 'A') && (nibbleValue <= 'F') ) - { - byteValue += (nibbleValue-'A'+10) << (4*(1-nibble)); - } - else - { + for (nibble = 0; nibble < 2; nibble++) { + nibbleValue = toupper(nibbleBuffer[i * 2 + nibble]); + if ((nibbleValue >= '0') && (nibbleValue <= '9')) { + byteValue += (nibbleValue - '0') << (4 * (1 - nibble)); + } else if ((nibbleValue >= 'A') && (nibbleValue <= 'F')) { + byteValue += (nibbleValue - 'A' + 10) << (4 * (1 - nibble)); + } else { LogError("Bad data in buffer."); } } @@ -844,13 +816,10 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber, octetstring_truncate(&fileData, blockNumBytes); // Send out the message and wait for answer - if (!Error_Detected) - { - Request_Invoke_ID = Send_Atomic_Write_File_Stream( - deviceInstanceNumber, - fileInstanceNumber, - blockStartAddr, - &fileData); + if (!Error_Detected) { + Request_Invoke_ID = + Send_Atomic_Write_File_Stream(deviceInstanceNumber, + fileInstanceNumber, blockStartAddr, &fileData); Wait_For_Answer_Or_Timeout(100, waitAnswer); } @@ -859,7 +828,8 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber, return isFailure; } -int BacnetGetMaxApdu() +int BacnetGetMaxApdu( + ) { unsigned requestedOctetCount = 0; uint16_t my_max_apdu = 0; @@ -887,16 +857,16 @@ int BacnetGetMaxApdu() return requestedOctetCount; } -int BacnetTimeSync(int deviceInstanceNumber, - int year, - int month, - int day, - int hour, - int minute, - int second, - int isUTC, - int UTCOffset) - +int BacnetTimeSync( + int deviceInstanceNumber, + int year, + int month, + int day, + int hour, + int minute, + int second, + int isUTC, + int UTCOffset) { BACNET_DATE bdate; BACNET_TIME btime; @@ -908,24 +878,24 @@ int BacnetTimeSync(int deviceInstanceNumber, my_time.tm_min = minute; my_time.tm_hour = hour; my_time.tm_mday = day; - my_time.tm_mon = month-1; - my_time.tm_year = year-1900; - my_time.tm_wday = 0; // does not matter - my_time.tm_yday = 0; // does not matter - my_time.tm_isdst = 0; // does not matter - + my_time.tm_mon = month - 1; + my_time.tm_year = year - 1900; + my_time.tm_wday = 0; // does not matter + my_time.tm_yday = 0; // does not matter + my_time.tm_isdst = 0; // does not matter + aTime = mktime(&my_time); newTime = localtime(&aTime); - bdate.year = newTime->tm_year; - bdate.month = newTime->tm_mon+1; - bdate.day = newTime->tm_mday; - bdate.wday = newTime->tm_wday ? newTime->tm_wday : 7; - btime.hour = newTime->tm_hour; - btime.min = newTime->tm_min; - btime.sec = newTime->tm_sec; + bdate.year = newTime->tm_year; + bdate.month = newTime->tm_mon + 1; + bdate.day = newTime->tm_mday; + bdate.wday = newTime->tm_wday ? newTime->tm_wday : 7; + btime.hour = newTime->tm_hour; + btime.min = newTime->tm_min; + btime.sec = newTime->tm_sec; btime.hundredths = 0; - + int len = 0; int pdu_len = 0; int bytes_sent = 0; @@ -934,10 +904,8 @@ int BacnetTimeSync(int deviceInstanceNumber, uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 }; // Loop for eary exit - do - { - if (!dcc_communication_enabled()) - { + do { + if (!dcc_communication_enabled()) { LogError("DCC communicaiton is not enabled"); break; } @@ -945,25 +913,32 @@ int BacnetTimeSync(int deviceInstanceNumber, /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); 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 */ - 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; /* send it out the datalink */ - bytes_sent = datalink_send_pdu(&Target_Address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); - if (bytes_sent <= 0) - { + bytes_sent = + datalink_send_pdu(&Target_Address, &npdu_data, + &Handler_Transmit_Buffer[0], pdu_len); + if (bytes_sent <= 0) { 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); break; } Wait_For_Answer_Or_Timeout(100, waitAnswer); } while (false); - + int isFailure = Error_Detected; Error_Detected = 0; return isFailure; @@ -972,26 +947,31 @@ int BacnetTimeSync(int deviceInstanceNumber, /****************************************************/ // This is the interface to AtomicReadFile /****************************************************/ -int BacnetAtomicReadFile(int deviceInstanceNumber, int fileInstanceNumber, int startOffset, int numBytes) +int BacnetAtomicReadFile( + int deviceInstanceNumber, + int fileInstanceNumber, + int startOffset, + int numBytes) { - if (!isAtomicReadFileHandlerRegistered) - { + if (!isAtomicReadFileHandlerRegistered) { /* 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 */ - 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 isAtomicReadFileHandlerRegistered = true; } - // 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); int isFailure = Error_Detected; Error_Detected = 0; return isFailure; } - diff --git a/bacnet-stack/demo/readpropm/main.c b/bacnet-stack/demo/readpropm/main.c index 57a22b3a..9fb97329 100644 --- a/bacnet-stack/demo/readpropm/main.c +++ b/bacnet-stack/demo/readpropm/main.c @@ -298,8 +298,7 @@ int main( "%s 123 1 99 85,87[0],87\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" - "use the following command:\r\n" - "%s 123 0 77 85 0 78 85\r\n" + "use the following command:\r\n" "%s 123 0 77 85 0 78 85\r\n" "If you want read the ALL property in\r\n" "Device object 123, you would use the following command:\r\n" "%s 123 8 123 8\r\n" @@ -308,8 +307,8 @@ int main( "%s 123 8 123 80\r\n" "If you want read the REQUIRED property in\r\n" "Device object 123, you would use the following command:\r\n" - "%s 123 8 123 105\r\n", - filename, filename, filename, filename, filename); + "%s 123 8 123 105\r\n", filename, filename, filename, filename, + filename); } return 0; } @@ -356,13 +355,14 @@ int main( property_token = strtok(argv[tag_value_arg], ","); /* add all the properties and optional index to our list */ while (rpm_property) { - scan_count = sscanf(property_token, "%u[%u]", - &property_id, + scan_count = + sscanf(property_token, "%u[%u]", &property_id, &property_array_index); if (scan_count > 0) { rpm_property->propertyIdentifier = 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, MAX_BACNET_PROPERTY_ID + 1); return 1; diff --git a/bacnet-stack/demo/scov/main.c b/bacnet-stack/demo/scov/main.c index 14a556c6..52098c41 100644 --- a/bacnet-stack/demo/scov/main.c +++ b/bacnet-stack/demo/scov/main.c @@ -29,7 +29,7 @@ #include #include #include /* for time */ -#include /* for toupper */ +#include /* for toupper */ #define PRINT_ENABLED 1 @@ -187,40 +187,30 @@ int main( if (print_usage_terse) { filename = filename_remove_path(argv[0]); printf("Usage: %s device-id object-type object-instance " - "process-id <[un]confirmed lifetime|cancel>\r\n", - filename); + "process-id <[un]confirmed lifetime|cancel>\r\n", filename); if (!print_usage_verbose) { return 0; } } if (print_usage_verbose) { - printf("\r\n" - "device-id:\r\n" - "The subscriber BACnet Device Object Instance number.\r\n" - "\r\n" + printf("\r\n" "device-id:\r\n" + "The subscriber BACnet Device Object Instance number.\r\n" "\r\n" "object-type:\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" "if you were monitoring Analog Output 2, the object-type\r\n" - "would be 1.\r\n" - "\r\n" - "object-instance:\r\n" - "The monitored object instance number.\r\n" - "\r\n" + "would be 1.\r\n" "\r\n" "object-instance:\r\n" + "The monitored object instance number.\r\n" "\r\n" "process-id:\r\n" - "Process Identifier for this COV subscription.\r\n" - "\r\n" + "Process Identifier for this COV subscription.\r\n" "\r\n" "confirmed:\r\n" "Optional flag to subscribe using Confirmed notifications.\r\n" - "Use the word \'confirmed\' or \'unconfirmed\'.\r\n" - "\r\n" + "Use the word \'confirmed\' or \'unconfirmed\'.\r\n" "\r\n" "lifetime:\r\n" - "Optional subscription lifetime is conveyed in seconds.\r\n" - "\r\n" + "Optional subscription lifetime is conveyed in seconds.\r\n" "\r\n" "cancel:\r\n" "Use the word \'cancel\' instead of confirm and lifetime.\r\n" - "This shall indicate a cancellation request.\r\n" - "\r\n" + "This shall indicate a cancellation request.\r\n" "\r\n" "Example:\r\n" "If you want subscribe to Device 123 Analog Input 9 object\r\n" "using confirmed COV notifications for 5 minutes,\r\n" @@ -230,8 +220,7 @@ int main( "notifications, send the following command:\r\n" "%s 123 0 9 1 unconfirmed 600\r\n" "To cancel the same COV subscription request,\r\n" - "send the following command:\r\n" - "%s 123 0 9 1 cancel\r\n", + "send the following command:\r\n" "%s 123 0 9 1 cancel\r\n", filename, filename, filename); return 0; } @@ -247,11 +236,11 @@ int main( cov_data = COV_Subscribe_Data; argi = 2; while (cov_data) { - cov_data->monitoredObjectIdentifier.type = - strtol(argv[argi], NULL, 0); + cov_data->monitoredObjectIdentifier.type = strtol(argv[argi], NULL, 0); if (cov_data->monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) { 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; } argi++; @@ -264,21 +253,19 @@ int main( return 1; } argi++; - cov_data->subscriberProcessIdentifier = - strtol(argv[argi], NULL, 0); + cov_data->subscriberProcessIdentifier = strtol(argv[argi], NULL, 0); argi++; - if (strcmp(argv[argi],"cancel") == 0) { + if (strcmp(argv[argi], "cancel") == 0) { cov_data->cancellationRequest = true; argi++; } else { cov_data->cancellationRequest = false; - if (strcmp(argv[argi],"confirmed") == 0) { + if (strcmp(argv[argi], "confirmed") == 0) { cov_data->issueConfirmedNotifications = true; - } else if (strcmp(argv[argi],"unconfirmed") == 0) { + } else if (strcmp(argv[argi], "unconfirmed") == 0) { cov_data->issueConfirmedNotifications = false; } else { - fprintf(stderr, "unknown option: %s\r\n", - argv[argi]); + fprintf(stderr, "unknown option: %s\r\n", argv[argi]); return 1; } argi++; @@ -342,8 +329,8 @@ int main( if (Request_Invoke_ID == 0) { Target_Device_Process_Identifier = cov_data->subscriberProcessIdentifier; - Request_Invoke_ID = Send_COV_Subscribe( - Target_Device_Object_Instance, + Request_Invoke_ID = + Send_COV_Subscribe(Target_Device_Object_Instance, cov_data); if (!cov_data->cancellationRequest && (timeout_seconds < cov_data->lifetime)) { @@ -351,7 +338,7 @@ int main( timeout_seconds = cov_data->lifetime; } printf("Sent SubscribeCOV request. Waiting %u seconds.\r\n", - (unsigned)(timeout_seconds - elapsed_seconds)); + (unsigned) (timeout_seconds - elapsed_seconds)); } else if (tsm_invoke_id_free(Request_Invoke_ID)) { if (cov_data->next) { cov_data = cov_data->next; diff --git a/bacnet-stack/demo/server/main.c b/bacnet-stack/demo/server/main.c index 2abc7720..2f0cdb66 100644 --- a/bacnet-stack/demo/server/main.c +++ b/bacnet-stack/demo/server/main.c @@ -128,7 +128,7 @@ static void Init_Service_Handlers( handler_get_event_information); apdu_set_confirmed_handler(SERVICE_CONFIRMED_GET_ALARM_SUMMARY, handler_get_alarm_summary); -#endif /* defined(INTRINSIC_REPORTING) */ +#endif /* defined(INTRINSIC_REPORTING) */ } /** Main function of server demo. diff --git a/bacnet-stack/demo/uptransfer/main.c b/bacnet-stack/demo/uptransfer/main.c index 6e4158ea..cadcd6e7 100644 --- a/bacnet-stack/demo/uptransfer/main.c +++ b/bacnet-stack/demo/uptransfer/main.c @@ -29,7 +29,7 @@ #include #include #include /* for time */ -#include /* for toupper */ +#include /* for toupper */ #define PRINT_ENABLED 1 @@ -164,7 +164,7 @@ int main( int args_remaining = 0, tag_value_arg = 0, i = 0; BACNET_APPLICATION_TAG property_tag; uint8_t context_tag = 0; - BACNET_PRIVATE_TRANSFER_DATA private_data = {0}; + BACNET_PRIVATE_TRANSFER_DATA private_data = { 0 }; int len = 0; bool sent_message = false; @@ -179,34 +179,26 @@ int main( "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" "Device Object 123, the device-instance would be 123.\r\n" - "\r\n" - "vendor_id:\r\n" + "\r\n" "vendor_id:\r\n" "the unique vendor identification code for the type of\r\n" - "vendor proprietary service to be performed.\r\n" - "\r\n" + "vendor proprietary service to be performed.\r\n" "\r\n" "service-number (Unsigned32):\r\n" - "the desired proprietary service to be performed.\r\n" - "\r\n" - "tag:\r\n" - "Tag is the integer value of the enumeration \r\n" + "the desired proprietary service to be performed.\r\n" "\r\n" + "tag:\r\n" "Tag is the integer value of the enumeration \r\n" "BACNET_APPLICATION_TAG in bacenum.h.\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" "use a tag of 4.\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" - "C2 4 creates a context 2 tagged REAL.\r\n" - "\r\n" - "value:\r\n" + "C2 4 creates a context 2 tagged REAL.\r\n" "\r\n" "value:\r\n" "The value is an ASCII representation of some type of data\r\n" "that you are transfering.\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" "you would use 100.0 as the value.\r\n" "If you were transferring an object identifier for Device 123,\r\n" - "you would use 8:123 as the value.\r\n" - "\r\n" - "Example:\r\n" + "you would use 8:123 as the value.\r\n" "\r\n" "Example:\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" "%s 99 260 23 4 1.1\r\n", filename); @@ -222,9 +214,9 @@ int main( Target_Device_Object_Instance, BACNET_MAX_INSTANCE); return 1; } - args_remaining = (argc - (6-2)); + args_remaining = (argc - (6 - 2)); for (i = 0; i < MAX_PROPERTY_VALUES; i++) { - tag_value_arg = (6-2) + (i * 2); + tag_value_arg = (6 - 2) + (i * 2); /* special case for context tagged values */ if (toupper(argv[tag_value_arg][0]) == 'C') { context_tag = strtol(&argv[tag_value_arg][1], NULL, 0); @@ -310,17 +302,17 @@ int main( } if (!sent_message) { if (found) { - len = bacapp_encode_data(&Service_Parameters[0], + len = + bacapp_encode_data(&Service_Parameters[0], &Target_Object_Property_Value[0]); private_data.serviceParameters = &Service_Parameters[0]; private_data.serviceParametersLen = len; private_data.vendorID = Target_Vendor_Identifier; private_data.serviceNumber = Target_Service_Number; - Send_UnconfirmedPrivateTransfer( - &Target_Address, + Send_UnconfirmedPrivateTransfer(&Target_Address, &private_data); printf("Sent PrivateTransfer. Waiting %u seconds.\r\n", - (unsigned)(timeout_seconds - elapsed_seconds)); + (unsigned) (timeout_seconds - elapsed_seconds)); sent_message = true; } else { if (elapsed_seconds > timeout_seconds) { diff --git a/bacnet-stack/demo/writefile/main.c b/bacnet-stack/demo/writefile/main.c index 533e15c5..c18044a6 100644 --- a/bacnet-stack/demo/writefile/main.c +++ b/bacnet-stack/demo/writefile/main.c @@ -311,4 +311,3 @@ int main( } return 0; } - diff --git a/bacnet-stack/include/bacapp.h b/bacnet-stack/include/bacapp.h index 9b73ae4f..351bbbd1 100644 --- a/bacnet-stack/include/bacapp.h +++ b/bacnet-stack/include/bacapp.h @@ -88,7 +88,7 @@ typedef struct BACnet_Access_Error { struct BACnet_Property_Reference; typedef struct BACnet_Property_Reference { BACNET_PROPERTY_ID propertyIdentifier; - uint32_t propertyArrayIndex; /* optional */ + uint32_t propertyArrayIndex; /* optional */ /* either value or error, but not both. Use NULL value to indicate error */ BACNET_APPLICATION_DATA_VALUE *value; @@ -195,10 +195,10 @@ extern "C" { #endif #ifdef BACAPP_SNPRINTF_ENABLED -int bacapp_snprintf_value( - char *str, - size_t str_len, - BACNET_OBJECT_PROPERTY_VALUE * object_value); + int bacapp_snprintf_value( + char *str, + size_t str_len, + BACNET_OBJECT_PROPERTY_VALUE * object_value); #endif #ifdef BACAPP_PRINT_ENABLED diff --git a/bacnet-stack/include/bacenum.h b/bacnet-stack/include/bacenum.h index dff13409..69df641c 100644 --- a/bacnet-stack/include/bacenum.h +++ b/bacnet-stack/include/bacenum.h @@ -379,12 +379,12 @@ typedef enum { PROP_COVU_PERIOD = 349, PROP_COVU_RECIPIENTS = 350, PROP_EVENT_MESSAGE_TEXTS = 351, - /* The special property identifiers all, optional, and required */ - /* are reserved for use in the ReadPropertyConditional and */ - /* ReadPropertyMultiple services or services not defined in this standard. */ - /* Enumerated values 0-511 are reserved for definition by ASHRAE. */ - /* Enumerated values 512-4194303 may be used by others subject to the */ - /* procedures and constraints described in Clause 23. */ + /* The special property identifiers all, optional, and required */ + /* are reserved for use in the ReadPropertyConditional and */ + /* ReadPropertyMultiple services or services not defined in this standard. */ + /* Enumerated values 0-511 are reserved for definition by ASHRAE. */ + /* Enumerated values 512-4194303 may be used by others subject to the */ + /* procedures and constraints described in Clause 23. */ /* enumerations used to test Addendum i to ANSI/ASHRAE 135-2008 - private */ PROP_BLINK_PRIORITY_THRESHOLD = 4201, PROP_BLINK_TIME = 4202, @@ -1398,10 +1398,10 @@ typedef enum { ERROR_CODE_BUSY = 82, ERROR_CODE_COMMUNICATION_DISABLED = 83, MAX_BACNET_ERROR_CODE = 84 - /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ - /* Enumerated values 256-65535 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ - /* The last enumeration used in this version is 50. */ + /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ + /* Enumerated values 256-65535 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ + /* The last enumeration used in this version is 50. */ } BACNET_ERROR_CODE; #define FIRST_PROPRIETARY_ERROR_CODE 256 #define LAST_PROPRIETARY_ERROR_CODE 65535 diff --git a/bacnet-stack/include/bacstr.h b/bacnet-stack/include/bacstr.h index 6dd5d326..4ab7fc0c 100644 --- a/bacnet-stack/include/bacstr.h +++ b/bacnet-stack/include/bacstr.h @@ -160,7 +160,7 @@ extern "C" { returns true if successfully converted and fits; false if too long */ bool octetstring_init_ascii_hex( BACNET_OCTET_STRING * octet_string, - const char * ascii_hex); + const char *ascii_hex); #endif bool octetstring_copy( BACNET_OCTET_STRING * dest, diff --git a/bacnet-stack/include/bvlc.h b/bacnet-stack/include/bvlc.h index 4e2f4d62..3a805ccd 100644 --- a/bacnet-stack/include/bvlc.h +++ b/bacnet-stack/include/bvlc.h @@ -83,24 +83,26 @@ extern "C" { uint16_t bbmd_port, /* in network byte order */ uint16_t time_to_live_seconds); -struct sockaddr_in; /* Defined elsewhere, needed here. */ + struct sockaddr_in; /* Defined elsewhere, needed here. */ /* Note any BVLC_RESULT code, or NAK the BVLL message in the unsupported cases. */ int bvlc_for_non_bbmd( - struct sockaddr_in * sout, - uint8_t * npdu, - uint16_t received_bytes); + struct sockaddr_in *sout, + uint8_t * npdu, + uint16_t received_bytes); /* 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 * 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. * We have to store this higher layer code for when the lower layers * need to know what it is, especially to differentiate between * 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 } diff --git a/bacnet-stack/include/config.h b/bacnet-stack/include/config.h index ab9d3dd0..a2d6a195 100644 --- a/bacnet-stack/include/config.h +++ b/bacnet-stack/include/config.h @@ -179,70 +179,70 @@ **/ #ifdef TEST - #define BACNET_SVC_I_HAVE_A 1 - #define BACNET_SVC_WP_A 1 - #define BACNET_SVC_RP_A 1 - #define BACNET_SVC_RPM_A 1 - #define BACNET_SVC_DCC_A 1 - #define BACNET_SVC_RD_A 1 - #define BACNET_SVC_TS_A 1 - #define BACNET_SVC_SERVER 0 - #define BACNET_USE_OCTETSTRING 1 - #define BACNET_USE_DOUBLE 1 - #define BACNET_USE_SIGNED 1 -#else /* Otherwise define our working set - all enabled here to avoid breaking things */ - #define BACNET_SVC_I_HAVE_A 1 - #define BACNET_SVC_WP_A 1 - #define BACNET_SVC_RP_A 1 - #define BACNET_SVC_RPM_A 1 - #define BACNET_SVC_DCC_A 1 - #define BACNET_SVC_RD_A 1 - #define BACNET_SVC_TS_A 1 - #define BACNET_SVC_SERVER 0 - #define BACNET_USE_OCTETSTRING 1 - #define BACNET_USE_DOUBLE 1 - #define BACNET_USE_SIGNED 1 +#define BACNET_SVC_I_HAVE_A 1 +#define BACNET_SVC_WP_A 1 +#define BACNET_SVC_RP_A 1 +#define BACNET_SVC_RPM_A 1 +#define BACNET_SVC_DCC_A 1 +#define BACNET_SVC_RD_A 1 +#define BACNET_SVC_TS_A 1 +#define BACNET_SVC_SERVER 0 +#define BACNET_USE_OCTETSTRING 1 +#define BACNET_USE_DOUBLE 1 +#define BACNET_USE_SIGNED 1 +#else /* Otherwise define our working set - all enabled here to avoid breaking things */ +#define BACNET_SVC_I_HAVE_A 1 +#define BACNET_SVC_WP_A 1 +#define BACNET_SVC_RP_A 1 +#define BACNET_SVC_RPM_A 1 +#define BACNET_SVC_DCC_A 1 +#define BACNET_SVC_RD_A 1 +#define BACNET_SVC_TS_A 1 +#define BACNET_SVC_SERVER 0 +#define BACNET_USE_OCTETSTRING 1 +#define BACNET_USE_DOUBLE 1 +#define BACNET_USE_SIGNED 1 #endif /* Do them one by one */ - #ifndef BACNET_SVC_I_HAVE_A /* Do we send I_Have requests? */ - #define BACNET_SVC_I_HAVE_A 0 - #endif +#ifndef BACNET_SVC_I_HAVE_A /* Do we send I_Have requests? */ +#define BACNET_SVC_I_HAVE_A 0 +#endif - #ifndef BACNET_SVC_WP_A /* Do we send WriteProperty requests? */ - #define BACNET_SVC_WP_A 0 - #endif +#ifndef BACNET_SVC_WP_A /* Do we send WriteProperty requests? */ +#define BACNET_SVC_WP_A 0 +#endif - #ifndef BACNET_SVC_RP_A /* Do we send ReadProperty requests? */ - #define BACNET_SVC_RP_A 0 - #endif +#ifndef BACNET_SVC_RP_A /* Do we send ReadProperty requests? */ +#define BACNET_SVC_RP_A 0 +#endif - #ifndef BACNET_SVC_RPM_A /* Do we send ReadPropertyMultiple requests? */ - #define BACNET_SVC_RPM_A 0 - #endif +#ifndef BACNET_SVC_RPM_A /* Do we send ReadPropertyMultiple requests? */ +#define BACNET_SVC_RPM_A 0 +#endif - #ifndef BACNET_SVC_DCC_A /* Do we send DeviceCommunicationControl requests? */ - #define BACNET_SVC_DCC_A 0 - #endif +#ifndef BACNET_SVC_DCC_A /* Do we send DeviceCommunicationControl requests? */ +#define BACNET_SVC_DCC_A 0 +#endif - #ifndef BACNET_SVC_RD_A /* Do we send ReinitialiseDevice requests? */ - #define BACNET_SVC_RD_A 0 - #endif +#ifndef BACNET_SVC_RD_A /* Do we send ReinitialiseDevice requests? */ +#define BACNET_SVC_RD_A 0 +#endif - #ifndef BACNET_SVC_SERVER /* Are we a pure server type device? */ - #define BACNET_SVC_SERVER 1 - #endif +#ifndef BACNET_SVC_SERVER /* Are we a pure server type device? */ +#define BACNET_SVC_SERVER 1 +#endif - #ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */ - #define BACNET_USE_OCTETSTRING 0 - #endif +#ifndef BACNET_USE_OCTETSTRING /* Do we need any octet strings? */ +#define BACNET_USE_OCTETSTRING 0 +#endif - #ifndef BACNET_USE_DOUBLE /* Do we need any doubles? */ - #define BACNET_USE_DOUBLE 0 - #endif +#ifndef BACNET_USE_DOUBLE /* Do we need any doubles? */ +#define BACNET_USE_DOUBLE 0 +#endif - #ifndef BACNET_USE_SIGNED /* Do we need any signed integers */ - #define BACNET_USE_SIGNED 0 - #endif +#ifndef BACNET_USE_SIGNED /* Do we need any signed integers */ +#define BACNET_USE_SIGNED 0 +#endif #endif diff --git a/bacnet-stack/include/datalink.h b/bacnet-stack/include/datalink.h index 5ecd59cd..354ee938 100644 --- a/bacnet-stack/include/datalink.h +++ b/bacnet-stack/include/datalink.h @@ -73,7 +73,7 @@ #define datalink_get_broadcast_address bip_get_broadcast_address #ifdef BAC_ROUTING extern void routed_get_my_address( - BACNET_ADDRESS * my_address); + BACNET_ADDRESS * my_address); #define datalink_get_my_address routed_get_my_address #else #define datalink_get_my_address bip_get_my_address @@ -135,7 +135,7 @@ extern "C" { * chosen at runtime from among these choices. * - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN * are not currently supported by this project. - *//** @defgroup DLTemplates DataLink Template Functions + *//** @defgroup DLTemplates DataLink Template Functions * @ingroup DataLink * Most of the functions in this group are function templates which are assigned * to a specific DataLink network layer implementation either at compile time or diff --git a/bacnet-stack/include/dcc.h b/bacnet-stack/include/dcc.h index 856a2819..c1af9fe6 100644 --- a/bacnet-stack/include/dcc.h +++ b/bacnet-stack/include/dcc.h @@ -94,7 +94,7 @@ extern "C" { * * The network management BIBBs prescribe the BACnet capabilities required to * interoperably perform network management functions. - *//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC) + *//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC) * @ingroup RDMS * 16.1 DeviceCommunicationControl Service
* The DeviceCommunicationControl service is used by a client BACnet-user to @@ -107,7 +107,7 @@ extern "C" { * "indefinite," meaning communication must be re-enabled by a * DeviceCommunicationControl or, if supported, ReinitializeDevice service, * not by time. - *//** @defgroup NMRC Network Management-Router Configuration (NM-RC) + *//** @defgroup NMRC Network Management-Router Configuration (NM-RC) * @ingroup RDMS * The A device may query and change the configuration of routers and * half-routers. diff --git a/bacnet-stack/include/dlenv.h b/bacnet-stack/include/dlenv.h index 217c1e1a..108b8e2f 100644 --- a/bacnet-stack/include/dlenv.h +++ b/bacnet-stack/include/dlenv.h @@ -35,13 +35,17 @@ extern "C" { void); void dlenv_maintenance_timer( uint16_t elapsed_seconds); - + /* Simple setters and getter. */ - void dlenv_bbmd_address_set( long address ); - void dlenv_bbmd_port_set( int port ); - void dlenv_bbmd_ttl_set( int ttl_secs ); - int dlenv_bbmd_result( void ); - + void dlenv_bbmd_address_set( + long address); + void dlenv_bbmd_port_set( + int port); + void dlenv_bbmd_ttl_set( + int ttl_secs); + int dlenv_bbmd_result( + void); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/bacnet-stack/include/event.h b/bacnet-stack/include/event.h index a1854aae..b5c2f21b 100644 --- a/bacnet-stack/include/event.h +++ b/bacnet-stack/include/event.h @@ -202,7 +202,7 @@ extern "C" { * These BIBBs prescribe the BACnet capabilities required to interoperably * perform the alarm and event management functions enumerated in 22.2.1.2 * for the BACnet devices defined therein. - *//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N) + *//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N) * @ingroup ALMEVNT * 13.6 ConfirmedCOVNotification Service
* The ConfirmedCOVNotification service is used to notify subscribers about @@ -219,7 +219,7 @@ extern "C" { * For unsubscribed notifications, the algorithm for determining when to issue * this service is a local matter and may be based on a change of value, * periodic updating, or some other criteria. - *//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK) + *//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK) * @ingroup ALMEVNT * 13.5 AcknowledgeAlarm Service
* In some systems a device may need to know that an operator has seen the alarm diff --git a/bacnet-stack/include/fifo.h b/bacnet-stack/include/fifo.h index 429ecbe1..4cbdc916 100755 --- a/bacnet-stack/include/fifo.h +++ b/bacnet-stack/include/fifo.h @@ -51,7 +51,7 @@ extern "C" { bool FIFO_Full( FIFO_BUFFER const *b); - bool FIFO_Available ( + bool FIFO_Available( FIFO_BUFFER const *b, unsigned count); diff --git a/bacnet-stack/include/handlers.h b/bacnet-stack/include/handlers.h index 6d47d4e4..e7a926d6 100644 --- a/bacnet-stack/include/handlers.h +++ b/bacnet-stack/include/handlers.h @@ -215,7 +215,8 @@ extern "C" { uint16_t service_len, BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data); - void handler_cov_task(void); + void handler_cov_task( + void); void handler_cov_timer_seconds( uint32_t elapsed_seconds); void handler_cov_init( diff --git a/bacnet-stack/include/mstp.h b/bacnet-stack/include/mstp.h index 8196c4d1..85ea3dc7 100644 --- a/bacnet-stack/include/mstp.h +++ b/bacnet-stack/include/mstp.h @@ -178,7 +178,7 @@ extern "C" { volatile struct mstp_port_struct_t *mstp_port); void MSTP_Slave_Node_FSM( - volatile struct mstp_port_struct_t * mstp_port); + volatile struct mstp_port_struct_t *mstp_port); /* returns true if line is active */ bool MSTP_Line_Active( diff --git a/bacnet-stack/include/proplist.h b/bacnet-stack/include/proplist.h index b9edbf1c..523a4364 100644 --- a/bacnet-stack/include/proplist.h +++ b/bacnet-stack/include/proplist.h @@ -37,11 +37,11 @@ extern "C" { #endif /* __cplusplus */ -unsigned property_list_count( - const int *pList); -void property_list_special( - BACNET_OBJECT_TYPE object_type, - struct special_property_list_t *pPropertyList); + unsigned property_list_count( + const int *pList); + void property_list_special( + BACNET_OBJECT_TYPE object_type, + struct special_property_list_t *pPropertyList); #ifdef __cplusplus } diff --git a/bacnet-stack/include/readrange.h b/bacnet-stack/include/readrange.h index 4a94f892..672799d7 100644 --- a/bacnet-stack/include/readrange.h +++ b/bacnet-stack/include/readrange.h @@ -162,7 +162,7 @@ extern "C" { * These BIBBs prescribe the BACnet capabilities required to interoperably * perform the trending functions enumerated in clause 22.2.1.4 for the * BACnet devices defined therein. - *//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT) + *//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT) * @ingroup Trend * 15.8 ReadRange Service
* The ReadRange service is used by a client BACnet-user to read a specific diff --git a/bacnet-stack/include/ringbuf.h b/bacnet-stack/include/ringbuf.h index b196dd93..6e6a0a46 100644 --- a/bacnet-stack/include/ringbuf.h +++ b/bacnet-stack/include/ringbuf.h @@ -31,11 +31,11 @@ #include struct ring_buffer_t { - volatile uint8_t * buffer; /* block of memory or array of data */ + volatile uint8_t *buffer; /* block of memory or array of data */ unsigned element_size; /* how many bytes for each chunk */ unsigned element_count; /* number of chunks of data */ - volatile unsigned head; /* where the writes go */ - volatile unsigned tail; /* where the reads come from */ + volatile unsigned head; /* where the writes go */ + volatile unsigned tail; /* where the reads come from */ }; typedef struct ring_buffer_t RING_BUFFER; @@ -43,9 +43,9 @@ typedef struct ring_buffer_t RING_BUFFER; extern "C" { #endif /* __cplusplus */ - unsigned Ringbuf_Count ( + unsigned Ringbuf_Count( RING_BUFFER const *b); - bool Ringbuf_Full ( + bool Ringbuf_Full( RING_BUFFER const *b); bool Ringbuf_Empty( RING_BUFFER const *b); @@ -55,13 +55,13 @@ extern "C" { RING_BUFFER * b); bool Ringbuf_Put( RING_BUFFER * b, /* ring buffer structure */ - volatile uint8_t *data_element); /* one element to add to the ring */ + volatile uint8_t * data_element); /* one element to add to the ring */ volatile uint8_t *Ringbuf_Alloc( - RING_BUFFER *b); + RING_BUFFER * b); /* Note: element_count must be a power of two */ void Ringbuf_Init( RING_BUFFER * b, /* ring buffer structure */ - volatile uint8_t * buffer, /* data block or array of data */ + volatile uint8_t * buffer, /* data block or array of data */ unsigned element_size, /* size of one element in the data block */ unsigned element_count); /* number of elements in the data block */ diff --git a/bacnet-stack/include/rp.h b/bacnet-stack/include/rp.h index b7087235..8c1e031c 100644 --- a/bacnet-stack/include/rp.h +++ b/bacnet-stack/include/rp.h @@ -125,7 +125,7 @@ extern "C" { * These BIBBs prescribe the BACnet capabilities required to interoperably * perform the data sharing functions enumerated in 22.2.1.1 for the BACnet * devices defined therein. - *//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP) + *//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP) * @ingroup DataShare * 15.5 ReadProperty Service
* The ReadProperty service is used by a client BACnet-user to request the diff --git a/bacnet-stack/include/wp.h b/bacnet-stack/include/wp.h index 17d3d5f2..0e304919 100644 --- a/bacnet-stack/include/wp.h +++ b/bacnet-stack/include/wp.h @@ -37,7 +37,7 @@ typedef struct BACnet_Write_Property_Data { BACNET_OBJECT_TYPE object_type; uint32_t object_instance; BACNET_PROPERTY_ID object_property; - uint32_t array_index; /* use BACNET_ARRAY_ALL when not setting */ + uint32_t array_index; /* use BACNET_ARRAY_ALL when not setting */ uint8_t application_data[MAX_APDU]; int application_data_len; uint8_t priority; /* use BACNET_NO_PRIORITY if no priority */ diff --git a/bacnet-stack/include/wpm.h b/bacnet-stack/include/wpm.h index 601bc5d2..8a902163 100644 --- a/bacnet-stack/include/wpm.h +++ b/bacnet-stack/include/wpm.h @@ -49,13 +49,16 @@ extern "C" { /* encode objects */ - int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id); - int wpm_encode_apdu_object_begin ( + int wpm_encode_apdu_init( + uint8_t * apdu, + uint8_t invoke_id); + int wpm_encode_apdu_object_begin( uint8_t * apdu, BACNET_OBJECT_TYPE object_type, uint32_t object_instance); - int wpm_encode_apdu_object_end (uint8_t * apdu); - int wpm_encode_apdu_object_property ( + int wpm_encode_apdu_object_end( + uint8_t * apdu); + int wpm_encode_apdu_object_property( uint8_t * apdu, BACNET_WRITE_PROPERTY_DATA * wpdata); diff --git a/bacnet-stack/ports/at91sam7s/av.c b/bacnet-stack/ports/at91sam7s/av.c index 1a876179..045285fd 100644 --- a/bacnet-stack/ports/at91sam7s/av.c +++ b/bacnet-stack/ports/at91sam7s/av.c @@ -360,8 +360,8 @@ bool Analog_Value_Write_Property( (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { level = (uint8_t) value.type.Real; object_index = - Analog_Value_Instance_To_Index - (wp_data->object_instance); + Analog_Value_Instance_To_Index(wp_data-> + object_instance); priority--; Present_Value[object_index] = level; /* Note: you could set the physical output here if we diff --git a/bacnet-stack/ports/at91sam7s/bv.c b/bacnet-stack/ports/at91sam7s/bv.c index d0a91595..4579a3a3 100644 --- a/bacnet-stack/ports/at91sam7s/bv.c +++ b/bacnet-stack/ports/at91sam7s/bv.c @@ -271,8 +271,8 @@ bool Binary_Value_Write_Property( (value.type.Enumerated <= MAX_BINARY_PV)) { level = value.type.Enumerated; object_index = - Binary_Value_Instance_To_Index - (wp_data->object_instance); + Binary_Value_Instance_To_Index(wp_data-> + object_instance); priority--; /* NOTE: this Binary value has no priority array */ Present_Value[object_index] = level; diff --git a/bacnet-stack/ports/at91sam7s/device.c b/bacnet-stack/ports/at91sam7s/device.c index a21c24c9..52e5dce8 100644 --- a/bacnet-stack/ports/at91sam7s/device.c +++ b/bacnet-stack/ports/at91sam7s/device.c @@ -193,10 +193,10 @@ static int Read_Property_Common( apdu_len = BACNET_STATUS_ERROR; } else { characterstring_init_ansi(&char_string, ""); - if (pObject->Object_Name) { - (void) pObject->Object_Name(rpdata->object_instance, - &char_string); - } + if (pObject->Object_Name) { + (void) pObject->Object_Name(rpdata->object_instance, + &char_string); + } apdu_len = encode_application_character_string(&apdu[0], &char_string); @@ -615,7 +615,7 @@ bool Device_Valid_Object_Id( } bool Device_Object_Name_Copy( - BACNET_OBJECT_TYPE object_type, + BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_CHARACTER_STRING * object_name) { @@ -850,8 +850,8 @@ bool Device_Write_Property_Local( case PROP_OBJECT_IDENTIFIER: if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { /* we could send an I-Am broadcast to let the world know */ status = true; } else { @@ -903,13 +903,13 @@ bool Device_Write_Property_Local( characterstring_encoding(&value.type.Character_String); if (encoding < MAX_CHARACTER_STRING_ENCODING) { /* All the object names in a device must be unique. */ - if (Device_Valid_Object_Name(&value.type. - Character_String, NULL, NULL)) { + if (Device_Valid_Object_Name(&value. + type.Character_String, NULL, NULL)) { wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_code = ERROR_CODE_DUPLICATE_NAME; } else { - Device_Set_Object_Name(&value.type. - Character_String); + Device_Set_Object_Name(&value. + type.Character_String); status = true; } } else { diff --git a/bacnet-stack/ports/at91sam7s/dlmstp.c b/bacnet-stack/ports/at91sam7s/dlmstp.c index 97001c9c..cb522347 100644 --- a/bacnet-stack/ports/at91sam7s/dlmstp.c +++ b/bacnet-stack/ports/at91sam7s/dlmstp.c @@ -1119,8 +1119,7 @@ static bool MSTP_Master_Node_FSM( Master_State = MSTP_MASTER_STATE_IDLE; /* clear our flag we were holding for comparison */ MSTP_Flag.ReceivedValidFrame = false; - } else if ((Timer_Silence() > Treply_delay) || - (pkt != NULL)) { + } else if ((Timer_Silence() > Treply_delay) || (pkt != NULL)) { /* DeferredReply */ /* If no reply will be available from the higher layers */ /* within Treply_delay after the reception of the */ diff --git a/bacnet-stack/ports/atmega168/bv.c b/bacnet-stack/ports/atmega168/bv.c index 48510722..f9f98587 100644 --- a/bacnet-stack/ports/atmega168/bv.c +++ b/bacnet-stack/ports/atmega168/bv.c @@ -211,8 +211,8 @@ bool Binary_Value_Write_Property( if ((value.type.Enumerated == BINARY_ACTIVE) || (value.type.Enumerated == BINARY_INACTIVE)) { object_index = - Binary_Value_Instance_To_Index - (wp_data->object_instance); + Binary_Value_Instance_To_Index(wp_data-> + object_instance); /* NOTE: this Binary value has no priority array */ Present_Value[object_index] = (BACNET_BINARY_PV) value.type.Enumerated; diff --git a/bacnet-stack/ports/atmega168/device.c b/bacnet-stack/ports/atmega168/device.c index 700a4d3c..c9d1b698 100644 --- a/bacnet-stack/ports/atmega168/device.c +++ b/bacnet-stack/ports/atmega168/device.c @@ -380,8 +380,8 @@ bool Device_Write_Property( case PROP_OBJECT_IDENTIFIER: if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { /* we could send an I-Am broadcast to let the world know */ status = true; } else { diff --git a/bacnet-stack/ports/atmega8/bv.c b/bacnet-stack/ports/atmega8/bv.c index 48510722..f9f98587 100644 --- a/bacnet-stack/ports/atmega8/bv.c +++ b/bacnet-stack/ports/atmega8/bv.c @@ -211,8 +211,8 @@ bool Binary_Value_Write_Property( if ((value.type.Enumerated == BINARY_ACTIVE) || (value.type.Enumerated == BINARY_INACTIVE)) { object_index = - Binary_Value_Instance_To_Index - (wp_data->object_instance); + Binary_Value_Instance_To_Index(wp_data-> + object_instance); /* NOTE: this Binary value has no priority array */ Present_Value[object_index] = (BACNET_BINARY_PV) value.type.Enumerated; diff --git a/bacnet-stack/ports/atmega8/device.c b/bacnet-stack/ports/atmega8/device.c index 848a15d7..a3281650 100644 --- a/bacnet-stack/ports/atmega8/device.c +++ b/bacnet-stack/ports/atmega8/device.c @@ -49,7 +49,7 @@ static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL; void Device_Init( object_functions_t * object_table) { - (void)object_table; + (void) object_table; /* Reinitialize_State = BACNET_REINIT_IDLE; */ /* dcc_set_status_duration(COMMUNICATION_ENABLE, 0); */ /* FIXME: Get the data from the eeprom */ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/bname.c b/bacnet-stack/ports/bdk-atxx4-mstp/bname.c index 7867cb25..45742596 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/bname.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/bname.c @@ -60,22 +60,17 @@ bool bacnet_name_save( char *str, uint8_t length) { - uint8_t buffer[NV_EEPROM_NAME_SIZE] = {0}; + uint8_t buffer[NV_EEPROM_NAME_SIZE] = { 0 }; uint8_t i = 0; if (bacnet_name_isvalid(encoding, length, str)) { - eeprom_bytes_write( - NV_EEPROM_NAME_LENGTH(offset), - &length, 1); - eeprom_bytes_write( - NV_EEPROM_NAME_ENCODING(offset), - (uint8_t *)&encoding, 1); + eeprom_bytes_write(NV_EEPROM_NAME_LENGTH(offset), &length, 1); + eeprom_bytes_write(NV_EEPROM_NAME_ENCODING(offset), + (uint8_t *) & encoding, 1); for (i = 0; i < length; i++) { buffer[i] = str[i]; } - eeprom_bytes_write( - NV_EEPROM_NAME_STRING(offset), - &buffer[0], + eeprom_bytes_write(NV_EEPROM_NAME_STRING(offset), &buffer[0], NV_EEPROM_NAME_SIZE); return true; } @@ -118,8 +113,8 @@ bool bacnet_name_write_unique( } else if (length <= NV_EEPROM_NAME_SIZE) { encoding = characterstring_encoding(char_string); if (encoding < MAX_CHARACTER_STRING_ENCODING) { - if (Device_Valid_Object_Name(char_string, - &duplicate_type, &duplicate_instance)) { + if (Device_Valid_Object_Name(char_string, &duplicate_type, + &duplicate_instance)) { if ((duplicate_type == object_type) && (duplicate_instance == object_instance)) { /* writing same name to same object */ @@ -185,8 +180,8 @@ void bacnet_name_init( uint16_t offset, char *default_string) { - (void)bacnet_name_save(offset, CHARACTER_UTF8, - default_string, strlen(default_string)); + (void) bacnet_name_save(offset, CHARACTER_UTF8, default_string, + strlen(default_string)); } void bacnet_name( diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/bo.c b/bacnet-stack/ports/bdk-atxx4-mstp/bo.c index 1741890d..71f9c318 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/bo.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/bo.c @@ -439,8 +439,8 @@ bool Binary_Output_Write_Property( priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; - Binary_Output_Present_Value_Set - (wp_data->object_instance, level, priority); + Binary_Output_Present_Value_Set(wp_data-> + object_instance, level, priority); } else if (priority == 6) { status = false; /* Command priority 6 is reserved for use by Minimum On/Off diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/device.c b/bacnet-stack/ports/bdk-atxx4-mstp/device.c index 13e0e674..ffd38959 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/device.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/device.c @@ -160,7 +160,7 @@ static int Read_Property_Common( BACNET_READ_PROPERTY_DATA * rpdata) { int apdu_len = BACNET_STATUS_ERROR; - BACNET_CHARACTER_STRING char_string = {0}; + BACNET_CHARACTER_STRING char_string = { 0 }; uint8_t *apdu = NULL; if ((rpdata->application_data == NULL) || @@ -579,7 +579,7 @@ bool Device_Valid_Object_Name( for (i = 0; i < max_objects; i++) { check_id = Device_Object_List_Identifier(i, &type, &instance); if (check_id) { - pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)type); + pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) type); if ((pObject != NULL) && (pObject->Object_Name != NULL) && (pObject->Object_Name(instance, &object_name2) && characterstring_same(object_name1, &object_name2))) { @@ -605,7 +605,7 @@ bool Device_Valid_Object_Id( bool status = false; /* return value */ struct my_object_functions *pObject = NULL; - pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE)object_type); + pObject = Device_Objects_Find_Functions((BACNET_OBJECT_TYPE) object_type); if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) { status = pObject->Object_Valid_Instance(object_instance); } @@ -614,7 +614,7 @@ bool Device_Valid_Object_Id( } bool Device_Object_Name_Copy( - BACNET_OBJECT_TYPE object_type, + BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_CHARACTER_STRING * object_name) { @@ -650,7 +650,7 @@ int Device_Read_Property_Local( } apdu = rpdata->application_data; switch (rpdata->object_property) { - /* object name, object id, object type are handled in Device object */ + /* object name, object id, object type are handled in Device object */ case PROP_DESCRIPTION: bacnet_name(NV_EEPROM_DEVICE_DESCRIPTION, &char_string, "BACnet Development Kit"); @@ -856,8 +856,8 @@ bool Device_Write_Property_Local( case PROP_OBJECT_IDENTIFIER: if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { eeprom_bytes_write(NV_EEPROM_DEVICE_0, (uint8_t *) & value.type.Object_Id.instance, 4); /* we could send an I-Am broadcast to let the world know */ @@ -902,12 +902,10 @@ bool Device_Write_Property_Local( break; case PROP_OBJECT_NAME: if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) { - status = bacnet_name_write_unique( - NV_EEPROM_DEVICE_NAME, - value.type.Object_Id.type, - value.type.Object_Id.instance, - &value.type.Character_String, - &wp_data->error_class, + status = + bacnet_name_write_unique(NV_EEPROM_DEVICE_NAME, + value.type.Object_Id.type, value.type.Object_Id.instance, + &value.type.Character_String, &wp_data->error_class, &wp_data->error_code); } else { wp_data->error_class = ERROR_CLASS_PROPERTY; diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c index b5f186c2..d85a4057 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c @@ -372,7 +372,7 @@ static void MSTP_Send_Frame( uint8_t crc8 = 0xFF; /* used to calculate the crc value */ uint16_t crc16 = 0xFFFF; /* used to calculate the crc value */ uint8_t buffer[8]; /* stores the header and header crc */ - uint8_t buffer_crc[2]; /* stores the data crc */ + uint8_t buffer_crc[2]; /* stores the data crc */ uint16_t i = 0; /* used to calculate CRC for data */ /* create the MS/TP header */ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h b/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h index 3bee43ae..756eaac1 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h +++ b/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h @@ -273,8 +273,11 @@ typedef struct { #endif #elif defined (__CROSSWORKS_AVR) /* use functions defined in crt0.s to mimic IAR macros */ -void __uint8_eeprom_store(unsigned char byte, unsigned addr); -unsigned char __uint8_eeprom_load(unsigned addr); +void __uint8_eeprom_store( + unsigned char byte, + unsigned addr); +unsigned char __uint8_eeprom_load( + unsigned addr); #define __EEPUT(addr, var) \ __uint8_eeprom_store((unsigned char)(var), (unsigned)(addr)) #define __EEGET(var, addr) \ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c b/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c index 731379dc..1b1ffaab 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c @@ -218,7 +218,7 @@ int seeprom_bytes_read( the slave, or it can leave the SDA line high (NACK), indicating to the slave that it is going to stop the transfer now. Assertion of ACK is handled by setting the TWEA bit in TWCR when - starting the current transfer.*/ + starting the current transfer. */ /* Next cycle(s): master receiver mode */ /* send repeated start condition */ TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/test.c b/bacnet-stack/ports/bdk-atxx4-mstp/test.c index c5aed938..6689e4c7 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/test.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/test.c @@ -163,19 +163,22 @@ void test_task( rs485_baud_rate_set(9600); break; 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); - serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer)); + serial_bytes_send((uint8_t *) Send_Buffer, + strlen(Send_Buffer)); break; case 'b': sprintf(Send_Buffer, "\r\n%lubps", (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; case 'm': sprintf(Send_Buffer, "\r\nMax:%u", (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; default: break; diff --git a/bacnet-stack/ports/linux/dlmstp.c b/bacnet-stack/ports/linux/dlmstp.c index 4f24e5ed..475db2a3 100644 --- a/bacnet-stack/ports/linux/dlmstp.c +++ b/bacnet-stack/ports/linux/dlmstp.c @@ -242,7 +242,7 @@ static void *dlmstp_master_fsm_task( } if (run_master) { if (MSTP_Port.This_Station <= DEFAULT_MAX_MASTER) { - while (MSTP_Master_Node_FSM (&MSTP_Port)) { + while (MSTP_Master_Node_FSM(&MSTP_Port)) { /* do nothing while immediate transitioning */ } } else if (MSTP_Port.This_Station < 255) { @@ -323,14 +323,9 @@ uint16_t MSTP_Get_Send( frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; } /* convert the PDU into the MSTP Frame */ - pdu_len = MSTP_Create_Frame( - &mstp_port->OutputBuffer[0], /* <-- loading this */ - mstp_port->OutputBufferSize, - frame_type, - pkt->destination_mac, - mstp_port->This_Station, - (uint8_t *) & pkt->buffer[0], - pkt->length); + pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */ + mstp_port->OutputBufferSize, frame_type, pkt->destination_mac, + mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length); return pdu_len; } @@ -369,8 +364,7 @@ static bool dlmstp_compare_data_expecting_reply( if (request.npdu_data.network_layer_message) { #if PRINT_ENABLED fprintf(stderr, - "DLMSTP: DER Compare failed: " - "Request is Network message.\n"); + "DLMSTP: DER Compare failed: " "Request is Network message.\n"); #endif return false; } @@ -378,8 +372,7 @@ static bool dlmstp_compare_data_expecting_reply( if (request.pdu_type != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) { #if PRINT_ENABLED fprintf(stderr, - "DLMSTP: DER Compare failed: " - "Not Confirmed Request.\n"); + "DLMSTP: DER Compare failed: " "Not Confirmed Request.\n"); #endif return false; } @@ -398,8 +391,7 @@ static bool dlmstp_compare_data_expecting_reply( if (reply.npdu_data.network_layer_message) { #if PRINT_ENABLED fprintf(stderr, - "DLMSTP: DER Compare failed: " - "Reply is Network message.\n"); + "DLMSTP: DER Compare failed: " "Reply is Network message.\n"); #endif return false; } @@ -445,26 +437,23 @@ static bool dlmstp_compare_data_expecting_reply( (reply.pdu_type == PDU_TYPE_ABORT)) { if (request.invoke_id != reply.invoke_id) { #if PRINT_ENABLED - fprintf(stderr, - "DLMSTP: DER Compare failed: " - "Invoke ID mismatch.\n"); + fprintf(stderr, + "DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n"); #endif return false; } } else { if (request.invoke_id != reply.invoke_id) { #if PRINT_ENABLED - fprintf(stderr, - "DLMSTP: DER Compare failed: " - "Invoke ID mismatch.\n"); + fprintf(stderr, + "DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n"); #endif return false; } if (request.service_choice != reply.service_choice) { #if PRINT_ENABLED - fprintf(stderr, - "DLMSTP: DER Compare failed: " - "Service choice mismatch.\n"); + fprintf(stderr, + "DLMSTP: DER Compare failed: " "Service choice mismatch.\n"); #endif return false; } @@ -480,16 +469,14 @@ static bool dlmstp_compare_data_expecting_reply( if (request.npdu_data.priority != reply.npdu_data.priority) { #if PRINT_ENABLED fprintf(stderr, - "DLMSTP: DER Compare failed: " - "NPDU Priority mismatch.\n"); + "DLMSTP: DER Compare failed: " "NPDU Priority mismatch.\n"); #endif return false; } if (!bacnet_address_same(&request.address, &reply.address)) { #if PRINT_ENABLED fprintf(stderr, - "DLMSTP: DER Compare failed: " - "BACnet Address mismatch.\n"); + "DLMSTP: DER Compare failed: " "BACnet Address mismatch.\n"); #endif return false; } @@ -514,13 +501,9 @@ uint16_t MSTP_Get_Reply( pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); /* is this the reply to the DER? */ matched = - dlmstp_compare_data_expecting_reply( - &mstp_port->InputBuffer[0], - mstp_port->DataLength, - mstp_port->SourceAddress, - (uint8_t *) & pkt->buffer[0], - pkt->length, - pkt->destination_mac); + dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0], + mstp_port->DataLength, mstp_port->SourceAddress, + (uint8_t *) & pkt->buffer[0], pkt->length, pkt->destination_mac); if (!matched) { return 0; } @@ -531,14 +514,9 @@ uint16_t MSTP_Get_Reply( frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; } /* convert the PDU into the MSTP Frame */ - pdu_len = MSTP_Create_Frame( - &mstp_port->OutputBuffer[0], /* <-- loading this */ - mstp_port->OutputBufferSize, - frame_type, - pkt->destination_mac, - mstp_port->This_Station, - (uint8_t *) & pkt->buffer[0], - pkt->length); + pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */ + mstp_port->OutputBufferSize, frame_type, pkt->destination_mac, + mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length); return pdu_len; } @@ -678,8 +656,7 @@ bool dlmstp_init( /* initialize PDU queue */ Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer, - sizeof(struct mstp_pdu_packet), - MSTP_PDU_PACKET_COUNT); + sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT); /* initialize packet queue */ Receive_Packet.ready = false; Receive_Packet.pdu_len = 0; diff --git a/bacnet-stack/ports/linux/mstpsnap.c b/bacnet-stack/ports/linux/mstpsnap.c index fcaf85d5..6dbf3804 100644 --- a/bacnet-stack/ports/linux/mstpsnap.c +++ b/bacnet-stack/ports/linux/mstpsnap.c @@ -83,7 +83,7 @@ static void Timer_Silence_Reset( /* functions used by the MS/TP state machine to put or get data */ uint16_t MSTP_Put_Receive( - volatile struct mstp_port_struct_t * mstp_port) + volatile struct mstp_port_struct_t *mstp_port) { (void) mstp_port; @@ -203,7 +203,7 @@ static void snap_received_packet( } /* Ethernet length is data only - not address or length bytes */ encode_unsigned16(&mtu[12], mtu_len - 14); - (void)write(sockfd, &mtu[0], mtu_len); + (void) write(sockfd, &mtu[0], mtu_len); } diff --git a/bacnet-stack/ports/linux/rs485.c b/bacnet-stack/ports/linux/rs485.c index 9f61a258..6a78434b 100644 --- a/bacnet-stack/ports/linux/rs485.c +++ b/bacnet-stack/ports/linux/rs485.c @@ -153,7 +153,7 @@ uint32_t RS485_Get_Baud_Rate( baud = 200; break; case B300: - baud =300; + baud = 300; break; case B600: baud = 600; @@ -288,13 +288,13 @@ void RS485_Send_Frame( uint16_t nbytes) { /* number of bytes of data (up to 501) */ uint32_t turnaround_time = Tturnaround * 1000; - uint32_t baud = RS485_Get_Baud_Rate (); + uint32_t baud = RS485_Get_Baud_Rate(); ssize_t written = 0; int greska; /* sleeping for turnaround time is necessary to give other devices time to change from sending to receiving state. */ - usleep(turnaround_time/baud); + usleep(turnaround_time / baud); /* On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned, and errno is set @@ -354,9 +354,9 @@ void RS485_Check_UART_Data( } } /* grab bytes and stuff them into the FIFO every time */ - FD_ZERO (&input); - FD_SET (RS485_Handle, &input); - n = select (RS485_Handle + 1, &input, NULL, NULL, &waiter); + FD_ZERO(&input); + FD_SET(RS485_Handle, &input); + n = select(RS485_Handle + 1, &input, NULL, NULL, &waiter); if (n < 0) { return; } diff --git a/bacnet-stack/ports/pic18f6720/av.c b/bacnet-stack/ports/pic18f6720/av.c index 302c884b..80f36335 100644 --- a/bacnet-stack/ports/pic18f6720/av.c +++ b/bacnet-stack/ports/pic18f6720/av.c @@ -325,8 +325,8 @@ bool Analog_Value_Write_Property( (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { level = (uint8_t) value.type.Real; object_index = - Analog_Value_Instance_To_Index - (wp_data->object_instance); + Analog_Value_Instance_To_Index(wp_data-> + object_instance); priority--; Present_Value[object_index] = level; /* Note: you could set the physical output here if we diff --git a/bacnet-stack/ports/pic18f6720/bv.c b/bacnet-stack/ports/pic18f6720/bv.c index a4c40ab7..a8f814d9 100644 --- a/bacnet-stack/ports/pic18f6720/bv.c +++ b/bacnet-stack/ports/pic18f6720/bv.c @@ -237,8 +237,8 @@ bool Binary_Value_Write_Property( (value.type.Enumerated <= MAX_BINARY_PV)) { level = value.type.Enumerated; object_index = - Binary_Value_Instance_To_Index - (wp_data->object_instance); + Binary_Value_Instance_To_Index(wp_data-> + object_instance); priority--; /* NOTE: this Binary value has no priority array */ Present_Value[object_index] = level; diff --git a/bacnet-stack/ports/pic18f6720/device.c b/bacnet-stack/ports/pic18f6720/device.c index 4e38416d..3ae40800 100644 --- a/bacnet-stack/ports/pic18f6720/device.c +++ b/bacnet-stack/ports/pic18f6720/device.c @@ -533,8 +533,8 @@ bool Device_Write_Property( case PROP_OBJECT_IDENTIFIER: if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { /* we could send an I-Am broadcast to let the world know */ status = true; } else { diff --git a/bacnet-stack/ports/pic18f6720/dlmstp.c b/bacnet-stack/ports/pic18f6720/dlmstp.c index 35a5a5cd..08028a0c 100644 --- a/bacnet-stack/ports/pic18f6720/dlmstp.c +++ b/bacnet-stack/ports/pic18f6720/dlmstp.c @@ -115,13 +115,9 @@ int dlmstp_send_pdu( return -4; } bytes_sent = - MSTP_Create_Frame( - (uint8_t *) & MSTP_Port.TxBuffer[0], - sizeof(MSTP_Port.TxBuffer), - MSTP_Port.TxFrameType, - MSTP_Port.TxDestination, - MSTP_Port.This_Station, - pdu, pdu_len); + MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0], + sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType, + MSTP_Port.TxDestination, MSTP_Port.This_Station, pdu, pdu_len); MSTP_Port.TxLength = bytes_sent; MSTP_Port.TxReady = true; MSTP_Packets++; diff --git a/bacnet-stack/ports/pic18f6720/mstp.c b/bacnet-stack/ports/pic18f6720/mstp.c index 0f58af71..847e0ff9 100644 --- a/bacnet-stack/ports/pic18f6720/mstp.c +++ b/bacnet-stack/ports/pic18f6720/mstp.c @@ -1145,13 +1145,10 @@ bool MSTP_Master_Node_FSM( see if the message is that same APDU type along with the matching src/dest and invoke ID */ matched = - mstp_compare_data_expecting_reply( - &mstp_port->InputBuffer[0], - mstp_port->DataLength, - mstp_port->SourceAddress, - &mstp_port->TxBuffer[0], - mstp_port->TxLength, - mstp_port->TxDestination); + mstp_compare_data_expecting_reply(&mstp_port-> + InputBuffer[0], mstp_port->DataLength, + mstp_port->SourceAddress, &mstp_port->TxBuffer[0], + mstp_port->TxLength, mstp_port->TxDestination); } if (matched && mstp_port->TxReady) { /* Reply */ @@ -1162,8 +1159,7 @@ bool MSTP_Master_Node_FSM( /* then call MSTP_Create_And_Send_Frame to transmit the reply frame */ /* and enter the IDLE state to wait for the next frame. */ RS485_Send_Frame(mstp_port, - (uint8_t *) & mstp_port->TxBuffer[0], - mstp_port->TxLength); + (uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength); mstp_port->TxReady = false; mstp_port->master_state = MSTP_MASTER_STATE_IDLE; } else { diff --git a/bacnet-stack/ports/rtos32/bip-init.c b/bacnet-stack/ports/rtos32/bip-init.c index c8bd98d4..3357b518 100644 --- a/bacnet-stack/ports/rtos32/bip-init.c +++ b/bacnet-stack/ports/rtos32/bip-init.c @@ -261,8 +261,7 @@ bool bip_init( bip_set_port(htons((0xBAC0)); /* assumes that the driver has already been initialized */ sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP); - bip_set_socket(sock_fd); - if (sock_fd < 0) + bip_set_socket(sock_fd); if (sock_fd < 0) return false; /* bind the socket to the local port number and IP address */ sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY); diff --git a/bacnet-stack/ports/rx62n/bo.c b/bacnet-stack/ports/rx62n/bo.c index 6f438d01..a8af0727 100644 --- a/bacnet-stack/ports/rx62n/bo.c +++ b/bacnet-stack/ports/rx62n/bo.c @@ -429,8 +429,8 @@ bool Binary_Output_Write_Property( priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; - Binary_Output_Present_Value_Set - (wp_data->object_instance, level, priority); + Binary_Output_Present_Value_Set(wp_data-> + object_instance, level, priority); } else if (priority == 6) { status = false; /* Command priority 6 is reserved for use by Minimum On/Off diff --git a/bacnet-stack/ports/rx62n/device.c b/bacnet-stack/ports/rx62n/device.c index 76db5bc2..552f9eb7 100644 --- a/bacnet-stack/ports/rx62n/device.c +++ b/bacnet-stack/ports/rx62n/device.c @@ -833,8 +833,8 @@ bool Device_Write_Property_Local( &wp_data->error_class, &wp_data->error_code); if (status) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { /* we could send an I-Am broadcast to let the world know */ status = true; } else { @@ -868,8 +868,8 @@ bool Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_NAME_LEN, false, &wp_data->error_class, &wp_data->error_code); if (status) { - Device_Set_Object_Name(characterstring_value(&value. - type.Character_String), + Device_Set_Object_Name(characterstring_value(&value.type. + Character_String), characterstring_length(&value.type.Character_String)); } break; @@ -878,8 +878,8 @@ bool Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_LOC_LEN, true, &wp_data->error_class, &wp_data->error_code); if (status) { - Device_Set_Location(characterstring_value(&value. - type.Character_String), + Device_Set_Location(characterstring_value(&value.type. + Character_String), characterstring_length(&value.type.Character_String)); } break; @@ -889,8 +889,8 @@ bool Device_Write_Property_Local( WPValidateString(&value, MAX_DEV_DESC_LEN, true, &wp_data->error_class, &wp_data->error_code); if (status) { - Device_Set_Description(characterstring_value(&value. - type.Character_String), + Device_Set_Description(characterstring_value(&value.type. + Character_String), characterstring_length(&value.type.Character_String)); } break; @@ -948,13 +948,13 @@ bool Device_Write_Property( /** Initialize the Device Object and each of its child Object instances. * @ingroup ObjIntf */ - void Device_Init( - object_functions_t * object_table) +void Device_Init( + object_functions_t * object_table) { struct my_object_functions *pObject = NULL; /* not using the standard table - using our own */ - (void)object_table; + (void) object_table; pObject = &Object_Table[0]; while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) { if (pObject->Object_Init) { diff --git a/bacnet-stack/ports/stm32f10x/bo.c b/bacnet-stack/ports/stm32f10x/bo.c index d34f1c3b..c38ed1e4 100644 --- a/bacnet-stack/ports/stm32f10x/bo.c +++ b/bacnet-stack/ports/stm32f10x/bo.c @@ -430,8 +430,8 @@ bool Binary_Output_Write_Property( priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; - Binary_Output_Present_Value_Set - (wp_data->object_instance, level, priority); + Binary_Output_Present_Value_Set(wp_data-> + object_instance, level, priority); } else if (priority == 6) { status = false; /* Command priority 6 is reserved for use by Minimum On/Off diff --git a/bacnet-stack/ports/stm32f10x/device.c b/bacnet-stack/ports/stm32f10x/device.c index ba68765a..0eb97e76 100644 --- a/bacnet-stack/ports/stm32f10x/device.c +++ b/bacnet-stack/ports/stm32f10x/device.c @@ -601,7 +601,7 @@ bool Device_Valid_Object_Id( } bool Device_Object_Name_Copy( - BACNET_OBJECT_TYPE object_type, + BACNET_OBJECT_TYPE object_type, uint32_t object_instance, BACNET_CHARACTER_STRING * object_name) { @@ -836,8 +836,8 @@ bool Device_Write_Property_Local( case PROP_OBJECT_IDENTIFIER: if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && - (Device_Set_Object_Instance_Number(value.type. - Object_Id.instance))) { + (Device_Set_Object_Instance_Number(value.type.Object_Id. + instance))) { /* we could send an I-Am broadcast to let the world know */ status = true; } else { @@ -889,13 +889,13 @@ bool Device_Write_Property_Local( characterstring_encoding(&value.type.Character_String); if (encoding < MAX_CHARACTER_STRING_ENCODING) { /* All the object names in a device must be unique. */ - if (Device_Valid_Object_Name(&value.type. - Character_String, NULL, NULL)) { + if (Device_Valid_Object_Name(&value. + type.Character_String, NULL, NULL)) { wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_code = ERROR_CODE_DUPLICATE_NAME; } else { - Device_Set_Object_Name(&value.type. - Character_String); + Device_Set_Object_Name(&value. + type.Character_String); status = true; } } else { diff --git a/bacnet-stack/ports/stm32f10x/dlmstp.c b/bacnet-stack/ports/stm32f10x/dlmstp.c index 99fd7ccd..5f6106e0 100644 --- a/bacnet-stack/ports/stm32f10x/dlmstp.c +++ b/bacnet-stack/ports/stm32f10x/dlmstp.c @@ -378,8 +378,7 @@ static bool MSTP_Transmit_FSM( case MSTP_TX_STATE_IDLE: if (!Ringbuf_Empty(&Transmit_Queue)) { /* get the packet - but don't remove it from queue */ - pkt = - (struct mstp_tx_packet *) + pkt = (struct mstp_tx_packet *) Ringbuf_Get_Front(&Transmit_Queue); state = MSTP_TX_STATE_SILENCE_WAIT; } @@ -1235,8 +1234,7 @@ static bool MSTP_Master_Node_FSM( Master_State = MSTP_MASTER_STATE_IDLE; /* clear our flag we were holding for comparison */ MSTP_Flag.ReceivedValidFrame = false; - } else if (rs485_silence_elapsed(Treply_delay) || - (pkt != NULL)) { + } else if (rs485_silence_elapsed(Treply_delay) || (pkt != NULL)) { /* DeferredReply */ /* If no reply will be available from the higher layers */ /* within Treply_delay after the reception of the */ diff --git a/bacnet-stack/ports/stm32f10x/rs485.c b/bacnet-stack/ports/stm32f10x/rs485.c index d85247af..96171240 100644 --- a/bacnet-stack/ports/stm32f10x/rs485.c +++ b/bacnet-stack/ports/stm32f10x/rs485.c @@ -112,7 +112,7 @@ bool rs485_receive_error( return false; } - /*********************************************************************//** + /*********************************************************************//** * @brief USARTx interrupt handler sub-routine * @param[in] None * @return None diff --git a/bacnet-stack/ports/win32/timer.c b/bacnet-stack/ports/win32/timer.c index 092df5d6..b7eaa984 100644 --- a/bacnet-stack/ports/win32/timer.c +++ b/bacnet-stack/ports/win32/timer.c @@ -95,7 +95,7 @@ int gettimeofday( time_start = timeGetTime(); } else { elapsed_milliseconds = timeGetTime() - time_start; - usec_elapsed = usec_timer + ((LONGLONG)elapsed_milliseconds * 1000UL); + usec_elapsed = usec_timer + ((LONGLONG) elapsed_milliseconds * 1000UL); tp->tv_sec = (long) (usec_elapsed / 1000000UL); tp->tv_usec = (long) (usec_elapsed % 1000000UL); } diff --git a/bacnet-stack/src/abort.c b/bacnet-stack/src/abort.c index c59bb26e..0167e07f 100644 --- a/bacnet-stack/src/abort.c +++ b/bacnet-stack/src/abort.c @@ -63,8 +63,7 @@ BACNET_ABORT_REASON abort_convert_error_code( abort_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED; break; case ERROR_CODE_ABORT_PROPRIETARY: - abort_code = - (BACNET_ABORT_REASON)FIRST_PROPRIETARY_ABORT_REASON; + abort_code = (BACNET_ABORT_REASON) FIRST_PROPRIETARY_ABORT_REASON; break; case ERROR_CODE_ABORT_OTHER: default: diff --git a/bacnet-stack/src/address.c b/bacnet-stack/src/address.c index 94b18295..88cdc811 100644 --- a/bacnet-stack/src/address.c +++ b/bacnet-stack/src/address.c @@ -149,8 +149,7 @@ static struct Address_Cache_Entry *address_remove_oldest( pMatch = Address_Cache; while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { - if ((pMatch-> - Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | + if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) { if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ ulTime = pMatch->TimeToLive; @@ -169,8 +168,7 @@ static struct Address_Cache_Entry *address_remove_oldest( /* Second pass - try in use and un bound as last resort */ pMatch = Address_Cache; while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { - if ((pMatch-> - Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | + if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | BAC_ADDR_STATIC)) == ((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) { if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ @@ -206,10 +204,11 @@ static void address_file_init( long device_id = 0; int snet = 0; unsigned max_apdu = 0; - unsigned mac[6] = {0}; + unsigned mac[6] = { 0 }; int count = 0; - char mac_string[80] = {""}, sadr_string[80] = {""}; - BACNET_ADDRESS src = {0}; + char mac_string[80] = { "" }, sadr_string[80] = { + ""}; + BACNET_ADDRESS src = { 0 }; int index = 0; pFile = fopen(pFilename, "r"); @@ -230,8 +229,9 @@ static void address_file_init( src.net = (uint16_t) snet; if (snet) { count = - sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x", &mac[0], - &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); + sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x", + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], + &mac[5]); src.len = (uint8_t) count; for (index = 0; index < MAX_MAC_LEN; index++) { src.adr[index] = (uint8_t) mac[index]; diff --git a/bacnet-stack/src/apdu.c b/bacnet-stack/src/apdu.c index 3844c80e..6ac2e6ad 100644 --- a/bacnet-stack/src/apdu.c +++ b/bacnet-stack/src/apdu.c @@ -46,10 +46,10 @@ /** @file apdu.c Handles APDU services */ extern int Routed_Device_Service_Approval( - BACNET_CONFIRMED_SERVICE service, - int service_argument, - uint8_t *apdu_buff, - uint8_t invoke_id ); + BACNET_CONFIRMED_SERVICE service, + int service_argument, + uint8_t * apdu_buff, + uint8_t invoke_id); /* APDU Timeout in Milliseconds */ @@ -155,11 +155,12 @@ bool apdu_service_supported( found = true; if (Confirmed_Function[i] != NULL) { #if BAC_ROUTING - /* Check to see if the current Device supports this service. */ - int len = Routed_Device_Service_Approval( - service_supported, 0, NULL, 0); - if ( len > 0 ) - break; /* Not supported - return false */ + /* Check to see if the current Device supports this service. */ + int len = + Routed_Device_Service_Approval(service_supported, 0, + NULL, 0); + if (len > 0) + break; /* Not supported - return false */ #endif status = true; diff --git a/bacnet-stack/src/bacapp.c b/bacnet-stack/src/bacapp.c index 260b1416..0c2d177b 100644 --- a/bacnet-stack/src/bacapp.c +++ b/bacnet-stack/src/bacapp.c @@ -264,8 +264,7 @@ int bacapp_decode_data( } } - if ((len == 0) && - (tag_data_type != BACNET_APPLICATION_TAG_NULL) && + if ((len == 0) && (tag_data_type != BACNET_APPLICATION_TAG_NULL) && (tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) && (tag_data_type != BACNET_APPLICATION_TAG_OCTET_STRING)) { /* indicate that we were not able to decode the value */ @@ -657,16 +656,16 @@ BACNET_APPLICATION_TAG bacapp_context_tag_type( case PROP_ACTIVE_COV_SUBSCRIPTIONS: /* BACnetCOVSubscription */ switch (tag_number) { - case 0: /* BACnetRecipientProcess */ - case 1: /* BACnetObjectPropertyReference */ + case 0: /* BACnetRecipientProcess */ + case 1: /* BACnetObjectPropertyReference */ break; - case 2: /* issueConfirmedNotifications */ + case 2: /* issueConfirmedNotifications */ tag = BACNET_APPLICATION_TAG_BOOLEAN; break; - case 3: /* timeRemaining */ + case 3: /* timeRemaining */ tag = BACNET_APPLICATION_TAG_UNSIGNED_INT; break; - case 4: /* covIncrement */ + case 4: /* covIncrement */ tag = BACNET_APPLICATION_TAG_REAL; break; default: @@ -723,7 +722,7 @@ int bacapp_decode_context_data( &len_value_type); apdu_len = tag_len; /* Empty construct : (closing tag) => returns NULL value */ - if (tag_len && ((unsigned)tag_len <= max_apdu_len) && + if (tag_len && ((unsigned) tag_len <= max_apdu_len) && !decode_is_closing_tag_number(&apdu[0], tag_number)) { value->context_tag = tag_number; value->tag = bacapp_context_tag_type(property, tag_number); @@ -739,9 +738,8 @@ int bacapp_decode_context_data( } else { apdu_len = BACNET_STATUS_ERROR; } - } - else if ( tag_len == 1 ) /* and is a Closing tag */ - apdu_len = 0; /* Don't advance over that closing tag. */ + } else if (tag_len == 1) /* and is a Closing tag */ + apdu_len = 0; /* Don't advance over that closing tag. */ } return apdu_len; @@ -961,18 +959,19 @@ int bacapp_data_len( } #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; int bytes_written; bytes_written = snprintf(*str, *rem_str_len, "%s", 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 */ retval = false; - } - else - { + } else { /* Successfully wrote the contents to the string. Let's advance the * string pointer to the end, and account for the used space */ *str += bytes_written; @@ -1016,26 +1015,27 @@ int bacapp_snprintf_value( ret_val = snprintf(str, str_len, "Null"); break; case BACNET_APPLICATION_TAG_BOOLEAN: - ret_val = (value->type.Boolean) ? - snprintf(str, str_len, "TRUE") : - snprintf(str, str_len, "FALSE"); + ret_val = + (value->type.Boolean) ? snprintf(str, str_len, + "TRUE") : snprintf(str, str_len, "FALSE"); break; 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); break; 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); break; case BACNET_APPLICATION_TAG_REAL: - ret_val = snprintf(str, str_len, "%f", - (double) value->type.Real); + ret_val = + snprintf(str, str_len, "%f", (double) value->type.Real); break; #if defined (BACAPP_DOUBLE) case BACNET_APPLICATION_TAG_DOUBLE: - ret_val = snprintf(str, str_len, "%f", - value->type.Double); + ret_val = snprintf(str, str_len, "%f", value->type.Double); break; #endif case BACNET_APPLICATION_TAG_OCTET_STRING: @@ -1047,15 +1047,15 @@ int bacapp_snprintf_value( break; octet_str++; } - if (i == len) - { + if (i == len) { // Everything went fine ret_val = str_len - rem_str_len; } break; case BACNET_APPLICATION_TAG_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, "\"")) break; for (i = 0; i < len; i++) { @@ -1068,10 +1068,8 @@ int bacapp_snprintf_value( break; char_str++; } - if ( (i == len) && - append_str(&p_str, &rem_str_len, "\"") - ) - { + if ((i == len) && append_str(&p_str, &rem_str_len, "\"") + ) { // Everything is fine. Indicate how many bytes were // written ret_val = str_len - rem_str_len; @@ -1087,16 +1085,13 @@ int bacapp_snprintf_value( (uint8_t) i) ? "true" : "false"); if (!append_str(&p_str, &rem_str_len, temp_str)) break; - if (i < len - 1) - { + if (i < len - 1) { if (!append_str(&p_str, &rem_str_len, ",")) break; } } - if ( (i == len) && - append_str(&p_str, &rem_str_len, "}") - ) - { + if ((i == len) && append_str(&p_str, &rem_str_len, "}") + ) { // Everything is fine. Indicate how many bytes were // written ret_val = str_len - rem_str_len; @@ -1106,83 +1101,97 @@ int bacapp_snprintf_value( switch (property) { case PROP_OBJECT_TYPE: if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) { - ret_val = snprintf(str, str_len, "%s", - bactext_object_type_name(value->type. - Enumerated)); + ret_val = + snprintf(str, str_len, "%s", + bactext_object_type_name(value-> + type.Enumerated)); } 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); } else { - ret_val = snprintf(str, str_len, "proprietary %lu", + ret_val = + snprintf(str, str_len, "proprietary %lu", (unsigned long) value->type.Enumerated); } break; 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)); break; case PROP_UNITS: if (value->type.Enumerated < 256) { - ret_val = snprintf(str, str_len, "%s", - bactext_engineering_unit_name(value-> - type.Enumerated)); + ret_val = + snprintf(str, str_len, "%s", + bactext_engineering_unit_name(value->type. + Enumerated)); } else { - ret_val = snprintf(str, str_len, "proprietary %lu", + ret_val = + snprintf(str, str_len, "proprietary %lu", (unsigned long) value->type.Enumerated); } break; case PROP_POLARITY: - ret_val = snprintf(str, str_len, "%s", - bactext_binary_polarity_name(value-> - type.Enumerated)); + ret_val = + snprintf(str, str_len, "%s", + bactext_binary_polarity_name(value->type. + Enumerated)); break; case PROP_PRESENT_VALUE: case PROP_RELINQUISH_DEFAULT: if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) { - ret_val = snprintf(str, str_len, "%s", - bactext_binary_present_value_name(value->type. - Enumerated)); + ret_val = + snprintf(str, str_len, "%s", + bactext_binary_present_value_name(value-> + type.Enumerated)); } else { - ret_val = snprintf(str, str_len, "%lu", + ret_val = + snprintf(str, str_len, "%lu", (unsigned long) value->type.Enumerated); } break; case PROP_RELIABILITY: - ret_val = snprintf(str, str_len, "%s", + ret_val = + snprintf(str, str_len, "%s", bactext_reliability_name(value->type.Enumerated)); break; case PROP_SYSTEM_STATUS: - ret_val = snprintf(str, str_len, "%s", - bactext_device_status_name(value-> - type.Enumerated)); + ret_val = + snprintf(str, str_len, "%s", + bactext_device_status_name(value->type. + Enumerated)); break; case PROP_SEGMENTATION_SUPPORTED: - ret_val = snprintf(str, str_len, "%s", + ret_val = + snprintf(str, str_len, "%s", bactext_segmentation_name(value->type.Enumerated)); break; 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)); break; default: - ret_val = snprintf(str, str_len, "%lu", + ret_val = + snprintf(str, str_len, "%lu", (unsigned long) value->type.Enumerated); break; } break; case BACNET_APPLICATION_TAG_DATE: if (!append_str(&p_str, &rem_str_len, - bactext_day_of_week_name(value->type.Date.wday) - ) - ) + bactext_day_of_week_name(value->type.Date.wday) + ) + ) break; if (!append_str(&p_str, &rem_str_len, ", ")) break; if (!append_str(&p_str, &rem_str_len, - bactext_month_name(value->type.Date.month) - ) - ) + bactext_month_name(value->type.Date.month) + ) + ) break; if (value->type.Date.day == 255) { if (!append_str(&p_str, &rem_str_len, " (unspecified), ")) @@ -1252,9 +1261,10 @@ int bacapp_snprintf_value( break; if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) { 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; snprintf(temp_str, sizeof(temp_str), ", %lu", (unsigned long) value->type.Object_Id.instance); @@ -1313,22 +1323,19 @@ bool bacapp_print_value( size_t str_len = 32; int status; - while (true) - { + while (true) { // 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) break; // Try to extract the value into allocated memory. If unable, try again // another time with a string that is twice as large. status = bacapp_snprintf_value(str, str_len, object_value); - if ( (status < 0 ) || (status >= str_len) ) - { + if ((status < 0) || (status >= str_len)) { free(str); str_len *= 2; - } - else if (status == 0) { + } else if (status == 0) { free(str); break; } else { @@ -1391,7 +1398,7 @@ bool bacapp_parse_application_data( break; #endif case BACNET_APPLICATION_TAG_OCTET_STRING: -#if PRINT_ENABLED /* Apparently ain't necessarily so. */ +#if PRINT_ENABLED /* Apparently ain't necessarily so. */ status = octetstring_init_ascii_hex(&value->type.Octet_String, argv); @@ -1413,7 +1420,8 @@ bool bacapp_parse_application_data( break; case BACNET_APPLICATION_TAG_DATE: count = - sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day, &wday); + sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day, + &wday); if (count == 3) { datetime_set_date(&value->type.Date, (uint16_t) year, (uint8_t) month, (uint8_t) day); @@ -1637,8 +1645,8 @@ void testBACnetApplicationData_Safe( break; case BACNET_APPLICATION_TAG_CHARACTER_STRING: - characterstring_init_ansi(&input_value[i].type. - Character_String, "Hello There!"); + characterstring_init_ansi(&input_value[i]. + type.Character_String, "Hello There!"); break; case BACNET_APPLICATION_TAG_BIT_STRING: @@ -2113,8 +2121,8 @@ void testBACnetApplicationData( ct_test(pTest, testBACnetApplicationDataValue(&value)); /* test empty string */ status = - bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, - "", &value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, "", + &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); diff --git a/bacnet-stack/src/bacstr.c b/bacnet-stack/src/bacstr.c index d8ad3823..eab18a06 100644 --- a/bacnet-stack/src/bacstr.c +++ b/bacnet-stack/src/bacstr.c @@ -501,21 +501,21 @@ bool characterstring_printable( placed in the public domain Fall 2005 */ static const char trailingBytesForUTF8[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, - 4, 4, 4, 5, 5, 5, 5 + 4, 4, 4, 5, 5, 5, 5 }; /* based on the valid_utf8 routine from the PCRE library by Philip Hazel @@ -546,7 +546,7 @@ bool utf8_isvalid( if ((c & 0xc0) != 0xc0) { return false; } - ab = (size_t)trailingBytesForUTF8[c]; + ab = (size_t) trailingBytesForUTF8[c]; if (length < ab) { return false; } @@ -659,7 +659,7 @@ bool octetstring_init( returns true if successfully converted and fits; false if too long */ bool octetstring_init_ascii_hex( BACNET_OCTET_STRING * octet_string, - const char * ascii_hex) + const char *ascii_hex) { bool status = false; /* return value */ unsigned index = 0; /* offset into buffer */ @@ -678,16 +678,16 @@ bool octetstring_init_ascii_hex( index++; continue; } - if (ascii_hex[index+1] == 0) { + if (ascii_hex[index + 1] == 0) { break; } hex_pair_string[0] = ascii_hex[index]; - hex_pair_string[1] = ascii_hex[index+1]; - value = (uint8_t)strtol(hex_pair_string, NULL, 16); + hex_pair_string[1] = ascii_hex[index + 1]; + value = (uint8_t) strtol(hex_pair_string, NULL, 16); if (octet_string->length <= MAX_OCTET_STRING_BYTES) { octet_string->value[octet_string->length] = value; octet_string->length++; - /* at least one pair was decoded */ + /* at least one pair was decoded */ status = true; } else { break; diff --git a/bacnet-stack/src/bactext.c b/bacnet-stack/src/bactext.c index fc5e4e83..6edf65bc 100644 --- a/bacnet-stack/src/bactext.c +++ b/bacnet-stack/src/bactext.c @@ -929,7 +929,8 @@ INDTEXT_DATA bacnet_property_names[] = { , {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"} , diff --git a/bacnet-stack/src/bip.c b/bacnet-stack/src/bip.c index 998ee58f..aae6fb74 100644 --- a/bacnet-stack/src/bip.c +++ b/bacnet-stack/src/bip.c @@ -262,8 +262,7 @@ uint16_t bip_receive( if (pdu[0] != BVLL_TYPE_BACNET_IP) 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. */ #if PRINT_ENABLED fprintf(stderr, "BIP: BVLC discarded!\n"); diff --git a/bacnet-stack/src/bvlc.c b/bacnet-stack/src/bvlc.c index 0a838296..d7a53411 100644 --- a/bacnet-stack/src/bvlc.c +++ b/bacnet-stack/src/bvlc.c @@ -59,7 +59,7 @@ static struct sockaddr_in Remote_BBMD; BACNET_BVLC_RESULT BVLC_Result_Code = BVLC_RESULT_SUCCESSFUL_COMPLETION; /** The current BVLC Function Code being handled. */ -BACNET_BVLC_FUNCTION BVLC_Function_Code = BVLC_RESULT; /* A safe default */ +BACNET_BVLC_FUNCTION BVLC_Function_Code = BVLC_RESULT; /* A safe default */ /* Define BBMD_ENABLED to get the functions that a * BBMD needs to handle its services. @@ -665,8 +665,8 @@ static void bvlc_bdt_forward_npdu( mask in the BDT entry and logically ORing it with the BBMD address of the same entry. */ bip_dest.sin_addr.s_addr = - ((~BBMD_Table[i].broadcast_mask. - s_addr) | BBMD_Table[i].dest_address.s_addr); + ((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i]. + dest_address.s_addr); bip_dest.sin_port = BBMD_Table[i].dest_port; /* don't send to my broadcast address and same port */ if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr()) @@ -1244,16 +1244,16 @@ int bvlc_register_with_bbmd( * BVLC message. If zero, may need further processing. */ int bvlc_for_non_bbmd( - struct sockaddr_in * sout, - uint8_t * npdu, - uint16_t received_bytes) + struct sockaddr_in *sout, + uint8_t * npdu, + uint16_t received_bytes) { - uint16_t result_code = 0; /* aka, BVLC_RESULT_SUCCESSFUL_COMPLETION */ + uint16_t result_code = 0; /* aka, BVLC_RESULT_SUCCESSFUL_COMPLETION */ - BVLC_Function_Code = npdu[1]; /* The BVLC function */ + BVLC_Function_Code = npdu[1]; /* The BVLC function */ switch (BVLC_Function_Code) { case BVLC_RESULT: - if ( received_bytes >= 6) { + if (received_bytes >= 6) { /* This is the result of our foreign device registration */ (void) decode_unsigned16(&npdu[4], &result_code); BVLC_Result_Code = (BACNET_BVLC_RESULT) result_code; @@ -1268,23 +1268,23 @@ int bvlc_for_non_bbmd( case BVLC_READ_BROADCAST_DIST_TABLE: result_code = BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK; break; - /* case BVLC_READ_BROADCAST_DIST_TABLE_ACK: */ + /* case BVLC_READ_BROADCAST_DIST_TABLE_ACK: */ case BVLC_REGISTER_FOREIGN_DEVICE: result_code = BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK; break; case BVLC_READ_FOREIGN_DEVICE_TABLE: result_code = BVLC_RESULT_READ_FOREIGN_DEVICE_TABLE_NAK; break; - /* case BVLC_READ_FOREIGN_DEVICE_TABLE_ACK: */ + /* case BVLC_READ_FOREIGN_DEVICE_TABLE_ACK: */ case BVLC_DELETE_FOREIGN_DEVICE_TABLE_ENTRY: result_code = BVLC_RESULT_DELETE_FOREIGN_DEVICE_TABLE_ENTRY_NAK; break; case BVLC_DISTRIBUTE_BROADCAST_TO_NETWORK: - result_code = BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK; + result_code = BVLC_RESULT_DISTRIBUTE_BROADCAST_TO_NETWORK_NAK; break; - /* case BVLC_FORWARDED_NPDU: */ - /* case BVLC_ORIGINAL_UNICAST_NPDU: */ - /* case BVLC_ORIGINAL_BROADCAST_NPDU: */ + /* case BVLC_FORWARDED_NPDU: */ + /* case BVLC_ORIGINAL_UNICAST_NPDU: */ + /* case BVLC_ORIGINAL_BROADCAST_NPDU: */ default: break; } @@ -1304,7 +1304,8 @@ int bvlc_for_non_bbmd( * BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK if registration failed, * 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; } @@ -1316,7 +1317,8 @@ BACNET_BVLC_RESULT bvlc_get_last_result(void) * * @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; } diff --git a/bacnet-stack/src/dcc.c b/bacnet-stack/src/dcc.c index 64484526..481d03de 100644 --- a/bacnet-stack/src/dcc.c +++ b/bacnet-stack/src/dcc.c @@ -127,7 +127,8 @@ bool dcc_set_status_duration( return valid; } -#if BACNET_SVC_DCC_A + +#if BACNET_SVC_DCC_A /* encode service */ int dcc_encode_apdu( uint8_t * apdu, diff --git a/bacnet-stack/src/event.c b/bacnet-stack/src/event.c index 8c3fa642..2d519864 100644 --- a/bacnet-stack/src/event.c +++ b/bacnet-stack/src/event.c @@ -192,14 +192,14 @@ int event_notify_encode_service_request( len = encode_context_bitstring(&apdu[apdu_len], 0, - &data->notificationParams. - changeOfBitstring.referencedBitString); + &data->notificationParams.changeOfBitstring. + referencedBitString); apdu_len += len; len = encode_context_bitstring(&apdu[apdu_len], 1, - &data->notificationParams. - changeOfBitstring.statusFlags); + &data->notificationParams.changeOfBitstring. + statusFlags); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 0); @@ -223,8 +223,8 @@ int event_notify_encode_service_request( len = encode_context_bitstring(&apdu[apdu_len], 1, - &data->notificationParams. - changeOfState.statusFlags); + &data->notificationParams.changeOfState. + statusFlags); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 1); @@ -242,8 +242,8 @@ int event_notify_encode_service_request( case CHANGE_OF_VALUE_REAL: len = encode_context_real(&apdu[apdu_len], 1, - data->notificationParams. - changeOfValue.newValue.changeValue); + data->notificationParams.changeOfValue. + newValue.changeValue); apdu_len += len; break; @@ -251,8 +251,8 @@ int event_notify_encode_service_request( len = encode_context_bitstring(&apdu[apdu_len], 0, - &data->notificationParams. - changeOfValue.newValue.changedBits); + &data->notificationParams.changeOfValue. + newValue.changedBits); apdu_len += len; break; @@ -265,8 +265,8 @@ int event_notify_encode_service_request( len = encode_context_bitstring(&apdu[apdu_len], 1, - &data->notificationParams. - changeOfValue.statusFlags); + &data->notificationParams.changeOfValue. + statusFlags); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 2); @@ -280,20 +280,20 @@ int event_notify_encode_service_request( len = encode_context_real(&apdu[apdu_len], 0, - data->notificationParams. - floatingLimit.referenceValue); + data->notificationParams.floatingLimit. + referenceValue); apdu_len += len; len = encode_context_bitstring(&apdu[apdu_len], 1, - &data->notificationParams. - floatingLimit.statusFlags); + &data->notificationParams.floatingLimit. + statusFlags); apdu_len += len; len = encode_context_real(&apdu[apdu_len], 2, - data->notificationParams. - floatingLimit.setPointValue); + data->notificationParams.floatingLimit. + setPointValue); apdu_len += len; len = @@ -312,8 +312,8 @@ int event_notify_encode_service_request( len = encode_context_real(&apdu[apdu_len], 0, - data->notificationParams. - outOfRange.exceedingValue); + data->notificationParams.outOfRange. + exceedingValue); apdu_len += len; len = @@ -341,26 +341,26 @@ int event_notify_encode_service_request( len = encode_context_enumerated(&apdu[apdu_len], 0, - data->notificationParams. - changeOfLifeSafety.newState); + data->notificationParams.changeOfLifeSafety. + newState); apdu_len += len; len = encode_context_enumerated(&apdu[apdu_len], 1, - data->notificationParams. - changeOfLifeSafety.newMode); + data->notificationParams.changeOfLifeSafety. + newMode); apdu_len += len; len = encode_context_bitstring(&apdu[apdu_len], 2, - &data->notificationParams. - changeOfLifeSafety.statusFlags); + &data->notificationParams.changeOfLifeSafety. + statusFlags); apdu_len += len; len = encode_context_enumerated(&apdu[apdu_len], 3, - data->notificationParams. - changeOfLifeSafety.operationExpected); + data->notificationParams.changeOfLifeSafety. + operationExpected); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 8); @@ -374,20 +374,20 @@ int event_notify_encode_service_request( len = bacapp_encode_context_device_obj_property_ref(&apdu [apdu_len], 0, - &data->notificationParams. - bufferReady.bufferProperty); + &data->notificationParams.bufferReady. + bufferProperty); apdu_len += len; len = encode_context_unsigned(&apdu[apdu_len], 1, - data->notificationParams. - bufferReady.previousNotification); + data->notificationParams.bufferReady. + previousNotification); apdu_len += len; len = encode_context_unsigned(&apdu[apdu_len], 2, - data->notificationParams. - bufferReady.currentNotification); + data->notificationParams.bufferReady. + currentNotification); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 10); @@ -399,20 +399,20 @@ int event_notify_encode_service_request( len = encode_context_unsigned(&apdu[apdu_len], 0, - data->notificationParams. - unsignedRange.exceedingValue); + data->notificationParams.unsignedRange. + exceedingValue); apdu_len += len; len = encode_context_bitstring(&apdu[apdu_len], 1, - &data->notificationParams. - unsignedRange.statusFlags); + &data->notificationParams.unsignedRange. + statusFlags); apdu_len += len; len = encode_context_unsigned(&apdu[apdu_len], 2, - data->notificationParams. - unsignedRange.exceededLimit); + data->notificationParams.unsignedRange. + exceededLimit); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 11); @@ -595,18 +595,16 @@ int event_notify_decode_service_request( case EVENT_CHANGE_OF_BITSTRING: if (-1 == (section_length = decode_context_bitstring(&apdu[len], 0, - &data-> - notificationParams.changeOfBitstring. - referencedBitString))) { + &data->notificationParams. + changeOfBitstring.referencedBitString))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_bitstring(&apdu[len], 1, - &data-> - notificationParams.changeOfBitstring. - statusFlags))) { + &data->notificationParams. + changeOfBitstring.statusFlags))) { return -1; } len += section_length; @@ -617,16 +615,16 @@ int event_notify_decode_service_request( if (-1 == (section_length = bacapp_decode_context_property_state(&apdu [len], 0, - &data->notificationParams. - changeOfState.newState))) { + &data->notificationParams.changeOfState. + newState))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_bitstring(&apdu[len], 1, - &data->notificationParams. - changeOfState.statusFlags))) { + &data->notificationParams.changeOfState. + statusFlags))) { return -1; } len += section_length; @@ -644,9 +642,8 @@ int event_notify_decode_service_request( if (-1 == (section_length = decode_context_bitstring(&apdu[len], 0, - &data-> - notificationParams.changeOfValue. - newValue.changedBits))) { + &data->notificationParams. + changeOfValue.newValue.changedBits))) { return -1; } @@ -657,9 +654,8 @@ int event_notify_decode_service_request( CHANGE_OF_VALUE_REAL)) { if (-1 == (section_length = decode_context_real(&apdu[len], 1, - &data-> - notificationParams.changeOfValue. - newValue.changeValue))) { + &data->notificationParams. + changeOfValue.newValue.changeValue))) { return -1; } @@ -677,8 +673,8 @@ int event_notify_decode_service_request( if (-1 == (section_length = decode_context_bitstring(&apdu[len], 1, - &data->notificationParams. - changeOfValue.statusFlags))) { + &data->notificationParams.changeOfValue. + statusFlags))) { return -1; } len += section_length; @@ -687,31 +683,31 @@ int event_notify_decode_service_request( case EVENT_FLOATING_LIMIT: if (-1 == (section_length = decode_context_real(&apdu[len], 0, - &data->notificationParams. - floatingLimit.referenceValue))) { + &data->notificationParams.floatingLimit. + referenceValue))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_bitstring(&apdu[len], 1, - &data->notificationParams. - floatingLimit.statusFlags))) { + &data->notificationParams.floatingLimit. + statusFlags))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_real(&apdu[len], 2, - &data->notificationParams. - floatingLimit.setPointValue))) { + &data->notificationParams.floatingLimit. + setPointValue))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_real(&apdu[len], 3, - &data->notificationParams. - floatingLimit.errorLimit))) { + &data->notificationParams.floatingLimit. + errorLimit))) { return -1; } len += section_length; @@ -720,31 +716,31 @@ int event_notify_decode_service_request( case EVENT_OUT_OF_RANGE: if (-1 == (section_length = decode_context_real(&apdu[len], 0, - &data->notificationParams. - outOfRange.exceedingValue))) { + &data->notificationParams.outOfRange. + exceedingValue))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_bitstring(&apdu[len], 1, - &data->notificationParams. - outOfRange.statusFlags))) { + &data->notificationParams.outOfRange. + statusFlags))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_real(&apdu[len], 2, - &data->notificationParams. - outOfRange.deadband))) { + &data->notificationParams.outOfRange. + deadband))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_real(&apdu[len], 3, - &data->notificationParams. - outOfRange.exceededLimit))) { + &data->notificationParams.outOfRange. + exceededLimit))) { return -1; } len += section_length; @@ -772,9 +768,8 @@ int event_notify_decode_service_request( if (-1 == (section_length = decode_context_bitstring(&apdu[len], 2, - &data-> - notificationParams.changeOfLifeSafety. - statusFlags))) { + &data->notificationParams. + changeOfLifeSafety.statusFlags))) { return -1; } len += section_length; @@ -784,8 +779,8 @@ int event_notify_decode_service_request( &value))) { return -1; } - data->notificationParams. - changeOfLifeSafety.operationExpected = + data->notificationParams.changeOfLifeSafety. + operationExpected = (BACNET_LIFE_SAFETY_OPERATION) value; len += section_length; break; @@ -794,24 +789,24 @@ int event_notify_decode_service_request( if (-1 == (section_length = bacapp_decode_context_device_obj_property_ref (&apdu[len], 0, - &data->notificationParams. - bufferReady.bufferProperty))) { + &data->notificationParams.bufferReady. + bufferProperty))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_unsigned(&apdu[len], 1, - &data->notificationParams. - bufferReady.previousNotification))) { + &data->notificationParams.bufferReady. + previousNotification))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_unsigned(&apdu[len], 2, - &data->notificationParams. - bufferReady.currentNotification))) { + &data->notificationParams.bufferReady. + currentNotification))) { return -1; } len += section_length; @@ -820,24 +815,24 @@ int event_notify_decode_service_request( case EVENT_UNSIGNED_RANGE: if (-1 == (section_length = decode_context_unsigned(&apdu[len], 0, - &data->notificationParams. - unsignedRange.exceedingValue))) { + &data->notificationParams.unsignedRange. + exceedingValue))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_bitstring(&apdu[len], 1, - &data->notificationParams. - unsignedRange.statusFlags))) { + &data->notificationParams.unsignedRange. + statusFlags))) { return -1; } len += section_length; if (-1 == (section_length = decode_context_unsigned(&apdu[len], 2, - &data->notificationParams. - unsignedRange.exceededLimit))) { + &data->notificationParams.unsignedRange. + exceededLimit))) { return -1; } len += section_length; @@ -1083,16 +1078,16 @@ void testEventEventState( data.eventType = EVENT_CHANGE_OF_BITSTRING; - bitstring_init(&data.notificationParams. - changeOfBitstring.referencedBitString); - bitstring_set_bit(&data.notificationParams. - changeOfBitstring.referencedBitString, 0, true); - bitstring_set_bit(&data.notificationParams. - changeOfBitstring.referencedBitString, 1, false); - bitstring_set_bit(&data.notificationParams. - changeOfBitstring.referencedBitString, 2, true); - bitstring_set_bit(&data.notificationParams. - changeOfBitstring.referencedBitString, 2, false); + bitstring_init(&data.notificationParams.changeOfBitstring. + referencedBitString); + bitstring_set_bit(&data.notificationParams.changeOfBitstring. + referencedBitString, 0, true); + bitstring_set_bit(&data.notificationParams.changeOfBitstring. + referencedBitString, 1, false); + bitstring_set_bit(&data.notificationParams.changeOfBitstring. + referencedBitString, 2, true); + bitstring_set_bit(&data.notificationParams.changeOfBitstring. + referencedBitString, 2, false); bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags); @@ -1116,8 +1111,8 @@ void testEventEventState( testBaseEventState(pTest); ct_test(pTest, - bitstring_same(&data.notificationParams.changeOfBitstring. - referencedBitString, + bitstring_same(&data.notificationParams. + changeOfBitstring.referencedBitString, &data2.notificationParams.changeOfBitstring.referencedBitString)); ct_test(pTest, @@ -1180,16 +1175,16 @@ void testEventEventState( data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS; - bitstring_init(&data.notificationParams.changeOfValue. - newValue.changedBits); - bitstring_set_bit(&data.notificationParams.changeOfValue. - newValue.changedBits, 0, true); - bitstring_set_bit(&data.notificationParams.changeOfValue. - newValue.changedBits, 1, false); - bitstring_set_bit(&data.notificationParams.changeOfValue. - newValue.changedBits, 2, false); - bitstring_set_bit(&data.notificationParams.changeOfValue. - newValue.changedBits, 3, false); + bitstring_init(&data.notificationParams.changeOfValue.newValue. + changedBits); + bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. + changedBits, 0, true); + bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. + changedBits, 1, false); + bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. + changedBits, 2, false); + bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. + changedBits, 3, false); memset(buffer, 0, MAX_APDU); inLen = event_notify_encode_service_request(&buffer[0], &data); @@ -1210,8 +1205,8 @@ void testEventEventState( data2.notificationParams.changeOfValue.tag); ct_test(pTest, - bitstring_same(&data.notificationParams.changeOfValue.newValue. - changedBits, + bitstring_same(&data.notificationParams.changeOfValue. + newValue.changedBits, &data2.notificationParams.changeOfValue.newValue.changedBits)); /**********************************************************************************/ @@ -1434,12 +1429,12 @@ void testEventEventState( data.notificationParams.bufferReady.currentNotification = 2345; data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type = OBJECT_DEVICE; - data.notificationParams.bufferReady.bufferProperty. - deviceIndentifier.instance = 500; + data.notificationParams.bufferReady.bufferProperty.deviceIndentifier. + instance = 500; data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type = OBJECT_ANALOG_INPUT; - data.notificationParams.bufferReady.bufferProperty. - objectIdentifier.instance = 100; + data.notificationParams.bufferReady.bufferProperty.objectIdentifier. + instance = 100; data.notificationParams.bufferReady.bufferProperty.propertyIdentifier = PROP_PRESENT_VALUE; data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0; @@ -1464,34 +1459,34 @@ void testEventEventState( ct_test(pTest, - data.notificationParams.bufferReady.bufferProperty. - deviceIndentifier.type == - data2.notificationParams.bufferReady.bufferProperty. - deviceIndentifier.type); + data.notificationParams.bufferReady.bufferProperty.deviceIndentifier. + type == + data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier. + type); + + ct_test(pTest, + data.notificationParams.bufferReady.bufferProperty.deviceIndentifier. + instance == + data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier. + instance); + + ct_test(pTest, + data.notificationParams.bufferReady.bufferProperty.objectIdentifier. + instance == + data2.notificationParams.bufferReady.bufferProperty.objectIdentifier. + instance); + + ct_test(pTest, + data.notificationParams.bufferReady.bufferProperty.objectIdentifier. + type == + data2.notificationParams.bufferReady.bufferProperty.objectIdentifier. + type); ct_test(pTest, data.notificationParams.bufferReady.bufferProperty. - deviceIndentifier.instance == + propertyIdentifier == 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, - data.notificationParams.bufferReady. - bufferProperty.propertyIdentifier == - data2.notificationParams.bufferReady. - bufferProperty.propertyIdentifier); + propertyIdentifier); ct_test(pTest, data.notificationParams.bufferReady.bufferProperty.arrayIndex == diff --git a/bacnet-stack/src/fifo.c b/bacnet-stack/src/fifo.c index 5123f65b..877a7c21 100755 --- a/bacnet-stack/src/fifo.c +++ b/bacnet-stack/src/fifo.c @@ -229,7 +229,7 @@ bool FIFO_Add( void FIFO_Flush( FIFO_BUFFER * b) { - unsigned head; /* used to avoid volatile decision */ + unsigned head; /* used to avoid volatile decision */ if (b) { head = b->head; @@ -271,10 +271,10 @@ void FIFO_Init( void testFIFOBuffer( Test * pTest) { - FIFO_BUFFER test_buffer = {0}; - volatile uint8_t data_store[FIFO_BUFFER_SIZE] = {0}; + FIFO_BUFFER test_buffer = { 0 }; + volatile uint8_t data_store[FIFO_BUFFER_SIZE] = { 0 }; uint8_t add_data[40] = { "RoseSteveLouPatRachelJessicaDaniAmyHerb" }; - uint8_t test_add_data[40] = {0}; + uint8_t test_add_data[40] = { 0 }; uint8_t test_data = 0; unsigned index = 0; unsigned count = 0; diff --git a/bacnet-stack/src/get_alarm_sum.c b/bacnet-stack/src/get_alarm_sum.c index 5af8aea4..181d830e 100644 --- a/bacnet-stack/src/get_alarm_sum.c +++ b/bacnet-stack/src/get_alarm_sum.c @@ -37,7 +37,7 @@ int get_alarm_summary_ack_encode_apdu_init( if (apdu) { apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */ - apdu[1] = invoke_id; /* original invoke id from request */ + apdu[1] = invoke_id; /* original invoke id from request */ apdu[2] = SERVICE_CONFIRMED_GET_ALARM_SUMMARY; apdu_len = 3; } @@ -54,20 +54,21 @@ int get_alarm_sumary_ack_encode_apdu_data( if (!apdu) { apdu_len = BACNET_STATUS_ERROR; - } - else if(max_apdu >= 10) { + } else if (max_apdu >= 10) { /* tag 0 - Object Identifier */ - apdu_len += encode_application_object_id(&apdu[apdu_len], - (int)get_alarm_data->objectIdentifier.type, - get_alarm_data->objectIdentifier.instance); + apdu_len += + encode_application_object_id(&apdu[apdu_len], + (int) get_alarm_data->objectIdentifier.type, + get_alarm_data->objectIdentifier.instance); /* tag 1 - Alarm State */ - apdu_len += encode_application_enumerated(&apdu[apdu_len], - get_alarm_data->alarmState); + apdu_len += + encode_application_enumerated(&apdu[apdu_len], + get_alarm_data->alarmState); /* tag 2 - Acknowledged Transitions */ - apdu_len += encode_application_bitstring(&apdu[apdu_len], - &get_alarm_data->acknowledgedTransitions); - } - else { + apdu_len += + encode_application_bitstring(&apdu[apdu_len], + &get_alarm_data->acknowledgedTransitions); + } else { apdu_len = BACNET_STATUS_ABORT; } diff --git a/bacnet-stack/src/memcopy.c b/bacnet-stack/src/memcopy.c index 8da372a3..415ca4fb 100644 --- a/bacnet-stack/src/memcopy.c +++ b/bacnet-stack/src/memcopy.c @@ -53,8 +53,8 @@ size_t memcopy( // s1 = dest; // s2 = src; if (len <= (max - offset)) { - memcpy(&((char *)dest)[offset], src, len); - return(len); + memcpy(&((char *) dest)[offset], src, len); + return (len); // for (i = 0; i < len; i++) { // s1[offset + i] = s2[i]; // copy_len++; diff --git a/bacnet-stack/src/mstp.c b/bacnet-stack/src/mstp.c index 0cd6fb23..a26b6489 100644 --- a/bacnet-stack/src/mstp.c +++ b/bacnet-stack/src/mstp.c @@ -1096,7 +1096,7 @@ bool MSTP_Master_Node_FSM( } void MSTP_Slave_Node_FSM( - volatile struct mstp_port_struct_t * mstp_port) + volatile struct mstp_port_struct_t *mstp_port) { unsigned length = 0; @@ -1140,13 +1140,9 @@ void MSTP_Slave_Node_FSM( break; case FRAME_TYPE_TEST_REQUEST: mstp_port->ReceivedValidFrame = false; - MSTP_Create_And_Send_Frame( - mstp_port, - FRAME_TYPE_TEST_RESPONSE, - mstp_port->SourceAddress, - mstp_port->This_Station, - &mstp_port->InputBuffer[0], - mstp_port->DataLength); + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_RESPONSE, + mstp_port->SourceAddress, mstp_port->This_Station, + &mstp_port->InputBuffer[0], mstp_port->DataLength); break; case FRAME_TYPE_TOKEN: case FRAME_TYPE_POLL_FOR_MASTER: diff --git a/bacnet-stack/src/npdu.c b/bacnet-stack/src/npdu.c index 515a08c2..b42c3b2d 100644 --- a/bacnet-stack/src/npdu.c +++ b/bacnet-stack/src/npdu.c @@ -409,12 +409,12 @@ int npdu_decode( } } } else if (src) { - /* Clear the net number, with one exception: if the receive() - * function set it to BACNET_BROADCAST_NETWORK, (eg, for - * BVLC_ORIGINAL_BROADCAST_NPDU) then don't stomp on that. - */ - if ( src->net != BACNET_BROADCAST_NETWORK ) - src->net = 0; + /* Clear the net number, with one exception: if the receive() + * function set it to BACNET_BROADCAST_NETWORK, (eg, for + * BVLC_ORIGINAL_BROADCAST_NPDU) then don't stomp on that. + */ + if (src->net != BACNET_BROADCAST_NETWORK) + src->net = 0; src->len = 0; for (i = 0; i < MAX_MAC_LEN; i++) { src->adr[i] = 0; diff --git a/bacnet-stack/src/proplist.c b/bacnet-stack/src/proplist.c index d0615dda..ba8b730b 100644 --- a/bacnet-stack/src/proplist.c +++ b/bacnet-stack/src/proplist.c @@ -708,71 +708,49 @@ void property_list_special( pPropertyList->Proprietary.pList = NULL; switch (object_type) { case OBJECT_DEVICE: - pPropertyList->Required.pList = - Device_Properties_Required; - pPropertyList->Optional.pList = - Device_Properties_Optional; + pPropertyList->Required.pList = Device_Properties_Required; + pPropertyList->Optional.pList = Device_Properties_Optional; break; break; case OBJECT_ACCUMULATOR: - pPropertyList->Required.pList = - Accumulator_Properties_Required; - pPropertyList->Optional.pList = - Accumulator_Properties_Optional; + pPropertyList->Required.pList = Accumulator_Properties_Required; + pPropertyList->Optional.pList = Accumulator_Properties_Optional; break; case OBJECT_ANALOG_INPUT: - pPropertyList->Required.pList = - Analog_Input_Properties_Required; - pPropertyList->Optional.pList = - Analog_Input_Properties_Optional; + pPropertyList->Required.pList = Analog_Input_Properties_Required; + pPropertyList->Optional.pList = Analog_Input_Properties_Optional; break; case OBJECT_ANALOG_OUTPUT: - pPropertyList->Required.pList = - Analog_Output_Properties_Required; - pPropertyList->Optional.pList = - Analog_Output_Properties_Optional; + pPropertyList->Required.pList = Analog_Output_Properties_Required; + pPropertyList->Optional.pList = Analog_Output_Properties_Optional; break; case OBJECT_ANALOG_VALUE: - pPropertyList->Required.pList = - Analog_Value_Properties_Required; - pPropertyList->Optional.pList = - Analog_Value_Properties_Optional; + pPropertyList->Required.pList = Analog_Value_Properties_Required; + pPropertyList->Optional.pList = Analog_Value_Properties_Optional; break; case OBJECT_AVERAGING: - pPropertyList->Required.pList = - Averaging_Properties_Required; - pPropertyList->Optional.pList = - Averaging_Properties_Optional; + pPropertyList->Required.pList = Averaging_Properties_Required; + pPropertyList->Optional.pList = Averaging_Properties_Optional; break; case OBJECT_BINARY_INPUT: - pPropertyList->Required.pList = - Binary_Input_Properties_Required; - pPropertyList->Optional.pList = - Binary_Input_Properties_Optional; + pPropertyList->Required.pList = Binary_Input_Properties_Required; + pPropertyList->Optional.pList = Binary_Input_Properties_Optional; break; case OBJECT_BINARY_OUTPUT: - pPropertyList->Required.pList = - Binary_Output_Properties_Required; - pPropertyList->Optional.pList = - Binary_Output_Properties_Optional; + pPropertyList->Required.pList = Binary_Output_Properties_Required; + pPropertyList->Optional.pList = Binary_Output_Properties_Optional; break; case OBJECT_BINARY_VALUE: - pPropertyList->Required.pList = - Binary_Value_Properties_Required; - pPropertyList->Optional.pList = - Binary_Value_Properties_Optional; + pPropertyList->Required.pList = Binary_Value_Properties_Required; + pPropertyList->Optional.pList = Binary_Value_Properties_Optional; break; case OBJECT_CALENDAR: - pPropertyList->Required.pList = - Calendar_Properties_Required; - pPropertyList->Optional.pList = - Calendar_Properties_Optional; + pPropertyList->Required.pList = Calendar_Properties_Required; + pPropertyList->Optional.pList = Calendar_Properties_Optional; break; case OBJECT_COMMAND: - pPropertyList->Required.pList = - Command_Properties_Required; - pPropertyList->Optional.pList = - Command_Properties_Optional; + pPropertyList->Required.pList = Command_Properties_Required; + pPropertyList->Optional.pList = Command_Properties_Optional; break; case OBJECT_CHARACTERSTRING_VALUE: pPropertyList->Required.pList = @@ -781,10 +759,8 @@ void property_list_special( CharacterString_Value_Properties_Optional; break; case OBJECT_LOAD_CONTROL: - pPropertyList->Required.pList = - Load_Control_Properties_Required; - pPropertyList->Optional.pList = - Load_Control_Properties_Optional; + pPropertyList->Required.pList = Load_Control_Properties_Required; + pPropertyList->Optional.pList = Load_Control_Properties_Optional; break; case OBJECT_LIFE_SAFETY_POINT: pPropertyList->Required.pList = @@ -817,10 +793,8 @@ void property_list_special( Notification_Class_Properties_Optional; break; case OBJECT_TRENDLOG: - pPropertyList->Required.pList = - Trend_Log_Properties_Required; - pPropertyList->Optional.pList = - Trend_Log_Properties_Optional; + pPropertyList->Required.pList = Trend_Log_Properties_Required; + pPropertyList->Optional.pList = Trend_Log_Properties_Optional; break; case OBJECT_EVENT_ENROLLMENT: case OBJECT_FILE: diff --git a/bacnet-stack/src/ptransfer.c b/bacnet-stack/src/ptransfer.c index 23c05356..2807817b 100644 --- a/bacnet-stack/src/ptransfer.c +++ b/bacnet-stack/src/ptransfer.c @@ -490,7 +490,8 @@ void test_Private_Transfer_Ack( private_data.vendorID = BACNET_VENDOR_ID; 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); ct_test(pTest, status == true); private_data_len = @@ -543,7 +544,8 @@ void test_Private_Transfer_Error( private_data.vendorID = BACNET_VENDOR_ID; 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); ct_test(pTest, status == true); private_data_len = @@ -585,16 +587,17 @@ void test_Private_Transfer_Request( uint8_t test_invoke_id = 0; int private_data_len = 0; char private_data_chunk[33] = { "00112233445566778899AABBCCDDEEFF" }; - BACNET_APPLICATION_DATA_VALUE data_value = {0}; - BACNET_APPLICATION_DATA_VALUE test_data_value = {0}; - BACNET_PRIVATE_TRANSFER_DATA private_data = {0}; - BACNET_PRIVATE_TRANSFER_DATA test_data = {0}; + BACNET_APPLICATION_DATA_VALUE data_value = { 0 }; + BACNET_APPLICATION_DATA_VALUE test_data_value = { 0 }; + BACNET_PRIVATE_TRANSFER_DATA private_data = { 0 }; + BACNET_PRIVATE_TRANSFER_DATA test_data = { 0 }; bool status = false; private_data.vendorID = BACNET_VENDOR_ID; 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); ct_test(pTest, status == true); private_data_len = @@ -638,8 +641,8 @@ void test_Unconfirmed_Private_Transfer_Request( private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - status = bacapp_parse_application_data( - BACNET_APPLICATION_TAG_CHARACTER_STRING, + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_CHARACTER_STRING, &private_data_chunk[0], &data_value); ct_test(pTest, status == true); private_data_len = diff --git a/bacnet-stack/src/reject.c b/bacnet-stack/src/reject.c index 1aea4d0b..b3a7d05b 100644 --- a/bacnet-stack/src/reject.c +++ b/bacnet-stack/src/reject.c @@ -81,7 +81,7 @@ BACNET_REJECT_REASON reject_convert_error_code( break; case ERROR_CODE_REJECT_PROPRIETARY: reject_code = - (BACNET_REJECT_REASON)FIRST_PROPRIETARY_REJECT_REASON; + (BACNET_REJECT_REASON) FIRST_PROPRIETARY_REJECT_REASON; break; case ERROR_CODE_REJECT_OTHER: default: diff --git a/bacnet-stack/src/ringbuf.c b/bacnet-stack/src/ringbuf.c index a9732414..b8500fef 100644 --- a/bacnet-stack/src/ringbuf.c +++ b/bacnet-stack/src/ringbuf.c @@ -47,15 +47,15 @@ * ALGORITHM: none * NOTES: none *****************************************************************************/ -unsigned Ringbuf_Count ( +unsigned Ringbuf_Count( RING_BUFFER const *b) { - unsigned head, tail; /* used to avoid volatile decision */ + unsigned head, tail; /* used to avoid volatile decision */ if (b) { head = b->head; tail = b->tail; - return head-tail; + return head - tail; } return 0; @@ -67,7 +67,7 @@ unsigned Ringbuf_Count ( * ALGORITHM: none * NOTES: none *****************************************************************************/ -bool Ringbuf_Full ( +bool Ringbuf_Full( RING_BUFFER const *b) { return (b ? (Ringbuf_Count(b) == b->element_count) : true); @@ -94,7 +94,7 @@ bool Ringbuf_Empty( volatile uint8_t *Ringbuf_Get_Front( RING_BUFFER const *b) { - volatile uint8_t *data_element = NULL; /* return value */ + volatile uint8_t *data_element = NULL; /* return value */ if (!Ringbuf_Empty(b)) { data_element = b->buffer; @@ -132,10 +132,10 @@ volatile uint8_t *Ringbuf_Pop_Front( *****************************************************************************/ bool Ringbuf_Put( RING_BUFFER * b, /* ring buffer structure */ - volatile uint8_t *data_element) + volatile uint8_t * data_element) { /* one element to add to the ring */ bool status = false; /* return value */ - volatile uint8_t *ring_data = NULL; /* used to help point ring data */ + volatile uint8_t *ring_data = NULL; /* used to help point ring data */ unsigned i; /* loop counter */ if (b && data_element) { @@ -161,9 +161,9 @@ bool Ringbuf_Put( * NOTES: none *****************************************************************************/ volatile uint8_t *Ringbuf_Alloc( - RING_BUFFER *b) + RING_BUFFER * b) { - volatile uint8_t *ring_data = NULL; /* used to help point ring data */ + volatile uint8_t *ring_data = NULL; /* used to help point ring data */ if (b) { /* limit the amount of elements that we accept */ @@ -186,7 +186,7 @@ volatile uint8_t *Ringbuf_Alloc( *****************************************************************************/ void Ringbuf_Init( RING_BUFFER * b, /* ring buffer structure */ - volatile uint8_t * buffer, /* data block or array of data */ + volatile uint8_t * buffer, /* data block or array of data */ unsigned element_size, /* size of one element in the data block */ unsigned element_count) { /* number of elements in the data block */ diff --git a/bacnet-stack/src/rp.c b/bacnet-stack/src/rp.c index 65a98fde..4c30f8ba 100644 --- a/bacnet-stack/src/rp.c +++ b/bacnet-stack/src/rp.c @@ -158,8 +158,7 @@ int rp_ack_encode_apdu_init( /* service ack follows */ len = - encode_context_object_id(&apdu[apdu_len], 0, - rpdata->object_type, + encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type, rpdata->object_instance); apdu_len += len; len = diff --git a/bacnet-stack/src/rpm.c b/bacnet-stack/src/rpm.c index dfdf0003..95bc3f40 100644 --- a/bacnet-stack/src/rpm.c +++ b/bacnet-stack/src/rpm.c @@ -382,9 +382,9 @@ int rpm_ack_encode_apdu_object_property_value( if (apdu) { /* Tag 4: propertyValue */ apdu_len += encode_opening_tag(&apdu[apdu_len], 4); - if (application_data == &apdu[apdu_len]) { /* Is Data already in place? */ - apdu_len += application_data_len; /* Yes, step over data */ - } else { /* No, copy data in */ + if (application_data == &apdu[apdu_len]) { /* Is Data already in place? */ + apdu_len += application_data_len; /* Yes, step over data */ + } else { /* No, copy data in */ for (len = 0; len < application_data_len; len++) { apdu[apdu_len++] = application_data[len]; } diff --git a/bacnet-stack/src/wpm.c b/bacnet-stack/src/wpm.c index ad2a369e..780a5ba5 100644 --- a/bacnet-stack/src/wpm.c +++ b/bacnet-stack/src/wpm.c @@ -67,12 +67,14 @@ int wpm_decode_object_id( apdu_len -= len; if (apdu_len >= 4) { 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_instance = object_instance; apdu_len -= len; } 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; } } else { @@ -90,7 +92,7 @@ int wpm_decode_object_id( return BACNET_STATUS_REJECT; } - return (int)len; + return (int) len; } @@ -135,7 +137,7 @@ int wpm_decode_object_property( if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) { len--; wp_data->application_data_len = - bacapp_data_len(&apdu[len], (unsigned)(apdu_len - len), + bacapp_data_len(&apdu[len], (unsigned) (apdu_len - len), wp_data->object_property); len++; @@ -174,15 +176,17 @@ int wpm_decode_object_property( } /* 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 */ if (apdu) { apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST; - apdu[1] = encode_max_segs_max_apdu (0, MAX_APDU); + apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); apdu[2] = invoke_id; - apdu[3] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE; /* service choice */ + apdu[3] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE; /* service choice */ apdu_len = 4; } @@ -190,59 +194,60 @@ 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, BACNET_OBJECT_TYPE object_type, uint32_t object_instance) { - int apdu_len = 0; /* total length of the apdu, return value */ + int apdu_len = 0; /* total length of the apdu, return value */ if (apdu) { - apdu_len = encode_context_object_id ( - &apdu[0], 0, object_type, object_instance); + apdu_len = + encode_context_object_id(&apdu[0], 0, object_type, + object_instance); /* Tag 1: sequence of WriteAccessSpecification */ - apdu_len += encode_opening_tag (&apdu[apdu_len], 1); + apdu_len += encode_opening_tag(&apdu[apdu_len], 1); } 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 */ if (apdu) { - apdu_len = encode_closing_tag (&apdu[0], 1); + apdu_len = encode_closing_tag(&apdu[0], 1); } return apdu_len; } -int wpm_encode_apdu_object_property ( +int wpm_encode_apdu_object_property( uint8_t * apdu, BACNET_WRITE_PROPERTY_DATA * wpdata) { - int apdu_len = 0; /* total length of the apdu, return value */ + int apdu_len = 0; /* total length of the apdu, return value */ int len = 0; if (apdu) { - apdu_len = encode_context_enumerated (&apdu[0], 0, - wpdata->object_property); + apdu_len = + encode_context_enumerated(&apdu[0], 0, wpdata->object_property); /* optional array index */ if (wpdata->array_index != BACNET_ARRAY_ALL) { apdu_len += - encode_context_unsigned (&apdu[apdu_len], 1, + encode_context_unsigned(&apdu[apdu_len], 1, wpdata->array_index); } - apdu_len += encode_opening_tag (&apdu[apdu_len], 2); + apdu_len += encode_opening_tag(&apdu[apdu_len], 2); for (len = 0; len < wpdata->application_data_len; len++) { apdu[apdu_len] = wpdata->application_data[len]; apdu_len++; } - apdu_len += encode_closing_tag (&apdu[apdu_len], 2); + apdu_len += encode_closing_tag(&apdu[apdu_len], 2); if (wpdata->priority != BACNET_NO_PRIORITY) { - encode_context_unsigned (&apdu[apdu_len], 3, - wpdata->priority); + encode_context_unsigned(&apdu[apdu_len], 3, wpdata->priority); } }