new member function not getting detected in IDE

Hi All,

Greetings!

I am working on interfacing SIM900 GSM module to Arduino and I am working on GSM_Shield library.

In the existing code of GSM_Shield library I have added one new function of my own. I have updated the library code as follows:

  1. In GSM_Shield.h --> I have added the function under Public: along with the existing functions char CheckCommunication(void);

  2. In GSM_Shield.c --> I have defined the function as follows:
    char GSM::CheckCommunication(void)
    ** {**
    ** //code**
    ** return ret_val;**
    ** }**

  3. I have also updated the keyword.txt file with the new function name.

I use this function in sketch:
gsm.CheckCommunication();

After doing all the three things, I am getting following error while compiling my sketch:

error: 'class GSM' has no member named 'CheckCommunication'

Am I missing something? This looks like a silly issue but I am confused what is missed. I even tried to restart my PC but that also didn't work. Is anything more need to be done to remove this error?

Regards
Amey

In the existing code of GSM_Shield library

That you got from where?

  1. In GSM_Shield.c --> I have defined the function as follows:
    char GSM::CheckCommunication(void)
    {
    //code
    return ret_val;
    }

Is ret_val a private field in the class? Is it a char? That seems like a strange type for a variable named ret_val.

Why is a class implemented in a C file?

  1. I got the GSM_Shield from some blog. I wil try to post the link soon.

  2. There was a typo in file name: The file is GSM_Shield.cpp.
    Following is the code in the char GSM::CheckCommunication(void) function:

char GSM::CheckCommunication(void)
{
** char ret_val = -2;**
** if (CLS_FREE != GetCommLineStatus()) return (ret_val);**
** SetCommLineStatus(CLS_ATCMD);**
** ret_val = 0; // not deleted yet**

** //send "AT" - check if comm line is OK**
** mySerial.write("AT");**
** mySerial.write("\r");**
** // 5000 msec. for initial comm tmout**
** // 20 msec. for inter character timeout**
** switch (WaitResp(5000, 50, "OK")) {**
** case RX_TMOUT_ERR:**
** // response was not received in specific time**
** ret_val = -2;**
** break;**
** case RX_FINISHED_STR_RECV:**
** // OK was received => SMS deleted**
** ret_val = 1;**
** break;**
** case RX_FINISHED_STR_NOT_RECV:**
** // other response: e.g. ERROR => SMS was not deleted**
** ret_val = 0;**
** break;**
** }**
** SetCommLineStatus(CLS_FREE);**
** return (ret_val);**
}

  char ret_val = -2;

Is char signed or unsigned, on the Arduino?

Suggest you post all the relevant code, not just snippets from it, in case there is a mistake elsewhere. For example, we can't tell what access specifier you have used for the method you added, or whether your implementation will actually compile, or whether the implementation that you are looking at is actually the one that your sketch is being compiled against.

Hi All,

Thanks for the help.

The issue was not with the syntax. The member declaration and definition was correct.
The problem was that, I had mistakenly kept two additional copies of GSM_Shield library in the libraries folder.
This was causing problem while the compilation of the modified library.

Thanks again.
Amey