Receiving a 16 character text give RTK 161. FXT009


#1

Hi ,

I am sending a text message to the FXT009.
when the length of that text is exactly 16 characters in total then the modem reboots and gives

but when I send other than 16 character
(16 > x < 16) then the everything is working perfectly fine. what could be the problem?

Depending on what I send, I do different things with the data, save it to flash, save it to the phonebook as a contact, send a reply message to the sender, etc. Everything works fine with the exception of the above error.

Thanks in advance.


#2

RTK Exception 161 has the following description:

#define RTK_EXCPT_BAD_HEAP_RELEASE  161 //<Bad bloc header or footer. Header or footer may have been destroyed

Make sure the buffer you are using to store the characters is greater than 16 bytes, and you aren’t overrunning it.


#3

Thanks Tom for your reply, I am allocating memory based on the length of the text received. So for example I use the following;

X = (ascii*) adl_memGet((received_text));

I am finding that where ever I use this and the received_text is 16 then the modem reboots with RKT 161 or 166. If the received_text is 15 or 17 (or any other number) I do not get a problem.

I have worked around this by doing the following;

if (received_text == 16) X = (ascii*) adl_memGet((received_text+2));
else X = (ascii*) adl_memGet(received_text);

Which works, but it doesn’t fix the problem, a problem I do not fully understand as yet.

Thanks in advance


#4

What firmware version is in use?
Which compiler has been used to compile the program?
Do you check if you actually get the requested pointer from adl_memGet?
If you’re using X as a string with normal string operations, you always should allocate one byte more than the length of the text.

As for the RTK 161, have you tried just restarting the modem to see if it always comes or only comes due to the 16 character text issue you’re having?


#5

firmware version - R7.47.4.201208311102
Compiler - Developer Studio 2.3.0 Build Version 2.3.0.201212051546-R10684

How?

I have not been doing this and by adding a +1 on the adl_memGet (X = (ascii*) adl_memGet((received_text+1))), this works regardless of how many characters I send, 15, 16, 17, etc. So thank you for this suggestion.
Why though, why was this a problem in the first place for only 16 characters?

We tried restarting the modem, it always happens, we tried a different modem (same model) it always happens. What is the problem with 16 characters?

Thanks


#6

If you had problems with 16 characters specifically, then it depends on how you processed the information.

ascii *buffer;
...
buffer=(ascii *)adl_memGet(...);
if (buffer!=NULL)
{
... // safe to work with buffer
}

Personally I have a habit of making sure the pointer points to NULL before doing any memory allocation, and setting it to NULL after releasing the memory.
That way you can always be certain that a NULL check after memory allocation attempt will reveal success or fail.


#7

Thank you very much Tobias.
I now have everything working as i need it to.


#8

So what, eaxctly, was your problem - and how did you correct it :question:

Please share for the benefit of others who may have similar problems…

catb.org/~esr/faqs/smart-que … l#followup


#9

Problem was:

Solution is:


#10

OK - To be more precise, the problem was the lack of NUL termination on your strings;

The crashing was a symptom of this problem.