chiark / gitweb /
suppress noisy messages
authorian <ian>
Sun, 20 Jan 2008 18:31:55 +0000 (18:31 +0000)
committerian <ian>
Sun, 20 Jan 2008 18:31:55 +0000 (18:31 +0000)
hostside/.cvsignore
hostside/Makefile
hostside/parse-proto-spec
hostside/realtime.c
hostside/realtime.h
hostside/skelproto-pic.c
hostside/skelproto-pic.h
hostside/startup.c
hostside/stastate.h.gen [new file with mode: 0755]

index 82443edb81fe96de41fcb94c66a9fe0d53f7f943..1962df45c328568298fe2bcb459c00b6120cff7d 100644 (file)
@@ -10,6 +10,7 @@ auproto-*
 gui-plan-bot
 selectors.h
 errorcodes.h
+stastate.h
 retransmit-table.h
 record-l.[ch]
 record-y.[ch]
index 0c0bc2d6b297b9d0c89ba281b3b08d6d07f95f45..589bffa9d133ed8122484f5f2611feab5bfbbae6 100644 (file)
@@ -1,7 +1,7 @@
 #
 
 AUTOINCS=      auproto-pic.h layoutinfo.h selectors.h retransmit-table.h \
-               errorcodes.h
+               errorcodes.h stastate.h
 TARGETS=       hostside-old gui-plan-bot realtime
 
 include ../common.make
@@ -50,7 +50,7 @@ auproto-pic.c auproto-pic.h: auproto-%: \
 layoutinfo.h:  ../layout/ours.layout-data.c Makefile
                sed -e '/^#include/,$$d' $< $o
 
-selectors.h retransmit-table.h errorcodes.h: %: %.gen
+selectors.h retransmit-table.h errorcodes.h stastate.h: %: %.gen
                (echo "/*autogenerated*/" && ./$<) $o
 
 safety:                safety.o utils.o trackloc.o ../layout/ours.layout-data.o
