a***@gmail.com
2016-01-28 17:49:46 UTC
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.
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.