Serial port not working from Linux -> QNX

In porting an application from Linux RedHat 7.2 to QNX Neutrino the serial port is no longer working. It is behaving as though the speed is not set correctly (as in, I still can send / receive data, but it just isn’t correct).

Here is my setup code:

char portName [] = “/dev/ser1”;

sd = open(portName, O_RDWR | O_NOCTTY);
if (sd < 0) {
perror(portName);
exit(-1);
}

tcgetattr(sd, &oldtio); // save current serial port settings
bzero(&newtio, sizeof(newtio)); // clear struct for new port settings
newtio.c_cflag = B57600 | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
// set input mode (non-canonical, no echo,…)
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 50;
newtio.c_cc[VMIN] = 0;
tcflush(sd, TCIFLUSH);
tcsetattr(sd, TCSANOW, &newtio);

And I am using this to read the port:

res = read(sd, inBuf, 3);
printf(“ser:%X %X %X : %d\n”, inBuf[0], inBuf[1],
inBuf[2], res);

It is all very straightforward, and I have no idea why this quit working.

Thanks for any help,

Mit

Have you checked this thread?
openqnx.com/PNphpBB2-viewtopic-t1003-.html

BTW, do a search on “devc-ser8250” on this site and see other discussions.

To answer my own question, I needed:

newtio.c_ispeed = B57600;
newtio.c_ospeed = B57600;

to set the speed correctly. I suppose Linux didn’t need / doesn’t have
those options.

Thanks…

Mit

Linux should have those members (it isn’t Posix if it doesn’t). Posix also says that one should not set these members directly, but should use the api calls cfsetispeed/cfsetospeed.

Yes, I realize Linux also has those members, but I didn’t need to set them
for my serial code to work?? Also, after I replied I did a little more reasearch into how to do this RIGHT, and found out about the setspeed commands. Hopefully I’m getting close to getting this working!

Thanks again,

Mit