serial port communication

Does any have any suggestions?

I am updating some legacy code. Basically I have two seperate process that
are talking to the same serial port and requesting information from a device
connected to it. It seems that when both processes are talking the return
message to one of the processes gets a little messed up. How do I set the
serial port as fifo for its return messages. I have tried to do this using
stty… and I am aware of the canonical buffer, but I put a serial port
reader on the line and watched as the streams of messages that went back and
forth, and I still see that the return message occasionally gets interrupted
before it is read and understood.

Thanks
Dave Gleason

Dave Gleason <dgleason@optomec.com> wrote:

I am updating some legacy code. Basically I have two seperate process that
are talking to the same serial port and requesting information from a device
connected to it.

You can’t to that. The general rule is that you should only have one process
talking to a serial port at any given time. They are not designed for any
sort of multiplexed access at all.

The proper way to do this is to have one process that talks to the serial
port and then have your processes talk to that via QNX messages. That way
the “driver” process can prevent things from getting garbled.

What you were seeing is this:
Task A sends to the serial port, gets the start of a reply
Task A uses up it’s timeslice and Task B is given the CPU
Task B sents to the serial port, and gets the last part of TaskA’s reply
as well as the start of Task B’s reply
Task B uses up it’s timeslice and Task A is given the CPU
… repeat

Cheers,
Camz.