]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
update, new function trb_strerrorf
authorhadaq <hadaq>
Fri, 11 Jun 2010 21:07:49 +0000 (21:07 +0000)
committerhadaq <hadaq>
Fri, 11 Jun 2010 21:07:49 +0000 (21:07 +0000)
libtrbnet/trberror.c
libtrbnet/trberror.h

index 2e8bf6051ad36f4fced19b2e2cb796d675c84a44..f86830f86b83dc372ede2a7bc62641fcf6e36622 100644 (file)
@@ -32,7 +32,7 @@ const char* trb_strerror(int trberrno)
     "FIFO Not Empty",
     "FIFO Timeout",
     "FIFO Error, invalid H0 header(s)",
-    "FIFO Error, invalid sequenze",
+    "FIFO Error, invalid sequence",
     "FIFO Error, invalid read-data-mode",
     "FIFO Incomplete Package",
     "FIFO Invalid Header-Type",
@@ -121,29 +121,42 @@ const char* trb_strterm(TRB_TERM term)
   unsigned int i;
   
   if (term.channel >= 4) {
-    snprintf(buffer, 2048, "INVALID ChannelId %d", term.channel);
+    sprintf(buffer, "INVALID ChannelId %d", term.channel);
     return buffer;
   }
-  
-  snprintf(buffer, 2048, 
-           "CommonStatusBits: 0x%04x, Channel#%d StatusBits: 0x%04x\n", 
-           term.status_common,
-           term.channel, 
-           term.status_channel);
+
+  sprintf(buffer,
+          "CommonStatusBits: 0x%04x, Channel#%d StatusBits: 0x%04x", 
+          term.status_common,
+          term.channel, 
+          term.status_channel);
+
   for (i = 0; i < 16; i++) {
     if ((term.status_common & (0x01 << i)) != (i != 0 ? 0 : 1)) {
-      strncat(buffer, "   ", 2048);
-      strncat(buffer, commonStatusBits[i], 2048); 
-      strncat(buffer, "\n", 2048);
+      strcat(buffer, "\n   ");
+      strcat(buffer, commonStatusBits[i]); 
     }
   }
   for (i = 0; i < 16; i++) {
     if ((term.status_channel & (0x01 << i)) != 0) {
-      strncat(buffer, "   ", 2048);
-      strncat(buffer, chStatusBits[term.channel] + 64 * i, 2048);
-      strncat(buffer, "\n", 2048);
+      strcat(buffer, "\n   ");
+      strcat(buffer, chStatusBits[term.channel] + 64 * i);
     }
   }
   
   return buffer;
 }
+
+const char* trb_strerrorf()
+{
+  static char buffer[4096] = "";
+  
+  if (trb_errno == TRB_STATUS_ERROR) {
+    snprintf(buffer, 4096, "%s\n%s",
+             trb_strerror(trb_errno), trb_strterm(trb_term));
+  } else {
+    snprintf(buffer, 4096, "%s", trb_strerror(trb_errno));
+  }
+  
+  return buffer;
+}
index 5f1dc3580be524d8de53ed3f15b7c0722f8f2e8a..9b1a7684cd6b18d602e7cb88f5e46b059ae9996f 100644 (file)
@@ -56,6 +56,8 @@ extern TRB_TERM trb_term;
 
 const char* trb_strterm(TRB_TERM term);
 
+const char* trb_strerrorf();
+
 #ifdef __cplusplus
 }
 #endif