Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
48:195c97f12e8e
Parent:
46:a670f187a704
Child:
58:af7e8788f106
--- a/vz_protocol.cpp	Tue Oct 07 18:43:44 2014 +0000
+++ b/vz_protocol.cpp	Mon Oct 20 16:13:10 2014 +0000
@@ -1,5 +1,6 @@
 #include "vz_protocol.h"
 #include "prompt.h"
+#include "debug.h"
     
 extern DigitalOut led2;
 extern DigitalOut led4;
@@ -25,7 +26,7 @@
     
     if( cb_buffer == NULL ) return( NULL );
     
-     if (cb_buffer[6] == 64) {
+     if( cb_buffer[ 6 ] == __FLOOD__ ) {
         static uint8_t flood_cnt = 0;
         static uint8_t first_run_flag = 0;
         static Timer t;
@@ -36,11 +37,19 @@
         } else {
             if (cb_buffer[0] == 0x00){
                 pc.printf("%d", t.read_us());
+                if( tcp_session ){
+                    char tmp[ 16 ];
+                    sprintf( tmp, "%d", t.read_us() );
+                    tcp_client.send_all( tmp, strlen( tmp ) );
                 }
+            }
             flood_cnt++;
             while (flood_cnt != cb_buffer[0]) {
                 pc.printf("0");
                 flood_cnt++;
+                if( tcp_session ){
+                    tcp_client.send_all( "0", strlen( "0" ) );
+                }
             }
             int i;
             int ok = 1;
@@ -50,14 +59,28 @@
                     if (cb_buffer[i] != cmp) ok = 0;
                 }
             }
-            if (ok) {
+            if( ok ){
                 pc.printf("+");
-            } else {
+                if( tcp_session ){
+                    tcp_client.send_all( "+", strlen( "+" ) );
+                }
+            }else{
                 pc.printf("%02x",cb_buffer[0] );
                 pc.printf("#");
                 pc.printf("\n\r");
-                for (int i = 0; i< 300 ; i++)   {pc.printf("%x", cb_buffer[i]);}
-                
+                if( tcp_session ){
+                    char tmp[ 16 ];
+                    sprintf( tmp, "%02x#\n\r", cb_buffer[ 0 ] );
+                    tcp_client.send_all( tmp, strlen( tmp ) );
+                }
+                for( int i = 0; i < 300 ; i++ ){
+                    pc.printf("%x", cb_buffer[ i ]);
+                    if( tcp_session ){
+                        char tmp[ 16 ];
+                        sprintf( tmp, "%x", cb_buffer[ i ] );
+                        tcp_client.send_all( tmp, strlen( tmp ) );
+                    }
+                }
             }
         }
         return( NULL );