Index: /drsdaq/DAQReadout.cc
===================================================================
--- /drsdaq/DAQReadout.cc	(revision 91)
+++ /drsdaq/DAQReadout.cc	(revision 92)
@@ -12,5 +12,5 @@
 #include "SlowData.h"
 
-#define TMPNAME "/tmp/__tmp__drsdaq__"
+#define TMPNAME "/tmp/__tmp__drsdaq__"  // ..for log file truncation
 
 static const char* daq_state_str[] = {"active", "stopped"};
@@ -26,5 +26,5 @@
    {"status", &DAQReadout::cmd_status, false, "[daq|drs]", "Show DAQ/DRS status information"},
    {"freq", &DAQReadout::cmd_freq, true, "<GHz> [reg]", "Set DRS sampling frequency (regulated)"},
-   {"calib", &DAQReadout::cmd_calib, true, "<t_f> <c_f> [dir]", "Response calibration"},
+   {"calib", &DAQReadout::cmd_calib, true, "<t_f> <c_f>", "Response calibration"},
    {"trigger", &DAQReadout::cmd_trigger, true, "<on|off>", "Hardware trigger on or off"},
    {"delayed", &DAQReadout::cmd_delayed, true, "<on|off>", "Switch delayed start on or off"},
@@ -76,24 +76,30 @@
   LastBoard	     = -1;
   CmdFromSocket      = false;
-      
-  // Read configuration file
+  ConfigOK  	     = true;
+  
+  // Read configuration file (if any item missing, program will be terminated in main() routine)
   FILE *File;
   if ((File = fopen(Configfile,"r")) == NULL) {
     printf("Error: Could not open drsdaq configuration file '%s'\n", Configfile);
+    ConfigOK = false;
+    return;
   }
   else {
     printf("Reading drsdaq configuration file %s\n", Configfile);
-    ReadCard("LogFile",             fLogFile,           's', File);
-    ReadCard("MaxLogLines",        &fMaxLogLines,       'U', File);
-    ReadCard("RawDataPath",         fRawDataPath,       's', File);
-    ReadCard("FirstSample",        &fFirstSample,       'I', File);
-    ReadCard("Samples",     	   &fSamples,        	'U', File);
-    ReadCard("MinDiskSpaceMB",     &fMinDiskSpaceMB,    'U', File);
-    ReadCard("MaxFileSizeMB",      &fMaxFileSizeMB,     'I', File);
-    ReadCard("CCPort",             &fCCPort,            'I', File);
-    ReadCard("FirstVMESlot",       &fFirstVMESlot,      'I', File);
-    ReadCard("LastVMESlot",        &fLastVMESlot,       'I', File);
-    ReadCard("HVFeedbackConfig",    fHVFeedbackConfig,  's', File);
+    ConfigOK &= ReadCard("LogFile",             fLogFile,           's', File);
+    ConfigOK &= ReadCard("SlowDataPath",        fSlowDataPath,      's', File);
+    ConfigOK &= ReadCard("MaxLogLines",        &fMaxLogLines,       'U', File);
+    ConfigOK &= ReadCard("RawDataPath",         fRawDataPath,       's', File);
+    ConfigOK &= ReadCard("FirstSample",        &fFirstSample,       'I', File);
+    ConfigOK &= ReadCard("Samples",            &fSamples,           'U', File);
+    ConfigOK &= ReadCard("MinDiskSpaceMB",     &fMinDiskSpaceMB,    'U', File);
+    ConfigOK &= ReadCard("MaxFileSizeMB",      &fMaxFileSizeMB,     'I', File);
+    ConfigOK &= ReadCard("CCPort",             &fCCPort,            'I', File);
+    ConfigOK &= ReadCard("FirstVMESlot",       &fFirstVMESlot,      'I', File);
+    ConfigOK &= ReadCard("LastVMESlot",        &fLastVMESlot,       'I', File);
+    ConfigOK &= ReadCard("HVFeedbackConfig",    fHVFeedbackConfig,  's', File);
+    ConfigOK &= ReadCard("DefaultFrequency",   &fDefaultFrequency , 'd', File);
     fclose(File);
+    if (!ConfigOK) return;
   }
   if (fFirstSample < 0 || fFirstSample > kNumberOfBins || fSamples > kNumberOfBins) {
@@ -108,10 +114,8 @@
   if (system(ShellCmd) != 0) printf("Warning: Could not truncate log file '%s' to %u lines\n", fLogFile, fMaxLogLines);
 
-  // Open log file
+  // Open log file and log configuration
   if ((Logfile = fopen(fLogFile, "a")) == NULL) printf("Warning: Could not open log file '%s'\n", fLogFile);
   PrintMessage(MsgToLog,"********** Logging started **********\n");
-  
-  // Print configuration
-  cmd_config();
+  PrintConfig(MsgToLog);
 
   // Create DRS instance and perform initial scan
@@ -151,10 +155,9 @@
   
   // Create instance of slow data class for DAQ
-  char Filename[MAX_PATH];
-  snprintf(Filename,sizeof(Filename),"%s/SlowData/", fRawDataPath);
-  SlowDataClass = new SlowData("DAQ", Filename);
+  SlowDataClass = new SlowData("DAQ", fSlowDataPath);
   if(SlowDataClass->ErrorCode != 0) {
    PrintMessage("Warning: Could not open DAQ slowdata file (%s)\n", strerror(SlowDataClass->ErrorCode));
   }
+  SlowDataClass->NewEntry("Runinfo-Info", "Run information written after completion or termination of run (Status can be OK or Error): Runnumber Status Runtype Events Files Description ");
 }
 
