Function call errors

Hello all!

I am trying to learn C or C++, and I still have a problems as well as need a lot of help.

I am trying to adapt the GSM_Shield program to control a GSM module only to send and receive SMS, at the moment I am testing only the send command. I have to write another function to receive the response.

I have the following function call the I am testing:

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(power_pin, HIGH); // Switch ON the GSM module

delay(2000):
  
char SendATCmdWaitResp("AT+CREG?", 1000, "\r\n+CREG:1,1\r\n\r\nOK\r\n");

}


char SendATCmdWaitResp(char const *AT_cmd_string, uint16_t time_out,
                char const *response_string)
               
{
  byte status;
  char ret_val = 0; 
  byte i;

    Serial.println(AT_cmd_string);

    /*   
      if(IsStringReceived(response_string)) {
        ret_val = AT_RESP_OK;      
        break;  // response is OK => finish
      }
      else ret_val = AT_RESP_ERR_DIF_RESP;
    }
    else {
      // nothing was received
      // --------------------
      ret_val = AT_RESP_ERR_NO_RESP;
    }
    
  }

*/

  return (ret_val);

I have the following errors:

GSM_Control_Final.ino: In function void loop();
GSM_Control_Final:48: error: expression list treated as a compound expression in initializer[-fpermissivel]
GSM_Control_Final:48: error: invalid conversion from 'cost char to char' [-fpermissivel]
expression list treated as a compound expression in initializer[-fpermissivel]

Your help is appreciated.

Thanks and regrads
Manuel

char const *

This maybe should be const char *

Michinyon,

Thanks for your prompt response and your help, but, changing from 'char const' to 'const char' didn't solve the problem.

Any help is wellcome.
Thanks.
Manuel

    char SendATCmdWaitResp("AT+CREG?", 1000, "\r\n+CREG:1,1\r\n\r\nOK\r\n");

Are you trying to call the function with this line in the loop() function or define it ?

Hello UKHeliBob!

I am trying to call the function in the loop(). The function prototype is before the setup().

char SendATCmdWaitResp(const char *AT_cmd_string, uint16_t time_out,const char *response_string);

Thanks for reply.
Manuek

Then you have a naked "char" there at the function call. It returns a char and you do nothing with it. you need to assign it to a variable or use it some other way.

KeithRB,

thanks for your answer. I am stucked I can not get out of this problem. I assgned a variable like this:

char resp = 0;

I went to the function call the add this:

if (resp == char SendATCmdWaitResp("AT+CREG?", 1000, "\r\n+CREG:1,1\r\n\r\nOK\r\n"));
{}

I still get the following error:
error: -expected primary_expression before 'char'
error: - expected a ')' before 'char'

That is not a function call.

This is:

char x = SendATCmdWaitResp("AT+CREG?", 1000, "\r\n+CREG:1,1\r\n\r\nOK\r\n");

Thanks to you all!

The problem was solved (wasn't a problem).

You do not believe, what was the problem for the function not printing. I forgot to include in setup() the function Serial.begin(115200);

Thanks again.
Manuel

Now you know why this sticky read this before posting a programming question tells you to post all of your program and not just snippets.

However, if you still have

char SendATCmdWaitResp("AT+CREG?", 1000, "\r\n+CREG:1,1\r\n\r\nOK\r\n");

in your program you are still not calling the function correctly.