LwIP issue on TMS570

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

LwIP issue on TMS570

Thomas Drage

Hi,

I have an implementation using lwIP on a TI TMS570LC4357 LaunchPad which exhibits a strange problem, and I'm hoping someone can provide some insight or tips :) 

1. The first message received calls tcp_recv instantly and is processed.

2. The second message might take 5 - 10s until tcp_recv is called.

3. The third etc. can take a very long time (or forever) between sending the data to the TMS570 and the getting callback.

My code is based on this echo-server: https://github.com/dreamcat4/lwip/blob/master/contrib/apps/tcpecho_raw/echo.c

Note that in the initial implementation of the echo server this problem doesn't occur, however, my implementation separates reading and writing (e.g. it is not an echo server anymore). So on reading, the message is parsed/stored, then instead of sending it back the pbuf is freed and tcp_recved called. If I insert a tcp_write after I have stored the message and just send some random (constant) string back before I deallocate the pbuf - everyone works once more (there is no delay on receiving subsequent packets). I struggle to explain why this is the case. Does anyone see a problem with the echo server code that would make it stop working if it's not being asked to send data?

It seems almost a little like this: https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/675413?RM46L852-Modbus-Over-TCP-IP-control-hand-in-TCP-Rx-interrupt 

I have attached my code. Note that in the function cont_read, if I remove the line "tcp_write(tpcb, "ACK", 3, 1);", I start getting the extreme delays before receiving subsequent messages.  

Thanks,

Thomas Drage


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

echo_mod.c (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: LwIP issue on TMS570

goldsimon@gmx.de
Am 16.04.2019 um 17:23 schrieb Thomas Drage:

> Hi,
>
> I have an implementation using lwIP on a TI TMS570LC4357 LaunchPad which
> exhibits a strange problem, and I'm hoping someone can provide some
> insight or tips :)
>
> 1. The first message received calls tcp_recv instantly and is processed.
>
> 2. The second message might take 5 - 10s until tcp_recv is called.
>
> 3. The third etc. can take a very long time (or forever) between sending
> the data to the TMS570 and the getting callback.

That almost sounds like the driver is somehow missing RX packets? A
common bug was/is that the driver only receives one packet per ISR call,
when (due to code runtime) multiple packets can be received before the
ISR returns.

>
> My code is based on this echo-server:
> https://github.com/dreamcat4/lwip/blob/master/contrib/apps/tcpecho_raw/echo.c

Why use a copy if you can use the original?

https://github.com/lwip-tcpip/lwip/

Regards,
Simion

>
> Note that in the initial implementation of the echo server this problem
> doesn't occur, however, my implementation separates reading and writing
> (e.g. it is not an echo server anymore). So on reading, the message is
> parsed/stored, then instead of sending it back the pbuf is freed and
> tcp_recved called. If I insert a tcp_write after I have stored the
> message and just send some random (constant) string back before I
> deallocate the pbuf - everyone works once more (there is no delay on
> receiving subsequent packets). I struggle to explain why this is the
> case. Does anyone see a problem with the echo server code that would
> make it stop working if it's not being asked to send data?
>
> It seems almost a little like this:
> https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/675413?RM46L852-Modbus-Over-TCP-IP-control-hand-in-TCP-Rx-interrupt
>
>
> I have attached my code. Note that in the function cont_read, if I
> remove the line "tcp_write(tpcb, "ACK", 3, 1);", I start getting the
> extreme delays before receiving subsequent messages.
>
> Thanks,
>
> Thomas Drage
>


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: LwIP issue on TMS570

Thomas Drage
In reply to this post by Thomas Drage
Thanks Simon,

The distribution I'm using is actually here:

Is there a workaround to that bug if it is the case that I see? I think my code is pretty quick and data rate pretty slow (at this stage I'm typing the messages into telnet)

Cheers,
Thomas 


----------------------------------------------------------------------

Message: 1
Date: Tue, 16 Apr 2019 21:26:20 +0200
From: "[hidden email]" <[hidden email]>
To: Mailing list for lwIP users <[hidden email]>
Subject: Re: [lwip-users] LwIP issue on TMS570
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=utf-8; format=flowed

Am 16.04.2019 um 17:23 schrieb Thomas Drage:
> Hi,
>
> I have an implementation using lwIP on a TI TMS570LC4357 LaunchPad which
> exhibits a strange problem, and I'm hoping someone can provide some
> insight or tips :)
>
> 1. The first message received calls tcp_recv instantly and is processed.
>
> 2. The second message might take 5 - 10s until tcp_recv is called.
>
> 3. The third etc. can take a very long time (or forever) between sending
> the data to the TMS570 and the getting callback.

That almost sounds like the driver is somehow missing RX packets? A
common bug was/is that the driver only receives one packet per ISR call,
when (due to code runtime) multiple packets can be received before the
ISR returns.

>
> My code is based on this echo-server:
> https://github.com/dreamcat4/lwip/blob/master/contrib/apps/tcpecho_raw/echo.c

Why use a copy if you can use the original?

https://github.com/lwip-tcpip/lwip/

Regards,
Simion

>
> Note that in the initial implementation of the echo server this problem
> doesn't occur, however, my implementation separates reading and writing
> (e.g. it is not an echo server anymore). So on reading, the message is
> parsed/stored, then instead of sending it back the pbuf is freed and
> tcp_recved called. If I insert a tcp_write after I have stored the
> message and just send some random (constant) string back before I
> deallocate the pbuf - everyone works once more (there is no delay on
> receiving subsequent packets). I struggle to explain why this is the
> case. Does anyone see a problem with the echo server code that would
> make it stop working if it's not being asked to send data?
>
> It seems almost a little like this:
> https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/675413?RM46L852-Modbus-Over-TCP-IP-control-hand-in-TCP-Rx-interrupt
>
>
> I have attached my code. Note that in the function cont_read, if I
> remove the line "tcp_write(tpcb, "ACK", 3, 1);", I start getting the
> extreme delays before receiving subsequent messages.
>
> Thanks,
>
> Thomas Drage
>



_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users