@@ -170,5 +173,4 @@
   delete[] WaveForm;  delete[] TriggerCell;
   
-  PrintMessage(MsgToLog,"********** Logging ended **********\n\n");
   if(Logfile) {
     if(!fclose(Logfile)) printf("Closing logfile\n");
@@ -224,11 +226,5 @@
 // Print DAQ configuration
 void DAQReadout::cmd_config() {
-  PrintMessage("LogFile: %s\tMaxLogLines: %u\tRawDataPath: %s\n"
-      	       "FirstSample: %d\tSamples: %u\n"
-     	       "MinDiskSpaceMB: %u\tMaxFileSizeMB: %d\tCCPort: %d\n"
-      	       "FirstVMESlot: %d\t\tLastVMESlot: %d\n"
-	       "HVFeedbackConfig: %s\n",
-    fLogFile,fMaxLogLines,fRawDataPath,fFirstSample,fSamples,fMinDiskSpaceMB,
-    fMaxFileSizeMB,fCCPort,fFirstVMESlot,fLastVMESlot,fHVFeedbackConfig);
+  PrintConfig(CmdFromSocket ? MsgToSocket : MsgToConsole);
 }
 
@@ -241,5 +237,10 @@
       return;
     }
-    if (!IsDRSFreqSet()) return;
+    if (!IsDRSFreqSet()) {
+      PrintMessage("Setting default frequency\n");
+      SetDRSFrequency(fDefaultFrequency, false);
+      CalibrationRead = false;
+    }
+    
     if (!CalibrationRead && !ReadCalibration()) {
       PrintMessage("Cannot start run if response calibration not read.\n");
@@ -445,9 +446,44 @@
 // Do internal calibration
 void DAQReadout::cmd_calib() {
-  if (NParam==4 && atof(Param[1]) && atof(Param[2]))
-    CalibrateDRS((char *) Param[3],atof(Param[1]),atof(Param[2])); 
-  else if (NParam==3 && atof(Param[1]) && atof(Param[2]))
-    CalibrateDRS(NULL,atof(Param[1]),atof(Param[2])); 
-  else PrintUsage();
+  char str[MAX_COM_SIZE];
+
+  if (NParam!=3 || !atof(Param[1]) || !atof(Param[2])) {
+    PrintUsage();
+    return;
+  }
+      
+  getcwd(str, sizeof(str));
+  strcat(str,"/calib");
+  PrintMessage("Writing calibration data to directory '%s'\n",str);
+
+  for (int i=FirstBoard; i<=LastBoard; i++) {
+    drs->GetBoard(i)->Init();
+    drs->GetBoard(i)->SetFrequency(atof(Param[2]));
+    drs->GetBoard(i)->SoftTrigger();
+
+    PrintMessage("Creating calibration of board %d (%d)\n", i, drs->GetBoard(i)->GetCMCSerialNumber());
+
+    drs->GetBoard(i)->EnableTcal(1);
+    PrintMessage("Tcal enabled\n");
+
+    if (drs->GetBoard(i)->GetChipVersion() == 3) drs->GetBoard(i)->GetResponseCalibration()->SetCalibrationParameters(1,21,0,20,0,0,0,0,0);
+    else drs->GetBoard(i)->GetResponseCalibration()->SetCalibrationParameters(1,36,110,20,19,40,15,atof(Param[1]),0);
+    drs->GetBoard(i)->SetCalibrationDirectory(str);
+
+    for (int j=0; j<2; j++) {
+      drs->GetBoard(i)->GetResponseCalibration()->ResetCalibration();
+      PrintMessage("Calibration reset done.\n");
+
+      while (!drs->GetBoard(i)->GetResponseCalibration()->RecordCalibrationPoints(j)) {}
+      PrintMessage("Record calibration points done.\n");
+      while (!drs->GetBoard(i)->GetResponseCalibration()->FitCalibrationPoints(j)) {}
+      PrintMessage("Calibration points fitted.\n");
+      while (!drs->GetBoard(i)->GetResponseCalibration()->OffsetCalibration(j)) {}
+      PrintMessage("Offset calibration done.\n");
+
+      if (!drs->GetBoard(i)->GetResponseCalibration()->WriteCalibration(j)) break;
+    }        
+    drs->GetBoard(i)->Init(); // Reset linear range -0.2 ... 0.8 V
+  } // Loop over boards
 }
 
@@ -650,5 +686,5 @@
 // Print feedback configuration
 void DAQReadout::cmd_fconfig() {
-  HVFB->PrintConfig();
+  HVFB->PrintConfig(CmdFromSocket ? MsgToSocket : MsgToConsole);
 }
 
@@ -799,65 +835,4 @@
 }
 
