Various problemes implementing API functionallity


i am trying to implement a RF communication with two xbee’s (rs232 to usb).

I managed to sent some data (<100 byte) in transparent mode - no problemes here. recieving was a bit different and weird because when polling /dev/ttyUSB1 with read() i got one or two complete messages (with a hugh time lap) followed by some fragments. Those fragments became shorter and shorter until i received the correct exit message (QUIT in my case).
Can someone explain that behaviour?

I went on to the API mode which looks better in sending/receiving issues. So i wrote a simple “buildMessage()” and “sendMessage()” function and sent it out the RF module (in fact the message was one single ‘a’ - accordingly to the spec). Then there happen strange things: First i did not receive anything. After stopping the sender and restarting the destination i received multiple 'a’s for some time but not constantly. Is there any kind of echo somehow?
I tried to “read()” the status frame from the sender (which should be sent after trying 3 times without success) but i am not able to read a single byte from it. The function call blocks for ever not returning anything (it was configured using FNDELAY).
Maybe someone has an explaination for that?

Thanks in advance, Ullrich