cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

DaHu_285096
Contributor II

 Does the compiler mind doing a string search on a buffer in struct. like this...

   

COM.Buf[LastByte] = '\0';

   

if(strstr(COM.Buf,"OK")

   

{

   

  //got it

   

}

   

This appeared to working initially when I had debugger attached to target, when I programmed the target and ran on its own, the code program did not perform the same as when debugging.

   

I then connected to debugger again and re-ran.When I stepped through this code, I noted the COM.Buf contained CR LF OK CR LF but the loop failed to find the string.

   

I also tried below code and it appeared to work but when I programmed device, the code did not perform the same.

   

COM.Buf[LastByte] = '\0';

   

sprinft(tempsrtr,COM.Buf)

   

if(strstr(temstr,"OK")

   

{

   

  //got it

   

}

   

What I mean by "did not perform the same" is that the fisrt part of initiation for the GSM modem simply issues and AT command to check modem responds with "OK", before sending setup parameters to it.

   

I have a seried of LEDs that show progress, AT OK, SIM OK, Network OK etc.

   

When I program the target and run on its own, It never indicates AT is OK. I have been running on debugger for several days developing the code and it appeared to get the AT OK response every single time.

0 Likes
Reply
5 Replies
JoMe_264151
Expert II

Can you post your complete project? This issue will be outside of your provided code-snippet.

   

 

   

Bob

0 Likes
Reply
HeLi_263931
Honored Contributor II

Did it only work when stepping through the code? Or was the difference whether the debugger was attached or not? Did you run the same code (compiled in debug mode) both times?

0 Likes
Reply
DaHu_285096
Contributor II

 I cannot step through the code properly due to inteerupt timer going off.

   

What I did was set break point before sending command to modem and then another at the point where successful response should have occurred.

0 Likes
Reply
DaHu_285096
Contributor II

 The program works fine if I program the target and run it with miniprog connected.

0 Likes
Reply
Anonymous
Not applicable

 How about change your timer to a longer tiem to see if that helps

   

Also, try to set some delay between sussesive commands, give more time for message to return and decode.

   

We use a Vreg from the programmer to stop a external WD, do you use the Vreg for anything? also was there any external circuit that would affect XRES? 

   

If the reply is only "OK" and is the first 2 bytes, I think it would return 0, would this be a problem?

0 Likes
Reply