RS232 Programming Query

I am writing two C programs read.c and write.c on QNX 4.25. My machine has two serial ports ser1 and ser2. I have connected both the ports via cable (the pin configuration is taken care of). I am executing the porgrams parallely read.c in one terminal and write.c in other.

The problem is when i write to ser1 i am able to do it but when i try to read from ser2 i am unable to do so. The LSR “data ready bit” is not being set and when i try to print the LSR value it shows…“Error in Receiver FIFO” that is the 7th bit is high.

The hardware is perfect and no problems. I have tried communicating with both the ports using “cat” command that is “cat < /dev/ser1” and
“cat > /dev/ser2” and vice-versa it works fine no problems.

Both the ports have the same configuration.

I am pasting the code of the programs i have written:

read.c

#define SIO_PORT_BASE 0x2f8
#define SIO_DATA_PORT SIO_PORT_BASE+0
#define SIO_STAT_PORT SIO_PORT_BASE+5

#define SIO_RXRDY_BIT 0x1
#define SIO_TXEMPTY_BIT 0x20

main()
{
unsigned char ch;
while(1)
{
while(!(inp(SIO_STAT_PORT) & SIO_RXRDY_BIT))
{
}
ch = inp(SIO_DATA_PORT);
printf("\n%c", ch);
}
}


write.c

#define SIO_PORT_BASE 0x3f8
#define SIO_DATA_PORT SIO_PORT_BASE+0
#define SIO_STAT_PORT SIO_PORT_BASE+5

#define SIO_RXRDY_BIT 0x1
#define SIO_TXEMPTY_BIT 0x20

main()
{
char ch;
while(1)
{
while(!(inp(SIO_STAT_PORT) & SIO_TXEMPTY_BIT))
{
}
ch = getch();
outp(SIO_DATA_PORT,ch);
putchar(ch);
}
}

Can anyone please help me out with this…

Thanking you in advance
Karthik