We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am getting error like this...program is running fine,when all file made to one main file..bt problem while creating different file....can some one suggest,how to clear this. linking... *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: LCD_INIT MODULE: lcd.obj (LCD) *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: _LCD_STR MODULE: lcd.obj (LCD) *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: _LCD_CMD MODULE: lcd.obj (LCD) *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: _LCD_DATA MODULE: lcd.obj (LCD) *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: _DELAY MODULE: lcd.obj (LCD) *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?_LCD_STR?LCD *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?LCD_INIT?LCD Program Size: data=15.0 xdata=0 code=652
can any body suggest me plz..by seeing above code......i have pinched my head last n8....bt i did,t gt the answer.
Interesting - you have managed to get the compiler to accept
\*prototypes*/
as a valid C comment?
Another interesting thing - you never noticed the rules about how to post source code on this site? Don't you think your posted code looks very, very strange, with line breaks at very unexpected places? Didn't you start to figure out what was wrong with the strange look when you saw it?
A third interesting thing - how will we be able to know if you have included the same C file twice in your project?
that i did't mentioned in code..that i have mentioned for your reference sir....i am new to this website..when i used to copy the code means it seems good..bt while i post in tht...it appers like tht...i hope this is some wat readable...
MAIN.C:-
#include <REGX51.H> #include"SERIAL.c" #include"LCD.c"
sbit rf=P2^0; sbit motor=P0^0;
unsigned char asc,ok[2],r[4],a,i,oxoa, a,m[20],j,temp[10],temp1[10]; void cmdwrt_lcd(unsigned char cmd); void serial_transmit(unsigned char *srstr); void command(unsigned char d[]); void serial_tx(unsigned char srda); void delay1();
void gsm_send()
{
command("AT");
delay1();
command("AT+CMGF=1");
delay(65000);
serial_transmit("AT+CMGS=");
serial_tx('"');
serial_transmit("9710362655");
serial_tx(0x0d);
serial_tx(0x0a);
delay(65000); delay(65000); delay(65000);
serial_transmit("Vehicle Thefted ");
serial_transmit("Send Stop message to stop the vehicle");
delay(650);
serial_tx(0x1A);
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
}
void gsm_send1()
delay(65000); delay(65000);
serial_transmit("Your Vehicle has been stopped");
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
void wait_0x0a()
do
{ a=serial_rx();
} while(a!=0x0a); }
void rec_msg()
unsigned char i=0;
{ while(RI==0);
temp[i]=SBUF;
i++;
RI=0;
} while(temp[i-1]!=0x0A);
void check_ok()
{ unsigned char i;
for(i=0;i<=3;i++) //receving OK//
temp1[i]=SBUF;
} }
void command(unsigned char d[])
{ serial_transmit(&d[0]);
cmdwrt_lcd(0x80);
//display_lcd(&d[0]);
wait_0x0a();
check_ok();
temp1[2]='\0';
cmdwrt_lcd(0xc0);
void delay1()
{ delay(65000);delay(65000);delay(65000);
void gsm_read()
{ command("AT");
command("AT+CGSMS=1");
command("AT+CMGD=1");
cmdwrt_lcd(0x01);
display_lcd("Waiting for Msg");
for(j=0;j<=15;j++)
m[j]=SBUF;
RI=0; }
cmdwrt_lcd(0xC0);
display_lcd(&m[0]);
serial_transmit("AT+CMGR=1");
display_lcd("AT+CMGR=1");
wait_0x0a(); wait_0x0a(); wait_0x0a();
rec_msg();
temp[4]='\0';
display_lcd(&temp[0]);
delay1(); delay1();
if(temp[0]=='S'&& temp[1]=='t'&&temp[2]=='o'&&temp[3]=='p')
{ motor=0;
display_lcd("Vehicle Stopped");
gsm_send1();
CODE FOR SERIAL(SERIAL.c):-
#include <REGX51.H> #include"header.h"
void serial_init()
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
void serial_tx(unsigned char srda)
{ SBUF = srda;
while(TI == 0);
TI = 0;
void serial_transmit(unsigned char *srstr)
while(*srstr != '\0')
serial_tx(*srstr);
//datawrt_lcd(*srstr);
srstr++;
unsigned char serial_rx()
unsigned char rbuf;
while(RI == 0);
RI = 0;
rbuf = SBUF;
return rbuf;
CODE FOR LCD(LCD.c):-
sbit rs = P3^5; sbit rw = P3^6; sbit en = P3^7;
void delay(unsigned int dela)
unsigned int i;
for(i=0;i<dela;i++);
void cmdwrt_lcd(unsigned char cmd)
P1 = cmd;
rs = 0;
rw = 0;
en = 1;
delay(15);
en = 0;
delay(150);
void datawrt_lcd(unsigned char datas)
P1 = datas;
rs = 1;
void display_lcd(unsigned char *lcdstr)
while (*lcdstr !='\0')
datawrt_lcd(*lcdstr);
lcdstr++;
void lcd_init()
cmdwrt_lcd(0x38);
cmdwrt_lcd(0x0C);
CODE FOR HEADER FILE(header.h)
#ifndef HEADER_H #define HEADER_H
extern void serial_tx(unsigned char);
extern void serial_transmit(unsigned char *);
extern unsigned char serial_rx();
extern void serial_init();
extern void lcd_init();
extern void display_lcd(unsigned char *);
extern void datawrt_lcd(unsigned char);
extern void cmdwrt_lcd(unsigned char);
extern void delay(unsigned int);
#endif
So, instead of just leaping in blindly, don't you think it would be a good idea spending some time to find out how to use it properly?!
Look at this picture: www.danlhenry.com/.../keil_code.png
Is that really so hard?
"i hope this is some wat readable..."
Don't just "hope" - use the Preview and verify for sure!!
MAIN.c:-
#include <REGX51.H> #include"SERIAL.c" #include"LCD.c" sbit rf=P2^0; sbit motor=P0^0; unsigned char asc,ok[2],r[4],a,i,oxoa, a,m[20],j,temp[10],temp1[10]; void cmdwrt_lcd(unsigned char cmd); void serial_transmit(unsigned char *srstr); void command(unsigned char d[]); void serial_tx(unsigned char srda); void delay1(); void gsm_send() { command("AT"); delay1(); command("AT+CMGF=1"); delay(65000); delay(65000); serial_transmit("AT+CMGS="); serial_tx('"'); serial_transmit("9710362655"); serial_tx('"'); serial_tx(0x0d); serial_tx(0x0a); delay(65000); delay(65000); serial_transmit("Vehicle Thefted "); serial_tx(0x0a); serial_transmit("Send Stop message to stop the vehicle"); serial_tx(0x0a); delay(650); serial_tx(0x1A); delay(65000); delay(65000); } void gsm_send1() { command("AT"); delay1(); command("AT+CMGF=1"); delay(65000); delay(65000); serial_transmit("AT+CMGS="); serial_tx('"'); serial_transmit("9710362655"); serial_tx('"'); serial_tx(0x0d); serial_tx(0x0a); delay(65000); delay(65000); serial_transmit("Your Vehicle has been stopped"); serial_tx(0x0a); delay(650); serial_tx(0x1A); delay(65000); delay(65000); } void wait_0x0a() { do { a=serial_rx(); }while(a!=0x0a); } void rec_msg() { unsigned char i=0; do { while(RI==0); temp[i]=SBUF; i++; RI=0; } while(temp[i-1]!=0x0A); } void check_ok() { unsigned char i; for(i=0;i<=3;i++) { while(RI==0); temp1[i]=SBUF; RI=0; } } void command(unsigned char d[]) { serial_transmit(&d[0]); cmdwrt_lcd(0x80); serial_tx(0x0d); wait_0x0a(); check_ok(); temp1[2]='\0'; delay(65000); delay(65000); cmdwrt_lcd(0xc0); } void delay1() { delay(65000);delay(65000);delay(65000); } void gsm_read() { command("AT"); delay1(); command("AT+CMGF=1"); delay1(); command("AT+CGSMS=1"); delay1(); command("AT+CMGD=1"); delay1(); cmdwrt_lcd(0x01); cmdwrt_lcd(0x80); display_lcd("Waiting for Msg"); for(j=0;j<=15;j++) { while(RI==0); m[j]=SBUF; RI=0; } delay1(); cmdwrt_lcd(0xC0); display_lcd(&m[0]); delay1(); cmdwrt_lcd(0x01); cmdwrt_lcd(0x80); serial_transmit("AT+CMGR=1"); display_lcd("AT+CMGR=1"); serial_tx(0x0d); wait_0x0a(); rec_msg(); delay1(); temp[4]='\0'; cmdwrt_lcd(0xc0); display_lcd(&temp[0]); delay1(); delay1(); if(temp[0]=='S'&& temp[1]=='t'&&temp[2]=='o'&&temp[3]=='p') { motor=0; cmdwrt_lcd(0x01); cmdwrt_lcd(0x80); display_lcd("Vehicle Stopped"); gsm_send1(); } } void main() { serial_init(); lcd_init(); P0=0x00; display_lcd("VEHI.THEFT ALERT"); cmdwrt_lcd(0xC0); display_lcd("SYSTEM USING GSM"); motor=1; delay(65000); while(1) { if(rf==0) { cmdwrt_lcd(0x01); display_lcd(" VEHICLE THEFTED"); gsm_send(); gsm_read(); while(rf==0); } } }</prev> CODE FOR SERIAL:-(SERIAL.c)
#include <REGX51.H> #include"header.h" void serial_init() { TMOD = 0x20; TH1 = 0xFD; SCON = 0x50; TR1 = 1; } void serial_tx(unsigned char srda) { SBUF = srda; while(TI == 0); TI = 0; } void serial_transmit(unsigned char *srstr) { while(*srstr != '\0') { serial_tx(*srstr); srstr++; } } unsigned char serial_rx() { unsigned char rbuf; while(RI == 0); RI = 0; rbuf = SBUF; return rbuf; }
CODE FOR LCD.c:-(LCD.c)
#include <REGX51.H> sbit rs = P3^5; sbit rw = P3^6; sbit en = P3^7; void delay(unsigned int dela) { unsigned int i; for(i=0;i<dela;i++); } void cmdwrt_lcd(unsigned char cmd) { P1 = cmd; rs = 0; rw = 0; en = 1; delay(15); en = 0; delay(150); } void datawrt_lcd(unsigned char datas) { P1 = datas; rs = 1; rw = 0; en = 1; delay(15); en = 0; delay(150); } void display_lcd(unsigned char *lcdstr) { while (*lcdstr !='\0') { datawrt_lcd(*lcdstr); lcdstr++; } } void lcd_init() { cmdwrt_lcd(0x38); cmdwrt_lcd(0x0C); cmdwrt_lcd(0x01); cmdwrt_lcd(0x80); }
CODE FOR HEADER.h:-(header.h)
#ifndef HEADER_H #define HEADER_H extern void serial_tx(unsigned char); extern void serial_transmit(unsigned char *); extern unsigned char serial_rx(); extern void serial_init(); extern void lcd_init(); extern void display_lcd(unsigned char *); extern void datawrt_lcd(unsigned char); extern void cmdwrt_lcd(unsigned char); extern void delay(unsigned int); #endif
now any one can suggest me.....
#include"SERIAL.c" #include"LCD.c"
DO NOT #include .c files
Erik
void gsm_send1() { command("AT"); delay1(); command("AT+CMGF=1"); delay(65000); delay(65000); serial_transmit("AT+CMGS="); serial_tx('"'); serial_transmit("9710362655"); serial_tx('"'); serial_tx(0x0d); serial_tx(0x0a); delay(65000); delay(65000); serial_transmit("Your Vehicle has been stopped"); serial_tx(0x0a); delay(650); serial_tx(0x1A); delay(65000); delay(65000); }
This is a very bad approach!
All AT commands give a response to indicate success or failure; you are ignoring these responses and just ploughing blindly on assuming success!!
In addition, AT+CMGS gives a Prompt when it is ready for input...
sir, that is equal to one(AT+CMGF = 1)..my friend types wrong in thread..but in coding we have done tht...u just tell, how we should avoid tht error of multiple public definition and un called segment...
Then,what should we do sir??
Maybe look at all the examples you got installed together with the compiler - don't they seem to sometimes contain multiple C files, without using #include to compile them?
There are no "typing wrong in thread".
There are copy and paste.
The difference between typing and copying/pasting is that code that is typed is meaningless for us to look at. Why look at something that isn't identical to what the compiler will see? It's just a waste of our time to consider code that has been retyped. And the time spent retyping would be a waste of time for the one retyping it too...
Yes i got it.....thanks to all...
that is the big mistake i committed here... should not add #include to .c files....
Once again thks to all.... especially Per Westermark sir....
Regard Zakir
Don't have more than 1 (ie, "multiple") definition for each public symbol!!