kobe leysen / Mbed 2 deprecated TEST

Dependencies:   DAQ mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
leysenkobe
Date:
Wed Apr 30 11:41:10 2014 +0000
Parent:
1:fa51edf89e71
Commit message:
kbk;

Changed in this revision

DAQ.lib Show annotated file Show diff for this revision Revisions of this file
DAQ/DummyDAQ.cpp Show diff for this revision Revisions of this file
DAQ/DummyDAQ.h Show diff for this revision Revisions of this file
DAQ/Measurement.cpp Show diff for this revision Revisions of this file
DAQ/Measurement.h Show diff for this revision Revisions of this file
Module.cpp Show annotated file Show diff for this revision Revisions of this file
Module.h Show annotated file Show diff for this revision Revisions of this file
Packet.cpp Show annotated file Show diff for this revision Revisions of this file
Uart.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAQ.lib	Wed Apr 30 11:41:10 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/leysenkobe/code/DAQ/#ea7eb499a27a
--- a/DAQ/DummyDAQ.cpp	Thu Apr 24 10:39:09 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#include "DummyDAQ.h"
-#include "mbed.h"
-
-//Constructor en Destructor
-DummyDAQ::DummyDAQ(void)
-{
-    
-}
-DummyDAQ::~DummyDAQ(void)
-{
-
-}
-
-//GETTERS
-Measurement* DummyDAQ::measure(void)
-{
-    Measurement *measurement = new Measurement();
-    
-    //measurement vullen met valse data
-    for (int i = 0; i < 16; i++)
-    {
-        measurement->Enable(i);
-        measurement->setPunt(i,i+1);
-    }
-    return measurement;
-}
-int DummyDAQ::getChannelGain(int channel)
-{
-    return 1000;
-}
-bool DummyDAQ::ChannelEnabled(int channel)
-{
-    return true;
-}
-bool DummyDAQ::Initialized(void)
-{
-    return true;
-}
-
-//SETTERS
-void DummyDAQ::setChannelGain(int channel,int gain)
-{
-    
-}
-void DummyDAQ::enableChannel(int channel)
-{
-    
-}
-void DummyDAQ::disableChannel(int channel)
-{
-    
-}
-void DummyDAQ::setInitialized(bool init)
-{
-    
-}
\ No newline at end of file
--- a/DAQ/DummyDAQ.h	Thu Apr 24 10:39:09 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-#ifndef DUMMYDAQ_H
-#define DUMMYDAQ_H
-
-#include "Measurement.h"
-
-class DummyDAQ
-{
-public:
-    DummyDAQ(void);
-    ~DummyDAQ(void);
-
-    //GETTERS
-    Measurement* measure(void);
-    int getChannelGain(int channel);
-    bool ChannelEnabled(int channel);
-    bool Initialized(void);
-
-    //SETTERS
-    void setChannelGain(int channel,int gain);
-    void enableChannel(int channel);
-    void disableChannel(int channel);
-    void setInitialized(bool init);
-};
-#endif
\ No newline at end of file
--- a/DAQ/Measurement.cpp	Thu Apr 24 10:39:09 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#include "Measurement.h"
-
-Measurement::Measurement(void)
-{
-    this->punten = new int[16];
-    this->puntEnabled = new bool[16];
-    
-    for (int i = 0; i < 16; i++)
-    {
-        this->punten[i] = 0;
-        this->puntEnabled[i] = false;
-    }
-}
-
-Measurement::~Measurement(void)
-{
-    delete [] punten;
-    delete [] puntEnabled;
-}
-
-//GETTERS
-int Measurement::getPunt(int channel)
-{
-    if(channel>=0 && channel<16)
-    {
-        return(this->punten[channel]);
-    }
-    return(-1);
-}
-bool Measurement::Enabled(int channel)
-{
-    if(channel>=0 && channel<16)
-    {
-        return(this->puntEnabled[channel]);
-    }
-    return(false);
-}
-
-//SETTERS
-void Measurement::setPunt(int channel,int punt)
-{
-    if(channel>=0 && channel<16)
-    {
-        this->punten[channel] = punt;
-    }
-}
-void Measurement::Enable(int channel)
-{
-    if(channel>=0 && channel<16)
-    {
-        this->puntEnabled[channel] = true;
-    }
-}
-void Measurement::Disable(int channel)
-{
-    if(channel>=0 && channel<16)
-    {
-        this->puntEnabled[channel] = false;
-    }
-}
\ No newline at end of file
--- a/DAQ/Measurement.h	Thu Apr 24 10:39:09 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#ifndef MEASUREMENT_H
-#define MEASUREMENT_H
-
-class Measurement
-{
-private:
-    int *punten;
-    bool *puntEnabled;
-    
-public:
-    Measurement(void);
-    ~Measurement(void);
-
-    //GETTERS
-    int getPunt(int channel);
-    bool Enabled(int channel);
-
-    //SETTERS
-    void setPunt(int channel,int punt);
-    void Enable(int channel);
-    void Disable(int channel);
-};
-#endif
\ No newline at end of file
--- a/Module.cpp	Thu Apr 24 10:39:09 2014 +0000
+++ b/Module.cpp	Wed Apr 30 11:41:10 2014 +0000
@@ -1,13 +1,14 @@
 #include "Module.h"
 
 Serial pl(USBTX, USBRX);