index 5564ca2d5a1b95ffec0179c22c32ecf1cf76cafd..c35319ee7d5327565ffd24bcef66972de482dadc 100755 (executable)
@@ -92,6 +92,11 @@ sub process_line () {
        $v{yn}= $yval;
        $v{dname}= $dname;
        $v{cname}= $cname;
+       $v{noiselevel}=
+           ($cname =~ m/nmradone/ ? 3 :
+            $cname =~ m/p[io]ng/ ? 2 :
+            $cname =~ m/detect/ ? 1 :
+            0);
        $v{cnameyn}= $cname.$yval;
        $v{cnameynu}= uc($cname.$yval);
        $v{opcode}= b2xh($opcode, 0);
index 509ff1ba1b7be12cf37aecb1e0dbd975dc011c39..9972240583cc6cd596a1e790f29a59c0aa66415e 100644 (file)
@@ -9,6 +9,7 @@ const char *progname= "realtime";
 /*---------- global variables ----------*/
 
 CommandInput cmdi;
+int picio_send_noise= 1;
 
 static const char *device= "/dev/ttya0";
 
@@ -290,7 +291,7 @@ static void *serial_readable(oop_source *evts, int fd,
 
 void serial_transmit(const PicInsn *pi) {
   const PicInsnInfo *pii;
-  int objnum;
+  int objnum, suppress=0;
 
   if ((pi->d[0] & 0xf8) == 0x90) {
     SegmentNum segn;
@@ -308,16 +309,22 @@ void serial_transmit(const PicInsn *pi) {
     }
     oprintf(UPO,">\n");
   } else if (pi->d[0] == 0xff) {
-    oprint_nmradata(pi);
+    if (picio_send_noise < 3)
+      suppress= 1;
+    else 
+      oprint_nmradata(pi);
   } else {
     picinsn_decode(pi, pic_command_infos, &pii, &objnum);
     if (!pii)
       oprintf(UPO, "picio out unknown\n");
+    else if (pii->noiselevel > picio_send_noise)
+      suppress= 1;
     else
       oupicio("out",pii,objnum);
   }
 
-  ouhex("picioh out", pi->d, pi->l);
+  if (!suppress)
+    ouhex("picioh out", pi->d, pi->l);
 
   /* note that the serial port is still in nonblocking mode.  if
    * we ever buffer up far enough that the kernel wants to make us
index 541a5ef7cdf2685483791801f312d52b4f530574..94413e84f04678aadf4c1f44995aef5f0d4d618f 100644 (file)
@@ -69,25 +69,19 @@ void retransmit_urgent_cancel(RetransmitUrgentNode *rn);
 /*---------- global variables, in realtime.c ----------*/
 
 extern CommandInput cmdi;
+extern int picio_send_noise;
 
 #define UPO (&(cmdi.out))
 
 /*---------- from/for startup.c ----------*/
 
-typedef enum {   /* sta_toev   ping_toev    */
-  Sta_Flush,     /*  R 300      I ?         */
-  Sta_Off,       /*  I ?        I ?         */
-  Sta_Ping,      /*  I ?        I ?         */
-  Sta_Fault,     /*  I ?        R set       */
-  Sta_Settling,  /*  I ?        R set       */
-  Sta_Resolving, /*  I ?        R set       */
-  Sta_Run        /*  I ?        R set       */
-} StartupState;
+#include "stastate.h"
 
 void sta_startup(void);
 void serial_moredata(PicInsn *buf);
 
 extern StartupState sta_state;
+extern const char *const stastatelist[];
 
 /*---------- from/for record.c ----------*/
 
index 31895b2e84a979aad94583c3d4f24fb40f69b973..92c847d9caa787aba911f8cf09bd2c8ef2810be1 100644 (file)
@@ -68,11 +68,11 @@ void picinsn_decode(const PicInsn *pi, const PicInsnInfo *table,
 }
 
 const PicInsnInfo pic_command_infos[]= {
-  { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, 0 }, @h2p@
+  { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, @noiselevel@, 0 }, @h2p@
   { 0 }
 };
 
 const PicInsnInfo pic_reply_infos[]= {
-  { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, on_pic_@cnameyn@ },@p2h@
+  { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, @noiselevel@, on_pic_@cnameyn@ },@p2h@
   { 0 }
 };
index d30cad1d9c802a0ae64f292f7e6f9de173f26757..ee63e6492b2f9061cbb4d4627dcf6acf76753765 100644 (file)
@@ -34,7 +34,7 @@ void oopicio(const char *dirn, const PicInsnInfo *pii, int objnum);
 struct PicInsnInfo {
   const char *name;
   Byte opcode, mask;
-  int argbits;
+  int argbits, noiselevel;
   PicInputFn *input_fn;
 };
 
index 7efdc1a48fc4c23e74621ab271a5c8563937b153..458cb8e1e2dd5d0aa0264067696cadbb7684ab67 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "realtime.h"
 
+const char *const stastatelist[]= DEFINE_STASTATE_DATA;
 StartupState sta_state;
 
 static TimeoutEvent sta_toev;
@@ -86,13 +87,13 @@ static void sta_goto(StartupState new_state) {
   sta_state= new_state;
 
   /* notify various people: */
-  oprintf(UPO, "stastate %d\n", sta_state);
+  oprintf(UPO, "stastate %s\n", stastatelist[sta_state]);
   /* ... add others here. */
 }   
 
 void serial_moredata(PicInsn *buf) {
   const PicInsnInfo *pii;
-  int objnum;
+  int objnum, suppress;
   Byte *ep;
 
   /* Called when more data is received from PICs.
@@ -144,10 +145,13 @@ void serial_moredata(PicInsn *buf) {
  found_end:
   /* Aha! */
   buf->l= ep - buf->d + 1;
-  ouhex("picioh in msg", buf->d, buf->l);
   picinsn_decode(buf, pic_reply_infos, &pii, &objnum);
+  suppress= pii && pii->noiselevel > picio_send_noise;
+  if (!suppress)
+    ouhex("picioh in msg", buf->d, buf->l);
   if (!pii) { oprintf(UPO, "picio in unknown\n"); return; }
-  oupicio("in",pii,objnum);
+  if (!suppress)
+    oupicio("in",pii,objnum);
   pii->input_fn(pii,buf,objnum);
 }
 
diff --git a/hostside/stastate.h.gen b/hostside/stastate.h.gen
new file mode 100755 (executable)
index 0000000..faa07fb
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+Sta () { l="$l $1"; }
+
+                 # sta_toev   ping_toev
+  Sta Flush      #  R 300      I ?         
+  Sta Off        #  I ?        I ?         
+  Sta Ping       #  I ?        I ?         
+  Sta Fault      #  I ?        R set       
+  Sta Settling   #  I ?        R set       
+  Sta Resolving  #  I ?        R set       
+  Sta Run        #  I ?        R set       
+
+echo 'typedef enum {'
+for s in $l; do echo "  Sta_$s,"; done
+echo '} StartupState;
+#define DEFINE_STASTATE_DATA \'
+printf '  { '
+for s in $l; do printf '"%s",' $s; done
+echo '0 }'