Especial error with serial port

bridged with qnx.rtos
Post Reply
jakubfrackowiak

Especial error with serial port

Post by jakubfrackowiak » Sun Apr 15, 2007 8:30 am

Hi! It's my first topic and I write cause I can't found any answer for
my problem. I use that code

#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

void main()
{
struct termios termios_p;
speed_t speed;

int fd=open( "/dev/ser2", O_RDWR ); //external rs232
in my PC
speed = B9600;
cfsetispeed( &termios_p, speed );
cfsetospeed( &termios_p, speed );
tcsetattr( fd, TCSADRAIN, &termios_p);

// read or write here

close(fd);
}


First time I use this program it works good. But next time this
program stops on open() function. If I restart system this program
run properly but also only one time. I don't know why. What should I
change in thic code?
I work as root and the permission of /dev/ser2 is rw-rw-rw-.
thx for any answers.

jiv

RE: Especial error with serial port

Post by jiv » Sun Apr 15, 2007 8:30 am

?try NONBLOCK flag in open?
good luck!

jakubfrackowiak

RE: Especial error with serial port

Post by jakubfrackowiak » Sun Apr 15, 2007 8:30 am

Thank U. I've solved my problem. I should changed one parameter in:
tcsetattr( fd, TCSADRAIN, &termios_p); TCSADRAIN->TCSADNOW. I
didn't know it's importatnt.

Post Reply

Return to “qnx.rtos”