+DigitalOut led4(LED4);
 
 Module::Module()
 {
-    pl.baud(230400);
+    pl.baud(9600);
     
     //objects
-    this->daq = new DummyDAQ();
+    this->daq = new DAQ();
     this->uart = new Uart(this);
     
     //local variables
@@ -55,8 +56,9 @@
 
 void Module::meting_thread()
 {
-    if(enableData)
+    if(enableData && !this->daq->ChannelsDisabled())
     {
+        led4 = 1;
         Measurement *m = this->daq->measure();
         if(this->dataPacket->addMeasurement(m))
         {
@@ -73,88 +75,87 @@
         }
         delete m;
     }
+    else
+    {
+        led4 = 0;
+    }
 }
 
 //PACKET WORKER
 void Module::packetWorker(Packet *p)
 {
-    pl.putc(p->getID()[0]);
-    pl.putc(p->getID()[1]);
-    pl.putc(p->getCMD());
     switch(p->getCMD())
     {
         //S2C packets
-        case PACKET_ACK : this->sendPacket(p); pl.printf("ACK"); break;
-        case PACKET_NACK : this->sendPacket(p); pl.printf("NACK"); break;
-        case PACKET_ERROR : this->sendPacket(p); pl.printf("ERROR"); break;
-        case PACKET_ALIVE : this->sendPacket(p); pl.printf("ALIVE"); break;
-        case PACKET_DATA : this->sendPacket(p); pl.printf("DATA"); break;
-        case PACKET_GET_IP_REPLY : this->sendPacket(p); pl.printf("IP_REPLY"); break;
+        case PACKET_ACK : this->sendPacket(p); break;
+        case PACKET_NACK : this->sendPacket(p); break;
+        case PACKET_ERROR : this->sendPacket(p); break;
+        case PACKET_ALIVE : this->sendPacket(p); break;
+        case PACKET_DATA : this->sendPacket(p); break;
+        case PACKET_GET_IP_REPLY : this->sendPacket(p); break;
         
         //C2S packets
         case PACKET_INIT :
+            this->sendPacket(p);
             this->HandleInit(p);
-            printf("PACKET_INIT");
             break;
         case PACKET_ENABLE_DATA :
+            this->sendPacket(p);
             this->HandleEnableData(p);
-            printf("ENABLE_DATA");
             break;
         case PACKET_CHANGE_IP :
+            this->sendPacket(p);
             this->HandleChangeIP(p);
-            printf("CHANGE_IP");
             break;
         case PACKET_REMOVE_IP :
+            this->sendPacket(p);
             this->removeIP();
-            printf("REMOVE_IP");
             break;
         case PACKET_GET_IP :
+            this->sendPacket(p);
             this->IpReply();
-            printf("GET_IP");
             break;
         case PACKET_VERSION :
+            this->sendPacket(p);
             this->VersionReply();
-            printf("VERSION");
             break;
         //case PACKET_VERSION_REPLY : --> zelf versturen!
         //    break;
         case PACKET_SET_PACKAGE_SIZE :
+            this->sendPacket(p);
             HandleSetPackageSize(p);
-            printf("SET_PACKAGE_SIZE");
             break;
         case PACKET_GET_SETTINGS :
+            this->sendPacket(p);
             this->SettingsReply();
-            printf("GET_SETTINGS");
             break;
         //case PACKET_GET_SETTINGS_REPLY : --> moet verstuurd worden!
         //    break;
         case PACKET_SET_ID :
+            this->sendPacket(p);
             uint8_t *cmdData = p->getCMD_DATA();
             this->ID[0] = cmdData[0];
             this->ID[1] = cmdData[1];
             delete cmdData;
             this->Acknowledge();
-            printf("SET_ID");
             break;
         case PACKET_TEST_MODE :
+            this->sendPacket(p);
             this->uart->send(p); //uitsturen via beide interfaces
             //this->wifi->send(p);
-            printf("TEST_MODE");
             break;
         case PACKET_LED_TEST_MODE :
+            this->sendPacket(p);
             uint8_t *ledData = p->getCMD_DATA();
             uint8_t ledInfo = ledData[0];
             this->LedTest(ledInfo);
             delete ledData;
-            printf("LED_TEST_MODE");
             break;
         default:
             /// packet dat ik binnen krijg !!!!!
-            printf("huh??");
+            pl.printf("erorrrrrrr");
             break;
-    }
-    printf("gedaan");
-    delete p;    
+    } 
 }
 
 void Module::sendPacket(Packet *p)
