chiark / gitweb /
actually log non-Run/Resolving hex, and ping timeouts, to simulation log
authorian <ian>
Sun, 8 Jun 2008 16:25:46 +0000 (16:25 +0000)
committerian <ian>
Sun, 8 Jun 2008 16:25:46 +0000 (16:25 +0000)
hostside/realtime.c
hostside/realtime.h
hostside/simulate.c
hostside/startup.c

index 4a4f35c8661a6f203047012badd4fb5d64fb37e3..ee6c29e57117cad8ee02d87c83567bccaed1465b 100644 (file)
@@ -220,10 +220,10 @@ static void qouhex(const char *word, const Byte *command, int length,
   qprintf("\n");
 }
 
-void ouhexo(const char *word, const Byte *command, int length) {
+void ouhex(const char *word, const Byte *command, int length) {
   qouhex(word,command,length, ouprintf);
 }
-void ouhexi(const char *word, const Byte *command, int length) {
+void ouhex_nosim(const char *word, const Byte *command, int length) {
   qouhex(word,command,length, ouprintf_only);
 }
 
@@ -316,7 +316,7 @@ void serial_transmit(const PicInsn *pi) {
   }
 
   if (!suppress && picio_send_noise >= 2)
-    ouhexo("picioh out", pi->d, pi->l);
+    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 6b049f340a8cdad40b39a56caff54ff97f4fb322..7dfc7566f5915bf4fc146d7e56fbf2569ac81f65 100644 (file)
@@ -142,8 +142,8 @@ void persist_map_veryearly(void);
 
 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);
+void ouhex(const char *word, const Byte *command, int length);
+void ouhex_nosim(const char *word, const Byte *command, int length);
 
 void serial_transmit(const PicInsn *pi);
 void command_doline(ParseState *ps, CommandInput *cmdi_arg);
index 187e87e312c12dd59977a282f10f02aef23d5071..569242704a655f1d5b04f66258c66947930cc318 100644 (file)
@@ -101,10 +101,15 @@ void simlog_serial(const Byte *data, int length) {
   simlog_flush();
 }
 void simlog_open(const char *fn) {
+  int r;
+  
   if (!fn) fn= "+realtime.log";
   if (!strcmp(fn,"-")) {
     simoutput= stdout; /* we don't really use this - see vsimlog */
   } else if (fn[0]) {
+    r= unlink(fn);
+    if (r && errno!=ENOENT && errno!=EPERM)
+      diee("unlink old simulation log %s",fn);
     simoutput= fopen(fn,"w");
     if (!simoutput) diee("open simulation log %s",fn);
   }
index 0cdc9455f137920ccd50d5ca61b3e53ce3edd04c..e8a4cb70936514c38762696b7f59b4ab163596ed 100644 (file)
@@ -16,7 +16,7 @@ static void sta_goto(StartupState new_state);
 /*---------- ping ----------*/
 
 static int pong_seq;
-static TimeoutEvent ping_toev= { .pclass=toev_fast_pclass, .pinst="ping" };
+static TimeoutEvent ping_toev= { .pinst="ping" };
 
 static void timedout_ping(TimeoutEvent *toev) {
   assert(sta_state >= Sta_Ping);
@@ -27,6 +27,7 @@ static void timefor_ping(TimeoutEvent *toev) {
   enco_pic_ping(&piob, pong_seq ^ PING_PONG_PATTERN);
   serial_transmit(&piob);
   ping_toev.callback= timedout_ping;
+  ping_toev.pclass= "startup";
   toev_start(&ping_toev);
 }
 
@@ -178,23 +179,23 @@ void serial_moredata(PicInsn *buf) {
   assert(buf->l > 0);
   
   if (sta_state == Sta_Flush) {
-    ouhexi("picioh in junk", buf->d, buf->l);
+    ouhex("picioh in junk", buf->d, buf->l);
     toev_start(&sta_toev);
     return; /* junk absolutely everything */
   }
   if (PICMSG_AAARGH_P(buf->d[0])) {
-    ouhexi("picioh in aaargh", buf->d, buf->l);
+    ouhex("picioh in aaargh", buf->d, buf->l);
     die("PIC sent us AAARGH!");
   }
   if (PICMSG_HELLO_P(buf->d[0])) {
-    ouhexi("picioh in hello", buf->d, 1);
+    ouhex("picioh in hello", buf->d, 1);
     if (sta_state != Sta_Manual)
       sta_goto(Sta_Flush);
     buf->l= 1;
     return;
   }
   if (sta_state == Sta_Off) {
-    ouhexi("picioh in off", buf->d, 1);
+    ouhex("picioh in off", buf->d, 1);
     buf->l= 1;
     return;
   }
@@ -207,7 +208,7 @@ void serial_moredata(PicInsn *buf) {
       goto found_end;
 
   if (buf->l == sizeof(buf->d)) {
-    ouhexi("picioh in toolong", buf->d, buf->l);
+    ouhex("picioh in toolong", buf->d, buf->l);
     die("PIC sent packet too long");
   }
   buf->l= 0; /* message not yet finished, so consume nothing */
@@ -220,7 +221,7 @@ void serial_moredata(PicInsn *buf) {
   suppress= pii && pii->noiselevel > picio_send_noise;
 
   if (!suppress && picio_send_noise >= 2)
-    ouhexi("picioh in msg", buf->d, buf->l);
+    ouhex_nosim("picioh in msg", buf->d, buf->l);
 
   if (simlog_full || sta_state < Sta_Settling ||
       !((pii->opcode==PICMSG_NMRADONE && obj==1) ||
@@ -254,6 +255,7 @@ void on_pic_pong(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
 
   ping_toev.duration= 1000;
   ping_toev.callback= timefor_ping;
+  ping_toev.pclass= toev_fast_pclass;
   toev_start(&ping_toev);
 
   if (sta_state == Sta_Ping)