wfd cof_serXgetS not returning.

Hi All, I have a costate that sends a string and waits for a reply using the following:
main()
{
//do stuff
costate
{
serCputs(sbuf_out);

wfd getOk = cof_serCgets(sbuf_in,2,timeout);

if ((getOk > 0) && (sbuf_in[0] != NULL))
    {
	//do stuff to buffer
}else abort;

}//end costate

 //do more stuff

}
Problem is that if I don’t get any chars back it never comes out of the wfd.

Dum = GPSserrdUsed();

#ifdef GPSVERBOSE
printf("
RxGPS function");
printf("
GPS Dum = %d

",Dum);
#endif

while ((Dum == 0)&&(TT > MS_TIMER))
{
yield;
Dum = GPSserrdUsed();
}

TT = MS_TIMER + 200;
while ((Tel < 200)&&(TT > MS_TIMER))
{
Dum = GPSsergetc();
if (Dum == -1)
yield;

I have experienced the same problem, and as such have written the following function. I hope you can understand it.
You could modify it to ignore Timer, and keep yielding as long as there is no
data. By all means let me know if you have any questions.
PS - I copied it out of one of my projects so some minor errors might have been introduced copying it here :smiley:

xmem cofunc char RxGPS(unsigned long Timer)
{
unsigned long TT;
signed char Tel, Dum;

TT = MS_TIMER + Timer;
Tel = 0;
Dum = serErdUsed();
while ((Dum == 0)&&(TT > MS_TIMER))
{
yield;
Dum = serErdUsed();
}

TT = MS_TIMER + 200;
while ((Tel < 200)&&(TT > MS_TIMER))
{
Dum = serEgetc();
if (Dum == -1)
yield;
else
Tel++;
//Process your character or load it in a circular buffer…
}
}

Thanks, Kobuseng, I didn’t use your routine but I got a clue from your use of serXrdUsed(). Using this I was able to not get to the wfd until I had at least 1 char in the buffer.

Thanks for the tip

Tony

Glad I could help.