Versão limpa em 04/09/2014. Telnet funcionando.

Dependencies:   EthernetInterface mbed-rtos mbed NTPClient

Revision:
42:d6f9ce115eaf
Parent:
38:132e83a591d0
Child:
43:69afea5f5a4d
--- a/main.cpp	Thu Jan 14 17:26:05 2016 +0000
+++ b/main.cpp	Mon Jan 18 18:01:59 2016 +0000
@@ -13,6 +13,10 @@
         - m_Socket[]       --> Não Utilizado, sem acompanhamento
         - m_MaxTries       --> Adicionei constante (MAXTRIES). Se mudar tem de recompilar.
 */
+
+
+#define MSGWINDOW "Limpo - Version 5"
+
 #include <stdio.h>
 
 #include "mbed.h"
@@ -39,88 +43,10 @@
 
 #include "whatchdog.h"
 
-
-
 //__attribute((section("AHBSRAM0"),aligned)) char LargeBuffer[1024]; 
 EthernetInterface eth;
 Watchdog wdt;
 
-void thread1(void const *args)
-{
-    DigitalOut led1(LED1);
-    int n = 0;
-    //int tatual, tnovo;
-    float rms[NUMBER_OF_CHANNELS], mv2[NUMBER_OF_CHANNELS];
-    int under[NUMBER_OF_CHANNELS], over[NUMBER_OF_CHANNELS];
-    
-    Capture::Initialize();
-    
-    //Timer t;
-    //t.start();
-    //tatual = 0;
-    
-    while(1)
-    {
-        Capture::Wait();
-        
-        // Calcula o RMS dos 6 canais
-        SignalProcessor::CalculateRMSBulk(rms, mv2, under, over);
-        //printf("Tempo ms %d\n", t.read_ms());
-        //t.reset();
-        
-        //rms[0] = 2050;
-        //rms[1]=rms[2]=rms[3]=rms[4]=rms[5]=2000;
-        
-        for(int i=0;i<6;i++){
-            //printf("Main %d\n", i);
-            EventDetector::get_Detector(i).ProcessEvent(rms[i], mv2[i], under[i], over[i]);
-            //wait_ms(2);
-        }
-        //Thread::yield();
-        
-        
-        /*
-        for(int i =0; i < 6; i++)
-            printf("%5.2f\t", rms[i]);
-        printf("\n");
-        
-        wait(5);
-        */
-        n++;
-        if(n==60)
-        {
-            printf("%.2f %.0f %.2f %.0f\t%.2f %.0f %.2f %.0f\t%.2f %.0f %.2f %.0f\n",rms[0], mv2[0],rms[1],mv2[1],rms[2],mv2[2],rms[3],mv2[3],rms[4],mv2[4],rms[5],mv2[5]);
-            led1 = !led1;            
-            n=0;    
-            //t.stop();
-            
-            /*
-            tnovo = t.read_us();            
-            printf("MAIN: The time XXX taken loop %d\n", tnovo - tatual);
-            tatual = tnovo;
-            t.reset();
-            */
-            //Thread::wait(1000); //1000
-            
-            PmedLog::Mark();
-            
-            //wait(1);
-        }
-    }
-}
-
-/*
-void InitializeEthernetLink()
-{
-    if(Settings::get_Dhcp())
-        eth.init(); //Use DHCP
-    else
-        eth.init(Settings::get_IpAddress(),Settings::get_Netmask(),Settings::get_Gateway());
-        
-    eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
-}
-*/
 void InitializeEthernetLink()
 {
     if(Settings::get_Dhcp())
@@ -137,20 +63,21 @@
 }
 
 int main() {
-    //DigitalOut myled3(LED3); //The pushbutton or power on caused a reset
-    //DigitalOut myled4(LED4); //The watchdog timer caused a reset
+    DigitalOut myled3(LED3); //The pushbutton or power on caused a reset
+    DigitalOut myled4(LED4); //The watchdog timer caused a reset
     
     if ((LPC_WDT->WDMOD >> 2) & 1){
-        //myled4 = 1; 
+        myled4 = 1; 
         PmedLog::WriteEntry(PMEDLOG_INITIALIZINGWDT);
     }
     else{        
-        //myled3 = 1;
+        myled3 = 1;
         PmedLog::WriteEntry(PMEDLOG_INITIALIZING);
     }
 
-    printf("\r\nNova versao 70 ( 20151028.1 )... Com WhatchDog\r\n");
+    printf("\r\n %s \r\n", MSGWINDOW);
     FILE *f;
+    
     //Set Highest Priority
     //osThreadSetPriority(osThreadGetId(),osPriorityHigh);
     
@@ -162,16 +89,16 @@
     printf("Inicializou link Ethernet\n");
     
     //Start HTTP POST service
-    Thread http_post(HttpPost::HttpPost_Thread);        
+    Thread http_post(HttpPost::HttpPost_Thread);            
     
     //Start TCP daemon service
     //Thread TcpService(CommTCP::CommTCP_Thread);
         
     //Start Telnet Service
-    Thread telnetserver(TelnetServer::TelnetServer_Thread);
+    Thread telnetserver(TelnetServer::TelnetServer_Thread);    
     
     //Start TFTP Service    
-    Thread tftpsrv(tftpsrv::tftpsrv_Thread);
+    //Thread tftpsrv(tftpsrv::tftpsrv_Thread);
     
     //Start NTP Client for refresh time
     //Thread ntpc(ntpc::ntpc_Thread);
@@ -208,17 +135,17 @@
     /* start test WahtchDog */
     DigitalOut led1(LED1);
     int n = 0;
-    //int tatual, tnovo;
     float rms[NUMBER_OF_CHANNELS], mv2[NUMBER_OF_CHANNELS];
     int under[NUMBER_OF_CHANNELS], over[NUMBER_OF_CHANNELS];
     
     wdt.kick(10.0);  
     
-    Capture::Initialize();
+    Capture::InitializeAD();
        
     while(1)
     {
-        Capture::Wait();
+        //get sample values from 6 channels
+        Capture::AcquireValues();
         
         // Calcula o RMS dos 6 canais
         SignalProcessor::CalculateRMSBulk(rms, mv2, under, over);