-// Do internal calibration
-void DAQReadout::CalibrateDRS(char *dir, double trigfreq, double calibfreq) {
-
-  int i,j;
-  char str[MAX_COM_SIZE];
-  DIR *pdir;
-      
-  if (NumBoards) {
-    if(dir!=NULL) {
-      if ((pdir=opendir(str))==0){
-	PrintMessage("Error: target directory \"%s\" does not exist!\n",str);
-        return;
-      }
-      closedir(pdir);
-      snprintf(str,sizeof(str),"%s",dir);
-      PrintMessage("Target: \"%s\"\n",str);
-    }
-    else {
-      getcwd(str, sizeof(str));
-      strcat(str,"/calib");
-      PrintMessage("Taking default target: \"%s/\"\n",str);
-    }
-        
-    for (i=FirstBoard; i<=LastBoard; i++) {
-      drs->GetBoard(i)->Init();
-      drs->GetBoard(i)->SetFrequency(calibfreq);
-      drs->GetBoard(i)->SoftTrigger();
-            
-      PrintMessage("Creating calibration of board %d\n", drs->GetBoard(i)->GetCMCSerialNumber());
-
-      drs->GetBoard(i)->EnableTcal(1);
-      PrintMessage("Tcal enabled");
-
-      if (drs->GetBoard(i)->GetChipVersion() == 3)
-	drs->GetBoard(i)->GetResponseCalibration()->SetCalibrationParameters(1,21,0,20,0,0,0,0,0);
-      else
-	drs->GetBoard(i)->GetResponseCalibration()->SetCalibrationParameters(1,36,110,20,19,40,15,trigfreq,0);
-            
-      drs->GetBoard(i)->SetCalibrationDirectory(str);
-      PrintMessage("Storage directory \"%s\"\n",str);
-
-      for (j=0;j<2;j++) {
-	drs->GetBoard(i)->GetResponseCalibration()->ResetCalibration();
-	PrintMessage("Calibration reset done.\n");
-
-	while (!drs->GetBoard(i)->GetResponseCalibration()->RecordCalibrationPoints(j)) {}
-	PrintMessage("Record calibration points done.\n");
-	while (!drs->GetBoard(i)->GetResponseCalibration()->FitCalibrationPoints(j)) {}
-	PrintMessage("Calibration points fitted.\n");
-	while (!drs->GetBoard(i)->GetResponseCalibration()->OffsetCalibration(j)) {}
-	PrintMessage("Offset calibration done.\n");
-
-	if (!drs->GetBoard(i)->GetResponseCalibration()->WriteCalibration(j))
-	  break;
-      }        
-      drs->GetBoard(i)->Init(); // Reset linear range -0.2 ... 0.8 V
-    } // Loop over boards   
-  }
-  else PrintMessage("No DRS boards available\n");
-}
-
 // Check if DRS is sampling
 bool DAQReadout::IsDRSBusy() {
@@ -871,5 +846,5 @@
 bool DAQReadout::IsDRSFreqSet() {
 
-  for (int i=FirstBoard;i<=LastBoard;i++)
+  for (int i=FirstBoard; i<=LastBoard; i++)
     if (DRSFreq[i]==0) {
       PrintMessage("DRS sampling frequency of board %d not set!\n",i);
@@ -992,7 +967,8 @@
 }
 
-// Write event header
-bool DAQReadout::WriteEventHeader() {
-
+// Write event
+bool DAQReadout::WriteEvent() {
+
+  // Event header
   struct timeval Time;
 
@@ -1000,5 +976,5 @@
   
   EHeader->EventNumber = NumEvents;
-  EHeader->TriggerType = (daq_runtype == data) ? 1 : 0;
+  EHeader->TriggerType = daq_runtype==data ? 0 : 1;
   EHeader->Second = Time.tv_sec;
   EHeader->Microsecond = Time.tv_usec;
@@ -1010,11 +986,8 @@
     return false;
   }
-  return true;
-}
-
-// Write event data (It is required that at least three chunks can be written with writev(), therefore
-// IOV_MAX>=3 is checked at startup
-bool DAQReadout::WriteEventData() {
-
+  
+  // Event data (It is required that at least three chunks can be written with writev(), therefore
+  // IOV_MAX>=3 is checked at startup
+  
   unsigned int Start, Count = 0;
   ssize_t WriteResult, Size = 0;
@@ -1022,5 +995,5 @@
 
   // First chunk: trigger cells
-  DataPart[Count].iov_base = TriggerCell + FirstBoard*kNumberOfChips;
+  DataPart[Count].iov_base = (char *) TriggerCell + FirstBoard*kNumberOfChips*sizeof(int); // TriggerCell is without cast a pointer to an 8-byte unit (two ints) !
   DataPart[Count++].iov_len = RHeader->NBoards * kNumberOfChips * sizeof(int);
   Size += DataPart[Count-1].iov_len;
@@ -1054,5 +1027,17 @@
     } // Chips
   } // Boards
+  
   return true;
+}
+
+// Print configuration to target
+void DAQReadout::PrintConfig(int Target) {
+  PrintMessage(Target, "LogFile: %s\tMaxLogLines: %u\tRawDataPath: %s\n"
+      	       "DefaultFrequency: %.2f\tFirstSample: %d\tSamples: %u\n"
+     	       "MinDiskSpaceMB: %u\tMaxFileSizeMB: %d\tCCPort: %d\n"
+      	       "FirstVMESlot: %d\t\tLastVMESlot: %d\n"
+	       "SlowDataPath: %s\tHVFeedbackConfig: %s\n",
+    fLogFile,fMaxLogLines,fRawDataPath,fDefaultFrequency,fFirstSample,fSamples,fMinDiskSpaceMB,
+    fMaxFileSizeMB,fCCPort,fFirstVMESlot,fLastVMESlot,fSlowDataPath,fHVFeedbackConfig);
 }
 
