lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Is this a memory fragmentation problem


From: Keith Rubow
Subject: Re: [lwip-users] Is this a memory fragmentation problem
Date: Fri, 18 May 2018 10:28:21 -0700
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

I'll try to answer your questions. No, we haven't talked about this problem.
Yes, all lwip RAW API functions are being called from the same context (main loop). Nothing called from interrupt. My driver was written by myself, not vendor supplied. It seems to work well. It is not interrupt driven, it is polled. Data throughput rate is not an issue for me. Yes, one port is a modbus slave (up to 5 connections). The other port is a telnet (or raw TCP/IP) user interface. I use Teraterm to talk to my device on the user interface port. I can both Rx and Tx fine for hours and hours on end. I have some modbus test software on my PC polling modbus data every 1 or 2 seconds. I can do tens of thousands of polls before my system gets into this strange failure mode where it can't send data because tcp_write() starts returning ERR_MEM. I have a tcp_sent() callback, but it does nothing except for return ERR_OK. I always check tcp_sndbuf() before tcp_write(), and wait for enough free memory before I send anything. Does the tcp_sent() callback need to do anything else? Do I even need it if I always check tcp_sndbuf() before calling tcp_write()? Yes, all my sent data is copied into the memory allocated from the pool defined by MEM_SIZE. I'm not sure if my error handling in tcp_recv() callback is correct. If the callback is called with a non-zero err, I call pbuf_free(p) if p was not NULL, and then return err. Do I need to call tcp_recved() (or anything else) when handling an error in the tcp_recv() callback? Should I close the connection if there is ever any error in the receive callback?

I am going to insert some diagnostics the tell me if I am ever getting an err condition in my receive callbacks. Then my system will have to run (maybe the rest of the day) before it fails. I'll post more information when I have anything to report.

Keith Rubow


On 5/18/2018 6:35 AM, Sergio R. Caprile wrote:
First things first.
Maybe we've already talked about this, but I don't remember everyone in
the list...
Are you calling all lwIP RAW API functions from the same context ?
Either main loop or interrupts but only one of them and always the same one.
Did you run a known-good application long enough in order to make sure
your driver and your port are OK ? Yes, vendor provided too, and those
the most.

Now, I assume you are a modbus slave (TCP server) since you said you
were listening.
Since you say you can't tx, I'll assume you are rx'ing (you see the poll
but you can't answer)
Do you have proper tcp_sent() callbacks ? I don't know if this could
lead to a situation like yours, though.
Are you allocing memory ? tx memory is taken as PBUF_RAM

Yes, what you describe looks weird.

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]