die Kollision zu vermeiden

Fragen und Diskussionen zur Entwicklung von neuen Geräten. Sowohl Hardware als auch Software. English is welcome.
Antworten
vannachen
Beiträge: 28
Registriert: 23. Mai 2013, 12:19

die Kollision zu vermeiden

Beitrag von vannachen »

Hallo,

sorry for my poor deutsch!

die Kollision mit lib_922 immer bei mir. Heute hinzufüge ich eine neue Mehode wie folgend,
und die Ergebnis seht gut aus:
colli_flag ist von der state_machine
void SetAndTransmitObject(unsigned char objectNr)
{
	unsigned char send_obj_count;
	unsigned int m;
	unsigned char n;

	EX1=0;
	send_obj_value(objectNr);
	while((fb_state>0) || TR1 || wait_for_ack);
	send_obj_count=1;
	while( colli_flag && send_obj_count<4 ) {
		if(colli_flag) colli_flag = 0;
		
		//CSMA/CD, after a random time-delay resend!~
		switch(send_obj_count) {
		case 1:
			if(colli_timedelay<15000)
				colli_timedelay = 30000- colli_timedelay;
			break;
		case 2:
			if(colli_timedelay<10000)
				colli_timedelay = 20000-colli_timedelay;
			break;
		case 3:
			if(colli_timedelay>10000)
				colli_timedelay -= 10000;
			break;
		case 4:
			while(colli_timedelay>5000)
				colli_timedelay -= 5000;
			break;
		}

		srand(colli_timedelay);//seed colli_timedelay
		for(n=0;n<10;n++)
			for(m=0;m<rand();m++);
		
		EX1=0;
		send_obj_value(objectNr);
		while((fb_state>0) || TR1 || wait_for_ack);
		send_obj_count++;
	}
	EX1=1;
}
Edit by StefanT: set code to pre format to make it readable
StefanT
Beiträge: 268
Registriert: 17. Mai 2013, 08:18
Wohnort: Salzburg

Re: die Kollision zu vermeiden

Beitrag von StefanT »

This makes the app busy wait until the telegram is sent. I might be wrong, but I think the collision problem is (or shall) be handled inside the library.
vannachen
Beiträge: 28
Registriert: 23. Mai 2013, 12:19

Re: die Kollision zu vermeiden

Beitrag von vannachen »

StefanT hat geschrieben:This makes the app busy wait until the telegram is sent. I might be wrong, but I think the collision problem is (or shall) be handled inside the library.
Hallo, Stefant

yes, you are right, but:

in the statemachine there is a resend-mechanism, repeat_count flag.
But:

1. when the kollision happens, we must wait a while to resend. If we wait for the same time in different "Controller", the kollision happens always!
2. when the tel_arrived the telegramm[]-array changed, so we just do the repeat_count++ and repeat the init_tx(), but we do actually send the received telegramms.

so we should do the repeat in main-loop. And main-loop has the low priority so the interrupts just like INT1 or T1 should not wait for the sent.

(maybe we should add the if(tel_arrived) process_tel(); after the while())

all of these are just my analysis, should be verified, but for me the problems seem solved.
Antworten