In prefix mode any message you sent is sent with the prefix header. Maybe this is the cause of this error?
Prefix mode is more fragile to interruptions (missing bytes for example).
Are you handling the terminated and error events?
I thought that the prefix mode was a robust protocol. I have tried the non prefix protocol and with same result.
Is there a way to detect if the receive event is disabled so you can reinitiate the serial.
I set a breakpoint at Astream_Newdata, restart the PIC, witch starts with sending message to android, but no reaction.
If there were missing bytes something should happen.
I have a button on android that send data and this is working fine.
I am running the PIC program with MPLABX so I can se exactly what is coming on the serial port.
When android sends ACK (char(06)) I receive only one char (06H) to PIC, no header.
The same if I send a longer message only what I put into "sendbuffer" in android.
The chat can go on for several hours and suddenly for no reason just stop.
What do you mean by "terminated event" ?