Index: /hvcontrol/src/HV.cc
===================================================================
--- /hvcontrol/src/HV.cc	(revision 112)
+++ /hvcontrol/src/HV.cc	(revision 113)
@@ -30,4 +30,5 @@
   WrapOK = true;
   LastWrapCount = -1;
+  ErrorCount = 0;
   
   ClearVoltageArrays();
@@ -87,6 +88,8 @@
   
   // === Write data ===
-  if (write(fDescriptor, wbuf, Bytes) < Bytes) {
-    m->PrintMessage("Error: Could not write (all) data to HV board\n");
+  if ((ret=write(fDescriptor, wbuf, Bytes)) < Bytes) {
+    if (ret == -1) m->PrintMessage("Could not write data to HV board (%s)\n", strerror(errno));
+    else m->PrintMessage("Could write only %d of %d bytes to HV board\n", ret, Bytes);
+    ErrorCount++;
     return 0;
   }
@@ -100,5 +103,5 @@
   struct timeval WaitTime = {(long) fTimeOut, (long) ((fTimeOut-(long) fTimeOut)*1e6)};
   if (select(fDescriptor+1, &SelectDescriptor, NULL, NULL, &WaitTime)==-1) {
-    m->PrintMessage("Error with select() (%d/%s)\n", errno,strerror(errno));
+    m->PrintMessage("Error with select() (%s)\n", strerror(errno));
     return 0;
   }
@@ -111,4 +114,5 @@
   if ((ret = read(fDescriptor, &rbuf, 1)) == -1) {
     m->PrintMessage("Read error (%s)\n", strerror(errno));
+    ErrorCount++;
     return 0;
   }
@@ -135,5 +139,8 @@
   int ret;
   
-  if((ret = Communicate(wbuf, 3)) == 1) ClearVoltageArrays();  
+  if((ret = Communicate(wbuf, 3)) == 1) {
+    ClearVoltageArrays();
+    ErrorCount = 0;
+  }  
   return ret;
 }
Index: /hvcontrol/src/HV.h
===================================================================
--- /hvcontrol/src/HV.h	(revision 112)
+++ /hvcontrol/src/HV.h	(revision 113)
@@ -46,5 +46,6 @@
    int LastWrapCount;
    double fTimeOut;      // [s] timeout to return from read 
-  
+   int ErrorCount;
+   
    char *BoardName; 
    int HV[NUM_CHAINS][NUM_CHANNELS];      // HV value in DAC units
Index: /hvcontrol/src/ProcessIO.cc
===================================================================
--- /hvcontrol/src/ProcessIO.cc	(revision 112)
+++ /hvcontrol/src/ProcessIO.cc	(revision 113)
@@ -163,5 +163,5 @@
 		  config->NumHVBoards);  
     for (int i=0; i<config->NumHVBoards; i++) { 
-      PrintMessage(" Board %d: %s\n ", i, config->fUSBDevice[i]);
+      PrintMessage(" Board %d: %s\n", i, config->fUSBDevice[i]);
     }
     PrintMessage( " TimeOut:           %.2f s\n"
@@ -439,24 +439,25 @@
     PrintMessage(" Socket state: %s\n", Socket==-1 ? "disconnected":"connected");
     PrintMessage(" Total number of HV boards: %d\n", NumHVBoards);
-    PrintMessage(" Active HV boards: %d\n\n ", LastBoard - FirstBoard + 1);
+    PrintMessage(" Active HV boards: %d\n\n", LastBoard - FirstBoard + 1);
 
     for (int i=FirstBoard; i<=LastBoard; i++) {
-      PrintMessage(" BOARD %d (%s)   Wrap counter: %s (%d)  Manual reset: %s  Time-out: %.2f s\n\n",
+      PrintMessage(" BOARD %d (%s)   Wrap counter: %s (%d)  Manual reset: %s\n    Time-out: %.2f s  Error count: %d\n\n",
 	fHVBoard[i]->GetBoardNumber(), fHVBoard[i]->BoardName,
 	fHVBoard[i]->WrapOK ? "ok":"error",
 	fHVBoard[i]->LastWrapCount, 
 	fHVBoard[i]->ResetButton ? "yes" : "no",
-	fHVBoard[i]->fTimeOut);
+	fHVBoard[i]->fTimeOut,
+	fHVBoard[i]->ErrorCount);
 
       for (int j=FirstChain; j<=LastChain; j++) {
-	PrintMessage("  CHAIN %d     Over-current: %s\n ", j, fHVBoard[i]->Overcurrent[j] ? "yes" : "no");
+	PrintMessage("  CHAIN %d     Over-current: %s\n", j, fHVBoard[i]->Overcurrent[j] ? "yes" : "no");
 	for (int k=0;k<4;k++) {
+          PrintMessage("\r");
 	  for (int l=0;l<8;l++) {
 	    if(NParam == 2) PrintMessage("%5d ",fHVBoard[i]->HV[j][k*8+l]);
     	    else PrintMessage("%#5.2f ",fHVBoard[i]->HVV[j][k*8+l]);
     	  }
-	  PrintMessage("\n ");
+	  PrintMessage("\n");
 	}
-	  PrintMessage("\n ");
       }
     }
@@ -554,5 +555,5 @@
   va_list ArgumentPointer;
   va_start(ArgumentPointer, Format); 
-  PrintMessage(Format, ArgumentPointer, Target);
+  DoPrintMessage(Format, ArgumentPointer, Target);
   va_end(ArgumentPointer);
 }
