Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
2:e67f7c158087
Parent:
1:e392595b4b76
Child:
3:24c5f0f50bf1
--- a/main.cpp	Fri Jul 20 19:04:02 2012 +0000
+++ b/main.cpp	Tue Jul 24 02:07:23 2012 +0000
@@ -10,6 +10,7 @@
 #include "SnConfigFrame.h"
 #include "SnEventFrame.h"
 #include "SnStatusFrame.h"
+#include "SnHeaderFrame.h"
 #include "SnCommWin.h"
 #include "SnCommAfar.h"
 #include "SnCommUsb.h"
@@ -98,7 +99,7 @@
 //static char           gEvtBuf[SnEventFrame::kMaxSizeOf];
 //static char           gConfBuf[SnConfigFrame::kMaxSizeOf];
 //static char           gStatBuf[SnStatusFrame::kMaxSizeOf];
-static char           gGenBuf[SnStatusFrame::kMaxSizeOf]; // must be big enough for event or status or config!
+static char           gGenBuf[SnStatusFrame::kMaxSizeOf + SnHeaderFrame::kMaxSizeOf]; // must be big enough for event or status or config!
 
 void procForceTrigger() {
     //led1=!led1;
@@ -136,10 +137,10 @@
 
 int main() {
     {
-        led1=1; wait(0.3);
-        led1=0; led2=1; wait(0.3);
-        led2=0; led3=1; wait(0.3);
-        led3=0; led4=1; wait(0.3);
+        led1=1; wait(0.2);
+        led1=0; led2=1; wait(0.2);
+        led2=0; led3=1; wait(0.2);
+        led3=0; led4=1; wait(0.2);
         led4=0;
     }
     
@@ -168,7 +169,7 @@
     // get config
     //
     printf("open window\r\n");
-    //gOpenCommWin();
+    OpenCommWin();
 
     // get ready to trigger
     PIN_spi.format( 16, 1 ); // change to data readout format
@@ -232,7 +233,6 @@
                 PIN_lockRegisters = 0; // done reading, unlock so we can talk to SD card.
                 
                 printf("save event\r\n");
-                wait(5);
                 SaveEvent(etms);
                 restartEvtTimer=true;
             } else {
@@ -276,7 +276,7 @@
     printf("gEvtNum=%d\r\n",gEvtNum);
     if (gEvtNum==10) {
         fclose(SnSDUtils::GetCurFile());
-        while (1) {
+        while (true) {
             led3 = 1; led4=1;
             wait(0.5);
             led3 = 0; led4=0;
@@ -314,8 +314,6 @@
                                  gConf.GetRun());
     printf("made output file with run %u\r\n",gConf.GetRun());
     printf("filename=%s\r\n",SnSDUtils::GetCurFileName());
-    SnSDUtils::WriteFileHeader(SnSDUtils::GetCurFile(),
-                               gConf.GetMacAddress());
     SnSDUtils::WriteConfig(SnSDUtils::GetCurFile(), gConf);
     
     // TODO: turn on amps individually, when that's possible
@@ -507,7 +505,7 @@
         printf("gtt=%u, ct=%d, lcw=%d, dur=%u\r\n",GetTimeoutTime(gLastCommWin,conto),
             time(0), gLastCommWin, gConf.GetCommWinDuration());
         const SnCommWin::ECommWinResult conres = (*cw)->OpenWindow(
-            GetTimeoutTime(gLastCommWin, conto), *ss, gConf, gEvent, gGenBuf, gGenBuf);
+            GetTimeoutTime(gLastCommWin, conto), *ss, gConf, gEvent, gGenBuf);
         if (conres>=SnCommWin::kConnected) {
             Watchdog::kick(); // don't reset!
             // connected. listen for config
@@ -526,7 +524,7 @@
                 // send data if need be (files, some events, etc)
                 if (gConf.GetCommSendData()!=0) {
                     
-                    res = (*cw)->SendData(gConf, gEvent, gGenBuf, gGenBuf,
+                    res = (*cw)->SendData(gConf, gEvent, gGenBuf,
                         GetTimeoutTime(gLastCommWin, gConf.GetCommWinDuration()));
                 } else {
                     // don't send anything