Problem with serial communication

I have an app built with MIT App Inventor that is sending serial bluetooth data to my arduino via a HC-05 module.

Below is the data stream as it comes in and I display it in the Serial monitor:

I am using # chracter to deliniate 'words' as per my const char* readBTWord(HardwareSerial& serialHC05) function (also below).

So from the data stream below the process seems to get 'stuck' in the middle of one of the words and my readBTWord functions never sees the '#' character that terminates the word and my loop.

The app running on my mobile phone is sending the data as one string.

I am not even sure about the nature of the problem.

Can anyone offer me some insight into what is going wrong with the serial communications?

Initializing SD card...Initializing SD card...initialization done!
3
3/
3/8
3/8:
3/8:1
3/8:17
3/8:17:
3/8:17:0
3/8:17:06
3/8:17:06-
3/8:17:06-1
3/8:17:06-10
3/8:17:06-10
===============
p
pr
pro
prog
progr
progra
program
program
===============
s
st
sta
stat
stati
statio
station
station1
station1
===============
station1
s
su
sus
susp
suspe
suspen
suspend
suspend:
suspend:
===============
	suspend:
s
st
sta
stat
stati
statio
station
station2
station2
===============
station2
s
su
sus
susp
suspe
suspen
suspend
suspend:
suspend:
===============
	suspend:
s
st
sta
stat
stati
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
statio
String strWord;

const char* readBTWord(HardwareSerial& serialHC05)
{
  char cCh = 0;

  strWord = "";

  while (cCh != '#')
  {
     if (serialHC05.available() > 0)
     {
       cCh = serialHC05.read();
       if (cCh != '#')
         strWord += String(cCh);
     }
debug(strWord);
  }
debug("===============");
  return strWord.c_str();
}

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example.

It is not a good idea to use the String (capital S) class as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

…R