Reading from serial port

Hello all,
I am opening a serial terminal from ide(6.2.1) and reading from it.I have a program which will read whatever characters typed in serial terminal will be displayed.The problem is when i type the characters two times where 1 character is displayed in serial terminal and another in my program.why is it
so?

I don’t understand what you mean by “serial terminal”. Does that mean you have 2 serial ports connected together?

he probably has 2 programs reading 1 serial line, resulting in described behaviour above…

That is what I was afraid ;-)

No i have a pin if i connect to ser1 it can act as self loopback i.e.i can read and write to same port(ser1).So i am writing characters from ide serial terminal which is connected to ser1 and in my program reading from ser1.
In the ide serial terminal i should type twice the same character where one gets displayed in ide terminal and another one where i am running the program.why is it so?

LOL, mezed sais “he probably has 2 program reading 1 serial line”, then you reply “No” but add "serial terminal which is connected to ser1 and in my program reading from ser1. That does sound like tw programs reading the same serial port to me ;-)

The ide opens the serial port (/dev/ser1) , it opens it in read and write mode. Your program open the same serial port (/dev/ser1). Now you press a key in the terminal, that key is send over /dev/ser1, then the data is received by the serial driver. Fine so far, but then the serial driver says oh gee, there are two programs that have the /dev/ser1 port open, who am I going to send that characters to. It could be argued that it should send the data to both your program and the terminal, but it doesn’t. It alternated between the two programs, which is why one byte will go to the terminal and the other to your program (it doesn’t really alternate but I’ll use that word to keep things simple)

Thank you,I got it.