Index: trunk/Ohana/src/libohana/src/CommOps.c
===================================================================
--- trunk/Ohana/src/libohana/src/CommOps.c	(revision 26995)
+++ trunk/Ohana/src/libohana/src/CommOps.c	(revision 26996)
@@ -14,5 +14,5 @@
     return (status);
   }
-  // fprintf (stderr, "resp: %s\n", command.buffer);
+  // fprintf (stderr, "resp: (%d) %s\n", command.Nbuffer, command.buffer);
 
   /* buffer contains an EOL NULL, we can just sscan it */
@@ -21,4 +21,5 @@
   
   status = ExpectCommand (device, length, timeout, message);
+
   return (status);
 }
@@ -45,4 +46,5 @@
     
     if (Nread > 0) {
+      // fprintf (stderr, "read %d of %d\n", Nread, length - buffer[0].Nbuffer);
       buffer[0].Nbuffer += Nread;
       continue;
@@ -50,4 +52,6 @@
 
     if (Nread == -1) {
+      // fprintf (stderr, "errno: %d\n", errno);
+      // perror ("read error");
       switch (errno) {
 	case EAGAIN:
@@ -99,6 +103,46 @@
 int SendMessageFixed (int device, int length, char *message) {
 
+  int status;
+  int Nbytes, Nsent;
+  struct timespec request, remain;
+
+  // fprintf (stderr, "send fixed message, length = %d\n", length);
+
   if (!SendCommand (device, 16, "NBYTES: %6d", length)) return FALSE;
-  if (!SendCommand (device, length, message)) return FALSE;
+
+  /* avoid blocking on waitpid, test every 1000 usec, up to timeout msec */
+  request.tv_sec = 0;
+  request.tv_nsec = 1000000;
+
+  Nsent = 0;
+  while (Nsent < length) {
+    Nbytes = write (device, &message[Nsent], length - Nsent);
+    
+    // fprintf (stderr, "sent %d of %d\n", Nbytes, length - Nsent);
+
+    if (Nbytes > 0) {
+      Nsent += Nbytes;
+      continue;
+    }
+
+    if (Nbytes == -1) {
+      // fprintf (stderr, "errno: %d\n", errno);
+      // perror ("send error");
+      switch (errno) {
+	case EAGAIN:
+	case EIO:
+	  /** no data available in pipe, wait a bit, check for timeout **/
+	  nanosleep (&request, &remain);
+	  break;
+	default:
+	  /** error reading from pipe **/
+	  perror ("SendMessageFixed write error");
+	  return FALSE;
+      }
+    }
+    if (Nbytes == 0) return FALSE;
+  }
+  // if (!SendCommand (device, length, message)) return FALSE;
+
   return TRUE;
 }
@@ -124,4 +168,6 @@
   memset (string, 0, length + 1);
   vsnprintf (string, length + 1, format, argp);
+
+  // fprintf (stderr, "write command, length = %d\n", length);
 
   status = write (device, string, length);