@@ -562,14 +563,12 @@
   va_list ArgumentPointer;
   va_start(ArgumentPointer, Format);
-  if (CmdFromSocket) PrintMessage(Format, ArgumentPointer, MsgToSocket|MsgToLog);
-  else PrintMessage(Format, ArgumentPointer, MsgToConsole|MsgToLog);
+  if (CmdFromSocket) DoPrintMessage(Format, ArgumentPointer, MsgToSocket|MsgToLog);
+  else DoPrintMessage(Format, ArgumentPointer, MsgToConsole|MsgToLog);
   va_end(ArgumentPointer);
 }
 
 // Function doing the actual printing work
-// It is important that Target is here the last argument, otherwise
-// there can be confusion with the variadic versions (this function is 
-// called instead of PrintMessage(int, const char *, ...)
-void ProcessIO::PrintMessage(const char *Format, va_list ArgumentPointer, int Target) {
+// Be careful with overloading variadic functions!
+void ProcessIO::DoPrintMessage(const char *Format, va_list ArgumentPointer, int Target) {
 
   char Textbuffer[MAX_COM_SIZE];
@@ -590,5 +589,5 @@
     write(Socket, Textbuffer, strlen(Textbuffer));
   }
-  // Print to log file (repace carriage return by linefeed)
+  // Print to log file (replace carriage return by linefeed)
   if((Target & MsgToLog) && Logfile!=NULL) {
     for (unsigned int i=0; i<strlen(Textbuffer); i++) {
@@ -630,19 +629,20 @@
 
 
-// Check board status
+// Check board status (ignore board if it has more than 10 read/write errors)
 void ProcessIO::Monitor() {
 
-  static unsigned int MismatchCount, ErrorCount;
+  static bool Warned = false;
   
   for (int i=0; i<NumHVBoards; i++) {
+    if (fHVBoard[i]->ErrorCount > 10) {
+      if (!Warned) {
+        Warned = true;
+        PrintMessage("Warning: Some board has many read/write errors, status monitor disabled\n");
+      }
+      continue;
+    }
 
     if (fHVBoard[i]->GetStatus() != 1) {
       PrintMessage("Error: Monitor could not read status of board %d\n", fHVBoard[i]->GetBoardNumber());
-      sleep(1);
-      if (ErrorCount++ > 10) {
-        PrintMessage("Too many errors from HV monitor, terminating program after next command\n");
-        Exit = true;
-        pthread_kill(SocketThread, SIGUSR1);
-      } 
     }
     
@@ -653,6 +653,5 @@
     
     if (!fHVBoard[i]->WrapOK) {
-      if (MismatchCount++>10) PrintMessage("Error: Wrap counter mismatch board %d\n",fHVBoard[i]->GetBoardNumber());
-      else PrintMessage("Too many wrap counter mismatches, stopping messages\n");
+      PrintMessage("Error: Wrap counter mismatch board %d\n",fHVBoard[i]->GetBoardNumber());
     }
 
Index: /hvcontrol/src/ProcessIO.h
===================================================================
--- /hvcontrol/src/ProcessIO.h	(revision 112)
+++ /hvcontrol/src/ProcessIO.h	(revision 113)
@@ -65,5 +65,5 @@
   void PrintMessage(int, const char *, ...);
   void PrintMessage(const char *, ...);
-  void PrintMessage(const char *, va_list, int);
+  void DoPrintMessage(const char *, va_list, int);
   void CommandControl(char*);
   bool RampVoltage(unsigned int, int, int, int);