@@ -1238,7 +1223,4 @@
       else if (m->daq_runtype == pedestal) m->StopDRS();   // ..or for software trigger
 
-      EventsInFile++;      m->NumEvents++;	
-      WriteError |= !m->WriteEventHeader();
-
       // Read event data via VME or generate test data (for one board if no boards available)
       if (m->daq_runtype != test) {
@@ -1252,6 +1234,7 @@
       }
 
-      // Write data to disk and update file size
-      WriteError |= !m->WriteEventData();
+      // Write event to disk and update file size
+      EventsInFile++;      m->NumEvents++;	
+      WriteError |= !m->WriteEvent();
 
       if((FileSize = lseek(m->Rawfile, 0, SEEK_CUR)) == -1) {
@@ -1273,16 +1256,16 @@
   } while((m->NumEvents<m->NumEventsRequested || m->NumEventsRequested==0) && !m->Stop && !WriteError);
 
-  // Print run summary to slow data file and to screen
   m->StopDRS();
-  if(!WriteError) {
-    m->PrintMessage("\rRun #%d (%s) %s, %d events\n",m->RunNumber,daq_runtype_str[m->daq_runtype],(m->NumEvents == m->NumEventsRequested) ? "completed":"stopped",m->NumEvents);
-    m->SlowDataClass->NewEntry("Runinfo");
-    m->SlowDataClass->AddToEntry("%d %s %s %d %d", m->RunNumber, daq_runtype_str[m->daq_runtype], m->RHeader->Description, m->NumEvents, m->FileNumber);
-    if(m->SlowDataClass->ErrorCode != 0) {
-      m->PrintMessage("Error, could not write DAQ data to file (%s), file closed\n", strerror(m->SlowDataClass->ErrorCode));
-    }
-
-  }
+  
+  // Print run summary to screen
+  if(!WriteError) m->PrintMessage("\rRun #%d (%s) %s, %d events\n",m->RunNumber,daq_runtype_str[m->daq_runtype],(m->NumEvents == m->NumEventsRequested) ? "completed":"stopped",m->NumEvents);
   else m->PrintMessage("\rRun #%d (%s) aborted due to error after %d events\n",m->RunNumber,daq_runtype_str[m->daq_runtype],m->NumEvents);
