read the sensor data on switch

Status
Not open for further replies.

embed_v

Junior Member level 1
Joined
Aug 10, 2010
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,432
hii this my code :

my logic is that i have to read the current sensor data on appropriate dip sw.
for that i define the structure for sensor ,also int Read_sensor_id(int Dip_Switch) for to read sensor data on sw.
but when i complied the err occoured:

Error: L6200E: Symbol infor multiply defined (by delay.o and commands.o).
Error: L6200E: Symbol infor multiply defined (by i2c.o and commands.o).
Error: L6200E: Symbol infor multiply defined (by sensor.o and commands.o).

i think logic is ok but somthing wrg in structure....?????????


Code:
struct sensor
{
	U8 sensr_id;
	U8 opto_read;
	 
}infor;

int Read_sensor_id(int Dip_Switch)
{
	int sensor_id;
       Dip_Switch = DIP_SWITCH;    //4bit dipsw
	switch (Dip_Switch)
	{
	case 0:
		sensor_id = SENSOR_ID0;
		break;

	case 1:
		sensor_id = SENSOR_ID1;
		break;
	case 2:
		sensor_id = SENSOR_ID2; 

	default:
		sensor_id = -1; 
	break;
	}

	return sensor_id;
}

int Read_sensor_current_id(int curr_id)
{
	curr_id =  Read_Cassette_id(infor.sensr_id);

	return curr_id; 
}
 

I suggest to read the error message strictly.

It says, that the symbol is defined in multiple compilation units, which isn't allowed according to the C standard. Because you are showing only one unit, the problem can't be seen from your post.

It may be the case, that you have exported the symbol through an include file without using the external keyword. Depending on your compiler, it may be necessary to separate structure definition (by a typedef) and variable instance in this case.

Or you have multiple variables with same name, that are not intended to share it's memory space. Then they can be simply renamed.
 

this logic aren't so good. As I told you in the your another thread: https://www.edaboard.com/threads/214807/#post909261 , by the way seems to be the same thing in 2 threads, without the break in case 2 if this case has been selected the result will be the same as default case and you also have other redundances on your code. For a better organization, keep just one of those threads.

Iuri~

EDIT: Sorry, now I realise that are 2 different users with a similar name, just ignore what i told you about the threads.
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…