serial port using under QNX

Hi! I have to develop a control system, so I get a Hercules-EBX Board (Diamond Systems Corporation) and a little touch screen. The touch screen should be controlled via the serial port (RS-232). And here is my Problem… I try to write a very simple program to test the basic functions. First off all I try to read from the COM1, so I provide a null-modem-cable and connect the QNX-Board with my Windows-XP PC. Then I start BRAY-TERMINAL at the XP-PC and send a series of characters trough the cable (the PC really sends the characters, I have controlled the output with an oscilloscope). The program at the QNX-Board (a little inspired by an other topic) looks as followed:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <iostream.h>

using namespace std;

int main()
int fd;
int numRead=0;
char buffer[255];

fd = open("/dev/ser1", O_RDWR | O_NOCTTY | O_NDELAY );

    memset(buffer, 0, sizeof(buffer));

    numRead = read(fd, buffer, sizeof(buffer));
    printf("\n fd..%i numRead..%i buffer..%s",fd,numRead,buffer);

return 0;


OK… the result is that I get this output on my console:

fd…3 numRead…-1 buffer…
fd…3 numRead…-1 buffer…
fd…3 numRead…-1 buffer…
fd…3 numRead…-1 buffer…
fd…3 numRead…-1 buffer…
fd…3 numRead…-1 buffer…

So we know that the program can open the/dev/ser1 but reading is not possible.
Can somebody please tell me what to do?!?

regards Marco

Ok… I resolved the problem! I just need to get my thread the I/O-Privicy with the command: status = ThreadCtl(_NTO_TCTL_IO, 0);

Thank u anyway

Hmmm, you don’t need IO privity to read the serial port (the serial driver does, but a client app doesn’t).

The only credentials a client app needs to read the serial port, is r/w access on the device (i.e. /dev/ser1 needs to be -rw-rw-rw).

I have the same problem and ThreaCtl solve this problem. My ser1 have -crw-rw-rw

Something isn’t right.

My permission was set on rw- rw- rw- too. So I really need the ThreadCtr-command!

Something isn’t right. Try running qtalk as non root, does it work? If it does and it’s not running as root then that’s the proof you shouldn’t need to call ThreadCtr, as it can only be called from root .

how do u use the command: status = ThreadCtl(_NTO_TCTL_IO, 0);
i mean where in ur program.

Simply insert “ThreadCtl(_NTO_TCTL_IO, 0)” like a first string in you thread, that do open/read/write.