Closed d-serj closed 5 years ago
Hello. Call init in your task. Reseive can a global variable. Like Char myussdanswer[128]; Or null. If it's null. You can read answer in sim80x structure ( in sim80x.gsm.msg)
Thanks for your fast replying. Here is minimal model of your problem:
char a[10], *ptr = a;
void foo(char *p)
{
p = NULL;
}
...
foo(ptr); // after calling this function ptr won't be changed
If we need to change ptr
we have to pass pointer to pointer
void foo(char **p)
{
*p = NULL;
}
...
foo(&ptr ); // in that case the value of ptr will be changed
Your code if(receive != NULL) receive = Sim80x.Gsm.Msg;
has absolutely no effect and function bool Gsm_Ussd(char *send, char *receive)
doesn't work! The value of variable that receive
pointed to, will never be changed.
My solution is to use memcpy(receive, Sim80x.Gsm.Msg, receiveSize);
instead of
receive = Sim80x.Gsm.Msg
or pass pointer to pointer as function argument.
I dont have a board for test now. . I try it soon. Thank you for report bugs
Hello! Could you descrive (write comments) of the API functions in your code?
In my case, I dont understand the meaning of the parameter
receive
in functionbool Gsm_Ussd(char *send, char *receive)
. I think, there is no effect of code in this functionif(receive != NULL) receive = Sim80x.Gsm.Msg;
becausereceive
is local variable. Or I need to pass pointer to pointer as the parameter?P.S. Sorry for my English.