1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Debugging: Add PIOS_DEBUG_Panic() call wen an UAVObject handle is requested but object is uninitialized, make PiOS.posix bail in case of a Panic with an error message

This commit is contained in:
Corvus Corax 2011-08-19 12:56:26 +02:00
parent 01a844e0da
commit 78e42470d4
2 changed files with 11 additions and 3 deletions

View File

@ -79,8 +79,15 @@ void PIOS_DEBUG_Panic(const char *msg)
PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, "\r%s @0x%x\r", msg, lr);
#endif
// Stay put
while (1) ;
// tell the user whats going on on commandline too
fprintf(stderr,"CRITICAL ERROR: %s\n",msg);
// this helps debugging: causing a div by zero allows a backtrace
// and/or ends execution
int b = 0;
int a = (2/b);
b=a;
}
/**

View File

@ -40,7 +40,7 @@
#include "$(NAMELC).h"
// Private variables
static UAVObjHandle handle;
static UAVObjHandle handle = NULL;
/**
* Initialize object.
@ -103,6 +103,7 @@ $(INITFIELDS)
*/
UAVObjHandle $(NAME)Handle()
{
if (!handle) PIOS_DEBUG_Panic("$(NAME) used uninitialized");
return handle;
}