lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] RAW TCP client gets terminated


From: address@hidden
Subject: Re: [lwip-users] RAW TCP client gets terminated
Date: Mon, 16 Mar 2020 19:54:48 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

Am 16.03.2020 um 17:42 schrieb Jonas97:
> Hi Hugh,
>
> I did not find any specific documentation on the way sys_now() should be
> implemented.

For things like this, improved documentation is always welcome. Plus it
should be easy to provide it for everyone...

> After debugging I noticed that sys_check_timeouts was using following macro:
>
> /* Check if timer's expiry time is greater than time and care about u32_t
> wraparounds */
> #define TIME_LESS_THAN(t, compare_to) ( (((u32_t)((t)-(compare_to))) >
> LWIP_MAX_TIMEOUT) ? 1 : 0 )
>
> So I suspect that the timer should run all the way to the unsigned 32 bit
> wraparound point. This is only hit after 49 days so I didn't dig deeper as
> my application doesn't run that long.

Yes, it should just continue. And yes, it's hard to test since this is a
purely port-provided function.

Regards,
Simon

>
> The problem was that the ms function for my microcontroller was wrapping
> around after 71583 so instead of hitting 71584 it would start at zero again.
>
> Below is my quick and dirty fix for this which might contain future bugs, is
> gcc specific and also specific to the 71583 wrap around point. Feedback
> always appreciated.
>
> u32_t sys_now( void )
> {
>     static uint32_t ms = 0;
>     static uint32_t lastMs = 0;
>
>     uint32_t newMs = cpu_cy_2_ms( Get_sys_count(), sysclk_get_cpu_hz() );
>     uint32_t diffMs;
>
>     if( newMs < lastMs )
>     {
>         diffMs = ( newMs + 4294895712 ) - ( lastMs + 4294895712 );
>         diffMs -= 4294895712;
>     }
>     else
>     {
>         diffMs = newMs - lastMs;
>     }
>
>     lastMs = newMs;
>     ms += diffMs;
>
>     return ms;
> }
>
>
>
>
> --
> Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html
>
> _______________________________________________
> 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]