Index: fact/BIASctrl/BIASctrl.cc
===================================================================
--- fact/BIASctrl/BIASctrl.cc	(revision 11204)
+++ fact/BIASctrl/BIASctrl.cc	(revision 11205)
@@ -29,5 +29,6 @@
   siginterrupt(SIGTERM, true);
 
-  system("clear");                   
+  if (system("clear") == -1) printf("Error with system() call\n");
+                   
   printf("\n*** BIASctrl (compiled %s, %s) ***\n\n", __DATE__, __TIME__);
    
Index: fact/BIASctrl/Crate.cc
===================================================================
--- fact/BIASctrl/Crate.cc	(revision 11204)
+++ fact/BIASctrl/Crate.cc	(revision 11205)
@@ -134,5 +134,5 @@
 	FD_ZERO(&SelectDescriptor);   FD_SET(fDescriptor, &SelectDescriptor);
 	if (select(fDescriptor+1, &SelectDescriptor, NULL, NULL, &WaitTime)==-1) {
-	  if (errno = EINTR) goto ExitCommunicate;  // in case program is exiting
+	  if (errno == EINTR) goto ExitCommunicate;  // in case program is exiting
       m->Message(m->FATAL, "Error with select() (%s)", strerror(errno));
 	}
Index: fact/BIASctrl/History.txt
===================================================================
--- fact/BIASctrl/History.txt	(revision 11204)
+++ fact/BIASctrl/History.txt	(revision 11205)
@@ -12,2 +12,3 @@
 			Added 'crate' command. Changed signaling of program exit.
 3/6/2011	Fixed bug in channel addressing from board numbers above 7.
+28/6/2011	Adapted for compilation under ubuntu
Index: fact/BIASctrl/Makefile
===================================================================
--- fact/BIASctrl/Makefile	(revision 11204)
+++ fact/BIASctrl/Makefile	(revision 11205)
@@ -6,5 +6,5 @@
 
 CPPFLAGS = -O3 -Wall $(INCDIRS)
-LDLIBS = -L/usr/lib/termcap -lstdc++ -lpthread -lfl -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
+LDLIBS = -L/usr/lib/termcap -lstdc++ -lpthread -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
 
 BIASctrl: $(OBJECTS)
Index: fact/BIASctrl/User.cc
===================================================================
--- fact/BIASctrl/User.cc	(revision 11204)
+++ fact/BIASctrl/User.cc	(revision 11205)
@@ -114,5 +114,7 @@
   // Shell command
   if(Command[0]=='.') {
-    system(Command.c_str()+1);
+    if (system(Command.c_str()+1) == 1) {
+	  PrintMessage("Error with system() call\n");
+	}
     return;
   }
