Serial Communications Problem

Hi,

I’m new to QNX and I’ve been trying to use these following functions:

modem_open()
modem_write()
modem_read(),

to open, write, and read to serial ports.

I’ve been testing out how to use these functions but there’s just one problem (probably very simple).

I have physically linked together the receive and transmit lines of the serial port I’ve been working with. I have opened the serial port, written a simple string to it, and tried to read the data just written, all on the same port. All the functions executed without errors. However, I just can’t seem to read correctly the data that I wrote to the port. I don’t get any errors when running the program so I don’t know if the data is being written incorrectly to the port or read incorrectly from the port.

The data I read is just rubbish. I’m baffled as to what is wrong. Am I not allowed to write to a port and then read from it again straight afterwards?

Any help would be greatly appreciated.

Thanks

John Lai

PS: I don’t know if this matters, but I’ve configured the port to be in “raw mode”.

If you are recieving characters to the screen then you can obviously send and receive from the same port.

If your recieving garbled characters your problem is most likley due to an incorrect baud rate.

Try setting it to 9600 when you use the modem_open command.

nathan

Very unlikely since he’s using the same serial port ( loopback ).

Can you post your code?

Maybe the baud rate for out is != the baud rate for input

most hardware don’t support that. Plus modem_open only accept only baud_rate (there is no way to set a different baud rate for tx and rx).

My guess is a bug in the program or maybe a problem with the hardware connection.