From 1f0cb92492b67caca727761b453477fbfc3dcb82 Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 4 Jun 2005 11:12:52 +0000 Subject: [PATCH] wip print meaning in serial_transmit --- hostside/client.c | 2 +- hostside/output.c | 9 ++++++++- hostside/parse-proto-spec | 14 ++++++++++++-- hostside/skelproto-pic.c | 20 ++++++++++++++++++-- hostside/skelproto-pic.h | 4 +++- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/hostside/client.c b/hostside/client.c index d7bdbfb..22784ed 100644 --- a/hostside/client.c +++ b/hostside/client.c @@ -205,5 +205,5 @@ static void stdin_error(OutBufferChain *ch, const char *e1, const char *e2) { } void stdin_client(void) { - new_client(0, stdin_error, (char*)"stdin", "p"); + new_client(0, stdin_error, (char*)"stdin", "pP"); } diff --git a/hostside/output.c b/hostside/output.c index 3081c0c..e6d8bd3 100644 --- a/hostside/output.c +++ b/hostside/output.c @@ -6,6 +6,7 @@ #include #include "hostside.h" +#include "auproto-pic.h" #define FOR_OOS(s) do{ \ Client *cl, *next_cl; \ @@ -41,6 +42,12 @@ void output_hex(Selector sel, const char *word, } void serial_transmit(const PicInsn *pi) { - output_hex('p', "pic-out", pi->d, pi->l); + const PicInsnInfo *pii; + pii= lookup_byopcode(pi->d[0], pic_command_infos); + if (!pii) { + ooprintf('p', "pic-out unknown\n"); + } else { + } + output_hex('P', "pic-out-h", pi->d, pi->l); serial_transmit_now(pi->d, pi->l); } diff --git a/hostside/parse-proto-spec b/hostside/parse-proto-spec index 0ed7381..5865e42 100755 --- a/hostside/parse-proto-spec +++ b/hostside/parse-proto-spec @@ -35,6 +35,11 @@ sub expand_and_write () { pln($templl); } +sub b2xh ($$) { + my ($bin,$orin) = @_; + return sprintf "0x%02x", (oct("0b$bin") | $orin); +} + sub process_line () { chomp; $origprotoline= $_; @@ -58,6 +63,7 @@ sub process_line () { $msg =~ s/ //g; if ($msg =~ m/^0[01]{7}$/) { $opcode= $&; + $opcodemask= '11111111'; $arglen= 0; $ybit= 0; } else { @@ -73,6 +79,8 @@ sub process_line () { $msg =~ m/^(0[01][01_]{6})$/; $opcode= $1; die if $opcode =~ m/_[01]/; + $opcodemask= $opcode; + $opcodemask =~ y/01_/110/; $opcode =~ s/_/0/g; $arglen= $msg; $arglen =~ s/[01]//g; @@ -85,8 +93,10 @@ sub process_line () { $v{dname}= $dname; $v{cname}= $cname; $v{cnameyn}= $cname.$yval; - $v{opcode}= sprintf "0x%02x", oct("0b$opcode"); - $v{opcodeyn}= sprintf "0x%02x", (oct("0b$opcode") | $ybit * $yval); + $v{opcode}= b2xh($opcode, 0); + $v{opcodeyn}= b2xh($opcode, $ybit * $yval); + $v{opcodemask}= b2xh($opcodemask, 0); + $v{opcodemaskyn}= b2xh($opcodemask, $ybit); $v{arglen}= $arglen; $v{arglentf}= sprintf "%d", !!$arglen; expand_and_write(); diff --git a/hostside/skelproto-pic.c b/hostside/skelproto-pic.c index 651dd85..5e2339c 100644 --- a/hostside/skelproto-pic.c +++ b/hostside/skelproto-pic.c @@ -24,12 +24,28 @@ extern void enco_pic_anyinsn(PicInsn *out, const PicInsnInfo *pii, out->d[0] |= pii->opcode; } +#if 0 +const char *pi_getarg(const PicInsn *pi, const PicInsnInfo *pi, long *a_r) { + +const PicInsn *pi, long *arg_o, +#endif + +const PicInsnInfo *lookup_byopcode(Byte byte0, const PicInsnInfo *table) { + const PicInsnInfo *pi; + for (pi= table; + pi->name; + pi++) + if ((byte0 & pi->mask) == pi->opcode) + return pi; + return 0; +} + const PicInsnInfo pic_command_infos[]= { - { "@cnameyn@", @opcodeyn@, @arglen@ }, @h2p@ + { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@ }, @h2p@ { 0 } }; const PicInsnInfo pic_reply_infos[]= { - { "@cnameyn@", @opcodeyn@, @arglen@ }, @p2h@ + { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@ }, @p2h@ { 0 } }; diff --git a/hostside/skelproto-pic.h b/hostside/skelproto-pic.h index 5d1762b..e42b48c 100644 --- a/hostside/skelproto-pic.h +++ b/hostside/skelproto-pic.h @@ -24,9 +24,11 @@ extern void on_pic_debug(int ch); extern void enco_pic_anyinsn(PicInsn *out, const PicInsnInfo *pii, int objnum); +const PicInsnInfo *lookup_byopcode(Byte byte0, const PicInsnInfo *table); + struct PicInsnInfo { const char *name; - Byte opcode; + Byte opcode, mask; int argbits; }; -- 2.30.2