@@ -620,5 +622,5 @@
 bool User::ConvertToRange(string String, struct User::Range &R) {
 
-  int N, M;
+  int N=0, M=0; // Init to avoid compiler warning
 
   // Full range
Index: fact/Evidence/DColl.cc
===================================================================
--- fact/Evidence/DColl.cc	(revision 11204)
+++ fact/Evidence/DColl.cc	(revision 11205)
@@ -260,5 +260,5 @@
 	struct tm *TM = localtime(&RawTime);
 
-	fprintf(DataFile, "%s %d %d %d %d %d %d %d %d %lu ", I->getName(), I->getQuality(), TM->tm_year+1900, TM->tm_mon+1, TM->tm_mday, TM->tm_hour, TM->tm_min, TM->tm_sec, I->getTimestampMillisecs(), I->getTimestamp());
+	fprintf(DataFile, "%s %d %d %d %d %d %d %d %d %d ", I->getName(), I->getQuality(), TM->tm_year+1900, TM->tm_mon+1, TM->tm_mday, TM->tm_hour, TM->tm_min, TM->tm_sec, I->getTimestampMillisecs(), I->getTimestamp());
 
 	// Translate data into ASCII
Index: fact/FADctrl/FAD.cc
===================================================================
--- fact/FADctrl/FAD.cc	(revision 11204)
+++ fact/FADctrl/FAD.cc	(revision 11205)
@@ -138,5 +138,5 @@
   // Shell command
   if (*Command == '.') {
-    system(Command+1);
+    if (system(Command+1) == -1) PrintMessage("Error with system() call\n");
     return;
   }
@@ -1216,5 +1216,5 @@
 bool FAD::ConvertToRange(string String, struct FAD::Range &R) {
 
-  int N, M;
+  int N=0, M=0;
 
   // Full range
Index: fact/FADctrl/FAD.h
===================================================================
--- fact/FADctrl/FAD.h	(revision 11204)
+++ fact/FADctrl/FAD.h	(revision 11205)
@@ -16,4 +16,5 @@
 #include <dirent.h>
 #include <sys/time.h>
+#include <sys/stat.h>
 #include <limits>
 #include <fcntl.h>
Index: fact/FADctrl/FADBoard.cc
===================================================================
--- fact/FADctrl/FADBoard.cc	(revision 11204)
+++ fact/FADctrl/FADBoard.cc	(revision 11205)
@@ -513,5 +513,4 @@
 	  for (unsigned int i=0; i<NDAC; i++) Status.DAC[i] = ntohs(Header->dac[i]);
 
-	  short Buf;
 	  for (unsigned int Chip=0; Chip<NChips; Chip++) {
 		// Extract trigger cells	  
@@ -522,9 +521,9 @@
 		  Status.ROI[Chip][Chan] = ntohs(Channel[Chip+NChips*Chan]->roi);
 
-		  // Extract ADC data (stored in 12 bit signed twis complement with out-of-range-bit and leading zeroes)
-		  for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
-			  Buf = (Channel[Chip+NChips*Chan]->adc_data[i]);
-			  (Buf <<= 4) >>= 4;			//delete the sign-bit by shifting left and shift back
-			  Data[Chip][Chan][i] = Buf;					
+		  // Extract ADC data (stored as signed short)
+		  // FADs ADC is 12 bit (values -2048 .. 2047)
+		  // negative/positive overflow is -2049 / +2048
+		  for (int i=0; i<Status.ROI[Chip][Chan]; i++) {			  
+			Data[Chip][Chan][i] = Channel[Chip+NChips*Chan]->adc_data[i];
 		  }
 		}
Index: fact/FADctrl/FADctrl.cc
===================================================================
--- fact/FADctrl/FADctrl.cc	(revision 11204)
+++ fact/FADctrl/FADctrl.cc	(revision 11205)
@@ -28,5 +28,7 @@
   read_history(READLINE_HIST_FILE.c_str());
 
-  system("clear");
+  if (system("clear") == -1) {
+	printf("Error with system() call\n");
+  }
   printf("\n*** FADctrl (built %s, %s, revision %s) *** \n\n",__DATE__, __TIME__, REVISION);
 
Index: fact/Feedback/Feedback.cc
===================================================================
--- fact/Feedback/Feedback.cc	(revision 11204)
+++ fact/Feedback/Feedback.cc	(revision 11205)
@@ -224,5 +224,5 @@
 
   // Calculate average signal  
-  for (unsigned int i=0; i<Parameter.size()-1, i<fIDTable.size(); i++) {
+  for (unsigned int i=0; i<Parameter.size()-1 && i<fIDTable.size(); i++) {
 	Average[i] += atof(Parameter[i+1].c_str());
 	Sigma[i] += pow(atof(Parameter[i+1].c_str()), 2);
@@ -465,5 +465,5 @@
   char *Command;
 
-  system("clear");
+  if (system("clear") == -1) printf("Error with system() call\n");
   printf("\n*** Bias feedback (built %s, %s, revision %s) *** \n\n",__DATE__, __TIME__, REVISION);
 
Index: fact/Feedback/Makefile
===================================================================
--- fact/Feedback/Makefile	(revision 11204)
+++ fact/Feedback/Makefile	(revision 11205)
@@ -12,5 +12,5 @@
 
 CPPFLAGS = -DREVISION='"$(REVISION)"' -O3 -Wall
-LIBS = -L /usr/lib/termcap -lstdc++ -lz -lpthread -lutil -lfl -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
+LIBS = -L /usr/lib/termcap -lstdc++ -lz -lpthread -lutil -lreadline -ltermcap $(DIMDIR)/linux/libdim.a
 
 Feedback: $(OBJECTS)
