• Wireless communiaction using RS232 serial port

    From arp2859@gmail.com@21:1/5 to All on Thu Jan 28 09:49:46 2016
    Hello,

    I am trying to develop wireless communication between host(Windows) & Target (QNX). I am using serial port RS232 to send data to host. RS232 is connected to Xbee for wireless communication. USB Xbee dongle is inserted on Host. So, Target send data to
    RS232 serial port , it sends data to Xbee and Host receive data through USB Xbee . I also tried serial communication using RS232 cable. That also doesn't work.Now, I am trying to run following code on Target & send some data to host.

    ---------------------------------------------------------------------------- #include <stdio.h> /* Standard input/output definitions */
    #include <string.h> /* String function definitions */
    #include <unistd.h> /* UNIX standard function definitions */
    #include <fcntl.h> /* File control definitions */
    #include <errno.h> /* Error number definitions */
    #include <termios.h> /* POSIX terminal control definitions */ #include<sys/types.h>
    #include<sys/stat.h>
    #include<stdlib.h>

    //'open_port()' - Open serial port 1.

    int open_port(void)
    {
    int fd; /* File descriptor for the port */


    fd = open("/dev/ser1", O_RDWR | O_NOCTTY | O_NDELAY);
    if (fd == -1)
    {

    // Could not open the port.

    perror("open_port: Unable to open /dev/ttyf1 - ");
    }
    else

    {
    printf("Port Opened\n");
    fcntl(fd, F_SETFL, 0);

    }

    return (fd);
    }

    void close_port(int fd)
    {
    close(fd);
    printf("Port closed\n");
    }

    int main()
    {
    int n, x, y;
    char data[6];
    n = open_port();
    printf("File Descriptor for port is: %d\n", n);


    x = write(n, "Ankur\r", 6);
    if(x < 0)
    fputs("writing failed\n", stderr);
    else
    printf("Total written bytes of data: %d\n", x);
    y = 0;
    while(y < 6)
    {
    y = read(n, data, 6);
    printf("Bytes read: %d\n", y);
    }

    close_port(n);

    return 0;
    }

    ----------------------------------------------------------------------------

    I also use command "devc-ser8250", "ls /dev/ser*" on Target.
    On host side i am using "Serial Port monitor" software to check receive data. Unfortunately, i couldn't find anything on it.

    Can you elaborate the procedure to help me in my project.

    Thanks in advance
    Ankur.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas@21:1/5 to All on Mon Feb 1 09:05:00 2016
    Le 30/01/2016 19:37, Ankur Patel a écrit :
    --Serial interface works perfectly.
    --Problem was in RS232 cable. It was my mistake to use straight cable. I checked serial interface using null modem cable, i am good with it.
    --I need hint for Xbee side. QNX simulated data is almost 60-70 MB in 1-2 minutes. I want to receive data on host side as a Real time.
    --Target simulation data i need to receive on host side in Real time.
    --I am going to use ("https://www.sparkfun.com/products/13225") serial to Xbee module.
    -- Is it possible with this implement?
    A simple calculation :
    XBee max data rate = 250kbps => 25kB/s => 1.5MB per minute

    This is far from what you need.



    Thanks in advance.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas@21:1/5 to All on Fri Jan 29 08:57:39 2016
    Le 28/01/2016 18:49, arp2859@gmail.com a écrit :
    Hello,

    I am trying to develop wireless communication between host(Windows) & Target (QNX). I am using serial port RS232 to send data to host. RS232 is connected to Xbee for wireless communication. USB Xbee dongle is inserted on Host. So, Target send data to
    RS232 serial port , it sends data to Xbee and Host receive data through USB Xbee . I also tried serial communication using RS232 cable. That also doesn't work.Now, I am trying to run following code on Target & send some data to host.

    What kind of board uses QNX ?

    ---------------------------------------------------------------------------- #include <stdio.h> /* Standard input/output definitions */
    #include <string.h> /* String function definitions */
    #include <unistd.h> /* UNIX standard function definitions */
    #include <fcntl.h> /* File control definitions */
    #include <errno.h> /* Error number definitions */
    #include <termios.h> /* POSIX terminal control definitions */ #include<sys/types.h>
    #include<sys/stat.h>
    #include<stdlib.h>

    //'open_port()' - Open serial port 1.

    int open_port(void)
    {
    int fd; /* File descriptor for the port */


    fd = open("/dev/ser1", O_RDWR | O_NOCTTY | O_NDELAY);
    if (fd == -1)
    {

    // Could not open the port.

    perror("open_port: Unable to open /dev/ttyf1 - ");
    }
    else

    {
    printf("Port Opened\n");
    fcntl(fd, F_SETFL, 0);

    }

    return (fd);
    }

    void close_port(int fd)
    {
    close(fd);
    printf("Port closed\n");
    }

    int main()
    {
    int n, x, y;
    char data[6];
    n = open_port();
    printf("File Descriptor for port is: %d\n", n);


    x = write(n, "Ankur\r", 6);
    if(x < 0)
    fputs("writing failed\n", stderr);
    else
    printf("Total written bytes of data: %d\n", x);
    y = 0;
    while(y < 6)
    {
    y = read(n, data, 6);
    printf("Bytes read: %d\n", y);
    }

    close_port(n);

    return 0;
    }

    ----------------------------------------------------------------------------

    What error/behaviour do you have ?

    I also use command "devc-ser8250", "ls /dev/ser*" on Target.

    Please give the full command for devc-ser8250.

    What is the output for ls /dev/ser* ?

    On host side i am using "Serial Port monitor" software to check receive data. Unfortunately, i couldn't find anything on it.

    Can you elaborate the procedure to help me in my project.

    To eliminate problems, first use a direct link between host and device.
    Once this works, then add xbee link between both.


    Thanks in advance
    Ankur.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ankur Patel@21:1/5 to All on Wed Feb 3 10:05:47 2016
    ANY OTHER OPTIONS?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas@21:1/5 to All on Fri Feb 5 16:01:55 2016
    Le 04/02/2016 02:08, Ankur Patel a écrit :
    I tried Xbee serial explorer.
    The same code which I posted and works perfectly in serial interface.
    But when i execute that using Xbee serial explorer, it shows different output ,Bytes read :0 multiple times.
    Is there any configuration to do before run that code?

    This is not a QNX related question.
    Ask xbee experts.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)