Problem with adl_memRelease() after ed_SendDataExt()


#1

Hi,

We are trying to send data to a Webserver using TCP Socket Service.

The program crashes when the memory allocated for data to send is released immediately after returning from the ed_SendDataExt() call. Will the stack not copy the data to an internal buffer and send it from there. How long do I need to reserve the memory - when may I release it in this case???

void socket_request( u16 maxlen, TeDHandle ID )
{
   ascii *text = (ascii *)NULL;
...
            text = (ascii *)adl_memGet( maxlen );
            // [<<<filling in data from flash IDs>>>]
...
      x = ed_SendDataExt( text, maxlen, FALSE, ED_ID_TCPSOCKET_1+ID );
...
         adl_memRelease( text );
}

If we comment out the adl_memRelease call, the program won’t crash…
But then we will have no memory left pretty soon ;-(

Is this the wrong way of communicating data to the stack? We have to send big chunks of data (24-48kBytes), so we really can’t have all of it allocated at the same time…

Any recommendations?

Thanks!!

Best Regards,
Jan

P.S. we are using the ADS compiler, 6.51 Firmware, Open AT 3.02, and the edLib that shipped with OpenAT 3.02. (The RTE program does not(!) crash; gcc does not compile the project (see other post))


#2

Hi [color=blue]jan,

Will it crash even if you do not send big chunks of data (what happens with one single byte)?

/Snoooze


#3

Hi Jan,

Have you tried releasing the memory the next time socket_request is called?

Kind regards,
Mike


#4

Hi,

I just successfully sent about 125 bytes with the dynamic allocation above. It worked just fine… Hmmmm… Need to do more tests…

Thanks for your answers!

Jan