Hi,
I use a LPC1778 with RTX and RL-TCP library. I am getting ERR_MEM_ALLOC error (sys_error()) after some tcp activity.
The pc send a request of 16 bytes and the card responds with a data frame of 112 bytes and this 10000 times in a row.
After several hundred sending the program crashes. Never in one place.
so I change the memory pool size :
#define MEM_SIZE 2045
by
#define MEM_SIZE 4096
My send function is :
void send_data_param (U8 *mesg, U16 nb) { U8 *sendbuf; if (tcp_get_state(socket_tcp_param) == TCP_STATE_CONNECT) if (tcp_check_send (socket_tcp_param) == __TRUE) { sendbuf = tcp_get_buf(nb); memcpy(sendbuf,mesg,nb); tcp_send(socket_tcp_param, sendbuf, nb); } }
how can I know the memory pool required?
Why the error persists then I doubled his memory pool?
The memory pool is automatically managed by RTX and TCPnet?
how can you know if the memory pool is full?
Anyone a suggestion how to solve this problem?
Thanks. JB
Hi Florian,
thanks for you help,
I tried to secure by calling tsk_lock/tsk_unlock. Like that :
tsk_lock (); sendbuf = tcp_get_buf(nb); tsk_unlock ();
The function tcp_get_buf() uses a memory allocation and it's at this location that the program crashes with the error ERR_MEM_LOCK.
But the problem does not change.
I have synchronised my tasks with a mutex and have not had any problems since. But you will have to wait for the mutex in every function that uses TcpNet. In your case it will be:
os_mut_wait(mutex,0xFFFF); main_TcpNet(); os_mut_release(mutex);
as well as your "send_data_param".
Best Regards, Florian
I have some things similar.
I followed the new method of Keil with new version v4.54 : the event driven TCPnet operation in RTX environment. www.keil.com/.../rlarm_tn_using_evtdriven.htm All process TCP is located in the tcp_main task.
Now it works well.
Thank you all for your help.