digidotcom / xbee_ansic_library

A collection of portable ANSI C code for communicating with Digi International's XBee wireless radio modules in API mode.
204 stars 116 forks source link

xbee_term issue #7

Closed ikoes closed 6 years ago

ikoes commented 8 years ago

Hello guys,

I've compiled the samples/posix folder. So I'm able to run the _xbeeterm application.

My uart node is /dev/ttyS0, and I'm sure that is correctly configured because when I loop the TXD pin with the RXD one I'am able to see what I have sent (using a custom a simple C program)

So I expected the same behaviour running the _xbeeterm app using /dev/ttyS0 as input to the Connect to which device ? request.

By the way I get a failed to open error. So after same debugging I've added the follwing code to the _parse_serialargs.c in the samples/posix/ folder:

....
        while (*serial->device == '\0')
        {
                printf( "Connect to which device? ");
                fgets( serial->device, sizeof serial->device, stdin);

               printf("fgets dbg: ");
               for(i=0;i<sizeof(serial->device);i++)
                        printf("%x ",serial->device[i]);
                printf("\n");
        }
......

Then I've recompiled and then re-run the xbee_term application $ ./xbee_term

And this is the input/output

Connect to which device? /dev/ttyS0
fgets dbg: 2f 64 65 76 2f 74 74 79 53 30 a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
Error -2 opening serial port

The error seems related to the fgets that retains the LF char (0xa).

Adding a bit of code that remove the LF the _xbeeterm app runs correctly.

        char * s;
        s=serial->device;
        while(*s && *s != '\n' && *s != '\r') s++;
        *s = 0;
tomlogic commented 8 years ago

I found a clean one-liner to strip the trailing newline, and have applied it to my fork of this repository. See commit 3b8f7adc89.

tomlogic commented 6 years ago

We can close this issue -- that commit is in 3b8f7adc89.