From: ian Date: Wed, 5 Jan 2005 18:19:00 +0000 (+0000) Subject: some debugging prints, which we will remove shortly X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=8d6c41f263430ba8cacc6e4a6221d54a9b05aa9b;p=trains.git some debugging prints, which we will remove shortly --- diff --git a/hostside/nmra.c b/hostside/nmra.c index e6697da..dc9faa4 100644 --- a/hostside/nmra.c +++ b/hostside/nmra.c @@ -1,6 +1,7 @@ /**/ #include +#include #include "hostside.h" @@ -16,9 +17,11 @@ void xmit_nmra_raw(const Byte *nmra_packet, int length) { working_qty= 15; /* are some data bits to encode, rest are clear. */ /* we start with the 14-bit preamble and the packet start bit */ for (;;) { +fprintf(stderr,"l=%d w=%08x q=%-2d",length,working,working_qty); assert(working_qty >= 0); if (working_qty < 7) { if (length > 0) { +fprintf(stderr," nmra=%02x",*nmra_packet); /* plonk new data bits just to right of old data bits */ length--; newbits= *nmra_packet++; @@ -26,17 +29,22 @@ void xmit_nmra_raw(const Byte *nmra_packet, int length) { newbits |= !length; /* 9 bits, bottom one is `end of packet' */ working |= (newbits << (7-working_qty)); working_qty += 9; +fprintf(stderr," nmra\n"); +continue; } else if (!working_qty) { /* all done */ +fprintf(stderr," alldone\n"); break; } else { /* pad with exactly enough 1 bits to make up the encoded byte */ working |= 0xffU << (8-working_qty); working_qty= 7; +fprintf(stderr," pad\n"); } } assert(encp < encoded + COMMAND_ENCODED_MAX); *encp++= (working >> 9) & 0x7f; /* top 7 bits, right-justified */ +fprintf(stderr," enc=%02x\n", encp[-1]); working <<= 7; working_qty -= 7; }