Discussion:
Wireless communiaction using RS232 serial port
(too old to reply)
a***@gmail.com
2016-01-28 17:49:46 UTC
Permalink
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.
Nicolas
2016-01-29 07:57:39 UTC
Permalink
Post by a***@gmail.com
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 ?
Post by a***@gmail.com
----------------------------------------------------------------------------
#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 ?
Post by a***@gmail.com
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* ?
Post by a***@gmail.com
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.
Post by a***@gmail.com
Thanks in advance
Ankur.
Ankur Patel
2016-01-30 18:37:41 UTC
Permalink
--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?


Thanks in advance.
Nicolas
2016-02-01 08:05:00 UTC
Permalink
Post by Ankur Patel
--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.
Post by Ankur Patel
Thanks in advance.
Ankur Patel
2016-02-03 18:05:47 UTC
Permalink
ANY OTHER OPTIONS?
Ankur Patel
2016-02-04 01:08:17 UTC
Permalink
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?
Nicolas
2016-02-05 15:01:55 UTC
Permalink
Post by Ankur Patel
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.

Loading...