diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index 5c7e7d23..c7bddf9b 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -61,12 +61,11 @@ static uint8_t RxBuffer[MAX_MPDU]; static uint8_t TxBuffer[MAX_MPDU]; /* statistics derived from monitoring the network for each node */ -struct mstp_statistics -{ +struct mstp_statistics { /* counts how many times the node passes the token */ - uint32_t token_count; + uint32_t token_count; /* counts how many times the node gets a second token */ - uint32_t token_retries; + uint32_t token_retries; /* delay after poll for master */ uint32_t tusage_timeout; /* highest number MAC during poll for master */ @@ -90,8 +89,8 @@ static uint32_t timeval_diff_ms( uint32_t ms = 0; /* convert to milliseconds */ - ms = (now->tv_sec-old->tv_sec)*1000+ - (now->tv_usec-old->tv_usec)/1000; + ms = (now->tv_sec - old->tv_sec) * 1000 + (now->tv_usec - + old->tv_usec) / 1000; return ms; } @@ -100,7 +99,7 @@ static void packet_statistics( struct timeval *tv, volatile struct mstp_port_struct_t *mstp_port) { - static struct timeval old_tv = {0}; + static struct timeval old_tv = { 0 }; static uint8_t old_frame = 255; static uint8_t old_src = 255; static uint8_t old_dst = 255; @@ -189,39 +188,38 @@ static void packet_statistics( old_tv.tv_usec = tv->tv_usec; } -static void packet_statistics_save(void) +static void packet_statistics_save( + void) { unsigned i; /* loop counter */ fprintf(stdout, "\r\n"); /* separate with tabs (8) keep words under 8 characters */ - fprintf(stdout, + fprintf(stdout, "MAC\tMaxMstr\tTokens\tRetries\tTreply" "\tTusage\tTrpfm\tTder\tTpostpd"); fprintf(stdout, "\r\n"); for (i = 0; i < 256; i++) { /* check for masters or slaves */ - if ((MSTP_Statistics[i].token_count) || - (MSTP_Statistics[i].der_reply)) { + if ((MSTP_Statistics[i].token_count) || (MSTP_Statistics[i].der_reply)) { fprintf(stdout, "%u\t%u", i, - (unsigned)MSTP_Statistics[i].max_master); - fprintf(stdout, - "\t%lu\t%lu\t%lu\t%lu", - (long unsigned int)MSTP_Statistics[i].token_count, - (long unsigned int)MSTP_Statistics[i].token_retries, - (long unsigned int)MSTP_Statistics[i].token_reply, - (long unsigned int)MSTP_Statistics[i].tusage_timeout); - fprintf(stdout, - "\t%lu\t%lu\t%lu", - (long unsigned int)MSTP_Statistics[i].pfm_reply, - (long unsigned int)MSTP_Statistics[i].der_reply, - (long unsigned int)MSTP_Statistics[i].reply_postponed); + (unsigned) MSTP_Statistics[i].max_master); + fprintf(stdout, "\t%lu\t%lu\t%lu\t%lu", + (long unsigned int) MSTP_Statistics[i].token_count, + (long unsigned int) MSTP_Statistics[i].token_retries, + (long unsigned int) MSTP_Statistics[i].token_reply, + (long unsigned int) MSTP_Statistics[i].tusage_timeout); + fprintf(stdout, "\t%lu\t%lu\t%lu", + (long unsigned int) MSTP_Statistics[i].pfm_reply, + (long unsigned int) MSTP_Statistics[i].der_reply, + (long unsigned int) MSTP_Statistics[i].reply_postponed); fprintf(stdout, "\r\n"); } } } -static void packet_statistics_clear(void) +static void packet_statistics_clear( + void) { unsigned i; /* loop counter */ @@ -247,7 +245,7 @@ static uint16_t Timer_Silence( delta_time = 0xFFFF; } - return (uint16_t)delta_time; + return (uint16_t) delta_time; } static void Timer_Silence_Reset( @@ -391,7 +389,8 @@ static void cleanup( } #if defined(_WIN32) -static BOOL WINAPI CtrlCHandler(DWORD dwCtrlType) +static BOOL WINAPI CtrlCHandler( + DWORD dwCtrlType) { dwCtrlType = dwCtrlType; exit(0); @@ -472,10 +471,8 @@ int main( RS485_Interface(), (long) RS485_Get_Baud_Rate()); atexit(cleanup); #if defined(_WIN32) - SetConsoleMode( - GetStdHandle(STD_INPUT_HANDLE), - ENABLE_PROCESSED_INPUT); - SetConsoleCtrlHandler( (PHANDLER_ROUTINE)CtrlCHandler, TRUE ); + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_PROCESSED_INPUT); + SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlCHandler, TRUE); #else signal_init(); #endif diff --git a/bacnet-stack/demo/object/ai.c b/bacnet-stack/demo/object/ai.c index 9211ae29..9ae38da9 100644 --- a/bacnet-stack/demo/object/ai.c +++ b/bacnet-stack/demo/object/ai.c @@ -175,7 +175,8 @@ int Analog_Input_Encode_Property_APDU( 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: diff --git a/bacnet-stack/demo/object/av.c b/bacnet-stack/demo/object/av.c index f225d38d..0c90d1c2 100644 --- a/bacnet-stack/demo/object/av.c +++ b/bacnet-stack/demo/object/av.c @@ -377,10 +377,8 @@ bool Analog_Value_Write_Property( /* Command priority 6 is reserved for use by Minimum On/Off algorithm and may not be used for other purposes in any object. */ - if (Analog_Value_Present_Value_Set( - wp_data->object_instance, - value.type.Real, - wp_data->priority)) { + if (Analog_Value_Present_Value_Set(wp_data->object_instance, + value.type.Real, wp_data->priority)) { status = true; } else if (wp_data->priority == 6) { /* Command priority 6 is reserved for use by Minimum On/Off diff --git a/bacnet-stack/demo/object/bo.c b/bacnet-stack/demo/object/bo.c index b33b70ac..69491457 100644 --- a/bacnet-stack/demo/object/bo.c +++ b/bacnet-stack/demo/object/bo.c @@ -285,12 +285,12 @@ int Binary_Output_Encode_Property_APDU( object_index = Binary_Output_Instance_To_Index(object_instance); if (array_index <= BACNET_MAX_PRIORITY) { - if (Binary_Output_Level[object_index][array_index-1] == + if (Binary_Output_Level[object_index][array_index - 1] == BINARY_NULL) len = encode_application_null(&apdu[apdu_len]); else { present_value = - Binary_Output_Level[object_index][array_index-1]; + Binary_Output_Level[object_index][array_index - 1]; len = encode_application_enumerated(&apdu[apdu_len], present_value); diff --git a/bacnet-stack/demo/readprop/main.c b/bacnet-stack/demo/readprop/main.c index 5018e2c2..83a20f5c 100644 --- a/bacnet-stack/demo/readprop/main.c +++ b/bacnet-stack/demo/readprop/main.c @@ -245,10 +245,10 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - if(!found){ - found = - address_bind_request(Target_Device_Object_Instance, &max_apdu, - &Target_Address); + if (!found) { + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); } if (found) { if (invoke_id == 0) { diff --git a/bacnet-stack/demo/readpropm/main.c b/bacnet-stack/demo/readpropm/main.c index f23a0538..e7a67b5e 100644 --- a/bacnet-stack/demo/readpropm/main.c +++ b/bacnet-stack/demo/readpropm/main.c @@ -321,7 +321,7 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - if(!found){ + if (!found) { found = address_bind_request(Target_Device_Object_Instance, &max_apdu, &Target_Address); diff --git a/bacnet-stack/demo/ucov/main.c b/bacnet-stack/demo/ucov/main.c index 38ab4e1a..95cc8528 100644 --- a/bacnet-stack/demo/ucov/main.c +++ b/bacnet-stack/demo/ucov/main.c @@ -67,14 +67,17 @@ static void Init_Service_Handlers( handler_read_property); } -int main(int argc, char *argv[]) { +int main( + int argc, + char *argv[]) +{ char *value_string = NULL; bool status = false; BACNET_COV_DATA cov_data; BACNET_PROPERTY_VALUE value_list; uint8_t tag; - if (argc < 7) { + 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" diff --git a/bacnet-stack/demo/whois/main.c b/bacnet-stack/demo/whois/main.c index 236a8f0f..3eddb871 100644 --- a/bacnet-stack/demo/whois/main.c +++ b/bacnet-stack/demo/whois/main.c @@ -67,7 +67,8 @@ void MyAbortHandler( (void) src; (void) invoke_id; (void) server; - fprintf(stderr,"BACnet Abort: %s\r\n", bactext_abort_reason_name(abort_reason)); + fprintf(stderr, "BACnet Abort: %s\r\n", + bactext_abort_reason_name(abort_reason)); Error_Detected = true; } @@ -79,7 +80,8 @@ void MyRejectHandler( /* FIXME: verify src and invoke id */ (void) src; (void) invoke_id; - fprintf(stderr, "BACnet Reject: %s\r\n", bactext_reject_reason_name(reject_reason)); + fprintf(stderr, "BACnet Reject: %s\r\n", + bactext_reject_reason_name(reject_reason)); Error_Detected = true; } @@ -111,14 +113,16 @@ static void print_address_cache( unsigned max_apdu = 0; /* printf("%-7s %-14s %-4s %-5s %-14s\n", "Device", "MAC", "APDU", "SNET", "SADR"); */ - printf(";%-7s %-17s %-5s %-17s %-4s\n", "Device", "MAC", "SNET", "SADR", "APDU"); + printf(";%-7s %-17s %-5s %-17s %-4s\n", "Device", "MAC", "SNET", "SADR", + "APDU"); printf(";------- ----------------- ----- ----------------- ----\n"); for (i = 0; i < MAX_ADDRESS_CACHE; i++) { if (address_get_by_index(i, &device_id, &max_apdu, &address)) { printf(" %-7u ", device_id); for (j = 0; j < MAX_MAC_LEN; j++) { if (j < address.mac_len) { - if(j > 0) printf(":"); + if (j > 0) + printf(":"); printf("%02X", address.mac[j]); } else { printf(" "); @@ -128,20 +132,21 @@ static void print_address_cache( if (address.net) { for (j = 0; j < MAX_MAC_LEN; j++) { if (j < address.len) { - if(j > 0) printf(":"); + if (j > 0) + printf(":"); printf("%02X", address.adr[j]); } else { printf(" "); } /*printf(" "); */ } - }else{ + } else { printf("0 "); for (j = 2; j < MAX_MAC_LEN; j++) { - printf (" "); + printf(" "); } printf(""); - } + } printf("%-4hu ", max_apdu); printf("\n"); } diff --git a/bacnet-stack/demo/writeprop/main.c b/bacnet-stack/demo/writeprop/main.c index 2cce4616..432e4b6e 100644 --- a/bacnet-stack/demo/writeprop/main.c +++ b/bacnet-stack/demo/writeprop/main.c @@ -434,7 +434,7 @@ int main(int argc, char *argv[]) { if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - if(!found){ + if (!found) { found = address_bind_request(Target_Device_Object_Instance, &max_apdu, &Target_Address); diff --git a/bacnet-stack/include/av.h b/bacnet-stack/include/av.h index 1b2b9fa0..1a31b523 100644 --- a/bacnet-stack/include/av.h +++ b/bacnet-stack/include/av.h @@ -63,16 +63,16 @@ extern "C" { BACNET_WRITE_PROPERTY_DATA * wp_data, BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code); - + bool Analog_Value_Present_Value_Set( uint32_t object_instance, float value, uint8_t priority); float Analog_Value_Present_Value( uint32_t object_instance); - + void Analog_Value_Init( - void); + void); #ifdef TEST #include "ctest.h" diff --git a/bacnet-stack/include/mstp.h b/bacnet-stack/include/mstp.h index ebef55b2..7ca9da6b 100644 --- a/bacnet-stack/include/mstp.h +++ b/bacnet-stack/include/mstp.h @@ -219,5 +219,4 @@ extern "C" { #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/adc.c b/bacnet-stack/ports/bdk-atxx4-mstp/adc.c index dc00d5ea..658ef8f1 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/adc.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/adc.c @@ -27,22 +27,22 @@ /* prescale select bits */ #if (F_CPU >> 1) < 1000000 - #define ADPS_8BIT (1) - #define ADPS_10BIT (3) +#define ADPS_8BIT (1) +#define ADPS_10BIT (3) #elif (F_CPU >> 2) < 1000000 - #define ADPS_8BIT (2) - #define ADPS_10BIT (4) +#define ADPS_8BIT (2) +#define ADPS_10BIT (4) #elif (F_CPU >> 3) < 1000000 - #define ADPS_8BIT (3) - #define ADPS_10BIT (5) +#define ADPS_8BIT (3) +#define ADPS_10BIT (5) #elif (F_CPU >> 4) < 1000000 - #define ADPS_8BIT (4) - #define ADPS_10BIT (6) +#define ADPS_8BIT (4) +#define ADPS_10BIT (6) #elif (F_CPU >> 5) < 1000000 - #define ADPS_8BIT (5) - #define ADPS_10BIT (7) +#define ADPS_8BIT (5) +#define ADPS_10BIT (7) #else - #error "ADC: F_CPU too large for accuracy." +#error "ADC: F_CPU too large for accuracy." #endif /* we could have array of ADC results */ @@ -55,37 +55,38 @@ ISR(ADC_vect) } uint8_t adc_result( - uint8_t channel) /* 0..7 = ADC0..ADC7, respectively */ -{ + uint8_t channel) +{ /* 0..7 = ADC0..ADC7, respectively */ return Sample_Result; } -void adc_init(void) +void adc_init( + void) { /* set prescaler */ ADCSRA |= ADPS_8BIT; /* Initial channel selection */ /* ADLAR = Left Adjust Result REFSx = hardware setup: cap on AREF - */ - ADMUX = 7 /* channel */ | (1 << ADLAR) | (0 << REFS1) | (1 << REFS0); + */ + ADMUX = 7 /* channel */ | (1 << ADLAR) | (0 << REFS1) | (1 << REFS0); /* ADEN = Enable - ADSC = Start conversion - ADIF = Interrupt Flag - ADIE = Interrupt Enable - ADATE = Auto Trigger Enable - */ + ADSC = Start conversion + ADIF = Interrupt Flag + ADIE = Interrupt Enable + ADATE = Auto Trigger Enable + */ ADCSRA |= (1 << ADEN) | (1 << ADIE) | (1 << ADIF) | (1 << ADATE); /* trigger selection bits - 0 0 0 Free Running mode - 0 0 1 Analog Comparator - 0 1 0 External Interrupt Request 0 - 0 1 1 Timer/Counter0 Compare Match - 1 0 0 Timer/Counter0 Overflow - 1 0 1 Timer/Counter1 Compare Match B - 1 1 0 Timer/Counter1 Overflow - 1 1 1 Timer/Counter1 Capture Event - */ + 0 0 0 Free Running mode + 0 0 1 Analog Comparator + 0 1 0 External Interrupt Request 0 + 0 1 1 Timer/Counter0 Compare Match + 1 0 0 Timer/Counter0 Overflow + 1 0 1 Timer/Counter1 Compare Match B + 1 1 0 Timer/Counter1 Overflow + 1 1 1 Timer/Counter1 Capture Event + */ ADCSRB |= (0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0); /* start the conversions */ ADCSRA |= (1 << ADSC); diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/adc.h b/bacnet-stack/ports/bdk-atxx4-mstp/adc.h index c44d76c0..3958cc5b 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/adc.h +++ b/bacnet-stack/ports/bdk-atxx4-mstp/adc.h @@ -30,11 +30,12 @@ extern "C" { #endif /* __cplusplus */ -uint8_t adc_result(uint8_t channel); -void adc_init(void); + uint8_t adc_result( + uint8_t channel); + void adc_init( + void); #ifdef __cplusplus } #endif /* __cplusplus */ - #endif diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/av.c b/bacnet-stack/ports/bdk-atxx4-mstp/av.c index 2562e650..9645bb24 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/av.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/av.c @@ -29,9 +29,9 @@ #include #include #if defined(__GNUC__) && (__GNUC__ > 4) && (__GNUC_MINOR__ > 2) - #include /* for NAN */ +#include /* for NAN */ #else - #define NAN __builtin_nan("") +#define NAN __builtin_nan("") #endif #include "bacdef.h" @@ -209,7 +209,7 @@ int Analog_Value_Encode_Property_APDU( unsigned i = 0; bool state = false; #endif - + switch (property) { case PROP_OBJECT_IDENTIFIER: apdu_len = @@ -346,10 +346,8 @@ bool Analog_Value_Write_Property( switch (wp_data->object_property) { case PROP_PRESENT_VALUE: if (value.tag == BACNET_APPLICATION_TAG_REAL) { - if (Analog_Value_Present_Value_Set( - wp_data->object_instance, - value.type.Real, - wp_data->priority)) { + if (Analog_Value_Present_Value_Set(wp_data->object_instance, + value.type.Real, wp_data->priority)) { status = true; } else if (wp_data->priority == 6) { /* Command priority 6 is reserved for use by Minimum On/Off @@ -363,10 +361,8 @@ bool Analog_Value_Write_Property( } #if 0 } else if (value.tag == BACNET_APPLICATION_TAG_NULL) { - if (Analog_Value_Present_Value_Set( - wp_data->object_instance, - NAN, - wp_data->priority)) { + if (Analog_Value_Present_Value_Set(wp_data->object_instance, + NAN, wp_data->priority)) { status = true; } else { *error_class = ERROR_CLASS_PROPERTY; diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/bi.c b/bacnet-stack/ports/bdk-atxx4-mstp/bi.c index 71dd69e2..b40034a6 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/bi.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/bi.c @@ -157,7 +157,7 @@ bool Binary_Input_Present_Value_Set( } return true; } - + return false; } diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/bo.c b/bacnet-stack/ports/bdk-atxx4-mstp/bo.c index 23089a0a..cceb186f 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/bo.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/bo.c @@ -175,7 +175,7 @@ static BACNET_BINARY_PV Present_Value( BACNET_BINARY_PV value = RELINQUISH_DEFAULT; BACNET_BINARY_PV current_value = RELINQUISH_DEFAULT; unsigned i = 0; - + if (index < MAX_BINARY_OUTPUTS) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) { current_value = Binary_Output_Level[index][i]; @@ -203,7 +203,7 @@ void Binary_Output_Level_Sync( unsigned int index) { BACNET_BINARY_PV pv; - + if (index < MAX_BINARY_OUTPUTS) { if (Out_Of_Service[index]) { return; @@ -351,7 +351,7 @@ int Binary_Output_Encode_Property_APDU( Binary_Output_Instance_To_Index(object_instance); if (array_index <= BACNET_MAX_PRIORITY) { present_value = - Binary_Output_Level[object_index][array_index-1]; + Binary_Output_Level[object_index][array_index - 1]; if (present_value == BINARY_NULL) { len = encode_application_null(&apdu[apdu_len]); } else { diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/fuses.c b/bacnet-stack/ports/bdk-atxx4-mstp/fuses.c index 3aea8234..6e6604d2 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/fuses.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/fuses.c @@ -33,31 +33,30 @@ FUSES = { /* note: fuses are enabled by clearing the bit, so any fuses listed below are cleared fuses. */ .low = (FUSE_CKSEL3 & FUSE_SUT0 & FUSE_SUT1), - - /* BOOTSZ configuration: - BOOTSZ1 BOOTSZ0 Boot Size - ------- ------- --------- - 1 1 512 - 1 0 1024 - 0 1 2048 - 0 0 4096 - */ - /* note: fuses are enabled by clearing the bit, so - any fuses listed below are cleared fuses. */ - .high = - (FUSE_BOOTSZ1 & FUSE_BOOTRST & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN), - /* Brown-out detection VCC=2.7V */ - /* BODLEVEL configuration - BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage - --------- --------- --------- -------- - 1 1 1 disabled - 1 1 0 1.8V - 1 0 1 2.7V - 1 0 0 4.3V - */ - /* note: fuses are enabled by clearing the bit, so - any fuses listed below are cleared fuses. */ - .extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0) + /* BOOTSZ configuration: + BOOTSZ1 BOOTSZ0 Boot Size + ------- ------- --------- + 1 1 512 + 1 0 1024 + 0 1 2048 + 0 0 4096 + */ + /* note: fuses are enabled by clearing the bit, so + any fuses listed below are cleared fuses. */ + .high = + (FUSE_BOOTSZ1 & FUSE_BOOTRST & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN), + /* Brown-out detection VCC=2.7V */ + /* BODLEVEL configuration + BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage + --------- --------- --------- -------- + 1 1 1 disabled + 1 1 0 1.8V + 1 0 1 2.7V + 1 0 0 4.3V + */ + /* note: fuses are enabled by clearing the bit, so + any fuses listed below are cleared fuses. */ + .extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0) }; /* AVR lock bits - unlocked */ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/input.c b/bacnet-stack/ports/bdk-atxx4-mstp/input.c index becfc5d0..cef65d15 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/input.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/input.c @@ -34,7 +34,8 @@ static uint8_t Buttons; #if BDK_V1_HACK /* version 1 BDK workaournd for floating inputs */ -static void input_switch_workaround(void) +static void input_switch_workaround( + void) { /* configure the port pins for the switch - as outputs */ BIT_SET(DDRA, DDA0); @@ -60,7 +61,7 @@ static void input_switch_workaround(void) BIT_CLEAR(DDRA, DDA4); BIT_CLEAR(DDRA, DDA5); BIT_CLEAR(DDRA, DDA6); - + return; } #endif @@ -74,17 +75,17 @@ void input_task( static uint8_t old_buttons = 0; /* only check the inputs every debounce time */ - if (timer_elapsed_milliseconds(TIMER_DEBOUNCE,30)) { + if (timer_elapsed_milliseconds(TIMER_DEBOUNCE, 30)) { timer_reset(TIMER_DEBOUNCE); /* pins used are PA6, PA5, PA4, PA3, PA2, PA1, PA0 */ #if BDK_V1_HACK /* version 1 BDK - workaround */ - value = (PINA&0x7F); + value = (PINA & 0x7F); #else /* version 2 BDK - has inverted inputs */ value = ~PINA; value &= 0x7F; -#endif +#endif if (value == old_address) { /* stable value */ Address_Switch = old_address; @@ -111,7 +112,7 @@ bool input_button_value( uint8_t index) { bool value = false; - + switch (index) { case 0: value = BIT_CHECK(Buttons, 0); @@ -131,8 +132,8 @@ bool input_button_value( default: break; } - - return value; + + return value; } diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/main.c b/bacnet-stack/ports/bdk-atxx4-mstp/main.c index 26ca04a4..2b9ec178 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/main.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/main.c @@ -159,10 +159,11 @@ void idle_init( void idle_task( void) { - /* do nothing */ + /* do nothing */ } -void test_init(void) +void test_init( + void) { timer_reset(TIMER_LED_3); timer_reset(TIMER_LED_4); @@ -170,21 +171,21 @@ void test_init(void) } void test_task( - void) + void) { uint8_t buffer[32] = "BACnet: 0000000\r\n"; uint8_t nbytes = 17; uint8_t data_register = 0; - + if (timer_elapsed_seconds(TIMER_TEST, 1)) { timer_reset(TIMER_TEST); - buffer[8] = (MSTP_MAC_Address&BIT0)?'1':'0'; - buffer[9] = (MSTP_MAC_Address&BIT1)?'1':'0'; - buffer[10] = (MSTP_MAC_Address&BIT2)?'1':'0'; - buffer[11] = (MSTP_MAC_Address&BIT3)?'1':'0'; - buffer[12] = (MSTP_MAC_Address&BIT4)?'1':'0'; - buffer[13] = (MSTP_MAC_Address&BIT5)?'1':'0'; - buffer[14] = (MSTP_MAC_Address&BIT6)?'1':'0'; + buffer[8] = (MSTP_MAC_Address & BIT0) ? '1' : '0'; + buffer[9] = (MSTP_MAC_Address & BIT1) ? '1' : '0'; + buffer[10] = (MSTP_MAC_Address & BIT2) ? '1' : '0'; + buffer[11] = (MSTP_MAC_Address & BIT3) ? '1' : '0'; + buffer[12] = (MSTP_MAC_Address & BIT4) ? '1' : '0'; + buffer[13] = (MSTP_MAC_Address & BIT5) ? '1' : '0'; + buffer[14] = (MSTP_MAC_Address & BIT6) ? '1' : '0'; serial_bytes_send(buffer, nbytes); } if (serial_byte_get(&data_register)) { diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/serial.c b/bacnet-stack/ports/bdk-atxx4-mstp/serial.c index b7cf7613..fa61cd55 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/serial.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/serial.c @@ -117,7 +117,8 @@ void serial_byte_send( return; } -void serial_byte_transmit_complete(void) +void serial_byte_transmit_complete( + void) { /* was the frame sent? */ while (!BIT_CHECK(UCSR1A, TXC1)) { diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/serial.h b/bacnet-stack/ports/bdk-atxx4-mstp/serial.h index 7dcf05f6..bf7f3634 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/serial.h +++ b/bacnet-stack/ports/bdk-atxx4-mstp/serial.h @@ -38,11 +38,12 @@ extern "C" { void serial_bytes_send( uint8_t * buffer, /* data to send */ uint16_t nbytes); /* number of bytes of data */ - + /* byte transmit */ void serial_byte_send( uint8_t ch); - void serial_byte_transmit_complete(void); + void serial_byte_transmit_complete( + void); uint32_t serial_baud_rate( void); diff --git a/bacnet-stack/ports/linux/timer.c b/bacnet-stack/ports/linux/timer.c index 7a4e2db2..aaa43129 100644 --- a/bacnet-stack/ports/linux/timer.c +++ b/bacnet-stack/ports/linux/timer.c @@ -33,16 +33,18 @@ static volatile uint32_t Millisecond_Counter[MAX_MILLISECOND_TIMERS]; /* start time for the clock */ static struct timespec start; -uint32_t timeGetTime(void) +uint32_t timeGetTime( + void) { struct timespec now; uint32_t ticks; - - clock_gettime(CLOCK_MONOTONIC,&now); - - ticks = (now.tv_sec-start.tv_sec)*1000+ - (now.tv_nsec-start.tv_nsec)/1000000; - + + clock_gettime(CLOCK_MONOTONIC, &now); + + ticks = + (now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec - + start.tv_nsec) / 1000000; + return ticks; } @@ -56,7 +58,7 @@ uint32_t timer_milliseconds( { uint32_t now = timeGetTime(); uint32_t delta_time = 0; - + if (index < MAX_MILLISECOND_TIMERS) { if (Millisecond_Counter[index] <= now) { delta_time = now - Millisecond_Counter[index]; @@ -64,7 +66,7 @@ uint32_t timer_milliseconds( delta_time = (UINT32_MAX - Millisecond_Counter[index]) + now + 1; } } - + return delta_time; } @@ -89,7 +91,7 @@ bool timer_elapsed_seconds( unsigned index, uint32_t seconds) { - return ((timer_milliseconds(index)/1000) >= seconds); + return ((timer_milliseconds(index) / 1000) >= seconds); } /************************************************************************* @@ -101,7 +103,7 @@ bool timer_elapsed_minutes( unsigned index, uint32_t minutes) { - return ((timer_milliseconds(index)/(1000*60)) >= minutes); + return ((timer_milliseconds(index) / (1000 * 60)) >= minutes); } /************************************************************************* @@ -113,12 +115,12 @@ uint32_t timer_reset( unsigned index) { uint32_t timer_value = 0; - + if (index < MAX_MILLISECOND_TIMERS) { timer_value = timer_milliseconds(index); Millisecond_Counter[index] = timeGetTime(); } - + return timer_value; } @@ -130,5 +132,5 @@ uint32_t timer_reset( void timer_init( void) { - clock_gettime(CLOCK_MONOTONIC,&start); + clock_gettime(CLOCK_MONOTONIC, &start); } diff --git a/bacnet-stack/ports/linux/timer.h b/bacnet-stack/ports/linux/timer.h index 75a30c27..f08e0e1a 100644 --- a/bacnet-stack/ports/linux/timer.h +++ b/bacnet-stack/ports/linux/timer.h @@ -29,14 +29,15 @@ /* Timer Module */ #ifndef MAX_MILLISECOND_TIMERS - #define TIMER_SILENCE 0 - #define MAX_MILLISECOND_TIMERS 1 +#define TIMER_SILENCE 0 +#define MAX_MILLISECOND_TIMERS 1 #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - uint32_t timeGetTime(void); + uint32_t timeGetTime( + void); void timer_init( void); diff --git a/bacnet-stack/ports/win32/dlmstp-mm.c b/bacnet-stack/ports/win32/dlmstp-mm.c index a0b6b4eb..82c00fce 100644 --- a/bacnet-stack/ports/win32/dlmstp-mm.c +++ b/bacnet-stack/ports/win32/dlmstp-mm.c @@ -40,7 +40,7 @@ #define WIN32_LEAN_AND_MEAN #define STRICT 1 #include -#include /* for multimedia timers */ +#include /* for multimedia timers */ /* Number of MS/TP Packets Rx/Tx */ uint16_t MSTP_Packets = 0; @@ -77,7 +77,7 @@ static uint16_t Timer_Silence( delta_time = 0xFFFF; } - return (uint16_t)delta_time; + return (uint16_t) delta_time; } static void Timer_Silence_Reset( @@ -659,9 +659,10 @@ bool dlmstp_init( #endif /* set timer resolution */ if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) { - fprintf(stderr, "Failed to set timer resolution\n"); + fprintf(stderr, "Failed to set timer resolution\n"); } - TimeBeginPeriod = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax); + TimeBeginPeriod = + min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax); timeBeginPeriod(TimeBeginPeriod); /* start the threads */ diff --git a/bacnet-stack/ports/win32/timer.c b/bacnet-stack/ports/win32/timer.c index 587619ac..f03ab8ad 100644 --- a/bacnet-stack/ports/win32/timer.c +++ b/bacnet-stack/ports/win32/timer.c @@ -29,7 +29,7 @@ #define WIN32_LEAN_AND_MEAN #define STRICT 1 #include -#include +#include #include "timer.h" /* counter for the various timers */ @@ -63,7 +63,7 @@ uint32_t timer_milliseconds( { uint32_t now = timeGetTime(); uint32_t delta_time = 0; - + if (index < MAX_MILLISECOND_TIMERS) { if (Millisecond_Counter[index] <= now) { @@ -97,7 +97,7 @@ bool timer_elapsed_seconds( unsigned index, uint32_t seconds) { - return ((timer_milliseconds(index)/1000) >= seconds); + return ((timer_milliseconds(index) / 1000) >= seconds); } /************************************************************************* @@ -109,7 +109,7 @@ bool timer_elapsed_minutes( unsigned index, uint32_t minutes) { - return ((timer_milliseconds(index)/(1000*60)) >= minutes); + return ((timer_milliseconds(index) / (1000 * 60)) >= minutes); } /************************************************************************* @@ -140,7 +140,7 @@ void timer_init( /* set timer resolution */ if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) { - fprintf(stderr, "Failed to get timer resolution parameters\n"); + fprintf(stderr, "Failed to get timer resolution parameters\n"); } /* configure for 1ms resolution - if possible */ period = min(max(tc.wPeriodMin, 1), tc.wPeriodMax); diff --git a/bacnet-stack/ports/win32/timer.h b/bacnet-stack/ports/win32/timer.h index 7a42b021..80329e6a 100644 --- a/bacnet-stack/ports/win32/timer.h +++ b/bacnet-stack/ports/win32/timer.h @@ -43,8 +43,8 @@ /* Timer Module */ #ifndef MAX_MILLISECOND_TIMERS - #define TIMER_SILENCE 0 - #define MAX_MILLISECOND_TIMERS 1 +#define TIMER_SILENCE 0 +#define MAX_MILLISECOND_TIMERS 1 #endif #ifdef __cplusplus diff --git a/bacnet-stack/src/alarm_ack.c b/bacnet-stack/src/alarm_ack.c index 1d134147..8619b611 100644 --- a/bacnet-stack/src/alarm_ack.c +++ b/bacnet-stack/src/alarm_ack.c @@ -82,7 +82,7 @@ int alarm_ack_encode_service_request( len = encode_context_object_id(&apdu[apdu_len], 1, - (int)data->eventObjectIdentifier.type, + (int) data->eventObjectIdentifier.type, data->eventObjectIdentifier.instance); apdu_len += len; @@ -123,7 +123,7 @@ int alarm_ack_decode_service_request( { int len = 0; int section_len; - uint32_t enumValue; + uint32_t enumValue; if (-1 == (section_len = decode_context_unsigned(&apdu[len], 0, @@ -141,11 +141,10 @@ int alarm_ack_decode_service_request( len += section_len; if (-1 == (section_len = - decode_context_enumerated(&apdu[len], 2, - &enumValue))) { + decode_context_enumerated(&apdu[len], 2, &enumValue))) { return -1; } - data->eventTypeAcked = (BACNET_EVENT_TYPE)enumValue; + data->eventTypeAcked = (BACNET_EVENT_TYPE) enumValue; len += section_len; if (-1 == (section_len = diff --git a/bacnet-stack/src/arf.c b/bacnet-stack/src/arf.c index f527fa8a..72f18b1d 100644 --- a/bacnet-stack/src/arf.c +++ b/bacnet-stack/src/arf.c @@ -105,7 +105,7 @@ int arf_decode_service_request( if (tag_number != BACNET_APPLICATION_TAG_OBJECT_ID) return -1; len += decode_object_id(&apdu[len], &type, &data->object_instance); - data->object_type = (BACNET_OBJECT_TYPE)type; + data->object_type = (BACNET_OBJECT_TYPE) type; if (decode_is_opening_tag_number(&apdu[len], 0)) { data->access = FILE_STREAM_ACCESS; /* a tag number is not extended so only one octet */ diff --git a/bacnet-stack/src/awf.c b/bacnet-stack/src/awf.c index 8aa6262d..3583e3e5 100644 --- a/bacnet-stack/src/awf.c +++ b/bacnet-stack/src/awf.c @@ -110,7 +110,7 @@ int awf_decode_service_request( if (tag_number != BACNET_APPLICATION_TAG_OBJECT_ID) return -1; len += decode_object_id(&apdu[len], &type, &data->object_instance); - data->object_type = (BACNET_OBJECT_TYPE)type; + data->object_type = (BACNET_OBJECT_TYPE) type; if (decode_is_opening_tag_number(&apdu[len], 0)) { data->access = FILE_STREAM_ACCESS; /* a tag number of 2 is not extended so only one octet */ diff --git a/bacnet-stack/src/bacapp.c b/bacnet-stack/src/bacapp.c index 227e97e2..79418db2 100644 --- a/bacnet-stack/src/bacapp.c +++ b/bacnet-stack/src/bacapp.c @@ -744,7 +744,7 @@ bool bacapp_print_value( characterstring_value(&value->type.Character_String); fprintf(stream, "\""); for (i = 0; i < len; i++) { - if (isprint(*((unsigned char *)char_str))) { + if (isprint(*((unsigned char *) char_str))) { fprintf(stream, "%c", *char_str); } else { fprintf(stream, "."); diff --git a/bacnet-stack/src/bacdevobjpropref.c b/bacnet-stack/src/bacdevobjpropref.c index 6dda239a..da94d706 100644 --- a/bacnet-stack/src/bacdevobjpropref.c +++ b/bacnet-stack/src/bacdevobjpropref.c @@ -95,7 +95,7 @@ int bacapp_decode_device_obj_property_ref( { int len; int apdu_len = 0; - uint32_t enumValue; + uint32_t enumValue; if (-1 == (len = decode_context_object_id(&apdu[apdu_len], 0, &value->objectIdentifier.type, @@ -105,11 +105,10 @@ int bacapp_decode_device_obj_property_ref( apdu_len += len; if (-1 == (len = - decode_context_enumerated(&apdu[apdu_len], 1, - &enumValue))) { + decode_context_enumerated(&apdu[apdu_len], 1, &enumValue))) { return -1; } - value->propertyIdentifier = (BACNET_PROPERTY_ID)enumValue; + value->propertyIdentifier = (BACNET_PROPERTY_ID) enumValue; apdu_len += len; if (decode_is_context_tag(&apdu[apdu_len], 2)) { diff --git a/bacnet-stack/src/bacpropstates.c b/bacnet-stack/src/bacpropstates.c index a6f143fa..1c268301 100644 --- a/bacnet-stack/src/bacpropstates.c +++ b/bacnet-stack/src/bacpropstates.c @@ -46,7 +46,7 @@ int bacapp_decode_property_state( int len = 0; uint32_t len_value_type; int section_length; - uint32_t enumValue; + uint32_t enumValue; section_length = decode_tag_number_and_value(&apdu[len], (uint8_t *) & value->tag, @@ -68,7 +68,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.binaryValue = (BACNET_BINARY_PV)enumValue; + value->state.binaryValue = (BACNET_BINARY_PV) enumValue; break; case EVENT_TYPE: @@ -77,7 +77,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.eventType = (BACNET_EVENT_TYPE)enumValue; + value->state.eventType = (BACNET_EVENT_TYPE) enumValue; break; case POLARITY: @@ -86,7 +86,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.polarity = (BACNET_POLARITY)enumValue; + value->state.polarity = (BACNET_POLARITY) enumValue; break; case PROGRAM_CHANGE: @@ -95,7 +95,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.programChange = (BACNET_PROGRAM_REQUEST)enumValue; + value->state.programChange = (BACNET_PROGRAM_REQUEST) enumValue; break; case PROGRAM_STATE: @@ -104,7 +104,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.programState = (BACNET_PROGRAM_STATE)enumValue; + value->state.programState = (BACNET_PROGRAM_STATE) enumValue; break; case REASON_FOR_HALT: @@ -113,7 +113,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.programError = (BACNET_PROGRAM_ERROR)enumValue; + value->state.programError = (BACNET_PROGRAM_ERROR) enumValue; break; case RELIABILITY: @@ -122,7 +122,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.reliability = (BACNET_RELIABILITY)enumValue; + value->state.reliability = (BACNET_RELIABILITY) enumValue; break; case STATE: @@ -131,7 +131,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.state = (BACNET_EVENT_STATE)enumValue; + value->state.state = (BACNET_EVENT_STATE) enumValue; break; case SYSTEM_STATUS: @@ -140,7 +140,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.systemStatus = (BACNET_DEVICE_STATUS)enumValue; + value->state.systemStatus = (BACNET_DEVICE_STATUS) enumValue; break; case UNITS: @@ -149,7 +149,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.units = (BACNET_ENGINEERING_UNITS)enumValue; + value->state.units = (BACNET_ENGINEERING_UNITS) enumValue; break; case UNSIGNED_VALUE: @@ -166,7 +166,7 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.lifeSafetyMode = (BACNET_LIFE_SAFETY_MODE)enumValue; + value->state.lifeSafetyMode = (BACNET_LIFE_SAFETY_MODE) enumValue; break; case LIFE_SAFETY_STATE: @@ -175,7 +175,8 @@ int bacapp_decode_property_state( &enumValue))) { return -1; } - value->state.lifeSafetyState = (BACNET_LIFE_SAFETY_STATE)enumValue; + value->state.lifeSafetyState = + (BACNET_LIFE_SAFETY_STATE) enumValue; break; default: diff --git a/bacnet-stack/src/bvlc.c b/bacnet-stack/src/bvlc.c index a40ec2a5..f20994f5 100644 --- a/bacnet-stack/src/bvlc.c +++ b/bacnet-stack/src/bvlc.c @@ -910,7 +910,7 @@ uint16_t bvlc_receive( Register-Foreign-Device message */ /* FIXME: clients may need this result */ (void) decode_unsigned16(&npdu[4], &result_code); - BVLC_Result_Code = (BACNET_BVLC_RESULT)result_code; + BVLC_Result_Code = (BACNET_BVLC_RESULT) result_code; debug_printf("BVLC: Result Code=%d\n", BVLC_Result_Code); /* not an NPDU */ npdu_len = 0; diff --git a/bacnet-stack/src/cov.c b/bacnet-stack/src/cov.c index 901d297a..eff9ad94 100644 --- a/bacnet-stack/src/cov.c +++ b/bacnet-stack/src/cov.c @@ -238,7 +238,7 @@ int cov_notify_decode_service_request( decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); len += decode_enumerated(&apdu[len], len_value, &property); - value->propertyIdentifier = (BACNET_PROPERTY_ID)property; + value->propertyIdentifier = (BACNET_PROPERTY_ID) property; } else { return -1; } @@ -572,7 +572,8 @@ int cov_subscribe_property_decode_service_request( decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); len += decode_enumerated(&apdu[len], len_value, &property); - data->monitoredProperty.propertyIdentifier = (BACNET_PROPERTY_ID)property; + data->monitoredProperty.propertyIdentifier = + (BACNET_PROPERTY_ID) property; } else return -4; /* the optional array index is tag 1 */ diff --git a/bacnet-stack/src/event.c b/bacnet-stack/src/event.c index a70c2cc9..e2d95317 100644 --- a/bacnet-stack/src/event.c +++ b/bacnet-stack/src/event.c @@ -504,7 +504,7 @@ int event_notify_decode_service_request( decode_context_enumerated(&apdu[len], 6, &value)) == -1) { return -1; } else { - data->eventType = (BACNET_EVENT_TYPE)value; + data->eventType = (BACNET_EVENT_TYPE) value; len += section_length; } /* tag 7 - messageText */ @@ -533,7 +533,7 @@ int event_notify_decode_service_request( decode_context_enumerated(&apdu[len], 8, &value)) == -1) { return -1; } else { - data->notifyType = (BACNET_NOTIFY_TYPE)value; + data->notifyType = (BACNET_NOTIFY_TYPE) value; len += section_length; } switch (data->notifyType) { @@ -553,7 +553,7 @@ int event_notify_decode_service_request( &value)) == -1) { return -1; } else { - data->fromState = (BACNET_EVENT_STATE)value; + data->fromState = (BACNET_EVENT_STATE) value; len += section_length; } break; @@ -561,14 +561,14 @@ int event_notify_decode_service_request( /* FIXME: handle this case */ default: return -1; - + } /* tag 11 - toState */ if ((section_length = decode_context_enumerated(&apdu[len], 11, &value)) == -1) { return -1; } else { - data->toState = (BACNET_EVENT_STATE)value; + data->toState = (BACNET_EVENT_STATE) value; len += section_length; } /* tag 12 - eventValues */ @@ -750,7 +750,7 @@ int event_notify_decode_service_request( return -1; } data->notificationParams.changeOfLifeSafety.newState = - (BACNET_LIFE_SAFETY_STATE)value; + (BACNET_LIFE_SAFETY_STATE) value; len += section_length; if (-1 == (section_length = @@ -759,7 +759,7 @@ int event_notify_decode_service_request( return -1; } data->notificationParams.changeOfLifeSafety.newMode = - (BACNET_LIFE_SAFETY_MODE)value; + (BACNET_LIFE_SAFETY_MODE) value; len += section_length; if (-1 == (section_length = @@ -776,7 +776,8 @@ int event_notify_decode_service_request( return -1; } data->notificationParams.changeOfLifeSafety. - operationExpected = (BACNET_LIFE_SAFETY_OPERATION)value; + operationExpected = + (BACNET_LIFE_SAFETY_OPERATION) value; len += section_length; break; diff --git a/bacnet-stack/src/lso.c b/bacnet-stack/src/lso.c index 961431b0..cba2051c 100644 --- a/bacnet-stack/src/lso.c +++ b/bacnet-stack/src/lso.c @@ -109,7 +109,7 @@ int lso_decode_service_request( decode_context_enumerated(&apdu[len], 2, &operation)) == -1) { return -1; } - data->operation = (BACNET_LIFE_SAFETY_OPERATION)operation; + data->operation = (BACNET_LIFE_SAFETY_OPERATION) operation; len += section_length; /* diff --git a/bacnet-stack/src/tsm.c b/bacnet-stack/src/tsm.c index 22d88f93..3265bf60 100644 --- a/bacnet-stack/src/tsm.c +++ b/bacnet-stack/src/tsm.c @@ -254,7 +254,7 @@ void tsm_timer_milliseconds( TSM_List[i].RetryCount--; TSM_List[i].RequestTimer = apdu_timeout(); if (TSM_List[i].RetryCount) { - datalink_send_pdu(&TSM_List[i].dest, + datalink_send_pdu(&TSM_List[i].dest, &TSM_List[i].npdu_data, &TSM_List[i].apdu[0], TSM_List[i].apdu_len); } else {