![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: vz_protocol.cpp
- Revision:
- 132:05cd37f7e007
- Parent:
- 126:1f90756250fb
- Child:
- 135:2f4290590e51
diff -r 938ab88facae -r 05cd37f7e007 vz_protocol.cpp --- a/vz_protocol.cpp Tue Jul 21 20:03:35 2015 +0000 +++ b/vz_protocol.cpp Tue Sep 01 17:21:11 2015 +0000 @@ -8,37 +8,8 @@ int init_ranges ( void ) { - FILE * begin_ext = fopen( "/qspi/minext.txt", "r" ); - if( begin_ext == NULL ){ - if( debug_out_of_range ) debug_msg("Failed to open /qspi/minext.txt" ); - begin = MIN_EXT; - }else{ - char inner_tmp[ 20 ]; - if( fread( (void *)inner_tmp, 1, 20, begin_ext ) > 0 ){ - begin = atoi( inner_tmp ); - if( debug_out_of_range ) debug_msg("Ext Min %d", begin ); - }else{ - if( debug_out_of_range ) debug_msg("Failed to read /qspi/minext.txt" ); - begin = MIN_EXT; - } - } - fclose( begin_ext ); - - FILE * end_ext = fopen( "/qspi/maxext.txt", "r" ); - if( end_ext == NULL ){ - if( debug_out_of_range ) debug_msg("Failed to open /qspi/maxext.txt" ); - end = MAX_EXT; - }else{ - char inner_tmp[ 20 ]; - if( fread( (void *)inner_tmp, 1, 20, end_ext ) > 0 ){ - end = atoi( inner_tmp ); - if( debug_out_of_range ) debug_msg("Ext Min %d", end ); - }else{ - if( debug_out_of_range ) debug_msg("Failed to read /qspi/maxext.txt" ); - begin = MAX_EXT; - } - } - fclose( end_ext ); + begin = cm -> get_min_ext (); + end = cm -> get_max_ext (); return ( 0 ); } @@ -121,7 +92,7 @@ if ( cc != cc_calculated ) { - if ( debug_cks_err ) send_msg ( "Received PKG, but -- CKS ERROR: %d ( %d )", cc_calculated, cc ); + if ( debug_cks_err ) vz_printf ( "Received PKG, but -- CKS ERROR: %d ( %d )", cc_calculated, cc ); if ( cc_calculated == 30975 and cc == 0 ){ pkg_zero++; @@ -132,16 +103,16 @@ } else { - pkg_cksok++; - e_msb = cb_buffer[ 0 ]; - e_lsb = cb_buffer[ 1 ]; + pkg_cksok ++; + e_msb = cb_buffer [ 0 ]; + e_lsb = cb_buffer [ 1 ]; *ext = ( (uint16_t )e_msb ) << 8 bitor e_lsb; //restriçao de controle para cbx malucos if ( *ext < begin or *ext > end ) { - if ( debug_out_of_range ) send_msg ("Trying from %d", *ext ); - out_of_range++; + if ( debug_out_of_range ) vz_printf ("Trying from %d", *ext ); + out_of_range ++; return ( NULL ); } @@ -151,7 +122,7 @@ *type = cb_buffer [ TYPE_PLACE ]; - return( cb_buffer + VZ_HEADER_OFFSET ); + return ( cb_buffer + VZ_HEADER_OFFSET ); } } @@ -270,10 +241,10 @@ struct tm * result_tm; if( sizeof( time_t ) != sizeof( long ) ) { - if ( debug_clock ) debug_msg("sizeof( time_t ) : %lu -- sizeof( long int ) : %lu\n", sizeof( time_t ), sizeof( long ) ); + if ( debug_print_clock ) vz_debug ("sizeof( time_t ) : %lu -- sizeof( long int ) : %lu\n", sizeof( time_t ), sizeof( long ) ); } - if ( debug_clock ) debug_msg("current_time : %lu\t", current_time ); + if ( debug_print_clock ) vz_debug ("current_time : %lu\t", current_time ); if( current_time != 0 ) { @@ -288,9 +259,9 @@ size_t formated_nbytes = strftime( formated_time, sizeof( formated_time ), "%Y%m%d%H%M%S", result_tm ); - if ( debug_clock ) debug_msg("clock() : %s\n", formated_time ); + if ( debug_print_clock ) vz_debug ("clock() : %s\n", formated_time ); - if( formated_nbytes != CLOCK_SYNC_SIZE ) debug_msg("( %lu )\n", formated_nbytes ); + if( formated_nbytes != CLOCK_SYNC_SIZE ) vz_debug ("( %lu )\n", formated_nbytes ); for( register int i = 0; i < CLOCK_SYNC_SIZE; i++ ) buffer[ i ] = formated_time[ i ]; }