Sodaq board sara AFF hanging :

Consider this function :

float get_geoDistance(String G1, String G2) {   
	
	int startSearch = 0;
	String LAT, LON;
	float lat1, lon1, lat2, lon2;
	
	
	int GGA_loc ;
	
	G1 = G1 + "\n";
	G2 = G2 + "\n";
	
	GGA_loc = G1.indexOf("GGA", startSearch);
	
	if (GGA_loc == -1 ){	
		return 0;
	}
	
	if ( GGA_loc != -1) {
		int TRM_loc = G1.indexOf("\n", GGA_loc);                          
		String extract = G1.substring(GGA_loc, TRM_loc);   
		
		LAT = split(extract, ',',2); 
		LON = split(extract, ',',4); 
		LAT.trim();
		LON.trim();
		lat1 = LAT.toFloat() / 100.00 * (PI) / 180.00 ;
		lon1 = LON.toFloat() / 100.00 * (PI) / 180.00 ; 
		debug2(LAT + "; " + LON);
		if (LAT != "" && LON != "") {
			setLedColor(YELLOW); 			
		sodaq_wdt_safe_delay(20); // specifically this line or the one marked below.
		}
		
	}
	
	GGA_loc = G2.indexOf("GGA", startSearch);
	
	
	if (GGA_loc == -1 ) { 
		GPS_usable_old = G1; 
		GPS_usable_old_rec = G1;
		return 0;
	}
	
	if ( GGA_loc != -1) {
		int TRM_loc = G2.indexOf("\n", GGA_loc);
		String extract = G2.substring(GGA_loc, TRM_loc);  
		
		LAT = split(extract, ',',2);    
		LON = split(extract, ',',4);    
		LAT.trim();
		LON.trim();
		lat2 = LAT.toFloat() / 100.00 * (PI) / 180.00;
		lon2 = LON.toFloat() / 100.00 * (PI) / 180.00;    
		if (LAT != "" && LON != ""){
			setLedColor(YELLOW); 			
		sodaq_wdt_safe_delay(20); // specifically this line or the one marked above.
		}
	}
	
	
	float a = pow((sin((lat1 - lat2) / 2.0)),2);
	float b = cos(lat1) * cos( lat2);
	float c = pow((sin((lon1 - lon2) / 2.0)),2);
	
	float r = 6370000;
	
	float d = 2 * r * asin(sqrt( a + b*c)) ;
	
	return d;
	
}

This causes the program to hang from time to time. What am doing wrong? the safe delay?? Thank you.

PS: I have seen this.

I need a way to keep the watchdog time alive for 10 minutes at least, and then reset it. Is there a way to do it?

Hi Sean,

If your program just “hangs” it does not seem like you’ve implemented the watchdog. Double so as the maximum timeout you can set for the watchdog is approximately 8.192 seconds.

As to why it’s failing, that’s a tough call. My next step would be to either disable some parts of the code and see when it starts working again (assuming this doesn’t take way too long to occur) or to catch the hardfault handler and check what is actually causing it to hardfault.

Calling wdt reset when the wdt is not enabled should be save, but it’s just going to be a delay then.

Also consider adding a lot more print functions to see where it fails as well, that’s probably your best bet without a debugger (SW & HW).

Regards,
Thom

Hi

My bad - I wanted to say, that the program hangs without the watchdog timer.

The watchdog does reset the program , and calls the setup function. But yes, I am trying now all these printline methods since this morning. But did not encounter the error any more…