Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: utils.cpp
- Revision:
- 72:895ca792c647
- Parent:
- 70:714c33487aae
- Child:
- 74:81c47fff88a5
diff -r 757fa1ef37c6 -r 895ca792c647 utils.cpp --- a/utils.cpp Mon Nov 17 13:44:53 2014 +0000 +++ b/utils.cpp Wed Nov 19 13:36:33 2014 +0000 @@ -3,7 +3,9 @@ EthernetInterface eth; uint8_t cb_tx_buffer[ __CB_BUFFER_SIZE__ ]; - + +ring_buffer * rb = ring_buffer_init( NULL ); + UDPSocket t_sock; Endpoint t_server; @@ -291,10 +293,34 @@ } void __send_to_cb__( uint8_t * buffer ){ - xmemcpy( TXBuffer, buffer, DATA_SIZE ); - xmemcpy( cb_tx_buffer, buffer, __CB_BUFFER_SIZE__ ); - send2callboxes(); + if( tx_clear == 1 ){ + tx_clear = 0; + xmemcpy( TXBuffer, buffer, DATA_SIZE ); + parallel_write( TXBuffer[ 0 ] ); + DataReady = 1; + xmemcpy( cb_tx_buffer, buffer, __CB_BUFFER_SIZE__ ); + //send2callboxes(); + }else{ + uint8_t ret = ring_buffer_add( rb, buffer ); + + if( ret == 0x01 ) if( dparallel ) send_msg("Error: Ring buffer fully charged"); + + if( ret == 0x00 ) if( dparallel ) send_msg("Success : package queued -- on queue %u", rb->size ); + } } + +void tx_buffer_ring_buffer_handler( void ){ + if( rb->size != 0x00 ){ + if( tx_clear == 1 ){ + uint8_t * buffer = ring_buffer_get_next( rb ); + xmemcpy( TXBuffer, buffer, DATA_SIZE ); + xmemcpy( cb_tx_buffer, buffer, __CB_BUFFER_SIZE__ ); + if( dparallel ) send_msg("Ring Buffer less one -- remain %u", rb->size ); + send2callboxes(); + } + } +} + void init_telemetry_handler( void ){ char buff_ip[ 16 ] = ""; char buff_port[ 8 ] = "";