A generic way to make use of rpmsg from user space

Hi,
I tried like you said. I used simple open, read, write instructions on file /dev/RPMsg to send data to M4. The code works for single write command. But when i am trying to write in a loop, i receive junk data at m4. Also the read() command is not at all working.
Also if there is only a single write command and if i put a delay after it, same thing occurs (receives junk data at M4). I am only using simple open, read, write commands. Am i missing something here? Can you please provide a sample program with simple read-write? Please help