chiark / gitweb /
make simulation log short even with -v4
authorian <ian>
Sat, 24 May 2008 19:25:02 +0000 (19:25 +0000)
committerian <ian>
Sat, 24 May 2008 19:25:02 +0000 (19:25 +0000)
hostside/common.h
hostside/realtime.c
hostside/realtime.h
hostside/startup.c

index 6e4e19e64fe12356d7e5ac4107c7da5d2d369851..debc0849c7c138a95f26018747826c30750013f9 100644 (file)
@@ -152,8 +152,7 @@ void nmra_encodeforpic(const Nmra *packet, PicInsn *pi_out);
 
 #define ARRAY_SIZE(a) (sizeof((a))/sizeof(*(a)))
 #define ARRAY_END(a) ((a) + ARRAY_SIZE((a)))
-
 #define CTYPE(isfoobar,ch) (isfoobar((unsigned char)(ch)))
-
+#define COMMA ,
 
 #endif /*COMMON_H*/
index 40e1b2942d0a13bc34eff293e99f310154d96837..4a4f35c8661a6f203047012badd4fb5d64fb37e3 100644 (file)
@@ -74,13 +74,13 @@ void ouprintf(const char *fmt, ...) {
   va_end(al);
 }
 
-void do_dvprintf(const char *fmt, va_list al) {
+void ouvprintf_only(const char *fmt, va_list al) {
   ovprintf(&cmdi.out, fmt,al);
 }
-void do_dprintf(const char *fmt, ...) {
+void ouprintf_only(const char *fmt, ...) {
   va_list al;
   va_start(al,fmt);
-  do_dvprintf(fmt,al);
+  ouvprintf_only(fmt,al);
   va_end(al);
 }
 
@@ -195,13 +195,14 @@ int vbadcmd(ParseState *ps, const char *fmt, va_list al) {
   return EC_BadCmd;
 }
 
-void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v) {
+void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v,
+            void (*qprintf)(const char *fmt, ...)) {
   if (!pii->argsbits)
-    ouprintf("picio %s %s\n", dirn, pii->name);
+    qprintf("picio %s %s\n", dirn, pii->name);
   else if (!pii->vbits)
-    ouprintf("picio %s %s %#x\n", dirn, pii->name, obj);
+    qprintf("picio %s %s %#x\n", dirn, pii->name, obj);
   else
-    ouprintf("picio %s %s %#x %d\n", dirn, pii->name, obj, v);
+    qprintf("picio %s %s %#x %d\n", dirn, pii->name, obj, v);
 }
 
 static void obc_error(OutBufferChain *ch, const char *e1, const char *e2) {
@@ -212,13 +213,18 @@ static void obc_error(OutBufferChain *ch, const char *e1, const char *e2) {
   exit(-1);
 }
 
+static void qouhex(const char *word, const Byte *command, int length,
+                  void (*qprintf)(const char *fmt, ...)) {
+  qprintf("%s", word);
+  while (length--) qprintf(" %02x", *command++);
+  qprintf("\n");
+}
+
 void ouhexo(const char *word, const Byte *command, int length) {
-  ouprintf("%s", word);
-  while (length--) ouprintf(" %02x", *command++);
-  ouprintf("\n");
+  qouhex(word,command,length, ouprintf);
 }
 void ouhexi(const char *word, const Byte *command, int length) {
-  ouhexo(word,command,length);
+  qouhex(word,command,length, ouprintf_only);
 }
 
 void die_vprintf_hook(const char *fmt, va_list al) {
@@ -306,7 +312,7 @@ void serial_transmit(const PicInsn *pi) {
     else if (pii->noiselevel > picio_send_noise)
       suppress= 1;
     else
-      oupicio("out",pii,obj,v);
+      oupicio("out",pii,obj,v,ouprintf);
   }
 
   if (!suppress && picio_send_noise >= 2)
index 6686336d85e8f95318cb3c97bb7fbcc4cc561c29..d4d3fafa6a8663f23230b1e51c7655116552e717 100644 (file)
@@ -149,7 +149,8 @@ void persist_map_veryearly(void);
 
 /*---------- from/for realtime.c ----------*/
 
-void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v);
+void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v,
+            void (*qprintf)(const char *fmt, ...));
 void ouhexi(const char *word, const Byte *command, int length);
 void ouhexo(const char *word, const Byte *command, int length);
 
@@ -235,17 +236,17 @@ extern unsigned rtfeats_use;
 void ouvprintf(const char *fmt, va_list al);
 void ouprintf(const char *fmt, ...);
 
-void do_dvprintf(const char *fmt, va_list al);
-void do_dprintf(const char *fmt, ...);
+void ouvprintf_only(const char *fmt, va_list al);
+void ouprintf_only(const char *fmt, ...);
 
 #define DEBUGP(a,k) (dflags_##a & DBIT_##a##_##k)
 
 #define COND_DPRINTF(cond, a,k, fmt, ...) \
 ((cond) ? do_dprintf("debug " #a "/" #k " : " fmt,##__VA_ARGS__) : (void)0)
((cond) ? ouprintf_only("debug " #a "/" #k " : " fmt,##__VA_ARGS__) : (void)0)
 
 #define DPRINTF(a,k,f,...) COND_DPRINTF(DEBUGP(a,k),a,k,f,##__VA_ARGS__)
 #define DPRINTF1(a,k,f,...) COND_DPRINTF((DP)=DEBUGP(a,k), a,k,f,##__VA_ARGS__)
-#define DPRINTF2(f,...) ((DP) ? do_dprintf(f,##__VA_ARGS__) : (void)0)
+#define DPRINTF2(f,...) ((DP) ? ouprintf_only(f,##__VA_ARGS__) : (void)0)
 
 /*---------- tbi ----------*/
 
index 72d595b4bf3e091dbf03562b54821c118a91ff0d..dd6fd0cb3de94f232257ae5de689c7f4947d7144 100644 (file)
@@ -221,15 +221,15 @@ void serial_moredata(PicInsn *buf) {
 
   if (!suppress && picio_send_noise >= 2)
     ouhexi("picioh in msg", buf->d, buf->l);
-  else
-    if (simlog_full || sta_state < Sta_Settling ||
-       !((pii->opcode==PICMSG_NMRADONE && obj==1) ||
-         (pii->opcode==PICMSG_PONG && obj==pong_seq)))
-      simlog_serial(buf->d, buf->l);
+
+  if (simlog_full || sta_state < Sta_Settling ||
+      !((pii->opcode==PICMSG_NMRADONE && obj==1) ||
+       (pii->opcode==PICMSG_PONG && obj==pong_seq)))
+    simlog_serial(buf->d, buf->l);
   
   if (!pii) { ouprintf("picio in unknown\n"); return; }
   if (!suppress)
-    oupicio("in",pii,obj,v);
+    oupicio("in",pii,obj,v,ouprintf_only);
   pii->input_fn(pii,buf,obj);
 }
 
@@ -292,8 +292,8 @@ static SegmentNum on_pic_detect_prep(int detyn, int objnum) {
   if (!(picio_send_noise <= 1 &&
        segments[segn].owner &&
        segments[segn].det_ignore))
-    ouprintf("picio in-info detect %d %s\n",
-            detyn, info_segments[segn].pname);
+    ouprintf_only("picio in-info detect %d %s\n",
+                 detyn, info_segments[segn].pname);
 
   return segn;
 }