+
+  // Write run summary to slow data file
+  m->SlowDataClass->NewEntry("Runinfo");
+  m->SlowDataClass->AddToEntry("%d %s %s %d %d %s", m->RunNumber, WriteError?"Error":"OK", daq_runtype_str[m->daq_runtype], m->NumEvents, m->FileNumber, m->RHeader->Description);
+  if(m->SlowDataClass->ErrorCode != 0) {
+    m->PrintMessage("Error, could not write DAQ data to file (%s), file closed\n", strerror(m->SlowDataClass->ErrorCode));
+  }
 
   // Print run statistics
Index: /drsdaq/DAQReadout.h
===================================================================
--- /drsdaq/DAQReadout.h	(revision 91)
+++ /drsdaq/DAQReadout.h	(revision 92)
@@ -54,4 +54,5 @@
     // Configuration data
     char fLogFile[MAX_PATH];
+    char fSlowDataPath[MAX_PATH];
     unsigned int fMaxLogLines;
     char fRawDataPath[MAX_PATH];
@@ -64,4 +65,5 @@
     int fFirstVMESlot;
     char fHVFeedbackConfig[MAX_PATH];
+    double fDefaultFrequency;
     
     // Status variables    
@@ -85,5 +87,6 @@
     char FileName[MAX_PATH];
     char Prompt[MAX_COM_SIZE];
-    
+    bool ConfigOK;
+       
     // Public functions
     DAQReadout(const char*);
