chiark / gitweb /
some debugging prints, which we will remove shortly
authorian <ian>
Wed, 5 Jan 2005 18:19:00 +0000 (18:19 +0000)
committerian <ian>
Wed, 5 Jan 2005 18:19:00 +0000 (18:19 +0000)
hostside/nmra.c

index e6697daee387a60108c0857556bfd277dbed6343..dc9faa4b023efd12da07af12bad1d20c178a95fb 100644 (file)
@@ -1,6 +1,7 @@
 /**/
 
 #include <assert.h>
+#include <stdio.h>
 
 #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;
   }