Subject: Re: [dtn-users] dtnrecv without hexdump?
From: "Graham Keellings (Leonix Solutions Pte Ltd)" <[email-masked]>
To: "Jonson, Thomas [USA]" <[email-masked]>
Cc: "[email-masked]" <[email-masked]>
Date: Fri, 31 Jul 2009 10:50:06 +0800
List-Id: dtn-users mailing list <dtn-users.maillists.intel-research.net>

Jonson, Thomas [USA] wrote:
> Hello Graham,
> I just tried this and while it worked, I was actually hoping not to have the hex displayed, but rather just the ascii message.  For example, on the regular dtnrecv output a | separates the hex on the left with the message on the right.  The code change you recommended will get rid of the message on the right side and just display the hex on the left.  I was hoping to get rid of the hex and just display the ascii, preferably without the newline every 16 bytes.
>   
D'oh!!! Sorry, Thomas, guess I didn't pay attention when reading (hence 
my "don't know why you would want to do this").

I agree with you that some command line parameter(s) could be added, but 
if you want to he hack the code then just change the thusly:

delete lines 230 to 236:
        while (k%BUFSIZE != BUFSIZE-1) {
            if (k%2 == 0) {
                printf(" ");
            }
            printf("  ");
            k++;
        }
and delete lines 210 to 220
        if (k%BUFSIZE == 0) // new line every 16 bytes
        {
            printf("%07x ", k);
        }
        else if (k%2 == 0)
        {
            printf(" "); // space every 2 bytes
        }
                    
        printf("%02x", buffer[k] & 0xff);

It worked for me.

with best wishes,

~graham();

> I'm not much of a c programmer, but replacing the entire print_data function in the dtnrecv.c code with the below seemed to work for the most part, but the there are some extra characters being printed at the end of the line depending on the size of the message:
>
> print_data(char* buffer, u_int length)
> {
> printf(buffer);
> printf("\n");
> }
>
> Thanks,
> Tom
>
> From: Graham Keellings (Leonix Solutions Pte Ltd) [mailto:[email-masked]]
> Sent: Wednesday, July 29, 2009 10:34 PM
> To: Jonson, Thomas [USA]
> Cc: [email-masked]
> Subject: Re: [dtn-users] dtnrecv without hexdump?
>
> Jonson, Thomas [USA] wrote:
>
> I'm fairly new to the DTN2 protocol so perhaps I've just missed this in the documentation, but is there a way to run dtnrecv and have it display just the message, without the hexdump?
>
>
> Hi, Thomas,
>
>   I don't see any command line switch for this - and I can't for the life of me think why you would want it, but ...
>
> By my reckoning, if you edit <dtn directory>/apps/dtnrecv.c  (make a backup first)
>
> and change  (line 221 in my copy, ymmv)
>
>         if (k%BUFSIZE == BUFSIZE-1)
>         {
>             printf(" |  %.*s\n", BUFSIZE, s_buffer);
>         }
>
> to
>         if (k%BUFSIZE == BUFSIZE-1)
>         {
>             printf(" \n");
>         }
>
> and also
>
>  (at line 237 in my copy, ymmv)
>
>         printf("   |  %.*s\n",
>                (int)length%BUFSIZE,
>                s_buffer);
>
> to
>         printf("\n");
>
> Then rebuild, it should so what you want. I tried it and it works.
>
> Happy DTNing ;-)
>
>
> ~graham();
>
>
>
>
>
>
>
>
>
> Thanks,
>
> Tom
>
>
>
>
>
>
>
>
>
>
> ________________________________
>
>
>
>
>
>
> _______________________________________________
>
> dtn-users mailing list
>
> [email-masked]<mailto:[email-masked]>
>
> http://maillists.intel-research.net/mailman/listinfo/dtn-users
>
>
>
>
>
>
> --
>
> Technical Director
>
> Leonix Solutions (Pte) Ltd
>
> 18 Boon Lay Way
>
> #09-95 TradeHub 21
>
> Singapore 609966
>
> Telephone:+65 6316 9968
>
> Fax: +65 6316 9208
>
>   

-- 
Technical Director
Leonix Solutions (Pte) Ltd
18 Boon Lay Way
#09-95 TradeHub 21
Singapore 609966
Telephone:+65 6316 9968
Fax: +65 6316 9208