From b85c4355d0336db44be03d34abd473ddb86b63c8 Mon Sep 17 00:00:00 2001 From: skarg Date: Sat, 18 Apr 2009 20:50:04 +0000 Subject: [PATCH] Indented according to standard indent rules for this project. --- bacnet-stack/demo/handler/h_iam.c | 6 +- bacnet-stack/demo/handler/h_lso.c | 34 +++--- bacnet-stack/demo/handler/h_rpm.c | 14 +-- bacnet-stack/demo/handler/h_rpm_a.c | 30 +++-- bacnet-stack/demo/initrouter/main.c | 3 +- bacnet-stack/demo/mstpcap/main.c | 60 +++++----- bacnet-stack/demo/readprop/main.c | 4 +- bacnet-stack/demo/readpropm/main.c | 3 +- bacnet-stack/demo/ucov/main.c | 4 +- bacnet-stack/include/bacapp.h | 2 +- bacnet-stack/include/bacdcode.h | 4 +- bacnet-stack/include/bacenum.h | 8 +- bacnet-stack/include/datalink.h | 41 ++++--- bacnet-stack/include/fifo.h | 24 ++-- bacnet-stack/include/handlers.h | 14 +-- bacnet-stack/include/keylist.h | 61 +++++----- bacnet-stack/include/lso.h | 29 +++-- bacnet-stack/include/ptransfer.h | 10 +- bacnet-stack/lib/main.h | 5 +- bacnet-stack/ports/linux/mstpsnap.c | 14 +-- bacnet-stack/ports/linux/rs485.c | 2 +- bacnet-stack/ports/pic18f6720/apdu.c | 9 +- bacnet-stack/ports/pic18f6720/main.c | 8 +- bacnet-stack/ports/rtos32/dlmstp.c | 2 +- bacnet-stack/src/address.c | 67 +++++------ bacnet-stack/src/bacaddr.c | 4 +- bacnet-stack/src/bacapp.c | 6 +- bacnet-stack/src/bacdcode.c | 85 ++++++++------ bacnet-stack/src/bacdevobjpropref.c | 5 +- bacnet-stack/src/bacpropstates.c | 2 +- bacnet-stack/src/cov.c | 10 +- bacnet-stack/src/event.c | 24 ++-- bacnet-stack/src/fifo.c | 30 ++--- bacnet-stack/src/iam.c | 9 +- bacnet-stack/src/ihave.c | 8 +- bacnet-stack/src/indtext.c | 4 +- bacnet-stack/src/lso.c | 128 ++++++++++---------- bacnet-stack/src/npdu.c | 8 +- bacnet-stack/src/ptransfer.c | 168 +++++++++++++-------------- bacnet-stack/src/rp.c | 6 +- bacnet-stack/src/rpm.c | 44 ++++--- bacnet-stack/src/whohas.c | 2 +- bacnet-stack/src/wp.c | 2 +- 43 files changed, 501 insertions(+), 502 deletions(-) diff --git a/bacnet-stack/demo/handler/h_iam.c b/bacnet-stack/demo/handler/h_iam.c index 883efc37..4a14fde4 100644 --- a/bacnet-stack/demo/handler/h_iam.c +++ b/bacnet-stack/demo/handler/h_iam.c @@ -52,9 +52,9 @@ void handler_i_am_add( #endif if (len != -1) { #if PRINT_ENABLED - fprintf(stderr, " from %u, MAC = %d.%d.%d.%d.%d.%d\n",device_id, - src->mac[0],src->mac[1],src->mac[2], - src->mac[3],src->mac[4],src->mac[5]); + fprintf(stderr, " from %u, MAC = %d.%d.%d.%d.%d.%d\n", device_id, + src->mac[0], src->mac[1], src->mac[2], src->mac[3], src->mac[4], + src->mac[5]); #endif address_add(device_id, max_apdu, src); } else { diff --git a/bacnet-stack/demo/handler/h_lso.c b/bacnet-stack/demo/handler/h_lso.c index 51dc53f7..17a810ca 100644 --- a/bacnet-stack/demo/handler/h_lso.c +++ b/bacnet-stack/demo/handler/h_lso.c @@ -43,12 +43,12 @@ bool handler_lso( BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data) { - BACNET_LSO_DATA data; - int len = 0; - int pdu_len = 0; - BACNET_NPDU_DATA npdu_data; - int bytes_sent = 0; - BACNET_ADDRESS my_address; + BACNET_LSO_DATA data; + int len = 0; + int pdu_len = 0; + BACNET_NPDU_DATA npdu_data; + int bytes_sent = 0; + BACNET_ADDRESS my_address; /* encode the NPDU portion of the packet */ datalink_get_my_address(&my_address); @@ -84,24 +84,20 @@ bool handler_lso( goto LSO_ABORT; } - /* - ** Process Life Safety Operation Here - */ + /* + ** Process Life Safety Operation Here + */ #if PRINT_ENABLED fprintf(stderr, - "Life Safety Operation: Received operation %d from process id %d for object %id\n", - data.operation, - data.processId, - data.targetObject.instance); + "Life Safety Operation: Received operation %d from process id %d for object %id\n", + data.operation, data.processId, data.targetObject.instance); #endif len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len], - service_data->invoke_id, - SERVICE_CONFIRMED_LIFE_SAFETY_OPERATION); + service_data->invoke_id, SERVICE_CONFIRMED_LIFE_SAFETY_OPERATION); #if PRINT_ENABLED - fprintf(stderr, - "Life Safety Operation: " "Sending Simple Ack!\n"); + fprintf(stderr, "Life Safety Operation: " "Sending Simple Ack!\n"); #endif LSO_ABORT: @@ -111,11 +107,9 @@ bool handler_lso( pdu_len); #if PRINT_ENABLED if (bytes_sent <= 0) - fprintf(stderr, - "Life Safety Operation: " "Failed to send PDU (%s)!\n", + fprintf(stderr, "Life Safety Operation: " "Failed to send PDU (%s)!\n", strerror(errno)); #endif return; } - diff --git a/bacnet-stack/demo/handler/h_rpm.c b/bacnet-stack/demo/handler/h_rpm.c index 2d244022..00c295e1 100644 --- a/bacnet-stack/demo/handler/h_rpm.c +++ b/bacnet-stack/demo/handler/h_rpm.c @@ -421,15 +421,14 @@ void handler_read_property_multiple( /* handle the error code - but use the special property */ len = RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, MAX_APDU, - object_type, object_instance, object_property, - array_index); + npdu_len + apdu_len, MAX_APDU, object_type, + object_instance, object_property, array_index); if (len > 0) { apdu_len += len; } else { apdu_len = - abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], - service_data->invoke_id, + abort_encode_apdu(&Handler_Transmit_Buffer + [npdu_len], service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true); goto RPM_ABORT; } @@ -440,9 +439,8 @@ void handler_read_property_multiple( special_object_property, index); len = RPM_Encode_Property(&Handler_Transmit_Buffer[0], - npdu_len + apdu_len, MAX_APDU, - object_type, object_instance, object_property, - array_index); + npdu_len + apdu_len, MAX_APDU, object_type, + object_instance, object_property, array_index); if (len > 0) { apdu_len += len; } else { diff --git a/bacnet-stack/demo/handler/h_rpm_a.c b/bacnet-stack/demo/handler/h_rpm_a.c index 54787954..e34e2b10 100644 --- a/bacnet-stack/demo/handler/h_rpm_a.c +++ b/bacnet-stack/demo/handler/h_rpm_a.c @@ -50,10 +50,10 @@ static int rpm_ack_decode_service_request( BACNET_READ_ACCESS_DATA * read_access_data) { int decoded_len = 0; /* return value */ - uint32_t error_value = 0; /* decoded error value */ + uint32_t error_value = 0; /* decoded error value */ int len = 0; /* number of bytes returned from decoding */ - uint8_t tag_number = 0; /* decoded tag number */ - uint32_t len_value = 0; /* decoded length value */ + uint8_t tag_number = 0; /* decoded tag number */ + uint32_t len_value = 0; /* decoded length value */ BACNET_READ_ACCESS_DATA *rpm_object; BACNET_READ_ACCESS_DATA *old_rpm_object; BACNET_PROPERTY_REFERENCE *rpm_property; @@ -108,12 +108,12 @@ static int rpm_ack_decode_service_request( while (value && (apdu_len > 0)) { if (decode_is_context_specific(apdu)) { len = - bacapp_decode_context_data( - apdu, apdu_len, value, - rpm_property->propertyIdentifier); + bacapp_decode_context_data(apdu, apdu_len, value, + rpm_property->propertyIdentifier); } else { len = - bacapp_decode_application_data(apdu, apdu_len, value); + bacapp_decode_application_data(apdu, apdu_len, + value); } decoded_len += len; apdu_len -= len; @@ -137,8 +137,7 @@ static int rpm_ack_decode_service_request( apdu++; /* decode the class and code sequence */ len = - decode_tag_number_and_value(apdu, &tag_number, - &len_value); + decode_tag_number_and_value(apdu, &tag_number, &len_value); decoded_len += len; apdu_len -= len; apdu += len; @@ -149,13 +148,12 @@ static int rpm_ack_decode_service_request( apdu_len -= len; apdu += len; len = - decode_tag_number_and_value(apdu, &tag_number, - &len_value); + decode_tag_number_and_value(apdu, &tag_number, &len_value); decoded_len += len; apdu_len -= len; apdu += len; /* FIXME: we could validate that the tag is enumerated... */ - len = decode_enumerated(apdu, len_value, &error_value); + len = decode_enumerated(apdu, len_value, &error_value); rpm_property->error.error_code = error_value; decoded_len += len; apdu_len -= len; @@ -242,10 +240,10 @@ static void PrintReadPropertyMultipleData( #if PRINT_ENABLED /* AccessError */ fprintf(stdout, "BACnet Error: %s: %s\r\n", - bactext_error_class_name( - (int)listOfProperties->error.error_class), - bactext_error_code_name( - (int)listOfProperties->error.error_code)); + bactext_error_class_name((int) listOfProperties->error. + error_class), + bactext_error_code_name((int) listOfProperties->error. + error_code)); #endif } listOfProperties = listOfProperties->next; diff --git a/bacnet-stack/demo/initrouter/main.c b/bacnet-stack/demo/initrouter/main.c index 71583f48..6103488a 100644 --- a/bacnet-stack/demo/initrouter/main.c +++ b/bacnet-stack/demo/initrouter/main.c @@ -325,8 +325,7 @@ static void address_parse(BACNET_ADDRESS * dst, dst->mac_len = 6; for (index = 0; index < 4; index++) { dst->mac[index] = mac[index]; - } - encode_unsigned16(&dst->mac[4], + } encode_unsigned16(&dst->mac[4], port); } else { count = diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index 17168e45..8fb7198d 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -99,11 +99,12 @@ static void dlmstp_millisecond_timer( } #if !defined (_WIN32) -void Sleep(unsigned long milliseconds) +void Sleep( + unsigned long milliseconds) { struct timespec timeOut, remains; - timeOut.tv_sec = milliseconds/1000; + timeOut.tv_sec = milliseconds / 1000; timeOut.tv_nsec = (milliseconds - (timeOut.tv_sec * 1000)) * 10000000; nanosleep(&timeOut, &remains); } @@ -165,7 +166,8 @@ uint16_t MSTP_Get_Reply( static char Capture_Filename[32] = "mstp_20090123091200.cap"; static FILE *pFile = NULL; /* stream pointer */ -static void filename_create(char *filename) +static void filename_create( + char *filename) { time_t my_time; struct tm *today; @@ -173,13 +175,9 @@ static void filename_create(char *filename) if (filename) { my_time = time(NULL); today = localtime(&my_time); - sprintf(filename,"mstp_%04d%02d%02d%02d%02d%02d.cap", - 1900+today->tm_year, - 1+today->tm_mon, - today->tm_mday, - today->tm_hour, - today->tm_min, - today->tm_sec); + sprintf(filename, "mstp_%04d%02d%02d%02d%02d%02d.cap", + 1900 + today->tm_year, 1 + today->tm_mon, today->tm_mday, + today->tm_hour, today->tm_min, today->tm_sec); } } @@ -198,13 +196,13 @@ static void write_global_header( /* create a new file. */ pFile = fopen(filename, "wb"); if (pFile) { - (void)fwrite(&magic_number, sizeof(magic_number), 1, pFile); - (void)fwrite(&version_major, sizeof(version_major), 1, pFile); - (void)fwrite(&version_minor, sizeof(version_minor), 1, pFile); - (void)fwrite(&thiszone, sizeof(thiszone), 1, pFile); - (void)fwrite(&sigfigs, sizeof(sigfigs), 1, pFile); - (void)fwrite(&snaplen, sizeof(snaplen), 1, pFile); - (void)fwrite(&network, sizeof(network), 1, pFile); + (void) fwrite(&magic_number, sizeof(magic_number), 1, pFile); + (void) fwrite(&version_major, sizeof(version_major), 1, pFile); + (void) fwrite(&version_minor, sizeof(version_minor), 1, pFile); + (void) fwrite(&thiszone, sizeof(thiszone), 1, pFile); + (void) fwrite(&sigfigs, sizeof(sigfigs), 1, pFile); + (void) fwrite(&snaplen, sizeof(snaplen), 1, pFile); + (void) fwrite(&network, sizeof(network), 1, pFile); fflush(pFile); fprintf(stdout, "mstpcap: saving capture to %s\n", filename); } else { @@ -228,16 +226,16 @@ static void write_received_packet( gettimeofday(&tv, NULL); ts_sec = tv.tv_sec; ts_usec = tv.tv_usec; - (void)fwrite(&ts_sec, sizeof(ts_sec), 1, pFile); - (void)fwrite(&ts_usec, sizeof(ts_usec), 1, pFile); + (void) fwrite(&ts_sec, sizeof(ts_sec), 1, pFile); + (void) fwrite(&ts_usec, sizeof(ts_usec), 1, pFile); if (mstp_port->DataLength) { max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength); incl_len = orig_len = 8 + max_data + 2; } else { incl_len = orig_len = 8; } - (void)fwrite(&incl_len, sizeof(incl_len), 1, pFile); - (void)fwrite(&orig_len, sizeof(orig_len), 1, pFile); + (void) fwrite(&incl_len, sizeof(incl_len), 1, pFile); + (void) fwrite(&orig_len, sizeof(orig_len), 1, pFile); header[0] = 0x55; header[1] = 0xFF; header[2] = mstp_port->FrameType; @@ -246,11 +244,11 @@ static void write_received_packet( header[5] = HI_BYTE(mstp_port->DataLength); header[6] = LO_BYTE(mstp_port->DataLength); header[7] = mstp_port->HeaderCRCActual; - (void)fwrite(header, sizeof(header), 1, pFile); + (void) fwrite(header, sizeof(header), 1, pFile); if (mstp_port->DataLength) { - (void)fwrite(mstp_port->InputBuffer, max_data, 1, pFile); - (void)fwrite((char *) &mstp_port->DataCRCActualMSB, 1, 1, pFile); - (void)fwrite((char *) &mstp_port->DataCRCActualLSB, 1, 1, pFile); + (void) fwrite(mstp_port->InputBuffer, max_data, 1, pFile); + (void) fwrite((char *) &mstp_port->DataCRCActualMSB, 1, 1, pFile); + (void) fwrite((char *) &mstp_port->DataCRCActualLSB, 1, 1, pFile); } } else { fprintf(stderr, "mstpcap: failed to open %s: %s\n", Capture_Filename, @@ -287,7 +285,8 @@ void signal_init( } #endif -void filename_create_new(void) +void filename_create_new( + void) { if (pFile) { fclose(pFile); @@ -320,14 +319,11 @@ int main( "Captures MS/TP packets from a serial interface\r\n" "and save them to a file. Saves packets in a\r\n" "filename mstp_20090123091200.cap that has data and time.\r\n" - "After receiving 65535 packets, a new file is created.\r\n" - "\r\n" - "Command line options:\r\n" - "[interface] - serial interface.\r\n" + "After receiving 65535 packets, a new file is created.\r\n" "\r\n" + "Command line options:\r\n" "[interface] - serial interface.\r\n" " defaults to COM4 on Windows, and /dev/ttyUSB0 on linux.\r\n" "[baud] - baud rate. 9600, 19200, 38400, 57600, 115200\r\n" - " defaults to 38400.\r\n" - ""); + " defaults to 38400.\r\n" ""); return 0; } if (argc > 1) { diff --git a/bacnet-stack/demo/readprop/main.c b/bacnet-stack/demo/readprop/main.c index 02c70532..f3abfb32 100644 --- a/bacnet-stack/demo/readprop/main.c +++ b/bacnet-stack/demo/readprop/main.c @@ -174,14 +174,14 @@ static void Init_DataLink( pEnv = getenv("BACNET_MSTP_BAUD"); if (pEnv) { RS485_Set_Baud_Rate(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_MSTP_BAUD=%s\r\n",pEnv); + fprintf(stderr, "BACNET_MSTP_BAUD=%s\r\n", pEnv); } else { RS485_Set_Baud_Rate(38400); } pEnv = getenv("BACNET_APDU_TIMEOUT"); if (pEnv) { apdu_timeout_set(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n",pEnv); + fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); } pEnv = getenv("BACNET_MSTP_MAC"); if (pEnv) { diff --git a/bacnet-stack/demo/readpropm/main.c b/bacnet-stack/demo/readpropm/main.c index 4368b7d4..9aab6228 100644 --- a/bacnet-stack/demo/readpropm/main.c +++ b/bacnet-stack/demo/readpropm/main.c @@ -230,7 +230,8 @@ void cleanup(void) { old_rpm_property = rpm_property; rpm_property = rpm_property->next; free(old_rpm_property); - } old_rpm_object = rpm_object; + } + old_rpm_object = rpm_object; rpm_object = rpm_object->next; free(old_rpm_object); } diff --git a/bacnet-stack/demo/ucov/main.c b/bacnet-stack/demo/ucov/main.c index c80c5032..8622b935 100644 --- a/bacnet-stack/demo/ucov/main.c +++ b/bacnet-stack/demo/ucov/main.c @@ -212,8 +212,8 @@ int main(int argc, char *argv[]) { filename_remove_path(argv[0]), filename_remove_path(argv[0])); return 0; } - /* decode the command line parameters */ cov_data. - subscriberProcessIdentifier = strtol(argv[1], NULL, 0); + /* decode the command line parameters */ + cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0); cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0); cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0); cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0); diff --git a/bacnet-stack/include/bacapp.h b/bacnet-stack/include/bacapp.h index a3042edf..5a59391f 100644 --- a/bacnet-stack/include/bacapp.h +++ b/bacnet-stack/include/bacapp.h @@ -100,7 +100,7 @@ typedef struct BACnet_Property_Reference { BACNET_PROPERTY_ID propertyIdentifier; int32_t propertyArrayIndex; /* optional */ /* either value or error, but not both. - Use NULL value to indicate error */ + Use NULL value to indicate error */ BACNET_APPLICATION_DATA_VALUE *value; BACNET_ACCESS_ERROR error; /* simple linked list */ diff --git a/bacnet-stack/include/bacdcode.h b/bacnet-stack/include/bacdcode.h index e70618ac..a331ea9b 100644 --- a/bacnet-stack/include/bacdcode.h +++ b/bacnet-stack/include/bacdcode.h @@ -288,11 +288,11 @@ extern "C" { int decode_enumerated( uint8_t * apdu, uint32_t len_value, - uint32_t *value); + uint32_t * value); int decode_context_enumerated( uint8_t * apdu, uint8_t tag_value, - uint32_t *value); + uint32_t * value); int encode_bacnet_enumerated( uint8_t * apdu, uint32_t value); diff --git a/bacnet-stack/include/bacenum.h b/bacnet-stack/include/bacenum.h index 4446be4d..ba7f1149 100644 --- a/bacnet-stack/include/bacenum.h +++ b/bacnet-stack/include/bacenum.h @@ -898,11 +898,9 @@ typedef enum { OBJECT_ACCESS_ZONE = 36, OBJECT_AUTHENTICATION_FACTOR_INPUT = 37, MAX_ASHRAE_OBJECT_TYPE = 38 - - /* Enumerated values 0-127 are reserved for definition by ASHRAE. */ - /* Enumerated values 128-1023 may be used by others subject to */ - /* the procedures and constraints described in Clause 23. */ - + /* Enumerated values 0-127 are reserved for definition by ASHRAE. */ + /* Enumerated values 128-1023 may be used by others subject to */ + /* the procedures and constraints described in Clause 23. */ } BACNET_OBJECT_TYPE; /* used for bit string loop */ #define MAX_BACNET_OBJECT_TYPE 1023 diff --git a/bacnet-stack/include/datalink.h b/bacnet-stack/include/datalink.h index 5c0e2cd0..68ad3e8c 100644 --- a/bacnet-stack/include/datalink.h +++ b/bacnet-stack/include/datalink.h @@ -92,30 +92,29 @@ extern "C" { #endif /* __cplusplus */ -int datalink_send_pdu( - BACNET_ADDRESS * dest, - BACNET_NPDU_DATA * npdu_data, - uint8_t * pdu, - unsigned pdu_len); -extern uint16_t datalink_receive( - BACNET_ADDRESS * src, - uint8_t * pdu, - uint16_t max_pdu, - unsigned timeout); -extern void datalink_cleanup( - void); -extern void datalink_get_broadcast_address( - BACNET_ADDRESS * dest); -extern void datalink_get_my_address( - BACNET_ADDRESS * my_address); -extern void datalink_set_interface( - char *ifname); -extern void datalink_set( - char *datalink_string); + int datalink_send_pdu( + BACNET_ADDRESS * dest, + BACNET_NPDU_DATA * npdu_data, + uint8_t * pdu, + unsigned pdu_len); + extern uint16_t datalink_receive( + BACNET_ADDRESS * src, + uint8_t * pdu, + uint16_t max_pdu, + unsigned timeout); + extern void datalink_cleanup( + void); + extern void datalink_get_broadcast_address( + BACNET_ADDRESS * dest); + extern void datalink_get_my_address( + BACNET_ADDRESS * my_address); + extern void datalink_set_interface( + char *ifname); + extern void datalink_set( + char *datalink_string); #ifdef __cplusplus } #endif /* __cplusplus */ #endif - #endif diff --git a/bacnet-stack/include/fifo.h b/bacnet-stack/include/fifo.h index 53af8297..bf343d75 100755 --- a/bacnet-stack/include/fifo.h +++ b/bacnet-stack/include/fifo.h @@ -46,10 +46,10 @@ #include struct fifo_buffer_t { - volatile unsigned head; /* first byte of data */ + volatile unsigned head; /* first byte of data */ volatile unsigned tail; /* last byte of data */ - volatile uint8_t *buffer; /* block of memory or array of data */ - unsigned buffer_len; /* length of the data */ + volatile uint8_t *buffer; /* block of memory or array of data */ + unsigned buffer_len; /* length of the data */ }; typedef struct fifo_buffer_t FIFO_BUFFER; @@ -57,31 +57,31 @@ typedef struct fifo_buffer_t FIFO_BUFFER; extern "C" { #endif /* __cplusplus */ -bool FIFO_Empty( + bool FIFO_Empty( FIFO_BUFFER const *b); -uint8_t FIFO_Peek( + uint8_t FIFO_Peek( FIFO_BUFFER const *b); -uint8_t FIFO_Get( + uint8_t FIFO_Get( FIFO_BUFFER * b); -bool FIFO_Put( + bool FIFO_Put( FIFO_BUFFER * b, uint8_t data_byte); -bool FIFO_Add( + bool FIFO_Add( FIFO_BUFFER * b, - uint8_t *data_bytes, + uint8_t * data_bytes, unsigned count); -void FIFO_Flush( + void FIFO_Flush( FIFO_BUFFER * b); /* note: buffer_len must be a power of two */ -void FIFO_Init( + void FIFO_Init( FIFO_BUFFER * b, - volatile uint8_t *buffer, + volatile uint8_t * buffer, unsigned buffer_len); #ifdef __cplusplus diff --git a/bacnet-stack/include/handlers.h b/bacnet-stack/include/handlers.h index 3aad1f81..4bb1f2cc 100644 --- a/bacnet-stack/include/handlers.h +++ b/bacnet-stack/include/handlers.h @@ -169,13 +169,13 @@ extern "C" { uint8_t * service_request, uint16_t service_len, BACNET_ADDRESS * src); - - bool handler_lso( - uint8_t * service_request, - uint16_t service_len, - BACNET_ADDRESS * src, - BACNET_CONFIRMED_SERVICE_DATA * service_data); - + + bool handler_lso( + uint8_t * service_request, + uint16_t service_len, + BACNET_ADDRESS * src, + BACNET_CONFIRMED_SERVICE_DATA * service_data); + #ifdef __cplusplus } diff --git a/bacnet-stack/include/keylist.h b/bacnet-stack/include/keylist.h index c21a5ba6..5c373afd 100644 --- a/bacnet-stack/include/keylist.h +++ b/bacnet-stack/include/keylist.h @@ -58,63 +58,62 @@ extern "C" { #endif /* __cplusplus */ /* returns head of the list or NULL on failure. */ -OS_Keylist Keylist_Create( - void); + OS_Keylist Keylist_Create( + void); /* delete specified list */ /* note: you should pop all the nodes off the list first. */ -void Keylist_Delete( - OS_Keylist list); + void Keylist_Delete( + OS_Keylist list); /* inserts a node into its sorted position */ /* returns the index where it was added */ -int Keylist_Data_Add( - OS_Keylist list, - KEY key, - void *data); + int Keylist_Data_Add( + OS_Keylist list, + KEY key, + void *data); /* deletes a node specified by its key */ /* returns the data from the node */ -void *Keylist_Data_Delete( - OS_Keylist list, - KEY key); + void *Keylist_Data_Delete( + OS_Keylist list, + KEY key); /* deletes a node specified by its index */ /* returns the data from the node */ -void *Keylist_Data_Delete_By_Index( - OS_Keylist list, - int index); + void *Keylist_Data_Delete_By_Index( + OS_Keylist list, + int index); /* returns the data from last node, and removes it from the list */ -void *Keylist_Data_Pop( - OS_Keylist list); + void *Keylist_Data_Pop( + OS_Keylist list); /* returns the data from the node specified by key */ -void *Keylist_Data( - OS_Keylist list, - KEY key); + void *Keylist_Data( + OS_Keylist list, + KEY key); /* returns the data specified by key */ -void *Keylist_Data_Index( - OS_Keylist list, - int index); + void *Keylist_Data_Index( + OS_Keylist list, + int index); /* return the key at the given index */ -KEY Keylist_Key( - OS_Keylist list, - int index); + KEY Keylist_Key( + OS_Keylist list, + int index); /* returns the next empty key from the list */ -KEY Keylist_Next_Empty_Key( - OS_Keylist list, - KEY key); + KEY Keylist_Next_Empty_Key( + OS_Keylist list, + KEY key); /* returns the number of items in the list */ -int Keylist_Count( - OS_Keylist list); + int Keylist_Count( + OS_Keylist list); #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/include/lso.h b/bacnet-stack/include/lso.h index 2f895042..80d97dd1 100644 --- a/bacnet-stack/include/lso.h +++ b/bacnet-stack/include/lso.h @@ -46,24 +46,23 @@ extern "C" { /* Life Safety Operation Service */ -typedef struct -{ - uint32_t processId; - BACNET_CHARACTER_STRING requestingSrc; - BACNET_LIFE_SAFETY_OPERATION operation; - BACNET_OBJECT_ID targetObject; -} BACNET_LSO_DATA; + typedef struct { + uint32_t processId; + BACNET_CHARACTER_STRING requestingSrc; + BACNET_LIFE_SAFETY_OPERATION operation; + BACNET_OBJECT_ID targetObject; + } BACNET_LSO_DATA; -int lso_encode_adpu( - uint8_t *apdu, - uint8_t invoke_id, - BACNET_LSO_DATA *data); + int lso_encode_adpu( + uint8_t * apdu, + uint8_t invoke_id, + BACNET_LSO_DATA * data); /* decode the service request only */ -int lso_decode_service_request( - uint8_t *apdu, - unsigned apdu_len, - BACNET_LSO_DATA *data); + int lso_decode_service_request( + uint8_t * apdu, + unsigned apdu_len, + BACNET_LSO_DATA * data); #ifdef TEST diff --git a/bacnet-stack/include/ptransfer.h b/bacnet-stack/include/ptransfer.h index 21b7a7b3..693fe5a4 100644 --- a/bacnet-stack/include/ptransfer.h +++ b/bacnet-stack/include/ptransfer.h @@ -62,7 +62,7 @@ extern "C" { uint8_t invoke_id, BACNET_ERROR_CLASS error_class, BACNET_ERROR_CODE error_code, - BACNET_PRIVATE_TRANSFER_DATA *private_data); + BACNET_PRIVATE_TRANSFER_DATA * private_data); int ptransfer_error_decode_service_request( uint8_t * apdu, unsigned apdu_len, @@ -73,18 +73,18 @@ extern "C" { int ptransfer_ack_encode_apdu( uint8_t * apdu, uint8_t invoke_id, - BACNET_PRIVATE_TRANSFER_DATA *private_data); + BACNET_PRIVATE_TRANSFER_DATA * private_data); /* ptransfer_ack_decode_service_request() is the same as ptransfer_decode_service_request */ #ifdef TEST #include "ctest.h" void test_Private_Transfer_Request( - Test * pTest); + Test * pTest); void test_Private_Transfer_Ack( - Test * pTest); + Test * pTest); void test_Private_Transfer_Error( - Test * pTest); + Test * pTest); #endif #ifdef __cplusplus diff --git a/bacnet-stack/lib/main.h b/bacnet-stack/lib/main.h index c6c92c1a..154c2a02 100644 --- a/bacnet-stack/lib/main.h +++ b/bacnet-stack/lib/main.h @@ -17,11 +17,10 @@ extern "C" { #endif /* __cplusplus */ -void DLL_EXPORT SomeFunction( - const LPCSTR sometext); + void DLL_EXPORT SomeFunction( + const LPCSTR sometext); #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/ports/linux/mstpsnap.c b/bacnet-stack/ports/linux/mstpsnap.c index 1f73caeb..0107ba15 100644 --- a/bacnet-stack/ports/linux/mstpsnap.c +++ b/bacnet-stack/ports/linux/mstpsnap.c @@ -267,18 +267,14 @@ int main( printf("mstsnap [serial] [baud] [network]\r\n" "Captures MS/TP packets from a serial interface\r\n" "and sends them to a network interface using SNAP \r\n" - "protocol packets (mimics Cimetrics U+4 packet).\r\n" - "\r\n" - "Command line options:\r\n" - "[serial] - serial interface.\r\n" + "protocol packets (mimics Cimetrics U+4 packet).\r\n" "\r\n" + "Command line options:\r\n" "[serial] - serial interface.\r\n" " defaults to /dev/ttyUSB0.\r\n" "[baud] - baud rate. 9600, 19200, 38400, 57600, 115200\r\n" - " defaults to 38400.\r\n" - "[network] - network interface.\r\n" - " defaults to eth0.\r\n" - ""); + " defaults to 38400.\r\n" "[network] - network interface.\r\n" + " defaults to eth0.\r\n" ""); return 0; - } + } /* initialize our interface */ if (argc > 1) { RS485_Set_Interface(argv[1]); diff --git a/bacnet-stack/ports/linux/rs485.c b/bacnet-stack/ports/linux/rs485.c index 610edf43..71da849f 100644 --- a/bacnet-stack/ports/linux/rs485.c +++ b/bacnet-stack/ports/linux/rs485.c @@ -246,7 +246,7 @@ void RS485_Initialize( Open device for reading and writing. Blocking mode - more CPU effecient */ - RS485_Handle = open(RS485_Port_Name, O_RDWR | O_NOCTTY /*| O_NDELAY*/); + RS485_Handle = open(RS485_Port_Name, O_RDWR | O_NOCTTY /*| O_NDELAY */ ); if (RS485_Handle < 0) { perror(RS485_Port_Name); exit(-1); diff --git a/bacnet-stack/ports/pic18f6720/apdu.c b/bacnet-stack/ports/pic18f6720/apdu.c index 643c60e8..e9cc5397 100644 --- a/bacnet-stack/ports/pic18f6720/apdu.c +++ b/bacnet-stack/ports/pic18f6720/apdu.c @@ -123,14 +123,15 @@ void apdu_handler( if (service_choice == SERVICE_CONFIRMED_READ_PROPERTY) { handler_read_property(service_request, service_request_len, src, &service_data); - } - else if (service_choice == SERVICE_CONFIRMED_WRITE_PROPERTY) { + } else if (service_choice == SERVICE_CONFIRMED_WRITE_PROPERTY) { handler_write_property(service_request, service_request_len, src, &service_data); - } else if (service_choice == SERVICE_CONFIRMED_REINITIALIZE_DEVICE) { + } else if (service_choice == + SERVICE_CONFIRMED_REINITIALIZE_DEVICE) { handler_reinitialize_device(service_request, service_request_len, src, &service_data); - } else if (service_choice == SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL) { + } else if (service_choice == + SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL) { handler_device_communication_control(service_request, service_request_len, src, &service_data); } else { diff --git a/bacnet-stack/ports/pic18f6720/main.c b/bacnet-stack/ports/pic18f6720/main.c index 895dabbf..31d1fdb4 100644 --- a/bacnet-stack/ports/pic18f6720/main.c +++ b/bacnet-stack/ports/pic18f6720/main.c @@ -260,10 +260,10 @@ void main( Hardware_Initialize(); Initialize_Variables(); /* initialize BACnet Data Link Layer */ - dlmstp_set_my_address(42); - dlmstp_set_max_info_frames(1); - dlmstp_set_max_master(127); - RS485_Set_Baud_Rate(38400); + dlmstp_set_my_address(42); + dlmstp_set_max_info_frames(1); + dlmstp_set_max_master(127); + RS485_Set_Baud_Rate(38400); dlmstp_init(); /* Handle anything that needs to be done on powerup */ /* Greet the BACnet world! */ diff --git a/bacnet-stack/ports/rtos32/dlmstp.c b/bacnet-stack/ports/rtos32/dlmstp.c index 01b2cf5e..309cdd66 100644 --- a/bacnet-stack/ports/rtos32/dlmstp.c +++ b/bacnet-stack/ports/rtos32/dlmstp.c @@ -89,7 +89,7 @@ int dlmstp_send_pdu( return -2; } /* header len */ - mtu_len = MAX_HEADER - 2 /* data crc */; + mtu_len = MAX_HEADER - 2 /* data crc */ ; if ((MAX_HEADER + pdu_len) > MAX_MPDU) { #if PRINT_ENABLED fprintf(stderr, "mstp: PDU is too big to send!\n"); diff --git a/bacnet-stack/src/address.c b/bacnet-stack/src/address.c index 6ffff791..dd4754cf 100644 --- a/bacnet-stack/src/address.c +++ b/bacnet-stack/src/address.c @@ -54,39 +54,40 @@ static struct Address_Cache_Entry { BACNET_ADDRESS address; } Address_Cache[MAX_ADDRESS_CACHE]; -bool address_match(BACNET_ADDRESS * dest, - BACNET_ADDRESS * src) +bool address_match( + BACNET_ADDRESS * dest, + BACNET_ADDRESS * src) { - uint8_t i = 0; - uint8_t max_len = 0; + uint8_t i = 0; + uint8_t max_len = 0; - if (dest->mac_len != src->mac_len) - return false; - max_len = dest->mac_len; - if (max_len > MAX_MAC_LEN) - max_len = MAX_MAC_LEN; - for (i = 0; i < max_len; i++) { - if (dest->mac[i] != src->mac[i]) - return false; - } - if (dest->net != src->net) - return false; + if (dest->mac_len != src->mac_len) + return false; + max_len = dest->mac_len; + if (max_len > MAX_MAC_LEN) + max_len = MAX_MAC_LEN; + for (i = 0; i < max_len; i++) { + if (dest->mac[i] != src->mac[i]) + return false; + } + if (dest->net != src->net) + return false; - /* if local, ignore remaining fields */ - if (dest->net == 0) - return true; + /* if local, ignore remaining fields */ + if (dest->net == 0) + return true; - if (dest->len != src->len) - return false; - max_len = dest->len; - if (max_len > MAX_MAC_LEN) - max_len = MAX_MAC_LEN; - for (i = 0; i < max_len; i++) { - if (dest->adr[i] != src->adr[i]) - return false; - } + if (dest->len != src->len) + return false; + max_len = dest->len; + if (max_len > MAX_MAC_LEN) + max_len = MAX_MAC_LEN; + for (i = 0; i < max_len; i++) { + if (dest->adr[i] != src->adr[i]) + return false; + } - return true; + return true; } void address_remove_device( @@ -129,7 +130,7 @@ void address_file_init( pFile = fopen(pFilename, "r"); if (pFile) { - while (fgets(line, (int)sizeof(line), pFile) != NULL) { + while (fgets(line, (int) sizeof(line), pFile) != NULL) { /* ignore comments */ if (line[0] != ';') { if (sscanf(line, "%ld %s %d %s %u", &device_id, &mac_string[0], @@ -137,16 +138,16 @@ void address_file_init( count = sscanf(mac_string, "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); - src.mac_len = (uint8_t)count; + src.mac_len = (uint8_t) count; for (index = 0; index < MAX_MAC_LEN; index++) { src.mac[index] = mac[index]; } - src.net = (uint16_t)snet; + src.net = (uint16_t) snet; if (snet) { count = sscanf(sadr_string, "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); - src.len = (uint8_t)count; + src.len = (uint8_t) count; for (index = 0; index < MAX_MAC_LEN; index++) { src.adr[index] = mac[index]; } @@ -156,7 +157,7 @@ void address_file_init( src.adr[index] = 0; } } - address_add((uint32_t)device_id, max_apdu, &src); + address_add((uint32_t) device_id, max_apdu, &src); } } } diff --git a/bacnet-stack/src/bacaddr.c b/bacnet-stack/src/bacaddr.c index 7d6d21cc..78e85ecc 100644 --- a/bacnet-stack/src/bacaddr.c +++ b/bacnet-stack/src/bacaddr.c @@ -60,8 +60,8 @@ bool bacnet_address_same( BACNET_ADDRESS * dest, BACNET_ADDRESS * src) { - uint8_t i = 0; /* loop counter */ - uint8_t max_len = 0; /* used for dynamic max */ + uint8_t i = 0; /* loop counter */ + uint8_t max_len = 0; /* used for dynamic max */ bool match = true; /* return value */ if (dest->mac_len != src->mac_len) diff --git a/bacnet-stack/src/bacapp.c b/bacnet-stack/src/bacapp.c index ad44acc9..dfae7e29 100644 --- a/bacnet-stack/src/bacapp.c +++ b/bacnet-stack/src/bacapp.c @@ -135,7 +135,7 @@ int bacapp_encode_application_data( case BACNET_APPLICATION_TAG_OBJECT_ID: apdu_len = encode_application_object_id(&apdu[0], - (int)value->type.Object_Id.type, + (int) value->type.Object_Id.type, value->type.Object_Id.instance); break; #endif @@ -376,7 +376,7 @@ int bacapp_encode_context_data_value( case BACNET_APPLICATION_TAG_OBJECT_ID: apdu_len = encode_context_object_id(&apdu[0], context_tag_number, - (int)value->type.Object_Id.type, + (int) value->type.Object_Id.type, value->type.Object_Id.instance); break; #endif @@ -686,7 +686,7 @@ int bacapp_data_len( break; } } - if ((unsigned)apdu_len > max_apdu_len) { + if ((unsigned) apdu_len > max_apdu_len) { /* error: exceeding our buffer limit */ total_len = -1; break; diff --git a/bacnet-stack/src/bacdcode.c b/bacnet-stack/src/bacdcode.c index 96dacca0..2ed3ff2e 100644 --- a/bacnet-stack/src/bacdcode.c +++ b/bacnet-stack/src/bacdcode.c @@ -682,7 +682,7 @@ int encode_application_bitstring( BACNET_BIT_STRING * bit_string) { int len = 0; - uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */ + uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */ /* 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); @@ -700,13 +700,11 @@ int encode_context_bitstring( BACNET_BIT_STRING * bit_string) { int len = 0; - uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */ + uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */ /* 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], tag_number, true, - bit_string_encoded_length); + len = encode_tag(&apdu[0], tag_number, true, bit_string_encoded_length); len += encode_bitstring(&apdu[len], bit_string); return len; @@ -757,7 +755,7 @@ int encode_bacnet_object_id( uint32_t type = 0; int len = 0; - type = (uint32_t)object_type; + type = (uint32_t) object_type; value = ((type & BACNET_MAX_OBJECT) << BACNET_INSTANCE_BITS) | (instance & BACNET_MAX_INSTANCE); @@ -781,7 +779,7 @@ int encode_context_object_id( len = encode_bacnet_object_id(&apdu[1], object_type, instance); /* we only reserved 1 byte for encoding the tag - check the limits */ if ((tag_number <= 14) && (len <= 4)) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -801,7 +799,9 @@ int encode_application_object_id( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_object_id(&apdu[1], object_type, instance); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_OBJECT_ID, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_OBJECT_ID, false, + (uint32_t) len); return len; } @@ -819,7 +819,7 @@ int encode_octet_string( if (octet_string) { /* FIXME: might need to pass in the length of the APDU to bounds check since it might not be the only data chunk */ - len = (int)octetstring_length(octet_string); + len = (int) octetstring_length(octet_string); value = octetstring_value(octet_string); for (i = 0; i < len; i++) { apdu[i] = value[i]; @@ -891,7 +891,7 @@ int decode_octet_string( status = octetstring_init(octet_string, &apdu[0], len_value); if (status) { - len = (int)len_value; + len = (int) len_value; } return len; @@ -931,11 +931,11 @@ int encode_bacnet_character_string( int len, i; char *pString; - len = (int)characterstring_length(char_string); + len = (int) characterstring_length(char_string); apdu[0] = characterstring_encoding(char_string); pString = characterstring_value(char_string); for (i = 0; i < len; i++) { - apdu[1 + i] = (uint8_t)pString[i]; + apdu[1 + i] = (uint8_t) pString[i]; } return len + 1 /* for encoding */ ; @@ -951,10 +951,11 @@ int encode_application_character_string( int len = 0; int string_len = 0; - string_len = (int)characterstring_length(char_string) + 1 /* for encoding */ ; + string_len = + (int) characterstring_length(char_string) + 1 /* for encoding */ ; len = encode_tag(&apdu[0], BACNET_APPLICATION_TAG_CHARACTER_STRING, false, - (uint32_t)string_len); + (uint32_t) string_len); if ((len + string_len) < MAX_APDU) { len += encode_bacnet_character_string(&apdu[len], char_string); } else { @@ -972,8 +973,9 @@ int encode_context_character_string( int len = 0; int string_len = 0; - string_len = (int)characterstring_length(char_string) + 1 /* for encoding */ ; - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)string_len); + string_len = + (int) characterstring_length(char_string) + 1 /* for encoding */ ; + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) string_len); if ((len + string_len) < MAX_APDU) { len += encode_bacnet_character_string(&apdu[len], char_string); } else { @@ -998,7 +1000,7 @@ int decode_character_string( characterstring_init(char_string, apdu[0], (char *) &apdu[1], len_value - 1); if (status) { - len = (int)len_value; + len = (int) len_value; } return len; @@ -1061,7 +1063,7 @@ int decode_unsigned( } } - return (int)len_value; + return (int) len_value; } int decode_context_unsigned( @@ -1119,7 +1121,7 @@ int encode_context_unsigned( len = encode_bacnet_unsigned(&apdu[1], value); /* we only reserved 1 byte for encoding the tag - check the limits */ if ((tag_number <= 14) && (len <= 4)) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -1138,7 +1140,8 @@ int encode_application_unsigned( len = encode_bacnet_unsigned(&apdu[1], value); len += - encode_tag(&apdu[0], BACNET_APPLICATION_TAG_UNSIGNED_INT, false, (uint32_t)len); + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_UNSIGNED_INT, false, + (uint32_t) len); return len; } @@ -1149,7 +1152,7 @@ int encode_application_unsigned( int decode_enumerated( uint8_t * apdu, uint32_t len_value, - uint32_t *value) + uint32_t * value) { uint32_t unsigned_value = 0; int len; @@ -1165,7 +1168,7 @@ int decode_enumerated( int decode_context_enumerated( uint8_t * apdu, uint8_t tag_value, - uint32_t *value) + uint32_t * value) { int len = 0; uint8_t tag_number; @@ -1202,7 +1205,9 @@ int encode_application_enumerated( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_enumerated(&apdu[1], value); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_ENUMERATED, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_ENUMERATED, false, + (uint32_t) len); return len; } @@ -1221,7 +1226,7 @@ int encode_context_enumerated( len = encode_bacnet_enumerated(&apdu[1], value); /* we only reserved 1 byte for encoding the tag - check the limits */ if ((tag_number <= 14) && (len <= 4)) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -1257,7 +1262,7 @@ int decode_signed( } } - return (int)len_value; + return (int) len_value; } int decode_context_signed( @@ -1316,7 +1321,9 @@ int encode_application_signed( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_signed(&apdu[1], value); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_SIGNED_INT, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_SIGNED_INT, false, + (uint32_t) len); return len; } @@ -1335,7 +1342,7 @@ int encode_context_signed( len = encode_bacnet_signed(&apdu[1], value); /* we only reserved 1 byte for encoding the tag - check the limits */ if ((tag_number <= 14) && (len <= 4)) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -1354,7 +1361,9 @@ int encode_application_real( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_real(value, &apdu[1]); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_REAL, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_REAL, false, + (uint32_t) len); return len; } @@ -1370,7 +1379,7 @@ int encode_context_real( len = encode_bacnet_real(value, &apdu[1]); /* we only reserved 1 byte for encoding the tag - check the limits */ if (tag_number <= 14) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -1389,7 +1398,9 @@ int encode_application_double( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_double(value, &apdu[1]); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DOUBLE, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DOUBLE, false, + (uint32_t) len); return len; } @@ -1405,7 +1416,7 @@ int encode_context_double( len = encode_bacnet_double(value, &apdu[1]); /* we only reserved 1 byte for encoding the tag - check the limits */ if (tag_number <= 14) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -1439,7 +1450,9 @@ int encode_application_time( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_time(&apdu[1], btime); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_TIME, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_TIME, false, + (uint32_t) len); return len; } @@ -1455,7 +1468,7 @@ int encode_context_time( len = encode_bacnet_time(&apdu[1], btime); /* we only reserved 1 byte for encoding the tag - check the limits */ if ((tag_number <= 14) && (len <= 4)) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } @@ -1558,7 +1571,9 @@ int encode_application_date( /* assumes that the tag only consumes 1 octet */ len = encode_bacnet_date(&apdu[1], bdate); - len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DATE, false, (uint32_t)len); + len += + encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DATE, false, + (uint32_t) len); return len; @@ -1575,7 +1590,7 @@ int encode_context_date( len = encode_bacnet_date(&apdu[1], bdate); /* we only reserved 1 byte for encoding the tag - check the limits */ if ((tag_number <= 14) && (len <= 4)) { - len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len); + len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len); } else { len = 0; } diff --git a/bacnet-stack/src/bacdevobjpropref.c b/bacnet-stack/src/bacdevobjpropref.c index eb92a3f7..e9843fe6 100644 --- a/bacnet-stack/src/bacdevobjpropref.c +++ b/bacnet-stack/src/bacdevobjpropref.c @@ -68,7 +68,7 @@ int bacapp_encode_device_obj_property_ref( len = encode_context_object_id(&apdu[apdu_len], 0, - (int)value->objectIdentifier.type, value->objectIdentifier.instance); + (int) value->objectIdentifier.type, value->objectIdentifier.instance); apdu_len += len; len = @@ -82,7 +82,8 @@ int bacapp_encode_device_obj_property_ref( } len = encode_context_object_id(&apdu[apdu_len], 3, - (int)value->deviceIndentifier.type, value->deviceIndentifier.instance); + (int) value->deviceIndentifier.type, + value->deviceIndentifier.instance); apdu_len += len; return apdu_len; diff --git a/bacnet-stack/src/bacpropstates.c b/bacnet-stack/src/bacpropstates.c index 49cf07eb..872a967f 100644 --- a/bacnet-stack/src/bacpropstates.c +++ b/bacnet-stack/src/bacpropstates.c @@ -301,7 +301,7 @@ int bacapp_encode_property_state( } #ifdef TEST -#include /* for memset */ +#include /* for memset */ void testPropStates( Test * pTest) diff --git a/bacnet-stack/src/cov.c b/bacnet-stack/src/cov.c index aaadd6a4..9a0fb009 100644 --- a/bacnet-stack/src/cov.c +++ b/bacnet-stack/src/cov.c @@ -68,7 +68,7 @@ static int notify_encode_adpu( /* tag 2 - monitoredObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 2, - (int)data->monitoredObjectIdentifier.type, + (int) data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.instance); apdu_len += len; /* tag 3 - timeRemaining */ @@ -173,7 +173,7 @@ int cov_notify_decode_service_request( uint32_t len_value = 0; uint32_t decoded_value = 0; /* for decoding */ uint16_t decoded_type = 0; /* for decoding */ - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ BACNET_PROPERTY_VALUE *value = NULL; /* value in list */ if (apdu_len && data) { @@ -338,7 +338,7 @@ int cov_subscribe_encode_adpu( /* tag 1 - monitoredObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 1, - (int)data->monitoredObjectIdentifier.type, + (int) data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.instance); apdu_len += len; /* @@ -467,7 +467,7 @@ int cov_subscribe_property_encode_adpu( /* tag 1 - monitoredObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 1, - (int)data->monitoredObjectIdentifier.type, + (int) data->monitoredObjectIdentifier.type, data->monitoredObjectIdentifier.instance); apdu_len += len; if (!data->cancellationRequest) { @@ -518,7 +518,7 @@ int cov_subscribe_property_decode_service_request( uint32_t len_value = 0; uint32_t decoded_value = 0; /* for decoding */ uint16_t decoded_type = 0; /* for decoding */ - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ if (apdu_len && data) { /* tag 0 - subscriberProcessIdentifier */ diff --git a/bacnet-stack/src/event.c b/bacnet-stack/src/event.c index 140e00d8..221be9cb 100644 --- a/bacnet-stack/src/event.c +++ b/bacnet-stack/src/event.c @@ -106,14 +106,14 @@ int event_notify_encode_service_request( /* tag 1 - initiatingObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 1, - (int)data->initiatingObjectIdentifier.type, + (int) data->initiatingObjectIdentifier.type, data->initiatingObjectIdentifier.instance); apdu_len += len; /* tag 2 - eventObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 2, - (int)data->eventObjectIdentifier.type, + (int) data->eventObjectIdentifier.type, data->eventObjectIdentifier.instance); apdu_len += len; @@ -442,7 +442,7 @@ int event_notify_decode_service_request( int len = 0; /* return value */ int section_length = 0; uint32_t value = 0; - + if (apdu_len && data) { /* tag 0 - processIdentifier */ if ((section_length = @@ -501,8 +501,7 @@ int event_notify_decode_service_request( } /* tag 6 - eventType */ if ((section_length = - decode_context_enumerated(&apdu[len], 6, - &value)) == -1) { + decode_context_enumerated(&apdu[len], 6, &value)) == -1) { return -1; } else { data->eventType = value; @@ -531,8 +530,7 @@ int event_notify_decode_service_request( /* tag 8 - notifyType */ if ((section_length = - decode_context_enumerated(&apdu[len], 8, - &value)) == -1) { + decode_context_enumerated(&apdu[len], 8, &value)) == -1) { return -1; } else { data->notifyType = value; @@ -568,8 +566,7 @@ int event_notify_decode_service_request( } /* tag 11 - toState */ if ((section_length = - decode_context_enumerated(&apdu[len], 11, - &value)) == -1) { + decode_context_enumerated(&apdu[len], 11, &value)) == -1) { return -1; } else { data->toState = value; @@ -753,7 +750,8 @@ int event_notify_decode_service_request( &value))) { return -1; } - data->notificationParams.changeOfLifeSafety.newState = value; + data->notificationParams.changeOfLifeSafety.newState = + value; len += section_length; if (-1 == (section_length = @@ -761,7 +759,8 @@ int event_notify_decode_service_request( &value))) { return -1; } - data->notificationParams.changeOfLifeSafety.newMode = value; + data->notificationParams.changeOfLifeSafety.newMode = + value; len += section_length; if (-1 == (section_length = @@ -777,7 +776,8 @@ int event_notify_decode_service_request( &value))) { return -1; } - data->notificationParams.changeOfLifeSafety.operationExpected = value; + data->notificationParams.changeOfLifeSafety. + operationExpected = value; len += section_length; break; diff --git a/bacnet-stack/src/fifo.c b/bacnet-stack/src/fifo.c index 6f9e9840..235065ea 100755 --- a/bacnet-stack/src/fifo.c +++ b/bacnet-stack/src/fifo.c @@ -47,7 +47,7 @@ * ALGORITHM: none * NOTES: none *****************************************************************************/ -static unsigned FIFO_Count ( +static unsigned FIFO_Count( FIFO_BUFFER const *b) { return (b ? (b->head - b->tail) : 0); @@ -59,7 +59,7 @@ static unsigned FIFO_Count ( * ALGORITHM: none * NOTES: none *****************************************************************************/ -static bool FIFO_Full ( +static bool FIFO_Full( FIFO_BUFFER const *b) { return (b ? (FIFO_Count(b) == b->buffer_len) : true); @@ -71,7 +71,7 @@ static bool FIFO_Full ( * ALGORITHM: none * NOTES: none *****************************************************************************/ -static bool FIFO_Available ( +static bool FIFO_Available( FIFO_BUFFER const *b, unsigned count) { @@ -85,7 +85,7 @@ static bool FIFO_Available ( * NOTES: none *****************************************************************************/ bool FIFO_Empty( - FIFO_BUFFER const *b) + FIFO_BUFFER const *b) { return (b ? (FIFO_Count(b) == 0) : true); } @@ -97,7 +97,7 @@ bool FIFO_Empty( * NOTES: Use Empty function to see if there is data to retrieve *****************************************************************************/ uint8_t FIFO_Peek( - FIFO_BUFFER const *b) + FIFO_BUFFER const *b) { if (b) { return (b->buffer[b->tail % b->buffer_len]); @@ -113,7 +113,7 @@ uint8_t FIFO_Peek( * NOTES: Use Empty function to see if there is data to retrieve *****************************************************************************/ uint8_t FIFO_Get( - FIFO_BUFFER * b) + FIFO_BUFFER * b) { uint8_t data_byte = 0; @@ -131,8 +131,8 @@ uint8_t FIFO_Get( * NOTES: none *****************************************************************************/ bool FIFO_Put( - FIFO_BUFFER * b, - uint8_t data_byte) + FIFO_BUFFER * b, + uint8_t data_byte) { bool status = false; /* return value */ @@ -155,14 +155,14 @@ bool FIFO_Put( * NOTES: none *****************************************************************************/ bool FIFO_Add( - FIFO_BUFFER * b, - uint8_t *data_bytes, - unsigned count) + FIFO_BUFFER * b, + uint8_t * data_bytes, + unsigned count) { bool status = false; /* return value */ /* limit the ring to prevent overwriting */ - if (FIFO_Available (b, count)) { + if (FIFO_Available(b, count)) { while (count) { b->buffer[b->head % b->buffer_len] = *data_bytes; b->head++; @@ -182,7 +182,7 @@ bool FIFO_Add( * NOTES: none *****************************************************************************/ void FIFO_Flush( - FIFO_BUFFER * b) + FIFO_BUFFER * b) { if (b) { b->tail = b->head; @@ -197,7 +197,7 @@ void FIFO_Flush( *****************************************************************************/ void FIFO_Init( FIFO_BUFFER * b, - volatile uint8_t *buffer, + volatile uint8_t * buffer, unsigned buffer_len) { if (b) { @@ -224,7 +224,7 @@ void testFIFOBuffer( { FIFO_BUFFER test_buffer; volatile uint8_t data_store[FIFO_BUFFER_SIZE]; - uint8_t test_add_data[40] = {"RoseSteveLouPatRachelJessicaDaniAmyHerb"}; + uint8_t test_add_data[40] = { "RoseSteveLouPatRachelJessicaDaniAmyHerb" }; uint8_t test_data; uint8_t index; uint8_t count; diff --git a/bacnet-stack/src/iam.c b/bacnet-stack/src/iam.c index 6005d428..137a376f 100755 --- a/bacnet-stack/src/iam.c +++ b/bacnet-stack/src/iam.c @@ -61,8 +61,9 @@ int iam_encode_apdu( apdu_len += len; len = encode_application_unsigned(&apdu[apdu_len], max_apdu); apdu_len += len; - len = encode_application_enumerated(&apdu[apdu_len], - (uint32_t)segmentation); + len = + encode_application_enumerated(&apdu[apdu_len], + (uint32_t) segmentation); apdu_len += len; len = encode_application_unsigned(&apdu[apdu_len], vendor_id); apdu_len += len; @@ -107,7 +108,7 @@ int iam_decode_service_request( len = decode_unsigned(&apdu[apdu_len], len_value, &decoded_value); apdu_len += len; if (pMax_apdu) - *pMax_apdu = (unsigned)decoded_value; + *pMax_apdu = (unsigned) decoded_value; /* Segmentation - enumerated */ len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value); @@ -119,7 +120,7 @@ int iam_decode_service_request( if (decoded_value >= MAX_BACNET_SEGMENTATION) return -1; if (pSegmentation) - *pSegmentation = (int)decoded_value; + *pSegmentation = (int) decoded_value; /* Vendor ID - unsigned16 */ len = decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value); diff --git a/bacnet-stack/src/ihave.c b/bacnet-stack/src/ihave.c index 8e5888c4..3c6e2bec 100644 --- a/bacnet-stack/src/ihave.c +++ b/bacnet-stack/src/ihave.c @@ -50,13 +50,13 @@ int ihave_encode_apdu( apdu_len = 2; /* deviceIdentifier */ len = - encode_application_object_id(&apdu[apdu_len], (int)data->device_id.type, - data->device_id.instance); + encode_application_object_id(&apdu[apdu_len], + (int) data->device_id.type, data->device_id.instance); apdu_len += len; /* objectIdentifier */ len = - encode_application_object_id(&apdu[apdu_len], (int)data->object_id.type, - data->object_id.instance); + encode_application_object_id(&apdu[apdu_len], + (int) data->object_id.type, data->object_id.instance); apdu_len += len; /* objectName */ len = diff --git a/bacnet-stack/src/indtext.c b/bacnet-stack/src/indtext.c index 42d0e3b3..81920205 100644 --- a/bacnet-stack/src/indtext.c +++ b/bacnet-stack/src/indtext.c @@ -44,8 +44,8 @@ int stricmp( unsigned char c1, c2; do { - c1 = (unsigned char)*s1; - c2 = (unsigned char)*s2; + c1 = (unsigned char) *s1; + c2 = (unsigned char) *s2; c1 = (unsigned char) tolower(c1); c2 = (unsigned char) tolower(c2); s1++; diff --git a/bacnet-stack/src/lso.c b/bacnet-stack/src/lso.c index 8fbf5b2a..a5221897 100644 --- a/bacnet-stack/src/lso.c +++ b/bacnet-stack/src/lso.c @@ -52,9 +52,7 @@ int lso_encode_adpu( apdu[3] = SERVICE_CONFIRMED_LIFE_SAFETY_OPERATION; apdu_len = 4; /* tag 0 - requestingProcessId */ - len = - encode_context_unsigned(&apdu[apdu_len], 0, - data->processId); + len = encode_context_unsigned(&apdu[apdu_len], 0, data->processId); apdu_len += len; /* tag 1 - requestingSource */ len = @@ -62,17 +60,17 @@ int lso_encode_adpu( &data->requestingSrc); apdu_len += len; /* - Operation + Operation */ - len = encode_context_enumerated(&apdu[apdu_len], 2, data->operation); + len = encode_context_enumerated(&apdu[apdu_len], 2, data->operation); apdu_len += len; /* - Object ID + Object ID */ - len = encode_context_object_id(&apdu[apdu_len], 3, - (int)data->targetObject.type, - data->targetObject.instance); + len = + encode_context_object_id(&apdu[apdu_len], 3, + (int) data->targetObject.type, data->targetObject.instance); apdu_len += len; } @@ -81,60 +79,59 @@ int lso_encode_adpu( } int lso_decode_service_request( - uint8_t *apdu, - unsigned apdu_len, - BACNET_LSO_DATA *data) + uint8_t * apdu, + unsigned apdu_len, + BACNET_LSO_DATA * data) { int len = 0; /* return value */ - int section_length = 0; /* length returned from decoding */ - uint32_t operation = 0; /* handles decoded value */ + int section_length = 0; /* length returned from decoding */ + uint32_t operation = 0; /* handles decoded value */ /* check for value pointers */ if (apdu_len && data) { /* Tag 0: Object ID */ - if ( (section_length = decode_context_unsigned(&apdu[len], 0, &data->processId)) == -1) - { - return -1; - } - len += section_length; + if ((section_length = + decode_context_unsigned(&apdu[len], 0, + &data->processId)) == -1) { + return -1; + } + len += section_length; - if ( (section_length = decode_context_character_string(&apdu[len], 1, &data->requestingSrc)) == -1) - { - return -1; - } - len += section_length; + if ((section_length = + decode_context_character_string(&apdu[len], 1, + &data->requestingSrc)) == -1) { + return -1; + } + len += section_length; - if ( (section_length = decode_context_enumerated(&apdu[len], 2, &operation)) == -1) - { - return -1; - } - data->operation = operation; - len += section_length; + if ((section_length = + decode_context_enumerated(&apdu[len], 2, &operation)) == -1) { + return -1; + } + data->operation = operation; + len += section_length; - /* - ** This is an optional parameter, so dont fail if it doesnt exist - */ - if ( decode_is_context_tag(&apdu[len], 3) ) - { - if ( (section_length = decode_context_object_id(&apdu[len], 3, - &data->targetObject.type, - &data->targetObject.instance)) == -1 ) - { - return -1; - } - len += section_length; - } - else - { - data->targetObject.type = 0; - data->targetObject.instance = 0; - } - return len; + /* + ** This is an optional parameter, so dont fail if it doesnt exist + */ + if (decode_is_context_tag(&apdu[len], 3)) { + if ((section_length = + decode_context_object_id(&apdu[len], 3, + &data->targetObject.type, + &data->targetObject.instance)) == -1) { + return -1; + } + len += section_length; + } else { + data->targetObject.type = 0; + data->targetObject.instance = 0; + } + return len; - } - - return 0; + } + + return 0; } #ifdef TEST @@ -146,30 +143,31 @@ int lso_decode_service_request( void testLSO( Test * pTest) { - uint8_t apdu[1000]; - int len; + uint8_t apdu[1000]; + int len; - BACNET_LSO_DATA data; - BACNET_LSO_DATA rxdata; + BACNET_LSO_DATA data; + BACNET_LSO_DATA rxdata; - memset(&rxdata, 0, sizeof(rxdata)); + memset(&rxdata, 0, sizeof(rxdata)); - characterstring_init_ansi(&data.requestingSrc, "foobar"); - data.operation = LIFE_SAFETY_OP_RESET; - data.processId = 0x1234; - data.targetObject.instance = 0x1000; - data.targetObject.type = OBJECT_BINARY_INPUT; + characterstring_init_ansi(&data.requestingSrc, "foobar"); + data.operation = LIFE_SAFETY_OP_RESET; + data.processId = 0x1234; + data.targetObject.instance = 0x1000; + data.targetObject.type = OBJECT_BINARY_INPUT; - len = lso_encode_adpu(apdu, 100, &data); + len = lso_encode_adpu(apdu, 100, &data); - lso_decode_service_request(&apdu[4], len, &rxdata); + lso_decode_service_request(&apdu[4], len, &rxdata); ct_test(pTest, data.operation == rxdata.operation); ct_test(pTest, data.processId == rxdata.processId); ct_test(pTest, data.targetObject.instance == rxdata.targetObject.instance); ct_test(pTest, data.targetObject.type == rxdata.targetObject.type); - ct_test(pTest, memcmp(data.requestingSrc.value, rxdata.requestingSrc.value, rxdata.requestingSrc.length) == 0); + ct_test(pTest, memcmp(data.requestingSrc.value, rxdata.requestingSrc.value, + rxdata.requestingSrc.length) == 0); } #ifdef TEST_LSO diff --git a/bacnet-stack/src/npdu.c b/bacnet-stack/src/npdu.c index 3a084060..4fcc9024 100644 --- a/bacnet-stack/src/npdu.c +++ b/bacnet-stack/src/npdu.c @@ -103,7 +103,7 @@ int npdu_encode_pdu( BACNET_NPDU_DATA * npdu_data) { int len = 0; /* return value - number of octets loaded in this function */ - uint8_t i = 0; /* counter */ + uint8_t i = 0; /* counter */ if (npdu && npdu_data) { @@ -248,7 +248,7 @@ int npdu_decode( BACNET_NPDU_DATA * npdu_data) { int len = 0; /* return value - number of octets loaded in this function */ - uint8_t i = 0; /* counter */ + uint8_t i = 0; /* counter */ uint16_t src_net = 0; uint16_t dest_net = 0; uint8_t address_len = 0; @@ -297,7 +297,7 @@ int npdu_decode( dest->len = address_len; } if (address_len) { - if ( address_len > MAX_MAC_LEN ) { + if (address_len > MAX_MAC_LEN) { /* address is too large could be a malformed message */ return -1; } @@ -332,7 +332,7 @@ int npdu_decode( src->len = address_len; } if (address_len) { - if ( address_len > MAX_MAC_LEN ) { + if (address_len > MAX_MAC_LEN) { /* address is too large could be a malformed message */ return -1; } diff --git a/bacnet-stack/src/ptransfer.c b/bacnet-stack/src/ptransfer.c index 64fd249c..4db89f85 100644 --- a/bacnet-stack/src/ptransfer.c +++ b/bacnet-stack/src/ptransfer.c @@ -59,11 +59,13 @@ int ptransfer_encode_apdu( serviceParameters [2] ABSTRACT-SYNTAX.&Type OPTIONAL } */ - len = encode_context_unsigned(&apdu[apdu_len], 0, - private_data->vendorID); + len = + encode_context_unsigned(&apdu[apdu_len], 0, + private_data->vendorID); apdu_len += len; - len = encode_context_unsigned(&apdu[apdu_len], 1, - private_data->serviceNumber); + len = + encode_context_unsigned(&apdu[apdu_len], 1, + private_data->serviceNumber); apdu_len += len; len = encode_opening_tag(&apdu[apdu_len], 2); apdu_len += len; @@ -84,10 +86,10 @@ int ptransfer_decode_service_request( unsigned apdu_len, BACNET_PRIVATE_TRANSFER_DATA * private_data) { - int len = 0; /* return value */ + int len = 0; /* return value */ int decode_len = 0; /* return value */ uint32_t unsigned_value = 0; - + /* check for value pointers */ if (apdu_len && private_data) { /* Tag 0: vendorID */ @@ -110,10 +112,10 @@ int ptransfer_decode_service_request( len++; /* don't decode the serviceParameters here */ private_data->serviceParameters = &apdu[len]; - private_data->serviceParametersLen = - (int)apdu_len - len - 1 /*closing tag */ ; + private_data->serviceParametersLen = + (int) apdu_len - len - 1 /*closing tag */ ; /* len includes the data and the closing tag */ - len = (int)apdu_len; + len = (int) apdu_len; } else { return -1; } @@ -127,10 +129,10 @@ int ptransfer_error_encode_apdu( uint8_t invoke_id, BACNET_ERROR_CLASS error_class, BACNET_ERROR_CODE error_code, - BACNET_PRIVATE_TRANSFER_DATA *private_data) + BACNET_PRIVATE_TRANSFER_DATA * private_data) { int apdu_len = 0; /* total length of the apdu, return value */ - int len = 0; /* length of the part of the encoding */ + int len = 0; /* length of the part of the encoding */ if (apdu) { apdu[0] = PDU_TYPE_ERROR; @@ -154,11 +156,13 @@ int ptransfer_error_encode_apdu( apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], 0); apdu_len += len; - len = encode_context_unsigned(&apdu[apdu_len], 1, - private_data->vendorID); + len = + encode_context_unsigned(&apdu[apdu_len], 1, + private_data->vendorID); apdu_len += len; - len = encode_context_unsigned(&apdu[apdu_len], 2, - private_data->serviceNumber); + len = + encode_context_unsigned(&apdu[apdu_len], 2, + private_data->serviceNumber); apdu_len += len; len = encode_opening_tag(&apdu[apdu_len], 3); apdu_len += len; @@ -181,7 +185,7 @@ int ptransfer_error_decode_service_request( BACNET_ERROR_CODE * error_code, BACNET_PRIVATE_TRANSFER_DATA * private_data) { - int len = 0; /* return value */ + int len = 0; /* return value */ int decode_len = 0; /* return value */ uint8_t tag_number = 0; uint32_t len_value_type = 0; @@ -196,12 +200,12 @@ int ptransfer_error_decode_service_request( /* error class */ decode_len = decode_tag_number_and_value(&apdu[len], &tag_number, - &len_value_type); + &len_value_type); len += decode_len; if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED) { return 0; } - decode_len = + decode_len = decode_enumerated(&apdu[len], len_value_type, &unsigned_value); len += decode_len; if (error_class) { @@ -210,12 +214,12 @@ int ptransfer_error_decode_service_request( /* error code */ decode_len = decode_tag_number_and_value(&apdu[len], &tag_number, - &len_value_type); + &len_value_type); len += decode_len; if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED) { return 0; } - decode_len = + decode_len = decode_enumerated(&apdu[len], len_value_type, &unsigned_value); len += decode_len; if (error_code) { @@ -248,7 +252,8 @@ int ptransfer_error_decode_service_request( len++; /* don't decode the serviceParameters here */ private_data->serviceParameters = &apdu[len]; - private_data->serviceParametersLen = (int)apdu_len - len - 1 /*closing tag */ ; + private_data->serviceParametersLen = + (int) apdu_len - len - 1 /*closing tag */ ; } else { return -1; } @@ -261,7 +266,7 @@ int ptransfer_error_decode_service_request( int ptransfer_ack_encode_apdu( uint8_t * apdu, uint8_t invoke_id, - BACNET_PRIVATE_TRANSFER_DATA *private_data) + BACNET_PRIVATE_TRANSFER_DATA * private_data) { int len = 0; /* length of each encoding */ int apdu_len = 0; /* total length of the apdu, return value */ @@ -269,7 +274,7 @@ int ptransfer_ack_encode_apdu( if (apdu) { apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */ apdu[1] = invoke_id; /* original invoke id from request */ - apdu[2] = SERVICE_CONFIRMED_PRIVATE_TRANSFER; /* service choice */ + apdu[2] = SERVICE_CONFIRMED_PRIVATE_TRANSFER; /* service choice */ apdu_len = 3; /* service ack follows */ /* @@ -279,10 +284,12 @@ int ptransfer_ack_encode_apdu( resultBlock [2] ABSTRACT-SYNTAX.&Type OPTIONAL } */ - len = encode_context_unsigned(&apdu[apdu_len], 0, + len = + encode_context_unsigned(&apdu[apdu_len], 0, private_data->vendorID); apdu_len += len; - len = encode_context_unsigned(&apdu[apdu_len], 1, + len = + encode_context_unsigned(&apdu[apdu_len], 1, private_data->serviceNumber); apdu_len += len; len = encode_opening_tag(&apdu[apdu_len], 2); @@ -311,7 +318,7 @@ int ptransfer_decode_apdu( uint8_t * apdu, unsigned apdu_len, uint8_t * invoke_id, - BACNET_PRIVATE_TRANSFER_DATA *private_data) + BACNET_PRIVATE_TRANSFER_DATA * private_data) { int len = 0; unsigned offset = 0; @@ -323,16 +330,17 @@ int ptransfer_decode_apdu( return -1; /* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */ /* invoke id - filled in by net layer */ - *invoke_id = apdu[2]; + *invoke_id = apdu[2]; if (apdu[3] != SERVICE_CONFIRMED_PRIVATE_TRANSFER) return -1; offset = 4; if (apdu_len > offset) { - len = ptransfer_decode_service_request( - &apdu[offset], apdu_len - offset, private_data); + len = + ptransfer_decode_service_request(&apdu[offset], apdu_len - offset, + private_data); } - + return len; } @@ -340,7 +348,7 @@ int ptransfer_ack_decode_apdu( uint8_t * apdu, int apdu_len, /* total length of the apdu */ uint8_t * invoke_id, - BACNET_PRIVATE_TRANSFER_DATA *private_data) + BACNET_PRIVATE_TRANSFER_DATA * private_data) { int len = 0; int offset = 0; @@ -356,8 +364,8 @@ int ptransfer_ack_decode_apdu( offset = 3; if (apdu_len > offset) { len = - ptransfer_decode_service_request( - &apdu[offset], apdu_len - offset, private_data); + ptransfer_decode_service_request(&apdu[offset], apdu_len - offset, + private_data); } return len; @@ -369,7 +377,7 @@ int ptransfer_error_decode_apdu( uint8_t * invoke_id, BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code, - BACNET_PRIVATE_TRANSFER_DATA *private_data) + BACNET_PRIVATE_TRANSFER_DATA * private_data) { int len = 0; int offset = 0; @@ -385,16 +393,15 @@ int ptransfer_error_decode_apdu( offset = 3; if (apdu_len > offset) { len = - ptransfer_error_decode_service_request( - &apdu[offset], apdu_len - offset, - error_class, error_code, private_data); + ptransfer_error_decode_service_request(&apdu[offset], + apdu_len - offset, error_class, error_code, private_data); } return len; } void test_Private_Transfer_Ack( - Test * pTest) + Test * pTest) { uint8_t apdu[480] = { 0 }; int len = 0; @@ -405,19 +412,17 @@ void test_Private_Transfer_Ack( BACNET_PRIVATE_TRANSFER_DATA test_data; uint8_t test_value[480] = { 0 }; int private_data_len = 0; - uint8_t private_data_chunk[32] = {"I Love You, Patricia!"}; + uint8_t private_data_chunk[32] = { "I Love You, Patricia!" }; BACNET_APPLICATION_DATA_VALUE data_value; BACNET_APPLICATION_DATA_VALUE test_data_value; private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - bacapp_parse_application_data( - BACNET_APPLICATION_TAG_OCTET_STRING, + bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, &private_data_chunk[0], &data_value); - private_data_len = bacapp_encode_application_data( - &test_value[0], - &data_value); + private_data_len = + bacapp_encode_application_data(&test_value[0], &data_value); private_data.serviceParameters = &test_value[0]; private_data.serviceParametersLen = private_data_len; @@ -427,24 +432,23 @@ void test_Private_Transfer_Ack( ct_test(pTest, len != 0); ct_test(pTest, len != -1); apdu_len = len; - len = ptransfer_ack_decode_apdu( - &apdu[0], apdu_len, - &test_invoke_id, &test_data); + len = + ptransfer_ack_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_data); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_data.vendorID == private_data.vendorID); ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber); - ct_test(pTest, + ct_test(pTest, test_data.serviceParametersLen == private_data.serviceParametersLen); - len = bacapp_decode_application_data( - test_data.serviceParameters, - test_data.serviceParametersLen, - &test_data_value); + len = + bacapp_decode_application_data(test_data.serviceParameters, + test_data.serviceParametersLen, &test_data_value); ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true); } void test_Private_Transfer_Error( - Test * pTest) + Test * pTest) { uint8_t apdu[480] = { 0 }; int len = 0; @@ -459,49 +463,45 @@ void test_Private_Transfer_Error( BACNET_PRIVATE_TRANSFER_DATA test_data; uint8_t test_value[480] = { 0 }; int private_data_len = 0; - uint8_t private_data_chunk[32] = {"I Love You, Patricia!"}; + uint8_t private_data_chunk[32] = { "I Love You, Patricia!" }; BACNET_APPLICATION_DATA_VALUE data_value; BACNET_APPLICATION_DATA_VALUE test_data_value; private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - bacapp_parse_application_data( - BACNET_APPLICATION_TAG_OCTET_STRING, + bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, &private_data_chunk[0], &data_value); - private_data_len = bacapp_encode_application_data( - &test_value[0], - &data_value); + private_data_len = + bacapp_encode_application_data(&test_value[0], &data_value); private_data.serviceParameters = &test_value[0]; private_data.serviceParametersLen = private_data_len; - len = ptransfer_error_encode_apdu(&apdu[0], invoke_id, - error_class, error_code, &private_data); + len = + ptransfer_error_encode_apdu(&apdu[0], invoke_id, error_class, + error_code, &private_data); ct_test(pTest, len != 0); ct_test(pTest, len != -1); apdu_len = len; - len = ptransfer_error_decode_apdu( - &apdu[0], apdu_len, - &test_invoke_id, - &test_error_class, &test_error_code, - &test_data); + len = + ptransfer_error_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, + &test_error_class, &test_error_code, &test_data); ct_test(pTest, len != -1); ct_test(pTest, test_invoke_id == invoke_id); ct_test(pTest, test_data.vendorID == private_data.vendorID); ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber); ct_test(pTest, test_error_class == error_class); ct_test(pTest, test_error_code == error_code); - ct_test(pTest, + ct_test(pTest, test_data.serviceParametersLen == private_data.serviceParametersLen); - len = bacapp_decode_application_data( - test_data.serviceParameters, - test_data.serviceParametersLen, - &test_data_value); + len = + bacapp_decode_application_data(test_data.serviceParameters, + test_data.serviceParametersLen, &test_data_value); ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true); } void test_Private_Transfer_Request( - Test * pTest) + Test * pTest) { uint8_t apdu[480] = { 0 }; uint8_t test_value[480] = { 0 }; @@ -510,7 +510,7 @@ void test_Private_Transfer_Request( uint8_t invoke_id = 128; uint8_t test_invoke_id = 0; int private_data_len = 0; - uint8_t private_data_chunk[32] = {"I Love You, Patricia!"}; + uint8_t private_data_chunk[32] = { "I Love You, Patricia!" }; BACNET_APPLICATION_DATA_VALUE data_value; BACNET_APPLICATION_DATA_VALUE test_data_value; BACNET_PRIVATE_TRANSFER_DATA private_data; @@ -519,28 +519,26 @@ void test_Private_Transfer_Request( private_data.vendorID = BACNET_VENDOR_ID; private_data.serviceNumber = 1; - bacapp_parse_application_data( - BACNET_APPLICATION_TAG_OCTET_STRING, + bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, &private_data_chunk[0], &data_value); - private_data_len = bacapp_encode_application_data( - &test_value[0], - &data_value); + private_data_len = + bacapp_encode_application_data(&test_value[0], &data_value); private_data.serviceParameters = &test_value[0]; private_data.serviceParametersLen = private_data_len; len = ptransfer_encode_apdu(&apdu[0], invoke_id, &private_data); ct_test(pTest, len != 0); apdu_len = len; - len = ptransfer_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_data); + len = + ptransfer_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_data); ct_test(pTest, len != -1); ct_test(pTest, test_data.vendorID == private_data.vendorID); ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber); - ct_test(pTest, + ct_test(pTest, test_data.serviceParametersLen == private_data.serviceParametersLen); - len = bacapp_decode_application_data( - test_data.serviceParameters, - test_data.serviceParametersLen, - &test_data_value); + len = + bacapp_decode_application_data(test_data.serviceParameters, + test_data.serviceParametersLen, &test_data_value); ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true); return; @@ -548,7 +546,7 @@ void test_Private_Transfer_Request( #ifdef TEST_PRIVATE_TRANSFER int main( - void) + void) { Test *pTest; bool rc; diff --git a/bacnet-stack/src/rp.c b/bacnet-stack/src/rp.c index 4e2d0cdb..b1e8ab25 100644 --- a/bacnet-stack/src/rp.c +++ b/bacnet-stack/src/rp.c @@ -82,7 +82,7 @@ int rp_decode_service_request( uint8_t tag_number = 0; uint32_t len_value_type = 0; uint16_t type = 0; /* for decoding */ - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ uint32_t array_value = 0; /* for decoding */ /* check for value pointers */ @@ -215,7 +215,7 @@ int rp_ack_decode_service_request( int tag_len = 0; /* length of tag decode */ int len = 0; /* total length of decodes */ uint16_t object = 0; /* object type */ - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ uint32_t array_value = 0; /* for decoding */ /* FIXME: check apdu_len against the len during decode */ @@ -247,7 +247,7 @@ int rp_ack_decode_service_request( len++; /* don't decode the application tag number or its data here */ rpdata->application_data = &apdu[len]; - rpdata->application_data_len = apdu_len - len - 1 /*closing tag */; + rpdata->application_data_len = apdu_len - len - 1 /*closing tag */ ; /* len includes the data and the closing tag */ len = apdu_len; } else { diff --git a/bacnet-stack/src/rpm.c b/bacnet-stack/src/rpm.c index 5d201e11..cccea93e 100644 --- a/bacnet-stack/src/rpm.c +++ b/bacnet-stack/src/rpm.c @@ -119,8 +119,9 @@ int rpm_encode_apdu( BACNET_PROPERTY_REFERENCE *rpm_property; /* current property */ len = rpm_encode_apdu_init(&apdu_temp[0], invoke_id); - len = (int)memcopy(&apdu[0], &apdu_temp[0], - (size_t)apdu_len, (size_t)len, (size_t)max_apdu); + len = + (int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, (size_t) len, + (size_t) max_apdu); if (len == 0) { return 0; } @@ -130,16 +131,18 @@ int rpm_encode_apdu( len = encode_context_object_id(&apdu_temp[0], 0, rpm_object->object_type, rpm_object->object_instance); - len = (int)memcopy(&apdu[0], &apdu_temp[0], - (size_t)apdu_len, (size_t)len, (size_t)max_apdu); + len = + (int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, + (size_t) len, (size_t) max_apdu); if (len == 0) { return 0; } apdu_len += len; /* Tag 1: sequence of ReadAccessSpecification */ len = encode_opening_tag(&apdu_temp[0], 1); - len = (int)memcopy(&apdu[0], &apdu_temp[0], - (size_t)apdu_len, (size_t)len, (size_t)max_apdu); + len = + (int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, + (size_t) len, (size_t) max_apdu); if (len == 0) { return 0; } @@ -150,8 +153,9 @@ int rpm_encode_apdu( len = encode_context_enumerated(&apdu_temp[0], 0, rpm_property->propertyIdentifier); - len = (int)memcopy(&apdu[0], &apdu_temp[0], - (size_t)apdu_len, (size_t)len, (size_t)max_apdu); + len = + (int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, + (size_t) len, (size_t) max_apdu); if (len == 0) { return 0; } @@ -161,8 +165,9 @@ int rpm_encode_apdu( len = encode_context_unsigned(&apdu_temp[0], 1, rpm_property->propertyArrayIndex); - len = (int)memcopy(&apdu[0], &apdu_temp[0], - (size_t)apdu_len, (size_t)len, (size_t)max_apdu); + len = + (int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, + (size_t) len, (size_t) max_apdu); if (len == 0) { return 0; } @@ -171,8 +176,9 @@ int rpm_encode_apdu( rpm_property = rpm_property->next; } len = encode_closing_tag(&apdu_temp[0], 1); - len = (int)memcopy(&apdu[0], &apdu_temp[0], - (size_t)apdu_len, (size_t)len, (size_t)max_apdu); + len = + (int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, + (size_t) len, (size_t) max_apdu); if (len == 0) { return 0; } @@ -242,7 +248,7 @@ int rpm_decode_object_property( unsigned option_len = 0; uint8_t tag_number = 0; uint32_t len_value_type = 0; - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ uint32_t array_value = 0; /* for decoding */ /* check for valid pointers */ @@ -261,8 +267,9 @@ int rpm_decode_object_property( /* Tag 1: Optional propertyArrayIndex */ if ((len < apdu_len) && decode_is_context_specific(&apdu[len]) && (!decode_is_closing_tag(&apdu[len]))) { - option_len = (unsigned)decode_tag_number_and_value( - &apdu[len], &tag_number, &len_value_type); + option_len = + (unsigned) decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number == 1) { len += option_len; len += @@ -434,7 +441,7 @@ int rpm_ack_decode_object_property( unsigned tag_len = 0; uint8_t tag_number = 0; uint32_t len_value_type = 0; - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ uint32_t array_value = 0; /* for decoding */ /* check for valid pointers */ @@ -453,8 +460,9 @@ int rpm_ack_decode_object_property( /* Tag 3: Optional propertyArrayIndex */ if ((len < apdu_len) && decode_is_context_specific(&apdu[len]) && (!decode_is_closing_tag(&apdu[len]))) { - tag_len = (unsigned)decode_tag_number_and_value( - &apdu[len], &tag_number, &len_value_type); + tag_len = + (unsigned) decode_tag_number_and_value(&apdu[len], &tag_number, + &len_value_type); if (tag_number == 3) { len += tag_len; len += diff --git a/bacnet-stack/src/whohas.c b/bacnet-stack/src/whohas.c index b93e9b06..373392d0 100644 --- a/bacnet-stack/src/whohas.c +++ b/bacnet-stack/src/whohas.c @@ -69,7 +69,7 @@ int whohas_encode_apdu( } else { len = encode_context_object_id(&apdu[apdu_len], 2, - (int)data->object.identifier.type, + (int) data->object.identifier.type, data->object.identifier.instance); apdu_len += len; } diff --git a/bacnet-stack/src/wp.c b/bacnet-stack/src/wp.c index 8a5ab7ff..829ffaa2 100644 --- a/bacnet-stack/src/wp.c +++ b/bacnet-stack/src/wp.c @@ -100,7 +100,7 @@ int wp_decode_service_request( uint8_t tag_number = 0; uint32_t len_value_type = 0; uint16_t type = 0; /* for decoding */ - uint32_t property = 0; /* for decoding */ + uint32_t property = 0; /* for decoding */ uint32_t unsigned_value = 0; int i = 0; /* loop counter */