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

c program problem

i am using at89c52. i compiled the below c program its showing error as given below whats is the error in this program

c(4): warning C318: can't open file 'usart.h'
c(5): warning C318: can't open file 'lcd.h'
c(6): warning C318: can't open file 'gsm.h'
c(47): warning C206: 'DelayMs': missing function-prototype
c(47): error C267: 'DelayMs': requires ANSI-style prototype

#include <at89c51xd2.h>
#include <string.h>
#include <stdio.h>
#include "usart.h"
#include "lcd.h"
#include "gsm.h"

// Inputs
#define moistureSensor1 P1_4
#define moistureSensor2 P1_5
#define moistureSensor3 P1_6
#define moistureSensor4 P1_7

//Outputs
#define relayMotor P0_0
#define NOR_CONDITION 1
#define DRY_CONDITION 2
#define WET_CONDITION 3

unsigned char fieldStatus = 0;

unsigned char motorOnFlag = 0;
unsigned char motorOffFlag = 0;
unsigned char moisSenCnt = 0;
unsigned char mtOnSmsFlag = 0;
unsigned char mtOffSmsFlag = 0;

unsigned char smsSendFlag = 0;
xdata unsigned char smsMessage[ 100 ];

void main( void )
{ xdata unsigned char messageBuffer[200]; int retValue = 0; unsigned char *myString1 = "Starting........"; unsigned char *myString2 = "................"; unsigned char *myString3 = "Wting 4 Command "; unsigned char *myString4 = "Command Recieved"; unsigned char colunCount = 0, index = 0; xdata unsigned char gsmCommand[7]; unsigned int waitCnt = 0;

P2 = 0xFF; P3 = 0xFF; relayMotor=0; Delay_Ms(5);

Lcd_Init(); SenStringToLcd ( 1, myString1 ); SenStringToLcd ( 2, myString2 );

smsSendFlag = 0;

USART_Init_9600();

retValue = DeleteSms(); if( retValue == 0 ){

SenStringToLcd ( 1, "GSM Modem is " ); SenStringToLcd ( 2, "Not Functioning " ); }

while(1){

moisSenCnt = 0; motorOnFlag = 0; motorOffFlag = 0;

SenStringToLcd ( 1, " Sensing field " ); SenStringToLcd ( 2, " Condition " ); DelayMs( 100 );

if( moistureSensor1 == 1 ) moisSenCnt++; if( moistureSensor2 == 1 ) moisSenCnt++; if( moistureSensor3 == 1 ) moisSenCnt++; if( moistureSensor4 == 1 ) moisSenCnt++;

SenStringToLcd ( 1, " Field Sensed " ); SenStringToLcd ( 2, "****************" );

fieldStatus = NOR_CONDITION;

if( moisSenCnt <= 2 ){ fieldStatus = DRY_CONDITION; motorOnFlag = 1; motorOffFlag = 0; relayMotor=1; SenStringToLcd ( 1, "Field Is In Dry " ); SenStringToLcd ( 2, " Condition " ); DelayMs( 300 ); } else{ fieldStatus = WET_CONDITION; motorOffFlag = 1; motorOnFlag = 0; relayMotor=0; SenStringToLcd ( 1, "Field Is In Wet " ); SenStringToLcd ( 2, " Condition " ); DelayMs( 00 ); } SenStringToLcd ( 1, "****************" ); SenStringToLcd ( 2, "****************" ); DelayMs( 100 );

SenStringToLcd ( 2, myString3 ); DelayMs( 100 ); SenStringToLcd ( 2, myString2 ); DelayMs( 100 );

retValue = 0; strcpy( messageBuffer, "\0" ); retValue = ReadSms( messageBuffer ); if( retValue == 1 ){

index = 0; colunCount = 0; waitCnt = 0; while( (colunCount < 6) && (waitCnt < 10000) ){ if( messageBuffer[ index ] == '"' ){ colunCount++; } index++; waitCnt++; }

SenStringToLcd ( 1, myString4 ); strcpy( gsmCommand, "\0" ); strncpy( gsmCommand, &messageBuffer[index+2],6 ); gsmCommand[6] = '\0'; SenStringToLcd ( 2, myString2 ); DelayMs( 10 ); SenStringToLcd ( 2, gsmCommand ); DelayMs( 250 );

if ( !strcmp( gsmCommand, "MTR ON" ) ){ relayMotor=1; motorOnFlag = 1; motorOffFlag = 0; SenStringToLcd ( 1, " MOTOR ON " ); SenStringToLcd ( 2, "****************" ); } else if ( !strcmp( gsmCommand, "MTR OF" ) ){ relayMotor=0; motorOffFlag = 1; motorOnFlag = 0; SenStringToLcd ( 1, " MOTOR OFF " ); SenStringToLcd ( 2, "****************" ); } else if ( !strcmp( gsmCommand, "GIFMOD" ) ){ smsSendFlag = 1; SenStringToLcd ( 1, "Request Received" ); SenStringToLcd ( 2, "****************" ); DelayMs( 100 ); } else{ SenStringToLcd ( 1, "Invalid Command " ); DelayMs( 200 ); SenStringToLcd ( 2, "Received " ); DelayMs( 200 ); }

if( smsSendFlag == 1 ){

smsSendFlag = 0;

if( fieldStatus == NOR_CONDITION ){ strcpy( smsMessage, "Field Is In Normal Condition." ); SendSms( "+919490045729", smsMessage ); DelayMs( 500 ); SendSms( "+919703935935", smsMessage ); DelayMs( 500 ); } else if( fieldStatus == DRY_CONDITION ){ strcpy( smsMessage, "Field Is In Dry Condition." ); SendSms( "+919490045729", smsMessage ); DelayMs( 500 ); SendSms( "+919703935935", smsMessage ); DelayMs( 500 ); } else if( fieldStatus == WET_CONDITION ){ strcpy( smsMessage, "Field Is In Wet Condition." ); SendSms( "+919490045729", smsMessage ); DelayMs( 500 ); SendSms( "+919703935935", smsMessage ); DelayMs( 500 ); } else{ } }

if( motorOnFlag == 1 && mtOnSmsFlag == 0){

motorOnFlag = 0; mtOnSmsFlag = 1; mtOffSmsFlag = 0; strcpy( smsMessage, "Motor On In the field" ); SendSms( "+919490045729", smsMessage ); DelayMs( 500 ); SendSms( "+919703935935", smsMessage ); DelayMs( 500 ); } if( motorOffFlag == 1 && mtOffSmsFlag == 0){

motorOffFlag = 0; mtOffSmsFlag = 1; mtOnSmsFlag = 0; strcpy( smsMessage, "Motor Off In the field" ); SendSms( "+919490045729", smsMessage ); DelayMs( 500 ); SendSms( "+919703935935", smsMessage ); DelayMs( 500 ); }

SenStringToLcd ( 1, "Command Executed"); DelayMs( 300 );

while( DeleteSms() == 0); SenStringToLcd ( 1, "Command Deleted "); SenStringToLcd ( 2, myString2 ); } } // End Of while(1);
}

Parents
  • Learn to read the error messages, and find the files it is looking for and are currently missing. Start by looking where you took this source file from. Fix the syntax if that is still a problem.

    Learn to read the source code posting instructions, it stops your code looking like a wall of texts, and that you pay attention to detail.

Reply
  • Learn to read the error messages, and find the files it is looking for and are currently missing. Start by looking where you took this source file from. Fix the syntax if that is still a problem.

    Learn to read the source code posting instructions, it stops your code looking like a wall of texts, and that you pay attention to detail.

Children
No data