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:
- 69:65665afbad5d
- Parent:
- 67:cdedc64d9921
- Child:
- 70:714c33487aae
diff -r b54993674190 -r 65665afbad5d vz_protocol.cpp --- a/vz_protocol.cpp Fri Nov 07 17:57:55 2014 +0000 +++ b/vz_protocol.cpp Wed Nov 12 13:25:54 2014 +0000 @@ -9,17 +9,6 @@ uint16_t pkg_cksok = 0; uint8_t * __parse_vz_pkg__( int * ext, int * port, volatile uint8_t * type, uint8_t * cb_buffer ){ - /** - * parse and split vz package, - * | E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... | - * E = Ext = Ramal - * P = Port = Porta - * C = Checksum - * T = Type = Tipo - * Seq_num = Sequence Number = Numero de sequencia - * Clock = 14 bytes to sync - * ... = demais __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__ bytes - */ uint8_t p_lsb, p_msb; uint8_t e_lsb, e_msb; @@ -211,6 +200,8 @@ } uint16_t __checksum__( uint8_t * buffer, size_t length ){ + if( !buffer ) return( 0 ); + uint16_t cc = 0x00; buffer[ 4 ] = buffer[ 5 ] = 0x5a; for( register int i = 0; i < length; i++ ){ @@ -236,6 +227,8 @@ time( &seconds ); ts = *localtime( &seconds ); //} + + if( !buffer ) return; int ano = ts.tm_year + 1900; int mes = ts.tm_mon + 1;