diff --git a/bacnet-stack/demo/handler/h_arf.c b/bacnet-stack/demo/handler/h_arf.c index f388d3b2..b5bc8e20 100644 --- a/bacnet-stack/demo/handler/h_arf.c +++ b/bacnet-stack/demo/handler/h_arf.c @@ -181,8 +181,7 @@ void handler_atomic_read_file( error = true; } else if (bacfile_read_stream_data(&data)) { #if PRINT_ENABLED - fprintf(stderr, - "ARF: fileStartRecord %d, %u RecordCount.\n", + fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n", data.type.record.fileStartRecord, data.type.record.RecordCount); #endif diff --git a/bacnet-stack/demo/handler/h_cov.c b/bacnet-stack/demo/handler/h_cov.c index eb65ef23..33a630d0 100644 --- a/bacnet-stack/demo/handler/h_cov.c +++ b/bacnet-stack/demo/handler/h_cov.c @@ -49,7 +49,7 @@ /** @file h_cov.c Handles Change of Value (COV) services. */ -typedef struct BACnet_COV_Address{ +typedef struct BACnet_COV_Address { bool valid:1; BACNET_ADDRESS dest; } BACNET_COV_ADDRESS; @@ -106,7 +106,8 @@ static BACNET_ADDRESS *cov_address_get( * Removes the address from the list of COV addresses, if it is not * used by other COV subscriptions */ -static void cov_address_remove_unused(void) +static void cov_address_remove_unused( + void) { unsigned index = 0; unsigned cov_index = 0; @@ -137,7 +138,7 @@ static void cov_address_remove_unused(void) * @return index number 0..N, or -1 if unable to add */ static int cov_address_add( - BACNET_ADDRESS *dest) + BACNET_ADDRESS * dest) { int index = -1; unsigned i = 0; @@ -475,8 +476,8 @@ static bool cov_send_request( datalink_get_my_address(&my_address); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = - npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, - &my_address, &npdu_data); + npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address, + &npdu_data); /* load the COV data structure for outgoing message */ cov_data.subscriberProcessIdentifier = cov_subscription->subscriberProcessIdentifier; @@ -504,13 +505,12 @@ static bool cov_send_request( } pdu_len += len; if (cov_subscription->flag.issueConfirmedNotifications) { - tsm_set_confirmed_unsegmented_transaction(invoke_id, - dest, &npdu_data, &Handler_Transmit_Buffer[0], - (uint16_t) pdu_len); + tsm_set_confirmed_unsegmented_transaction(invoke_id, dest, &npdu_data, + &Handler_Transmit_Buffer[0], (uint16_t) pdu_len); } bytes_sent = - datalink_send_pdu(dest, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); if (bytes_sent > 0) { status = true; #if PRINT_ENABLED diff --git a/bacnet-stack/demo/handler/h_npdu.c b/bacnet-stack/demo/handler/h_npdu.c index e286b0fd..973b6061 100644 --- a/bacnet-stack/demo/handler/h_npdu.c +++ b/bacnet-stack/demo/handler/h_npdu.c @@ -87,7 +87,7 @@ void npdu_handler( routing information cause they are not for us */ if ((dest.net == BACNET_BROADCAST_NETWORK) && ((pdu[apdu_offset] & 0xF0) == - PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) { + PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) { /* hack for 5.4.5.1 - IDLE */ /* ConfirmedBroadcastReceived */ /* then enter IDLE - ignore the PDU */ diff --git a/bacnet-stack/demo/handler/h_whohas.c b/bacnet-stack/demo/handler/h_whohas.c index 28d7db3e..91360a87 100644 --- a/bacnet-stack/demo/handler/h_whohas.c +++ b/bacnet-stack/demo/handler/h_whohas.c @@ -111,8 +111,8 @@ void handler_who_has( #ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */ - /* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in - virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */ + /* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in + virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */ /** Handler for Who-Has requests in the virtual routing setup, * with broadcast I-Have response. diff --git a/bacnet-stack/demo/handler/h_whois.c b/bacnet-stack/demo/handler/h_whois.c index 819da580..1da8cf9e 100644 --- a/bacnet-stack/demo/handler/h_whois.c +++ b/bacnet-stack/demo/handler/h_whois.c @@ -114,10 +114,10 @@ void handler_who_is_unicast( #ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */ - /* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in - virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */ - - + /* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in + virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */ + + /** 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/s_awfs.c b/bacnet-stack/demo/handler/s_awfs.c index eade7275..e5aa2802 100644 --- a/bacnet-stack/demo/handler/s_awfs.c +++ b/bacnet-stack/demo/handler/s_awfs.c @@ -45,86 +45,89 @@ /** @file s_awfs.c Send part of an Atomic Write File Stream request. */ -uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id, - uint32_t file_instance, - int fileStartPosition, - BACNET_OCTET_STRING * fileData) { - BACNET_ADDRESS dest; - BACNET_ADDRESS my_address; - BACNET_NPDU_DATA npdu_data; - unsigned max_apdu = 0; - uint8_t invoke_id = 0; - bool status = false; - int len = 0; - int pdu_len = 0; - int bytes_sent = 0; - BACNET_ATOMIC_WRITE_FILE_DATA data; +uint8_t Send_Atomic_Write_File_Stream( + uint32_t device_id, + uint32_t file_instance, + int fileStartPosition, + BACNET_OCTET_STRING * fileData) +{ + BACNET_ADDRESS dest; + BACNET_ADDRESS my_address; + BACNET_NPDU_DATA npdu_data; + unsigned max_apdu = 0; + uint8_t invoke_id = 0; + bool status = false; + int len = 0; + int pdu_len = 0; + int bytes_sent = 0; + BACNET_ATOMIC_WRITE_FILE_DATA data; - /* if we are forbidden to send, don't send! */ - if (!dcc_communication_enabled ()) - return 0; + /* if we are forbidden to send, don't send! */ + if (!dcc_communication_enabled()) + return 0; - /* is the device bound? */ - status = address_get_by_device (device_id, &max_apdu, &dest); - /* is there a tsm available? */ - if (status) - invoke_id = tsm_next_free_invokeID (); - if (invoke_id) { - /* load the data for the encoding */ - data.object_type = OBJECT_FILE; - data.object_instance = file_instance; - data.access = FILE_STREAM_ACCESS; - data.type.stream.fileStartPosition = fileStartPosition; - status = octetstring_copy (&data.fileData[0], fileData); - if (status) { - /* encode the NPDU portion of the packet */ - datalink_get_my_address (&my_address); - npdu_encode_npdu_data (&npdu_data, true, MESSAGE_PRIORITY_NORMAL); - pdu_len = - npdu_encode_pdu (&Handler_Transmit_Buffer[0], &dest, &my_address, - &npdu_data); - /* encode the APDU portion of the packet */ - len = - awf_encode_apdu (&Handler_Transmit_Buffer[pdu_len], invoke_id, &data); - pdu_len += len; - /* will the APDU fit the target device? - note: if there is a bottleneck router in between - us and the destination, we won't know unless - we have a way to check for that and update the - max_apdu in the address binding table. */ - if ((unsigned) pdu_len <= max_apdu) { - tsm_set_confirmed_unsegmented_transaction (invoke_id, &dest, - &npdu_data, - &Handler_Transmit_Buffer - [0], (uint16_t) pdu_len); - bytes_sent = - datalink_send_pdu (&dest, &npdu_data, &Handler_Transmit_Buffer[0], - pdu_len); + /* is the device bound? */ + status = address_get_by_device(device_id, &max_apdu, &dest); + /* is there a tsm available? */ + if (status) + invoke_id = tsm_next_free_invokeID(); + if (invoke_id) { + /* load the data for the encoding */ + data.object_type = OBJECT_FILE; + data.object_instance = file_instance; + data.access = FILE_STREAM_ACCESS; + data.type.stream.fileStartPosition = fileStartPosition; + status = octetstring_copy(&data.fileData[0], fileData); + if (status) { + /* encode the NPDU portion of the packet */ + datalink_get_my_address(&my_address); + npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, + &my_address, &npdu_data); + /* encode the APDU portion of the packet */ + len = + awf_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, + &data); + pdu_len += len; + /* will the APDU fit the target device? + note: if there is a bottleneck router in between + us and the destination, we won't know unless + we have a way to check for that and update the + max_apdu in the address binding table. */ + if ((unsigned) pdu_len <= max_apdu) { + tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, + &npdu_data, &Handler_Transmit_Buffer[0], + (uint16_t) pdu_len); + bytes_sent = + datalink_send_pdu(&dest, &npdu_data, + &Handler_Transmit_Buffer[0], pdu_len); #if PRINT_ENABLED - if (bytes_sent <= 0) - fprintf (stderr, "Failed to Send AtomicWriteFile Request (%s)!\n", - strerror (errno)); + if (bytes_sent <= 0) + fprintf(stderr, + "Failed to Send AtomicWriteFile Request (%s)!\n", + strerror(errno)); #endif - } else { - tsm_free_invoke_id (invoke_id); - invoke_id = 0; + } else { + tsm_free_invoke_id(invoke_id); + invoke_id = 0; #if PRINT_ENABLED - fprintf (stderr, - "Failed to Send AtomicWriteFile Request " - "(payload [%d] exceeds destination maximum APDU [%u])!\n", - pdu_len, max_apdu); + fprintf(stderr, + "Failed to Send AtomicWriteFile Request " + "(payload [%d] exceeds destination maximum APDU [%u])!\n", + pdu_len, max_apdu); #endif - } - } else { - tsm_free_invoke_id (invoke_id); - invoke_id = 0; + } + } else { + tsm_free_invoke_id(invoke_id); + invoke_id = 0; #if PRINT_ENABLED - fprintf (stderr, - "Failed to Send AtomicWriteFile Request " - "(payload [%d] exceeds octet string capacity)!\n", pdu_len); + fprintf(stderr, + "Failed to Send AtomicWriteFile Request " + "(payload [%d] exceeds octet string capacity)!\n", pdu_len); #endif + } } - } - return invoke_id; + return invoke_id; } diff --git a/bacnet-stack/demo/handler/s_wpm.c b/bacnet-stack/demo/handler/s_wpm.c index e08c650e..715b7984 100644 --- a/bacnet-stack/demo/handler/s_wpm.c +++ b/bacnet-stack/demo/handler/s_wpm.c @@ -1,119 +1,120 @@ -/** -* @file -* @author Daniel Blazevic -* @date 2013 -* @brief Send Write Property Multiple request -* -* @section LICENSE -* -* Copyright (C) 2013 Daniel Blazevic -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include -#include -#include -#include -#include "config.h" -#include "txbuf.h" -#include "bacdef.h" -#include "bacdcode.h" -#include "address.h" -#include "tsm.h" -#include "npdu.h" -#include "apdu.h" -#include "device.h" -#include "datalink.h" -#include "dcc.h" -#include "wpm.h" -/* some demo stuff needed */ -#include "handlers.h" -#include "sbuf.h" -#include "client.h" - -/** @file s_wpm.c Send Write Property Multiple request. */ - -/** Sends a Write Property Multiple request. - * @param device_id [in] ID of the destination device - * @param write_access_data [in] Ptr to structure with the linked list of - * objects and properties to be written. - * @return invoke id of outgoing message, or 0 if device is not bound or no tsm available - */ -uint8_t Send_Write_Property_Multiple_Request_Data( - uint32_t device_id, - BACNET_WRITE_ACCESS_DATA * write_access_data) -{ - BACNET_ADDRESS dest; - BACNET_ADDRESS my_address; - unsigned max_apdu = 0; - uint8_t invoke_id = 0; - bool status = false; - int len = 0; - int pdu_len = 0; - int bytes_sent = 0; - BACNET_NPDU_DATA npdu_data; - - /* is the device bound? */ - status = address_get_by_device(device_id, &max_apdu, &dest); - /* is there a tsm available? */ - if (status) - invoke_id = tsm_next_free_invokeID(); - if (invoke_id) { - /* encode the NPDU portion of the packet */ - datalink_get_my_address(&my_address); - npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); - pdu_len = - npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, - &npdu_data); - - len = wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu, - invoke_id, write_access_data); - - pdu_len += len; - - /* will it fit in the sender? - note: if there is a bottleneck router in between - us and the destination, we won't know unless - we have a way to check for that and update the - max_apdu in the address binding table. */ - if ((unsigned) pdu_len < max_apdu) { - tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, - &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len); - bytes_sent = - datalink_send_pdu(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); -#if PRINT_ENABLED - if (bytes_sent <= 0) - fprintf(stderr, "Failed to Send WriteProperty Request (%s)!\n", - strerror(errno)); -#endif - } else { - tsm_free_invoke_id(invoke_id); - invoke_id = 0; -#if PRINT_ENABLED - fprintf(stderr, - "Failed to Send WriteProperty Request " - "(exceeds destination maximum APDU)!\n"); -#endif - } - } - - return invoke_id; -} +/** +* @file +* @author Daniel Blazevic +* @date 2013 +* @brief Send Write Property Multiple request +* +* @section LICENSE +* +* Copyright (C) 2013 Daniel Blazevic +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include +#include +#include +#include +#include "config.h" +#include "txbuf.h" +#include "bacdef.h" +#include "bacdcode.h" +#include "address.h" +#include "tsm.h" +#include "npdu.h" +#include "apdu.h" +#include "device.h" +#include "datalink.h" +#include "dcc.h" +#include "wpm.h" +/* some demo stuff needed */ +#include "handlers.h" +#include "sbuf.h" +#include "client.h" + +/** @file s_wpm.c Send Write Property Multiple request. */ + +/** Sends a Write Property Multiple request. + * @param device_id [in] ID of the destination device + * @param write_access_data [in] Ptr to structure with the linked list of + * objects and properties to be written. + * @return invoke id of outgoing message, or 0 if device is not bound or no tsm available + */ +uint8_t Send_Write_Property_Multiple_Request_Data( + uint32_t device_id, + BACNET_WRITE_ACCESS_DATA * write_access_data) +{ + BACNET_ADDRESS dest; + BACNET_ADDRESS my_address; + unsigned max_apdu = 0; + uint8_t invoke_id = 0; + bool status = false; + int len = 0; + int pdu_len = 0; + int bytes_sent = 0; + BACNET_NPDU_DATA npdu_data; + + /* is the device bound? */ + status = address_get_by_device(device_id, &max_apdu, &dest); + /* is there a tsm available? */ + if (status) + invoke_id = tsm_next_free_invokeID(); + if (invoke_id) { + /* encode the NPDU portion of the packet */ + datalink_get_my_address(&my_address); + npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, + &npdu_data); + + len = + wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu, + invoke_id, write_access_data); + + pdu_len += len; + + /* will it fit in the sender? + note: if there is a bottleneck router in between + us and the destination, we won't know unless + we have a way to check for that and update the + max_apdu in the address binding table. */ + if ((unsigned) pdu_len < max_apdu) { + tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, + &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len); + bytes_sent = + datalink_send_pdu(&dest, &npdu_data, + &Handler_Transmit_Buffer[0], pdu_len); +#if PRINT_ENABLED + if (bytes_sent <= 0) + fprintf(stderr, "Failed to Send WriteProperty Request (%s)!\n", + strerror(errno)); +#endif + } else { + tsm_free_invoke_id(invoke_id); + invoke_id = 0; +#if PRINT_ENABLED + fprintf(stderr, + "Failed to Send WriteProperty Request " + "(exceeds destination maximum APDU)!\n"); +#endif + } + } + + return invoke_id; +} diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index 235be5aa..b35d1542 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -132,7 +132,7 @@ static uint32_t timeval_diff_ms( static void mstp_monitor_i_am( uint8_t mac, - uint8_t *pdu, + uint8_t * pdu, uint16_t pdu_len) { BACNET_ADDRESS src = { 0 }; @@ -150,10 +150,9 @@ static void mstp_monitor_i_am( if (pdu[0] == BACNET_PROTOCOL_VERSION) { MSTP_Fill_BACnet_Address(&src, mac); apdu_offset = npdu_decode(&pdu[0], &dest, &src, &npdu_data); - if ((!npdu_data.network_layer_message) && - (apdu_offset > 0) && (apdu_offset < pdu_len) && - ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) && - (src.net == 0)) { + if ((!npdu_data.network_layer_message) && (apdu_offset > 0) && + (apdu_offset < pdu_len) && ((dest.net == 0) || + (dest.net == BACNET_BROADCAST_NETWORK)) && (src.net == 0)) { apdu_len = pdu_len - apdu_offset; apdu = &pdu[apdu_offset]; pdu_type = apdu[0] & 0xF0; @@ -162,8 +161,9 @@ static void mstp_monitor_i_am( service_choice = apdu[1]; service_request = &apdu[2]; if (service_choice == SERVICE_UNCONFIRMED_I_AM) { - len = iam_decode_service_request(service_request, - &device_id, NULL, NULL, NULL); + len = + iam_decode_service_request(service_request, &device_id, + NULL, NULL, NULL); if (len != -1) { MSTP_Statistics[mac].device_id = device_id; } @@ -272,11 +272,10 @@ static void packet_statistics( } } if ((mstp_port->ReceivedValidFrame) || - (mstp_port->ReceivedValidFrameNotForUs)){ + (mstp_port->ReceivedValidFrameNotForUs)) { if ((mstp_port->DataLength <= mstp_port->InputBufferSize) && (mstp_port->DataLength > 0)) { - mstp_monitor_i_am(src, - &mstp_port->InputBuffer[0], + mstp_monitor_i_am(src, &mstp_port->InputBuffer[0], mstp_port->DataLength); } } @@ -754,8 +753,8 @@ static bool read_received_packet( mstp_port->HeaderCRCActual = header[7]; mstp_port->HeaderCRC = 0xFF; for (i = 2; i < 8; i++) { - mstp_port->HeaderCRC = CRC_Calc_Header(header[i], - mstp_port->HeaderCRC); + mstp_port->HeaderCRC = + CRC_Calc_Header(header[i], mstp_port->HeaderCRC); } if (mstp_port->HeaderCRC != 0x55) { mstp_port->ReceivedInvalidFrame = true; @@ -792,11 +791,9 @@ static bool read_received_packet( mstp_port->DataCRC); } mstp_port->DataCRC = - CRC_Calc_Data(mstp_port->DataCRCActualMSB, - mstp_port->DataCRC); + CRC_Calc_Data(mstp_port->DataCRCActualMSB, mstp_port->DataCRC); mstp_port->DataCRC = - CRC_Calc_Data(mstp_port->DataCRCActualLSB, - mstp_port->DataCRC); + CRC_Calc_Data(mstp_port->DataCRCActualLSB, mstp_port->DataCRC); if (mstp_port->DataCRC == 0xF0B8) { mstp_port->ReceivedValidFrame = true; mstp_port->ReceivedValidFrameNotForUs = true; @@ -851,13 +848,14 @@ static BOOL WINAPI CtrlCHandler( * Returns: none * Notes: none **************************************************************************/ -static void print_com_ports(void) +static void print_com_ports( + void) { unsigned i = 0; printf("List of available COM ports:\r\n"); /* try to open all 255 COM ports */ - for (i=1; i<256; i++) { + for (i = 1; i < 256; i++) { if (RS485_Interface_Valid(i)) { printf("COM%u\r\n", i); } @@ -964,10 +962,10 @@ int main( if (argc > 1) { RS485_Set_Interface(argv[1]); } else { - #if defined(_WIN32) +#if defined(_WIN32) print_com_ports(); return 0; - #endif +#endif } if (argc > 2) { my_baud = strtol(argv[2], NULL, 0); diff --git a/bacnet-stack/demo/object/ao.h b/bacnet-stack/demo/object/ao.h index f30e8cfe..84dbdaf7 100644 --- a/bacnet-stack/demo/object/ao.h +++ b/bacnet-stack/demo/object/ao.h @@ -124,5 +124,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/demo/object/av.h b/bacnet-stack/demo/object/av.h index fda53e0f..2fddbdc6 100644 --- a/bacnet-stack/demo/object/av.h +++ b/bacnet-stack/demo/object/av.h @@ -123,7 +123,8 @@ extern "C" { uint16_t Analog_Value_Units( uint32_t instance); bool Analog_Value_Units_Set( - uint32_t instance, uint16_t unit); + uint32_t instance, + uint16_t unit); bool Analog_Value_Out_Of_Service( uint32_t instance); diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index 0d6f697a..94a880b2 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -282,7 +282,7 @@ int bacfile_read_property( case PROP_FILE_ACCESS_METHOD: apdu_len = encode_application_enumerated(&apdu[0], - FILE_RECORD_AND_STREAM_ACCESS); + FILE_RECORD_AND_STREAM_ACCESS); break; default: rpdata->error_class = ERROR_CLASS_PROPERTY; @@ -551,7 +551,8 @@ bool bacfile_write_record_data( } for (i = 0; i < data->type.record.returnedRecordCount; i++) { if (fwrite(octetstring_value(&data->fileData[i]), - octetstring_length(&data->fileData[i]), 1, pFile) != 1) { + octetstring_length(&data->fileData[i]), 1, + pFile) != 1) { /* do something if it fails? */ } } @@ -598,7 +599,7 @@ bool bacfile_read_ack_record_data( FILE *pFile = NULL; char *pFilename = NULL; uint32_t i = 0; - char dummy_data[MAX_OCTET_STRING_BYTES] = {0}; + char dummy_data[MAX_OCTET_STRING_BYTES] = { 0 }; char *pData = NULL; pFilename = bacfile_name(instance); @@ -616,10 +617,11 @@ bool bacfile_read_ack_record_data( } for (i = 0; i < data->type.record.RecordCount; i++) { if (fwrite(octetstring_value(&data->fileData[i]), - octetstring_length(&data->fileData[i]), 1, pFile) != 1) { + octetstring_length(&data->fileData[i]), 1, + pFile) != 1) { #if PRINT_ENABLED - fprintf(stderr, "Failed to write to %s (%lu)!\n", pFilename, - (unsigned long) instance); + fprintf(stderr, "Failed to write to %s (%lu)!\n", + pFilename, (unsigned long) instance); #endif } } diff --git a/bacnet-stack/demo/object/bv.h b/bacnet-stack/demo/object/bv.h index e96481f5..0c075ffd 100644 --- a/bacnet-stack/demo/object/bv.h +++ b/bacnet-stack/demo/object/bv.h @@ -138,4 +138,3 @@ extern "C" { } #endif /* __cplusplus */ #endif - diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index 9109827b..1c27657c 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -1173,7 +1173,7 @@ int Device_Read_Property_Local( uint8_t *apdu = NULL; struct object_functions *pObject = NULL; bool found = false; - uint16_t apdu_max =0; + uint16_t apdu_max = 0; if ((rpdata == NULL) || (rpdata->application_data == NULL) || (rpdata->application_data_len == 0)) { @@ -1818,8 +1818,8 @@ void Device_Init( struct uci_context *ctx; fprintf(stderr, "Device_Init\n"); ctx = ucix_init("bacnet_dev"); - if(!ctx) - fprintf(stderr, "Failed to load config file bacnet_dev\n"); + if (!ctx) + fprintf(stderr, "Failed to load config file bacnet_dev\n"); uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name"); if (uciname != 0) { characterstring_init_ansi(&My_Object_Name, uciname); diff --git a/bacnet-stack/demo/object/device.h b/bacnet-stack/demo/object/device.h index 92656e9b..8515855a 100644 --- a/bacnet-stack/demo/object/device.h +++ b/bacnet-stack/demo/object/device.h @@ -440,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/ptransfer/main.c b/bacnet-stack/demo/ptransfer/main.c index 9a26a6c0..7e5202fb 100644 --- a/bacnet-stack/demo/ptransfer/main.c +++ b/bacnet-stack/demo/ptransfer/main.c @@ -29,7 +29,7 @@ #include #include #include /* for time */ -#include /* for tupper */ +#include /* for tupper */ #if defined(WIN32) || defined(__BORLANDC__) #include #endif diff --git a/bacnet-stack/demo/readbdt/main.c b/bacnet-stack/demo/readbdt/main.c index beb5a1a7..f18aa8e0 100644 --- a/bacnet-stack/demo/readbdt/main.c +++ b/bacnet-stack/demo/readbdt/main.c @@ -30,7 +30,7 @@ #include #include /* for time */ #include -#include /* for toupper */ +#include /* for toupper */ #include "bactext.h" #include "iam.h" #include "address.h" diff --git a/bacnet-stack/demo/readfile/main.c b/bacnet-stack/demo/readfile/main.c index 8333641b..23cc5da4 100644 --- a/bacnet-stack/demo/readfile/main.c +++ b/bacnet-stack/demo/readfile/main.c @@ -130,7 +130,7 @@ static void AtomicReadFileAckHandler( /* is there anything to do with this? data.stream.requestedOctetCount */ (void) fseek(pFile, data.type.stream.fileStartPosition, SEEK_SET); - octets_written = fwrite(octetstring_value(&data.fileData[0]), 1, /* unit to write in bytes - in our case, an octet is one byte */ + octets_written = fwrite(octetstring_value(&data.fileData[0]), 1, /* unit to write in bytes - in our case, an octet is one byte */ octetstring_length(&data.fileData[0]), pFile); if (octets_written != octetstring_length(&data.fileData[0])) { fprintf(stderr, "Unable to write data to file \"%s\".\n", diff --git a/bacnet-stack/demo/server/main.c b/bacnet-stack/demo/server/main.c index 95bb8337..c029fecc 100644 --- a/bacnet-stack/demo/server/main.c +++ b/bacnet-stack/demo/server/main.c @@ -166,8 +166,8 @@ int main( struct uci_context *ctx; ctx = ucix_init("bacnet_dev"); - if(!ctx) - fprintf(stderr, "Failed to load config file bacnet_dev\n"); + if (!ctx) + fprintf(stderr, "Failed to load config file bacnet_dev\n"); uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0); printf("ID: %i", uciId); if (uciId != 0) { diff --git a/bacnet-stack/include/arf.h b/bacnet-stack/include/arf.h index 01d1122c..1ff600f2 100644 --- a/bacnet-stack/include/arf.h +++ b/bacnet-stack/include/arf.h @@ -48,7 +48,7 @@ typedef struct BACnet_Atomic_Read_File_Data { uint32_t RecordCount; } record; } type; - BACNET_OCTET_STRING fileData[BACNET_READ_FILE_RECORD_COUNT]; + BACNET_OCTET_STRING fileData[BACNET_READ_FILE_RECORD_COUNT]; bool endOfFile; } BACNET_ATOMIC_READ_FILE_DATA; diff --git a/bacnet-stack/include/bacenum.h b/bacnet-stack/include/bacenum.h index 7f4f33f6..d9ca25a9 100644 --- a/bacnet-stack/include/bacenum.h +++ b/bacnet-stack/include/bacenum.h @@ -409,12 +409,12 @@ typedef enum { PROP_POWER = 384, PROP_TRANSITION = 385, PROP_EGRESS_ACTIVE = 386, - /* 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. */ /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ @@ -495,9 +495,9 @@ typedef enum { UNITS_AMPERES_PER_METER = 167, UNITS_AMPERES_PER_SQUARE_METER = 168, UNITS_AMPERE_SQUARE_METERS = 169, - UNITS_DECIBELS = 199, - UNITS_DECIBELS_MILLIVOLT = 200, - UNITS_DECIBELS_VOLT = 201, + UNITS_DECIBELS = 199, + UNITS_DECIBELS_MILLIVOLT = 200, + UNITS_DECIBELS_VOLT = 201, UNITS_FARADS = 170, UNITS_HENRYS = 171, UNITS_OHMS = 4, @@ -702,34 +702,34 @@ typedef enum { UNITS_WATTS_PER_METER_PER_DEGREE_KELVIN = 189, UNITS_WATTS_PER_SQUARE_METER_DEGREE_KELVIN = 141, UNITS_PER_MILLE = 207, - UNITS_GRAMS_PER_GRAM = 208, - UNITS_KILOGRAMS_PER_KILOGRAM = 209, - UNITS_GRAMS_PER_KILOGRAM = 210, - UNITS_MILLIGRAMS_PER_GRAM = 211, - UNITS_MILLIGRAMS_PER_KILOGRAM = 212, - UNITS_GRAMS_PER_MILLILITER = 213, - UNITS_GRAMS_PER_LITER = 214, - UNITS_MILLIGRAMS_PER_LITER = 215, - UNITS_MICROGRAMS_PER_LITER = 216, - UNITS_GRAMS_PER_CUBIC_METER = 217, - UNITS_MILLIGRAMS_PER_CUBIC_METER = 218, - UNITS_MICROGRAMS_PER_CUBIC_METER = 219, - UNITS_NANOGRAMS_PER_CUBIC_METER = 220, - UNITS_GRAMS_PER_CUBIC_CENTIMETER = 221, - UNITS_BECQUERELS = 222, - UNITS_MEGABECQUERELS = 224, - UNITS_GRAY = 225, - UNITS_MILLIGRAY = 226, - UNITS_MICROGRAY = 227, - UNITS_SIEVERTS = 228, - UNITS_MILLISIEVERTS = 229, - UNITS_MICROSIEVERTS = 230, - UNITS_MICROSIEVERTS_PER_HOUR = 231, - UNITS_DECIBELS_A = 232, - UNITS_NEPHELOMETRIC_TURBIDITY_UNIT = 233, - UNITS_PH = 234, - UNITS_GRAMS_PER_SQUARE_METER = 235, - UNITS_MINUTES_PER_DEGREE_KELVIN = 236, + UNITS_GRAMS_PER_GRAM = 208, + UNITS_KILOGRAMS_PER_KILOGRAM = 209, + UNITS_GRAMS_PER_KILOGRAM = 210, + UNITS_MILLIGRAMS_PER_GRAM = 211, + UNITS_MILLIGRAMS_PER_KILOGRAM = 212, + UNITS_GRAMS_PER_MILLILITER = 213, + UNITS_GRAMS_PER_LITER = 214, + UNITS_MILLIGRAMS_PER_LITER = 215, + UNITS_MICROGRAMS_PER_LITER = 216, + UNITS_GRAMS_PER_CUBIC_METER = 217, + UNITS_MILLIGRAMS_PER_CUBIC_METER = 218, + UNITS_MICROGRAMS_PER_CUBIC_METER = 219, + UNITS_NANOGRAMS_PER_CUBIC_METER = 220, + UNITS_GRAMS_PER_CUBIC_CENTIMETER = 221, + UNITS_BECQUERELS = 222, + UNITS_MEGABECQUERELS = 224, + UNITS_GRAY = 225, + UNITS_MILLIGRAY = 226, + UNITS_MICROGRAY = 227, + UNITS_SIEVERTS = 228, + UNITS_MILLISIEVERTS = 229, + UNITS_MICROSIEVERTS = 230, + UNITS_MICROSIEVERTS_PER_HOUR = 231, + UNITS_DECIBELS_A = 232, + UNITS_NEPHELOMETRIC_TURBIDITY_UNIT = 233, + UNITS_PH = 234, + UNITS_GRAMS_PER_SQUARE_METER = 235, + UNITS_MINUTES_PER_DEGREE_KELVIN = 236, /* 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. */ @@ -772,9 +772,9 @@ typedef enum { PROGRAM_ERROR_INTERNAL = 2, PROGRAM_ERROR_PROGRAM = 3, PROGRAM_ERROR_OTHER = 4, - /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ - /* Enumerated values 64-65535 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ + /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ + /* Enumerated values 64-65535 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ @@ -853,9 +853,9 @@ typedef enum { RELIABILITY_MEMBER_FAULT = 11, RELIABILITY_COMMUNICATION_FAILURE = 12, RELIABILITY_TRIPPED = 13, - /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ - /* Enumerated values 64-65535 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ + /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ + /* Enumerated values 64-65535 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ @@ -876,14 +876,14 @@ typedef enum { EVENT_EXTENDED = 9, EVENT_BUFFER_READY = 10, EVENT_UNSIGNED_RANGE = 11, - /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ - /* Enumerated values 64-65535 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ - /* It is expected that these enumerated values will correspond to */ - /* the use of the complex-event-type CHOICE [6] of the */ - /* BACnetNotificationParameters production. */ - /* The last enumeration used in this version is 11. */ - /* do the max range inside of enum so that + /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ + /* Enumerated values 64-65535 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ + /* It is expected that these enumerated values will correspond to */ + /* the use of the complex-event-type CHOICE [6] of the */ + /* BACnetNotificationParameters production. */ + /* The last enumeration used in this version is 11. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ EVENT_PROPRIETARY_MIN = 64, @@ -914,10 +914,10 @@ typedef enum { LIFE_SAFETY_MODE_AUTOMATIC_RELEASE_DISABLED = 13, LIFE_SAFETY_MODE_DEFAULT = 14, MAX_LIFE_SAFETY_MODE = 15, - /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ - /* Enumerated values 256-65535 may be used by others subject to */ - /* procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ + /* Enumerated values 256-65535 may be used by others subject to */ + /* procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ LIFE_SAFETY_MODE_PROPRIETARY_MIN = 256, @@ -935,10 +935,10 @@ typedef enum { LIFE_SAFETY_OP_UNSILENCE = 7, LIFE_SAFETY_OP_UNSILENCE_AUDIBLE = 8, LIFE_SAFETY_OP_UNSILENCE_VISUAL = 9, - /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ - /* Enumerated values 64-65535 may be used by others subject to */ - /* procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ + /* Enumerated values 64-65535 may be used by others subject to */ + /* procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ LIFE_SAFETY_OP_PROPRIETARY_MIN = 64, @@ -972,10 +972,10 @@ typedef enum { LIFE_SAFETY_STATE_SUPERVISORY = 22, LIFE_SAFETY_STATE_TEST_SUPERVISORY = 23, MAX_LIFE_SAFETY_STATE = 24, - /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ - /* Enumerated values 256-65535 may be used by others subject to */ - /* procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ + /* Enumerated values 256-65535 may be used by others subject to */ + /* procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ LIFE_SAFETY_STATE_PROPRIETARY_MIN = 256, @@ -987,10 +987,10 @@ typedef enum { SILENCED_STATE_AUDIBLE_SILENCED = 1, SILENCED_STATE_VISIBLE_SILENCED = 2, SILENCED_STATE_ALL_SILENCED = 3, - /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ - /* Enumerated values 64-65535 may be used by others subject to */ - /* procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ + /* Enumerated values 64-65535 may be used by others subject to */ + /* procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ SILENCED_STATE_PROPRIETARY_MIN = 64, @@ -1002,10 +1002,10 @@ typedef enum { MAINTENANCE_PERIODIC_TEST = 1, MAINTENANCE_NEED_SERVICE_OPERATIONAL = 2, MAINTENANCE_NEED_SERVICE_INOPERATIVE = 3, - /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ - /* Enumerated values 256-65535 may be used by others subject to */ - /* procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-255 are reserved for definition by ASHRAE. */ + /* Enumerated values 256-65535 may be used by others subject to */ + /* procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ MAINTENANCE_PROPRIETARY_MIN = 256, @@ -1074,10 +1074,10 @@ typedef enum { OBJECT_ALERT_ENROLLMENT = 52, /* Addendum 2010-af */ OBJECT_CHANNEL = 53, /* Addendum 2010-aa */ OBJECT_LIGHTING_OUTPUT = 54, /* Addendum 2010-i */ - /* Enumerated values 0-127 are reserved for definition by ASHRAE. */ - /* Enumerated values 128-1023 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-127 are reserved for definition by ASHRAE. */ + /* Enumerated values 128-1023 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ OBJECT_PROPRIETARY_MIN = 128, @@ -1101,10 +1101,10 @@ typedef enum { VT_CLASS_DEC_VT220 = 4, VT_CLASS_HP_700_94 = 5, /* real name is HP 700/94 */ VT_CLASS_IBM_3130 = 6, - /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ - /* Enumerated values 64-65535 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ - /* do the max range inside of enum so that + /* Enumerated values 0-63 are reserved for definition by ASHRAE. */ + /* Enumerated values 64-65535 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ + /* do the max range inside of enum so that compilers will allocate adequate sized datatype for enum which is used to store decoding */ VT_CLASS_PROPRIETARY_MIN = 64, @@ -1307,9 +1307,9 @@ typedef enum { SERVICE_SUPPORTED_UTC_TIME_SYNCHRONIZATION = 36, SERVICE_SUPPORTED_WHO_HAS = 33, SERVICE_SUPPORTED_WHO_IS = 34 - /* Other services to be added as they are defined. */ - /* All values in this production are reserved */ - /* for definition by ASHRAE. */ + /* Other services to be added as they are defined. */ + /* All values in this production are reserved */ + /* for definition by ASHRAE. */ } BACNET_SERVICES_SUPPORTED; typedef enum { diff --git a/bacnet-stack/include/client.h b/bacnet-stack/include/client.h index 4eecb530..e37d78de 100644 --- a/bacnet-stack/include/client.h +++ b/bacnet-stack/include/client.h @@ -152,9 +152,9 @@ extern "C" { int application_data_len, uint8_t priority, uint32_t array_index); - uint8_t Send_Write_Property_Multiple_Request_Data( - uint32_t device_id, - BACNET_WRITE_ACCESS_DATA * write_access_data); + uint8_t Send_Write_Property_Multiple_Request_Data( + uint32_t device_id, + BACNET_WRITE_ACCESS_DATA * write_access_data); /* returns the invoke ID for confirmed request, or 0 if failed */ uint8_t Send_Reinitialize_Device_Request( diff --git a/bacnet-stack/include/datalink.h b/bacnet-stack/include/datalink.h index 63273a2a..77f7614d 100644 --- a/bacnet-stack/include/datalink.h +++ b/bacnet-stack/include/datalink.h @@ -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/datetime.h b/bacnet-stack/include/datetime.h index 1ca953b8..97ac2a76 100644 --- a/bacnet-stack/include/datetime.h +++ b/bacnet-stack/include/datetime.h @@ -89,18 +89,18 @@ extern "C" { uint8_t hundredths); /* utility test for validity */ bool datetime_is_valid( - BACNET_DATE *bdate, - BACNET_TIME *btime); + BACNET_DATE * bdate, + BACNET_TIME * btime); bool datetime_time_is_valid( - BACNET_TIME *btime); + BACNET_TIME * btime); bool datetime_date_is_valid( - BACNET_DATE *bdate); + BACNET_DATE * bdate); /* date and time calculations and summaries */ uint32_t datetime_days_since_epoch( - BACNET_DATE *bdate); + BACNET_DATE * bdate); void datetime_days_since_epoch_into_date( uint32_t days, - BACNET_DATE *bdate); + BACNET_DATE * bdate); bool datetime_is_leap_year( uint16_t year); uint8_t datetime_month_days( @@ -115,9 +115,9 @@ extern "C" { uint8_t month, uint8_t day); uint32_t datetime_seconds_since_midnight( - BACNET_TIME *btime); + BACNET_TIME * btime); uint16_t datetime_minutes_since_midnight( - BACNET_TIME *btime); + BACNET_TIME * btime); /* utility comparison functions: if the date/times are the same, return is 0 diff --git a/bacnet-stack/include/dcc.h b/bacnet-stack/include/dcc.h index 86c28948..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/event.h b/bacnet-stack/include/event.h index 259d29a2..a1854aae 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/readrange.h b/bacnet-stack/include/readrange.h index 539d4b76..bb18be89 100644 --- a/bacnet-stack/include/readrange.h +++ b/bacnet-stack/include/readrange.h @@ -161,7 +161,7 @@ extern "C" { /** @defgroup Trend Trending BIBBs * 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. + * BACnet devices defined therein. *//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT) * @ingroup Trend * 15.8 ReadRange Service
diff --git a/bacnet-stack/include/rp.h b/bacnet-stack/include/rp.h index 5108d088..74f270d3 100644 --- a/bacnet-stack/include/rp.h +++ b/bacnet-stack/include/rp.h @@ -124,7 +124,7 @@ extern "C" { /** @defgroup DataShare Data Sharing BIBBs * 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. + * devices defined therein. *//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP) * @ingroup DataShare * 15.5 ReadProperty Service
diff --git a/bacnet-stack/include/ucix.h b/bacnet-stack/include/ucix.h index ea9af200..d857235f 100644 --- a/bacnet-stack/include/ucix.h +++ b/bacnet-stack/include/ucix.h @@ -18,24 +18,56 @@ #ifndef _UCI_H__ #define _UCI_H__ -struct uci_context* ucix_init(const char *config_file); -struct uci_context* ucix_init_path(const char *path, const char *config_file); -void ucix_cleanup(struct uci_context *ctx); -void ucix_save(struct uci_context *ctx); -void ucix_save_state(struct uci_context *ctx); -const char* ucix_get_option(struct uci_context *ctx, - const char *p, const char *s, const char *o); -int ucix_get_option_int(struct uci_context *ctx, - const char *p, const char *s, const char *o, int def); -void ucix_add_section(struct uci_context *ctx, - const char *p, const char *s, const char *t); -void ucix_add_option(struct uci_context *ctx, - const char *p, const char *s, const char *o, const char *t); -void ucix_add_option_int(struct uci_context *ctx, - const char *p, const char *s, const char *o, int t); -int ucix_commit(struct uci_context *ctx, const char *p); -void ucix_revert(struct uci_context *ctx, - const char *p, const char *s, const char *o); -void ucix_del(struct uci_context *ctx, const char *p, - const char *s, const char *o); +struct uci_context *ucix_init( + const char *config_file); +struct uci_context *ucix_init_path( + const char *path, + const char *config_file); +void ucix_cleanup( + struct uci_context *ctx); +void ucix_save( + struct uci_context *ctx); +void ucix_save_state( + struct uci_context *ctx); +const char *ucix_get_option( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o); +int ucix_get_option_int( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + int def); +void ucix_add_section( + struct uci_context *ctx, + const char *p, + const char *s, + const char *t); +void ucix_add_option( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + const char *t); +void ucix_add_option_int( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + int t); +int ucix_commit( + struct uci_context *ctx, + const char *p); +void ucix_revert( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o); +void ucix_del( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o); #endif diff --git a/bacnet-stack/include/wpm.h b/bacnet-stack/include/wpm.h index 575fe128..6f860552 100644 --- a/bacnet-stack/include/wpm.h +++ b/bacnet-stack/include/wpm.h @@ -35,14 +35,14 @@ extern "C" { #endif /* __cplusplus */ - struct BACnet_Write_Access_Data; - typedef struct BACnet_Write_Access_Data { - BACNET_OBJECT_TYPE object_type; - uint32_t object_instance; - /* simple linked list of values */ - BACNET_PROPERTY_VALUE *listOfProperties; - struct BACnet_Write_Access_Data *next; - } BACNET_WRITE_ACCESS_DATA; + struct BACnet_Write_Access_Data; + typedef struct BACnet_Write_Access_Data { + BACNET_OBJECT_TYPE object_type; + uint32_t object_instance; + /* simple linked list of values */ + BACNET_PROPERTY_VALUE *listOfProperties; + struct BACnet_Write_Access_Data *next; + } BACNET_WRITE_ACCESS_DATA; /* decode the service request only */ int wpm_decode_object_id( @@ -69,11 +69,11 @@ extern "C" { int wpm_encode_apdu_object_property( uint8_t * apdu, BACNET_WRITE_PROPERTY_DATA * wpdata); - int wpm_encode_apdu( - uint8_t * apdu, - size_t max_apdu, - uint8_t invoke_id, - BACNET_WRITE_ACCESS_DATA * write_access_data); + int wpm_encode_apdu( + uint8_t * apdu, + size_t max_apdu, + uint8_t invoke_id, + BACNET_WRITE_ACCESS_DATA * write_access_data); /* encode service */ int wpm_ack_encode_apdu_init( diff --git a/bacnet-stack/ports/at91sam7s/device.c b/bacnet-stack/ports/at91sam7s/device.c index 0c04fe3a..6e7175a5 100644 --- a/bacnet-stack/ports/at91sam7s/device.c +++ b/bacnet-stack/ports/at91sam7s/device.c @@ -648,7 +648,7 @@ int Device_Read_Property_Local( return 0; } apdu = rpdata->application_data; - switch ((int)rpdata->object_property) { + switch ((int) rpdata->object_property) { case PROP_DESCRIPTION: characterstring_init_ansi(&char_string, "BACnet Demo"); apdu_len = @@ -851,7 +851,7 @@ bool Device_Write_Property_Local( wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; return false; } - switch ((int)wp_data->object_property) { + switch ((int) wp_data->object_property) { case PROP_OBJECT_IDENTIFIER: if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if ((value.type.Object_Id.type == OBJECT_DEVICE) && diff --git a/bacnet-stack/ports/at91sam7s/irq.c b/bacnet-stack/ports/at91sam7s/irq.c index 23086057..ba19c1d6 100644 --- a/bacnet-stack/ports/at91sam7s/irq.c +++ b/bacnet-stack/ports/at91sam7s/irq.c @@ -1,29 +1,32 @@ -// The following functions must be written in ARM mode -// these functions are called directly by an exception vector - -//------------------------------------------------------------------------------ -// Internal functions -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -/// Default spurious interrupt handler. Infinite loop. -//------------------------------------------------------------------------------ -void AT91F_Spurious_handler( void ) -{ - while (1); -} - -//------------------------------------------------------------------------------ -/// Default handler for fast interrupt requests. Infinite loop. -//------------------------------------------------------------------------------ -void AT91F_Default_FIQ_handler( void ) -{ - while (1); -} - -//------------------------------------------------------------------------------ -/// Default handler for standard interrupt requests. Infinite loop. -//------------------------------------------------------------------------------ -void AT91F_Default_IRQ_handler( void ) -{ - while (1); -} +// The following functions must be written in ARM mode +// these functions are called directly by an exception vector + +//------------------------------------------------------------------------------ +// Internal functions +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +/// Default spurious interrupt handler. Infinite loop. +//------------------------------------------------------------------------------ +void AT91F_Spurious_handler( + void) +{ + while (1); +} + +//------------------------------------------------------------------------------ +/// Default handler for fast interrupt requests. Infinite loop. +//------------------------------------------------------------------------------ +void AT91F_Default_FIQ_handler( + void) +{ + while (1); +} + +//------------------------------------------------------------------------------ +/// Default handler for standard interrupt requests. Infinite loop. +//------------------------------------------------------------------------------ +void AT91F_Default_IRQ_handler( + void) +{ + while (1); +} diff --git a/bacnet-stack/ports/atmega8/device.c b/bacnet-stack/ports/atmega8/device.c index bcb02abe..eb852af6 100644 --- a/bacnet-stack/ports/atmega8/device.c +++ b/bacnet-stack/ports/atmega8/device.c @@ -295,8 +295,7 @@ int Device_Read_Property( } } else { if (Device_Object_List_Identifier(rpdata->array_index, - &object_type, - &instance)) + &object_type, &instance)) apdu_len = encode_application_object_id(&apdu[0], object_type, instance); diff --git a/bacnet-stack/ports/linux/dlmstp_linux.c b/bacnet-stack/ports/linux/dlmstp_linux.c index b36bb790..5192de56 100644 --- a/bacnet-stack/ports/linux/dlmstp_linux.c +++ b/bacnet-stack/ports/linux/dlmstp_linux.c @@ -875,9 +875,8 @@ bool dlmstp_init( return false; } - poSharedData = - (SHARED_MSTP_DATA *) ((struct mstp_port_struct_t *) mstp_port)-> - UserData; + poSharedData = (SHARED_MSTP_DATA *) ((struct mstp_port_struct_t *) + mstp_port)->UserData; if (!poSharedData) { return false; } diff --git a/bacnet-stack/ports/stm32f10x/rs485.c b/bacnet-stack/ports/stm32f10x/rs485.c index b1047752..2f86aad4 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/rs485.c b/bacnet-stack/ports/win32/rs485.c index 105fe788..0ab9a62f 100644 --- a/bacnet-stack/ports/win32/rs485.c +++ b/bacnet-stack/ports/win32/rs485.c @@ -131,7 +131,8 @@ void RS485_Set_Interface( * ALGORITHM: none * NOTES: none *****************************************************************************/ -bool RS485_Interface_Valid(unsigned port_number) +bool RS485_Interface_Valid( + unsigned port_number) { HANDLE h = 0; DWORD err = 0; @@ -139,17 +140,12 @@ bool RS485_Interface_Valid(unsigned port_number) char ifname[255] = ""; sprintf(ifname, "\\\\.\\COM%u", port_number); - h = CreateFile( - ifname, - GENERIC_READ | GENERIC_WRITE, 0, - NULL, OPEN_EXISTING, 0, - NULL); + h = CreateFile(ifname, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, 0, NULL); if (h == INVALID_HANDLE_VALUE) { err = GetLastError(); - if ((err == ERROR_ACCESS_DENIED) || - (err == ERROR_GEN_FAILURE) || - (err == ERROR_SHARING_VIOLATION) || - (err == ERROR_SEM_TIMEOUT)) { + if ((err == ERROR_ACCESS_DENIED) || (err == ERROR_GEN_FAILURE) || + (err == ERROR_SHARING_VIOLATION) || (err == ERROR_SEM_TIMEOUT)) { status = true; } } else { diff --git a/bacnet-stack/ports/win32/rs485.h b/bacnet-stack/ports/win32/rs485.h index 820bba18..c9a75304 100644 --- a/bacnet-stack/ports/win32/rs485.h +++ b/bacnet-stack/ports/win32/rs485.h @@ -68,7 +68,8 @@ extern "C" { void RS485_Print_Error( void); - bool RS485_Interface_Valid(unsigned port_number); + bool RS485_Interface_Valid( + unsigned port_number); #ifdef __cplusplus diff --git a/bacnet-stack/src/arf.c b/bacnet-stack/src/arf.c index 28c13f2e..8083394d 100644 --- a/bacnet-stack/src/arf.c +++ b/bacnet-stack/src/arf.c @@ -236,7 +236,7 @@ int arf_ack_encode_apdu( for (i = 0; i < data->type.record.RecordCount; i++) { apdu_len += encode_application_octet_string(&apdu[apdu_len], - &data->fileData[i]); + &data->fileData[i]); } apdu_len += encode_closing_tag(&apdu[apdu_len], 1); break; @@ -330,7 +330,7 @@ int arf_ack_decode_service_request( return -1; len += decode_octet_string(&apdu[len], len_value_type, - &data->fileData[i]); + &data->fileData[i]); } if (!decode_is_closing_tag_number(&apdu[len], 1)) return -1; diff --git a/bacnet-stack/src/awf.c b/bacnet-stack/src/awf.c index cac6bd96..140244b0 100644 --- a/bacnet-stack/src/awf.c +++ b/bacnet-stack/src/awf.c @@ -79,7 +79,7 @@ int awf_encode_apdu( for (i = 0; i < data->type.record.returnedRecordCount; i++) { apdu_len += encode_application_octet_string(&apdu[apdu_len], - &data->fileData[i]); + &data->fileData[i]); } apdu_len += encode_closing_tag(&apdu[apdu_len], 1); break; @@ -175,7 +175,7 @@ int awf_decode_service_request( return -1; len += decode_octet_string(&apdu[len], len_value_type, - &data->fileData[i]); + &data->fileData[i]); } if (!decode_is_closing_tag_number(&apdu[len], 1)) return -1; diff --git a/bacnet-stack/src/bactext.c b/bacnet-stack/src/bactext.c index cf545760..56884d3b 100644 --- a/bacnet-stack/src/bactext.c +++ b/bacnet-stack/src/bactext.c @@ -1014,7 +1014,7 @@ INDTEXT_DATA bacnet_property_names[] = { {PROP_LIGHTING_COMMAND, "lighting-command"} , {PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, - "lighting-command-default-priority"} + "lighting-command-default-priority"} , {PROP_MAX_ACTUAL_VALUE, "max-actual-value"} , @@ -1735,59 +1735,116 @@ INDTEXT_DATA bacnet_error_code_names[] = { , {ERROR_CODE_COMMUNICATION_DISABLED, "access-denied"} , - {ERROR_CODE_SUCCESS, "success"}, - {ERROR_CODE_ACCESS_DENIED, "access-denied"}, - {ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"}, - {ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"}, - {ERROR_CODE_BAD_SIGNATURE, "bad-signature"}, - {ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"}, - {ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"}, - {ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"}, - {ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"}, - {ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"}, - {ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED, "destination-device-id-required"}, - {ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"}, - {ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"}, - {ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"}, - {ERROR_CODE_INCORRECT_KEY, "incorrect-key"}, - {ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"}, - {ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"}, - {ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"}, - {ERROR_CODE_NOT_KEY_SERVER, "not-key-server"}, - {ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"}, - {ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"}, - {ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"}, - {ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"}, - {ERROR_CODE_UNKNOWN_KEY, "unknown-key"}, - {ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"}, - {ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"}, - {ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"}, - {ERROR_CODE_ROUTER_BUSY, "router-busy"}, - {ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"}, - {ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"}, - {ERROR_CODE_SECURITY_ERROR, "security-error"}, - {ERROR_CODE_ADDRESSING_ERROR, "addressing-error"}, - {ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"}, - {ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"}, - {ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED, "register-foreign-device-failed"}, - {ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"}, - {ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"}, - {ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"}, - {ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"}, - {ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"}, - {ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME, "abort-application-exceeded-reply-time"}, - {ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"}, - {ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"}, - {ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE, "abort-window-size-out-of-range"}, - {ERROR_CODE_FILE_FULL, "file-full"}, - {ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"}, - {ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"}, - {ERROR_CODE_INTERNAL_ERROR, "internal-error"}, - {ERROR_CODE_NOT_CONFIGURED, "not-configured"}, - {ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"}, - {ERROR_CODE_VALUE_TOO_LONG, "value-too-long"}, - {ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"}, - {ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"}, + {ERROR_CODE_SUCCESS, "success"} + , + {ERROR_CODE_ACCESS_DENIED, "access-denied"} + , + {ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"} + , + {ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"} + , + {ERROR_CODE_BAD_SIGNATURE, "bad-signature"} + , + {ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"} + , + {ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"} + , + {ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"} + , + {ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"} + , + {ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"} + , + {ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED, + "destination-device-id-required"} + , + {ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"} + , + {ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"} + , + {ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"} + , + {ERROR_CODE_INCORRECT_KEY, "incorrect-key"} + , + {ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"} + , + {ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"} + , + {ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"} + , + {ERROR_CODE_NOT_KEY_SERVER, "not-key-server"} + , + {ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"} + , + {ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"} + , + {ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"} + , + {ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"} + , + {ERROR_CODE_UNKNOWN_KEY, "unknown-key"} + , + {ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"} + , + {ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"} + , + {ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"} + , + {ERROR_CODE_ROUTER_BUSY, "router-busy"} + , + {ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"} + , + {ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"} + , + {ERROR_CODE_SECURITY_ERROR, "security-error"} + , + {ERROR_CODE_ADDRESSING_ERROR, "addressing-error"} + , + {ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"} + , + {ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"} + , + {ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED, + "register-foreign-device-failed"} + , + {ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"} + , + {ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"} + , + {ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"} + , + {ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"} + , + {ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"} + , + {ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME, + "abort-application-exceeded-reply-time"} + , + {ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"} + , + {ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"} + , + {ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE, + "abort-window-size-out-of-range"} + , + {ERROR_CODE_FILE_FULL, "file-full"} + , + {ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"} + , + {ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"} + , + {ERROR_CODE_INTERNAL_ERROR, "internal-error"} + , + {ERROR_CODE_NOT_CONFIGURED, "not-configured"} + , + {ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"} + , + {ERROR_CODE_VALUE_TOO_LONG, "value-too-long"} + , + {ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"} + , + {ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"} + , {0, NULL} }; diff --git a/bacnet-stack/src/datetime.c b/bacnet-stack/src/datetime.c index 6e93350f..0b516a76 100644 --- a/bacnet-stack/src/datetime.c +++ b/bacnet-stack/src/datetime.c @@ -89,12 +89,11 @@ bool datetime_ymd_is_valid( uint8_t month, uint8_t day) { - bool status = false; /* true if value date */ - uint8_t monthdays = 0; /* days in a month */ + bool status = false; /* true if value date */ + uint8_t monthdays = 0; /* days in a month */ monthdays = datetime_month_days(year, month); - if ((year >= 1900) && (monthdays > 0) && - (day >= 1) && (day <= monthdays)) { + if ((year >= 1900) && (monthdays > 0) && (day >= 1) && (day <= monthdays)) { status = true; } @@ -102,10 +101,10 @@ bool datetime_ymd_is_valid( } bool datetime_date_is_valid( - BACNET_DATE *bdate) + BACNET_DATE * bdate) { - bool status = false; /* true if value date */ + bool status = false; /* true if value date */ if (bdate) { status = datetime_ymd_is_valid(bdate->year, bdate->month, bdate->day); @@ -139,7 +138,7 @@ static uint32_t days_since_epoch( } uint32_t datetime_days_since_epoch( - BACNET_DATE *bdate) + BACNET_DATE * bdate) { uint32_t days = 0; @@ -188,7 +187,7 @@ static void days_since_epoch_into_ymd( void datetime_days_since_epoch_into_date( uint32_t days, - BACNET_DATE *bdate) + BACNET_DATE * bdate) { uint16_t year = 0; uint8_t month = 0; @@ -209,7 +208,7 @@ uint8_t datetime_day_of_week( } bool datetime_time_is_valid( - BACNET_TIME *btime) + BACNET_TIME * btime) { bool status = false; @@ -232,8 +231,8 @@ bool datetime_time_is_valid( * @return true if the date and time are valid */ bool datetime_is_valid( - BACNET_DATE *bdate, - BACNET_TIME *btime) + BACNET_DATE * bdate, + BACNET_TIME * btime) { return datetime_date_is_valid(bdate) && datetime_time_is_valid(btime); } @@ -447,15 +446,12 @@ static void seconds_since_midnight_into_hms( * @return seconds since midnight */ uint32_t datetime_seconds_since_midnight( - BACNET_TIME *btime) + BACNET_TIME * btime) { uint32_t seconds = 0; if (btime) { - seconds = seconds_since_midnight( - btime->hour, - btime->min, - btime->sec); + seconds = seconds_since_midnight(btime->hour, btime->min, btime->sec); } return seconds; @@ -468,14 +464,12 @@ uint32_t datetime_seconds_since_midnight( * @return minutes since midnight */ uint16_t datetime_minutes_since_midnight( - BACNET_TIME *btime) + BACNET_TIME * btime) { uint32_t minutes = 0; if (btime) { - minutes = minutes_since_midnight( - btime->hour, - btime->min); + minutes = minutes_since_midnight(btime->hour, btime->min); } return minutes; @@ -983,8 +977,8 @@ void testDateEpoch( for (month = 1; month <= 12; month++) { for (day = 1; day <= datetime_month_days(year, month); day++) { days = days_since_epoch(year, month, day); - days_since_epoch_into_ymd(days, - &test_year, &test_month, &test_day); + days_since_epoch_into_ymd(days, &test_year, &test_month, + &test_day); ct_test(pTest, year == test_year); ct_test(pTest, month == test_month); ct_test(pTest, day == test_day); diff --git a/bacnet-stack/src/proplist.c b/bacnet-stack/src/proplist.c index 4ab8b93f..158436bb 100644 --- a/bacnet-stack/src/proplist.c +++ b/bacnet-stack/src/proplist.c @@ -923,7 +923,7 @@ BACNET_PROPERTY_ID property_list_special_property( { int property = -1; /* return value */ unsigned required, optional, proprietary; - struct special_property_list_t PropertyList = {{0}}; + struct special_property_list_t PropertyList = { {0} }; property_list_special(object_type, &PropertyList); required = PropertyList.Required.count; @@ -967,7 +967,7 @@ unsigned property_list_special_count( BACNET_PROPERTY_ID special_property) { unsigned count = 0; /* return value */ - struct special_property_list_t PropertyList = {{0}}; + struct special_property_list_t PropertyList = { {0} }; property_list_special(object_type, &PropertyList); if (special_property == PROP_ALL) { @@ -997,16 +997,15 @@ void testPropList( unsigned object_id = 0, object_name = 0, object_type = 0; for (i = 0; i < OBJECT_PROPRIETARY_MIN; i++) { - count = property_list_special_count((BACNET_OBJECT_TYPE)i, PROP_ALL); + count = property_list_special_count((BACNET_OBJECT_TYPE) i, PROP_ALL); ct_test(pTest, count >= 3); object_id = 0; object_name = 0; object_type = 0; for (j = 0; j < count; j++) { - property = property_list_special_property( - (BACNET_OBJECT_TYPE)i, - PROP_ALL, - j); + property = + property_list_special_property((BACNET_OBJECT_TYPE) i, + PROP_ALL, j); if (property == PROP_OBJECT_TYPE) { object_type++; } diff --git a/bacnet-stack/src/ucix.c b/bacnet-stack/src/ucix.c index fe20ebca..6623cde4 100644 --- a/bacnet-stack/src/ucix.c +++ b/bacnet-stack/src/ucix.c @@ -27,149 +27,195 @@ static struct uci_ptr ptr; -static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t) +static inline int ucix_get_ptr( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + const char *t) { - memset(&ptr, 0, sizeof(ptr)); - ptr.package = p; - ptr.section = s; - ptr.option = o; - ptr.value = t; - return uci_lookup_ptr(ctx, &ptr, NULL, true); + memset(&ptr, 0, sizeof(ptr)); + ptr.package = p; + ptr.section = s; + ptr.option = o; + ptr.value = t; + return uci_lookup_ptr(ctx, &ptr, NULL, true); } -struct uci_context* ucix_init(const char *config_file) +struct uci_context *ucix_init( + const char *config_file) { - struct uci_context *ctx = uci_alloc_context(); -// uci_add_history_path(ctx, "/var/state"); - uci_add_delta_path(ctx, "/var/state"); - if(uci_load(ctx, config_file, NULL) != UCI_OK) - { - fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file); - return NULL; - } - return ctx; + struct uci_context *ctx = uci_alloc_context(); +// uci_add_history_path(ctx, "/var/state"); + uci_add_delta_path(ctx, "/var/state"); + if (uci_load(ctx, config_file, NULL) != UCI_OK) { + fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, + config_file); + return NULL; + } + return ctx; } -struct uci_context* ucix_init_path(const char *path, const char *config_file) +struct uci_context *ucix_init_path( + const char *path, + const char *config_file) { - struct uci_context *ctx = uci_alloc_context(); - if(path) - uci_set_confdir(ctx, path); - if(uci_load(ctx, config_file, NULL) != UCI_OK) - { - fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file); - return NULL; - } - return ctx; + struct uci_context *ctx = uci_alloc_context(); + if (path) + uci_set_confdir(ctx, path); + if (uci_load(ctx, config_file, NULL) != UCI_OK) { + fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, + config_file); + return NULL; + } + return ctx; } -void ucix_cleanup(struct uci_context *ctx) +void ucix_cleanup( + struct uci_context *ctx) { - uci_free_context(ctx); + uci_free_context(ctx); } -void ucix_save(struct uci_context *ctx) +void ucix_save( + struct uci_context *ctx) { - uci_set_savedir(ctx, "/tmp/.uci/"); - uci_save(ctx, NULL); + uci_set_savedir(ctx, "/tmp/.uci/"); + uci_save(ctx, NULL); } -void ucix_save_state(struct uci_context *ctx) +void ucix_save_state( + struct uci_context *ctx) { - uci_set_savedir(ctx, "/var/state/"); - uci_save(ctx, NULL); + uci_set_savedir(ctx, "/var/state/"); + uci_save(ctx, NULL); } -const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o) +const char *ucix_get_option( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o) { - struct uci_element *e = NULL; - const char *value = NULL; - if(ucix_get_ptr(ctx, p, s, o, NULL)) - return NULL; - if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) - return NULL; - e = ptr.last; - switch (e->type) - { - case UCI_TYPE_SECTION: - value = uci_to_section(e)->type; - break; - case UCI_TYPE_OPTION: - switch(ptr.o->type) { - case UCI_TYPE_STRING: - value = ptr.o->v.string; - break; - default: - value = NULL; - break; - } - break; - default: - return 0; - } + struct uci_element *e = NULL; + const char *value = NULL; + if (ucix_get_ptr(ctx, p, s, o, NULL)) + return NULL; + if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) + return NULL; + e = ptr.last; + switch (e->type) { + case UCI_TYPE_SECTION: + value = uci_to_section(e)->type; + break; + case UCI_TYPE_OPTION: + switch (ptr.o->type) { + case UCI_TYPE_STRING: + value = ptr.o->v.string; + break; + default: + value = NULL; + break; + } + break; + default: + return 0; + } - return value; + return value; } -int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def) +int ucix_get_option_int( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + int def) { - const char *tmp = ucix_get_option(ctx, p, s, o); - int ret = def; + const char *tmp = ucix_get_option(ctx, p, s, o); + int ret = def; - if (tmp) - ret = atoi(tmp); - return ret; + if (tmp) + ret = atoi(tmp); + return ret; } -void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t) +void ucix_add_section( + struct uci_context *ctx, + const char *p, + const char *s, + const char *t) { - if(ucix_get_ptr(ctx, p, s, NULL, t)) - return; - uci_set(ctx, &ptr); + if (ucix_get_ptr(ctx, p, s, NULL, t)) + return; + uci_set(ctx, &ptr); } -void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t) +void ucix_add_option( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + const char *t) { - if(ucix_get_ptr(ctx, p, s, o, (t)?(t):(""))) - return; - uci_set(ctx, &ptr); + if (ucix_get_ptr(ctx, p, s, o, (t) ? (t) : (""))) + return; + uci_set(ctx, &ptr); } -void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t) +void ucix_add_option_int( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o, + int t) { - char tmp[64]; - snprintf(tmp, 64, "%d", t); - ucix_add_option(ctx, p, s, o, tmp); + char tmp[64]; + snprintf(tmp, 64, "%d", t); + ucix_add_option(ctx, p, s, o, tmp); } -void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o) +void ucix_del( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o) { - if(!ucix_get_ptr(ctx, p, s, o, NULL)) - uci_delete(ctx, &ptr); + if (!ucix_get_ptr(ctx, p, s, o, NULL)) + uci_delete(ctx, &ptr); } -void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o) +void ucix_revert( + struct uci_context *ctx, + const char *p, + const char *s, + const char *o) { - if(!ucix_get_ptr(ctx, p, s, o, NULL)) - uci_revert(ctx, &ptr); + if (!ucix_get_ptr(ctx, p, s, o, NULL)) + uci_revert(ctx, &ptr); } -void ucix_for_each_section_type(struct uci_context *ctx, - const char *p, const char *t, - void (*cb)(const char*, void*), void *priv) +void ucix_for_each_section_type( + struct uci_context *ctx, + const char *p, + const char *t, + void (*cb) (const char *, + void *), + void *priv) { - struct uci_element *e; - if(ucix_get_ptr(ctx, p, NULL, NULL, NULL)) - return; - uci_foreach_element(&ptr.p->sections, e) - if (!strcmp(t, uci_to_section(e)->type)) - cb(e->name, priv); + struct uci_element *e; + if (ucix_get_ptr(ctx, p, NULL, NULL, NULL)) + return; + uci_foreach_element(&ptr.p->sections, e) + if (!strcmp(t, uci_to_section(e)->type)) + cb(e->name, priv); } -int ucix_commit(struct uci_context *ctx, const char *p) +int ucix_commit( + struct uci_context *ctx, + const char *p) { - if(ucix_get_ptr(ctx, p, NULL, NULL, NULL)) - return 1; - return uci_commit(ctx, &ptr.p, false); + if (ucix_get_ptr(ctx, p, NULL, NULL, NULL)) + return 1; + return uci_commit(ctx, &ptr.p, false); } - diff --git a/bacnet-stack/src/wpm.c b/bacnet-stack/src/wpm.c index 6713e50d..7327ab77 100644 --- a/bacnet-stack/src/wpm.c +++ b/bacnet-stack/src/wpm.c @@ -256,56 +256,58 @@ int wpm_encode_apdu_object_property( } int wpm_encode_apdu( - uint8_t * apdu, - size_t max_apdu, - uint8_t invoke_id, - BACNET_WRITE_ACCESS_DATA * write_access_data) + uint8_t * apdu, + size_t max_apdu, + uint8_t invoke_id, + BACNET_WRITE_ACCESS_DATA * write_access_data) { - int apdu_len = 0; - int len = 0; - BACNET_WRITE_ACCESS_DATA *wpm_object; /* current object */ - uint8_t apdu_temp[MAX_APDU]; /* temp for data before copy */ - BACNET_PROPERTY_VALUE *wpm_property; /* current property */ - BACNET_WRITE_PROPERTY_DATA wpdata; /* for compatibility with wpm_encode_apdu_object_property function */ + int apdu_len = 0; + int len = 0; + BACNET_WRITE_ACCESS_DATA *wpm_object; /* current object */ + uint8_t apdu_temp[MAX_APDU]; /* temp for data before copy */ + BACNET_PROPERTY_VALUE *wpm_property; /* current property */ + BACNET_WRITE_PROPERTY_DATA wpdata; /* for compatibility with wpm_encode_apdu_object_property function */ - if (apdu) { - len = wpm_encode_apdu_init(&apdu[0], invoke_id); - apdu_len += len; + if (apdu) { + len = wpm_encode_apdu_init(&apdu[0], invoke_id); + apdu_len += len; - wpm_object = write_access_data; + wpm_object = write_access_data; - while(wpm_object){ + while (wpm_object) { - len = wpm_encode_apdu_object_begin(&apdu[apdu_len], - wpm_object->object_type, wpm_object->object_instance); - apdu_len += len; + len = + wpm_encode_apdu_object_begin(&apdu[apdu_len], + wpm_object->object_type, wpm_object->object_instance); + apdu_len += len; - wpm_property = wpm_object->listOfProperties; + wpm_property = wpm_object->listOfProperties; - while(wpm_property){ - wpdata.object_property = wpm_property->propertyIdentifier; - wpdata.array_index = wpm_property->propertyArrayIndex; - wpdata.priority = wpm_property->priority; + while (wpm_property) { + wpdata.object_property = wpm_property->propertyIdentifier; + wpdata.array_index = wpm_property->propertyArrayIndex; + wpdata.priority = wpm_property->priority; - wpdata.application_data_len = bacapp_encode_data(&apdu_temp[0], - &wpm_property->value); - memcpy(&wpdata.application_data[0], &apdu_temp[0], - wpdata.application_data_len); + wpdata.application_data_len = + bacapp_encode_data(&apdu_temp[0], &wpm_property->value); + memcpy(&wpdata.application_data[0], &apdu_temp[0], + wpdata.application_data_len); - len = wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata); - apdu_len += len; + len = + wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata); + apdu_len += len; - wpm_property = wpm_property->next; - } + wpm_property = wpm_property->next; + } - len = wpm_encode_apdu_object_end(&apdu[apdu_len]); - apdu_len += len; + len = wpm_encode_apdu_object_end(&apdu[apdu_len]); + apdu_len += len; - wpm_object = wpm_object->next; - } - } + wpm_object = wpm_object->next; + } + } - return apdu_len; + return apdu_len; } int wpm_ack_encode_apdu_init(