Problem with serial port not sending data (QNX 6 patch A)

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);

tcgetattr(serial_fd, &termios_p);

cfsetispeed(&termios_p, speed); // input baud rate
cfsetospeed(&termios_p, speed); // output baud rate

// 8 data bits, 1 stop bit, no parity, no flow control
termios_p.c_cflag |= CS8|CREAD|CLOCAL; // 8 data bits, turn on
receiver, no modem control
termios_p.c_lflag &= ~(ICANON | ECHO); // no echo or canonical
processing
termios_p.c_cflag &= ~(IHFLOW|OHFLOW); // no hardware flow control

status = tcsetattr(serial_fd, TCSANOW, &termios_p);
if (status)
perror(“InitializeCOM tcsetattr”);
tcflush(serial_fd, TCIOFLUSH);

status=write(serial_fd, “K”, 1); // send out first character -
sometimes it doesn’t work, but status returns 1 anyway

I check the return status on the open, and it is ok. I know it is not
sending anything because I watch it on a data scope. One wrinkle is
that when I slay the application I never call close(serial_fd) - is that
a problem? Thanks.

Don’t know where th eproblem might be, but we are using /dev/ser1
successfully. Suggestions:

  • I assume BAUDRATE is one of the #defined quantities B9600, etc.

  • You can set raw mode easily using the cfmakeraw() function

  • Maybe you need to set options.c_cc[VMIN] = 1 for 1 char at a time. And
    options.c_cc[VTIME] = 0 for no timeout.

Bruce Davis wrote:

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);
tcgetattr(serial_fd, &termios_p);

cfsetispeed(&termios_p, speed); // input baud rate
cfsetospeed(&termios_p, speed); // output baud rate

// 8 data bits, 1 stop bit, no parity, no flow control
termios_p.c_cflag |= CS8|CREAD|CLOCAL; // 8 data bits, turn on
receiver, no modem control
termios_p.c_lflag &= ~(ICANON | ECHO); // no echo or canonical
processing
termios_p.c_cflag &= ~(IHFLOW|OHFLOW); // no hardware flow control

status = tcsetattr(serial_fd, TCSANOW, &termios_p);
if (status)
perror(“InitializeCOM tcsetattr”);
tcflush(serial_fd, TCIOFLUSH);

status=write(serial_fd, “K”, 1); // send out first character -
sometimes it doesn’t work, but status returns 1 anyway

I check the return status on the open, and it is ok. I know it is not
sending anything because I watch it on a data scope. One wrinkle is
that when I slay the application I never call close(serial_fd) - is that
a problem? Thanks.

John H. Zouck
The Johns Hopkins University
Applied Physics Laboratory

cfmakeraw seems to have done the trick. I must have been missing a setting.
Thanks!!

John H. Zouck wrote in message <3AAE6DF7.F5DE337E@jhuapl.edu>…

Don’t know where th eproblem might be, but we are using /dev/ser1
successfully. Suggestions:

  • I assume BAUDRATE is one of the #defined quantities B9600, etc.

  • You can set raw mode easily using the cfmakeraw() function

  • Maybe you need to set options.c_cc[VMIN] = 1 for 1 char at a time. And
    options.c_cc[VTIME] = 0 for no timeout.

Bruce Davis wrote:

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);
tcgetattr(serial_fd, &termios_p);

cfsetispeed(&termios_p, speed); // input baud rate
cfsetospeed(&termios_p, speed); // output baud rate

// 8 data bits, 1 stop bit, no parity, no flow control
termios_p.c_cflag |= CS8|CREAD|CLOCAL; // 8 data bits, turn on
receiver, no modem control
termios_p.c_lflag &= ~(ICANON | ECHO); // no echo or canonical
processing
termios_p.c_cflag &= ~(IHFLOW|OHFLOW); // no hardware flow control

status = tcsetattr(serial_fd, TCSANOW, &termios_p);
if (status)
perror(“InitializeCOM tcsetattr”);
tcflush(serial_fd, TCIOFLUSH);

status=write(serial_fd, “K”, 1); // send out first character -
sometimes it doesn’t work, but status returns 1 anyway

I check the return status on the open, and it is ok. I know it is not
sending anything because I watch it on a data scope. One wrinkle is
that when I slay the application I never call close(serial_fd) - is that
a problem? Thanks.

John H. Zouck
The Johns Hopkins University
Applied Physics Laboratory

Actually I am still having a problem with this, I have to slay devc-ser8250
and restart it every time I restart my application to get reliable
operation. Any have a guess as to what I am doing wrong?

natesplace@mindspring.com wrote in message <98m4d9$t5o$1@inn.qnx.com>…

cfmakeraw seems to have done the trick. I must have been missing a
setting.
Thanks!!

