Problem with using wm_itoa()


#1

I am having a problem with getting some standard functions, including wm_itoa(), to work. I have simplified my application to just converting 123 to a string and printing. As soon as my code hits the wm_itoa() function the module restarts the app and keeps looping and restarting indefinitely… See my hyperterm log below:

What am I doing wrong?? I’m using WMP100 with FW 7.46.0
Thanks

at+wopen=1
OK

+WIND: 13

+CREG: 0

+CGREG: 0
Program started

+WIND: 1

+CREG: 2

+WIND: 15,4,“11/11/15,23:13:51-32”,6,“0”

+WIND: 16

+WIND: 7

+CREG: 5,“23A0”,“DC3B”
Indside wind 4 handler
+WIND: 13

+CREG: 0

+CGREG: 0
Program started

+WIND: 1

+CREG: 2

+WIND: 16

+WIND: 15,4,“11/11/15,23:14:02-32”,6,“0”

+WIND: 7

+CREG: 5,“23A0”,“DC3B”
Indside wind 4 handler
+WIND: 13

#include "adl_global.h"
#include "generated.h"
#include "wm_types.h"

const u16 wm_apmCustomStackSize = 4096;

//Local Variables
ascii *string;
s32 intgr;


//Send text to network
bool wind_4_handler(adl_atUnsolicited_t *paras)
{
	adl_atSendResponse(ADL_AT_UNS, "Indside wind 4 handler\r\n");

	intgr = 123;
	wm_itoa(intgr, string);

	adl_atSendResponse(ADL_AT_UNS, "String converted from int:\r\n");
	adl_atSendResponse(ADL_AT_UNS, string);

	return FALSE;
}


//Main Function
void main_task(adl_InitType_e InitType)
{
	adl_atSendResponse(ADL_AT_UNS,"Program started\r\n");
   adl_atUnSoSubscribe("+WIND: 4",wind_4_handler);
}

#2

Change your string declaration to:

ascii string[30];

If you look at the backtraces coming from the module, you will see an invalid address error. This is probably because you haven’t initialised your ascii pointer. Declaring an ascii array initialises the memory correctly and so wm_itoa writes to the correct location.