Getting junk value through GSM call

Hi ,
I am sending data stored in A&D memory through GSM call using adl_fcmSendData() to receiving modem on basis of some particular command sent by the receiving modem.Its working fine. But some times the data while sending suddenly stops(say stops at 800 bytes for the file of 1k). Then after waiting for some time the receiving modem gives one more command at that time instead of sending the proper response my modem is sending the remaining part of the data but with limited size. Please tell me wats the problem here do i have to clear the buffer before sending?

In short
if(recevived command == “1”)

here its sending only “ABCDE”

next time for the following command
if(received command == “2”)

i will get “FGI” which is the remaining part of the previously sent data instead of “XYZ”. what is the cause for this I think the modem’s buffer is not being cleared.

Do you check the return value from adl_fcmSendData - that will tell you if you are running out of buffer space!

Do you also wait for the “memory release” event to know when memory has been released by a previous transmission?