From 1477603af679dfa413aaca3f7847a1d8213f47db Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 29 Nov 2007 16:39:48 +0000 Subject: [PATCH] indented. --- bacnet-stack/.indent.pro | 2 +- bacnet-stack/demo/dcc/main.c | 22 +-- bacnet-stack/demo/epics/main.c | 19 ++- bacnet-stack/demo/handler/h_arf.c | 28 ++-- bacnet-stack/demo/handler/h_arf_a.c | 4 +- bacnet-stack/demo/handler/h_awf.c | 28 ++-- bacnet-stack/demo/handler/h_dcc.c | 57 ++++--- bacnet-stack/demo/handler/h_iam.c | 10 +- bacnet-stack/demo/handler/h_rd.c | 34 ++-- bacnet-stack/demo/handler/h_rp.c | 110 ++++++------ bacnet-stack/demo/handler/h_rp_a.c | 3 +- bacnet-stack/demo/handler/h_rpm.c | 87 ++++++---- bacnet-stack/demo/handler/h_ts.c | 10 +- bacnet-stack/demo/handler/h_whohas.c | 9 +- bacnet-stack/demo/handler/h_whois.c | 5 +- bacnet-stack/demo/handler/h_wp.c | 59 +++---- bacnet-stack/demo/handler/noserv.c | 13 +- bacnet-stack/demo/handler/s_arfs.c | 13 +- bacnet-stack/demo/handler/s_awfs.c | 11 +- bacnet-stack/demo/handler/s_dcc.c | 9 +- bacnet-stack/demo/handler/s_ihave.c | 9 +- bacnet-stack/demo/handler/s_rd.c | 13 +- bacnet-stack/demo/handler/s_rp.c | 16 +- bacnet-stack/demo/handler/s_ts.c | 25 +-- bacnet-stack/demo/handler/s_whohas.c | 18 +- bacnet-stack/demo/handler/s_whois.c | 14 +- bacnet-stack/demo/handler/s_wp.c | 27 ++- bacnet-stack/demo/object/ai.c | 8 +- bacnet-stack/demo/object/ao.c | 11 +- bacnet-stack/demo/object/av.c | 11 +- bacnet-stack/demo/object/bacfile.c | 29 ++-- bacnet-stack/demo/object/bi.c | 8 +- bacnet-stack/demo/object/bo.c | 11 +- bacnet-stack/demo/object/bv.c | 11 +- bacnet-stack/demo/object/device.c | 16 +- bacnet-stack/demo/object/lc.c | 84 ++++++---- bacnet-stack/demo/object/lo.c | 24 +-- bacnet-stack/demo/object/lsp.c | 11 +- bacnet-stack/demo/object/mso.c | 14 +- bacnet-stack/demo/readfile/main.c | 20 +-- bacnet-stack/demo/readprop/main.c | 16 +- bacnet-stack/demo/reinit/main.c | 26 ++- bacnet-stack/demo/server/main.c | 15 +- bacnet-stack/demo/timesync/main.c | 18 +- bacnet-stack/demo/ucov/main.c | 52 ++---- bacnet-stack/demo/whohas/main.c | 14 +- bacnet-stack/demo/writefile/main.c | 17 +- bacnet-stack/demo/writeprop/main.c | 56 +++---- bacnet-stack/indent.sh | 2 +- bacnet-stack/ports/at91sam7s/ai.c | 15 +- bacnet-stack/ports/at91sam7s/av.c | 11 +- bacnet-stack/ports/at91sam7s/bi.c | 8 +- bacnet-stack/ports/at91sam7s/bv.c | 11 +- bacnet-stack/ports/at91sam7s/device.c | 16 +- bacnet-stack/ports/at91sam7s/dlmstp.c | 61 ++++--- bacnet-stack/ports/at91sam7s/h_rp.c | 71 ++++---- bacnet-stack/ports/at91sam7s/h_wp.c | 32 ++-- bacnet-stack/ports/at91sam7s/init.c | 5 +- bacnet-stack/ports/at91sam7s/main.c | 3 +- bacnet-stack/ports/atmega168/ai.c | 8 +- bacnet-stack/ports/atmega168/apdu.c | 9 +- bacnet-stack/ports/atmega168/av.c | 11 +- bacnet-stack/ports/atmega168/device.c | 14 +- bacnet-stack/ports/atmega168/dlmstp.c | 42 +++-- bacnet-stack/ports/atmega168/h_rp.c | 50 +++--- bacnet-stack/ports/atmega168/h_whois.c | 5 +- bacnet-stack/ports/atmega168/h_wp.c | 20 ++- bacnet-stack/ports/linux/arcnet.c | 19 +-- bacnet-stack/ports/linux/bip-init.c | 18 +- bacnet-stack/ports/linux/dlmstp.c | 49 +++--- bacnet-stack/ports/linux/ethernet.c | 23 ++- bacnet-stack/ports/linux/main.c | 9 +- bacnet-stack/ports/linux/rx_fsm.c | 14 +- bacnet-stack/ports/pic18f6720/ai.c | 15 +- bacnet-stack/ports/pic18f6720/av.c | 11 +- bacnet-stack/ports/pic18f6720/bi.c | 8 +- bacnet-stack/ports/pic18f6720/bv.c | 11 +- bacnet-stack/ports/pic18f6720/device.c | 16 +- bacnet-stack/ports/pic18f6720/dlmstp.c | 13 +- bacnet-stack/ports/pic18f6720/h_rp.c | 81 +++++---- bacnet-stack/ports/pic18f6720/h_wp.c | 32 ++-- bacnet-stack/ports/pic18f6720/main.c | 7 +- bacnet-stack/ports/pic18f6720/mstp.c | 85 ++++------ bacnet-stack/ports/rtos32/bip-init.c | 8 +- bacnet-stack/ports/rtos32/dlmstp.c | 9 +- bacnet-stack/ports/rtos32/ethernet.c | 7 +- bacnet-stack/ports/rtos32/mstp.c | 85 ++++------ bacnet-stack/ports/win32/bip-init.c | 31 ++-- bacnet-stack/ports/win32/dlmstp.c | 44 +++-- bacnet-stack/ports/win32/ethernet.c | 22 ++- bacnet-stack/ports/win32/main.c | 9 +- bacnet-stack/ports/win32/rs485.c | 5 +- bacnet-stack/ports/win32/rx_fsm.c | 14 +- bacnet-stack/src/abort.c | 30 ++-- bacnet-stack/src/address.c | 7 +- bacnet-stack/src/apdu.c | 8 +- bacnet-stack/src/arf.c | 163 +++++++++++------- bacnet-stack/src/awf.c | 109 +++++++----- bacnet-stack/src/bacapp.c | 224 +++++++++++++++---------- bacnet-stack/src/bacdcode.c | 70 ++++---- bacnet-stack/src/bacerror.c | 78 +++++---- bacnet-stack/src/bacstr.c | 37 ++-- bacnet-stack/src/bactext.c | 84 +++++----- bacnet-stack/src/bip.c | 8 +- bacnet-stack/src/bvlc.c | 23 +-- bacnet-stack/src/cov.c | 101 ++++++----- bacnet-stack/src/datalink.c | 4 +- bacnet-stack/src/datetime.c | 36 ++-- bacnet-stack/src/dcc.c | 36 ++-- bacnet-stack/src/iam.c | 24 +-- bacnet-stack/src/ihave.c | 22 ++- bacnet-stack/src/keylist.c | 12 +- bacnet-stack/src/mstptext.c | 4 +- bacnet-stack/src/rd.c | 24 +-- bacnet-stack/src/reject.c | 29 ++-- bacnet-stack/src/rp.c | 62 ++++--- bacnet-stack/src/rpm.c | 178 ++++++++++++-------- bacnet-stack/src/timesync.c | 9 +- bacnet-stack/src/tsm.c | 7 +- bacnet-stack/src/whohas.c | 26 +-- bacnet-stack/src/whois.c | 21 +-- bacnet-stack/src/wp.c | 73 ++++---- bacnet-stack/test/ctest.c | 7 +- 123 files changed, 1994 insertions(+), 1688 deletions(-) diff --git a/bacnet-stack/.indent.pro b/bacnet-stack/.indent.pro index 277b98a4..22a1b031 100644 --- a/bacnet-stack/.indent.pro +++ b/bacnet-stack/.indent.pro @@ -1 +1 @@ --kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 +-kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 -nhnl diff --git a/bacnet-stack/demo/dcc/main.c b/bacnet-stack/demo/dcc/main.c index e2bfd925..a774f049 100644 --- a/bacnet-stack/demo/dcc/main.c +++ b/bacnet-stack/demo/dcc/main.c @@ -72,8 +72,7 @@ static void MyErrorHandler( /* FIXME: verify src and invoke id */ (void) src; (void) invoke_id; - printf("BACnet Error: %s: %s\r\n", - bactext_error_class_name(error_class), + printf("BACnet Error: %s: %s\r\n", bactext_error_class_name(error_class), bactext_error_code_name(error_code)); Error_Detected = true; } @@ -129,8 +128,7 @@ static void Init_Service_Handlers( apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property); /* handle communication so we can shutup when asked */ - apdu_set_confirmed_handler - (SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, + apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, handler_device_communication_control); /* handle the ack coming back */ apdu_set_confirmed_simple_ack_handler @@ -162,11 +160,8 @@ int main( /* note: priority 16 and 0 should produce the same end results... */ printf("Usage: %s device-instance state timeout [password]\r\n" "Send BACnet DeviceCommunicationControl service to device.\r\n" - "\r\n" - "The device-instance can be 0 to %d.\r\n" - "Possible state values:\r\n" - " 0=enable\r\n" - " 1=disable\r\n" + "\r\n" "The device-instance can be 0 to %d.\r\n" + "Possible state values:\r\n" " 0=enable\r\n" " 1=disable\r\n" " 2=disable-initiation\r\n" "The timeout can be 0 for infinite, or a value in minutes for disable.\r\n" "The optional password is a character string of 1 to 20 characters.\r\n" @@ -196,8 +191,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); /* loop forever */ @@ -218,8 +213,9 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { if (invoke_id == 0) { invoke_id = diff --git a/bacnet-stack/demo/epics/main.c b/bacnet-stack/demo/epics/main.c index 884c6658..743e5792 100644 --- a/bacnet-stack/demo/epics/main.c +++ b/bacnet-stack/demo/epics/main.c @@ -79,8 +79,7 @@ static void MyErrorHandler( (void) src; (void) invoke_id; #if 1 - printf("BACnet Error: %s: %s\r\n", - bactext_error_class_name(error_class), + printf("BACnet Error: %s: %s\r\n", bactext_error_class_name(error_class), bactext_error_code_name(error_code)); #else (void) error_class; @@ -151,7 +150,8 @@ void PrintReadPropertyData( application_data_len = data->application_data_len; /* value? loop until all of the len is gone... */ for (;;) { - len = bacapp_decode_application_data(application_data, + len = + bacapp_decode_application_data(application_data, (uint8_t) application_data_len, &value); if (first_value && (len < application_data_len)) { first_value = false; @@ -233,8 +233,8 @@ static uint8_t Read_Properties( if (pRequired[index] != -1) { printf(" %s: ", bactext_property_name(pRequired[index])); - invoke_id = Send_Read_Property_Request(device_instance, - OBJECT_DEVICE, + invoke_id = + Send_Read_Property_Request(device_instance, OBJECT_DEVICE, device_instance, pRequired[index], BACNET_ARRAY_ALL); if (invoke_id) { index++; @@ -282,8 +282,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); printf("List of Objects in test device:\r\n"); @@ -305,8 +305,9 @@ int main( tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000)); } /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { /* invoke ID is set to zero when it is not in use */ if (invoke_id == 0) { diff --git a/bacnet-stack/demo/handler/h_arf.c b/bacnet-stack/demo/handler/h_arf.c index df575bf9..04f39cdb 100644 --- a/bacnet-stack/demo/handler/h_arf.c +++ b/bacnet-stack/demo/handler/h_arf.c @@ -117,12 +117,14 @@ void handler_atomic_read_file( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED fprintf(stderr, "ARF: Segmented Message. Sending Abort!\n"); #endif @@ -131,7 +133,8 @@ void handler_atomic_read_file( len = arf_decode_service_request(service_request, service_len, &data); /* bad decoding - send an abort */ if (len < 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); #if PRINT_ENABLED fprintf(stderr, "Bad Encoding. Sending Abort!\n"); @@ -151,8 +154,8 @@ void handler_atomic_read_file( data.type.stream.requestedOctetCount); #endif len = - arf_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + arf_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); } else { error = true; error_class = ERROR_CLASS_OBJECT; @@ -185,13 +188,14 @@ void handler_atomic_read_file( if (error) { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_ATOMIC_READ_FILE, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_ATOMIC_READ_FILE, + error_class, error_code); } ARF_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) { fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); diff --git a/bacnet-stack/demo/handler/h_arf_a.c b/bacnet-stack/demo/handler/h_arf_a.c index e6d2a80e..65ab8c53 100644 --- a/bacnet-stack/demo/handler/h_arf_a.c +++ b/bacnet-stack/demo/handler/h_arf_a.c @@ -73,8 +73,8 @@ void handler_atomic_read_file_ack( if (pFilename) { pFile = fopen(pFilename, "rb"); if (pFile) { - (void) fseek(pFile, - data.type.stream.fileStartPosition, SEEK_SET); + (void) fseek(pFile, data.type.stream.fileStartPosition, + SEEK_SET); if (fwrite(octetstring_value(&data.fileData), octetstring_length(&data.fileData), 1, pFile) != 1) { diff --git a/bacnet-stack/demo/handler/h_awf.c b/bacnet-stack/demo/handler/h_awf.c index 021d24a7..10b59754 100644 --- a/bacnet-stack/demo/handler/h_awf.c +++ b/bacnet-stack/demo/handler/h_awf.c @@ -95,12 +95,14 @@ void handler_atomic_write_file( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED fprintf(stderr, "Segmented Message. Sending Abort!\n"); #endif @@ -109,7 +111,8 @@ void handler_atomic_write_file( len = awf_decode_service_request(service_request, service_len, &data); /* bad decoding - send an abort */ if (len < 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); #if PRINT_ENABLED fprintf(stderr, "Bad Encoding. Sending Abort!\n"); @@ -127,8 +130,8 @@ void handler_atomic_write_file( octetstring_length(&data.fileData)); #endif len = - awf_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + awf_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); } else { error = true; error_class = ERROR_CLASS_OBJECT; @@ -150,13 +153,14 @@ void handler_atomic_write_file( if (error) { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_ATOMIC_READ_FILE, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_ATOMIC_READ_FILE, + error_class, error_code); } AWF_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) { fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); diff --git a/bacnet-stack/demo/handler/h_dcc.c b/bacnet-stack/demo/handler/h_dcc.c index 334afc93..34f83b53 100644 --- a/bacnet-stack/demo/handler/h_dcc.c +++ b/bacnet-stack/demo/handler/h_dcc.c @@ -58,56 +58,65 @@ void handler_device_communication_control( /* encode the NPDU portion of the reply packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); #if PRINT_ENABLED fprintf(stderr, "DeviceCommunicationControl!\n"); #endif if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED - fprintf(stderr, "DeviceCommunicationControl: " + fprintf(stderr, + "DeviceCommunicationControl: " "Sending Abort - segmented message.\n"); #endif goto DCC_ABORT; } /* decode the service request only */ - len = dcc_decode_service_request(service_request, - service_len, &timeDuration, &state, &password); + len = + dcc_decode_service_request(service_request, service_len, &timeDuration, + &state, &password); #if PRINT_ENABLED if (len > 0) - fprintf(stderr, "DeviceCommunicationControl: " - "timeout=%u state=%u password=%s\n", - (unsigned) timeDuration, - (unsigned) state, characterstring_value(&password)); + fprintf(stderr, + "DeviceCommunicationControl: " "timeout=%u state=%u password=%s\n", + (unsigned) timeDuration, (unsigned) state, + characterstring_value(&password)); #endif /* bad decoding or something we didn't understand - send an abort */ if (len < 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); #if PRINT_ENABLED - fprintf(stderr, "DeviceCommunicationControl: " + fprintf(stderr, + "DeviceCommunicationControl: " "Sending Abort - could not decode.\n"); #endif goto DCC_ABORT; } if (state >= MAX_BACNET_COMMUNICATION_ENABLE_DISABLE) { - len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, REJECT_REASON_UNDEFINED_ENUMERATION); #if PRINT_ENABLED - fprintf(stderr, "DeviceCommunicationControl: " + fprintf(stderr, + "DeviceCommunicationControl: " "Sending Reject - undefined enumeration\n"); #endif } else { if (characterstring_ansi_same(&password, My_Password)) { - len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], + len = + encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL); #if PRINT_ENABLED - fprintf(stderr, "DeviceCommunicationControl: " - "Sending Simple Ack!\n"); + fprintf(stderr, + "DeviceCommunicationControl: " "Sending Simple Ack!\n"); #endif dcc_set_status_duration(state, timeDuration); } else { @@ -125,12 +134,14 @@ void handler_device_communication_control( } DCC_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) - fprintf(stderr, "DeviceCommunicationControl: " - "Failed to send PDU (%s)!\n", strerror(errno)); + fprintf(stderr, + "DeviceCommunicationControl: " "Failed to send PDU (%s)!\n", + strerror(errno)); #endif return; diff --git a/bacnet-stack/demo/handler/h_iam.c b/bacnet-stack/demo/handler/h_iam.c index 97b20ac9..b3bf31d2 100644 --- a/bacnet-stack/demo/handler/h_iam.c +++ b/bacnet-stack/demo/handler/h_iam.c @@ -44,8 +44,9 @@ void handler_i_am_add( uint16_t vendor_id = 0; (void) service_len; - len = iam_decode_service_request(service_request, - &device_id, &max_apdu, &segmentation, &vendor_id); + len = + iam_decode_service_request(service_request, &device_id, &max_apdu, + &segmentation, &vendor_id); #if PRINT_ENABLED fprintf(stderr, "Received I-Am Request"); #endif @@ -75,8 +76,9 @@ void handler_i_am_bind( uint16_t vendor_id = 0; (void) service_len; - len = iam_decode_service_request(service_request, - &device_id, &max_apdu, &segmentation, &vendor_id); + len = + iam_decode_service_request(service_request, &device_id, &max_apdu, + &segmentation, &vendor_id); /* only add address if requested to bind */ address_add_binding(device_id, max_apdu, src); diff --git a/bacnet-stack/demo/handler/h_rd.c b/bacnet-stack/demo/handler/h_rd.c index 754f54e6..1bd49382 100644 --- a/bacnet-stack/demo/handler/h_rd.c +++ b/bacnet-stack/demo/handler/h_rd.c @@ -58,15 +58,17 @@ void handler_reinitialize_device( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); #if PRINT_ENABLED fprintf(stderr, "ReinitializeDevice!\n"); #endif if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED fprintf(stderr, "ReinitializeDevice: Sending Abort - segmented message.\n"); @@ -74,8 +76,9 @@ void handler_reinitialize_device( goto RD_ABORT; } /* decode the service request only */ - len = rd_decode_service_request(service_request, - service_len, &state, &their_password); + len = + rd_decode_service_request(service_request, service_len, &state, + &their_password); #if PRINT_ENABLED if (len > 0) fprintf(stderr, "ReinitializeDevice: state=%u password=%s\n", @@ -85,7 +88,8 @@ void handler_reinitialize_device( #endif /* bad decoding or something we didn't understand - send an abort */ if (len < 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); #if PRINT_ENABLED fprintf(stderr, @@ -95,7 +99,8 @@ void handler_reinitialize_device( } /* check the data from the request */ if (state >= MAX_BACNET_REINITIALIZED_STATE) { - len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, REJECT_REASON_UNDEFINED_ENUMERATION); #if PRINT_ENABLED fprintf(stderr, @@ -104,7 +109,8 @@ void handler_reinitialize_device( } else { characterstring_init_ansi(&My_Password, Password); if (characterstring_same(&their_password, &My_Password)) { - len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], + len = + encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE); #if PRINT_ENABLED @@ -117,8 +123,7 @@ void handler_reinitialize_device( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_REINITIALIZE_DEVICE, + service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE, ERROR_CLASS_SERVICES, ERROR_CODE_PASSWORD_FAILURE); #if PRINT_ENABLED fprintf(stderr, @@ -128,8 +133,9 @@ void handler_reinitialize_device( } RD_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) fprintf(stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n", diff --git a/bacnet-stack/demo/handler/h_rp.c b/bacnet-stack/demo/handler/h_rp.c index f1df99c3..a2872603 100644 --- a/bacnet-stack/demo/handler/h_rp.c +++ b/bacnet-stack/demo/handler/h_rp.c @@ -72,78 +72,88 @@ int Encode_Property_APDU( switch (object_type) { case OBJECT_DEVICE: if (Device_Valid_Object_Instance_Number(object_instance)) { - apdu_len = Device_Encode_Property_APDU(&apdu[0], - property, array_index, error_class, error_code); + apdu_len = + Device_Encode_Property_APDU(&apdu[0], property, + array_index, error_class, error_code); } break; case OBJECT_ANALOG_INPUT: if (Analog_Input_Valid_Instance(object_instance)) { - apdu_len = Analog_Input_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Analog_Input_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_ANALOG_OUTPUT: if (Analog_Output_Valid_Instance(object_instance)) { - apdu_len = Analog_Output_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Analog_Output_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_ANALOG_VALUE: if (Analog_Value_Valid_Instance(object_instance)) { - apdu_len = Analog_Value_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Analog_Value_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_BINARY_INPUT: if (Binary_Input_Valid_Instance(object_instance)) { - apdu_len = Binary_Input_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Binary_Input_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_BINARY_OUTPUT: if (Binary_Output_Valid_Instance(object_instance)) { - apdu_len = Binary_Output_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Binary_Output_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_BINARY_VALUE: if (Binary_Value_Valid_Instance(object_instance)) { - apdu_len = Binary_Value_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Binary_Value_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_LIFE_SAFETY_POINT: if (Life_Safety_Point_Valid_Instance(object_instance)) { - apdu_len = Life_Safety_Point_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Life_Safety_Point_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_LOAD_CONTROL: if (Load_Control_Valid_Instance(object_instance)) { - apdu_len = Load_Control_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Load_Control_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_MULTI_STATE_OUTPUT: if (Multistate_Output_Valid_Instance(object_instance)) { - apdu_len = Multistate_Output_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Multistate_Output_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; #if defined(BACFILE) case OBJECT_FILE: if (bacfile_valid_instance(object_instance)) { - apdu_len = bacfile_encode_property_apdu(&apdu[0], - object_instance, + apdu_len = + bacfile_encode_property_apdu(&apdu[0], object_instance, property, array_index, error_class, error_code); } break; @@ -176,13 +186,15 @@ void handler_read_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { /* we don't support segmentation - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED fprintf(stderr, "RP: Segmented message. Sending Abort!\n"); #endif @@ -196,7 +208,8 @@ void handler_read_property( #endif if (len < 0) { /* bad decoding - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); #if PRINT_ENABLED fprintf(stderr, "RP: Bad Encoding. Sending Abort!\n"); @@ -206,10 +219,10 @@ void handler_read_property( /* assume that there is an error */ error = true; - len = Encode_Property_APDU(&Temp_Buf[0], - data.object_type, - data.object_instance, - data.object_property, data.array_index, &error_class, &error_code); + len = + Encode_Property_APDU(&Temp_Buf[0], data.object_type, + data.object_instance, data.object_property, data.array_index, + &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ data.application_data = &Temp_Buf[0]; @@ -226,16 +239,18 @@ void handler_read_property( if (error) { if (len == -2) { /* BACnet APDU too small to fit data, so proper response is Abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); #if PRINT_ENABLED fprintf(stderr, "RP: Reply too big to fit into APDU!\n"); #endif } else { - len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code); + len = + bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "RP: Sending Error!\n"); #endif @@ -243,8 +258,9 @@ void handler_read_property( } RP_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); diff --git a/bacnet-stack/demo/handler/h_rp_a.c b/bacnet-stack/demo/handler/h_rp_a.c index b446df94..1a2d83d7 100644 --- a/bacnet-stack/demo/handler/h_rp_a.c +++ b/bacnet-stack/demo/handler/h_rp_a.c @@ -71,7 +71,8 @@ static void PrintReadPropertyData( /* FIXME: what if application_data_len is bigger than 255? */ /* value? need to loop until all of the len is gone... */ for (;;) { - len = bacapp_decode_application_data(application_data, + len = + bacapp_decode_application_data(application_data, (uint8_t) application_data_len, &value); if (first_value && (len < application_data_len)) { first_value = false; diff --git a/bacnet-stack/demo/handler/h_rpm.c b/bacnet-stack/demo/handler/h_rpm.c index a477c942..a1b2d8e0 100644 --- a/bacnet-stack/demo/handler/h_rpm.c +++ b/bacnet-stack/demo/handler/h_rpm.c @@ -198,8 +198,9 @@ static unsigned RPM_Object_Property_Count( unsigned count = 0; /* return value */ if (special_property == PROP_ALL) { - count = pPropertyList->Required.count + - pPropertyList->Optional.count + pPropertyList->Proprietary.count; + count = + pPropertyList->Required.count + pPropertyList->Optional.count + + pPropertyList->Proprietary.count; } else if (special_property == PROP_REQUIRED) { count = pPropertyList->Required.count; } else if (special_property == PROP_OPTIONAL) { @@ -246,19 +247,20 @@ int RPM_Encode_Property( BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT; BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT; - len = rpm_ack_encode_apdu_object_property(&Temp_Buf[0], - object_property, array_index); + len = + rpm_ack_encode_apdu_object_property(&Temp_Buf[0], object_property, + array_index); len = apdu_copy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu); if (!len) return 0; apdu_len += len; - len = Encode_Property_APDU(&Temp_Buf[0], - object_type, - object_instance, + len = + Encode_Property_APDU(&Temp_Buf[0], object_type, object_instance, object_property, array_index, &error_class, &error_code); if (len < 0) { /* error was returned - encode that for the response */ - len = rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0], + len = + rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0], error_class, error_code); len = apdu_copy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len, @@ -304,12 +306,14 @@ void handler_read_property_multiple( /* encode the NPDU portion of the packet */ datalink_get_my_address(&my_address); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - npdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], - src, &my_address, &npdu_data); + npdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { - apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + apdu_len = + abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED printf("RPM: Segmented message. Sending Abort!\r\n"); #endif @@ -317,16 +321,19 @@ void handler_read_property_multiple( } /* decode apdu request & encode apdu reply encode complex ack, invoke id, service choice */ - apdu_len = rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len], + apdu_len = + rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id); do { - len = rpm_decode_object_id(&service_request[decode_len], + len = + rpm_decode_object_id(&service_request[decode_len], service_len - decode_len, &object_type, &object_instance); /* end of object? */ if (len > 0) { decode_len += len; } else { - len = rpm_decode_object_end(&service_request[decode_len], + len = + rpm_decode_object_end(&service_request[decode_len], service_len - decode_len); if (len == 1) { decode_len++; @@ -351,12 +358,15 @@ void handler_read_property_multiple( } break; } - len = rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], - object_type, object_instance); - copy_len = apdu_copy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], + len = + rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], object_type, + object_instance); + copy_len = + apdu_copy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], apdu_len, len, sizeof(Handler_Transmit_Buffer)); if (!copy_len) { - apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], + apdu_len = + abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); goto RPM_ABORT; @@ -365,13 +375,15 @@ void handler_read_property_multiple( } /* do each property of this object of the RPM request */ do { - len = rpm_decode_object_property(&service_request[decode_len], + len = + rpm_decode_object_property(&service_request[decode_len], service_len - decode_len, &object_property, &array_index); /* end of property list? */ if (len > 0) { decode_len += len; } else { - len = rpm_decode_object_end(&service_request[decode_len], + len = + rpm_decode_object_end(&service_request[decode_len], service_len - decode_len); if (len == 1) { decode_len++; @@ -409,16 +421,18 @@ void handler_read_property_multiple( special_object_property = object_property; RPM_Property_List(object_type, &property_list); - property_count = RPM_Object_Property_Count(&property_list, + property_count = + RPM_Object_Property_Count(&property_list, special_object_property); for (index = 0; index < property_count; index++) { - object_property = RPM_Object_Property(&property_list, + object_property = + RPM_Object_Property(&property_list, special_object_property, index); - len = RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, - sizeof(Handler_Transmit_Buffer), - object_type, - object_instance, object_property, array_index); + len = + RPM_Encode_Property(&Handler_Transmit_Buffer[0], + npdu_len + apdu_len, sizeof(Handler_Transmit_Buffer), + object_type, object_instance, object_property, + array_index); if (len > 0) { apdu_len += len; } else { @@ -431,11 +445,11 @@ void handler_read_property_multiple( } } else { /* handle an individual property */ - len = RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, - sizeof(Handler_Transmit_Buffer), - object_type, - object_instance, object_property, array_index); + len = + RPM_Encode_Property(&Handler_Transmit_Buffer[0], + npdu_len + apdu_len, sizeof(Handler_Transmit_Buffer), + object_type, object_instance, object_property, + array_index); if (len > 0) { apdu_len += len; } else { @@ -453,6 +467,7 @@ void handler_read_property_multiple( } while (1); RPM_ABORT: pdu_len = apdu_len + npdu_len; - bytes_sent = datalink_send_pdu(src, - &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); } diff --git a/bacnet-stack/demo/handler/h_ts.c b/bacnet-stack/demo/handler/h_ts.c index 3f24a270..884afbcd 100644 --- a/bacnet-stack/demo/handler/h_ts.c +++ b/bacnet-stack/demo/handler/h_ts.c @@ -60,8 +60,9 @@ void handler_timesync( (void) src; (void) service_len; - len = timesync_decode_service_request(service_request, - service_len, &bdate, &btime); + len = + timesync_decode_service_request(service_request, service_len, &bdate, + &btime); #if PRINT_ENABLED fprintf(stderr, "Received TimeSyncronization Request\r\n"); show_bacnet_date_time(&bdate, &btime); @@ -82,8 +83,9 @@ void handler_timesync_utc( (void) src; (void) service_len; - len = timesync_decode_service_request(service_request, - service_len, &bdate, &btime); + len = + timesync_decode_service_request(service_request, service_len, &bdate, + &btime); #if PRINT_ENABLED fprintf(stderr, "Received TimeSyncronization Request\r\n"); show_bacnet_date_time(&bdate, &btime); diff --git a/bacnet-stack/demo/handler/h_whohas.c b/bacnet-stack/demo/handler/h_whohas.c index c2b6ef9a..a36d5166 100644 --- a/bacnet-stack/demo/handler/h_whohas.c +++ b/bacnet-stack/demo/handler/h_whohas.c @@ -62,11 +62,12 @@ void handler_who_has( if (data.object_name) { /* valid name in my device? */ object_name = characterstring_value(&data.object.name); - found = Device_Valid_Object_Name(object_name, - &object_type, &object_instance); + found = + Device_Valid_Object_Name(object_name, &object_type, + &object_instance); if (found) - Send_I_Have(Device_Object_Instance_Number(), - object_type, object_instance, object_name); + Send_I_Have(Device_Object_Instance_Number(), object_type, + object_instance, object_name); } else { /* valid object in my device? */ object_name = diff --git a/bacnet-stack/demo/handler/h_whois.c b/bacnet-stack/demo/handler/h_whois.c index 5c7c8532..d34d0aeb 100644 --- a/bacnet-stack/demo/handler/h_whois.c +++ b/bacnet-stack/demo/handler/h_whois.c @@ -47,8 +47,9 @@ void handler_who_is( int32_t high_limit = 0; (void) src; - len = whois_decode_service_request(service_request, - service_len, &low_limit, &high_limit); + len = + whois_decode_service_request(service_request, service_len, &low_limit, + &high_limit); if (len == 0) iam_send(&Handler_Transmit_Buffer[0]); else if (len != -1) { diff --git a/bacnet-stack/demo/handler/h_wp.c b/bacnet-stack/demo/handler/h_wp.c index 5bda2ceb..b673b935 100644 --- a/bacnet-stack/demo/handler/h_wp.c +++ b/bacnet-stack/demo/handler/h_wp.c @@ -68,15 +68,17 @@ void handler_write_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); #if PRINT_ENABLED fprintf(stderr, "WP: Received Request!\n"); #endif if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); #if PRINT_ENABLED fprintf(stderr, "WP: Segmented message. Sending Abort!\n"); #endif @@ -86,15 +88,15 @@ void handler_write_property( #if PRINT_ENABLED if (len > 0) fprintf(stderr, "WP: type=%u instance=%u property=%u index=%d\n", - wp_data.object_type, - wp_data.object_instance, + wp_data.object_type, wp_data.object_instance, wp_data.object_property, wp_data.array_index); else fprintf(stderr, "WP: Unable to decode Request!\n"); #endif /* bad decoding or something we didn't understand - send an abort */ if (len <= 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); #if PRINT_ENABLED fprintf(stderr, "WP: Bad Encoding. Sending Abort!\n"); @@ -113,8 +115,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Error for Device!\n"); #endif @@ -144,8 +146,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for BO!\n"); #endif @@ -163,8 +165,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for BV!\n"); #endif @@ -182,8 +184,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for AO!\n"); #endif @@ -201,8 +203,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for AV!\n"); #endif @@ -220,8 +222,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for LSP!\n"); #endif @@ -239,8 +241,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for Load Control!\n"); @@ -260,8 +262,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for MSO!\n"); #endif @@ -279,8 +281,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "WP: Sending Write Access Error for File!\n"); #endif @@ -299,8 +301,9 @@ void handler_write_property( } WP_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) fprintf(stderr, "WP: Failed to send PDU (%s)!\n", strerror(errno)); diff --git a/bacnet-stack/demo/handler/noserv.c b/bacnet-stack/demo/handler/noserv.c index 07b3cf1e..205a1ce8 100644 --- a/bacnet-stack/demo/handler/noserv.c +++ b/bacnet-stack/demo/handler/noserv.c @@ -52,15 +52,18 @@ void handler_unrecognized_service( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); /* encode the APDU portion of the packet */ - len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE); pdu_len += len; /* send the data */ - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent > 0) fprintf(stderr, "Sent Reject!\n"); diff --git a/bacnet-stack/demo/handler/s_arfs.c b/bacnet-stack/demo/handler/s_arfs.c index 58440b9f..8d3cb252 100644 --- a/bacnet-stack/demo/handler/s_arfs.c +++ b/bacnet-stack/demo/handler/s_arfs.c @@ -78,10 +78,12 @@ uint8_t Send_Atomic_Read_File_Stream( /* 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 = arf_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - invoke_id, &data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, + &npdu_data); + len = + arf_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 @@ -104,7 +106,8 @@ uint8_t Send_Atomic_Read_File_Stream( tsm_free_invoke_id(invoke_id); invoke_id = 0; #if PRINT_ENABLED - fprintf(stderr, "Failed to Send AtomicReadFile Request " + fprintf(stderr, + "Failed to Send AtomicReadFile Request " "(payload exceeds destination maximum APDU)!\n"); #endif } diff --git a/bacnet-stack/demo/handler/s_awfs.c b/bacnet-stack/demo/handler/s_awfs.c index 1f9fe82a..ade1a64f 100644 --- a/bacnet-stack/demo/handler/s_awfs.c +++ b/bacnet-stack/demo/handler/s_awfs.c @@ -83,8 +83,9 @@ uint8_t Send_Atomic_Write_File_Stream( 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); + 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 @@ -107,7 +108,8 @@ uint8_t Send_Atomic_Write_File_Stream( tsm_free_invoke_id(invoke_id); invoke_id = 0; #if PRINT_ENABLED - fprintf(stderr, "Failed to Send AtomicWriteFile Request " + fprintf(stderr, + "Failed to Send AtomicWriteFile Request " "(payload [%d] exceeds destination maximum APDU [%u])!\n", pdu_len, max_apdu); #endif @@ -116,7 +118,8 @@ uint8_t Send_Atomic_Write_File_Stream( tsm_free_invoke_id(invoke_id); invoke_id = 0; #if PRINT_ENABLED - fprintf(stderr, "Failed to Send AtomicWriteFile Request " + fprintf(stderr, + "Failed to Send AtomicWriteFile Request " "(payload [%d] exceeds octet string capacity)!\n", pdu_len); #endif } diff --git a/bacnet-stack/demo/handler/s_dcc.c b/bacnet-stack/demo/handler/s_dcc.c index e5928be5..59738abc 100644 --- a/bacnet-stack/demo/handler/s_dcc.c +++ b/bacnet-stack/demo/handler/s_dcc.c @@ -72,12 +72,13 @@ uint8_t Send_Device_Communication_Control_Request( /* 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); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, + &npdu_data); /* encode the APDU portion of the packet */ characterstring_init_ansi(&password_string, password); - len = dcc_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - invoke_id, + len = + dcc_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, timeDuration, state, password ? &password_string : NULL); pdu_len += len; /* will it fit in the sender? diff --git a/bacnet-stack/demo/handler/s_ihave.c b/bacnet-stack/demo/handler/s_ihave.c index 00685141..d00d6bb7 100644 --- a/bacnet-stack/demo/handler/s_ihave.c +++ b/bacnet-stack/demo/handler/s_ihave.c @@ -64,8 +64,8 @@ void Send_I_Have( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, - NULL, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); /* encode the APDU portion of the packet */ data.device_id.type = OBJECT_DEVICE; data.device_id.instance = device_id; @@ -75,8 +75,9 @@ void Send_I_Have( len = ihave_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data); pdu_len += len; /* send the data */ - bytes_sent = datalink_send_pdu(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], 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 I-Have Reply (%s)!\n", diff --git a/bacnet-stack/demo/handler/s_rd.c b/bacnet-stack/demo/handler/s_rd.c index 890226f4..af556853 100644 --- a/bacnet-stack/demo/handler/s_rd.c +++ b/bacnet-stack/demo/handler/s_rd.c @@ -71,12 +71,14 @@ uint8_t Send_Reinitialize_Device_Request( /* 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); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, + &npdu_data); /* encode the APDU portion of the packet */ characterstring_init_ansi(&password_string, password); - len = rd_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - invoke_id, state, password ? &password_string : NULL); + len = + rd_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, state, + password ? &password_string : NULL); pdu_len += len; /* will it fit in the sender? note: if there is a bottleneck router in between @@ -99,7 +101,8 @@ uint8_t Send_Reinitialize_Device_Request( tsm_free_invoke_id(invoke_id); invoke_id = 0; #if PRINT_ENABLED - fprintf(stderr, "Failed to Send ReinitializeDevice Request " + fprintf(stderr, + "Failed to Send ReinitializeDevice Request " "(exceeds destination maximum APDU)!\n"); #endif } diff --git a/bacnet-stack/demo/handler/s_rp.c b/bacnet-stack/demo/handler/s_rp.c index e312ef57..a8b30a84 100644 --- a/bacnet-stack/demo/handler/s_rp.c +++ b/bacnet-stack/demo/handler/s_rp.c @@ -74,15 +74,17 @@ uint8_t Send_Read_Property_Request( /* 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); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, + &npdu_data); /* encode the APDU portion of the packet */ data.object_type = object_type; data.object_instance = object_instance; data.object_property = object_property; data.array_index = array_index; - len = rp_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - invoke_id, &data); + len = + rp_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, + &data); pdu_len += len; /* will it fit in the sender? note: if there is a bottleneck router in between @@ -97,15 +99,15 @@ uint8_t Send_Read_Property_Request( &Handler_Transmit_Buffer[0], pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) - fprintf(stderr, - "Failed to Send ReadProperty Request (%s)!\n", + fprintf(stderr, "Failed to Send ReadProperty Request (%s)!\n", strerror(errno)); #endif } else { tsm_free_invoke_id(invoke_id); invoke_id = 0; #if PRINT_ENABLED - fprintf(stderr, "Failed to Send ReadProperty Request " + fprintf(stderr, + "Failed to Send ReadProperty Request " "(exceeds destination maximum APDU)!\n"); #endif } diff --git a/bacnet-stack/demo/handler/s_ts.c b/bacnet-stack/demo/handler/s_ts.c index 54ec5e54..523c7fb6 100644 --- a/bacnet-stack/demo/handler/s_ts.c +++ b/bacnet-stack/demo/handler/s_ts.c @@ -59,19 +59,19 @@ void Send_TimeSync( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, - NULL, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &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(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], 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 Time-Synchronization Request (%s)!\n", + fprintf(stderr, "Failed to Send Time-Synchronization Request (%s)!\n", strerror(errno)); #endif } @@ -91,10 +91,11 @@ void Send_TimeSyncUTC( /* we could use unicast or broadcast */ datalink_get_broadcast_address(&dest); /* encode the APDU portion of the packet */ - pdu_len = timesync_utc_encode_apdu(&Handler_Transmit_Buffer[0], - bdate, btime); - bytes_sent = datalink_send_pdu(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + pdu_len = + timesync_utc_encode_apdu(&Handler_Transmit_Buffer[0], bdate, btime); + bytes_sent = + datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) fprintf(stderr, diff --git a/bacnet-stack/demo/handler/s_whohas.c b/bacnet-stack/demo/handler/s_whohas.c index 9a960cfa..37013d80 100644 --- a/bacnet-stack/demo/handler/s_whohas.c +++ b/bacnet-stack/demo/handler/s_whohas.c @@ -62,8 +62,8 @@ void Send_WhoHas_Name( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, - NULL, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); /* encode the APDU portion of the packet */ data.low_limit = low_limit; data.high_limit = high_limit; @@ -72,8 +72,9 @@ void Send_WhoHas_Name( len = whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data); pdu_len += len; /* send the data */ - bytes_sent = datalink_send_pdu(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], 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 Who-Has Request (%s)!\n", @@ -102,8 +103,8 @@ void Send_WhoHas_Object( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, - NULL, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); /* encode the APDU portion of the packet */ data.low_limit = low_limit; data.high_limit = high_limit; @@ -112,8 +113,9 @@ void Send_WhoHas_Object( data.object.identifier.instance = object_instance; len = whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data); pdu_len += len; - bytes_sent = datalink_send_pdu(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], 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 Who-Has Request (%s)!\n", diff --git a/bacnet-stack/demo/handler/s_whois.c b/bacnet-stack/demo/handler/s_whois.c index 8b0107d7..29930b6d 100644 --- a/bacnet-stack/demo/handler/s_whois.c +++ b/bacnet-stack/demo/handler/s_whois.c @@ -61,14 +61,16 @@ void Send_WhoIs( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, - NULL, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); /* encode the APDU portion of the packet */ - len = whois_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - low_limit, high_limit); + len = + whois_encode_apdu(&Handler_Transmit_Buffer[pdu_len], low_limit, + high_limit); pdu_len += len; - bytes_sent = datalink_send_pdu(&dest, &npdu_data, - &Handler_Transmit_Buffer[0], 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 Who-Is Request (%s)!\n", diff --git a/bacnet-stack/demo/handler/s_wp.c b/bacnet-stack/demo/handler/s_wp.c index 7d4e4aab..6e0daec2 100644 --- a/bacnet-stack/demo/handler/s_wp.c +++ b/bacnet-stack/demo/handler/s_wp.c @@ -77,8 +77,9 @@ uint8_t Send_Write_Property_Request_Data( /* 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); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, + &npdu_data); /* encode the APDU portion of the packet */ data.object_type = object_type; data.object_instance = object_instance; @@ -88,8 +89,9 @@ uint8_t Send_Write_Property_Request_Data( memcpy(&data.application_data[0], &application_data[0], application_data_len); data.priority = priority; - len = wp_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - invoke_id, &data); + len = + wp_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, + &data); pdu_len += len; /* will it fit in the sender? note: if there is a bottleneck router in between @@ -104,15 +106,15 @@ uint8_t Send_Write_Property_Request_Data( &Handler_Transmit_Buffer[0], pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) - fprintf(stderr, - "Failed to Send WriteProperty Request (%s)!\n", + 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 " + fprintf(stderr, + "Failed to Send WriteProperty Request " "(exceeds destination maximum APDU)!\n"); #endif } @@ -135,8 +137,7 @@ uint8_t Send_Write_Property_Request( while (object_value) { #if PRINT_ENABLED_DEBUG - fprintf(stderr, "WriteProperty service: " - "%s tag=%d\n", + fprintf(stderr, "WriteProperty service: " "%s tag=%d\n", (object_value->context_specific ? "context" : "application"), (int) (object_value->context_specific ? object_value-> context_tag : object_value->tag)); @@ -150,9 +151,7 @@ uint8_t Send_Write_Property_Request( object_value = object_value->next; } - return Send_Write_Property_Request_Data(device_id, - object_type, - object_instance, - object_property, - &application_data[0], apdu_len, priority, array_index); + return Send_Write_Property_Request_Data(device_id, object_type, + object_instance, object_property, &application_data[0], apdu_len, + priority, array_index); } diff --git a/bacnet-stack/demo/object/ai.c b/bacnet-stack/demo/object/ai.c index fa21eb85..95f758dd 100644 --- a/bacnet-stack/demo/object/ai.c +++ b/bacnet-stack/demo/object/ai.c @@ -211,14 +211,14 @@ void testAnalogInput( /* FIXME: we should do a lot more testing here... */ - len = Analog_Input_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Input_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_INPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/ao.c b/bacnet-stack/demo/object/ao.c index 261de0ef..9dbd600b 100644 --- a/bacnet-stack/demo/object/ao.c +++ b/bacnet-stack/demo/object/ao.c @@ -411,7 +411,8 @@ bool Analog_Output_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -491,14 +492,14 @@ void testAnalogOutput( BACNET_ERROR_CODE error_code; - len = Analog_Output_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Output_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_OUTPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/av.c b/bacnet-stack/demo/object/av.c index b3ed00b3..665a32d8 100644 --- a/bacnet-stack/demo/object/av.c +++ b/bacnet-stack/demo/object/av.c @@ -339,7 +339,8 @@ bool Analog_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -439,14 +440,14 @@ void testAnalog_Value( BACNET_ERROR_CODE error_code; - len = Analog_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index 33d43f56..7cb97aee 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -198,8 +198,9 @@ int bacfile_encode_property_apdu( (void) array_index; switch (property) { case PROP_OBJECT_IDENTIFIER: - apdu_len = encode_application_object_id(&apdu[0], - OBJECT_FILE, object_instance); + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_FILE, + object_instance); break; case PROP_OBJECT_NAME: sprintf(text_string, "FILE %d", object_instance); @@ -222,7 +223,8 @@ int bacfile_encode_property_apdu( encode_application_character_string(&apdu[0], &char_string); break; case PROP_FILE_SIZE: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], bacfile_file_size(object_instance)); break; case PROP_MODIFICATION_DATE: @@ -285,7 +287,8 @@ bool bacfile_write_property( } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -371,18 +374,19 @@ uint32_t bacfile_instance_from_tsm( uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */ bool found = false; - found = tsm_get_transaction_pdu(invokeID, &dest, &npdu_data, &apdu[0], + found = + tsm_get_transaction_pdu(invokeID, &dest, &npdu_data, &apdu[0], &apdu_len); if (found) { - if (!npdu_data.network_layer_message - && npdu_data.data_expecting_reply + if (!npdu_data.network_layer_message && npdu_data.data_expecting_reply && (apdu[0] == PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) { len = - apdu_decode_confirmed_service_request(&apdu[0], - apdu_len, &service_data, &service_choice, - &service_request, &service_request_len); + apdu_decode_confirmed_service_request(&apdu[0], apdu_len, + &service_data, &service_choice, &service_request, + &service_request_len); if (service_choice == SERVICE_CONFIRMED_ATOMIC_READ_FILE) { - len = arf_decode_service_request(service_request, + len = + arf_decode_service_request(service_request, service_request_len, &data); if (len > 0) { if (data.object_type == OBJECT_FILE) @@ -410,7 +414,8 @@ bool bacfile_read_data( pFile = fopen(pFilename, "rb"); if (pFile) { (void) fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET); - len = fread(octetstring_value(&data->fileData), 1, + len = + fread(octetstring_value(&data->fileData), 1, data->type.stream.requestedOctetCount, pFile); if (len < data->type.stream.requestedOctetCount) data->endOfFile = true; diff --git a/bacnet-stack/demo/object/bi.c b/bacnet-stack/demo/object/bi.c index 0e7ea17c..8cf123ea 100644 --- a/bacnet-stack/demo/object/bi.c +++ b/bacnet-stack/demo/object/bi.c @@ -256,14 +256,14 @@ void testBinaryInput( /* FIXME: we should do a lot more testing here... */ - len = Binary_Input_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Input_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_INPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/bo.c b/bacnet-stack/demo/object/bo.c index b33e4211..6e806d91 100644 --- a/bacnet-stack/demo/object/bo.c +++ b/bacnet-stack/demo/object/bo.c @@ -335,7 +335,8 @@ bool Binary_Output_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -437,14 +438,14 @@ void testBinaryOutput( BACNET_ERROR_CODE error_code; - len = Binary_Output_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Output_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_OUTPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/bv.c b/bacnet-stack/demo/object/bv.c index c91c25d4..d5c86236 100644 --- a/bacnet-stack/demo/object/bv.c +++ b/bacnet-stack/demo/object/bv.c @@ -328,7 +328,8 @@ bool Binary_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -429,14 +430,14 @@ void testBinary_Value( BACNET_ERROR_CODE error_code; - len = Binary_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index 5a63db9e..385f4ddd 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -663,7 +663,8 @@ int Device_Encode_Property_APDU( switch (property) { case PROP_OBJECT_IDENTIFIER: - apdu_len = encode_application_object_id(&apdu[0], OBJECT_DEVICE, + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_DEVICE, Object_Instance_Number); break; case PROP_OBJECT_NAME: @@ -839,11 +840,13 @@ int Device_Encode_Property_APDU( } break; case PROP_MAX_APDU_LENGTH_ACCEPTED: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], Device_Max_APDU_Length_Accepted()); break; case PROP_SEGMENTATION_SUPPORTED: - apdu_len = encode_application_enumerated(&apdu[0], + apdu_len = + encode_application_enumerated(&apdu[0], Device_Segmentation_Supported()); break; case PROP_APDU_TIMEOUT: @@ -897,7 +900,8 @@ bool Device_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -921,8 +925,8 @@ bool Device_Write_Property( case PROP_NUMBER_OF_APDU_RETRIES: if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { /* FIXME: bounds check? */ - Device_Set_Number_Of_APDU_Retries((uint8_t) value. - type.Unsigned_Int); + Device_Set_Number_Of_APDU_Retries((uint8_t) value.type. + Unsigned_Int); status = true; } else { *error_class = ERROR_CLASS_PROPERTY; diff --git a/bacnet-stack/demo/object/lc.c b/bacnet-stack/demo/object/lc.c index 9cf87902..28a44733 100644 --- a/bacnet-stack/demo/object/lc.c +++ b/bacnet-stack/demo/object/lc.c @@ -314,12 +314,10 @@ struct tm { timer = time(NULL); tblock = localtime(&timer); - datetime_set_values(bdatetime, - (uint16_t) tblock->tm_year, - (uint8_t) tblock->tm_mon, - (uint8_t) tblock->tm_mday, - (uint8_t) tblock->tm_hour, - (uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec, 0); + datetime_set_values(bdatetime, (uint16_t) tblock->tm_year, + (uint8_t) tblock->tm_mon, (uint8_t) tblock->tm_mday, + (uint8_t) tblock->tm_hour, (uint8_t) tblock->tm_min, + (uint8_t) tblock->tm_sec, 0); } /* convert the shed level request into an Analog Output Present_Value */ @@ -758,16 +756,19 @@ int Load_Control_Encode_Property_APDU( case PROP_REQUESTED_SHED_LEVEL: switch (Requested_Shed_Level[object_index].type) { case BACNET_SHED_TYPE_PERCENT: - apdu_len = encode_context_unsigned(&apdu[0], 0, + apdu_len = + encode_context_unsigned(&apdu[0], 0, Requested_Shed_Level[object_index].value.percent); break; case BACNET_SHED_TYPE_AMOUNT: - apdu_len = encode_context_real(&apdu[0], 2, + apdu_len = + encode_context_real(&apdu[0], 2, Requested_Shed_Level[object_index].value.amount); break; case BACNET_SHED_TYPE_LEVEL: default: - apdu_len = encode_context_unsigned(&apdu[0], 1, + apdu_len = + encode_context_unsigned(&apdu[0], 1, Requested_Shed_Level[object_index].value.level); break; } @@ -777,16 +778,19 @@ int Load_Control_Encode_Property_APDU( encode_application_date(&apdu[0], &Start_Time[object_index].date); apdu_len = len; - len = encode_application_time(&apdu[apdu_len], + len = + encode_application_time(&apdu[apdu_len], &Start_Time[object_index].time); apdu_len += len; break; case PROP_SHED_DURATION: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], Shed_Duration[object_index]); break; case PROP_DUTY_WINDOW: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], Duty_Window[object_index]); break; case PROP_ENABLE: @@ -794,22 +798,26 @@ int Load_Control_Encode_Property_APDU( apdu_len = encode_application_boolean(&apdu[0], state); break; case PROP_FULL_DUTY_BASELINE: /* optional */ - apdu_len = encode_application_real(&apdu[0], + apdu_len = + encode_application_real(&apdu[0], Full_Duty_Baseline[object_index]); break; case PROP_EXPECTED_SHED_LEVEL: switch (Expected_Shed_Level[object_index].type) { case BACNET_SHED_TYPE_PERCENT: - apdu_len = encode_context_unsigned(&apdu[0], 0, + apdu_len = + encode_context_unsigned(&apdu[0], 0, Expected_Shed_Level[object_index].value.percent); break; case BACNET_SHED_TYPE_AMOUNT: - apdu_len = encode_context_real(&apdu[0], 2, + apdu_len = + encode_context_real(&apdu[0], 2, Expected_Shed_Level[object_index].value.amount); break; case BACNET_SHED_TYPE_LEVEL: default: - apdu_len = encode_context_unsigned(&apdu[0], 1, + apdu_len = + encode_context_unsigned(&apdu[0], 1, Expected_Shed_Level[object_index].value.level); break; } @@ -817,16 +825,19 @@ int Load_Control_Encode_Property_APDU( case PROP_ACTUAL_SHED_LEVEL: switch (Actual_Shed_Level[object_index].type) { case BACNET_SHED_TYPE_PERCENT: - apdu_len = encode_context_unsigned(&apdu[0], 0, + apdu_len = + encode_context_unsigned(&apdu[0], 0, Actual_Shed_Level[object_index].value.percent); break; case BACNET_SHED_TYPE_AMOUNT: - apdu_len = encode_context_real(&apdu[0], 2, + apdu_len = + encode_context_real(&apdu[0], 2, Actual_Shed_Level[object_index].value.amount); break; case BACNET_SHED_TYPE_LEVEL: default: - apdu_len = encode_context_unsigned(&apdu[0], 1, + apdu_len = + encode_context_unsigned(&apdu[0], 1, Actual_Shed_Level[object_index].value.level); break; } @@ -857,7 +868,8 @@ int Load_Control_Encode_Property_APDU( } } else { if (array_index <= MAX_SHED_LEVELS) { - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], Shed_Levels[object_index][array_index - 1]); } else { *error_class = ERROR_CLASS_PROPERTY; @@ -879,7 +891,8 @@ int Load_Control_Encode_Property_APDU( /* FIXME: check if we have room before adding it to APDU */ characterstring_init_ansi(&char_string, Shed_Level_Descriptions[i]); - len = encode_application_character_string(&apdu[apdu_len], + len = + encode_application_character_string(&apdu[apdu_len], &char_string); /* add it if we have room */ if ((apdu_len + len) < MAX_APDU) @@ -895,7 +908,8 @@ int Load_Control_Encode_Property_APDU( if (array_index <= MAX_SHED_LEVELS) { characterstring_init_ansi(&char_string, Shed_Level_Descriptions[array_index - 1]); - apdu_len = encode_application_character_string(&apdu[0], + apdu_len = + encode_application_character_string(&apdu[0], &char_string); } else { *error_class = ERROR_CLASS_PROPERTY; @@ -932,16 +946,18 @@ bool Load_Control_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ object_index = Load_Control_Instance_To_Index(wp_data->object_instance); switch (wp_data->object_property) { case PROP_REQUESTED_SHED_LEVEL: - len = bacapp_decode_context_data(wp_data->application_data, - wp_data->application_data_len, - &value, PROP_REQUESTED_SHED_LEVEL); + len = + bacapp_decode_context_data(wp_data->application_data, + wp_data->application_data_len, &value, + PROP_REQUESTED_SHED_LEVEL); if (value.context_tag == 0) { /* percent - Unsigned */ Requested_Shed_Level[object_index].type = @@ -974,8 +990,8 @@ bool Load_Control_Write_Property( break; case PROP_START_TIME: if (value.tag == BACNET_APPLICATION_TAG_DATE) { - memcpy(&Start_Time[object_index].date, - &value.type.Date, sizeof(value.type.Date)); + memcpy(&Start_Time[object_index].date, &value.type.Date, + sizeof(value.type.Date)); Start_Time_Property_Written[object_index] = true; status = true; } else { @@ -988,8 +1004,8 @@ bool Load_Control_Write_Property( bacapp_decode_application_data(wp_data->application_data + len, wp_data->application_data_len - len, &value); if (len && value.tag == BACNET_APPLICATION_TAG_TIME) { - memcpy(&Start_Time[object_index].time, - &value.type.Time, sizeof(value.type.Time)); + memcpy(&Start_Time[object_index].time, &value.type.Time, + sizeof(value.type.Time)); status = true; } else { status = false; @@ -1455,14 +1471,14 @@ void testLoadControl( BACNET_ERROR_CLASS error_class; BACNET_ERROR_CODE error_code; - len = Load_Control_Encode_Property_APDU(&apdu[0], - instance, + len = + Load_Control_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_LOAD_CONTROL); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/lo.c b/bacnet-stack/demo/object/lo.c index 9374feb6..ba8d08c4 100644 --- a/bacnet-stack/demo/object/lo.c +++ b/bacnet-stack/demo/object/lo.c @@ -144,8 +144,9 @@ int Lighting_Output_Decode_Lighting_Command( /* Tag 0: operation */ if (!decode_is_context_tag(&apdu[apdu_len], 0)) return -1; - len = decode_tag_number_and_value(&apdu[apdu_len], - &tag_number, &len_value_type); + len = + decode_tag_number_and_value(&apdu[apdu_len], &tag_number, + &len_value_type); apdu_len += len; len = decode_enumerated(&apdu[apdu_len], len_value_type, @@ -153,8 +154,9 @@ int Lighting_Output_Decode_Lighting_Command( apdu_len += len; /* Tag 1: level - OPTIONAL */ if (decode_is_context_tag(&apdu[apdu_len], 1)) { - len = decode_tag_number_and_value(&apdu[apdu_len], - &tag_number, &len_value_type); + len = + decode_tag_number_and_value(&apdu[apdu_len], &tag_number, + &len_value_type); apdu_len += len; len = decode_real(&apdu[apdu_len], &real_value); apdu_len += len; @@ -412,7 +414,8 @@ int Lighting_Output_Encode_Property_APDU( apdu_len = encode_application_real(&apdu[0], real_value); break; case PROP_LIGHTING_COMMAND: - apdu_len = Lighting_Output_Encode_Lighting_Command(&apdu[0], + apdu_len = + Lighting_Output_Encode_Lighting_Command(&apdu[0], &Lighting_Command[object_instance]); break; case PROP_STATUS_FLAGS: @@ -521,7 +524,8 @@ bool Lighting_Output_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -615,14 +619,14 @@ void testLightingOutput( BACNET_ERROR_CODE error_code; - len = Lighting_Output_Encode_Property_APDU(&apdu[0], - instance, + len = + Lighting_Output_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_LIGHTING_OUTPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/lsp.c b/bacnet-stack/demo/object/lsp.c index fa4f70c6..3ccf042e 100644 --- a/bacnet-stack/demo/object/lsp.c +++ b/bacnet-stack/demo/object/lsp.c @@ -307,7 +307,8 @@ bool Life_Safety_Point_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -373,14 +374,14 @@ void testLifeSafetyPoint( BACNET_ERROR_CODE error_code; - len = Life_Safety_Point_Encode_Property_APDU(&apdu[0], - instance, + len = + Life_Safety_Point_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_LIFE_SAFETY_POINT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/object/mso.c b/bacnet-stack/demo/object/mso.c index 1c459c48..6eb61f98 100644 --- a/bacnet-stack/demo/object/mso.c +++ b/bacnet-stack/demo/object/mso.c @@ -312,7 +312,8 @@ int Multistate_Output_Encode_Property_APDU( apdu_len = encode_application_enumerated(&apdu[0], present_value); break; case PROP_NUMBER_OF_STATES: - apdu_len = encode_application_unsigned(&apdu[apdu_len], + apdu_len = + encode_application_unsigned(&apdu[apdu_len], MULTISTATE_NUMBER_OF_STATES); break; @@ -346,7 +347,8 @@ bool Multistate_Output_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -451,14 +453,14 @@ void testMultistateOutput( BACNET_ERROR_CODE error_code; - len = Multistate_Output_Encode_Property_APDU(&apdu[0], - instance, + len = + Multistate_Output_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_MULTI_STATE_OUTPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/demo/readfile/main.c b/bacnet-stack/demo/readfile/main.c index ada9e6ca..243855c3 100644 --- a/bacnet-stack/demo/readfile/main.c +++ b/bacnet-stack/demo/readfile/main.c @@ -132,8 +132,7 @@ static void AtomicReadFileAckHandler( octets_written = fwrite(octetstring_value(&data.fileData), 1, /* unit to write in bytes - in our case, an octet is one byte */ octetstring_length(&data.fileData), pFile); if (octets_written != octetstring_length(&data.fileData)) - fprintf(stderr, - "Unable to write data to file \"%s\".\n", + fprintf(stderr, "Unable to write data to file \"%s\".\n", Local_File_Name); else printf("\r%u bytes", @@ -161,8 +160,9 @@ static void LocalIAmHandler( (void) src; (void) service_len; - len = iam_decode_service_request(service_request, - &device_id, &max_apdu, &segmentation, &vendor_id); + len = + iam_decode_service_request(service_request, &device_id, &max_apdu, + &segmentation, &vendor_id); if (len != -1) { address_add(device_id, max_apdu, src); } else @@ -242,8 +242,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); /* loop forever */ @@ -264,8 +264,9 @@ int main( if (End_Of_File_Detected || Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { /* calculate the smaller of our APDU size or theirs and remove the overhead of the APDU (about 16 octets max). @@ -292,8 +293,7 @@ int main( /* we'll read the file in chunks less than max_apdu to keep unsegmented */ invoke_id = - Send_Atomic_Read_File_Stream - (Target_Device_Object_Instance, + Send_Atomic_Read_File_Stream(Target_Device_Object_Instance, Target_File_Object_Instance, fileStartPosition, requestedOctetCount); Current_Invoke_ID = invoke_id; diff --git a/bacnet-stack/demo/readprop/main.c b/bacnet-stack/demo/readprop/main.c index b64050ef..a530623b 100644 --- a/bacnet-stack/demo/readprop/main.c +++ b/bacnet-stack/demo/readprop/main.c @@ -190,8 +190,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); /* loop forever */ @@ -212,15 +212,15 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { if (invoke_id == 0) { invoke_id = - Send_Read_Property_Request - (Target_Device_Object_Instance, Target_Object_Type, - Target_Object_Instance, Target_Object_Property, - Target_Object_Index); + Send_Read_Property_Request(Target_Device_Object_Instance, + Target_Object_Type, Target_Object_Instance, + Target_Object_Property, Target_Object_Index); } else if (tsm_invoke_id_free(invoke_id)) break; else if (tsm_invoke_id_failed(invoke_id)) { diff --git a/bacnet-stack/demo/reinit/main.c b/bacnet-stack/demo/reinit/main.c index 44101aea..77576f10 100644 --- a/bacnet-stack/demo/reinit/main.c +++ b/bacnet-stack/demo/reinit/main.c @@ -70,8 +70,7 @@ static void MyErrorHandler( /* FIXME: verify src and invoke id */ (void) src; (void) invoke_id; - printf("BACnet Error: %s: %s\r\n", - bactext_error_class_name(error_class), + printf("BACnet Error: %s: %s\r\n", bactext_error_class_name(error_class), bactext_error_code_name(error_code)); Error_Detected = true; } @@ -155,17 +154,11 @@ int main( if (argc < 3) { /* note: priority 16 and 0 should produce the same end results... */ printf("Usage: %s device-instance state [password]\r\n" - "Send BACnet ReinitializeDevice service to device.\r\n" - "\r\n" + "Send BACnet ReinitializeDevice service to device.\r\n" "\r\n" "The device-instance can be 0 to %d.\r\n" - "Possible state values:\r\n" - " 0=coldstart\r\n" - " 1=warmstart\r\n" - " 2=startbackup\r\n" - " 3=endbackup\r\n" - " 4=startrestore\r\n" - " 5=endrestore\r\n" - " 6=abortrestore\r\n" + "Possible state values:\r\n" " 0=coldstart\r\n" + " 1=warmstart\r\n" " 2=startbackup\r\n" " 3=endbackup\r\n" + " 4=startrestore\r\n" " 5=endrestore\r\n" " 6=abortrestore\r\n" "The optional password is a character string of 1 to 20 characters.\r\n", filename_remove_path(argv[0]), BACNET_MAX_INSTANCE - 1); return 0; @@ -191,8 +184,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); /* loop forever */ @@ -213,8 +206,9 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { if (invoke_id == 0) { invoke_id = diff --git a/bacnet-stack/demo/server/main.c b/bacnet-stack/demo/server/main.c index 0b28d4cf..08aecf9b 100644 --- a/bacnet-stack/demo/server/main.c +++ b/bacnet-stack/demo/server/main.c @@ -81,13 +81,12 @@ static void Init_Service_Handlers( #endif apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE, handler_reinitialize_device); - apdu_set_unconfirmed_handler - (SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, handler_timesync_utc); + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, + handler_timesync_utc); apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, handler_timesync); /* handle communication so we can shutup when asked */ - apdu_set_confirmed_handler - (SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, + apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, handler_device_communication_control); } @@ -144,11 +143,9 @@ int main( dlmstp_set_mac_address(127); } #endif - printf("BACnet Server Demo\n" - "BACnet Stack Version %s\n" - "BACnet Device ID: %u\n" - "Max APDU: %d\n", - BACnet_Version, Device_Object_Instance_Number(), MAX_APDU); + printf("BACnet Server Demo\n" "BACnet Stack Version %s\n" + "BACnet Device ID: %u\n" "Max APDU: %d\n", BACnet_Version, + Device_Object_Instance_Number(), MAX_APDU); Init_Service_Handlers(); BIP_Debug = true; if (!datalink_init(getenv("BACNET_IFACE"))) diff --git a/bacnet-stack/demo/timesync/main.c b/bacnet-stack/demo/timesync/main.c index 6e66fe8f..53ddb8cc 100644 --- a/bacnet-stack/demo/timesync/main.c +++ b/bacnet-stack/demo/timesync/main.c @@ -96,8 +96,8 @@ static void Init_Service_Handlers( apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property); /* handle the reply (request) coming in */ - apdu_set_unconfirmed_handler - (SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, handler_timesync_utc); + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, + handler_timesync_utc); apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, handler_timesync); /* handle any errors coming back */ @@ -127,17 +127,11 @@ int main( printf("Usage: %s date time [device-instance]\r\n" "Send BACnet TimeSynchronization request to all devices.\r\n" "date format: year/month/day:dayofweek (e.g. 2006/4/1:6)\r\n" - "year: AD, such as 2006\r\n" - "month: 1=January, 12=December\r\n" - "day: 1-31\r\n" - "dayofweek: 1=Monday, 7=Sunday\r\n" - "\r\n" + "year: AD, such as 2006\r\n" "month: 1=January, 12=December\r\n" + "day: 1-31\r\n" "dayofweek: 1=Monday, 7=Sunday\r\n" "\r\n" "time format: hour:minute:second.hundredths (e.g. 23:59:59.12)\r\n" - "hour: 0-23\r\n" - "minute: 0-59\r\n" - "second: 0-59\r\n" - "hundredths: 0-99\r\n" - "\r\n" + "hour: 0-23\r\n" "minute: 0-59\r\n" "second: 0-59\r\n" + "hundredths: 0-99\r\n" "\r\n" "Optional device-instance sends a unicast time sync.\r\n", filename_remove_path(argv[0])); return 0; diff --git a/bacnet-stack/demo/ucov/main.c b/bacnet-stack/demo/ucov/main.c index 1a461fd6..e15739a0 100644 --- a/bacnet-stack/demo/ucov/main.c +++ b/bacnet-stack/demo/ucov/main.c @@ -78,55 +78,38 @@ int main( if (argc < 7) { /* note: priority 16 and 0 should produce the same end results... */ printf("Usage: %s pid device-id object-type object-instance " - "time property tag value [priority] [index]\r\n" - "\r\n" - "pid:\r\n" - "Process Identifier for this broadcast.\r\n" - "\r\n" + "time property tag value [priority] [index]\r\n" "\r\n" "pid:\r\n" + "Process Identifier for this broadcast.\r\n" "\r\n" "device-id:\r\n" - "The Initiating BACnet Device Object Instance number.\r\n" - "\r\n" + "The Initiating 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" - "time:\r\n" + "would be 1.\r\n" "\r\n" "object-instance:\r\n" + "The monitored object instance number.\r\n" "\r\n" "time:\r\n" "The subscription time remaining is conveyed in seconds.\r\n" - "\r\n" - "property:\r\n" + "\r\n" "property:\r\n" "The property is an integer value of the enumeration \r\n" "BACNET_PROPERTY_ID in bacenum.h. For example, if you were\r\n" "monitoring the Present Value property, you would use 85\r\n" - "as the property.\r\n" - "\r\n" - "tag:\r\n" + "as the property.\r\n" "\r\n" "tag:\r\n" "Tag is the integer value of the enumeration BACNET_APPLICATION_TAG \r\n" "in bacenum.h. It is the data type of the value that you are\r\n" "monitoring. For example, if you were monitoring a REAL value, you would \r\n" - "use a tag of 4." - "\r\n" - "value:\r\n" + "use a tag of 4." "\r\n" "value:\r\n" "The value is an ASCII representation of some type of data that you\r\n" "are monitoring. It is encoded using the tag information provided. For\r\n" "example, if you were writing a REAL value of 100.0, you would use \r\n" - "100.0 as the value.\r\n" - "\r\n" - "[priority]:\r\n" + "100.0 as the value.\r\n" "\r\n" "[priority]:\r\n" "This optional parameter is used for reporting the priority of the\r\n" "value. If no priority is given, none is sent, and the BACnet \r\n" "standard requires that the value is reported at the lowest \r\n" "priority (16) if the object property supports priorities.\r\n" - "\r\n" - "[index]\r\n" + "\r\n" "[index]\r\n" "This optional integer parameter is the index number of an array.\r\n" "If the property is an array, individual elements can be reported.\r\n" - "\r\n" - "Here is a brief overview of BACnet property and tags:\r\n" + "\r\n" "Here is a brief overview of BACnet property and tags:\r\n" "Certain properties are expected to be written with certain \r\n" "application tags, so you probably need to know which ones to use\r\n" "with each property of each object. It is almost safe to say that\r\n" @@ -136,9 +119,7 @@ int main( "accepting REAL, BOOLEAN, NULL, etc. Perhaps it would be simpler for\r\n" "the demo to use this kind of table - but I also wanted to be able\r\n" "to do negative testing by passing the wrong tag and have the server\r\n" - "return a reject message.\r\n" - "\r\n" - "Example:\r\n" + "return a reject message.\r\n" "\r\n" "Example:\r\n" "If you want generate an unconfirmed COV,\r\n" "you could send the following command:\r\n" "%s 1 2 3 4 5 85 4 100.0\r\n" @@ -191,12 +172,13 @@ int main( return 1; } if (tag >= MAX_BACNET_APPLICATION_TAG) { - fprintf(stderr, "tag=%u - it must be less than %u\r\n", - tag, MAX_BACNET_APPLICATION_TAG); + fprintf(stderr, "tag=%u - it must be less than %u\r\n", tag, + MAX_BACNET_APPLICATION_TAG); return 1; } - status = bacapp_parse_application_data(tag, - value_string, &cov_data.listOfValues.value); + status = + bacapp_parse_application_data(tag, value_string, + &cov_data.listOfValues.value); if (!status) { /* FIXME: show the expected entry format for the tag */ fprintf(stderr, "unable to parse the tag value\r\n"); diff --git a/bacnet-stack/demo/whohas/main.c b/bacnet-stack/demo/whohas/main.c index 62292458..b44f91c6 100644 --- a/bacnet-stack/demo/whohas/main.c +++ b/bacnet-stack/demo/whohas/main.c @@ -121,14 +121,11 @@ int main( /* note: priority 16 and 0 should produce the same end results... */ printf("Usage: %s \r\n" "Send BACnet WhoHas request to devices, and wait for responses.\r\n" - "\r\n" - "Use either:\r\n" - "The object-type can be 0 to %d.\r\n" - "The object-instance can be 0 to %d.\r\n" - "or:\r\n" + "\r\n" "Use either:\r\n" "The object-type can be 0 to %d.\r\n" + "The object-instance can be 0 to %d.\r\n" "or:\r\n" "The object-name can be any string of characters.\r\n", - filename_remove_path(argv[0]), - MAX_BACNET_OBJECT_TYPE - 1, BACNET_MAX_INSTANCE); + filename_remove_path(argv[0]), MAX_BACNET_OBJECT_TYPE - 1, + BACNET_MAX_INSTANCE); return 0; } /* decode the command line parameters */ @@ -138,8 +135,7 @@ int main( Target_Object_Type = strtol(argv[1], NULL, 0); Target_Object_Instance = strtol(argv[2], NULL, 0); if (Target_Object_Instance > BACNET_MAX_INSTANCE) { - fprintf(stderr, - "object-instance=%u - it must be less than %u\r\n", + fprintf(stderr, "object-instance=%u - it must be less than %u\r\n", Target_Object_Instance, BACNET_MAX_INSTANCE + 1); return 1; } diff --git a/bacnet-stack/demo/writefile/main.c b/bacnet-stack/demo/writefile/main.c index ae1be39a..dc9fdaa5 100644 --- a/bacnet-stack/demo/writefile/main.c +++ b/bacnet-stack/demo/writefile/main.c @@ -117,8 +117,9 @@ static void LocalIAmHandler( (void) src; (void) service_len; - len = iam_decode_service_request(service_request, - &device_id, &max_apdu, &segmentation, &vendor_id); + len = + iam_decode_service_request(service_request, &device_id, &max_apdu, + &segmentation, &vendor_id); if (len != -1) { address_add(device_id, max_apdu, src); } else @@ -198,8 +199,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); /* loop forever */ @@ -222,8 +223,9 @@ int main( break; } /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { /* calculate the smaller of our APDU size or theirs and remove the overhead of the APDU (varies depending on size). @@ -252,7 +254,8 @@ int main( pFile = fopen(Local_File_Name, "rb"); if (pFile) { (void) fseek(pFile, fileStartPosition, SEEK_SET); - len = fread(octetstring_value(&fileData), 1, + len = + fread(octetstring_value(&fileData), 1, requestedOctetCount, pFile); if (len < requestedOctetCount) End_Of_File_Detected = true; diff --git a/bacnet-stack/demo/writeprop/main.c b/bacnet-stack/demo/writeprop/main.c index 5c4d577a..1cd90eab 100644 --- a/bacnet-stack/demo/writeprop/main.c +++ b/bacnet-stack/demo/writeprop/main.c @@ -178,50 +178,39 @@ int main( "communicate to. This number will be used to try and bind with\r\n" "the device using Who-Is and I-Am services. For example, if you were\r\n" "writing to Device Object 123, the device-instance would be 123.\r\n" - "\r\n" - "object-type:\r\n" + "\r\n" "object-type:\r\n" "The object type is the integer value of the enumeration\r\n" "BACNET_OBJECT_TYPE in bacenum.h. It is the object that you are\r\n" "writing to. For example if you were writing to Analog Output 2, \r\n" - "the object-type would be 1.\r\n" - "\r\n" - "object-instance:\r\n" + "the object-type would be 1.\r\n" "\r\n" "object-instance:\r\n" "This is the object instance number of the object that you are \r\n" "writing to. For example, if you were writing to Analog Output 2, \r\n" - "the object-instance would be 2.\r\n" - "\r\n" - "property:\r\n" + "the object-instance would be 2.\r\n" "\r\n" "property:\r\n" "The property is an integer value of the enumeration \r\n" "BACNET_PROPERTY_ID in bacenum.h. It is the property you are \r\n" "writing to. For example, if you were writing to the Present Value\r\n" - "property, you would use 85 as the property.\r\n" - "\r\n" + "property, you would use 85 as the property.\r\n" "\r\n" "priority:\r\n" "This parameter is used for setting the priority of the\r\n" "write. If Priority 0 is given, no priority is sent. The BACnet \r\n" "standard states that the value is written at the lowest \r\n" "priority (16) if the object property supports priorities\r\n" - "when no priority is sent.\r\n" - "\r\n" - "index\r\n" + "when no priority is sent.\r\n" "\r\n" "index\r\n" "This integer parameter is the index number of an array.\r\n" "If the property is an array, individual elements can be written\r\n" "to if supported. If this parameter is -1, the index is ignored.\r\n" - "\r\n" - "tag:\r\n" + "\r\n" "tag:\r\n" "Tag is the integer value of the enumeration BACNET_APPLICATION_TAG \r\n" "in bacenum.h. It is the data type of the value that you are\r\n" "writing. For example, if you were writing a REAL value, you would \r\n" "use a tag of 4.\r\n" "Context tags are created using two tags in a row. The context tag\r\n" "is preceded by a C. Ctag tag. C2 4 creates a context 2 tagged REAL.\r\n" - "\r\n" - "value:\r\n" + "\r\n" "value:\r\n" "The value is an ASCII representation of some type of data that you\r\n" "are writing. It is encoded using the tag information provided. For\r\n" "example, if you were writing a REAL value of 100.0, you would use \r\n" - "100.0 as the value.\r\n" - "\r\n" + "100.0 as the value.\r\n" "\r\n" "Here is a brief overview of BACnet property and tags:\r\n" "Certain properties are expected to be written with certain \r\n" "application tags, so you probably need to know which ones to use\r\n" @@ -232,15 +221,13 @@ int main( "accepting REAL, BOOLEAN, NULL, etc. Perhaps it would be simpler for\r\n" "the demo to use this kind of table - but I also wanted to be able\r\n" "to do negative testing by passing the wrong tag and have the server\r\n" - "return a reject message.\r\n" - "\r\n" - "Example:\r\n" + "return a reject message.\r\n" "\r\n" "Example:\r\n" "If you want send a 100 to the Present-Value in the Analog Output\r\n" "at priority 16, you could send the following command:\r\n" "%s 123 1 0 85 4 100\r\n" "You could also send a relinquish command:\r\n" - "%s 123 1 0 85 0 0\r\n", - filename_remove_path(argv[0]), filename_remove_path(argv[0])); + "%s 123 1 0 85 0 0\r\n", filename_remove_path(argv[0]), + filename_remove_path(argv[0])); } return 0; } @@ -296,8 +283,9 @@ int main( property_tag, MAX_BACNET_APPLICATION_TAG); return 1; } - status = bacapp_parse_application_data(property_tag, - value_string, &Target_Object_Property_Value[i]); + status = + bacapp_parse_application_data(property_tag, value_string, + &Target_Object_Property_Value[i]); if (!status) { /* FIXME: show the expected entry format for the tag */ fprintf(stderr, "unable to parse the tag value\r\n"); @@ -319,8 +307,8 @@ int main( return 1; /* configure the timeout values */ last_seconds = time(NULL); - timeout_seconds = (Device_APDU_Timeout() / 1000) * - Device_Number_Of_APDU_Retries(); + timeout_seconds = + (Device_APDU_Timeout() / 1000) * Device_Number_Of_APDU_Retries(); /* try to bind with the device */ Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); /* loop forever */ @@ -341,15 +329,15 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = address_bind_request(Target_Device_Object_Instance, - &max_apdu, &Target_Address); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); if (found) { if (invoke_id == 0) { invoke_id = - Send_Write_Property_Request - (Target_Device_Object_Instance, Target_Object_Type, - Target_Object_Instance, Target_Object_Property, - &Target_Object_Property_Value[0], + Send_Write_Property_Request(Target_Device_Object_Instance, + Target_Object_Type, Target_Object_Instance, + Target_Object_Property, &Target_Object_Property_Value[0], Target_Object_Property_Priority, Target_Object_Property_Index); } else if (tsm_invoke_id_free(invoke_id)) diff --git a/bacnet-stack/indent.sh b/bacnet-stack/indent.sh index a3cf511b..6911bd2e 100755 --- a/bacnet-stack/indent.sh +++ b/bacnet-stack/indent.sh @@ -6,7 +6,7 @@ [ -x /usr/bin/dos2unix ] || exit 0 INDENTRC=".indent.pro" -if [ ! -x ${INDENTRC} ] +if [ ! -e ${INDENTRC} ] then echo No ${INDENTRC} file found. Creating ${INDENTRC} file. echo "-kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 -nhnl" > ${INDENTRC} diff --git a/bacnet-stack/ports/at91sam7s/ai.c b/bacnet-stack/ports/at91sam7s/ai.c index ca91a782..4d485fe1 100644 --- a/bacnet-stack/ports/at91sam7s/ai.c +++ b/bacnet-stack/ports/at91sam7s/ai.c @@ -122,11 +122,12 @@ int Analog_Input_Encode_Property_APDU( encode_application_character_string(&apdu[0], &char_string); break; case PROP_OBJECT_TYPE: - apdu_len = encode_application_enumerated(&apdu[0], - OBJECT_ANALOG_INPUT); + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_ANALOG_INPUT); break; case PROP_PRESENT_VALUE: - apdu_len = encode_application_real(&apdu[0], + apdu_len = + encode_application_real(&apdu[0], Analog_Input_Present_Value(object_instance)); break; case PROP_STATUS_FLAGS: @@ -177,14 +178,14 @@ void testAnalogInput( /* FIXME: we should do a lot more testing here... */ - len = Analog_Input_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Input_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_INPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/at91sam7s/av.c b/bacnet-stack/ports/at91sam7s/av.c index 59c0f044..304f61c7 100644 --- a/bacnet-stack/ports/at91sam7s/av.c +++ b/bacnet-stack/ports/at91sam7s/av.c @@ -296,7 +296,8 @@ bool Analog_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -400,14 +401,14 @@ void testAnalog_Value( BACNET_ERROR_CODE error_code; - len = Analog_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/at91sam7s/bi.c b/bacnet-stack/ports/at91sam7s/bi.c index b08b7d31..ba4f539d 100644 --- a/bacnet-stack/ports/at91sam7s/bi.c +++ b/bacnet-stack/ports/at91sam7s/bi.c @@ -211,14 +211,14 @@ void testBinaryInput( /* FIXME: we should do a lot more testing here... */ - len = Binary_Input_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Input_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_INPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/at91sam7s/bv.c b/bacnet-stack/ports/at91sam7s/bv.c index 3cb3e061..2139bda6 100644 --- a/bacnet-stack/ports/at91sam7s/bv.c +++ b/bacnet-stack/ports/at91sam7s/bv.c @@ -207,7 +207,8 @@ bool Binary_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -315,14 +316,14 @@ void testBinary_Value( BACNET_ERROR_CODE error_code; - len = Binary_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/at91sam7s/device.c b/bacnet-stack/ports/at91sam7s/device.c index 317216d6..42df2621 100644 --- a/bacnet-stack/ports/at91sam7s/device.c +++ b/bacnet-stack/ports/at91sam7s/device.c @@ -277,7 +277,8 @@ int Device_Encode_Property_APDU( /* FIXME: change the hardcoded names to suit your application */ switch (property) { case PROP_OBJECT_IDENTIFIER: - apdu_len = encode_application_object_id(&apdu[0], OBJECT_DEVICE, + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_DEVICE, Object_Instance_Number); break; case PROP_OBJECT_NAME: @@ -416,11 +417,13 @@ int Device_Encode_Property_APDU( } break; case PROP_MAX_APDU_LENGTH_ACCEPTED: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], Device_Max_APDU_Length_Accepted()); break; case PROP_SEGMENTATION_SUPPORTED: - apdu_len = encode_application_enumerated(&apdu[0], + apdu_len = + encode_application_enumerated(&apdu[0], Device_Segmentation_Supported()); break; case PROP_APDU_TIMEOUT: @@ -502,7 +505,8 @@ bool Device_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -510,8 +514,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/at91sam7s/dlmstp.c b/bacnet-stack/ports/at91sam7s/dlmstp.c index e6832754..88ff60f8 100644 --- a/bacnet-stack/ports/at91sam7s/dlmstp.c +++ b/bacnet-stack/ports/at91sam7s/dlmstp.c @@ -303,8 +303,9 @@ static bool dlmstp_compare_data_expecting_reply( /* decode the request data */ request.address.mac[0] = src_address; request.address.mac_len = 1; - offset = npdu_decode(&request_pdu[0], - NULL, &request.address, &request.npdu_data); + offset = + npdu_decode(&request_pdu[0], NULL, &request.address, + &request.npdu_data); if (request.npdu_data.network_layer_message) { return false; } @@ -321,8 +322,8 @@ static bool dlmstp_compare_data_expecting_reply( /* decode the reply data */ reply.address.mac[0] = dest_address; reply.address.mac_len = 1; - offset = npdu_decode(&reply_pdu[0], - &reply.address, NULL, &reply.npdu_data); + offset = + npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data); if (reply.npdu_data.network_layer_message) { return false; } @@ -788,9 +789,7 @@ static bool MSTP_Master_Node_FSM( } else { frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; } - MSTP_Send_Frame(frame_type, - TransmitPacketDest, - This_Station, + MSTP_Send_Frame(frame_type, TransmitPacketDest, This_Station, (uint8_t *) & TransmitPacket[0], TransmitPacketLen); MSTP_Flag.TransmitPacketPending = false; FrameCount++; @@ -904,8 +903,8 @@ static bool MSTP_Master_Node_FSM( /* address at which a new master node may be found in that case. */ TokenCount++; /* transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); RetryCount = 0; EventCount = 0; Master_State = MSTP_MASTER_STATE_PASS_TOKEN; @@ -927,8 +926,8 @@ static bool MSTP_Master_Node_FSM( /* ResetMaintenancePFM */ Poll_Station = This_Station; /* transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); RetryCount = 0; TokenCount = 1; /* changed in Errata SSPC-135-2004 */ EventCount = 0; @@ -937,8 +936,8 @@ static bool MSTP_Master_Node_FSM( } else { /* SendMaintenancePFM */ Poll_Station = next_poll_station; - MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, - Poll_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station, + This_Station, NULL, 0); RetryCount = 0; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; } @@ -959,8 +958,8 @@ static bool MSTP_Master_Node_FSM( /* RetrySendToken */ RetryCount++; /* Transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); EventCount = 0; /* re-enter the current state to listen for NS */ /* to begin using the token. */ @@ -969,8 +968,8 @@ static bool MSTP_Master_Node_FSM( /* Assume that NS has failed. */ Poll_Station = next_next_station; /* Transmit a Poll For Master frame to PS. */ - MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, - Poll_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station, + This_Station, NULL, 0); /* no known successor node */ Next_Station = This_Station; RetryCount = 0; @@ -1003,8 +1002,8 @@ static bool MSTP_Master_Node_FSM( /* on the network and is empowered to create a token. */ Poll_Station = next_this_station; /* Transmit a Poll For Master frame to PS. */ - MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, - Poll_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station, + This_Station, NULL, 0); /* indicate that the next station is unknown */ Next_Station = This_Station; RetryCount = 0; @@ -1027,8 +1026,8 @@ static bool MSTP_Master_Node_FSM( Next_Station = SourceAddress; EventCount = 0; /* Transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); Poll_Station = This_Station; TokenCount = 0; RetryCount = 0; @@ -1060,8 +1059,8 @@ static bool MSTP_Master_Node_FSM( /* poll for a master at address PS. */ EventCount = 0; /* transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); RetryCount = 0; Master_State = MSTP_MASTER_STATE_PASS_TOKEN; } else { @@ -1092,10 +1091,10 @@ static bool MSTP_Master_Node_FSM( case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST: /* Note: we could wait for up to Treply_delay */ if (MSTP_Flag.TransmitPacketPending) { - matched = dlmstp_compare_data_expecting_reply(&InputBuffer[0], - DataLength, - SourceAddress, - &TransmitPacket[0], TransmitPacketLen, TransmitPacketDest); + matched = + dlmstp_compare_data_expecting_reply(&InputBuffer[0], + DataLength, SourceAddress, &TransmitPacket[0], + TransmitPacketLen, TransmitPacketDest); } if (MSTP_Flag.TransmitPacketPending && matched) { /* Reply */ @@ -1111,9 +1110,7 @@ static bool MSTP_Master_Node_FSM( } else { frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; } - MSTP_Send_Frame(frame_type, - TransmitPacketDest, - This_Station, + MSTP_Send_Frame(frame_type, TransmitPacketDest, This_Station, (uint8_t *) & TransmitPacket[0], TransmitPacketLen); MSTP_Flag.TransmitPacketPending = false; Master_State = MSTP_MASTER_STATE_IDLE; @@ -1127,8 +1124,8 @@ static bool MSTP_Master_Node_FSM( /* Any reply shall wait until this node receives the token. */ /* Call MSTP_Send_Frame to transmit a Reply Postponed frame, */ /* and enter the IDLE state. */ - MSTP_Send_Frame(FRAME_TYPE_REPLY_POSTPONED, - SourceAddress, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_REPLY_POSTPONED, SourceAddress, + This_Station, NULL, 0); Master_State = MSTP_MASTER_STATE_IDLE; } /* clear our flag we were holding for comparison */ diff --git a/bacnet-stack/ports/at91sam7s/h_rp.c b/bacnet-stack/ports/at91sam7s/h_rp.c index a7c32396..c54a57a8 100644 --- a/bacnet-stack/ports/at91sam7s/h_rp.c +++ b/bacnet-stack/ports/at91sam7s/h_rp.c @@ -65,36 +65,41 @@ int Encode_Property_APDU( switch (object_type) { case OBJECT_DEVICE: if (Device_Valid_Object_Instance_Number(object_instance)) { - apdu_len = Device_Encode_Property_APDU(&apdu[0], - property, array_index, error_class, error_code); + apdu_len = + Device_Encode_Property_APDU(&apdu[0], property, + array_index, error_class, error_code); } break; case OBJECT_ANALOG_INPUT: if (Analog_Input_Valid_Instance(object_instance)) { - apdu_len = Analog_Input_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Analog_Input_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_ANALOG_VALUE: if (Analog_Value_Valid_Instance(object_instance)) { - apdu_len = Analog_Value_Encode_Property_APDU(&Temp_Buf[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Analog_Value_Encode_Property_APDU(&Temp_Buf[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_BINARY_INPUT: if (Binary_Input_Valid_Instance(object_instance)) { - apdu_len = Binary_Input_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Binary_Input_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; case OBJECT_BINARY_VALUE: if (Binary_Value_Valid_Instance(object_instance)) { - apdu_len = Binary_Value_Encode_Property_APDU(&Temp_Buf[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Binary_Value_Encode_Property_APDU(&Temp_Buf[0], + object_instance, property, array_index, error_class, + error_code); } break; default: @@ -125,28 +130,31 @@ void handler_read_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { /* we don't support segmentation - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); goto RP_ABORT; } len = rp_decode_service_request(service_request, service_len, &data); if (len < 0) { /* bad decoding - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); goto RP_ABORT; } /* most cases will be error */ error = true; - len = Encode_Property_APDU(&Temp_Buf[0], - data.object_type, - data.object_instance, - data.object_property, data.array_index, &error_class, &error_code); + len = + Encode_Property_APDU(&Temp_Buf[0], data.object_type, + data.object_instance, data.object_property, data.array_index, + &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ data.application_data = &Temp_Buf[0]; @@ -160,19 +168,22 @@ void handler_read_property( if (error) { if (len == -2) { /* BACnet APDU too small to fit data, so proper response is Abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); goto RP_ABORT; } - len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code); + len = + bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY, + error_class, error_code); } RP_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); return; } diff --git a/bacnet-stack/ports/at91sam7s/h_wp.c b/bacnet-stack/ports/at91sam7s/h_wp.c index 46771934..ae4b6aba 100644 --- a/bacnet-stack/ports/at91sam7s/h_wp.c +++ b/bacnet-stack/ports/at91sam7s/h_wp.c @@ -63,19 +63,22 @@ void handler_write_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); goto WP_ABORT; } /* decode the service request only */ len = wp_decode_service_request(service_request, service_len, &wp_data); /* bad decoding or something we didn't understand - send an abort */ if (len <= 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); goto WP_ABORT; } @@ -89,8 +92,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); } break; case OBJECT_ANALOG_INPUT: @@ -111,8 +114,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); } break; case OBJECT_ANALOG_VALUE: @@ -124,8 +127,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); } break; default: @@ -137,8 +140,9 @@ void handler_write_property( } WP_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); return; } diff --git a/bacnet-stack/ports/at91sam7s/init.c b/bacnet-stack/ports/at91sam7s/init.c index aee5819f..1c5202f8 100644 --- a/bacnet-stack/ports/at91sam7s/init.c +++ b/bacnet-stack/ports/at91sam7s/init.c @@ -77,8 +77,9 @@ void LowLevelInit( // // OUT = 0 (not used) // result: AT91C_CKGR_PLLR = 0x00000000480A0E (PLL Register) - pPMC->PMC_PLLR = ((AT91C_CKGR_DIV & 14) | - (AT91C_CKGR_PLLCOUNT & (10 << 8)) | (AT91C_CKGR_MUL & (72 << 16))); + pPMC->PMC_PLLR = + ((AT91C_CKGR_DIV & 14) | (AT91C_CKGR_PLLCOUNT & (10 << 8)) | + (AT91C_CKGR_MUL & (72 << 16))); // Wait the startup time (until PMC Status register LOCK bit is set) while (!(pPMC->PMC_SR & AT91C_PMC_LOCK)); diff --git a/bacnet-stack/ports/at91sam7s/main.c b/bacnet-stack/ports/at91sam7s/main.c index 3a3ce7e7..878ea40e 100644 --- a/bacnet-stack/ports/at91sam7s/main.c +++ b/bacnet-stack/ports/at91sam7s/main.c @@ -155,8 +155,7 @@ static void bacnet_init( apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, handler_write_property); /* handle communication so we can shutup when asked */ - apdu_set_confirmed_handler - (SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, + apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, handler_device_communication_control); #endif } diff --git a/bacnet-stack/ports/atmega168/ai.c b/bacnet-stack/ports/atmega168/ai.c index 438cd2ac..b32e3099 100644 --- a/bacnet-stack/ports/atmega168/ai.c +++ b/bacnet-stack/ports/atmega168/ai.c @@ -122,13 +122,13 @@ int Analog_Input_Encode_Property_APDU( encode_application_character_string(&apdu[0], &char_string); break; case PROP_OBJECT_TYPE: - apdu_len = encode_application_enumerated(&apdu[0], - OBJECT_ANALOG_INPUT); + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_ANALOG_INPUT); break; case PROP_PRESENT_VALUE: object_index = Analog_Input_Instance_To_Index(object_instance); - apdu_len = encode_application_real(&apdu[0], - Present_Value[object_index]); + apdu_len = + encode_application_real(&apdu[0], Present_Value[object_index]); break; case PROP_STATUS_FLAGS: bitstring_init(&bit_string); diff --git a/bacnet-stack/ports/atmega168/apdu.c b/bacnet-stack/ports/atmega168/apdu.c index 6ea7afbc..1bf594f5 100644 --- a/bacnet-stack/ports/atmega168/apdu.c +++ b/bacnet-stack/ports/atmega168/apdu.c @@ -103,12 +103,11 @@ void apdu_handler( switch (apdu[0] & 0xF0) { case PDU_TYPE_CONFIRMED_SERVICE_REQUEST: len = apdu_decode_confirmed_service_request(&apdu[0], /* APDU data */ - apdu_len, - &service_data, - &service_choice, &service_request, &service_request_len); + apdu_len, &service_data, &service_choice, &service_request, + &service_request_len); if (service_choice == SERVICE_CONFIRMED_READ_PROPERTY) { - handler_read_property(service_request, - service_request_len, src, &service_data); + handler_read_property(service_request, service_request_len, + src, &service_data); } #if 0 else if (service_choice == SERVICE_CONFIRMED_WRITE_PROPERTY) { diff --git a/bacnet-stack/ports/atmega168/av.c b/bacnet-stack/ports/atmega168/av.c index e2d587bd..8d41918c 100644 --- a/bacnet-stack/ports/atmega168/av.c +++ b/bacnet-stack/ports/atmega168/av.c @@ -175,7 +175,8 @@ bool Analog_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -219,14 +220,14 @@ void testAnalog_Value( BACNET_ERROR_CODE error_code; - len = Analog_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/atmega168/device.c b/bacnet-stack/ports/atmega168/device.c index 6aaaf660..07d18d66 100644 --- a/bacnet-stack/ports/atmega168/device.c +++ b/bacnet-stack/ports/atmega168/device.c @@ -217,7 +217,8 @@ int Device_Encode_Property_APDU( /* FIXME: change the hardcoded names to suit your application */ switch (property) { case PROP_OBJECT_IDENTIFIER: - apdu_len = encode_application_object_id(&apdu[0], OBJECT_DEVICE, + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_DEVICE, Object_Instance_Number); break; case PROP_OBJECT_NAME: @@ -342,8 +343,8 @@ int Device_Encode_Property_APDU( apdu_len = encode_application_unsigned(&apdu[0], MAX_APDU); break; case PROP_SEGMENTATION_SUPPORTED: - apdu_len = encode_application_enumerated(&apdu[0], - SEGMENTATION_NONE); + apdu_len = + encode_application_enumerated(&apdu[0], SEGMENTATION_NONE); break; case PROP_APDU_TIMEOUT: apdu_len = encode_application_unsigned(&apdu[0], 60000); @@ -396,7 +397,8 @@ bool Device_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -404,8 +406,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/atmega168/dlmstp.c b/bacnet-stack/ports/atmega168/dlmstp.c index 931d6eb6..c67e329e 100644 --- a/bacnet-stack/ports/atmega168/dlmstp.c +++ b/bacnet-stack/ports/atmega168/dlmstp.c @@ -697,8 +697,7 @@ static bool MSTP_Master_Node_FSM( TransmitPacketLen = dlmstp_encode_unconfirmed_frame(); if (TransmitPacketLen) { MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY, - MSTP_BROADCAST_ADDRESS, - This_Station, + MSTP_BROADCAST_ADDRESS, This_Station, (uint8_t *) & TransmitPacket[0], TransmitPacketLen); FrameCount++; } else { @@ -798,8 +797,8 @@ static bool MSTP_Master_Node_FSM( /* address at which a new master node may be found in that case. */ TokenCount++; /* transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); RetryCount = 0; EventCount = 0; Master_State = MSTP_MASTER_STATE_PASS_TOKEN; @@ -821,8 +820,8 @@ static bool MSTP_Master_Node_FSM( /* ResetMaintenancePFM */ Poll_Station = This_Station; /* transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); RetryCount = 0; TokenCount = 1; /* changed in Errata SSPC-135-2004 */ EventCount = 0; @@ -831,8 +830,8 @@ static bool MSTP_Master_Node_FSM( } else { /* SendMaintenancePFM */ Poll_Station = next_poll_station; - MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, - Poll_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station, + This_Station, NULL, 0); RetryCount = 0; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; } @@ -853,8 +852,8 @@ static bool MSTP_Master_Node_FSM( /* RetrySendToken */ RetryCount++; /* Transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); EventCount = 0; /* re-enter the current state to listen for NS */ /* to begin using the token. */ @@ -863,8 +862,8 @@ static bool MSTP_Master_Node_FSM( /* Assume that NS has failed. */ Poll_Station = next_next_station; /* Transmit a Poll For Master frame to PS. */ - MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, - Poll_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station, + This_Station, NULL, 0); /* no known successor node */ Next_Station = This_Station; RetryCount = 0; @@ -897,8 +896,8 @@ static bool MSTP_Master_Node_FSM( /* on the network and is empowered to create a token. */ Poll_Station = next_this_station; /* Transmit a Poll For Master frame to PS. */ - MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, - Poll_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station, + This_Station, NULL, 0); /* indicate that the next station is unknown */ Next_Station = This_Station; RetryCount = 0; @@ -921,8 +920,8 @@ static bool MSTP_Master_Node_FSM( Next_Station = SourceAddress; EventCount = 0; /* Transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); Poll_Station = This_Station; TokenCount = 0; RetryCount = 0; @@ -954,8 +953,8 @@ static bool MSTP_Master_Node_FSM( /* poll for a master at address PS. */ EventCount = 0; /* transmit a Token frame to NS */ - MSTP_Send_Frame(FRAME_TYPE_TOKEN, - Next_Station, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station, + This_Station, NULL, 0); RetryCount = 0; Master_State = MSTP_MASTER_STATE_PASS_TOKEN; } else { @@ -996,8 +995,7 @@ static bool MSTP_Master_Node_FSM( /* and enter the IDLE state to wait for the next frame. */ /* Note: optimized such that we are never a client */ MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY, - TransmitPacketDest, - This_Station, + TransmitPacketDest, This_Station, (uint8_t *) & TransmitPacket[0], TransmitPacketLen); MSTP_Flag.TransmitPacketPending = false; Master_State = MSTP_MASTER_STATE_IDLE; @@ -1011,8 +1009,8 @@ static bool MSTP_Master_Node_FSM( /* Any reply shall wait until this node receives the token. */ /* Call MSTP_Send_Frame to transmit a Reply Postponed frame, */ /* and enter the IDLE state. */ - MSTP_Send_Frame(FRAME_TYPE_REPLY_POSTPONED, - SourceAddress, This_Station, NULL, 0); + MSTP_Send_Frame(FRAME_TYPE_REPLY_POSTPONED, SourceAddress, + This_Station, NULL, 0); Master_State = MSTP_MASTER_STATE_IDLE; } /* clear our flag we were holding for comparison */ diff --git a/bacnet-stack/ports/atmega168/h_rp.c b/bacnet-stack/ports/atmega168/h_rp.c index 5a8f8fbe..e9dc533c 100644 --- a/bacnet-stack/ports/atmega168/h_rp.c +++ b/bacnet-stack/ports/atmega168/h_rp.c @@ -67,15 +67,17 @@ int Encode_Property_APDU( switch (object_type) { case OBJECT_DEVICE: if (Device_Valid_Object_Instance_Number(object_instance)) { - apdu_len = Device_Encode_Property_APDU(&apdu[0], - property, array_index, error_class, error_code); + apdu_len = + Device_Encode_Property_APDU(&apdu[0], property, + array_index, error_class, error_code); } break; case OBJECT_ANALOG_VALUE: if (Analog_Value_Valid_Instance(object_instance)) { - apdu_len = Analog_Value_Encode_Property_APDU(&apdu[0], - object_instance, - property, array_index, error_class, error_code); + apdu_len = + Analog_Value_Encode_Property_APDU(&apdu[0], + object_instance, property, array_index, error_class, + error_code); } break; default: @@ -107,24 +109,27 @@ void handler_read_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (len < 0) { /* bad decoding - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); } else if (service_data->segmented_message) { /* we don't support segmentation - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); } else { /* most cases will be error */ error = true; - len = Encode_Property_APDU(&Temp_Buf[0], - data.object_type, - data.object_instance, - data.object_property, data.array_index, &error_class, &error_code); + len = + Encode_Property_APDU(&Temp_Buf[0], data.object_type, + data.object_instance, data.object_property, data.array_index, + &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ data.application_data = &Temp_Buf[0]; @@ -140,21 +145,24 @@ void handler_read_property( switch (len) { /* BACnet APDU too small to fit data, so proper response is Abort */ case -2: - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); break; case -1: default: - len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code); + len = + bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY, + error_class, error_code); break; } } pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); return; } diff --git a/bacnet-stack/ports/atmega168/h_whois.c b/bacnet-stack/ports/atmega168/h_whois.c index d39046b1..d273bab4 100644 --- a/bacnet-stack/ports/atmega168/h_whois.c +++ b/bacnet-stack/ports/atmega168/h_whois.c @@ -50,8 +50,9 @@ void handler_who_is( int32_t target_device; (void) src; - len = whois_decode_service_request(service_request, - service_len, &low_limit, &high_limit); + len = + whois_decode_service_request(service_request, service_len, &low_limit, + &high_limit); if (len == 0) { Send_I_Am = true; } else if (len != -1) { diff --git a/bacnet-stack/ports/atmega168/h_wp.c b/bacnet-stack/ports/atmega168/h_wp.c index 18335548..f5e96087 100644 --- a/bacnet-stack/ports/atmega168/h_wp.c +++ b/bacnet-stack/ports/atmega168/h_wp.c @@ -67,16 +67,19 @@ void handler_write_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); /* bad decoding or something we didn't understand - send an abort */ if (len <= 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); } else if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); } else { switch (wp_data.object_type) { #if 0 @@ -143,8 +146,9 @@ void handler_write_property( } } pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); return; } diff --git a/bacnet-stack/ports/linux/arcnet.c b/bacnet-stack/ports/linux/arcnet.c index a553fb59..24fe2d07 100644 --- a/bacnet-stack/ports/linux/arcnet.c +++ b/bacnet-stack/ports/linux/arcnet.c @@ -124,8 +124,8 @@ static int arcnet_bind( "You might need to add the following to modules.conf\n" "(or in /etc/modutils/alias on Debian with update-modules):\n" "alias net-pf-17 af_packet\n" - "Also, add af_packet to /etc/modules.\n" - "Then follow it by:\n" "# modprobe af_packet\n"); + "Also, add af_packet to /etc/modules.\n" "Then follow it by:\n" + "# modprobe af_packet\n"); exit(-1); } @@ -144,14 +144,14 @@ static int arcnet_bind( if (bind(sock_fd, &ARCNET_Socket_Address, sizeof(ARCNET_Socket_Address)) != 0) { /* Bind problem, close socket and return */ - fprintf(stderr, - "arcnet: Unable to bind socket : %s\n", strerror(errno)); + fprintf(stderr, "arcnet: Unable to bind socket : %s\n", + strerror(errno)); fprintf(stderr, "You might need to add the following to modules.conf\n" "(or in /etc/modutils/alias on Debian with update-modules):\n" "alias net-pf-17 af_packet\n" - "Also, add af_packet to /etc/modules.\n" - "Then follow it by:\n" "# modprobe af_packet\n"); + "Also, add af_packet to /etc/modules.\n" "Then follow it by:\n" + "# modprobe af_packet\n"); /* Close the socket */ close(sock_fd); exit(-1); @@ -170,8 +170,8 @@ static int arcnet_bind( /* Strcpy the interface name into the address */ strncpy(ARCNET_Socket_Address.sa_data, interface_name, sizeof(ARCNET_Socket_Address.sa_data) - 1); - fprintf(stderr, "arcnet: MAC=%02Xh iface=\"%s\"\n", - ARCNET_MAC_Address, ARCNET_Socket_Address.sa_data); + fprintf(stderr, "arcnet: MAC=%02Xh iface=\"%s\"\n", ARCNET_MAC_Address, + ARCNET_Socket_Address.sa_data); atexit(arcnet_cleanup); @@ -295,8 +295,7 @@ uint16_t arcnet_receive( /* using O_NONBLOCK and no data */ /* was immediately available for reading. */ if (errno != EAGAIN) - fprintf(stderr, - "ethernet: Read error in receiving packet: %s\n", + fprintf(stderr, "ethernet: Read error in receiving packet: %s\n", strerror(errno)); return 0; } diff --git a/bacnet-stack/ports/linux/bip-init.c b/bacnet-stack/ports/linux/bip-init.c index 61a8a571..8ced946a 100644 --- a/bacnet-stack/ports/linux/bip-init.c +++ b/bacnet-stack/ports/linux/bip-init.c @@ -103,8 +103,8 @@ static void bip_set_interface( if (BIP_Debug) { fprintf(stderr, "IP Broadcast Address: %s\n", inet_ntoa(broadcast_address)); - fprintf(stderr, "UDP Port: 0x%04X [%hu]\n", - bip_get_port(), bip_get_port()); + fprintf(stderr, "UDP Port: 0x%04X [%hu]\n", bip_get_port(), + bip_get_port()); } } @@ -128,16 +128,18 @@ bool bip_init( /* Allow us to use the same socket for sending and receiving */ /* This makes sure that the src port is correct when sending */ sockopt = 1; - status = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, - &sockopt, sizeof(sockopt)); + status = + setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &sockopt, + sizeof(sockopt)); if (status < 0) { close(sock_fd); bip_set_socket(-1); return status; } /* allow us to send a broadcast */ - status = setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, - &sockopt, sizeof(sockopt)); + status = + setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, &sockopt, + sizeof(sockopt)); if (status < 0) { close(sock_fd); bip_set_socket(-1); @@ -148,8 +150,8 @@ bool bip_init( sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_port = htons(bip_get_port()); memset(&(sin.sin_zero), '\0', sizeof(sin.sin_zero)); - status = bind(sock_fd, - (const struct sockaddr *) &sin, sizeof(struct sockaddr)); + status = + bind(sock_fd, (const struct sockaddr *) &sin, sizeof(struct sockaddr)); if (status < 0) { close(sock_fd); bip_set_socket(-1); diff --git a/bacnet-stack/ports/linux/dlmstp.c b/bacnet-stack/ports/linux/dlmstp.c index 09dccdfc..40df5b82 100644 --- a/bacnet-stack/ports/linux/dlmstp.c +++ b/bacnet-stack/ports/linux/dlmstp.c @@ -177,8 +177,7 @@ uint16_t dlmstp_receive( /* was immediately available for reading. */ if (errno != EAGAIN) { #if PRINT_ENABLED - fprintf(stderr, - "mstp: Read error in Receive_Client packet: %s\n", + fprintf(stderr, "mstp: Read error in Receive_Client packet: %s\n", strerror(errno)); #endif } @@ -320,8 +319,8 @@ int dlmstp_get_transmit_packet( max = Transmit_Client_SockFD; if (select(max + 1, &read_fds, NULL, NULL, &select_timeout) > 0) { - received_bytes = read(Transmit_Client_SockFD, - packet, sizeof(DLMSTP_PACKET)); + received_bytes = + read(Transmit_Client_SockFD, packet, sizeof(DLMSTP_PACKET)); } else { return 0; } @@ -333,8 +332,7 @@ int dlmstp_get_transmit_packet( /* was immediately available for reading. */ if (errno != EAGAIN) { #if PRINT_ENABLED - fprintf(stderr, - "mstp: Read error in Transmit_Client packet: %s\n", + fprintf(stderr, "mstp: Read error in Transmit_Client packet: %s\n", strerror(errno)); #endif } @@ -369,9 +367,8 @@ uint16_t MSTP_Get_Send( } /* convert the PDU into the MSTP Frame */ pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */ - mstp_port->OutputBufferSize, - packet.frame_type, - destination, mstp_port->This_Station, &packet.pdu[0], packet.pdu_len); + mstp_port->OutputBufferSize, packet.frame_type, destination, + mstp_port->This_Station, &packet.pdu[0], packet.pdu_len); return pdu_len; } @@ -401,8 +398,9 @@ bool dlmstp_compare_data_expecting_reply( /* decode the request data */ request.address.mac[0] = src_address; request.address.mac_len = 1; - offset = npdu_decode(&request_pdu[0], - NULL, &request.address, &request.npdu_data); + offset = + npdu_decode(&request_pdu[0], NULL, &request.address, + &request.npdu_data); if (request.npdu_data.network_layer_message) { return false; } @@ -418,8 +416,8 @@ bool dlmstp_compare_data_expecting_reply( request.service_choice = request_pdu[offset + 3]; /* decode the reply data */ bacnet_address_copy(&reply.address, dest_address); - offset = npdu_decode(&reply_pdu[0], - &reply.address, NULL, &reply.npdu_data); + offset = + npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data); if (reply.npdu_data.network_layer_message) { return false; } @@ -508,25 +506,23 @@ uint16_t MSTP_Get_Reply( return 0; } /* is this the reply to the DER? */ - matched = dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0], - mstp_port->DataLength, - mstp_port->SourceAddress, - &Transmit_Packet.pdu[0], - Transmit_Packet.pdu_len, &Transmit_Packet.address); + matched = + dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0], + mstp_port->DataLength, mstp_port->SourceAddress, + &Transmit_Packet.pdu[0], Transmit_Packet.pdu_len, + &Transmit_Packet.address); if (matched) { /* convert the PDU into the MSTP Frame */ pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */ - mstp_port->OutputBufferSize, - Transmit_Packet.frame_type, - destination, - mstp_port->This_Station, - &Transmit_Packet.pdu[0], Transmit_Packet.pdu_len); + mstp_port->OutputBufferSize, Transmit_Packet.frame_type, + destination, mstp_port->This_Station, &Transmit_Packet.pdu[0], + Transmit_Packet.pdu_len); /* not used here, but setting it anyway */ Transmit_Packet.ready = false; } else { /* put it back into the queue */ - (void) write(Transmit_Server_SockFD, - &Transmit_Packet, sizeof(Transmit_Packet)); + (void) write(Transmit_Server_SockFD, &Transmit_Packet, + sizeof(Transmit_Packet)); } return pdu_len; @@ -842,8 +838,7 @@ int main( /* forever task */ for (;;) { #if (defined(MSTP_TEST_REQUEST) && MSTP_TEST_REQUEST) - MSTP_Create_And_Send_Frame(&MSTP_Port, - FRAME_TYPE_TEST_REQUEST, + MSTP_Create_And_Send_Frame(&MSTP_Port, FRAME_TYPE_TEST_REQUEST, MSTP_Port.SourceAddress, MSTP_Port.This_Station, NULL, 0); nanosleep(&timeOut, &remains); #endif diff --git a/bacnet-stack/ports/linux/ethernet.c b/bacnet-stack/ports/linux/ethernet.c index 866099be..d38a4f7d 100644 --- a/bacnet-stack/ports/linux/ethernet.c +++ b/bacnet-stack/ports/linux/ethernet.c @@ -112,14 +112,14 @@ static int ethernet_bind( /* Attempt to open the socket for 802.2 ethernet frames */ if ((sock_fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_802_2))) < 0) { /* Error occured */ - fprintf(stderr, - "ethernet: Error opening socket: %s\n", strerror(errno)); + fprintf(stderr, "ethernet: Error opening socket: %s\n", + strerror(errno)); fprintf(stderr, "You might need to add the following to modules.conf\n" "(or in /etc/modutils/alias on Debian with update-modules):\n" "alias net-pf-17 af_packet\n" - "Also, add af_packet to /etc/modules.\n" - "Then follow it by:\n" "# modprobe af_packet\n"); + "Also, add af_packet to /etc/modules.\n" "Then follow it by:\n" + "# modprobe af_packet\n"); exit(-1); } /* Bind the socket to an address */ @@ -132,14 +132,14 @@ static int ethernet_bind( /* Attempt to bind the socket to the interface */ if (bind(sock_fd, eth_addr, sizeof(struct sockaddr)) != 0) { /* Bind problem, close socket and return */ - fprintf(stderr, - "ethernet: Unable to bind 802.2 socket : %s\n", strerror(errno)); + fprintf(stderr, "ethernet: Unable to bind 802.2 socket : %s\n", + strerror(errno)); fprintf(stderr, "You might need to add the following to modules.conf\n" "(or in /etc/modutils/alias on Debian with update-modules):\n" "alias net-pf-17 af_packet\n" - "Also, add af_packet to /etc/modules.\n" - "Then follow it by:\n" "# modprobe af_packet\n"); + "Also, add af_packet to /etc/modules.\n" "Then follow it by:\n" + "# modprobe af_packet\n"); /* Close the socket */ close(sock_fd); exit(-1); @@ -248,8 +248,8 @@ int ethernet_send_pdu( /* Send the packet */ bytes = - sendto(eth802_sockfd, &mtu, mtu_len, 0, - (struct sockaddr *) ð_addr, sizeof(struct sockaddr)); + sendto(eth802_sockfd, &mtu, mtu_len, 0, (struct sockaddr *) ð_addr, + sizeof(struct sockaddr)); /* did it get sent? */ if (bytes < 0) fprintf(stderr, "ethernet: Error sending packet: %s\n", @@ -303,8 +303,7 @@ uint16_t ethernet_receive( /* using O_NONBLOCK and no data */ /* was immediately available for reading. */ if (errno != EAGAIN) - fprintf(stderr, - "ethernet: Read error in receiving packet: %s\n", + fprintf(stderr, "ethernet: Read error in receiving packet: %s\n", strerror(errno)); return 0; } diff --git a/bacnet-stack/ports/linux/main.c b/bacnet-stack/ports/linux/main.c index b80727aa..0c33e64c 100644 --- a/bacnet-stack/ports/linux/main.c +++ b/bacnet-stack/ports/linux/main.c @@ -63,8 +63,9 @@ static void LocalIAmHandler( (void) src; (void) service_len; - len = iam_decode_service_request(service_request, - &device_id, &max_apdu, &segmentation, &vendor_id); + len = + iam_decode_service_request(service_request, &device_id, &max_apdu, + &segmentation, &vendor_id); fprintf(stderr, "Received I-Am Request"); if (len != -1) { fprintf(stderr, " from %u!\n", device_id); @@ -138,8 +139,8 @@ static void Read_Properties( got the reply with matching invoke ID or the TSM of the invoke ID expired. This demo is doing things asynchronously. */ status = Send_Read_Property_Request(device_id, /* destination device */ - OBJECT_DEVICE, - device_id, object_props[property], BACNET_ARRAY_ALL); + OBJECT_DEVICE, device_id, object_props[property], + BACNET_ARRAY_ALL); if (status) property++; } diff --git a/bacnet-stack/ports/linux/rx_fsm.c b/bacnet-stack/ports/linux/rx_fsm.c index ca7a1c8b..a15ecb74 100644 --- a/bacnet-stack/ports/linux/rx_fsm.c +++ b/bacnet-stack/ports/linux/rx_fsm.c @@ -160,20 +160,16 @@ static void print_received_packet( /* Data CRC: (present only if Length is non-zero) two octets, */ /* least significant octet first */ /* (pad): (optional) at most one octet of padding: X'FF' */ - fprintf(stderr, - "55 FF %02X %02X %02X %02X %02X %02X ", - mstp_port->FrameType, - mstp_port->DestinationAddress, - mstp_port->SourceAddress, - HI_BYTE(mstp_port->DataLength), + fprintf(stderr, "55 FF %02X %02X %02X %02X %02X %02X ", + mstp_port->FrameType, mstp_port->DestinationAddress, + mstp_port->SourceAddress, HI_BYTE(mstp_port->DataLength), LO_BYTE(mstp_port->DataLength), mstp_port->HeaderCRCActual); if (mstp_port->DataLength) { for (i = 0; i < mstp_port->DataLength; i++) { fprintf(stderr, "%02X ", mstp_port->InputBuffer[i]); } - fprintf(stderr, - "%02X %02X ", - mstp_port->DataCRCActualMSB, mstp_port->DataCRCActualLSB); + fprintf(stderr, "%02X %02X ", mstp_port->DataCRCActualMSB, + mstp_port->DataCRCActualLSB); } fprintf(stderr, "%s", mstptext_frame_type(mstp_port->FrameType)); fprintf(stderr, "\n"); diff --git a/bacnet-stack/ports/pic18f6720/ai.c b/bacnet-stack/ports/pic18f6720/ai.c index c9a13544..44598774 100644 --- a/bacnet-stack/ports/pic18f6720/ai.c +++ b/bacnet-stack/ports/pic18f6720/ai.c @@ -119,11 +119,12 @@ int Analog_Input_Encode_Property_APDU( encode_application_character_string(&apdu[0], &char_string); break; case PROP_OBJECT_TYPE: - apdu_len = encode_application_enumerated(&apdu[0], - OBJECT_ANALOG_INPUT); + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_ANALOG_INPUT); break; case PROP_PRESENT_VALUE: - apdu_len = encode_application_real(&apdu[0], + apdu_len = + encode_application_real(&apdu[0], Analog_Input_Present_Value(object_instance)); break; case PROP_STATUS_FLAGS: @@ -174,14 +175,14 @@ void testAnalogInput( /* FIXME: we should do a lot more testing here... */ - len = Analog_Input_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Input_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_INPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/pic18f6720/av.c b/bacnet-stack/ports/pic18f6720/av.c index 5e53e6d9..615edc2f 100644 --- a/bacnet-stack/ports/pic18f6720/av.c +++ b/bacnet-stack/ports/pic18f6720/av.c @@ -293,7 +293,8 @@ bool Analog_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -397,14 +398,14 @@ void testAnalog_Value( BACNET_ERROR_CODE error_code; - len = Analog_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Analog_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_ANALOG_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/pic18f6720/bi.c b/bacnet-stack/ports/pic18f6720/bi.c index a2a7e221..28f50d49 100644 --- a/bacnet-stack/ports/pic18f6720/bi.c +++ b/bacnet-stack/ports/pic18f6720/bi.c @@ -208,14 +208,14 @@ void testBinaryInput( /* FIXME: we should do a lot more testing here... */ - len = Binary_Input_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Input_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len >= 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_INPUT); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/pic18f6720/bv.c b/bacnet-stack/ports/pic18f6720/bv.c index b85ae06c..9ebcbe77 100644 --- a/bacnet-stack/ports/pic18f6720/bv.c +++ b/bacnet-stack/ports/pic18f6720/bv.c @@ -208,7 +208,8 @@ bool Binary_Value_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -316,14 +317,14 @@ void testBinary_Value( BACNET_ERROR_CODE error_code; - len = Binary_Value_Encode_Property_APDU(&apdu[0], - instance, + len = + Binary_Value_Encode_Property_APDU(&apdu[0], instance, PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code); ct_test(pTest, len != 0); len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID); - len = decode_object_id(&apdu[len], - (int *) &decoded_type, &decoded_instance); + len = + decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance); ct_test(pTest, decoded_type == OBJECT_BINARY_VALUE); ct_test(pTest, decoded_instance == instance); diff --git a/bacnet-stack/ports/pic18f6720/device.c b/bacnet-stack/ports/pic18f6720/device.c index fc9a9f91..3f4d5315 100644 --- a/bacnet-stack/ports/pic18f6720/device.c +++ b/bacnet-stack/ports/pic18f6720/device.c @@ -284,7 +284,8 @@ int Device_Encode_Property_APDU( /* FIXME: change the hardcoded names to suit your application */ switch (property) { case PROP_OBJECT_IDENTIFIER: - apdu_len = encode_application_object_id(&apdu[0], OBJECT_DEVICE, + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_DEVICE, Object_Instance_Number); break; case PROP_OBJECT_NAME: @@ -428,11 +429,13 @@ int Device_Encode_Property_APDU( } break; case PROP_MAX_APDU_LENGTH_ACCEPTED: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], Device_Max_APDU_Length_Accepted()); break; case PROP_SEGMENTATION_SUPPORTED: - apdu_len = encode_application_enumerated(&apdu[0], + apdu_len = + encode_application_enumerated(&apdu[0], Device_Segmentation_Supported()); break; case PROP_APDU_TIMEOUT: @@ -514,7 +517,8 @@ bool Device_Write_Property( return false; } /* decode the some of the request */ - len = bacapp_decode_application_data(wp_data->application_data, + len = + bacapp_decode_application_data(wp_data->application_data, wp_data->application_data_len, &value); /* FIXME: len < application_data_len: more data? */ /* FIXME: len == 0: unable to decode? */ @@ -522,8 +526,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 926557f4..084875ad 100644 --- a/bacnet-stack/ports/pic18f6720/dlmstp.c +++ b/bacnet-stack/ports/pic18f6720/dlmstp.c @@ -139,11 +139,10 @@ int dlmstp_send_pdu( if ((8 /* header len */ + pdu_len) > MAX_MPDU) { return -4; } - bytes_sent = MSTP_Create_Frame( - (uint8_t *) & MSTP_Port.TxBuffer[0], - sizeof(MSTP_Port.TxBuffer), - MSTP_Port.TxFrameType, - destination, MSTP_Port.This_Station, pdu, pdu_len); + bytes_sent = + MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0], + sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType, destination, + MSTP_Port.This_Station, pdu, pdu_len); MSTP_Port.TxLength = bytes_sent; MSTP_Port.TxReady = true; MSTP_Packets++; @@ -180,8 +179,8 @@ void dlmstp_task( if (Receive_Buffer.ready && !MSTP_Port.TxReady) { if (Receive_Buffer.pdu_len) { MSTP_Packets++; - npdu_handler(&Receive_Buffer.address, - &Receive_Buffer.pdu[0], Receive_Buffer.pdu_len); + npdu_handler(&Receive_Buffer.address, &Receive_Buffer.pdu[0], + Receive_Buffer.pdu_len); } Receive_Buffer.ready = false; } diff --git a/bacnet-stack/ports/pic18f6720/h_rp.c b/bacnet-stack/ports/pic18f6720/h_rp.c index cc50cdb8..3f0f789a 100644 --- a/bacnet-stack/ports/pic18f6720/h_rp.c +++ b/bacnet-stack/ports/pic18f6720/h_rp.c @@ -66,19 +66,22 @@ void handler_read_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { /* we don't support segmentation - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); goto RP_ABORT; } len = rp_decode_service_request(service_request, service_len, &data); if (len < 0) { /* bad decoding - send an abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); goto RP_ABORT; } @@ -88,26 +91,27 @@ void handler_read_property( case OBJECT_DEVICE: /* FIXME: probably need a length limitation sent with encode */ if (Device_Valid_Object_Instance_Number(data.object_instance)) { - len = Device_Encode_Property_APDU(&Temp_Buf[0], - data.object_property, - data.array_index, &error_class, &error_code); + len = + Device_Encode_Property_APDU(&Temp_Buf[0], + data.object_property, data.array_index, &error_class, + &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ data.application_data = &Temp_Buf[0]; data.application_data_len = len; /* FIXME: probably need a length limitation sent with encode */ len = - rp_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); error = false; } } break; case OBJECT_ANALOG_INPUT: if (Analog_Input_Valid_Instance(data.object_instance)) { - len = Analog_Input_Encode_Property_APDU(&Temp_Buf[0], - data.object_instance, - data.object_property, + len = + Analog_Input_Encode_Property_APDU(&Temp_Buf[0], + data.object_instance, data.object_property, data.array_index, &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ @@ -115,17 +119,17 @@ void handler_read_property( data.application_data_len = len; /* FIXME: probably need a length limitation sent with encode */ len = - rp_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); error = false; } } break; case OBJECT_BINARY_INPUT: if (Binary_Input_Valid_Instance(data.object_instance)) { - len = Binary_Input_Encode_Property_APDU(&Temp_Buf[0], - data.object_instance, - data.object_property, + len = + Binary_Input_Encode_Property_APDU(&Temp_Buf[0], + data.object_instance, data.object_property, data.array_index, &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ @@ -133,17 +137,17 @@ void handler_read_property( data.application_data_len = len; /* FIXME: probably need a length limitation sent with encode */ len = - rp_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); error = false; } } break; case OBJECT_BINARY_VALUE: if (Binary_Value_Valid_Instance(data.object_instance)) { - len = Binary_Value_Encode_Property_APDU(&Temp_Buf[0], - data.object_instance, - data.object_property, + len = + Binary_Value_Encode_Property_APDU(&Temp_Buf[0], + data.object_instance, data.object_property, data.array_index, &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ @@ -151,17 +155,17 @@ void handler_read_property( data.application_data_len = len; /* FIXME: probably need a length limitation sent with encode */ len = - rp_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); error = false; } } break; case OBJECT_ANALOG_VALUE: if (Analog_Value_Valid_Instance(data.object_instance)) { - len = Analog_Value_Encode_Property_APDU(&Temp_Buf[0], - data.object_instance, - data.object_property, + len = + Analog_Value_Encode_Property_APDU(&Temp_Buf[0], + data.object_instance, data.object_property, data.array_index, &error_class, &error_code); if (len >= 0) { /* encode the APDU portion of the packet */ @@ -169,8 +173,8 @@ void handler_read_property( data.application_data_len = len; /* FIXME: probably need a length limitation sent with encode */ len = - rp_ack_encode_apdu(&Handler_Transmit_Buffer - [pdu_len], service_data->invoke_id, &data); + rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, &data); error = false; } } @@ -181,19 +185,22 @@ void handler_read_property( if (error) { if (len == -2) { /* BACnet APDU too small to fit data, so proper response is Abort */ - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); goto RP_ABORT; } - len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code); + len = + bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY, + error_class, error_code); } RP_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); return; } diff --git a/bacnet-stack/ports/pic18f6720/h_wp.c b/bacnet-stack/ports/pic18f6720/h_wp.c index 7dc80640..4c4ba928 100644 --- a/bacnet-stack/ports/pic18f6720/h_wp.c +++ b/bacnet-stack/ports/pic18f6720/h_wp.c @@ -62,19 +62,22 @@ void handler_write_property( /* encode the NPDU portion of the packet */ 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], src, - &my_address, &npdu_data); + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, + &npdu_data); if (service_data->segmented_message) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, + true); goto WP_ABORT; } /* decode the service request only */ len = wp_decode_service_request(service_request, service_len, &wp_data); /* bad decoding or something we didn't understand - send an abort */ if (len <= 0) { - len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + len = + abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, ABORT_REASON_OTHER, true); goto WP_ABORT; } @@ -91,8 +94,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "Sending Write Property Error for Device!\n"); #endif @@ -122,8 +125,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "Sending Write Access Error for BV!\n"); #endif @@ -141,8 +144,8 @@ void handler_write_property( } else { len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code); + service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY, + error_class, error_code); #if PRINT_ENABLED fprintf(stderr, "Sending Write Access Error for AV!\n"); #endif @@ -160,8 +163,9 @@ void handler_write_property( } WP_ABORT: pdu_len += len; - bytes_sent = datalink_send_pdu(src, &npdu_data, - &Handler_Transmit_Buffer[0], pdu_len); + bytes_sent = + datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], + pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); diff --git a/bacnet-stack/ports/pic18f6720/main.c b/bacnet-stack/ports/pic18f6720/main.c index 0bd15ecb..022695fe 100644 --- a/bacnet-stack/ports/pic18f6720/main.c +++ b/bacnet-stack/ports/pic18f6720/main.c @@ -106,14 +106,13 @@ static void BACnet_Service_Handlers_Init( apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, handler_write_property); #if 0 - apdu_set_unconfirmed_handler - (SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, handler_timesync_utc); + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, + handler_timesync_utc); apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, handler_timesync); #endif /* handle communication so we can shutup when asked */ - apdu_set_confirmed_handler - (SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, + apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, handler_device_communication_control); } diff --git a/bacnet-stack/ports/pic18f6720/mstp.c b/bacnet-stack/ports/pic18f6720/mstp.c index 2c980154..6cde0ad9 100644 --- a/bacnet-stack/ports/pic18f6720/mstp.c +++ b/bacnet-stack/ports/pic18f6720/mstp.c @@ -506,7 +506,8 @@ void MSTP_Receive_Frame_FSM( #endif /* DataOctet */ if (mstp_port->Index < mstp_port->DataLength) { - mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, mstp_port->DataCRC); mstp_port->InputBuffer[mstp_port->Index] = mstp_port->DataRegister; @@ -515,14 +516,16 @@ void MSTP_Receive_Frame_FSM( } /* CRC1 */ else if (mstp_port->Index == mstp_port->DataLength) { - mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, mstp_port->DataCRC); mstp_port->Index++; mstp_port->receive_state = MSTP_RECEIVE_STATE_DATA; } /* CRC2 */ else if (mstp_port->Index == (mstp_port->DataLength + 1)) { - mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, mstp_port->DataCRC); /* STATE DATA CRC - no need for new state */ /* indicate the complete reception of a valid frame */ @@ -570,26 +573,21 @@ bool MSTP_Master_Node_FSM( #endif /* some calculations that several states need */ - next_poll_station = (mstp_port->Poll_Station + 1) % - (mstp_port->Nmax_master + 1); - next_this_station = (mstp_port->This_Station + 1) % - (mstp_port->Nmax_master + 1); - next_next_station = (mstp_port->Next_Station + 1) % - (mstp_port->Nmax_master + 1); + next_poll_station = + (mstp_port->Poll_Station + 1) % (mstp_port->Nmax_master + 1); + next_this_station = + (mstp_port->This_Station + 1) % (mstp_port->Nmax_master + 1); + next_next_station = + (mstp_port->Next_Station + 1) % (mstp_port->Nmax_master + 1); #if PRINT_ENABLED_MASTER if (mstp_port->master_state != master_state) { master_state = mstp_port->master_state; fprintf(stderr, "MSTP: TS=%02X[%02X] NS=%02X[%02X] PS=%02X[%02X] EC=%u TC=%u ST=%u %s\n", - mstp_port->This_Station, - next_this_station, - mstp_port->Next_Station, - next_next_station, - mstp_port->Poll_Station, - next_poll_station, - mstp_port->EventCount, - mstp_port->TokenCount, - mstp_port->SilenceTimer, + mstp_port->This_Station, next_this_station, + mstp_port->Next_Station, next_next_station, + mstp_port->Poll_Station, next_poll_station, mstp_port->EventCount, + mstp_port->TokenCount, mstp_port->SilenceTimer, mstptext_master_state(mstp_port->master_state)); } #endif @@ -625,17 +623,14 @@ bool MSTP_Master_Node_FSM( #if PRINT_ENABLED_MASTER fprintf(stderr, "MSTP: ReceivedValidFrame Src=%02X Dest=%02X DataLen=%u FC=%u ST=%u Type=%s\n", - mstp_port->SourceAddress, - mstp_port->DestinationAddress, - mstp_port->DataLength, - mstp_port->FrameCount, + mstp_port->SourceAddress, mstp_port->DestinationAddress, + mstp_port->DataLength, mstp_port->FrameCount, mstp_port->SilenceTimer, mstptext_frame_type(mstp_port->FrameType)); #endif /* destined for me! */ - if ((mstp_port->DestinationAddress == - mstp_port->This_Station) || - (mstp_port->DestinationAddress == + if ((mstp_port->DestinationAddress == mstp_port->This_Station) + || (mstp_port->DestinationAddress == MSTP_BROADCAST_ADDRESS)) { switch (mstp_port->FrameType) { /* ReceivedToken */ @@ -827,10 +822,9 @@ bool MSTP_Master_Node_FSM( /* address at which a new master node may be found in that case. */ mstp_port->TokenCount++; /* transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, - mstp_port->Next_Station, - mstp_port->This_Station, NULL, 0); + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); mstp_port->RetryCount = 0; mstp_port->EventCount = 0; mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN; @@ -854,10 +848,9 @@ bool MSTP_Master_Node_FSM( /* ResetMaintenancePFM */ mstp_port->Poll_Station = mstp_port->This_Station; /* transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, - mstp_port->Next_Station, - mstp_port->This_Station, NULL, 0); + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); mstp_port->RetryCount = 0; mstp_port->TokenCount = 1; /* changed in Errata SSPC-135-2004 */ mstp_port->EventCount = 0; @@ -867,8 +860,8 @@ bool MSTP_Master_Node_FSM( /* SendMaintenancePFM */ mstp_port->Poll_Station = next_poll_station; MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_POLL_FOR_MASTER, - mstp_port->Poll_Station, mstp_port->This_Station, NULL, 0); + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); mstp_port->RetryCount = 0; mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER; } @@ -889,8 +882,7 @@ bool MSTP_Master_Node_FSM( /* RetrySendToken */ mstp_port->RetryCount++; /* Transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station, mstp_port->This_Station, NULL, 0); mstp_port->EventCount = 0; @@ -902,9 +894,8 @@ bool MSTP_Master_Node_FSM( mstp_port->Poll_Station = next_next_station; /* Transmit a Poll For Master frame to PS. */ MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_POLL_FOR_MASTER, - mstp_port->Poll_Station, mstp_port->This_Station, NULL, - 0); + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); /* no known successor node */ mstp_port->Next_Station = mstp_port->This_Station; mstp_port->RetryCount = 0; @@ -940,9 +931,8 @@ bool MSTP_Master_Node_FSM( mstp_port->Poll_Station = next_this_station; /* Transmit a Poll For Master frame to PS. */ MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_POLL_FOR_MASTER, - mstp_port->Poll_Station, mstp_port->This_Station, NULL, - 0); + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); /* indicate that the next station is unknown */ mstp_port->Next_Station = mstp_port->This_Station; mstp_port->RetryCount = 0; @@ -967,8 +957,7 @@ bool MSTP_Master_Node_FSM( mstp_port->Next_Station = mstp_port->SourceAddress; mstp_port->EventCount = 0; /* Transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station, mstp_port->This_Station, NULL, 0); mstp_port->Poll_Station = mstp_port->This_Station; @@ -1002,8 +991,7 @@ bool MSTP_Master_Node_FSM( /* poll for a master at address PS. */ mstp_port->EventCount = 0; /* transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station, mstp_port->This_Station, NULL, 0); mstp_port->RetryCount = 0; @@ -1073,8 +1061,7 @@ bool MSTP_Master_Node_FSM( /* and enter the IDLE state. */ { MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_REPLY_POSTPONED, - mstp_port->SourceAddress, + FRAME_TYPE_REPLY_POSTPONED, mstp_port->SourceAddress, mstp_port->This_Station, NULL, 0); mstp_port->master_state = MSTP_MASTER_STATE_IDLE; } diff --git a/bacnet-stack/ports/rtos32/bip-init.c b/bacnet-stack/ports/rtos32/bip-init.c index 0bdec1c5..169625c6 100644 --- a/bacnet-stack/ports/rtos32/bip-init.c +++ b/bacnet-stack/ports/rtos32/bip-init.c @@ -174,8 +174,8 @@ static void NetInitialize( } #else /* Set the IP address and interface */ - printf("Using static IP address %i.%i.%i.%i\n", TargetIP[0], - TargetIP[1], TargetIP[2], TargetIP[3]); + printf("Using static IP address %i.%i.%i.%i\n", TargetIP[0], TargetIP[1], + TargetIP[2], TargetIP[3]); Result = xn_set_ip(interface, TargetIP, NetMask); /* define default gateway and DNS server */ xn_rt_add(RT_DEFAULT, ip_ffaddr, DefaultGateway, 1, interface, RT_INF); @@ -271,8 +271,8 @@ bool bip_init( sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_port = htons(bip_get_port()); memset(&(sin.sin_zero), '\0', 8); - rv = bind(sock_fd, - (const struct sockaddr *) &sin, sizeof(struct sockaddr)); + rv = bind(sock_fd, (const struct sockaddr *) &sin, + sizeof(struct sockaddr)); if (rv < 0) { close(sock_fd); bip_set_socket(-1); diff --git a/bacnet-stack/ports/rtos32/dlmstp.c b/bacnet-stack/ports/rtos32/dlmstp.c index f05d5a11..2c15977a 100644 --- a/bacnet-stack/ports/rtos32/dlmstp.c +++ b/bacnet-stack/ports/rtos32/dlmstp.c @@ -98,11 +98,10 @@ int dlmstp_send_pdu( } memmove(&PDU_Buffer[mtu_len], pdu, pdu_len); mtu_len += pdu_len; - bytes_sent = MSTP_Create_Frame( - (uint8_t *) & MSTP_Port.TxBuffer[0], - sizeof(MSTP_Port.TxBuffer), - MSTP_Port.TxFrameType, - destination, MSTP_Port.This_Station, &PDU_Buffer[0], mtu_len); + bytes_sent = + MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0], + sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType, destination, + MSTP_Port.This_Station, &PDU_Buffer[0], mtu_len); MSTP_Port.TxLength = bytes_sent; MSTP_Port.TxReady = true; } diff --git a/bacnet-stack/ports/rtos32/ethernet.c b/bacnet-stack/ports/rtos32/ethernet.c index 4962048a..bba30f45 100644 --- a/bacnet-stack/ports/rtos32/ethernet.c +++ b/bacnet-stack/ports/rtos32/ethernet.c @@ -78,8 +78,8 @@ bool ethernet_init( fprintf(stderr, "ethernet: failed to bind to socket!\r\n"); Ethernet_Address.sa_family = AF_INET; memset(Ethernet_Address.sa_data, 0, sizeof(Ethernet_Address.sa_data)); - if (bind(Ethernet_Socket, - &Ethernet_Address, sizeof(Ethernet_Address)) == SOCKET_ERROR) + if (bind(Ethernet_Socket, &Ethernet_Address, + sizeof(Ethernet_Address)) == SOCKET_ERROR) fprintf(stderr, "ethernet: failed to bind to socket!\r\n"); /*setsockopt(Ethernet_Socket,SOL_SOCKET,SO_802_2,(char *)&value,sizeof(value)); */ @@ -227,8 +227,7 @@ uint16_t ethernet_receive( /* using O_NONBLOCK and no data */ /* was immediately available for reading. */ if (errno != EAGAIN) - fprintf(stderr, - "ethernet: Read error in receiving packet: %s\n", + fprintf(stderr, "ethernet: Read error in receiving packet: %s\n", strerror(errno)); return 0; } diff --git a/bacnet-stack/ports/rtos32/mstp.c b/bacnet-stack/ports/rtos32/mstp.c index b5d25bf7..2b585e75 100644 --- a/bacnet-stack/ports/rtos32/mstp.c +++ b/bacnet-stack/ports/rtos32/mstp.c @@ -560,7 +560,8 @@ void MSTP_Receive_Frame_FSM( #endif /* DataOctet */ if (mstp_port->Index < mstp_port->DataLength) { - mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, mstp_port->DataCRC); mstp_port->InputBuffer[mstp_port->Index] = mstp_port->DataRegister; @@ -569,14 +570,16 @@ void MSTP_Receive_Frame_FSM( } /* CRC1 */ else if (mstp_port->Index == mstp_port->DataLength) { - mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, mstp_port->DataCRC); mstp_port->Index++; mstp_port->receive_state = MSTP_RECEIVE_STATE_DATA; } /* CRC2 */ else if (mstp_port->Index == (mstp_port->DataLength + 1)) { - mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, mstp_port->DataCRC); /* STATE DATA CRC - no need for new state */ /* indicate the complete reception of a valid frame */ @@ -708,26 +711,21 @@ bool MSTP_Master_Node_FSM( #endif /* some calculations that several states need */ - next_poll_station = (mstp_port->Poll_Station + 1) % - (mstp_port->Nmax_master + 1); - next_this_station = (mstp_port->This_Station + 1) % - (mstp_port->Nmax_master + 1); - next_next_station = (mstp_port->Next_Station + 1) % - (mstp_port->Nmax_master + 1); + next_poll_station = + (mstp_port->Poll_Station + 1) % (mstp_port->Nmax_master + 1); + next_this_station = + (mstp_port->This_Station + 1) % (mstp_port->Nmax_master + 1); + next_next_station = + (mstp_port->Next_Station + 1) % (mstp_port->Nmax_master + 1); #if PRINT_ENABLED_MASTER if (mstp_port->master_state != master_state) { master_state = mstp_port->master_state; fprintf(stderr, "MSTP: TS=%02X[%02X] NS=%02X[%02X] PS=%02X[%02X] EC=%u TC=%u ST=%u %s\n", - mstp_port->This_Station, - next_this_station, - mstp_port->Next_Station, - next_next_station, - mstp_port->Poll_Station, - next_poll_station, - mstp_port->EventCount, - mstp_port->TokenCount, - mstp_port->SilenceTimer, + mstp_port->This_Station, next_this_station, + mstp_port->Next_Station, next_next_station, + mstp_port->Poll_Station, next_poll_station, mstp_port->EventCount, + mstp_port->TokenCount, mstp_port->SilenceTimer, mstp_master_state_text(mstp_port->master_state)); } #endif @@ -763,17 +761,14 @@ bool MSTP_Master_Node_FSM( #if PRINT_ENABLED_MASTER fprintf(stderr, "MSTP: ReceivedValidFrame Src=%02X Dest=%02X DataLen=%u FC=%u ST=%u Type=%s\n", - mstp_port->SourceAddress, - mstp_port->DestinationAddress, - mstp_port->DataLength, - mstp_port->FrameCount, + mstp_port->SourceAddress, mstp_port->DestinationAddress, + mstp_port->DataLength, mstp_port->FrameCount, mstp_port->SilenceTimer, mstp_frame_type_text(mstp_port->FrameType)); #endif /* destined for me! */ - if ((mstp_port->DestinationAddress == - mstp_port->This_Station) || - (mstp_port->DestinationAddress == + if ((mstp_port->DestinationAddress == mstp_port->This_Station) + || (mstp_port->DestinationAddress == MSTP_BROADCAST_ADDRESS)) { switch (mstp_port->FrameType) { /* ReceivedToken */ @@ -964,10 +959,9 @@ bool MSTP_Master_Node_FSM( /* address at which a new master node may be found in that case. */ mstp_port->TokenCount++; /* transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, - mstp_port->Next_Station, - mstp_port->This_Station, NULL, 0); + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); mstp_port->RetryCount = 0; mstp_port->EventCount = 0; mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN; @@ -991,10 +985,9 @@ bool MSTP_Master_Node_FSM( /* ResetMaintenancePFM */ mstp_port->Poll_Station = mstp_port->This_Station; /* transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, - mstp_port->Next_Station, - mstp_port->This_Station, NULL, 0); + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); mstp_port->RetryCount = 0; mstp_port->TokenCount = 1; /* changed in Errata SSPC-135-2004 */ mstp_port->EventCount = 0; @@ -1004,8 +997,8 @@ bool MSTP_Master_Node_FSM( /* SendMaintenancePFM */ mstp_port->Poll_Station = next_poll_station; MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_POLL_FOR_MASTER, - mstp_port->Poll_Station, mstp_port->This_Station, NULL, 0); + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); mstp_port->RetryCount = 0; mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER; } @@ -1027,8 +1020,7 @@ bool MSTP_Master_Node_FSM( /* RetrySendToken */ mstp_port->RetryCount++; /* Transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station, mstp_port->This_Station, NULL, 0); mstp_port->EventCount = 0; @@ -1040,9 +1032,8 @@ bool MSTP_Master_Node_FSM( mstp_port->Poll_Station = next_next_station; /* Transmit a Poll For Master frame to PS. */ MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_POLL_FOR_MASTER, - mstp_port->Poll_Station, mstp_port->This_Station, NULL, - 0); + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); /* no known successor node */ mstp_port->Next_Station = mstp_port->This_Station; mstp_port->RetryCount = 0; @@ -1079,9 +1070,8 @@ bool MSTP_Master_Node_FSM( mstp_port->Poll_Station = next_this_station; /* Transmit a Poll For Master frame to PS. */ MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_POLL_FOR_MASTER, - mstp_port->Poll_Station, mstp_port->This_Station, NULL, - 0); + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); /* indicate that the next station is unknown */ mstp_port->Next_Station = mstp_port->This_Station; mstp_port->RetryCount = 0; @@ -1107,8 +1097,7 @@ bool MSTP_Master_Node_FSM( mstp_port->Next_Station = mstp_port->SourceAddress; mstp_port->EventCount = 0; /* Transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station, mstp_port->This_Station, NULL, 0); mstp_port->Poll_Station = mstp_port->This_Station; @@ -1141,8 +1130,7 @@ bool MSTP_Master_Node_FSM( /* poll for a master at address PS. */ mstp_port->EventCount = 0; /* transmit a Token frame to NS */ - MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_TOKEN, + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, mstp_port->Next_Station, mstp_port->This_Station, NULL, 0); mstp_port->RetryCount = 0; @@ -1214,8 +1202,7 @@ bool MSTP_Master_Node_FSM( /* and enter the IDLE state. */ { MSTP_Create_And_Send_Frame(mstp_port, - FRAME_TYPE_REPLY_POSTPONED, - mstp_port->SourceAddress, + FRAME_TYPE_REPLY_POSTPONED, mstp_port->SourceAddress, mstp_port->This_Station, NULL, 0); mstp_port->master_state = MSTP_MASTER_STATE_IDLE; transition_now = true; diff --git a/bacnet-stack/ports/win32/bip-init.c b/bacnet-stack/ports/win32/bip-init.c index 98e79eae..32681412 100644 --- a/bacnet-stack/ports/win32/bip-init.c +++ b/bacnet-stack/ports/win32/bip-init.c @@ -214,8 +214,7 @@ static char *winsock_error_code_text( case WSAEDISCON: return "Disconnect."; case WSAHOST_NOT_FOUND: - return "Host not found. " - "This message indicates that the key " + return "Host not found. " "This message indicates that the key " "(name, address, and so on) was not found."; case WSATRY_AGAIN: return "Nonauthoritative host not found. " @@ -251,8 +250,8 @@ bool bip_init( /*Result = WSAStartup(MAKEWORD(2,2), &wd); */ if (Result != 0) { Code = WSAGetLastError(); - printf("TCP/IP stack initialization failed\n" - " error code: %i %s\n", Code, winsock_error_code_text(Code)); + printf("TCP/IP stack initialization failed\n" " error code: %i %s\n", + Code, winsock_error_code_text(Code)); exit(1); } atexit(cleanup); @@ -265,8 +264,8 @@ bool bip_init( address.s_addr = gethostaddr(); if (address.s_addr == (unsigned) -1) { Code = WSAGetLastError(); - printf("Get host address failed\n" - " error code: %i %s\n", Code, winsock_error_code_text(Code)); + printf("Get host address failed\n" " error code: %i %s\n", Code, + winsock_error_code_text(Code)); exit(1); } bip_set_addr(address.s_addr); @@ -282,8 +281,8 @@ bool bip_init( broadcast_address.s_addr = htonl(bip_get_broadcast_addr()); fprintf(stderr, "IP Broadcast Address: %s\n", inet_ntoa(broadcast_address)); - fprintf(stderr, "UDP Port: 0x%04X [%hu]\n", - bip_get_port(), bip_get_port()); + fprintf(stderr, "UDP Port: 0x%04X [%hu]\n", bip_get_port(), + bip_get_port()); } /* assumes that the driver has already been initialized */ sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); @@ -294,8 +293,8 @@ bool bip_init( } /* Allow us to use the same socket for sending and receiving */ /* This makes sure that the src port is correct when sending */ - rv = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, - (char *) &value, sizeof(value)); + rv = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &value, + sizeof(value)); if (rv < 0) { fprintf(stderr, "bip: failed to set REUSEADDR socket option.\n"); close(sock_fd); @@ -303,8 +302,8 @@ bool bip_init( return false; } /* allow us to send a broadcast */ - rv = setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, - (char *) &value, sizeof(value)); + rv = setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, (char *) &value, + sizeof(value)); if (rv < 0) { fprintf(stderr, "bip: failed to set BROADCAST socket option.\n"); close(sock_fd); @@ -315,8 +314,8 @@ bool bip_init( /* probably only for Apple... */ /* rebind a port that is already in use. Note: all users of the port must specify this flag */ - rv = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEPORT, - (char *) &value, sizeof(value)); + rv = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEPORT, (char *) &value, + sizeof(value)); if (rv < 0) { fprintf(stderr, "bip: failed to set REUSEPORT socket option.\n"); close(sock_fd); @@ -347,8 +346,8 @@ bool bip_init( #endif sin.sin_port = htons(bip_get_port()); memset(&(sin.sin_zero), '\0', sizeof(sin.sin_zero)); - rv = bind(sock_fd, - (const struct sockaddr *) &sin, sizeof(struct sockaddr)); + rv = bind(sock_fd, (const struct sockaddr *) &sin, + sizeof(struct sockaddr)); if (rv < 0) { fprintf(stderr, "bip: failed to bind to %s port %hd\n", inet_ntoa(sin.sin_addr), bip_get_port()); diff --git a/bacnet-stack/ports/win32/dlmstp.c b/bacnet-stack/ports/win32/dlmstp.c index 5b77a9ad..cd18c41c 100644 --- a/bacnet-stack/ports/win32/dlmstp.c +++ b/bacnet-stack/ports/win32/dlmstp.c @@ -144,13 +144,12 @@ uint16_t dlmstp_receive( if (Receive_Packet.pdu_len) { MSTP_Packets++; if (src) { - memmove(src, - &Receive_Packet.address, + memmove(src, &Receive_Packet.address, sizeof(Receive_Packet.address)); } if (pdu) { - memmove(pdu, - &Receive_Packet.pdu, sizeof(Receive_Packet.pdu)); + memmove(pdu, &Receive_Packet.pdu, + sizeof(Receive_Packet.pdu)); } pdu_len = Receive_Packet.pdu_len; } @@ -301,11 +300,9 @@ uint16_t MSTP_Get_Send( } /* convert the PDU into the MSTP Frame */ pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */ - mstp_port->OutputBufferSize, - Transmit_Packet.frame_type, - destination, - mstp_port->This_Station, - &Transmit_Packet.pdu[0], Transmit_Packet.pdu_len); + mstp_port->OutputBufferSize, Transmit_Packet.frame_type, destination, + mstp_port->This_Station, &Transmit_Packet.pdu[0], + Transmit_Packet.pdu_len); Transmit_Packet.ready = false; return pdu_len; @@ -336,8 +333,9 @@ bool dlmstp_compare_data_expecting_reply( /* decode the request data */ request.address.mac[0] = src_address; request.address.mac_len = 1; - offset = npdu_decode(&request_pdu[0], - NULL, &request.address, &request.npdu_data); + offset = + npdu_decode(&request_pdu[0], NULL, &request.address, + &request.npdu_data); if (request.npdu_data.network_layer_message) { return false; } @@ -353,8 +351,8 @@ bool dlmstp_compare_data_expecting_reply( request.service_choice = request_pdu[offset + 3]; /* decode the reply data */ bacnet_address_copy(&reply.address, dest_address); - offset = npdu_decode(&reply_pdu[0], - &reply.address, NULL, &reply.npdu_data); + offset = + npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data); if (reply.npdu_data.network_layer_message) { return false; } @@ -443,19 +441,18 @@ uint16_t MSTP_Get_Reply( return 0; } /* is this the reply to the DER? */ - matched = dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0], - mstp_port->DataLength, - mstp_port->SourceAddress, - &Transmit_Packet.pdu[0], - Transmit_Packet.pdu_len, &Transmit_Packet.address); + matched = + dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0], + mstp_port->DataLength, mstp_port->SourceAddress, + &Transmit_Packet.pdu[0], Transmit_Packet.pdu_len, + &Transmit_Packet.address); if (!matched) return 0; /* convert the PDU into the MSTP Frame */ pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */ - mstp_port->OutputBufferSize, - Transmit_Packet.frame_type, - destination, mstp_port->This_Station, - &Transmit_Packet.pdu[0], Transmit_Packet.pdu_len); + mstp_port->OutputBufferSize, Transmit_Packet.frame_type, destination, + mstp_port->This_Station, &Transmit_Packet.pdu[0], + Transmit_Packet.pdu_len); Transmit_Packet.ready = false; return pdu_len; @@ -721,8 +718,7 @@ int main( for (;;) { pdu_len = dlmstp_receive(NULL, NULL, 0, INFINITE); #if 0 - MSTP_Create_And_Send_Frame(&MSTP_Port, - FRAME_TYPE_TEST_REQUEST, + MSTP_Create_And_Send_Frame(&MSTP_Port, FRAME_TYPE_TEST_REQUEST, MSTP_Port.SourceAddress, MSTP_Port.This_Station, NULL, 0); #endif } diff --git a/bacnet-stack/ports/win32/ethernet.c b/bacnet-stack/ports/win32/ethernet.c index 9a4f339c..ae07bb02 100644 --- a/bacnet-stack/ports/win32/ethernet.c +++ b/bacnet-stack/ports/win32/ethernet.c @@ -155,8 +155,8 @@ bool ethernet_init( */ /* Retrieve the device list */ if (pcap_findalldevs(&pcap_all_if, pcap_errbuf) == -1) { - sprintf(msgBuf, - "ethernet.c: error in pcap_findalldevs: %s\n", pcap_errbuf); + sprintf(msgBuf, "ethernet.c: error in pcap_findalldevs: %s\n", + pcap_errbuf); LogError(msgBuf); return false; } @@ -167,8 +167,8 @@ bool ethernet_init( } pcap_freealldevs(pcap_all_if); /* we don't need it anymore */ if (dev == NULL) { - sprintf(msgBuf, - "ethernet.c: specified interface not found: %s\n", if_name); + sprintf(msgBuf, "ethernet.c: specified interface not found: %s\n", + if_name); LogError(msgBuf); return false; } @@ -180,8 +180,8 @@ bool ethernet_init( lpAdapter = PacketOpenAdapter(if_name); if (lpAdapter == NULL) { ethernet_cleanup(); - sprintf(msgBuf, - "ethernet.c: error in PacketOpenAdapter(\"%s\")\n", if_name); + sprintf(msgBuf, "ethernet.c: error in PacketOpenAdapter(\"%s\")\n", + if_name); LogError(msgBuf); return false; } @@ -284,8 +284,7 @@ int ethernet_send( if (pcap_sendpacket(pcap_eth802_fp, mtu, mtu_len) != 0) { /* did it get sent? */ char msgBuf[200]; - sprintf(msgBuf, - "ethernet.c: error sending packet: %s\n", + sprintf(msgBuf, "ethernet.c: error sending packet: %s\n", pcap_geterr(pcap_eth802_fp)); LogError(msgBuf); return -5; @@ -342,8 +341,7 @@ uint16_t ethernet_receive( res = pcap_next_ex(pcap_eth802_fp, &header, &pkt_data); if (res < 0) { char msgBuf[200]; - sprintf(msgBuf, - "ethernet.c: error in receiving packet: %s\n", + sprintf(msgBuf, "ethernet.c: error in receiving packet: %s\n", pcap_geterr(pcap_eth802_fp)); return 0; } else if (res == 0) @@ -445,8 +443,8 @@ void ethernet_debug_address( } /* if */ if (dest) { - sprintf(msgBuf, - "Address:\n MAC Length=%d\n MAC Address=", dest->mac_len); + sprintf(msgBuf, "Address:\n MAC Length=%d\n MAC Address=", + dest->mac_len); LogInfo(msgBuf); for (i = 0; i < MAX_MAC_LEN; i++) { sprintf(msgBuf, "%02X ", (unsigned) dest->mac[i]); diff --git a/bacnet-stack/ports/win32/main.c b/bacnet-stack/ports/win32/main.c index fce0c32b..0f19c80c 100644 --- a/bacnet-stack/ports/win32/main.c +++ b/bacnet-stack/ports/win32/main.c @@ -105,8 +105,8 @@ static void Read_Properties( next_device = true; else { status = Send_Read_Property_Request(device_id, /* destination device */ - OBJECT_DEVICE, - device_id, object_props[property], BACNET_ARRAY_ALL); + OBJECT_DEVICE, device_id, object_props[property], + BACNET_ARRAY_ALL); if (status) property++; } @@ -137,8 +137,9 @@ static void LocalIAmHandler( (void) src; (void) service_len; - len = iam_decode_service_request(service_request, - &device_id, &max_apdu, &segmentation, &vendor_id); + len = + iam_decode_service_request(service_request, &device_id, &max_apdu, + &segmentation, &vendor_id); fprintf(stderr, "Received I-Am Request"); if (len != -1) { fprintf(stderr, " from %u!\n", device_id); diff --git a/bacnet-stack/ports/win32/rs485.c b/bacnet-stack/ports/win32/rs485.c index fe497033..4f41bd15 100644 --- a/bacnet-stack/ports/win32/rs485.c +++ b/bacnet-stack/ports/win32/rs485.c @@ -190,8 +190,9 @@ static void RS485_Configure_Status( void RS485_Initialize( void) { - RS485_Handle = CreateFile(RS485_Port_Name, - GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, + RS485_Handle = + CreateFile(RS485_Port_Name, GENERIC_READ | GENERIC_WRITE, 0, 0, + OPEN_EXISTING, /*FILE_FLAG_OVERLAPPED */ 0, 0); if (RS485_Handle == INVALID_HANDLE_VALUE) { diff --git a/bacnet-stack/ports/win32/rx_fsm.c b/bacnet-stack/ports/win32/rx_fsm.c index 586d8d26..1a459173 100644 --- a/bacnet-stack/ports/win32/rx_fsm.c +++ b/bacnet-stack/ports/win32/rx_fsm.c @@ -129,20 +129,16 @@ static void print_received_packet( /* Data CRC: (present only if Length is non-zero) two octets, */ /* least significant octet first */ /* (pad): (optional) at most one octet of padding: X'FF' */ - fprintf(stderr, - "55 FF %02X %02X %02X %02X %02X %02X ", - mstp_port->FrameType, - mstp_port->DestinationAddress, - mstp_port->SourceAddress, - HI_BYTE(mstp_port->DataLength), + fprintf(stderr, "55 FF %02X %02X %02X %02X %02X %02X ", + mstp_port->FrameType, mstp_port->DestinationAddress, + mstp_port->SourceAddress, HI_BYTE(mstp_port->DataLength), LO_BYTE(mstp_port->DataLength), mstp_port->HeaderCRCActual); if (mstp_port->DataLength) { for (i = 0; i < mstp_port->DataLength; i++) { fprintf(stderr, "%02X ", mstp_port->InputBuffer[i]); } - fprintf(stderr, - "%02X %02X ", - mstp_port->DataCRCActualMSB, mstp_port->DataCRCActualLSB); + fprintf(stderr, "%02X %02X ", mstp_port->DataCRCActualMSB, + mstp_port->DataCRCActualLSB); } fprintf(stderr, "%s", mstptext_frame_type(mstp_port->FrameType)); fprintf(stderr, "\n"); diff --git a/bacnet-stack/src/abort.c b/bacnet-stack/src/abort.c index 877535b2..ed1331df 100644 --- a/bacnet-stack/src/abort.c +++ b/bacnet-stack/src/abort.c @@ -103,8 +103,9 @@ int abort_decode_apdu( else *server = false; if (apdu_len > 1) { - len = abort_decode_service_request(&apdu[1], - apdu_len - 1, invoke_id, abort_reason); + len = + abort_decode_service_request(&apdu[1], apdu_len - 1, invoke_id, + abort_reason); } } @@ -127,8 +128,9 @@ void testAbortAPDU( len = abort_encode_apdu(&apdu[0], invoke_id, abort_reason, server); apdu_len = len; ct_test(pTest, len != 0); - len = abort_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_abort_reason, &test_server); + len = + abort_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_abort_reason, &test_server); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_abort_reason == abort_reason); @@ -154,8 +156,9 @@ void testAbort( len = abort_encode_apdu(&apdu[0], invoke_id, abort_reason, server); ct_test(pTest, len != 0); apdu_len = len; - len = abort_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_abort_reason, &test_server); + len = + abort_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_abort_reason, &test_server); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_abort_reason == abort_reason); @@ -163,18 +166,21 @@ void testAbort( /* change type to get negative response */ apdu[0] = PDU_TYPE_REJECT; - len = abort_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_abort_reason, &test_server); + len = + abort_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_abort_reason, &test_server); ct_test(pTest, len == -1); /* test NULL APDU */ - len = abort_decode_apdu(NULL, - apdu_len, &test_invoke_id, &test_abort_reason, &test_server); + len = + abort_decode_apdu(NULL, apdu_len, &test_invoke_id, &test_abort_reason, + &test_server); ct_test(pTest, len == -1); /* force a zero length */ - len = abort_decode_apdu(&apdu[0], - 0, &test_invoke_id, &test_abort_reason, &test_server); + len = + abort_decode_apdu(&apdu[0], 0, &test_invoke_id, &test_abort_reason, + &test_server); ct_test(pTest, len == 0); /* check them all... */ diff --git a/bacnet-stack/src/address.c b/bacnet-stack/src/address.c index f3d95c0c..dedba414 100644 --- a/bacnet-stack/src/address.c +++ b/bacnet-stack/src/address.c @@ -59,8 +59,7 @@ void address_remove_device( unsigned i; for (i = 0; i < MAX_ADDRESS_CACHE; i++) { - if ((Address_Cache[i].valid || - Address_Cache[i].bind_request) && + if ((Address_Cache[i].valid || Address_Cache[i].bind_request) && (Address_Cache[i].device_id == device_id)) { Address_Cache[i].valid = false; break; @@ -320,8 +319,8 @@ void testAddress( &test_address)); ct_test(pTest, test_max_apdu == max_apdu); ct_test(pTest, bacnet_address_same(&test_address, &src)); - ct_test(pTest, address_get_by_index(i, &test_device_id, - &test_max_apdu, &test_address)); + ct_test(pTest, address_get_by_index(i, &test_device_id, &test_max_apdu, + &test_address)); ct_test(pTest, test_device_id == device_id); ct_test(pTest, test_max_apdu == max_apdu); ct_test(pTest, bacnet_address_same(&test_address, &src)); diff --git a/bacnet-stack/src/apdu.c b/bacnet-stack/src/apdu.c index 4ac321e3..2b60f200 100644 --- a/bacnet-stack/src/apdu.c +++ b/bacnet-stack/src/apdu.c @@ -304,9 +304,8 @@ void apdu_handler( switch (apdu[0] & 0xF0) { case PDU_TYPE_CONFIRMED_SERVICE_REQUEST: len = apdu_decode_confirmed_service_request(&apdu[0], /* APDU data */ - apdu_len, - &service_data, - &service_choice, &service_request, &service_request_len); + apdu_len, &service_data, &service_choice, &service_request, + &service_request_len); /* When network communications are completely disabled, only DeviceCommunicationControl and ReinitializeDevice APDUs shall be processed and no messages shall be initiated. */ @@ -437,8 +436,7 @@ void apdu_handler( len += decode_enumerated(&apdu[len], len_value, &error_code); if (service_choice < MAX_BACNET_CONFIRMED_SERVICE) { if (Error_Function[service_choice]) - Error_Function[service_choice] (src, - invoke_id, + Error_Function[service_choice] (src, invoke_id, (BACNET_ERROR_CLASS) error_class, (BACNET_ERROR_CODE) error_code); } diff --git a/bacnet-stack/src/arf.c b/bacnet-stack/src/arf.c index eb8e663f..57edd430 100644 --- a/bacnet-stack/src/arf.c +++ b/bacnet-stack/src/arf.c @@ -55,22 +55,27 @@ int arf_encode_apdu( apdu[2] = invoke_id; apdu[3] = SERVICE_CONFIRMED_ATOMIC_READ_FILE; /* service choice */ apdu_len = 4; - apdu_len += encode_application_object_id(&apdu[apdu_len], - data->object_type, data->object_instance); + apdu_len += + encode_application_object_id(&apdu[apdu_len], data->object_type, + data->object_instance); switch (data->access) { case FILE_STREAM_ACCESS: apdu_len += encode_opening_tag(&apdu[apdu_len], 0); - apdu_len += encode_application_signed(&apdu[apdu_len], + apdu_len += + encode_application_signed(&apdu[apdu_len], data->type.stream.fileStartPosition); - apdu_len += encode_application_unsigned(&apdu[apdu_len], + apdu_len += + encode_application_unsigned(&apdu[apdu_len], data->type.stream.requestedOctetCount); apdu_len += encode_closing_tag(&apdu[apdu_len], 0); break; case FILE_RECORD_ACCESS: apdu_len += encode_opening_tag(&apdu[apdu_len], 1); - apdu_len += encode_application_signed(&apdu[apdu_len], + apdu_len += + encode_application_signed(&apdu[apdu_len], data->type.record.fileStartRecord); - apdu_len += encode_application_unsigned(&apdu[apdu_len], + apdu_len += + encode_application_unsigned(&apdu[apdu_len], data->type.record.RecordCount); apdu_len += encode_closing_tag(&apdu[apdu_len], 1); break; @@ -108,21 +113,25 @@ int arf_decode_service_request( /* a tag number is not extended so only one octet */ len++; /* fileStartPosition */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT) return -1; - len += decode_signed(&apdu[len], - len_value_type, &data->type.stream.fileStartPosition); + len += + decode_signed(&apdu[len], len_value_type, + &data->type.stream.fileStartPosition); /* requestedOctetCount */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) return -1; - len += decode_unsigned(&apdu[len], - len_value_type, &data->type.stream.requestedOctetCount); + len += + decode_unsigned(&apdu[len], len_value_type, + &data->type.stream.requestedOctetCount); if (!decode_is_closing_tag_number(&apdu[len], 0)) return -1; /* a tag number is not extended so only one octet */ @@ -132,21 +141,25 @@ int arf_decode_service_request( /* a tag number is not extended so only one octet */ len++; /* fileStartRecord */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT) return -1; - len += decode_signed(&apdu[len], - len_value_type, &data->type.record.fileStartRecord); + len += + decode_signed(&apdu[len], len_value_type, + &data->type.record.fileStartRecord); /* RecordCount */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) return -1; - len += decode_unsigned(&apdu[len], - len_value_type, &data->type.record.RecordCount); + len += + decode_unsigned(&apdu[len], len_value_type, + &data->type.record.RecordCount); if (!decode_is_closing_tag_number(&apdu[len], 1)) return -1; /* a tag number is not extended so only one octet */ @@ -179,8 +192,8 @@ int arf_decode_apdu( offset = 4; if (apdu_len > offset) { - len = arf_decode_service_request(&apdu[offset], - apdu_len - offset, data); + len = + arf_decode_service_request(&apdu[offset], apdu_len - offset, data); } return len; @@ -205,19 +218,24 @@ int arf_ack_encode_apdu( switch (data->access) { case FILE_STREAM_ACCESS: apdu_len += encode_opening_tag(&apdu[apdu_len], 0); - apdu_len += encode_application_signed(&apdu[apdu_len], + apdu_len += + encode_application_signed(&apdu[apdu_len], data->type.stream.fileStartPosition); - apdu_len += encode_application_octet_string(&apdu[apdu_len], + apdu_len += + encode_application_octet_string(&apdu[apdu_len], &data->fileData); apdu_len += encode_closing_tag(&apdu[apdu_len], 0); break; case FILE_RECORD_ACCESS: apdu_len += encode_opening_tag(&apdu[apdu_len], 1); - apdu_len += encode_application_signed(&apdu[apdu_len], + apdu_len += + encode_application_signed(&apdu[apdu_len], data->type.record.fileStartRecord); - apdu_len += encode_application_unsigned(&apdu[apdu_len], + apdu_len += + encode_application_unsigned(&apdu[apdu_len], data->type.record.RecordCount); - apdu_len += encode_application_octet_string(&apdu[apdu_len], + apdu_len += + encode_application_octet_string(&apdu[apdu_len], &data->fileData); apdu_len += encode_closing_tag(&apdu[apdu_len], 1); break; @@ -253,21 +271,25 @@ int arf_ack_decode_service_request( /* a tag number is not extended so only one octet */ len++; /* fileStartPosition */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT) return -1; - len += decode_signed(&apdu[len], - len_value_type, &data->type.stream.fileStartPosition); + len += + decode_signed(&apdu[len], len_value_type, + &data->type.stream.fileStartPosition); /* fileData */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_OCTET_STRING) return -1; - len += decode_octet_string(&apdu[len], - len_value_type, &data->fileData); + len += + decode_octet_string(&apdu[len], len_value_type, + &data->fileData); if (!decode_is_closing_tag_number(&apdu[len], 0)) return -1; /* a tag number is not extended so only one octet */ @@ -277,29 +299,35 @@ int arf_ack_decode_service_request( /* a tag number is not extended so only one octet */ len++; /* fileStartRecord */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT) return -1; - len += decode_signed(&apdu[len], - len_value_type, &data->type.record.fileStartRecord); + len += + decode_signed(&apdu[len], len_value_type, + &data->type.record.fileStartRecord); /* returnedRecordCount */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) return -1; - len += decode_unsigned(&apdu[len], - len_value_type, &data->type.record.RecordCount); + len += + decode_unsigned(&apdu[len], len_value_type, + &data->type.record.RecordCount); /* fileData */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_OCTET_STRING) return -1; - len += decode_octet_string(&apdu[len], - len_value_type, &data->fileData); + len += + decode_octet_string(&apdu[len], len_value_type, + &data->fileData); if (!decode_is_closing_tag_number(&apdu[len], 1)) return -1; /* a tag number is not extended so only one octet */ @@ -331,8 +359,9 @@ int arf_ack_decode_apdu( offset = 3; if (apdu_len > offset) { - len = arf_ack_decode_service_request(&apdu[offset], - apdu_len - offset, data); + len = + arf_ack_decode_service_request(&apdu[offset], apdu_len - offset, + data); } return len; @@ -364,15 +393,19 @@ void testAtomicReadFileAckAccess( ct_test(pTest, test_data.endOfFile == data->endOfFile); ct_test(pTest, test_data.access == data->access); if (test_data.access == FILE_STREAM_ACCESS) { - ct_test(pTest, test_data.type.stream.fileStartPosition == + ct_test(pTest, + test_data.type.stream.fileStartPosition == data->type.stream.fileStartPosition); } else if (test_data.access == FILE_RECORD_ACCESS) { - ct_test(pTest, test_data.type.record.fileStartRecord == + ct_test(pTest, + test_data.type.record.fileStartRecord == data->type.record.fileStartRecord); - ct_test(pTest, test_data.type.record.RecordCount == + ct_test(pTest, + test_data.type.record.RecordCount == data->type.record.RecordCount); } - ct_test(pTest, octetstring_length(&test_data.fileData) == + ct_test(pTest, + octetstring_length(&test_data.fileData) == octetstring_length(&data->fileData)); ct_test(pTest, memcmp(octetstring_value(&test_data.fileData), octetstring_value(&data->fileData), @@ -389,16 +422,16 @@ void testAtomicReadFileAck( data.endOfFile = true; data.access = FILE_STREAM_ACCESS; data.type.stream.fileStartPosition = 0; - octetstring_init(&data.fileData, - test_octet_string, sizeof(test_octet_string)); + octetstring_init(&data.fileData, test_octet_string, + sizeof(test_octet_string)); testAtomicReadFileAckAccess(pTest, &data); data.endOfFile = false; data.access = FILE_RECORD_ACCESS; data.type.record.fileStartRecord = 1; data.type.record.RecordCount = 2; - octetstring_init(&data.fileData, - test_octet_string, sizeof(test_octet_string)); + octetstring_init(&data.fileData, test_octet_string, + sizeof(test_octet_string)); testAtomicReadFileAckAccess(pTest, &data); return; @@ -425,14 +458,18 @@ void testAtomicReadFileAccess( ct_test(pTest, test_data.object_instance == data->object_instance); ct_test(pTest, test_data.access == data->access); if (test_data.access == FILE_STREAM_ACCESS) { - ct_test(pTest, test_data.type.stream.fileStartPosition == + ct_test(pTest, + test_data.type.stream.fileStartPosition == data->type.stream.fileStartPosition); - ct_test(pTest, test_data.type.stream.requestedOctetCount == + ct_test(pTest, + test_data.type.stream.requestedOctetCount == data->type.stream.requestedOctetCount); } else if (test_data.access == FILE_RECORD_ACCESS) { - ct_test(pTest, test_data.type.record.fileStartRecord == + ct_test(pTest, + test_data.type.record.fileStartRecord == data->type.record.fileStartRecord); - ct_test(pTest, test_data.type.record.RecordCount == + ct_test(pTest, + test_data.type.record.RecordCount == data->type.record.RecordCount); } } diff --git a/bacnet-stack/src/awf.c b/bacnet-stack/src/awf.c index 10315489..e27e30f1 100644 --- a/bacnet-stack/src/awf.c +++ b/bacnet-stack/src/awf.c @@ -55,24 +55,30 @@ int awf_encode_apdu( apdu[2] = invoke_id; apdu[3] = SERVICE_CONFIRMED_ATOMIC_WRITE_FILE; /* service choice */ apdu_len = 4; - apdu_len += encode_application_object_id(&apdu[apdu_len], - data->object_type, data->object_instance); + apdu_len += + encode_application_object_id(&apdu[apdu_len], data->object_type, + data->object_instance); switch (data->access) { case FILE_STREAM_ACCESS: apdu_len += encode_opening_tag(&apdu[apdu_len], 0); - apdu_len += encode_application_signed(&apdu[apdu_len], + apdu_len += + encode_application_signed(&apdu[apdu_len], data->type.stream.fileStartPosition); - apdu_len += encode_application_octet_string(&apdu[apdu_len], + apdu_len += + encode_application_octet_string(&apdu[apdu_len], &data->fileData); apdu_len += encode_closing_tag(&apdu[apdu_len], 0); break; case FILE_RECORD_ACCESS: apdu_len += encode_opening_tag(&apdu[apdu_len], 1); - apdu_len += encode_application_signed(&apdu[apdu_len], + apdu_len += + encode_application_signed(&apdu[apdu_len], data->type.record.fileStartRecord); - apdu_len += encode_application_unsigned(&apdu[apdu_len], + apdu_len += + encode_application_unsigned(&apdu[apdu_len], data->type.record.returnedRecordCount); - apdu_len += encode_application_octet_string(&apdu[apdu_len], + apdu_len += + encode_application_octet_string(&apdu[apdu_len], &data->fileData); apdu_len += encode_closing_tag(&apdu[apdu_len], 1); break; @@ -112,21 +118,24 @@ int awf_decode_service_request( /* a tag number of 2 is not extended so only one octet */ len++; /* fileStartPosition */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT) return -1; len += decode_signed(&apdu[len], len_value_type, &signed_value); data->type.stream.fileStartPosition = signed_value; /* fileData */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_OCTET_STRING) return -1; - len += decode_octet_string(&apdu[len], - len_value_type, &data->fileData); + len += + decode_octet_string(&apdu[len], len_value_type, + &data->fileData); if (!decode_is_closing_tag_number(&apdu[len], 0)) return -1; /* a tag number is not extended so only one octet */ @@ -136,30 +145,34 @@ int awf_decode_service_request( /* a tag number is not extended so only one octet */ len++; /* fileStartRecord */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_SIGNED_INT) return -1; len += decode_signed(&apdu[len], len_value_type, &signed_value); data->type.record.fileStartRecord = signed_value; /* returnedRecordCount */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) return -1; - len += decode_unsigned(&apdu[len], len_value_type, - &unsigned_value); + len += + decode_unsigned(&apdu[len], len_value_type, &unsigned_value); data->type.record.returnedRecordCount = unsigned_value; /* fileData */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += tag_len; if (tag_number != BACNET_APPLICATION_TAG_OCTET_STRING) return -1; - len += decode_octet_string(&apdu[len], - len_value_type, &data->fileData); + len += + decode_octet_string(&apdu[len], len_value_type, + &data->fileData); if (!decode_is_closing_tag_number(&apdu[len], 1)) return -1; /* a tag number is not extended so only one octet */ @@ -192,8 +205,8 @@ int awf_decode_apdu( offset = 4; if (apdu_len > offset) { - len = awf_decode_service_request(&apdu[offset], - apdu_len - offset, data); + len = + awf_decode_service_request(&apdu[offset], apdu_len - offset, data); } return len; @@ -213,11 +226,13 @@ int awf_ack_encode_apdu( apdu_len = 3; switch (data->access) { case FILE_STREAM_ACCESS: - apdu_len += encode_context_signed(&apdu[apdu_len], 0, + apdu_len += + encode_context_signed(&apdu[apdu_len], 0, data->type.stream.fileStartPosition); break; case FILE_RECORD_ACCESS: - apdu_len += encode_context_signed(&apdu[apdu_len], 1, + apdu_len += + encode_context_signed(&apdu[apdu_len], 1, data->type.record.fileStartRecord); break; default: @@ -245,12 +260,14 @@ int awf_ack_decode_service_request( &len_value_type); if (tag_number == 0) { data->access = FILE_STREAM_ACCESS; - len += decode_signed(&apdu[len], - len_value_type, &data->type.stream.fileStartPosition); + len += + decode_signed(&apdu[len], len_value_type, + &data->type.stream.fileStartPosition); } else if (tag_number == 1) { data->access = FILE_RECORD_ACCESS; - len += decode_signed(&apdu[len], - len_value_type, &data->type.record.fileStartRecord); + len += + decode_signed(&apdu[len], len_value_type, + &data->type.record.fileStartRecord); } else return -1; } @@ -278,8 +295,8 @@ int awf_ack_decode_apdu( offset = 3; if (apdu_len > offset) { - len = awf_decode_service_request(&apdu[offset], - apdu_len - offset, data); + len = + awf_decode_service_request(&apdu[offset], apdu_len - offset, data); } return len; @@ -311,15 +328,19 @@ void testAtomicWriteFileAccess( ct_test(pTest, test_data.object_instance == data->object_instance); ct_test(pTest, test_data.access == data->access); if (test_data.access == FILE_STREAM_ACCESS) { - ct_test(pTest, test_data.type.stream.fileStartPosition == + ct_test(pTest, + test_data.type.stream.fileStartPosition == data->type.stream.fileStartPosition); } else if (test_data.access == FILE_RECORD_ACCESS) { - ct_test(pTest, test_data.type.record.fileStartRecord == + ct_test(pTest, + test_data.type.record.fileStartRecord == data->type.record.fileStartRecord); - ct_test(pTest, test_data.type.record.returnedRecordCount == + ct_test(pTest, + test_data.type.record.returnedRecordCount == data->type.record.returnedRecordCount); } - ct_test(pTest, octetstring_length(&test_data.fileData) == + ct_test(pTest, + octetstring_length(&test_data.fileData) == octetstring_length(&data->fileData)); ct_test(pTest, memcmp(octetstring_value(&test_data.fileData), octetstring_value(&data->fileData), @@ -336,8 +357,8 @@ void testAtomicWriteFile( data.object_instance = 1; data.access = FILE_STREAM_ACCESS; data.type.stream.fileStartPosition = 0; - octetstring_init(&data.fileData, - test_octet_string, sizeof(test_octet_string)); + octetstring_init(&data.fileData, test_octet_string, + sizeof(test_octet_string)); testAtomicWriteFileAccess(pTest, &data); data.object_type = OBJECT_FILE; @@ -345,8 +366,8 @@ void testAtomicWriteFile( data.access = FILE_RECORD_ACCESS; data.type.record.fileStartRecord = 1; data.type.record.returnedRecordCount = 2; - octetstring_init(&data.fileData, - test_octet_string, sizeof(test_octet_string)); + octetstring_init(&data.fileData, test_octet_string, + sizeof(test_octet_string)); testAtomicWriteFileAccess(pTest, &data); return; @@ -371,10 +392,12 @@ void testAtomicWriteFileAckAccess( ct_test(pTest, len != -1); ct_test(pTest, test_data.access == data->access); if (test_data.access == FILE_STREAM_ACCESS) { - ct_test(pTest, test_data.type.stream.fileStartPosition == + ct_test(pTest, + test_data.type.stream.fileStartPosition == data->type.stream.fileStartPosition); } else if (test_data.access == FILE_RECORD_ACCESS) { - ct_test(pTest, test_data.type.record.fileStartRecord == + ct_test(pTest, + test_data.type.record.fileStartRecord == data->type.record.fileStartRecord); } } diff --git a/bacnet-stack/src/bacapp.c b/bacnet-stack/src/bacapp.c index 3102a6d0..a687490d 100644 --- a/bacnet-stack/src/bacapp.c +++ b/bacnet-stack/src/bacapp.c @@ -62,19 +62,21 @@ int bacapp_encode_application_data( #endif #if defined (BACAPP_BOOLEAN) case BACNET_APPLICATION_TAG_BOOLEAN: - apdu_len = encode_application_boolean(&apdu[0], - value->type.Boolean); + apdu_len = + encode_application_boolean(&apdu[0], value->type.Boolean); break; #endif #if defined (BACAPP_UNSIGNED) case BACNET_APPLICATION_TAG_UNSIGNED_INT: - apdu_len = encode_application_unsigned(&apdu[0], + apdu_len = + encode_application_unsigned(&apdu[0], value->type.Unsigned_Int); break; #endif #if defined (BACAPP_SIGNED) case BACNET_APPLICATION_TAG_SIGNED_INT: - apdu_len = encode_application_signed(&apdu[0], + apdu_len = + encode_application_signed(&apdu[0], value->type.Signed_Int); break; #endif @@ -86,31 +88,35 @@ int bacapp_encode_application_data( #if defined (BACAPP_DOUBLE) case BACNET_APPLICATION_TAG_DOUBLE: /* FIXME: double is not implemented yet. */ - apdu_len = encode_application_double(&apdu[0], - value->type.Double); + apdu_len = + encode_application_double(&apdu[0], value->type.Double); break; #endif #if defined (BACAPP_OCTET_STRING) case BACNET_APPLICATION_TAG_OCTET_STRING: - apdu_len = encode_application_octet_string(&apdu[0], + apdu_len = + encode_application_octet_string(&apdu[0], &value->type.Octet_String); break; #endif #if defined (BACAPP_CHARACTER_STRING) case BACNET_APPLICATION_TAG_CHARACTER_STRING: - apdu_len = encode_application_character_string(&apdu[0], + apdu_len = + encode_application_character_string(&apdu[0], &value->type.Character_String); break; #endif #if defined (BACAPP_BIT_STRING) case BACNET_APPLICATION_TAG_BIT_STRING: - apdu_len = encode_application_bitstring(&apdu[0], + apdu_len = + encode_application_bitstring(&apdu[0], &value->type.Bit_String); break; #endif #if defined (BACAPP_ENUMERATED) case BACNET_APPLICATION_TAG_ENUMERATED: - apdu_len = encode_application_enumerated(&apdu[0], + apdu_len = + encode_application_enumerated(&apdu[0], value->type.Enumerated); break; #endif @@ -128,7 +134,8 @@ int bacapp_encode_application_data( #endif #if defined (BACAPP_OBJECT_ID) case BACNET_APPLICATION_TAG_OBJECT_ID: - apdu_len = encode_application_object_id(&apdu[0], + apdu_len = + encode_application_object_id(&apdu[0], value->type.Object_Id.type, value->type.Object_Id.instance); break; @@ -166,14 +173,16 @@ int bacapp_decode_data( #endif #if defined (BACAPP_UNSIGNED) case BACNET_APPLICATION_TAG_UNSIGNED_INT: - len = decode_unsigned(&apdu[0], - len_value_type, &value->type.Unsigned_Int); + len = + decode_unsigned(&apdu[0], len_value_type, + &value->type.Unsigned_Int); break; #endif #if defined (BACAPP_SIGNED) case BACNET_APPLICATION_TAG_SIGNED_INT: - len = decode_signed(&apdu[0], - len_value_type, &value->type.Signed_Int); + len = + decode_signed(&apdu[0], len_value_type, + &value->type.Signed_Int); break; #endif #if defined (BACAPP_REAL) @@ -188,26 +197,30 @@ int bacapp_decode_data( #endif #if defined (BACAPP_OCTET_STRING) case BACNET_APPLICATION_TAG_OCTET_STRING: - len = decode_octet_string(&apdu[0], - len_value_type, &value->type.Octet_String); + len = + decode_octet_string(&apdu[0], len_value_type, + &value->type.Octet_String); break; #endif #if defined (BACAPP_CHARACTER_STRING) case BACNET_APPLICATION_TAG_CHARACTER_STRING: - len = decode_character_string(&apdu[0], - len_value_type, &value->type.Character_String); + len = + decode_character_string(&apdu[0], len_value_type, + &value->type.Character_String); break; #endif #if defined (BACAPP_BIT_STRING) case BACNET_APPLICATION_TAG_BIT_STRING: - len = decode_bitstring(&apdu[0], - len_value_type, &value->type.Bit_String); + len = + decode_bitstring(&apdu[0], len_value_type, + &value->type.Bit_String); break; #endif #if defined (BACAPP_ENUMERATED) case BACNET_APPLICATION_TAG_ENUMERATED: - len = decode_enumerated(&apdu[0], - len_value_type, &value->type.Enumerated); + len = + decode_enumerated(&apdu[0], len_value_type, + &value->type.Enumerated); break; #endif #if defined (BACAPP_DATE) @@ -253,13 +266,15 @@ int bacapp_decode_application_data( max_apdu_len = max_apdu_len; if (apdu && value && !decode_is_context_specific(apdu)) { value->context_specific = false; - tag_len = decode_tag_number_and_value(&apdu[0], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[0], &tag_number, + &len_value_type); if (tag_len) { len += tag_len; value->tag = tag_number; - len += bacapp_decode_data(&apdu[len], - tag_number, len_value_type, value); + len += + bacapp_decode_data(&apdu[len], tag_number, len_value_type, + value); } value->next = NULL; } @@ -283,7 +298,8 @@ int bacapp_encode_context_data_value( #endif #if defined (BACAPP_BOOLEAN) case BACNET_APPLICATION_TAG_BOOLEAN: - apdu_len = encode_context_boolean(&apdu[0], context_tag_number, + apdu_len = + encode_context_boolean(&apdu[0], context_tag_number, value->type.Boolean); break; #endif @@ -296,20 +312,23 @@ int bacapp_encode_context_data_value( #endif #if defined (BACAPP_SIGNED) case BACNET_APPLICATION_TAG_SIGNED_INT: - apdu_len = encode_context_signed(&apdu[0], context_tag_number, + apdu_len = + encode_context_signed(&apdu[0], context_tag_number, value->type.Signed_Int); break; #endif #if defined (BACAPP_REAL) case BACNET_APPLICATION_TAG_REAL: - apdu_len = encode_context_real(&apdu[0], context_tag_number, + apdu_len = + encode_context_real(&apdu[0], context_tag_number, value->type.Real); break; #endif #if defined (BACAPP_DOUBLE) case BACNET_APPLICATION_TAG_DOUBLE: /* FIXME: double is not implemented yet. */ - apdu_len = encode_context_double(&apdu[0], context_tag_number, + apdu_len = + encode_context_double(&apdu[0], context_tag_number, value->type.Double); break; #endif @@ -343,13 +362,15 @@ int bacapp_encode_context_data_value( #endif #if defined (BACAPP_DATE) case BACNET_APPLICATION_TAG_DATE: - apdu_len = encode_context_date(&apdu[0], context_tag_number, + apdu_len = + encode_context_date(&apdu[0], context_tag_number, &value->type.Date); break; #endif #if defined (BACAPP_TIME) case BACNET_APPLICATION_TAG_TIME: - apdu_len = encode_context_time(&apdu[0], context_tag_number, + apdu_len = + encode_context_time(&apdu[0], context_tag_number, &value->type.Time); break; #endif @@ -445,8 +466,9 @@ int bacapp_encode_context_data( if (value && apdu) { tag_data_type = bacapp_context_tag_type(property, value->context_tag); if (tag_data_type < MAX_BACNET_APPLICATION_TAG) { - apdu_len = bacapp_encode_context_data_value(&apdu[0], - value->context_tag, value); + apdu_len = + bacapp_encode_context_data_value(&apdu[0], value->context_tag, + value); } else { /* FIXME: what now? */ apdu_len = 0; @@ -472,15 +494,17 @@ int bacapp_decode_context_data( max_apdu_len = max_apdu_len; if (apdu && value && decode_is_context_specific(apdu)) { value->context_specific = true; - tag_len = decode_tag_number_and_value(&apdu[0], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[0], &tag_number, + &len_value_type); if (tag_len) { apdu_len = tag_len; value->context_tag = tag_number; value->tag = bacapp_context_tag_type(property, tag_number); if (value->tag < MAX_BACNET_APPLICATION_TAG) { - len = bacapp_decode_data(&apdu[apdu_len], - value->tag, len_value_type, value); + len = + bacapp_decode_data(&apdu[apdu_len], value->tag, + len_value_type, value); apdu_len += len; } else { /* FIXME: what now? */ @@ -501,8 +525,9 @@ int bacapp_encode_data( if (value && apdu) { if (value->context_specific) { - apdu_len = bacapp_encode_context_data_value(&apdu[0], - value->context_tag, value); + apdu_len = + bacapp_encode_context_data_value(&apdu[0], value->context_tag, + value); } else { apdu_len = bacapp_encode_application_data(&apdu[0], value); } @@ -622,29 +647,33 @@ int bacapp_data_len( BACNET_APPLICATION_DATA_VALUE application_value; if (decode_is_opening_tag(&apdu[0])) { - len = decode_tag_number_and_value(&apdu[apdu_len], - &tag_number, &value); + len = + decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &value); apdu_len += len; opening_tag_number = tag_number; opening_tag_number_counter = 1; while (opening_tag_number_counter) { if (decode_is_opening_tag(&apdu[apdu_len])) { - len = decode_tag_number_and_value(&apdu[apdu_len], - &tag_number, &value); + len = + decode_tag_number_and_value(&apdu[apdu_len], &tag_number, + &value); if (tag_number == opening_tag_number) opening_tag_number_counter++; } else if (decode_is_closing_tag(&apdu[apdu_len])) { - len = decode_tag_number_and_value(&apdu[apdu_len], - &tag_number, &value); + len = + decode_tag_number_and_value(&apdu[apdu_len], &tag_number, + &value); if (tag_number == opening_tag_number) opening_tag_number_counter--; } else if (decode_is_context_specific(&apdu[apdu_len])) { /* context-specific tagged data */ - len = bacapp_decode_context_data(&apdu[apdu_len], + len = + bacapp_decode_context_data(&apdu[apdu_len], max_apdu_len - apdu_len, &application_value, property); } else { /* application tagged data */ - len = bacapp_decode_application_data(&apdu[apdu_len], + len = + bacapp_decode_application_data(&apdu[apdu_len], max_apdu_len - apdu_len, &application_value); } apdu_len += len; @@ -850,7 +879,8 @@ bool bacapp_parse_application_data( break; #endif case BACNET_APPLICATION_TAG_OCTET_STRING: - status = octetstring_init(&value->type.Octet_String, + status = + octetstring_init(&value->type.Octet_String, (uint8_t *) argv, strlen(argv)); break; case BACNET_APPLICATION_TAG_CHARACTER_STRING: @@ -871,8 +901,8 @@ bool bacapp_parse_application_data( count = sscanf(argv, "%d/%d/%d:%d", &year, &month, &day, &wday); if (count == 3) { - datetime_set_date(&value->type.Date, - (uint16_t) year, (uint8_t) month, (uint8_t) day); + datetime_set_date(&value->type.Date, (uint16_t) year, + (uint8_t) month, (uint8_t) day); } else if (count == 4) { value->type.Date.year = year; value->type.Date.month = month; @@ -1012,7 +1042,8 @@ bool bacapp_same_value( #endif #if defined (BACAPP_CHARACTER_STRING) case BACNET_APPLICATION_TAG_CHARACTER_STRING: - status = characterstring_same(&value->type.Character_String, + status = + characterstring_same(&value->type.Character_String, &test_value->type.Character_String); break; #endif @@ -1046,7 +1077,8 @@ void testBACnetApplicationDataLength( len = encode_closing_tag(&apdu[apdu_len], 3); apdu_len += len; /* verify the length of the data inside the opening/closing tags */ - len = bacapp_data_len(&apdu[0], apdu_len, + len = + bacapp_data_len(&apdu[0], apdu_len, PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES); ct_test(pTest, test_len == len); @@ -1194,27 +1226,30 @@ void testBACnetApplicationData( bool status = false; - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_NULL, - NULL, &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_NULL, NULL, + &value); ct_test(pTest, status == true); status = testBACnetApplicationDataValue(&value); ct_test(pTest, status == true); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_BOOLEAN, - "1", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_BOOLEAN, "1", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Boolean == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_BOOLEAN, - "0", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_BOOLEAN, "0", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Boolean == false); ct_test(pTest, testBACnetApplicationDataValue(&value)); status = - bacapp_parse_application_data(BACNET_APPLICATION_TAG_UNSIGNED_INT, - "0", &value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_UNSIGNED_INT, "0", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Unsigned_Int == 0); ct_test(pTest, testBACnetApplicationDataValue(&value)); @@ -1232,14 +1267,14 @@ void testBACnetApplicationData( ct_test(pTest, testBACnetApplicationDataValue(&value)); status = - bacapp_parse_application_data(BACNET_APPLICATION_TAG_SIGNED_INT, - "0", &value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_SIGNED_INT, "0", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Signed_Int == 0); ct_test(pTest, testBACnetApplicationDataValue(&value)); status = - bacapp_parse_application_data(BACNET_APPLICATION_TAG_SIGNED_INT, - "-1", &value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_SIGNED_INT, "-1", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Signed_Int == -1); ct_test(pTest, testBACnetApplicationDataValue(&value)); @@ -1256,30 +1291,35 @@ void testBACnetApplicationData( ct_test(pTest, value.type.Signed_Int == -32768); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, - "0.0", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "0.0", + &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, - "-1.0", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "-1.0", + &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, - "1.0", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "1.0", + &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, - "3.14159", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "3.14159", + &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, - "-3.14159", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "-3.14159", + &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); status = - bacapp_parse_application_data(BACNET_APPLICATION_TAG_ENUMERATED, - "0", &value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_ENUMERATED, "0", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Enumerated == 0); ct_test(pTest, testBACnetApplicationDataValue(&value)); @@ -1296,7 +1336,8 @@ void testBACnetApplicationData( ct_test(pTest, value.type.Enumerated == 0xFFFFFFFF); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_DATE, + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_DATE, "2005/5/22:1", &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Date.year == 2005); @@ -1306,8 +1347,9 @@ void testBACnetApplicationData( ct_test(pTest, testBACnetApplicationDataValue(&value)); /* Happy Valentines Day! */ - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_DATE, - "2007/2/14", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_DATE, "2007/2/14", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Date.year == 2007); ct_test(pTest, value.type.Date.month == 2); @@ -1316,7 +1358,8 @@ void testBACnetApplicationData( ct_test(pTest, testBACnetApplicationDataValue(&value)); /* Wildcard Values */ - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_DATE, + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_DATE, "2155/255/255:255", &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Date.year == 2155); @@ -1325,7 +1368,8 @@ void testBACnetApplicationData( ct_test(pTest, value.type.Date.wday == 255); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, "23:59:59.12", &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Time.hour == 23); @@ -1334,8 +1378,9 @@ void testBACnetApplicationData( ct_test(pTest, value.type.Time.hundredths == 12); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, - "23:59:59", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, "23:59:59", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Time.hour == 23); ct_test(pTest, value.type.Time.min == 59); @@ -1343,8 +1388,9 @@ void testBACnetApplicationData( ct_test(pTest, value.type.Time.hundredths == 0); ct_test(pTest, testBACnetApplicationDataValue(&value)); - status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, - "23:59", &value); + status = + bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, "23:59", + &value); ct_test(pTest, status == true); ct_test(pTest, value.type.Time.hour == 23); ct_test(pTest, value.type.Time.min == 59); @@ -1361,8 +1407,8 @@ void testBACnetApplicationData( ct_test(pTest, testBACnetApplicationDataValue(&value)); status = - bacapp_parse_application_data - (BACNET_APPLICATION_TAG_CHARACTER_STRING, "Karg!", &value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_CHARACTER_STRING, + "Karg!", &value); ct_test(pTest, status == true); ct_test(pTest, testBACnetApplicationDataValue(&value)); diff --git a/bacnet-stack/src/bacdcode.c b/bacnet-stack/src/bacdcode.c index b3c6d04b..ba77e92d 100644 --- a/bacnet-stack/src/bacdcode.c +++ b/bacnet-stack/src/bacdcode.c @@ -442,8 +442,8 @@ int encode_application_boolean( if (boolean_value) len_value = 1; - len = encode_tag(&apdu[0], BACNET_APPLICATION_TAG_BOOLEAN, false, - len_value); + len = + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_BOOLEAN, false, len_value); return len; } @@ -553,8 +553,8 @@ int decode_bitstring( byte_reverse_bits(apdu[len++])); } unused_bits = apdu[0] & 0x07; - bitstring_set_bits_used(bit_string, - (uint8_t) bytes_used, unused_bits); + bitstring_set_bits_used(bit_string, (uint8_t) bytes_used, + unused_bits); } } @@ -577,8 +577,8 @@ int encode_bitstring( apdu[len++] = 0; else { used_bytes = bitstring_bytes_used(bit_string); - remaining_used_bits = bitstring_bits_used(bit_string) - - ((used_bytes - 1) * 8); + remaining_used_bits = + bitstring_bits_used(bit_string) - ((used_bytes - 1) * 8); /* number of unused bits in the subsequent final octet */ apdu[len++] = 8 - remaining_used_bits; for (i = 0; i < used_bytes; i++) { @@ -598,7 +598,8 @@ int encode_application_bitstring( /* bit string may use more than 1 octet for the tag, so find out how many */ bit_string_encoded_length += bitstring_bytes_used(bit_string); - len = encode_tag(&apdu[0], BACNET_APPLICATION_TAG_BIT_STRING, false, + len = + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_BIT_STRING, false, bit_string_encoded_length); len += encode_bitstring(&apdu[len], bit_string); @@ -652,8 +653,9 @@ int encode_bacnet_object_id( int len = 0; type = object_type; - value = ((type & BACNET_MAX_OBJECT) << BACNET_INSTANCE_BITS) | - (instance & BACNET_MAX_INSTANCE); + value = + ((type & BACNET_MAX_OBJECT) << BACNET_INSTANCE_BITS) | (instance & + BACNET_MAX_INSTANCE); len = encode_unsigned32(apdu, value); return len; @@ -732,8 +734,8 @@ int encode_application_octet_string( if (octet_string) { apdu_len = - encode_tag(&apdu[0], BACNET_APPLICATION_TAG_OCTET_STRING, - false, octetstring_length(octet_string)); + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_OCTET_STRING, false, + octetstring_length(octet_string)); /* FIXME: probably need to pass in the length of the APDU to bounds check since it might not be the only data chunk */ if ((apdu_len + octetstring_length(octet_string)) < MAX_APDU) @@ -756,8 +758,9 @@ int encode_context_octet_string( int apdu_len = 0; if (apdu && octet_string) { - apdu_len = encode_tag(&apdu[0], (uint8_t) tag_number, - true, octetstring_length(octet_string)); + apdu_len = + encode_tag(&apdu[0], (uint8_t) tag_number, true, + octetstring_length(octet_string)); if ((apdu_len + octetstring_length(octet_string)) < MAX_APDU) apdu_len += encode_octet_string(&apdu[apdu_len], octet_string); else @@ -816,8 +819,8 @@ int encode_application_character_string( string_len = characterstring_length(char_string) + 1 /* for encoding */ ; len = - encode_tag(&apdu[0], BACNET_APPLICATION_TAG_CHARACTER_STRING, - false, string_len); + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_CHARACTER_STRING, false, + string_len); if ((len + string_len) < MAX_APDU) len += encode_bacnet_character_string(&apdu[len], char_string); else @@ -855,7 +858,8 @@ int decode_character_string( int len = 0; /* return value */ bool status = false; - status = characterstring_init(char_string, apdu[0], (char *) &apdu[1], + status = + characterstring_init(char_string, apdu[0], (char *) &apdu[1], len_value - 1); if (status) len = len_value; @@ -950,8 +954,8 @@ int encode_application_unsigned( int len = 0; len = encode_bacnet_unsigned(&apdu[1], value); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_UNSIGNED_INT, - false, len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_UNSIGNED_INT, false, len); return len; } @@ -1410,7 +1414,8 @@ void testBACDCodeTags( /* test the len-value-type portion */ for (value = 1;; value = value << 1) { len = encode_tag(&apdu[0], tag_number, false, value); - len = decode_tag_number_and_value(&apdu[0], &test_tag_number, + len = + decode_tag_number_and_value(&apdu[0], &test_tag_number, &test_value); ct_test(pTest, tag_number == test_tag_number); ct_test(pTest, value == test_value); @@ -1682,7 +1687,8 @@ void testBACDCodeOctetString( ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OCTET_STRING); len += decode_octet_string(&array[len], len_value, &test_octet_string); ct_test(pTest, apdu_len == len); - diff = memcmp(octetstring_value(&octet_string), &test_value[0], + diff = + memcmp(octetstring_value(&octet_string), &test_value[0], octetstring_length(&octet_string)); ct_test(pTest, diff == 0); @@ -1696,13 +1702,15 @@ void testBACDCodeOctetString( decode_tag_number_and_value(&encoded_array[0], &tag_number, &len_value); ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OCTET_STRING); - len += decode_octet_string(&encoded_array[len], len_value, + len += + decode_octet_string(&encoded_array[len], len_value, &test_octet_string); if (apdu_len != len) { printf("test octet string=#%d\n", i); } ct_test(pTest, apdu_len == len); - diff = memcmp(octetstring_value(&octet_string), &test_value[0], + diff = + memcmp(octetstring_value(&octet_string), &test_value[0], octetstring_length(&octet_string)); if (diff) { printf("test octet string=#%d\n", i); @@ -1736,7 +1744,8 @@ void testBACDCodeCharacterString( ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_CHARACTER_STRING); len += decode_character_string(&array[len], len_value, &test_char_string); ct_test(pTest, apdu_len == len); - diff = memcmp(characterstring_value(&char_string), &test_value[0], + diff = + memcmp(characterstring_value(&char_string), &test_value[0], characterstring_length(&char_string)); ct_test(pTest, diff == 0); for (i = 0; i < MAX_CHARACTER_STRING_BYTES - 1; i++) { @@ -1758,7 +1767,8 @@ void testBACDCodeCharacterString( printf("test string=#%d apdu_len=%d len=%d\n", i, apdu_len, len); } ct_test(pTest, apdu_len == len); - diff = memcmp(characterstring_value(&char_string), &test_value[0], + diff = + memcmp(characterstring_value(&char_string), &test_value[0], characterstring_length(&char_string)); if (diff) { printf("test string=#%d\n", i); @@ -1784,8 +1794,8 @@ void testBACDCodeObject( uint32_t decoded_instance = 0; encode_bacnet_object_id(&encoded_array[0], type, instance); - decode_object_id(&encoded_array[0], - (int *) &decoded_type, &decoded_instance); + decode_object_id(&encoded_array[0], (int *) &decoded_type, + &decoded_instance); ct_test(pTest, decoded_type == type); ct_test(pTest, decoded_instance == instance); encode_bacnet_object_id(&object_array[0], type, instance); @@ -1794,13 +1804,13 @@ void testBACDCodeObject( for (type = 0; type < 1024; type++) { for (instance = 0; instance <= BACNET_MAX_INSTANCE; instance += 1024) { encode_bacnet_object_id(&encoded_array[0], type, instance); - decode_object_id(&encoded_array[0], - (int *) &decoded_type, &decoded_instance); + decode_object_id(&encoded_array[0], (int *) &decoded_type, + &decoded_instance); ct_test(pTest, decoded_type == type); ct_test(pTest, decoded_instance == instance); encode_bacnet_object_id(&object_array[0], type, instance); - ct_test(pTest, memcmp(&object_array[0], - &encoded_array[0], sizeof(object_array)) == 0); + ct_test(pTest, memcmp(&object_array[0], &encoded_array[0], + sizeof(object_array)) == 0); } } diff --git a/bacnet-stack/src/bacerror.c b/bacnet-stack/src/bacerror.c index 6ed22e51..b4c43ac3 100644 --- a/bacnet-stack/src/bacerror.c +++ b/bacnet-stack/src/bacerror.c @@ -74,16 +74,18 @@ int bacerror_decode_error_class_and_code( if (apdu_len) { /* error class */ - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED) return 0; len += decode_enumerated(&apdu[len], len_value_type, &decoded_value); if (error_class) *error_class = (BACNET_ERROR_CLASS) decoded_value; /* error code */ - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED) return 0; len += decode_enumerated(&apdu[len], len_value_type, &decoded_value); @@ -111,8 +113,9 @@ int bacerror_decode_service_request( if (service) *service = (BACNET_CONFIRMED_SERVICE) apdu[1]; /* decode the application class and code */ - len = bacerror_decode_error_class_and_code(&apdu[2], - apdu_len - 2, error_class, error_code); + len = + bacerror_decode_error_class_and_code(&apdu[2], apdu_len - 2, + error_class, error_code); } return len; @@ -141,8 +144,9 @@ int bacerror_decode_apdu( if (apdu[0] != PDU_TYPE_ERROR) return -1; if (apdu_len > 1) { - len = bacerror_decode_service_request(&apdu[1], - apdu_len - 1, invoke_id, service, error_class, error_code); + len = + bacerror_decode_service_request(&apdu[1], apdu_len - 1, + invoke_id, service, error_class, error_code); } } @@ -164,14 +168,15 @@ void testBACError( BACNET_ERROR_CLASS test_error_class = 0; BACNET_ERROR_CODE test_error_code = 0; - len = bacerror_encode_apdu(&apdu[0], - invoke_id, service, error_class, error_code); + len = + bacerror_encode_apdu(&apdu[0], invoke_id, service, error_class, + error_code); ct_test(pTest, len != 0); apdu_len = len; - len = bacerror_decode_apdu(&apdu[0], - apdu_len, - &test_invoke_id, &test_service, &test_error_class, &test_error_code); + len = + bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_service, &test_error_class, &test_error_code); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_service == service); @@ -180,37 +185,37 @@ void testBACError( /* change type to get negative response */ apdu[0] = PDU_TYPE_ABORT; - len = bacerror_decode_apdu(&apdu[0], - apdu_len, - &test_invoke_id, &test_service, &test_error_class, &test_error_code); + len = + bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_service, &test_error_class, &test_error_code); ct_test(pTest, len == -1); /* test NULL APDU */ - len = bacerror_decode_apdu(NULL, - apdu_len, - &test_invoke_id, &test_service, &test_error_class, &test_error_code); + len = + bacerror_decode_apdu(NULL, apdu_len, &test_invoke_id, &test_service, + &test_error_class, &test_error_code); ct_test(pTest, len == -1); /* force a zero length */ - len = bacerror_decode_apdu(&apdu[0], - 0, - &test_invoke_id, &test_service, &test_error_class, &test_error_code); + len = + bacerror_decode_apdu(&apdu[0], 0, &test_invoke_id, &test_service, + &test_error_class, &test_error_code); ct_test(pTest, len == 0); /* check them all... */ for (service = 0; service < MAX_BACNET_CONFIRMED_SERVICE; service++) { - for (error_class = 0; - error_class < MAX_BACNET_ERROR_CLASS; error_class++) { - for (error_code = 0; - error_code < MAX_BACNET_ERROR_CODE; error_code++) { - len = bacerror_encode_apdu(&apdu[0], - invoke_id, service, error_class, error_code); + for (error_class = 0; error_class < MAX_BACNET_ERROR_CLASS; + error_class++) { + for (error_code = 0; error_code < MAX_BACNET_ERROR_CODE; + error_code++) { + len = + bacerror_encode_apdu(&apdu[0], invoke_id, service, + error_class, error_code); apdu_len = len; ct_test(pTest, len != 0); - len = bacerror_decode_apdu(&apdu[0], - apdu_len, - &test_invoke_id, + len = + bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_service, &test_error_class, &test_error_code); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); @@ -225,13 +230,14 @@ void testBACError( service = 255; error_class = LAST_PROPRIETARY_ERROR_CLASS; error_code = LAST_PROPRIETARY_ERROR_CODE; - len = bacerror_encode_apdu(&apdu[0], - invoke_id, service, error_class, error_code); + len = + bacerror_encode_apdu(&apdu[0], invoke_id, service, error_class, + error_code); apdu_len = len; ct_test(pTest, len != 0); - len = bacerror_decode_apdu(&apdu[0], - apdu_len, - &test_invoke_id, &test_service, &test_error_class, &test_error_code); + len = + bacerror_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_service, &test_error_class, &test_error_code); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_service == service); diff --git a/bacnet-stack/src/bacstr.c b/bacnet-stack/src/bacstr.c index 6b492683..6bb96596 100644 --- a/bacnet-stack/src/bacstr.c +++ b/bacnet-stack/src/bacstr.c @@ -229,16 +229,15 @@ bool characterstring_init_ansi( BACNET_CHARACTER_STRING * char_string, char *value) { - return characterstring_init(char_string, - CHARACTER_ANSI_X34, value, value ? strlen(value) : 0); + return characterstring_init(char_string, CHARACTER_ANSI_X34, value, + value ? strlen(value) : 0); } bool characterstring_copy( BACNET_CHARACTER_STRING * dest, BACNET_CHARACTER_STRING * src) { - return characterstring_init(dest, - characterstring_encoding(src), + return characterstring_init(dest, characterstring_encoding(src), characterstring_value(src), characterstring_length(src)); } @@ -429,8 +428,8 @@ bool octetstring_copy( BACNET_OCTET_STRING * dest, BACNET_OCTET_STRING * src) { - return octetstring_init(dest, - octetstring_value(src), octetstring_length(src)); + return octetstring_init(dest, octetstring_value(src), + octetstring_length(src)); } /* returns false if the string exceeds capacity */ @@ -568,9 +567,9 @@ void testCharacterString( ct_test(pTest, characterstring_encoding(&bacnet_string) == CHARACTER_ANSI_X34); /* bounds check */ - status = characterstring_init(&bacnet_string, - CHARACTER_ANSI_X34, - NULL, characterstring_capacity(&bacnet_string) + 1); + status = + characterstring_init(&bacnet_string, CHARACTER_ANSI_X34, NULL, + characterstring_capacity(&bacnet_string) + 1); ct_test(pTest, status == false); status = characterstring_truncate(&bacnet_string, @@ -582,8 +581,9 @@ void testCharacterString( ct_test(pTest, status == true); test_length = strlen(test_value); - status = characterstring_init(&bacnet_string, - CHARACTER_ANSI_X34, &test_value[0], test_length); + status = + characterstring_init(&bacnet_string, CHARACTER_ANSI_X34, + &test_value[0], test_length); ct_test(pTest, status == true); value = characterstring_value(&bacnet_string); length = characterstring_length(&bacnet_string); @@ -592,8 +592,9 @@ void testCharacterString( ct_test(pTest, value[i] == test_value[i]); } test_length = strlen(test_append_value); - status = characterstring_append(&bacnet_string, - &test_append_value[0], test_length); + status = + characterstring_append(&bacnet_string, &test_append_value[0], + test_length); strcat(test_append_string, test_value); strcat(test_append_string, test_append_value); test_length = strlen(test_append_string); @@ -628,10 +629,12 @@ void testOctetString( ct_test(pTest, value[i] == 0); } /* bounds check */ - status = octetstring_init(&bacnet_string, NULL, + status = + octetstring_init(&bacnet_string, NULL, octetstring_capacity(&bacnet_string) + 1); ct_test(pTest, status == false); - status = octetstring_init(&bacnet_string, NULL, + status = + octetstring_init(&bacnet_string, NULL, octetstring_capacity(&bacnet_string)); ct_test(pTest, status == true); status = @@ -654,8 +657,8 @@ void testOctetString( } test_length = strlen((char *) test_append_value); - status = octetstring_append(&bacnet_string, - &test_append_value[0], test_length); + status = + octetstring_append(&bacnet_string, &test_append_value[0], test_length); strcat((char *) test_append_string, (char *) test_value); strcat((char *) test_append_string, (char *) test_append_value); test_length = strlen((char *) test_append_string); diff --git a/bacnet-stack/src/bactext.c b/bacnet-stack/src/bactext.c index c0c86ea1..4609a061 100644 --- a/bacnet-stack/src/bactext.c +++ b/bacnet-stack/src/bactext.c @@ -78,8 +78,8 @@ INDTEXT_DATA bacnet_confirmed_service_names[] = { const char *bactext_confirmed_service_name( int index) { - return indtext_by_index_default(bacnet_confirmed_service_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_confirmed_service_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_unconfirmed_service_names[] = { @@ -110,8 +110,8 @@ INDTEXT_DATA bacnet_unconfirmed_service_names[] = { const char *bactext_unconfirmed_service_name( int index) { - return indtext_by_index_default(bacnet_unconfirmed_service_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_unconfirmed_service_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_application_tag_names[] = { @@ -153,8 +153,8 @@ INDTEXT_DATA bacnet_application_tag_names[] = { const char *bactext_application_tag_name( int index) { - return indtext_by_index_default(bacnet_application_tag_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_application_tag_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_object_type_names[] = { @@ -229,8 +229,8 @@ INDTEXT_DATA bacnet_object_type_names[] = { const char *bactext_object_type_name( int index) { - return indtext_by_index_split_default(bacnet_object_type_names, - index, 128, ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_object_type_names, index, 128, + ASHRAE_Reserved_String, Vendor_Proprietary_String); } INDTEXT_DATA bacnet_property_names[] = { @@ -692,8 +692,8 @@ INDTEXT_DATA bacnet_property_names[] = { const char *bactext_property_name( int index) { - return indtext_by_index_split_default(bacnet_property_names, - index, 512, ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_property_names, index, 512, + ASHRAE_Reserved_String, Vendor_Proprietary_String); } unsigned bactext_property_id( @@ -1099,8 +1099,8 @@ INDTEXT_DATA bacnet_engineering_unit_names[] = { const char *bactext_engineering_unit_name( int index) { - return indtext_by_index_split_default(bacnet_engineering_unit_names, - index, 256, ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_engineering_unit_names, index, + 256, ASHRAE_Reserved_String, Vendor_Proprietary_String); } INDTEXT_DATA bacnet_reject_reason_names[] = { @@ -1131,10 +1131,9 @@ INDTEXT_DATA bacnet_reject_reason_names[] = { const char *bactext_reject_reason_name( int index) { - return indtext_by_index_split_default(bacnet_reject_reason_names, - index, - FIRST_PROPRIETARY_REJECT_REASON, - ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_reject_reason_names, index, + FIRST_PROPRIETARY_REJECT_REASON, ASHRAE_Reserved_String, + Vendor_Proprietary_String); } INDTEXT_DATA bacnet_abort_reason_names[] = { @@ -1155,10 +1154,9 @@ INDTEXT_DATA bacnet_abort_reason_names[] = { const char *bactext_abort_reason_name( int index) { - return indtext_by_index_split_default(bacnet_abort_reason_names, - index, - FIRST_PROPRIETARY_ABORT_REASON, - ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_abort_reason_names, index, + FIRST_PROPRIETARY_ABORT_REASON, ASHRAE_Reserved_String, + Vendor_Proprietary_String); } INDTEXT_DATA bacnet_error_class_names[] = { @@ -1182,10 +1180,9 @@ INDTEXT_DATA bacnet_error_class_names[] = { const char *bactext_error_class_name( int index) { - return indtext_by_index_split_default(bacnet_error_class_names, - index, - FIRST_PROPRIETARY_ERROR_CLASS, - ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_error_class_names, index, + FIRST_PROPRIETARY_ERROR_CLASS, ASHRAE_Reserved_String, + Vendor_Proprietary_String); } INDTEXT_DATA bacnet_error_code_names[] = { @@ -1307,10 +1304,9 @@ INDTEXT_DATA bacnet_error_code_names[] = { const char *bactext_error_code_name( int index) { - return indtext_by_index_split_default(bacnet_error_code_names, - index, - FIRST_PROPRIETARY_ERROR_CLASS, - ASHRAE_Reserved_String, Vendor_Proprietary_String); + return indtext_by_index_split_default(bacnet_error_code_names, index, + FIRST_PROPRIETARY_ERROR_CLASS, ASHRAE_Reserved_String, + Vendor_Proprietary_String); } INDTEXT_DATA bacnet_month_names[] = { @@ -1346,8 +1342,8 @@ INDTEXT_DATA bacnet_month_names[] = { const char *bactext_month_name( int index) { - return indtext_by_index_default(bacnet_month_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_month_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_week_of_month_names[] = { @@ -1371,8 +1367,8 @@ INDTEXT_DATA bacnet_week_of_month_names[] = { const char *bactext_week_of_month_name( int index) { - return indtext_by_index_default(bacnet_week_of_month_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_week_of_month_names, index, + ASHRAE_Reserved_String); } /* note: different than DaysOfWeek bit string where 0=monday */ @@ -1399,8 +1395,8 @@ INDTEXT_DATA bacnet_day_of_week_names[] = { const char *bactext_day_of_week_name( int index) { - return indtext_by_index_default(bacnet_day_of_week_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_day_of_week_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_event_state_names[] = { @@ -1420,8 +1416,8 @@ INDTEXT_DATA bacnet_event_state_names[] = { const char *bactext_event_state_name( int index) { - return indtext_by_index_default(bacnet_event_state_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_event_state_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_binary_present_value_names[] = { @@ -1435,8 +1431,8 @@ INDTEXT_DATA bacnet_binary_present_value_names[] = { const char *bactext_binary_present_value_name( int index) { - return indtext_by_index_default(bacnet_binary_present_value_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_binary_present_value_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_reliability_names[] = { @@ -1468,8 +1464,8 @@ INDTEXT_DATA bacnet_reliability_names[] = { const char *bactext_reliability_name( int index) { - return indtext_by_index_default(bacnet_reliability_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_reliability_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_device_status_names[] = { @@ -1489,8 +1485,8 @@ INDTEXT_DATA bacnet_device_status_names[] = { const char *bactext_device_status_name( int index) { - return indtext_by_index_default(bacnet_device_status_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_device_status_names, index, + ASHRAE_Reserved_String); } INDTEXT_DATA bacnet_segmentation_names[] = { @@ -1508,6 +1504,6 @@ INDTEXT_DATA bacnet_segmentation_names[] = { const char *bactext_segmentation_name( int index) { - return indtext_by_index_default(bacnet_segmentation_names, - index, ASHRAE_Reserved_String); + return indtext_by_index_default(bacnet_segmentation_names, index, + ASHRAE_Reserved_String); } diff --git a/bacnet-stack/src/bip.c b/bacnet-stack/src/bip.c index 32aaf0fc..80210a45 100644 --- a/bacnet-stack/src/bip.c +++ b/bacnet-stack/src/bip.c @@ -163,7 +163,8 @@ int bip_send_pdu( mtu_len += pdu_len; /* Send the packet */ - bytes_sent = sendto(BIP_Socket, (char *) mtu, mtu_len, 0, + bytes_sent = + sendto(BIP_Socket, (char *) mtu, mtu_len, 0, (struct sockaddr *) &bip_dest, sizeof(struct sockaddr)); return bytes_sent; @@ -206,8 +207,9 @@ uint16_t bip_receive( max = BIP_Socket; /* see if there is a packet for us */ if (select(max + 1, &read_fds, NULL, NULL, &select_timeout) > 0) - received_bytes = recvfrom(BIP_Socket, - (char *) &pdu[0], max_pdu, 0, (struct sockaddr *) &sin, &sin_len); + received_bytes = + recvfrom(BIP_Socket, (char *) &pdu[0], max_pdu, 0, + (struct sockaddr *) &sin, &sin_len); else return 0; diff --git a/bacnet-stack/src/bvlc.c b/bacnet-stack/src/bvlc.c index 7caa0492..2819a231 100644 --- a/bacnet-stack/src/bvlc.c +++ b/bacnet-stack/src/bvlc.c @@ -253,9 +253,10 @@ int bvlc_encode_read_bdt_ack( pdu_len = 0; break; } - len = bvlc_encode_address_entry(&pdu[pdu_len], - &BBMD_Table[i].dest_address, - BBMD_Table[i].dest_port, &BBMD_Table[i].broadcast_mask); + len = + bvlc_encode_address_entry(&pdu[pdu_len], + &BBMD_Table[i].dest_address, BBMD_Table[i].dest_port, + &BBMD_Table[i].broadcast_mask); pdu_len += len; } } @@ -375,7 +376,8 @@ int bvlc_encode_read_fdt_ack( pdu_len = 0; break; } - len = bvlc_encode_bip_address(&pdu[pdu_len], + len = + bvlc_encode_bip_address(&pdu[pdu_len], &FD_Table[i].dest_address, FD_Table[i].dest_port); pdu_len += len; encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live); @@ -656,8 +658,8 @@ 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 = - htonl(((~BBMD_Table[i].broadcast_mask.s_addr) | - BBMD_Table[i].dest_address.s_addr)); + htonl(((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i]. + dest_address.s_addr)); bip_dest.sin_port = htons(BBMD_Table[i].dest_port); /* don't send to my broadcast address and same port */ if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr())) @@ -843,9 +845,9 @@ uint16_t bvlc_receive( max = bip_socket(); /* see if there is a packet for us */ if (select(max + 1, &read_fds, NULL, NULL, &select_timeout) > 0) { - received_bytes = recvfrom(bip_socket(), - (char *) &npdu[0], - max_npdu, 0, (struct sockaddr *) &sin, &sin_len); + received_bytes = + recvfrom(bip_socket(), (char *) &npdu[0], max_npdu, 0, + (struct sockaddr *) &sin, &sin_len); } else { return 0; } @@ -1110,7 +1112,8 @@ int bvlc_send_pdu( mtu_len += pdu_len; /* Send the packet */ - bytes_sent = sendto(bip_socket(), (char *) mtu, mtu_len, 0, + bytes_sent = + sendto(bip_socket(), (char *) mtu, mtu_len, 0, (struct sockaddr *) &bvlc_dest, sizeof(struct sockaddr)); return bytes_sent; diff --git a/bacnet-stack/src/cov.c b/bacnet-stack/src/cov.c index a567492f..4fc2ac1a 100644 --- a/bacnet-stack/src/cov.c +++ b/bacnet-stack/src/cov.c @@ -59,16 +59,18 @@ static int notify_encode_adpu( if (apdu) { /* tag 0 - subscriberProcessIdentifier */ - len = encode_context_unsigned(&apdu[apdu_len], - 0, data->subscriberProcessIdentifier); + len = + encode_context_unsigned(&apdu[apdu_len], 0, + data->subscriberProcessIdentifier); apdu_len += len; /* tag 1 - initiatingDeviceIdentifier */ - len = encode_context_object_id(&apdu[apdu_len], - 1, OBJECT_DEVICE, data->initiatingDeviceIdentifier); + len = + encode_context_object_id(&apdu[apdu_len], 1, OBJECT_DEVICE, + data->initiatingDeviceIdentifier); apdu_len += len; /* tag 2 - monitoredObjectIdentifier */ - len = encode_context_object_id(&apdu[apdu_len], - 2, + len = + encode_context_object_id(&apdu[apdu_len], 2, data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.instance); apdu_len += len; @@ -85,27 +87,30 @@ static int notify_encode_adpu( value = &data->listOfValues; while (value != NULL) { /* tag 0 - propertyIdentifier */ - len = encode_context_enumerated(&apdu[apdu_len], - 0, value->propertyIdentifier); + len = + encode_context_enumerated(&apdu[apdu_len], 0, + value->propertyIdentifier); apdu_len += len; /* tag 1 - propertyArrayIndex OPTIONAL */ if (value->propertyArrayIndex != BACNET_ARRAY_ALL) { - len = encode_context_unsigned(&apdu[apdu_len], - 1, value->propertyArrayIndex); + len = + encode_context_unsigned(&apdu[apdu_len], 1, + value->propertyArrayIndex); apdu_len += len; } /* tag 2 - value */ /* abstract syntax gets enclosed in a context tag */ len = encode_opening_tag(&apdu[apdu_len], 2); apdu_len += len; - len = bacapp_encode_application_data(&apdu[apdu_len], - &value->value); + len = + bacapp_encode_application_data(&apdu[apdu_len], &value->value); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 2); apdu_len += len; /* tag 3 - priority OPTIONAL */ if (value->priority != BACNET_NO_PRIORITY) { - len = encode_context_unsigned(&apdu[apdu_len], 3, + len = + encode_context_unsigned(&apdu[apdu_len], 3, value->priority); apdu_len += len; } @@ -248,8 +253,9 @@ int cov_notify_decode_service_request( return -1; /* a tag number of 2 is not extended so only one octet */ len++; - len += bacapp_decode_application_data(&apdu[len], - apdu_len - len, &value->value); + len += + bacapp_decode_application_data(&apdu[len], apdu_len - len, + &value->value); /* FIXME: check the return value; abort if no valid data? */ /* FIXME: there might be more than one data element in here! */ if (!decode_is_closing_tag_number(&apdu[len], 2)) @@ -313,12 +319,13 @@ int cov_subscribe_encode_adpu( apdu[3] = SERVICE_CONFIRMED_SUBSCRIBE_COV; apdu_len = 4; /* tag 0 - subscriberProcessIdentifier */ - len = encode_context_unsigned(&apdu[apdu_len], - 0, data->subscriberProcessIdentifier); + len = + encode_context_unsigned(&apdu[apdu_len], 0, + data->subscriberProcessIdentifier); apdu_len += len; /* tag 1 - monitoredObjectIdentifier */ - len = encode_context_object_id(&apdu[apdu_len], - 1, + len = + encode_context_object_id(&apdu[apdu_len], 1, data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.instance); apdu_len += len; @@ -329,8 +336,9 @@ int cov_subscribe_encode_adpu( */ if (!data->cancellationRequest) { /* tag 2 - issueConfirmedNotifications */ - len = encode_context_boolean(&apdu[apdu_len], - 2, data->issueConfirmedNotifications); + len = + encode_context_boolean(&apdu[apdu_len], 2, + data->issueConfirmedNotifications); apdu_len += len; /* tag 3 - lifetime */ len = encode_context_unsigned(&apdu[apdu_len], 3, data->lifetime); @@ -441,19 +449,21 @@ int cov_subscribe_property_encode_adpu( apdu[3] = SERVICE_CONFIRMED_SUBSCRIBE_COV_PROPERTY; apdu_len = 4; /* tag 0 - subscriberProcessIdentifier */ - len = encode_context_unsigned(&apdu[apdu_len], - 0, data->subscriberProcessIdentifier); + len = + encode_context_unsigned(&apdu[apdu_len], 0, + data->subscriberProcessIdentifier); apdu_len += len; /* tag 1 - monitoredObjectIdentifier */ - len = encode_context_object_id(&apdu[apdu_len], - 1, + len = + encode_context_object_id(&apdu[apdu_len], 1, data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.instance); apdu_len += len; if (!data->cancellationRequest) { /* tag 2 - issueConfirmedNotifications */ - len = encode_context_boolean(&apdu[apdu_len], - 2, data->issueConfirmedNotifications); + len = + encode_context_boolean(&apdu[apdu_len], 2, + data->issueConfirmedNotifications); apdu_len += len; /* tag 3 - lifetime */ len = encode_context_unsigned(&apdu[apdu_len], 3, data->lifetime); @@ -462,12 +472,14 @@ int cov_subscribe_property_encode_adpu( /* tag 4 - monitoredPropertyIdentifier */ len = encode_opening_tag(&apdu[apdu_len], 4); apdu_len += len; - len = encode_context_enumerated(&apdu[apdu_len], - 0, data->monitoredProperty.propertyIdentifier); + len = + encode_context_enumerated(&apdu[apdu_len], 0, + data->monitoredProperty.propertyIdentifier); apdu_len += len; if (data->monitoredProperty.propertyArrayIndex != BACNET_ARRAY_ALL) { - len = encode_context_unsigned(&apdu[apdu_len], - 1, data->monitoredProperty.propertyArrayIndex); + len = + encode_context_unsigned(&apdu[apdu_len], 1, + data->monitoredProperty.propertyArrayIndex); apdu_len += len; } @@ -634,8 +646,8 @@ int ccov_notify_decode_apdu( /* optional limits - must be used as a pair */ if (apdu_len > offset) { len = - cov_notify_decode_service_request(&apdu[offset], - apdu_len - offset, data); + cov_notify_decode_service_request(&apdu[offset], apdu_len - offset, + data); } return len; @@ -660,8 +672,8 @@ int ucov_notify_decode_apdu( offset = 2; if (apdu_len > offset) { len = - cov_notify_decode_service_request(&apdu[offset], - apdu_len - offset, data); + cov_notify_decode_service_request(&apdu[offset], apdu_len - offset, + data); } return len; @@ -830,8 +842,9 @@ void testCCOVNotifyData( apdu_len = len; test_data.listOfValues.next = NULL; - len = ccov_notify_decode_apdu(&apdu[0], apdu_len, - &test_invoke_id, &test_data); + len = + ccov_notify_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_data); ct_test(pTest, len > 0); ct_test(pTest, test_invoke_id == invoke_id); testCOVNotifyData(pTest, data, &test_data); @@ -852,8 +865,8 @@ void testCOVNotify( data.listOfValues.propertyIdentifier = PROP_PRESENT_VALUE; data.listOfValues.propertyArrayIndex = BACNET_ARRAY_ALL; - bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, - "21.0", &data.listOfValues.value); + bacapp_parse_application_data(BACNET_APPLICATION_TAG_REAL, "21.0", + &data.listOfValues.value); data.listOfValues.priority = 0; data.listOfValues.next = NULL; @@ -924,8 +937,9 @@ void testCOVSubscribeEncoding( ct_test(pTest, len != 0); apdu_len = len; - len = cov_subscribe_decode_apdu(&apdu[0], apdu_len, - &test_invoke_id, &test_data); + len = + cov_subscribe_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_data); ct_test(pTest, len > 0); ct_test(pTest, test_invoke_id == invoke_id); testCOVSubscribeData(pTest, data, &test_data); @@ -946,8 +960,9 @@ void testCOVSubscribePropertyEncoding( ct_test(pTest, len != 0); apdu_len = len; - len = cov_subscribe_property_decode_apdu(&apdu[0], apdu_len, - &test_invoke_id, &test_data); + len = + cov_subscribe_property_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_data); ct_test(pTest, len > 0); ct_test(pTest, test_invoke_id == invoke_id); testCOVSubscribePropertyData(pTest, data, &test_data); diff --git a/bacnet-stack/src/datalink.c b/bacnet-stack/src/datalink.c index 66f95ce9..0ebf269f 100644 --- a/bacnet-stack/src/datalink.c +++ b/bacnet-stack/src/datalink.c @@ -43,8 +43,8 @@ int ( uint8_t * pdu, unsigned pdu_len); -uint16_t(*datalink_receive) (BACNET_ADDRESS * src, - uint8_t * pdu, uint16_t max_pdu, unsigned timeout); +uint16_t(*datalink_receive) (BACNET_ADDRESS * src, uint8_t * pdu, + uint16_t max_pdu, unsigned timeout); void ( *datalink_cleanup) ( diff --git a/bacnet-stack/src/datetime.c b/bacnet-stack/src/datetime.c index 490b528e..133244d9 100644 --- a/bacnet-stack/src/datetime.c +++ b/bacnet-stack/src/datetime.c @@ -354,10 +354,12 @@ void datetime_add_minutes( uint32_t days = 0; /* convert bdatetime to seconds and days */ - bdatetime_minutes = seconds_since_midnight(bdatetime->time.hour, - bdatetime->time.min, bdatetime->time.sec) / 60; - bdatetime_days = days_since_epoch(bdatetime->date.year, - bdatetime->date.month, bdatetime->date.day); + bdatetime_minutes = + seconds_since_midnight(bdatetime->time.hour, bdatetime->time.min, + bdatetime->time.sec) / 60; + bdatetime_days = + days_since_epoch(bdatetime->date.year, bdatetime->date.month, + bdatetime->date.day); /* add */ days = minutes / (24 * 60); @@ -370,10 +372,11 @@ void datetime_add_minutes( /* convert bdatetime from seconds and days */ seconds_since_midnight_into_hms(bdatetime_minutes * 60, &bdatetime->time.hour, &bdatetime->time.min, &bdatetime->time.sec); - days_since_epoch_into_ymd(bdatetime_days, - &bdatetime->date.year, &bdatetime->date.month, &bdatetime->date.day); - bdatetime->date.wday = day_of_week(bdatetime->date.year, - bdatetime->date.month, bdatetime->date.day); + days_since_epoch_into_ymd(bdatetime_days, &bdatetime->date.year, + &bdatetime->date.month, &bdatetime->date.day); + bdatetime->date.wday = + day_of_week(bdatetime->date.year, bdatetime->date.month, + bdatetime->date.day); } bool datetime_wildcard( @@ -383,12 +386,9 @@ bool datetime_wildcard( if (bdatetime) { if ((bdatetime->date.year == (1900 + 0xFF)) && - (bdatetime->date.month == 0xFF) && - (bdatetime->date.day == 0xFF) && - (bdatetime->date.wday == 0xFF) && - (bdatetime->time.hour == 0xFF) && - (bdatetime->time.min == 0xFF) && - (bdatetime->time.sec == 0xFF) && + (bdatetime->date.month == 0xFF) && (bdatetime->date.day == 0xFF) && + (bdatetime->date.wday == 0xFF) && (bdatetime->time.hour == 0xFF) && + (bdatetime->time.min == 0xFF) && (bdatetime->time.sec == 0xFF) && (bdatetime->time.hundredths == 0xFF)) { wildcard_present = true; } @@ -494,8 +494,8 @@ void testBACnetDateTimeSeconds( for (minute = 0; minute < 60; minute += 3) { for (second = 0; second < 60; second += 17) { seconds = seconds_since_midnight(hour, minute, second); - seconds_since_midnight_into_hms(seconds, - &test_hour, &test_minute, &test_second); + seconds_since_midnight_into_hms(seconds, &test_hour, + &test_minute, &test_second); test_seconds = seconds_since_midnight(test_hour, test_minute, test_second); @@ -705,8 +705,8 @@ void testDateEpoch( for (month = 1; month <= 12; month++) { for (day = 1; day <= 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/dcc.c b/bacnet-stack/src/dcc.c index 4e4f0310..4504409d 100644 --- a/bacnet-stack/src/dcc.c +++ b/bacnet-stack/src/dcc.c @@ -178,7 +178,8 @@ int dcc_decode_service_request( if (apdu_len) { /* Tag 0: timeDuration --optional-- */ if (decode_is_context_tag(&apdu[len], 0)) { - len += decode_tag_number_and_value(&apdu[len], &tag_number, + len += + decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); len += decode_unsigned(&apdu[len], len_value_type, &value32); if (timeDuration) @@ -188,8 +189,9 @@ int dcc_decode_service_request( /* Tag 1: enable_disable */ if (!decode_is_context_tag(&apdu[len], 1)) return -1; - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += decode_enumerated(&apdu[len], len_value_type, &value); if (enable_disable) *enable_disable = (BACNET_COMMUNICATION_ENABLE_DISABLE) value; @@ -197,8 +199,9 @@ int dcc_decode_service_request( if (len < apdu_len) { if (!decode_is_context_tag(&apdu[len], 2)) return -1; - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += decode_character_string(&apdu[len], len_value_type, password); } else if (password) @@ -236,8 +239,9 @@ int dcc_decode_apdu( offset = 4; if (apdu_len > offset) { - len = dcc_decode_service_request(&apdu[offset], - apdu_len - offset, timeDuration, enable_disable, password); + len = + dcc_decode_service_request(&apdu[offset], apdu_len - offset, + timeDuration, enable_disable, password); } return len; @@ -258,14 +262,14 @@ void test_DeviceCommunicationControlData( BACNET_COMMUNICATION_ENABLE_DISABLE test_enable_disable; BACNET_CHARACTER_STRING test_password; - len = dcc_encode_apdu(&apdu[0], - invoke_id, timeDuration, enable_disable, password); + len = + dcc_encode_apdu(&apdu[0], invoke_id, timeDuration, enable_disable, + password); ct_test(pTest, len != 0); apdu_len = len; - len = dcc_decode_apdu(&apdu[0], - apdu_len, - &test_invoke_id, + len = + dcc_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_timeDuration, &test_enable_disable, &test_password); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); @@ -285,13 +289,13 @@ void test_DeviceCommunicationControl( timeDuration = 0; enable_disable = COMMUNICATION_DISABLE_INITIATION; characterstring_init_ansi(&password, "John 3:16"); - test_DeviceCommunicationControlData(pTest, - invoke_id, timeDuration, enable_disable, &password); + test_DeviceCommunicationControlData(pTest, invoke_id, timeDuration, + enable_disable, &password); timeDuration = 12345; enable_disable = COMMUNICATION_DISABLE; - test_DeviceCommunicationControlData(pTest, - invoke_id, timeDuration, enable_disable, NULL); + test_DeviceCommunicationControlData(pTest, invoke_id, timeDuration, + enable_disable, NULL); return; } diff --git a/bacnet-stack/src/iam.c b/bacnet-stack/src/iam.c index 888c20f7..30b92050 100755 --- a/bacnet-stack/src/iam.c +++ b/bacnet-stack/src/iam.c @@ -56,8 +56,9 @@ int iam_encode_apdu( apdu[0] = PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST; apdu[1] = SERVICE_UNCONFIRMED_I_AM; /* service choice */ apdu_len = 2; - len = encode_application_object_id(&apdu[apdu_len], - OBJECT_DEVICE, device_id); + len = + encode_application_object_id(&apdu[apdu_len], OBJECT_DEVICE, + device_id); apdu_len += len; len = encode_application_unsigned(&apdu[apdu_len], max_apdu); apdu_len += len; @@ -150,8 +151,8 @@ int iam_encode_pdu( npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data); /* encode the APDU portion of the packet */ - len = iam_encode_apdu(&buffer[pdu_len], - Device_Object_Instance_Number(), + len = + iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(), MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier()); pdu_len += len; @@ -199,8 +200,9 @@ int iam_decode_apdu( return -1; if (apdu[1] != SERVICE_UNCONFIRMED_I_AM) return -1; - apdu_len = iam_decode_service_request(&apdu[2], - pDevice_id, pMax_apdu, pSegmentation, pVendor_id); + apdu_len = + iam_decode_service_request(&apdu[2], pDevice_id, pMax_apdu, + pSegmentation, pVendor_id); return apdu_len; } @@ -219,12 +221,14 @@ void testIAm( int test_segmentation = 0; uint16_t test_vendor_id = 0; - len = iam_encode_apdu(&apdu[0], - device_id, max_apdu, segmentation, vendor_id); + len = + iam_encode_apdu(&apdu[0], device_id, max_apdu, segmentation, + vendor_id); ct_test(pTest, len != 0); - len = iam_decode_apdu(&apdu[0], - &test_device_id, &test_max_apdu, &test_segmentation, &test_vendor_id); + len = + iam_decode_apdu(&apdu[0], &test_device_id, &test_max_apdu, + &test_segmentation, &test_vendor_id); ct_test(pTest, len != -1); ct_test(pTest, test_device_id == device_id); diff --git a/bacnet-stack/src/ihave.c b/bacnet-stack/src/ihave.c index 673bd2ed..cad91d67 100644 --- a/bacnet-stack/src/ihave.c +++ b/bacnet-stack/src/ihave.c @@ -49,15 +49,18 @@ int ihave_encode_apdu( apdu[1] = SERVICE_UNCONFIRMED_I_HAVE; apdu_len = 2; /* deviceIdentifier */ - len = encode_application_object_id(&apdu[apdu_len], - data->device_id.type, data->device_id.instance); + len = + encode_application_object_id(&apdu[apdu_len], data->device_id.type, + data->device_id.instance); apdu_len += len; /* objectIdentifier */ - len = encode_application_object_id(&apdu[apdu_len], - data->object_id.type, data->object_id.instance); + len = + encode_application_object_id(&apdu[apdu_len], data->object_id.type, + data->object_id.instance); apdu_len += len; /* objectName */ - len = encode_application_character_string(&apdu[apdu_len], + len = + encode_application_character_string(&apdu[apdu_len], &data->object_name); apdu_len += len; } @@ -81,7 +84,8 @@ int ihave_decode_service_request( len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); if (tag_number == BACNET_APPLICATION_TAG_OBJECT_ID) { - len += decode_object_id(&apdu[len], &decoded_type, + len += + decode_object_id(&apdu[len], &decoded_type, &data->device_id.instance); data->device_id.type = decoded_type; } else @@ -90,7 +94,8 @@ int ihave_decode_service_request( len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); if (tag_number == BACNET_APPLICATION_TAG_OBJECT_ID) { - len += decode_object_id(&apdu[len], &decoded_type, + len += + decode_object_id(&apdu[len], &decoded_type, &data->object_id.instance); data->object_id.type = decoded_type; } else @@ -99,7 +104,8 @@ int ihave_decode_service_request( len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); if (tag_number == BACNET_APPLICATION_TAG_CHARACTER_STRING) { - len += decode_character_string(&apdu[len], len_value, + len += + decode_character_string(&apdu[len], len_value, &data->object_name); } else return -1; diff --git a/bacnet-stack/src/keylist.c b/bacnet-stack/src/keylist.c index b5f09675..77ac9b95 100644 --- a/bacnet-stack/src/keylist.c +++ b/bacnet-stack/src/keylist.c @@ -224,8 +224,8 @@ void *Keylist_Data_Delete_By_Index( struct Keylist_Node *node; void *data = NULL; - if (list && list->array && list->count && - (index >= 0) && (index < list->count)) { + if (list && list->array && list->count && (index >= 0) && + (index < list->count)) { node = list->array[index]; if (node) data = node->data; @@ -314,8 +314,8 @@ void *Keylist_Data_Index( { struct Keylist_Node *node = NULL; - if (list && list->array && list->count && - (index >= 0) && (index < list->count)) + if (list && list->array && list->count && (index >= 0) && + (index < list->count)) node = list->array[index]; return node ? node->data : NULL; @@ -329,8 +329,8 @@ KEY Keylist_Key( KEY key = 0; /* return value */ struct Keylist_Node *node; - if (list && list->array && list->count && - (index >= 0) && (index < list->count)) { + if (list && list->array && list->count && (index >= 0) && + (index < list->count)) { node = list->array[index]; if (node) key = node->key; diff --git a/bacnet-stack/src/mstptext.c b/bacnet-stack/src/mstptext.c index 465cbac2..4ec58ea7 100644 --- a/bacnet-stack/src/mstptext.c +++ b/bacnet-stack/src/mstptext.c @@ -53,6 +53,6 @@ static INDTEXT_DATA mstp_frame_type_text[] = { const char *mstptext_frame_type( int index) { - return indtext_by_index_split_default(mstp_frame_type_text, - index, FRAME_TYPE_PROPRIETARY_MIN, "UNKNOWN", "PROPRIETARY"); + return indtext_by_index_split_default(mstp_frame_type_text, index, + FRAME_TYPE_PROPRIETARY_MIN, "UNKNOWN", "PROPRIETARY"); } diff --git a/bacnet-stack/src/rd.c b/bacnet-stack/src/rd.c index 43fa9d25..a1ee575c 100644 --- a/bacnet-stack/src/rd.c +++ b/bacnet-stack/src/rd.c @@ -58,8 +58,8 @@ int rd_encode_apdu( /* optional password */ if (password) { /* FIXME: must be at least 1 character, limited to 20 characters */ - len = encode_context_character_string(&apdu[apdu_len], 1, - password); + len = + encode_context_character_string(&apdu[apdu_len], 1, password); apdu_len += len; } } @@ -84,8 +84,9 @@ int rd_decode_service_request( /* Tag 0: reinitializedStateOfDevice */ if (!decode_is_context_tag(&apdu[len], 0)) return -1; - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += decode_enumerated(&apdu[len], len_value_type, &value); if (state) *state = (BACNET_REINITIALIZED_STATE) value; @@ -93,8 +94,9 @@ int rd_decode_service_request( if (len < apdu_len) { if (!decode_is_context_tag(&apdu[len], 1)) return -1; - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); len += decode_character_string(&apdu[len], len_value_type, password); } @@ -130,8 +132,9 @@ int rd_decode_apdu( offset = 4; if (apdu_len > offset) { - len = rd_decode_service_request(&apdu[offset], - apdu_len - offset, state, password); + len = + rd_decode_service_request(&apdu[offset], apdu_len - offset, state, + password); } return len; @@ -156,8 +159,9 @@ void test_ReinitializeDevice( ct_test(pTest, len != 0); apdu_len = len; - len = rd_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_state, &test_password); + len = + rd_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_state, + &test_password); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_state == state); diff --git a/bacnet-stack/src/reject.c b/bacnet-stack/src/reject.c index be7ba9e4..ea88fc67 100644 --- a/bacnet-stack/src/reject.c +++ b/bacnet-stack/src/reject.c @@ -94,8 +94,9 @@ int reject_decode_apdu( if (apdu[0] != PDU_TYPE_REJECT) return -1; if (apdu_len > 1) { - len = reject_decode_service_request(&apdu[1], - apdu_len - 1, invoke_id, reject_reason); + len = + reject_decode_service_request(&apdu[1], apdu_len - 1, + invoke_id, reject_reason); } } @@ -117,26 +118,29 @@ void testReject( ct_test(pTest, len != 0); apdu_len = len; - len = reject_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_reject_reason); + len = + reject_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_reject_reason); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_reject_reason == reject_reason); /* change type to get negative response */ apdu[0] = PDU_TYPE_ABORT; - len = reject_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_reject_reason); + len = + reject_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_reject_reason); ct_test(pTest, len == -1); /* test NULL APDU */ - len = reject_decode_apdu(NULL, - apdu_len, &test_invoke_id, &test_reject_reason); + len = + reject_decode_apdu(NULL, apdu_len, &test_invoke_id, + &test_reject_reason); ct_test(pTest, len == -1); /* force a zero length */ - len = reject_decode_apdu(&apdu[0], - 0, &test_invoke_id, &test_reject_reason); + len = + reject_decode_apdu(&apdu[0], 0, &test_invoke_id, &test_reject_reason); ct_test(pTest, len == 0); @@ -146,8 +150,9 @@ void testReject( len = reject_encode_apdu(&apdu[0], invoke_id, reject_reason); apdu_len = len; ct_test(pTest, len != 0); - len = reject_decode_apdu(&apdu[0], - apdu_len, &test_invoke_id, &test_reject_reason); + len = + reject_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_reject_reason); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_reject_reason == reject_reason); diff --git a/bacnet-stack/src/rp.c b/bacnet-stack/src/rp.c index f4b38c8e..8e0a8ce9 100644 --- a/bacnet-stack/src/rp.c +++ b/bacnet-stack/src/rp.c @@ -52,15 +52,18 @@ int rp_encode_apdu( apdu[2] = invoke_id; apdu[3] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */ apdu_len = 4; - len = encode_context_object_id(&apdu[apdu_len], 0, - rpdata->object_type, rpdata->object_instance); + len = + encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type, + rpdata->object_instance); apdu_len += len; - len = encode_context_enumerated(&apdu[apdu_len], 1, + len = + encode_context_enumerated(&apdu[apdu_len], 1, rpdata->object_property); apdu_len += len; /* optional array index */ if (rpdata->array_index != BACNET_ARRAY_ALL) { - len = encode_context_unsigned(&apdu[apdu_len], 2, + len = + encode_context_unsigned(&apdu[apdu_len], 2, rpdata->array_index); apdu_len += len; } @@ -90,19 +93,21 @@ int rp_decode_service_request( len += decode_object_id(&apdu[len], &type, &rpdata->object_instance); rpdata->object_type = (BACNET_OBJECT_TYPE) type; /* Tag 1: Property ID */ - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number != 1) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); rpdata->object_property = (BACNET_PROPERTY_ID) property; /* Tag 2: Optional Array Index */ if (len < apdu_len) { - len += decode_tag_number_and_value(&apdu[len], &tag_number, + len += + decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number == 2) { - len += decode_unsigned(&apdu[len], len_value_type, - &array_value); + len += + decode_unsigned(&apdu[len], len_value_type, &array_value); rpdata->array_index = array_value; } else rpdata->array_index = BACNET_ARRAY_ALL; @@ -127,13 +132,16 @@ int rp_ack_encode_apdu( apdu[2] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */ apdu_len = 3; /* service ack follows */ - apdu_len += encode_context_object_id(&apdu[apdu_len], 0, - rpdata->object_type, rpdata->object_instance); - apdu_len += encode_context_enumerated(&apdu[apdu_len], 1, + apdu_len += + encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type, + rpdata->object_instance); + apdu_len += + encode_context_enumerated(&apdu[apdu_len], 1, rpdata->object_property); /* context 2 array index is optional */ if (rpdata->array_index != BACNET_ARRAY_ALL) { - apdu_len += encode_context_unsigned(&apdu[apdu_len], 2, + apdu_len += + encode_context_unsigned(&apdu[apdu_len], 2, rpdata->array_index); } /* propertyValue */ @@ -167,15 +175,15 @@ int rp_ack_decode_service_request( len += decode_object_id(&apdu[len], &object, &rpdata->object_instance); rpdata->object_type = (BACNET_OBJECT_TYPE) object; /* Tag 1: Property ID */ - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number != 1) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); rpdata->object_property = (BACNET_PROPERTY_ID) property; /* Tag 2: Optional Array Index */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number == 2) { len += tag_len; len += decode_unsigned(&apdu[len], len_value_type, &array_value); @@ -221,8 +229,9 @@ int rp_decode_apdu( offset = 4; if (apdu_len > offset) { - len = rp_decode_service_request(&apdu[offset], - apdu_len - offset, rpdata); + len = + rp_decode_service_request(&apdu[offset], apdu_len - offset, + rpdata); } return len; @@ -247,8 +256,9 @@ int rp_ack_decode_apdu( return -1; offset = 3; if (apdu_len > offset) { - len = rp_ack_decode_service_request(&apdu[offset], - apdu_len - offset, rpdata); + len = + rp_ack_decode_service_request(&apdu[offset], apdu_len - offset, + rpdata); } return len; @@ -274,8 +284,9 @@ void testReadPropertyAck( rpdata.object_property = PROP_OBJECT_IDENTIFIER; rpdata.array_index = BACNET_ARRAY_ALL; - rpdata.application_data_len = encode_bacnet_object_id(&apdu2[0], - rpdata.object_type, rpdata.object_instance); + rpdata.application_data_len = + encode_bacnet_object_id(&apdu2[0], rpdata.object_type, + rpdata.object_instance); rpdata.application_data = &apdu2[0]; len = rp_ack_encode_apdu(&apdu[0], invoke_id, &rpdata); @@ -296,8 +307,9 @@ void testReadPropertyAck( /* since object property == object_id, decode the application data using the appropriate decode function */ - len = decode_object_id(test_data.application_data, - &object, &object_instance); + len = + decode_object_id(test_data.application_data, &object, + &object_instance); object_type = object; ct_test(pTest, object_type == rpdata.object_type); ct_test(pTest, object_instance == rpdata.object_instance); diff --git a/bacnet-stack/src/rpm.c b/bacnet-stack/src/rpm.c index 687f62bb..b208be76 100644 --- a/bacnet-stack/src/rpm.c +++ b/bacnet-stack/src/rpm.c @@ -65,8 +65,9 @@ int rpm_encode_apdu_object_begin( 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 ReadAccessSpecification */ apdu_len += encode_opening_tag(&apdu[apdu_len], 1); } @@ -85,8 +86,8 @@ int rpm_encode_apdu_object_property( apdu_len = encode_context_enumerated(&apdu[0], 0, object_property); /* optional array index */ if (array_index != BACNET_ARRAY_ALL) - apdu_len += encode_context_unsigned(&apdu[apdu_len], 1, - array_index); + apdu_len += + encode_context_unsigned(&apdu[apdu_len], 1, array_index); } return apdu_len; @@ -171,24 +172,24 @@ int rpm_decode_object_property( /* Tag 0: propertyIdentifier */ if (!decode_is_context_specific(&apdu[len])) return -1; - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number != 0) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); if (object_property) *object_property = (BACNET_PROPERTY_ID) property; /* Tag 1: Optional propertyArrayIndex */ - if ((len < apdu_len) && - decode_is_context_specific(&apdu[len]) && + if ((len < apdu_len) && decode_is_context_specific(&apdu[len]) && (!decode_is_closing_tag(&apdu[len]))) { option_len = decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number == 1) { len += option_len; - len += decode_unsigned(&apdu[len], len_value_type, - &array_value); + len += + decode_unsigned(&apdu[len], len_value_type, &array_value); *array_index = array_value; } else *array_index = BACNET_ARRAY_ALL; @@ -224,8 +225,9 @@ int rpm_ack_encode_apdu_object_begin( if (apdu) { /* Tag 0: objectIdentifier */ - 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: listOfResults */ apdu_len += encode_opening_tag(&apdu[apdu_len], 1); } @@ -245,8 +247,8 @@ int rpm_ack_encode_apdu_object_property( apdu_len = encode_context_enumerated(&apdu[0], 2, object_property); /* Tag 3: optional propertyArrayIndex */ if (array_index != BACNET_ARRAY_ALL) - apdu_len += encode_context_unsigned(&apdu[apdu_len], 3, - array_index); + apdu_len += + encode_context_unsigned(&apdu[apdu_len], 3, array_index); } return apdu_len; @@ -363,23 +365,24 @@ int rpm_ack_decode_object_property( /* Tag 2: propertyIdentifier */ if (!decode_is_context_specific(&apdu[len])) return -1; - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number != 2) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); if (object_property) *object_property = (BACNET_PROPERTY_ID) property; /* Tag 3: Optional propertyArrayIndex */ - if ((len < apdu_len) && - decode_is_context_specific(&apdu[len]) && + if ((len < apdu_len) && decode_is_context_specific(&apdu[len]) && (!decode_is_closing_tag(&apdu[len]))) { - tag_len = decode_tag_number_and_value(&apdu[len], &tag_number, + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); if (tag_number == 3) { len += tag_len; - len += decode_unsigned(&apdu[len], len_value_type, - &array_value); + len += + decode_unsigned(&apdu[len], len_value_type, &array_value); *array_index = array_value; } else { *array_index = BACNET_ARRAY_ALL; @@ -479,21 +482,25 @@ void testReadPropertyMultiple( Also check case of storing a backoff point (i.e. save enough room for object_end) */ apdu_len = rpm_encode_apdu_init(&apdu[0], invoke_id); /* each object has a beginning and an end */ - apdu_len += rpm_encode_apdu_object_begin(&apdu[apdu_len], - OBJECT_DEVICE, 123); + apdu_len += + rpm_encode_apdu_object_begin(&apdu[apdu_len], OBJECT_DEVICE, 123); /* then stuff as many properties into it as APDU length will allow */ - apdu_len += rpm_encode_apdu_object_property(&apdu[apdu_len], + apdu_len += + rpm_encode_apdu_object_property(&apdu[apdu_len], PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL); - apdu_len += rpm_encode_apdu_object_property(&apdu[apdu_len], - PROP_OBJECT_NAME, BACNET_ARRAY_ALL); + apdu_len += + rpm_encode_apdu_object_property(&apdu[apdu_len], PROP_OBJECT_NAME, + BACNET_ARRAY_ALL); apdu_len += rpm_encode_apdu_object_end(&apdu[apdu_len]); /* each object has a beginning and an end */ - apdu_len += rpm_encode_apdu_object_begin(&apdu[apdu_len], - OBJECT_ANALOG_INPUT, 33); - apdu_len += rpm_encode_apdu_object_property(&apdu[apdu_len], + apdu_len += + rpm_encode_apdu_object_begin(&apdu[apdu_len], OBJECT_ANALOG_INPUT, 33); + apdu_len += + rpm_encode_apdu_object_property(&apdu[apdu_len], PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL); - apdu_len += rpm_encode_apdu_object_property(&apdu[apdu_len], - PROP_ALL, BACNET_ARRAY_ALL); + apdu_len += + rpm_encode_apdu_object_property(&apdu[apdu_len], PROP_ALL, + BACNET_ARRAY_ALL); apdu_len += rpm_encode_apdu_object_end(&apdu[apdu_len]); ct_test(pTest, apdu_len != 0); @@ -505,59 +512,69 @@ void testReadPropertyMultiple( ct_test(pTest, service_request != NULL); ct_test(pTest, service_request_len > 0); - test_len = rpm_decode_object_id(service_request, - service_request_len, &object_type, &object_instance); + test_len = + rpm_decode_object_id(service_request, service_request_len, + &object_type, &object_instance); ct_test(pTest, test_len != -1); ct_test(pTest, object_type == OBJECT_DEVICE); ct_test(pTest, object_instance == 123); len = test_len; /* decode the object property portion of the service request */ - test_len = rpm_decode_object_property(&service_request[len], + test_len = + rpm_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_OBJECT_IDENTIFIER); ct_test(pTest, array_index == BACNET_ARRAY_ALL); len += test_len; - test_len = rpm_decode_object_property(&service_request[len], + test_len = + rpm_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_OBJECT_NAME); ct_test(pTest, array_index == BACNET_ARRAY_ALL); len += test_len; /* try again - we should fail */ - test_len = rpm_decode_object_property(&service_request[len], + test_len = + rpm_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len == -1); /* is it the end of this object? */ - test_len = rpm_decode_object_end(&service_request[len], + test_len = + rpm_decode_object_end(&service_request[len], service_request_len - len); ct_test(pTest, test_len == 1); len += test_len; /* try to decode an object id */ - test_len = rpm_decode_object_id(&service_request[len], - service_request_len - len, &object_type, &object_instance); + test_len = + rpm_decode_object_id(&service_request[len], service_request_len - len, + &object_type, &object_instance); ct_test(pTest, test_len != -1); ct_test(pTest, object_type == OBJECT_ANALOG_INPUT); ct_test(pTest, object_instance == 33); len += test_len; /* decode the object property portion of the service request only */ - test_len = rpm_decode_object_property(&service_request[len], + test_len = + rpm_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_OBJECT_IDENTIFIER); ct_test(pTest, array_index == BACNET_ARRAY_ALL); len += test_len; - test_len = rpm_decode_object_property(&service_request[len], + test_len = + rpm_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_ALL); ct_test(pTest, array_index == BACNET_ARRAY_ALL); len += test_len; - test_len = rpm_decode_object_property(&service_request[len], + test_len = + rpm_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len == -1); /* got an error -1, is it the end of this object? */ - test_len = rpm_decode_object_end(&service_request[len], + test_len = + rpm_decode_object_end(&service_request[len], service_request_len - len); ct_test(pTest, test_len == 1); len += test_len; @@ -598,10 +615,11 @@ void testReadPropertyMultipleAck( apdu_len = rpm_ack_encode_apdu_init(&apdu[0], invoke_id); /* object beginning */ - apdu_len += rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], - OBJECT_DEVICE, 123); + apdu_len += + rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], OBJECT_DEVICE, 123); /* reply property */ - apdu_len += rpm_ack_encode_apdu_object_property(&apdu[apdu_len], + apdu_len += + rpm_ack_encode_apdu_object_property(&apdu[apdu_len], PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL); /* reply value */ application_data[0].tag = BACNET_APPLICATION_TAG_OBJECT_ID; @@ -614,8 +632,9 @@ void testReadPropertyMultipleAck( rpm_ack_encode_apdu_object_property_value(&apdu[apdu_len], &application_data_buffer[0], application_data_buffer_len); /* reply property */ - apdu_len += rpm_ack_encode_apdu_object_property(&apdu[apdu_len], - PROP_OBJECT_TYPE, BACNET_ARRAY_ALL); + apdu_len += + rpm_ack_encode_apdu_object_property(&apdu[apdu_len], PROP_OBJECT_TYPE, + BACNET_ARRAY_ALL); /* reply value */ application_data[1].tag = BACNET_APPLICATION_TAG_ENUMERATED; application_data[1].type.Enumerated = OBJECT_DEVICE; @@ -629,10 +648,12 @@ void testReadPropertyMultipleAck( apdu_len += rpm_ack_encode_apdu_object_end(&apdu[apdu_len]); /* object beginning */ - apdu_len += rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], - OBJECT_ANALOG_INPUT, 33); + apdu_len += + rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], OBJECT_ANALOG_INPUT, + 33); /* reply property */ - apdu_len += rpm_ack_encode_apdu_object_property(&apdu[apdu_len], + apdu_len += + rpm_ack_encode_apdu_object_property(&apdu[apdu_len], PROP_PRESENT_VALUE, BACNET_ARRAY_ALL); /* reply value */ application_data[2].tag = BACNET_APPLICATION_TAG_REAL; @@ -644,10 +665,12 @@ void testReadPropertyMultipleAck( rpm_ack_encode_apdu_object_property_value(&apdu[apdu_len], &application_data_buffer[0], application_data_buffer_len); /* reply property */ - apdu_len += rpm_ack_encode_apdu_object_property(&apdu[apdu_len], - PROP_DEADBAND, BACNET_ARRAY_ALL); + apdu_len += + rpm_ack_encode_apdu_object_property(&apdu[apdu_len], PROP_DEADBAND, + BACNET_ARRAY_ALL); /* reply error */ - apdu_len += rpm_ack_encode_apdu_object_property_error(&apdu[apdu_len], + apdu_len += + rpm_ack_encode_apdu_object_property_error(&apdu[apdu_len], ERROR_CLASS_PROPERTY, ERROR_CODE_UNKNOWN_PROPERTY); /* object end */ apdu_len += rpm_ack_encode_apdu_object_end(&apdu[apdu_len]); @@ -661,14 +684,16 @@ void testReadPropertyMultipleAck( ct_test(pTest, service_request != NULL); ct_test(pTest, service_request_len > 0); /* the first part should be the first object id */ - test_len = rpm_ack_decode_object_id(service_request, - service_request_len, &object_type, &object_instance); + test_len = + rpm_ack_decode_object_id(service_request, service_request_len, + &object_type, &object_instance); ct_test(pTest, test_len != -1); ct_test(pTest, object_type == OBJECT_DEVICE); ct_test(pTest, object_instance == 123); len = test_len; /* extract the property */ - test_len = rpm_ack_decode_object_property(&service_request[len], + test_len = + rpm_ack_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, object_property == PROP_OBJECT_IDENTIFIER); ct_test(pTest, array_index == BACNET_ARRAY_ALL); @@ -679,7 +704,8 @@ void testReadPropertyMultipleAck( /* decode the object property portion of the service request */ /* note: if this was an array, there could have been more than one element to decode */ - test_len = bacapp_decode_application_data(&service_request[len], + test_len = + bacapp_decode_application_data(&service_request[len], service_request_len - len, &test_application_data); ct_test(pTest, test_len > 0); ct_test(pTest, bacapp_same_value(&application_data[0], @@ -688,7 +714,8 @@ void testReadPropertyMultipleAck( ct_test(pTest, decode_is_closing_tag_number(&service_request[len], 4)); len++; /* see if there is another property */ - test_len = rpm_ack_decode_object_property(&service_request[len], + test_len = + rpm_ack_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_OBJECT_TYPE); @@ -698,7 +725,8 @@ void testReadPropertyMultipleAck( ct_test(pTest, decode_is_opening_tag_number(&service_request[len], 4)); len++; /* decode the object property portion of the service request */ - test_len = bacapp_decode_application_data(&service_request[len], + test_len = + bacapp_decode_application_data(&service_request[len], service_request_len - len, &test_application_data); ct_test(pTest, test_len > 0); ct_test(pTest, bacapp_same_value(&application_data[1], @@ -708,23 +736,27 @@ void testReadPropertyMultipleAck( len++; /* see if there is another property */ /* this time we should fail */ - test_len = rpm_ack_decode_object_property(&service_request[len], + test_len = + rpm_ack_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len == -1); /* see if it is the end of this object */ - test_len = rpm_ack_decode_object_end(&service_request[len], + test_len = + rpm_ack_decode_object_end(&service_request[len], service_request_len - len); ct_test(pTest, test_len == 1); len += test_len; /* try to decode another object id */ - test_len = rpm_ack_decode_object_id(&service_request[len], + test_len = + rpm_ack_decode_object_id(&service_request[len], service_request_len - len, &object_type, &object_instance); ct_test(pTest, test_len != -1); ct_test(pTest, object_type == OBJECT_ANALOG_INPUT); ct_test(pTest, object_instance == 33); len += test_len; /* decode the object property portion of the service request only */ - test_len = rpm_ack_decode_object_property(&service_request[len], + test_len = + rpm_ack_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_PRESENT_VALUE); @@ -734,7 +766,8 @@ void testReadPropertyMultipleAck( ct_test(pTest, decode_is_opening_tag_number(&service_request[len], 4)); len++; /* decode the object property portion of the service request */ - test_len = bacapp_decode_application_data(&service_request[len], + test_len = + bacapp_decode_application_data(&service_request[len], service_request_len - len, &test_application_data); ct_test(pTest, test_len > 0); ct_test(pTest, bacapp_same_value(&application_data[2], @@ -743,7 +776,8 @@ void testReadPropertyMultipleAck( ct_test(pTest, decode_is_closing_tag_number(&service_request[len], 4)); len++; /* see if there is another property */ - test_len = rpm_ack_decode_object_property(&service_request[len], + test_len = + rpm_ack_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len != -1); ct_test(pTest, object_property == PROP_DEADBAND); @@ -753,7 +787,8 @@ void testReadPropertyMultipleAck( ct_test(pTest, decode_is_opening_tag_number(&service_request[len], 5)); len++; /* it was an error reply */ - test_len = bacerror_decode_error_class_and_code(&service_request[len], + test_len = + bacerror_decode_error_class_and_code(&service_request[len], service_request_len - len, &error_class, &error_code); ct_test(pTest, test_len != 0); ct_test(pTest, error_class == ERROR_CLASS_PROPERTY); @@ -762,16 +797,19 @@ void testReadPropertyMultipleAck( ct_test(pTest, decode_is_closing_tag_number(&service_request[len], 5)); len++; /* is there another property? */ - test_len = rpm_ack_decode_object_property(&service_request[len], + test_len = + rpm_ack_decode_object_property(&service_request[len], service_request_len - len, &object_property, &array_index); ct_test(pTest, test_len == -1); /* got an error -1, is it the end of this object? */ - test_len = rpm_ack_decode_object_end(&service_request[len], + test_len = + rpm_ack_decode_object_end(&service_request[len], service_request_len - len); ct_test(pTest, test_len == 1); len += test_len; /* check for another object */ - test_len = rpm_ack_decode_object_id(&service_request[len], + test_len = + rpm_ack_decode_object_id(&service_request[len], service_request_len - len, &object_type, &object_instance); ct_test(pTest, test_len == 0); ct_test(pTest, len == service_request_len); diff --git a/bacnet-stack/src/timesync.c b/bacnet-stack/src/timesync.c index 1760ef47..92caca59 100644 --- a/bacnet-stack/src/timesync.c +++ b/bacnet-stack/src/timesync.c @@ -133,8 +133,9 @@ int timesync_decode_apdu_service( return -1; /* optional limits - must be used as a pair */ if (apdu_len > 2) { - len = timesync_decode_service_request(&apdu[2], apdu_len - 2, - my_date, my_time); + len = + timesync_decode_service_request(&apdu[2], apdu_len - 2, my_date, + my_time); } return len; @@ -147,8 +148,8 @@ int timesync_utc_decode_apdu( BACNET_TIME * my_time) { return timesync_decode_apdu_service(apdu, - SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, - apdu_len, my_date, my_time); + SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, apdu_len, my_date, + my_time); } int timesync_decode_apdu( diff --git a/bacnet-stack/src/tsm.c b/bacnet-stack/src/tsm.c index ba8edcb9..8e2820a9 100644 --- a/bacnet-stack/src/tsm.c +++ b/bacnet-stack/src/tsm.c @@ -256,9 +256,10 @@ void tsm_timer_milliseconds( TSM_List[i].RetryCount--; TSM_List[i].RequestTimer = Device_APDU_Timeout(); if (TSM_List[i].RetryCount) { - bytes_sent = datalink_send_pdu(&TSM_List[i].dest, - &TSM_List[i].npdu_data, - &TSM_List[i].apdu[0], TSM_List[i].apdu_len); + bytes_sent = + datalink_send_pdu(&TSM_List[i].dest, + &TSM_List[i].npdu_data, &TSM_List[i].apdu[0], + TSM_List[i].apdu_len); } else { /* note: the invoke id has not been cleared yet and this indicates a failed message: diff --git a/bacnet-stack/src/whohas.c b/bacnet-stack/src/whohas.c index 2a13efaf..0e34be17 100644 --- a/bacnet-stack/src/whohas.c +++ b/bacnet-stack/src/whohas.c @@ -57,17 +57,18 @@ int whohas_encode_apdu( && (data->high_limit <= BACNET_MAX_INSTANCE)) { len = encode_context_unsigned(&apdu[apdu_len], 0, data->low_limit); apdu_len += len; - len = encode_context_unsigned(&apdu[apdu_len], - 1, data->high_limit); + len = + encode_context_unsigned(&apdu[apdu_len], 1, data->high_limit); apdu_len += len; } if (data->object_name) { - len = encode_context_character_string(&apdu[apdu_len], - 3, &data->object.name); + len = + encode_context_character_string(&apdu[apdu_len], 3, + &data->object.name); apdu_len += len; } else { - len = encode_context_object_id(&apdu[apdu_len], - 2, + len = + encode_context_object_id(&apdu[apdu_len], 2, data->object.identifier.type, data->object.identifier.instance); apdu_len += len; @@ -186,9 +187,10 @@ void testWhoHasData( ct_test(pTest, test_data.object_name == data->object_name); /* Object ID */ if (data->object_name == false) { - ct_test(pTest, test_data.object.identifier.type == - data->object.identifier.type); - ct_test(pTest, test_data.object.identifier.instance == + ct_test(pTest, + test_data.object.identifier.type == data->object.identifier.type); + ct_test(pTest, + test_data.object.identifier.instance == data->object.identifier.instance); } /* Object Name */ @@ -210,11 +212,9 @@ void testWhoHas( data.object.identifier.instance = 1; testWhoHasData(pTest, &data); - for (data.low_limit = 0; - data.low_limit <= BACNET_MAX_INSTANCE; + for (data.low_limit = 0; data.low_limit <= BACNET_MAX_INSTANCE; data.low_limit += (BACNET_MAX_INSTANCE / 4)) { - for (data.high_limit = 0; - data.high_limit <= BACNET_MAX_INSTANCE; + for (data.high_limit = 0; data.high_limit <= BACNET_MAX_INSTANCE; data.high_limit += (BACNET_MAX_INSTANCE / 4)) { data.object_name = false; for (data.object.identifier.type = OBJECT_ANALOG_INPUT; diff --git a/bacnet-stack/src/whois.c b/bacnet-stack/src/whois.c index 0b6107f5..c5534471 100644 --- a/bacnet-stack/src/whois.c +++ b/bacnet-stack/src/whois.c @@ -121,8 +121,9 @@ int whois_decode_apdu( return -1; /* optional limits - must be used as a pair */ if (apdu_len > 2) { - len = whois_decode_service_request(&apdu[2], - apdu_len - 2, pLow_limit, pHigh_limit); + len = + whois_decode_service_request(&apdu[2], apdu_len - 2, pLow_limit, + pHigh_limit); } return len; @@ -143,23 +144,23 @@ void testWhoIs( ct_test(pTest, len != 0); apdu_len = len; - len = whois_decode_apdu(&apdu[0], - apdu_len, &test_low_limit, &test_high_limit); + len = + whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, + &test_high_limit); ct_test(pTest, len != -1); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); - for (low_limit = 0; - low_limit <= BACNET_MAX_INSTANCE; + for (low_limit = 0; low_limit <= BACNET_MAX_INSTANCE; low_limit += (BACNET_MAX_INSTANCE / 4)) { - for (high_limit = 0; - high_limit <= BACNET_MAX_INSTANCE; + for (high_limit = 0; high_limit <= BACNET_MAX_INSTANCE; high_limit += (BACNET_MAX_INSTANCE / 4)) { len = whois_encode_apdu(&apdu[0], low_limit, high_limit); apdu_len = len; ct_test(pTest, len != 0); - len = whois_decode_apdu(&apdu[0], - apdu_len, &test_low_limit, &test_high_limit); + len = + whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, + &test_high_limit); ct_test(pTest, len != -1); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); diff --git a/bacnet-stack/src/wp.c b/bacnet-stack/src/wp.c index a98d74b5..da956aba 100644 --- a/bacnet-stack/src/wp.c +++ b/bacnet-stack/src/wp.c @@ -54,15 +54,18 @@ int wp_encode_apdu( apdu[2] = invoke_id; apdu[3] = SERVICE_CONFIRMED_WRITE_PROPERTY; /* service choice */ apdu_len = 4; - len = encode_context_object_id(&apdu[apdu_len], 0, - wpdata->object_type, wpdata->object_instance); + len = + encode_context_object_id(&apdu[apdu_len], 0, wpdata->object_type, + wpdata->object_instance); apdu_len += len; - len = encode_context_enumerated(&apdu[apdu_len], 1, + len = + encode_context_enumerated(&apdu[apdu_len], 1, wpdata->object_property); apdu_len += len; /* optional array index; ALL is -1 which is assumed when missing */ if (wpdata->array_index != BACNET_ARRAY_ALL) { - len = encode_context_unsigned(&apdu[apdu_len], 2, + len = + encode_context_unsigned(&apdu[apdu_len], 2, wpdata->array_index); apdu_len += len; } @@ -77,8 +80,8 @@ int wp_encode_apdu( apdu_len += len; /* optional priority - 0 if not set, 1..16 if set */ if (wpdata->priority != BACNET_NO_PRIORITY) { - len = encode_context_unsigned(&apdu[apdu_len], 4, - wpdata->priority); + len = + encode_context_unsigned(&apdu[apdu_len], 4, wpdata->priority); apdu_len += len; } } @@ -111,20 +114,22 @@ int wp_decode_service_request( len += decode_object_id(&apdu[len], &type, &wpdata->object_instance); wpdata->object_type = (BACNET_OBJECT_TYPE) type; /* Tag 1: Property ID */ - len += decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + len += + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number != 1) return -1; len += decode_enumerated(&apdu[len], len_value_type, &property); wpdata->object_property = (BACNET_PROPERTY_ID) property; /* Tag 2: Optional Array Index */ /* note: decode without incrementing len so we can check for opening tag */ - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number == 2) { len += tag_len; - len += decode_unsigned(&apdu[len], len_value_type, - &unsigned_value); + len += + decode_unsigned(&apdu[len], len_value_type, &unsigned_value); wpdata->array_index = unsigned_value; } else wpdata->array_index = BACNET_ARRAY_ALL; @@ -132,8 +137,9 @@ int wp_decode_service_request( if (!decode_is_opening_tag_number(&apdu[len], 3)) return -1; /* determine the length of the data blob */ - wpdata->application_data_len = bacapp_data_len(&apdu[len], - apdu_len - len, (BACNET_PROPERTY_ID) property); + wpdata->application_data_len = + bacapp_data_len(&apdu[len], apdu_len - len, + (BACNET_PROPERTY_ID) property); /* a tag number of 3 is not extended so only one octet */ len++; /* copy the data from the APDU */ @@ -149,8 +155,9 @@ int wp_decode_service_request( /* Tag 4: optional Priority - assumed MAX if not explicitly set */ wpdata->priority = BACNET_MAX_PRIORITY; if ((unsigned) len < apdu_len) { - tag_len = decode_tag_number_and_value(&apdu[len], - &tag_number, &len_value_type); + tag_len = + decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number == 4) { len += tag_len; len = @@ -194,8 +201,9 @@ int wp_decode_apdu( offset = 4; if (apdu_len > offset) { - len = wp_decode_service_request(&apdu[offset], - apdu_len - offset, wpdata); + len = + wp_decode_service_request(&apdu[offset], apdu_len - offset, + wpdata); } return len; @@ -227,7 +235,8 @@ void testWritePropertyTag( ct_test(pTest, test_data.object_property == wpdata.object_property); ct_test(pTest, test_data.array_index == wpdata.array_index); /* decode the application value of the request */ - len = bacapp_decode_application_data(test_data.application_data, + len = + bacapp_decode_application_data(test_data.application_data, test_data.application_data_len, &test_value); ct_test(pTest, test_value.tag == value->tag); switch (test_value.tag) { @@ -237,24 +246,24 @@ void testWritePropertyTag( ct_test(pTest, test_value.type.Boolean == value->type.Boolean); break; case BACNET_APPLICATION_TAG_UNSIGNED_INT: - ct_test(pTest, test_value.type.Unsigned_Int == - value->type.Unsigned_Int); + ct_test(pTest, + test_value.type.Unsigned_Int == value->type.Unsigned_Int); break; case BACNET_APPLICATION_TAG_SIGNED_INT: - ct_test(pTest, test_value.type.Signed_Int == - value->type.Signed_Int); + ct_test(pTest, + test_value.type.Signed_Int == value->type.Signed_Int); break; case BACNET_APPLICATION_TAG_REAL: ct_test(pTest, test_value.type.Real == value->type.Real); break; case BACNET_APPLICATION_TAG_ENUMERATED: - ct_test(pTest, test_value.type.Enumerated == - value->type.Enumerated); + ct_test(pTest, + test_value.type.Enumerated == value->type.Enumerated); break; case BACNET_APPLICATION_TAG_DATE: ct_test(pTest, test_value.type.Date.year == value->type.Date.year); - ct_test(pTest, test_value.type.Date.month == - value->type.Date.month); + ct_test(pTest, + test_value.type.Date.month == value->type.Date.month); ct_test(pTest, test_value.type.Date.day == value->type.Date.day); ct_test(pTest, test_value.type.Date.wday == value->type.Date.wday); break; @@ -262,13 +271,15 @@ void testWritePropertyTag( ct_test(pTest, test_value.type.Time.hour == value->type.Time.hour); ct_test(pTest, test_value.type.Time.min == value->type.Time.min); ct_test(pTest, test_value.type.Time.sec == value->type.Time.sec); - ct_test(pTest, test_value.type.Time.hundredths == + ct_test(pTest, + test_value.type.Time.hundredths == value->type.Time.hundredths); break; case BACNET_APPLICATION_TAG_OBJECT_ID: - ct_test(pTest, test_value.type.Object_Id.type == - value->type.Object_Id.type); - ct_test(pTest, test_value.type.Object_Id.instance == + ct_test(pTest, + test_value.type.Object_Id.type == value->type.Object_Id.type); + ct_test(pTest, + test_value.type.Object_Id.instance == value->type.Object_Id.instance); break; default: diff --git a/bacnet-stack/test/ctest.c b/bacnet-stack/test/ctest.c index f8626e55..184a02b0 100644 --- a/bacnet-stack/test/ctest.c +++ b/bacnet-stack/test/ctest.c @@ -103,8 +103,7 @@ long ct_report( { assert(pTest); if (pTest->pStream) { - fprintf(pTest->pStream, - "Test \"%s\":\n\tPassed: %ld\n\tFailed: %ld\n", + fprintf(pTest->pStream, "Test \"%s\":\n\tPassed: %ld\n\tFailed: %ld\n", pTest->name, pTest->nPass, pTest->nFail); } return pTest->nFail; @@ -141,8 +140,8 @@ void ct_do_fail( assert(pTest); ++pTest->nFail; if (pTest->pStream) { - fprintf(pTest->pStream, - "%s failure: (%s), %s (line %ld)\n", pTest->name, str, file, line); + fprintf(pTest->pStream, "%s failure: (%s), %s (line %ld)\n", + pTest->name, str, file, line); } }