![](/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:
- 92:92df17f538a8
- Parent:
- 89:0fe315117b00
- Child:
- 98:43b45f26b430
diff -r c2a86b1f8aaa -r 92df17f538a8 vz_protocol.cpp --- a/vz_protocol.cpp Thu Jan 08 23:44:08 2015 +0000 +++ b/vz_protocol.cpp Sat Jan 10 16:35:11 2015 +0000 @@ -158,31 +158,37 @@ fill = length + __VZ_HEADER_OFFSET__; }else if( type == __INVITE__ ){ pkg[ 7 ] = seq_num; - //__print_clock__( pkg + 8 ); + __print_clock__( pkg + 8 ); + pkg[ __TIMESLICE_PLACE__ ] = cb_buffer[ __TIMESLICE_PLACE__ ]; fill = __TIMESLICE_PLACE__ + 1; }else if( type == __REGISTRY__ || type == __BOOT__ ){ pkg[ 7 ] = seq_num; - //__print_clock__( pkg + 8 ); + __print_clock__( pkg + 8 ); + fill = __VZ_HEADER_OFFSET__ + __CLOCK_SYNC_SIZE__ + __SEQ_NUM_SIZE__; }else if( type == __CB_BYE__ ){ pkg[ 7 ] = seq_num; - //__print_clock__( pkg + 8 ); + __print_clock__( pkg + 8 ); + pkg[ __TIMESLICE_PLACE__ ] = cb_buffer[ __TIMESLICE_PLACE__ ]; fill = __TIMESLICE_PLACE__ + 1; }else if( type == __PROMPT__ ){ - //__print_clock__( pkg + 8 ); + __print_clock__( pkg + 8 ); + xmemcpy((pkg+7), (uint8_t*)cb_buffer, 293); //FIXME isso forca qualquer cmd ter < 100 chars fill = 100; }else if( type == __TELEMETRY__ ){ pkg[ 7 ] = seq_num; - //__print_clock__( pkg + 8 ); + __print_clock__( pkg + 8 ); + pkg[ __TIMESLICE_PLACE__ ] = cb_buffer[ __TIMESLICE_PLACE__ ]; fill = __TIMESLICE_PLACE__ + 1; }else if( type == __BOOTLOADER_CBX__ ){ pkg[ 7 ] = seq_num; - //__print_clock__( pkg + 8 ); + __print_clock__( pkg + 8 ); + fill = __VZ_HEADER_OFFSET__ + __CLOCK_SYNC_SIZE__ + __SEQ_NUM_SIZE__; }else{ fill = __VZ_HEADER_OFFSET__; @@ -213,46 +219,46 @@ } void __print_clock__( uint8_t * buffer ){ - if( !buffer ) return; + //if( !buffer ) return; //int ntp_result = ntp.setTime( "200.192.232.8", 123, 3 ); //led2 = !led2; - struct tm ts; + //struct tm ts; //int ntp_result = ntp.setTime( "200.192.232.8" ); //int ntp_result = ntp.setTime( "200.192.232.8", 123, 3 ); //if( ntp_result == 0 ){ - time_t seconds; + // time_t seconds; // seconds = time(NULL); - time( &seconds ); - ts = *localtime( &seconds ); + // time( &seconds ); + // ts = *localtime( &seconds ); //} - int ano = ts.tm_year + 1900; - int mes = ts.tm_mon + 1; - int dia = ts.tm_mday; - int hora = ts.tm_hour - 3; - int min = ts.tm_min; - int sec = ts.tm_sec; + //int ano = ts.tm_year + 1900; + //int mes = ts.tm_mon + 1; + //int dia = ts.tm_mday; + //int hora = ts.tm_hour - 3; + //int min = ts.tm_min; + //int sec = ts.tm_sec; - buffer[ 0 ] = ano / 1000; - ano -= buffer[ 0 ] * 1000; - buffer[ 1 ] = ano / 100; - ano -= buffer[ 1 ]* 100; - buffer[ 2 ] = ano / 10; - ano -= buffer[ 2 ] * 10; - buffer[ 3 ] = ano; - buffer[ 4 ] = mes / 10; - buffer[ 5 ] = mes % 10; - buffer[ 6 ] = dia / 10; - buffer[ 7 ] = dia % 10; - buffer[ 8 ] = hora / 10; - buffer[ 9 ] = hora % 10; - buffer[ 10 ] = min / 10; - buffer[ 11 ] = min % 10; - buffer[ 12 ] = sec / 10; - buffer[ 13 ] = sec % 10; + //buffer[ 0 ] = ano / 1000; + //ano -= buffer[ 0 ] * 1000; + //buffer[ 1 ] = ano / 100; + //ano -= buffer[ 1 ]* 100; + //buffer[ 2 ] = ano / 10; + //ano -= buffer[ 2 ] * 10; + //buffer[ 3 ] = ano; + //buffer[ 4 ] = mes / 10; + //buffer[ 5 ] = mes % 10; + //buffer[ 6 ] = dia / 10; + //buffer[ 7 ] = dia % 10; + //buffer[ 8 ] = hora / 10; + //buffer[ 9 ] = hora % 10; + //buffer[ 10 ] = min / 10; + //buffer[ 11 ] = min % 10; + //buffer[ 12 ] = sec / 10; + //buffer[ 13 ] = sec % 10; /* convertendo pro ascii do nro */ - for( register int i = 0; i < 14; i++ ) buffer[ i ] += 0x30; + for( register int i = 0; i < 14; i++ ) buffer[ i ] = 0xab; //led4 = !led4; } \ No newline at end of file