Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
46:a670f187a704
Parent:
44:cc4996469404
Child:
48:195c97f12e8e
--- a/utils.cpp	Tue Oct 07 12:10:36 2014 +0000
+++ b/utils.cpp	Tue Oct 07 18:38:30 2014 +0000
@@ -53,7 +53,13 @@
         if( debug_file ) debug_msg("Failed to open /qspi/myip.txt" );
         strncpy( buff_ip, __MY_IP__, 20 );    
     }else{
-        if( fread( buff_ip, 1, 512, fp ) > 0 ){
+        int read = fread( buff_ip, 1, 512, fp );
+        if( read > 0 ){
+            for( int i = 0; i < read; i++ ) 
+                if( buff_ip[ i ] == '\n' || buff_ip[ i ] == '\r' ){
+                    buff_ip[ i ] = '\0';
+                    break;
+                }
             if( debug_file ) debug_msg("Eth ip %s", buff_ip );
         }else{
             if( debug_file ) if( debug_file ) debug_msg("Failed to read /qspi/myip.txt" );
@@ -68,7 +74,13 @@
         if( debug_file ) debug_msg("Failed to open /qspi/mymask.txt" );
         strncpy( buff_msk, __MY_MSK__, 20 );    
     }else{
-        if( fread( buff_msk, 1, 512, fp ) > 0 ){
+        int read = fread( buff_msk, 1, 512, fp );
+        if( read > 0 ){
+            for( int i = 0; i < read; i++ ) 
+                if( buff_msk[ i ] == '\n' || buff_msk[ i ] == '\r' ){
+                    buff_msk[ i ] = '\0';
+                    break;
+                }
             if( debug_file ) debug_msg("mascara de rede Eth %s", buff_msk );
         }else{
             if( debug_file ) debug_msg("Failed to read /qspi/mymask.txt" );
@@ -83,7 +95,13 @@
         if( debug_file ) debug_msg("Failed to open /qspi/mygate.txt" );
         strncpy( buff_gtw, __MY_GTW__, 20 );    
     }else{
-        if( fread( buff_gtw, 1, 512, fp ) > 0 ){
+        int read = fread( buff_gtw, 1, 512, fp );
+        if( read > 0 ){
+            for( int i = 0; i < read; i++ ) 
+                if( buff_gtw[ i ] == '\n' || buff_gtw[ i ] == '\r' ){
+                    buff_gtw[ i ] = '\0';
+                    break;
+                }
             if( debug_file ) debug_msg("Ip Gateway Eth %s", buff_gtw );
         }else{
             if( debug_file ) debug_msg("Failed to read /qspi/mygate.txt" );
@@ -92,8 +110,10 @@
     }
     fclose( fp );
     buff_gtw[ 15 ] = 0;
+    
     if( !initialized ){
         eth->init( buff_ip, buff_msk, buff_gtw );
+        //eth->init( __MY_IP__, __MY_MSK__, __MY_GTW__  );
         initialized = true;
     }
     return eth->connect();