Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
122:480c44b0e205
Parent:
121:ee02790d00b7
Child:
124:c1b6c893e1c3
diff -r ee02790d00b7 -r 480c44b0e205 vz_protocol.cpp
--- a/vz_protocol.cpp	Fri May 08 04:15:23 2015 +0000
+++ b/vz_protocol.cpp	Mon May 11 15:16:36 2015 +0000
@@ -274,4 +274,47 @@
     }
     cc ^= 0xffff;
     return cc; 
+}
+
+void print_clock ( uint8_t * buffer )
+{
+    if( buffer != NULL )
+    {
+        struct tm * result_tm;
+        if( sizeof( time_t ) != sizeof( long ) )
+        {
+            if ( debug_clock ) debug_msg("sizeof( time_t ) : %lu -- sizeof( long int ) : %lu\n", sizeof( time_t ), sizeof( long ) );
+        }
+                                   
+        if ( debug_clock ) debug_msg("current_time : %lu\t", current_time );
+                                                                                                                                        
+        if( current_time != 0 )
+        {
+            result_tm = localtime( ( const time_t *)&current_time );
+            if ( result_tm )
+            {
+                char formated_time[ 16 ];
+                
+                /* Correcao "manual" do (GMT -3:00) */
+                result_tm->tm_hour -= 3;
+                if ( result_tm->tm_hour < 0 ) result_tm->tm_hour = 24 + result_tm->tm_hour;
+                
+                size_t formated_nbytes = strftime( formated_time, sizeof( formated_time ), "%Y%m%d%H%M%S", result_tm );
+                
+                if ( debug_clock ) debug_msg("clock() : %s\n", formated_time );
+                
+                if( formated_nbytes != CLOCK_SYNC_SIZE ) debug_msg("( %lu )\n", formated_nbytes );
+                
+                for( register int i = 0; i < CLOCK_SYNC_SIZE; i++ ) buffer[ i ] = formated_time[ i ];
+            }
+                else
+            {
+                for( register int i = 0; i < CLOCK_SYNC_SIZE; i++ ) buffer[ i ] = 0xfa;
+            }
+        }
+            else
+        {
+            for( register int i = 0; i < CLOCK_SYNC_SIZE; i++ ) buffer[ i ] = 0xab;
+        }
+    }
 }
\ No newline at end of file