GPRS unable to compare "OK" commands.

Status
Not open for further replies.

Rohi231

Member level 2
Joined
Mar 21, 2012
Messages
53
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,673
Hello . I am interfacing GPRS with add semiconductor. I am unable to compare the "OK" commands. When i put
len=strnlen(rec);

what will be the length of len of "OK" commands.
 

Thank you moderator. I need the solution for this string. When
while(strcmp (strx,str1) != 0) ;



if condition gets true what will happen now. I am unable to trigger it out. plz help me.
 

Thank you moderator. I need the solution for this string. When
while(strcmp (strx,str1) != 0) ;



if condition gets true what will happen now. I am unable to trigger it out. plz help me.



If what you are trying to do is to wait for the module to send you the "OK<cr><lf>" response a possible implementation could be:

//issue command to gsm module
-- blah
-- blah

//wait for OK response
str1 = "OK<cr><lf>";
strx = "";
fail = 0;
while((strcmp (strx,str1) != 0) || fail = 0);
{
strx = gets(Usart_Rx_Buffer);
if(strx = Some_other_predefined_error_message_from_module)
fail = 1;
}

//proceed to give gsm module its next task


Refresh your mind when working with strings. Also have a look at The break; statement
https://www.cplusplus.com/doc/tutorial /control/
 

An important point when writing AT command interfaces is not to rely on assumptions about a specific response format. The first step will be to strip off delimiters and leading spaces.

I don't know what gets() is supposed to do, but I would expect that <CR><LF> is removed from the response string. In this case, the compare would fail.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…