@@ -114,5 +117,4 @@
     bool IsDRSFreqSet();
     void SetDRSFrequency(double, bool);
-    void CalibrateDRS(char*, double, double);
     void SetDOMINOMode(int);
     void SetDOMINOReadMode(int);
@@ -123,4 +125,5 @@
     bool IsCalibrationRead();
     void ReadCalibratedDRSData();
+    void PrintConfig(int);
     void PrintMessage(int, const char*, ...);
     void PrintMessage(const char*, ...);
@@ -129,6 +132,5 @@
     bool WriteRunHeader();
     bool UpdateRunHeader(unsigned int, bool);
-    bool WriteEventHeader();
-    bool WriteEventData();
+    bool WriteEvent();
 };
 
Index: /drsdaq/HVFeedback.cc
===================================================================
--- /drsdaq/HVFeedback.cc	(revision 91)
+++ /drsdaq/HVFeedback.cc	(revision 92)
@@ -24,5 +24,4 @@
 HVFeedback::HVFeedback(DAQReadout* DAQClass, char* Configfile) {
   struct sockaddr_in SocketAddress;
-  char Filename[MAX_PATH];
 
   m = DAQClass;
@@ -30,9 +29,11 @@
 
   // Create instance of slow data class for feedback
-  snprintf(Filename,sizeof(Filename),"%s/SlowData/", m->fRawDataPath);
-  SlowDataClass = new SlowData("HVFB", Filename);
+  SlowDataClass = new SlowData("HVFB", m->fSlowDataPath);
   if (SlowDataClass->ErrorCode != 0) {
     m->PrintMessage("Warning: Could not open feedback slowdata file (%s)\n", strerror(SlowDataClass->ErrorCode));
   }
+  SlowDataClass->NewEntry("Average-Info", "Feedback regulation occurred: Board Chip Channel Average Sigma Correction-Value");
+  SlowDataClass->NewEntry("Target-Info", "New Target values acquired: Board Chip Channel Target Sigma");
+  SlowDataClass->NewEntry("Response-Info", "New response measurement: Board Chip Channel Response");
 
   // Initialise with zero content
@@ -65,5 +66,5 @@
     fclose(File);
   }
-  PrintConfig();
+  PrintConfig(MsgToLog);
  
   // Initial state
@@ -373,6 +374,6 @@
 // Print feedback configuration
 //
