Read and Write to serial port

Hello.

I am trying to send and receive data over a rs485 serial port. I am able to send and receive data if I use two terminals but I am unable to get it working in one terminal. I have tried adding delays in between read and write but that doesn’t help at all.