From b9e32ffff0e6d1c1347c8668a78181776024026e Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 24 May 2008 19:25:02 +0000 Subject: [PATCH] make simulation log short even with -v4 --- hostside/common.h | 3 +-- hostside/realtime.c | 30 ++++++++++++++++++------------ hostside/realtime.h | 11 ++++++----- hostside/startup.c | 16 ++++++++-------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/hostside/common.h b/hostside/common.h index 6e4e19e..debc084 100644 --- a/hostside/common.h +++ b/hostside/common.h @@ -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*/ diff --git a/hostside/realtime.c b/hostside/realtime.c index 40e1b29..4a4f35c 100644 --- a/hostside/realtime.c +++ b/hostside/realtime.c @@ -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) diff --git a/hostside/realtime.h b/hostside/realtime.h index 6686336..d4d3faf 100644 --- a/hostside/realtime.h +++ b/hostside/realtime.h @@ -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 ----------*/ diff --git a/hostside/startup.c b/hostside/startup.c index 72d595b..dd6fd0c 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -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; } -- 2.30.2