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
I updated the file : "NET_CONFIG.c" in version v5.00 and the error has changed.
Now, the error is "ERR_MEM_LOCK".
when I use the TCP debug, it displays me: "Alloc, recursive call". I do not use recursive function or task. I'm just simple exchanges of TCP.
does this mean?
thank you for your help. JB
I'm currently experiencing the same problem. The system runs well for a couple of hours before it crashes. I am using only UDP Transfer, but I am sending data from two different tasks. Any call to alloc and free is secured by calling tsk_lock/tsk_unlock. Is there a list of functions from the TcpLib which are not thread safe? Is there any more documentation on this error than what is written in the source code?
I am now using MDK-ARM Professional 4.53.
"Is there a list of functions from the TcpLib which are not thread safe?"
It's more a case of saying none are unless explicitly stated otherwise:
Functions are not reentrant. This means they must not be interrupted and called again from another task. All TCPnet-related functionality should be collected in a single networking task.
To be found at:
www.keil.com/.../rlarm_tn_using_withkernel.htm
DJR
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.
Hi IB Shy,
I did a debug trace with a UlinkPro of my program.
it goes in the function tcp_get_buf(), and in this function, call it alloc_mem() and after sys_error(). I see no call for another task or interrupt.
I do not understand this error?
It isn't enough that you have one thread with locks - are you sure that not another thread (without locks) have already called any of the non-reentrant functions?
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.