This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

i'm getting error when i'm using strcmp(), in serial communication

i'm getting error when i'm using strcmp(), in serial communicationgsm

this program for gsm based home automeachine. i'm using the gsm800c module and 89s52 mc.
the main functin of this program is DTMF tones decoding
AT+DDET=1 command used to activated but in strcmp() run time shows error

//*****************************************home automation**********************************************//
#include <REGX51.H>

//********************************delay function*****************//

void delay(unsigned int ms)
{ int i,j; for(i=0;i<=ms;i++) for(j=0;j<=120;j++);
}

//***************************uart initelizatin**********************//

void uart_init(void) // INITIALIZE SERIAL PORT
{ TMOD = 0x20; // Timer 1 IN MODE 2-AUTO RELOAD TO GENERATE BAUD RATE TH1 = 0xFD; // LOAD BAUDRATE TO TIMER REGISTER SCON = 0x50; // SERIAL MODE 1, 8-DATA BIT 1-START BIT, 1-STOP BIT, REN ENABLED TR1 = 1; // START TIMER
} void tx_data(unsigned char serialdata)
{ SBUF = serialdata; // LOAD DATA TO SERIAL BUFFER REGISTER while(TI == 0); // WAIT UNTIL TRANSMISSION TO COMPLETE TI = 0; // CLEAR TRANSMISSION INTERRUPT FLAG
} unsigned rx_data(void)
{ while(RI == 0); // WAIT UNTIL DATA IS RECEIVED RI = 0; // CLEAR FLAG return SBUF; // RETURN SERIAL DATA

}
void tx_string(unsigned char *str)
{ while(*str) { tx_data(*str); str++; }

}

//****************************************MAIN PROGRAM************************************//

void main()
{ unsigned char i; unsigned char key1[]="DTMF:1"; unsigned char key2[10]; P1=0x00; P1_0=1; delay(1500); P1_0=0; uart_init(); tx_string("AT\r\n"); delay(100); tx_string("ATD***8919358088;\r\n");

while(1) { tx_string("ATS0=1\r\n"); tx_string("AT+DDET=1\r\n"); delay(100); for(i=0;i<6;i++) { key2[i] = rx_data; } key2[i]='\0'; if ((strncmp(key1, key2)) == 0) { P1=0xff; } }
}

>> this is the total program, the error is

motorcontrlleer.c(77): warning C206: 'strncmp': missing function-prototype
motorcontrlleer.c(77): error C267: 'strncmp': requires ANSI-style prototype
Target not created.
Build Time Elapsed: 00:00:01

plzzz any one helpme how to slove that error

  • For a start, please read and follow the simple, clearly-stated instructions for posting source code to the forum.

    Here is a picture to help you: www.danlhenry.com/.../keil_code.png

    It is import to learn to pay attention to information that is presented to you.

    The error messages are very clear:

    motorcontrlleer.c(77): warning C206: 'strncmp': missing function-prototype
    motorcontrlleer.c(77): error C267: 'strncmp': requires ANSI-style prototype
    

    If something - anything - is "missing" then the answer is obviously to provide it.

    If something - anything - is "required" then providing it is not optional. You must provide it.

  • For string functions, perhaps
    #include <strings.h>