@@ -238,15 +239,14 @@
 
 void Module::HandleEnableData(Packet *p){
     uint8_t *data = p->getCMD_DATA();
-    
-    if(data[0] == 0x00){
+    if(data[0] == 0x01)
+    {
         this->EnableData();    
     }
-    else{
+    else
+    {
         this->DisableData();
-    }
-    
-    delete data;    
+    }    
 }
 
 void Module::HandleSetPackageSize(Packet *p){
--- a/Module.h	Thu Apr 24 10:39:09 2014 +0000
+++ b/Module.h	Wed Apr 30 11:41:10 2014 +0000
@@ -3,7 +3,7 @@
 
 #include "Uart.h"
 #include "Packet.h"
-#include "DummyDAQ.h"
+#include "DAQ.h"
 #include "rtos.h"
 
 class Uart;
@@ -12,7 +12,7 @@
 {
 private:
     Uart *uart;
-    DummyDAQ *daq;
+    DAQ *daq;
     
     //local variables
     uint8_t ID[2];
--- a/Packet.cpp	Thu Apr 24 10:39:09 2014 +0000
+++ b/Packet.cpp	Wed Apr 30 11:41:10 2014 +0000
@@ -40,7 +40,6 @@
 }
 Packet::Packet(uint8_t ID[2])
 {
-    printf("error packet aanmaken \n");
     //geheugen in de heap vrij maken
     this->ID = new uint8_t[2];
     this->RESERVED = new uint8_t[2];
--- a/Uart.cpp	Thu Apr 24 10:39:09 2014 +0000
+++ b/Uart.cpp	Wed Apr 30 11:41:10 2014 +0000
@@ -71,10 +71,9 @@
         data[size+7] = pc.getc();
         data[size+8] = pc.getc();
             
-            
         this->flush();
-        Packet *p = new Packet(data,TOT_SIZE+2,m->getID());
-        m->packetWorker(p); 
+        Packet *p = new Packet(m->getID(),data,TOT_SIZE+2);
+        m->packetWorker(p);
             
         delete [] totsize;
         delete [] data;
@@ -85,7 +84,6 @@
     {
         for(int i = 0; i < packetscount; i++)
         {
-            pc.printf("%d",i);
             //pc.printf("PACKET: ");
             Packet *p = packets[i];
             
@@ -127,7 +125,6 @@
     if(packetscount<2)
     {
         packets[packetscount] = p;
-        pc.putc(p->getCMD());
         packetscount++;
     }
     else
--- a/main.cpp	Thu Apr 24 10:39:09 2014 +0000
+++ b/main.cpp	Wed Apr 30 11:41:10 2014 +0000
@@ -14,7 +14,7 @@
     {
         led2 =! led2;
         m->getUart()->uart_thread();
-        wait(0.1);
+        wait(0.01);
     }
 }