-void HVFeedback::PrintConfig() {
-  m->PrintMessage("LedTrigBoard: %d\t\tLedTrigChip: %d\t\tLedTrigChannel: %d\n"
+void HVFeedback::PrintConfig(int Target) {
+  m->PrintMessage(Target, "LedTrigBoard: %d\t\tLedTrigChip: %d\t\tLedTrigChannel: %d\n"
         "LedTrigSample: %d\tLedTrigThreshold: %.2f\n"
         "LedSignalSample: %d\tLedBaselineSample: %d\tDefaultNumAverage: %d\n"
Index: /drsdaq/HVFeedback.h
===================================================================
--- /drsdaq/HVFeedback.h	(revision 91)
+++ /drsdaq/HVFeedback.h	(revision 92)
@@ -64,5 +64,5 @@
     void ClearAverages();
     bool WriteHVCommand(const char *, ...);
-    void PrintConfig();
+    void PrintConfig(int);
 };
 
Index: /drsdaq/History.txt
===================================================================
--- /drsdaq/History.txt	(revision 91)
+++ /drsdaq/History.txt	(revision 92)
@@ -41,3 +41,9 @@
 18/6/2009   Run date is now calculated with a change to the next date on 13:00 UTC.
 9/7/2009    SlowData class is now independet of PrintMessage() method, thus more
-	    universal	    
+	    universal
+14/7/2009   Fixed assignment of trigger type in event header (now 0  is hardware
+    	    trigger, 1 software trigger). Fixed pointer-arithmetic for trigger cell
+	    writing if first board written to disk is not physically first board.	    
+28/7/2009   Added configuration parameters SlowDataPath and DefaultFrequency. All
+    	    configuration parameters are now mandatory: if one is not found, the
+	    program terminates.
Index: /drsdaq/SlowData.cc
===================================================================
--- /drsdaq/SlowData.cc	(revision 91)
+++ /drsdaq/SlowData.cc	(revision 92)
@@ -3,6 +3,15 @@
   SlowData.cc
 
-  Class handling the writing of slow data. String to be written in the
+  Class handling the writing of slow data. Strings to be written in the
   slow data file are checked that they do not contain control characters.
+  
+  1. Call constructor with desired identification and directory
+     for slow data file. The public ErrorCode variable will be zero 
+     if successful, otherwise contain the relevant errno.
+  2. Use NewEntry() to start a new entry with given variable name. A text
+     as second argument is optional.
+  3. If text should be added to an open entry, use AddToEntry(). It can
+     process printf()-style formatting.
+  4. The slow data file will be closed upon destruction of the instance.  
     
   Oliver Grimm
@@ -45,5 +54,5 @@
 // Add a new entry to slow data file
 //
-bool SlowData::NewEntry(const char *Variable) {
+bool SlowData::NewEntry(const char *Variable, const char *Text) {
 
   time_t RawTime;
@@ -57,4 +66,6 @@
   NewEntryCalled = AddToEntry("\n%s %s %d %d %d %d %d %d %d %lu ", Issuer, Variable, TM->tm_year+1900,TM->tm_mon+1,TM->tm_mday,TM->tm_hour,TM->tm_min,TM->tm_sec, Time.tv_usec/1000, Time.tv_sec);
   InternalCall = false;
+  if(Text != NULL && NewEntryCalled == true) NewEntryCalled = AddToEntry("%s", Text);
+
   return NewEntryCalled;
 }
@@ -65,5 +76,5 @@
 bool SlowData::AddToEntry(const char *Format, ...) {
 
-  char Textbuffer[MAX_COM_SIZE];
+  char Textbuffer[MAX_ENTRY_SIZE];
   va_list ArgumentPointer;
 
Index: /drsdaq/SlowData.h
===================================================================
--- /drsdaq/SlowData.h	(revision 91)
+++ /drsdaq/SlowData.h	(revision 92)
@@ -12,5 +12,5 @@
 
 #define MAX_PATH 256
-#define MAX_COM_SIZE 10000
+#define MAX_ENTRY_SIZE 10000
 
 class SlowData {
@@ -26,5 +26,5 @@
 
     int ErrorCode;	// Set to errno if an error occured, zero otherwise
-    bool NewEntry(const char*);
+    bool NewEntry(const char*, const char* = NULL);
     bool AddToEntry(const char*, ...);
 };
Index: /drsdaq/drsdaq.cpp
===================================================================
--- /drsdaq/drsdaq.cpp	(revision 91)
+++ /drsdaq/drsdaq.cpp	(revision 92)
@@ -85,26 +85,33 @@
   signal(SIGHUP, &CrashHandler);
     
-  // Construct main instance
+  // Construct main instance and create mutex for thread synchronization
   DAQReadout dreadout(argc==3 ? argv[2] : DEFAULT_CONFIG);
-
-  // Create threads and mutex for thread synchronization
   if (pthread_mutex_init(&dreadout.control_mutex, NULL) != 0) {
     perror("pthread_mutex_init failed");
     throw;
   }
-  if ((pthread_create(&thread_ConsoleCommand, NULL, (void * (*)(void *)) ConsoleCommand,(void *) &dreadout)) != 0) {
-    perror("pthread_create failed with console thread");
-    throw;
-  }
-  if ((pthread_create(&thread_CCCommand, NULL, (void * (*)(void *)) CCCommand,(void *) &dreadout)) != 0) {
-    perror("pthread_create failed with socket thread");
-    dreadout.SocketThread = NULL;
-  }
-  else dreadout.SocketThread = &thread_CCCommand;  // Thread should be accessible for sending signals  
- 
-  // Wait for threads to quit
-  pthread_join(thread_ConsoleCommand, NULL);
-  if(dreadout.SocketThread != NULL) pthread_join(thread_CCCommand, NULL);
-
+
+  if (dreadout.ConfigOK) { // Normal program execution only if configuration was complete
+    // Create threads
+    if (pthread_mutex_init(&dreadout.control_mutex, NULL) != 0) {
+      perror("pthread_mutex_init failed");
+      throw;
+    }
+    if ((pthread_create(&thread_ConsoleCommand, NULL, (void * (*)(void *)) ConsoleCommand,(void *) &dreadout)) != 0) {
+      perror("pthread_create failed with console thread");
+      throw;
+    }
+    if ((pthread_create(&thread_CCCommand, NULL, (void * (*)(void *)) CCCommand,(void *) &dreadout)) != 0) {
+      perror("pthread_create failed with socket thread");
+      dreadout.SocketThread = NULL;
+    }
+    else dreadout.SocketThread = &thread_CCCommand;  // Thread should be accessible for sending signals  
+
+    // Wait for threads to quit
+    pthread_join(thread_ConsoleCommand, NULL);
+    if(dreadout.SocketThread != NULL) pthread_join(thread_CCCommand, NULL);
+  }
+  else printf("Error: Configuration parameter missing in %s, terminating.\n", argc==3 ? argv[2] : DEFAULT_CONFIG);
+  
   // Destruct mutex and main instance
   pthread_mutex_destroy (&dreadout.control_mutex);
@@ -135,8 +142,11 @@
   
   while (!m->Exit) {
+  
+    // Assemble prompt
     if (m->NumBoards == 0) snprintf(m->Prompt,sizeof(m->Prompt),"\rDAQ> "); 
     else if (m->FirstBoard == m->LastBoard) snprintf(m->Prompt,sizeof(m->Prompt),"\rDAQ|B%d> ",m->FirstBoard); 
     else snprintf(m->Prompt,sizeof(m->Prompt),"\rDAQ|B%d-%d> ",m->FirstBoard,m->LastBoard); 
 
+    // Read Command
     Command = readline(m->Prompt);
     if (Command==NULL) {
@@ -144,7 +154,7 @@
       continue;
     }
-
     if(strlen(Command)>0) add_history(Command);
 
+    // Log command
     strftime(Buf,MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL))));
     m->PrintMessage(MsgToLog, "CONSOLE(%s)> %s\n", Buf, Command);
@@ -199,4 +209,5 @@
   SocketAddress.sin_port = htons((unsigned short) m->fCCPort);
   SocketAddress.sin_addr.s_addr = INADDR_ANY;
+
   if (bind(ServerSocket, (struct sockaddr *) &SocketAddress, sizeof(SocketAddress)) == -1)
   {
@@ -223,5 +234,8 @@
     m->Socket = ConnectionSocket;
 
-    while (!m->Exit) { // Looping as long as client exists
+    // Looping as long as client exists and program not terminated
+    while (!m->Exit) {
+
+      // Try to read command from socket
       memset(Command,0,sizeof(Command));
       ReadResult = read(ConnectionSocket, Command, MAX_COM_SIZE);
@@ -233,4 +247,5 @@
       if (Command[strlen(Command)-1]=='\n') Command[strlen(Command)-1]='\0';  // Remove trailing newline
       
+      // Log command
       strftime(Buf, MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL))));
       m->PrintMessage(MsgToConsole|MsgToLog, "SOCKET(%s)> %s\n", Buf, Command);
@@ -238,9 +253,10 @@
       // Process command     
       pthread_mutex_lock(&m->control_mutex);
-      m->CmdFromSocket = true;       
+      m->CmdFromSocket = true;
       m->CommandControl(Command);
-      m->CmdFromSocket = false;  
+      m->CmdFromSocket = false;
       pthread_mutex_unlock(&m->control_mutex);
     }
+
     m->Socket = -1;
     m->PrintMessage("Disconnected from client.\n");