John H. Zouck wrote in message <> 3AAE6DF7.F5DE337E@jhuapl.edu> >…
Don’t know where th eproblem might be, but we are using /dev/ser1
successfully. Suggestions:

  • I assume BAUDRATE is one of the #defined quantities B9600, etc.

  • You can set raw mode easily using the cfmakeraw() function

  • Maybe you need to set options.c_cc[VMIN] = 1 for 1 char at a time. And
    options.c_cc[VTIME] = 0 for no timeout.

Bruce Davis wrote:

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);
tcgetattr(serial_fd, &termios_p);

cfsetispeed(&termios_p, speed); // input baud rate
cfsetospeed(&termios_p, speed); // output baud rate

// 8 data bits, 1 stop bit, no parity, no flow control
termios_p.c_cflag |= CS8|CREAD|CLOCAL; // 8 data bits, turn on
receiver, no modem control
termios_p.c_lflag &= ~(ICANON | ECHO); // no echo or canonical
processing
termios_p.c_cflag &= ~(IHFLOW|OHFLOW); // no hardware flow control

status = tcsetattr(serial_fd, TCSANOW, &termios_p);
if (status)
perror(“InitializeCOM tcsetattr”);
tcflush(serial_fd, TCIOFLUSH);

status=write(serial_fd, “K”, 1); // send out first character -
sometimes it doesn’t work, but status returns 1 anyway

I check the return status on the open, and it is ok. I know it is not
sending anything because I watch it on a data scope. One wrinkle is
that when I slay the application I never call close(serial_fd) - is that
a problem? Thanks.

John H. Zouck
The Johns Hopkins University
Applied Physics Laboratory


\

I can’t see what might be wrong, but maybe you need to do a tcsetattr() with
the old attributes before you leave the process. I really don’t know if the
resource manager does this itself after a close or not. In other words, what
is the persistence of tcsetattr()? Can each process expect to see the port
attributes the same from time to time regardless of what other processes have
set the attributes to?

natesplace@mindspring.com wrote:

Actually I am still having a problem with this, I have to slay devc-ser8250
and restart it every time I restart my application to get reliable
operation. Any have a guess as to what I am doing wrong?

natesplace@mindspring.com > wrote in message <98m4d9$t5o$> 1@inn.qnx.com> >…
cfmakeraw seems to have done the trick. I must have been missing a
setting.
Thanks!!

John H. Zouck wrote in message <> 3AAE6DF7.F5DE337E@jhuapl.edu> >…
Don’t know where th eproblem might be, but we are using /dev/ser1
successfully. Suggestions:

  • I assume BAUDRATE is one of the #defined quantities B9600, etc.

  • You can set raw mode easily using the cfmakeraw() function

  • Maybe you need to set options.c_cc[VMIN] = 1 for 1 char at a time. And
    options.c_cc[VTIME] = 0 for no timeout.

Bruce Davis wrote:

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);
tcgetattr(serial_fd, &termios_p);

cfsetispeed(&termios_p, speed); // input baud rate
cfsetospeed(&termios_p, speed); // output baud rate

// 8 data bits, 1 stop bit, no parity, no flow control
termios_p.c_cflag |= CS8|CREAD|CLOCAL; // 8 data bits, turn on
receiver, no modem control
termios_p.c_lflag &= ~(ICANON | ECHO); // no echo or canonical
processing
termios_p.c_cflag &= ~(IHFLOW|OHFLOW); // no hardware flow control

status = tcsetattr(serial_fd, TCSANOW, &termios_p);
if (status)
perror(“InitializeCOM tcsetattr”);
tcflush(serial_fd, TCIOFLUSH);

status=write(serial_fd, “K”, 1); // send out first character -
sometimes it doesn’t work, but status returns 1 anyway

I check the return status on the open, and it is ok. I know it is not
sending anything because I watch it on a data scope. One wrinkle is
that when I slay the application I never call close(serial_fd) - is that
a problem? Thanks.

John H. Zouck
The Johns Hopkins University
Applied Physics Laboratory



\

John H. Zouck
The Johns Hopkins University
Applied Physics Laboratory

Bruce Davis wrote:

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);

do you need to do this?

serial_fd = open("/dev/ser1", O_RDWR|O_NONBLOCK);
~ ~


Bests…

Miguel

Actually I changed it to /dev/ser1 for the posting and forgot to put in the
quotes, in the actual code it is a string variable. Sharp eye though,
thanks.

Miguel Simon wrote:

Bruce Davis wrote:

Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:

int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];

speed = BAUDRATE; // 57600

serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);

do you need to do this?

serial_fd = open("/dev/ser1", O_RDWR|O_NONBLOCK);
~ ~

Bests…

Miguel