![](/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:
- 18:01a93677e40c
- Parent:
- 17:67a6b557eda5
- Child:
- 20:2d6ab23956e5
--- a/vz_protocol.cpp Fri Sep 19 16:40:17 2014 +0000 +++ b/vz_protocol.cpp Fri Sep 19 17:39:09 2014 +0000 @@ -22,11 +22,24 @@ uint16_t cc = ( uint16_t )cb_buffer[ 4 ] << 8 | cb_buffer[ 5 ]; - uint16_t calc_cc = __checksum__( cb_buffer, __CB_BUFFER_SIZE__ ); + /* + UDPSocket debug; + Endpoint debug_server; + char debug_msg[ 1024 ]; + + debug_server.set_address( "192.168.120.180", 9897 ); + debug.bind( 8182 ); + debug.init(); - if( cc != calc_cc ){ - debug_msg("wrong check sum -- calc :: %d ( %d ) -- diff %d", calc_cc, cc, ( cc > calc_cc ) ? cc - calc_cc : calc_cc - cc ); - return( NULL ); + //if( cc != __checksum__( cb_buffer + __CHECKSUM_OFFSET__, + // __CB_BUFFER_SIZE__ - __CHECKSUM_OFFSET__ ) ){ + + sprintf( debug_msg, " -- cc :: %x :: __checksum %x -- bit[4] %x :: bit[5] %x", cc, __checksum__( cb_buffer, __CB_BUFFER_SIZE__ ), cb_buffer[ 4 ], cb_buffer[ 5 ] ); + debug.sendTo( debug_server, debug_msg, strlen( debug_msg ) ); + debug.sendTo( debug_server, debug_msg, strlen( debug_msg ) ); + */ + if( cc != __checksum__( cb_buffer, __CB_BUFFER_SIZE__ ) ){ + return( NULL ); }else{ e_msb = cb_buffer[ 0 ]; e_lsb = cb_buffer[ 1 ]; @@ -42,7 +55,7 @@ } } uint8_t * __build_cb_package__( int ext, int port, uint8_t type, char * cb_buffer, uint8_t seq_num, int length, uint8_t * pkg ){ - //debug_msg(""); + debug_msg(""); pkg[ 0 ] = ( uint8_t )( ( ext & 0xFF00 ) >> 8 ); pkg[ 1 ] = ( uint8_t )( ext & 0x00FF ); pkg[ 2 ] = ( uint8_t )( ( port & 0xFF00 ) >> 8 ); @@ -84,7 +97,7 @@ pkg[ 4 ] =( uint8_t )( ( cc & 0xFF00 ) >> 8) ; pkg[ 5 ] =( uint8_t )( cc & 0x00FF ); - //debug_msg(""); + debug_msg(""); return pkg; }