Warning causing target crash?


#1

Why i get this warnings and can this warnings “crash” the target ?

void myGpioOutput(void)	
{
adl_atSendResponse(ADL_AT_RSP,"\r\n GPIO runing\r\n");
TRACE (( 3, "gpio running" ));		
adl_ioWriteSingle(GpioOutputHandle, ADL_IO_Q2686_GPIO_2, ADL_IO_HIGH);
TRACE (( 3, "HIGH" ));
adl_ioWriteSingle(GpioOutputHandle, ADL_IO_Q2686_GPIO_2, ADL_IO_LOW);
TRACE (( 3, "LOW" ));	
}

void setGpioOutput(void)
{
TRACE (( 3, "Config" ));
GpioOutputHandle = adl_ioSubscribe ( 1, Gpio2Config, 0, 0, 0 );	
adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, myGpioOutput );
adl_atSendResponse(ADL_AT_RSP,"\r\n Gpio - Config\r\n");
}

void timerHandler (u8 id)
{
adl_atCmdCreate("AT+ADC?", TRUE,ADC_Handler,"*", NULL);  
...
Timer_stop();
}

void Timer_stop()
{
adl_tmrUnSubscribe(setTimer,(adl_tmrHandler_t)timerHandler,ADL_TMR_TYPE_100MS);
setTimer = NULL;
}

#2

The clue is in the name: They are called “Warnings” because they Warn you about a potential [color=orange]problem in your code.

Of course not!
It’s not the Warning itself that crashes your target; it’s the underlying [color=orange]problem that causes the crash - that’s why the compiler is warning you!

If somebody warned you, “That car doesn’t look safe”, you would do well to consider whether or not the car is safe before getting into it, wouldn’t you?
If you just ignore them and go speeding off down the autobahn, and it turns out that the car really was unsafe, it’s not the fault of that person or their warning if you get hurt, is it?

Exactly the same applies to warnings that you may receive from a compiler!

Pointers are probably the most powerful feature of ‘C’ - unfortunately, this also means that they are also the most [color=red]dangerous when used carelessly or incorrectly!

The warning is about argument 4 of your call to ‘adl_tmrSubscribe’ - so take a look at it:

void myGpioOutput(void)	
{
   :
   :
}

void setGpioOutput(void)
{
   :
   adl_tmrSubscribe ( TRUE,  10,  ADL_TMR_TYPE_100MS, myGpioOutput  );
   :
}

Now, go back to the ADL User Guide - what does it tell you about the 4th parameter of adl_tmrSubscribe?
Does your setGpioOutput function match what the ADL User Guide tells you…?


#3

If i compile the code under RTE i get upper messages under “error” section.
If i compile the same code under Target i get those messages under “warning” section.

In both ways, how to correct this errors.
This is the example on one such function:


#4

The Remote (RTE) and Target builds use different compilers:
The Remote build uses a native PC compiler (eg Microsoft);
The Target build uses an ARM Cross-Compiler (eg, GCC).

That explains why the messages are slightly different.

They are both telling you that the types don’t match - so make them match!


#5

could you be more precisely. What would you do…


#6

For a start, look at the exact messages, and see which particular parameter(s) are affected.

Then look at the types of the actual parameter(s) you have supplied.

Then look in the ADL manual to find what types are required.

If they differ, then that’s your problem!


#7
  • If i call one function, one time, then i get no warnings/errors ??
  • functions are different but the error is always the same.
  • the function that i have sent is the whole function, there nothing else so i can not see what can be problem.
  • the gpioconfig part is OK.

#8

C doesn’t like calling a function before it is declared.

try to reverse the code like this:

void Timer_stop() 
{ 
adl_tmrUnSubscribe(setTimer,(adl_tmrHandler_t)timerHandler,ADL_TMR_TYPE_100MS); 
setTimer = NULL; 
}

void timerHandler (u8 id) 
{ 
adl_atCmdCreate("AT+ADC?", TRUE,ADC_Handler,"*", NULL);  
... 
Timer_stop(); 
}

or do define the prototype, if you don’t want or can’t reverse the code:

void Timer_stop();

void timerHandler (u8 id) 
{ 
adl_atCmdCreate("AT+ADC?", TRUE,ADC_Handler,"*", NULL);  
... 
Timer_stop(); 
} 

void Timer_stop() 
{ 
adl_tmrUnSubscribe(setTimer,(adl_tmrHandler_t)timerHandler,ADL_TMR_TYPE_100MS); 
setTimer = NULL; 
}

In the case of ‘myFunction’ this might also apply.

Best Regards,
Jan


#9

and if you do it, ‘C’ is likely to make default assumptions about its type & parameters - which may well not be as you require, so may well end up givig you errors/warnings about type errors and/or mismatches…