From 2910599082c2179c5336bfc0ea0c29d9f4d72348 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 8 Jun 2008 16:25:46 +0000 Subject: [PATCH] actually log non-Run/Resolving hex, and ping timeouts, to simulation log --- hostside/realtime.c | 6 +++--- hostside/realtime.h | 4 ++-- hostside/simulate.c | 5 +++++ hostside/startup.c | 16 +++++++++------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/hostside/realtime.c b/hostside/realtime.c index 4a4f35c..ee6c29e 100644 --- a/hostside/realtime.c +++ b/hostside/realtime.c @@ -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 diff --git a/hostside/realtime.h b/hostside/realtime.h index 6b049f3..7dfc756 100644 --- a/hostside/realtime.h +++ b/hostside/realtime.h @@ -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); diff --git a/hostside/simulate.c b/hostside/simulate.c index 187e87e..5692427 100644 --- a/hostside/simulate.c +++ b/hostside/simulate.c @@ -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); } diff --git a/hostside/startup.c b/hostside/startup.c index 0cdc945..e8a4cb7 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -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) -- 2.30.2