Re: [lwip-users] LWIP v2.0.0 hangs without Phy

2017-10-13 Thread Stephen Cowell
We use LWIP l.4.l with RAW (no OS).  I had to query my PHY's 
control/status register to determine the link status... I did this from 
main loop (non-interrupt) time.  There is also a protocol for requesting 
direct PHY access, depending on the uP's interface.  Huge PITA, but 
entirely necessary for our application.  Nothing about LWIP was 
involved.  If you're using OS you'll have to suspend the LWIP thread(s) 
to do this.


--
Stephen Cowell
Project Manager/Engineer
Plasmability LLC
www.plasmability.com

On 10/13/2017 6:48 AM, Gustavo Costa TAP wrote:

Hi Jens,

thank you for your colaboration. Is it possible that you share if me 
your fix? I am trying not to reinvent the wheel.


As I said to Simon, I am trying to use the LWIP_NETIF_LINK_CALLBACK 
and LWIP_NETIF_STATUS_CALLBACK functions to keep track of the Phy 
Link, but these functions never gets called, even if I disconnect the 
cable.


My demicode is as below:

*#if LWIP_NETIF_STATUS_CALLBACK
*
*void status_callback(void) {*
*LED_BLUE_TOGGLE();*
*}*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
*void link_callback(void) {*
*if (netif_is_link_up(_netif0)) {  //DES link up blink fast*
*LED_GREEN_ON();*
*dhcp_start(_netif0);*
*netif_set_up(_netif0);*
*} else {*
*LED_GREEN_OFF();*
*dhcp_stop(_netif0);*
*netif_set_down(_netif0);*
*}*
*}*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*

---

*PRINTF("TCP/IP initializing...\r\n");*
*tcpip_init(NULL, NULL);*
*PRINTF("TCP/IP initialized.\r\n");*
*
*
*xSemaphoreENET = xSemaphoreCreateBinary();*
*
*
*while (netif_add(_netif0, _netif0_ipaddr, _netif0_netmask,*
*_netif0_gw,*
*NULL, ethernetif_init, tcpip_input) == NULL) {*
*
*
*netif_remove(_netif0);*
*vTaskDelay(1000 / portTICK_PERIOD_MS);*
*}*

*WDOG_Refresh(WDOG);*
*
*
*netif_set_default(_netif0);*
*netif_set_up(_netif0);*
*
*
*#if LWIP_NETIF_STATUS_CALLBACK*
*netif_set_status_callback(_netif0, status_callback);*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
*netif_set_link_callback(_netif0, link_callback);*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*
*
*
*err = dhcp_start(_netif0);*
*
*
---

Thank you very much.

Best Regards,



*Gustavo Costa*
/Engenheiro Eletricista/

/Departamento de P/

/Tap Eletro Sistemas Ltda./

/(31) 3395-1180/9 8769-8593 /

/gustavo.co...@tapeletro.com /










2017-10-12 12:24 GMT-03:00 Jens Nielsen >:


Yes I fixed this particular problem in a driver recently, it was
waiting for autonegotiation to complete. 6th parameter to
netif_add is a function pointer to an init function in your code,
that's where you'll find your bug.

On 2017-10-12 10:33, Simon Goldschmidt wrote:

When the "netif_add" api is called without the cable being actually plugged 
the function just hangs and my wdog barks.

Now this can't be an lwIP bug: lwIP knows nothing of phys. That is part of 
your netif driver, which probably needs fixing.




___
lwip-users mailing list
lwip-users@nongnu.org 
https://lists.nongnu.org/mailman/listinfo/lwip-users





___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] LWIP v2.0.0 hangs without Phy

2017-10-13 Thread Jens Nielsen

Hi Gustavo

You're missing one very important point, that is below lwip is a part 
that you are responsible for, this is the "driver" and it is not a part 
of lwip. This part handles among other things the link status and should 
notify lwip if it changes. Your callbacks are probably not called 
because your driver doesn't notify lwip of the link status.


All your issues are in the driver part and there is nothing anyone here 
can do about it, unless maybe if you share your driver or at least let 
us know which one you're using you can get a kind soul to have a look at 
it. I'm guessing though that you got your driver packaged together with 
lwip from a third party, that would be a better place to ask for help.


Best regards
Jens

On 2017-10-13 13:48, Gustavo Costa TAP wrote:

Hi Jens,

thank you for your colaboration. Is it possible that you share if me 
your fix? I am trying not to reinvent the wheel.


As I said to Simon, I am trying to use the LWIP_NETIF_LINK_CALLBACK 
and LWIP_NETIF_STATUS_CALLBACK functions to keep track of the Phy 
Link, but these functions never gets called, even if I disconnect the 
cable.


My demicode is as below:

*#if LWIP_NETIF_STATUS_CALLBACK
*
*void status_callback(void) {*
*LED_BLUE_TOGGLE();*
*}*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
*void link_callback(void) {*
*if (netif_is_link_up(_netif0)) {  //DES link up blink fast*
*LED_GREEN_ON();*
*dhcp_start(_netif0);*
*netif_set_up(_netif0);*
*} else {*
*LED_GREEN_OFF();*
*dhcp_stop(_netif0);*
*netif_set_down(_netif0);*
*}*
*}*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*

---

*PRINTF("TCP/IP initializing...\r\n");*
*tcpip_init(NULL, NULL);*
*PRINTF("TCP/IP initialized.\r\n");*
*
*
*xSemaphoreENET = xSemaphoreCreateBinary();*
*
*
*while (netif_add(_netif0, _netif0_ipaddr, _netif0_netmask,*
*_netif0_gw,*
*NULL, ethernetif_init, tcpip_input) == NULL) {*
*
*
*netif_remove(_netif0);*
*vTaskDelay(1000 / portTICK_PERIOD_MS);*
*}*

*WDOG_Refresh(WDOG);*
*
*
*netif_set_default(_netif0);*
*netif_set_up(_netif0);*
*
*
*#if LWIP_NETIF_STATUS_CALLBACK*
*netif_set_status_callback(_netif0, status_callback);*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
*netif_set_link_callback(_netif0, link_callback);*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*
*
*
*err = dhcp_start(_netif0);*
*
*
---

Thank you very much.

Best Regards,



*Gustavo Costa*
/Engenheiro Eletricista/

/Departamento de P/

/Tap Eletro Sistemas Ltda./

/(31) 3395-1180/9 8769-8593 /

/gustavo.co...@tapeletro.com /










2017-10-12 12:24 GMT-03:00 Jens Nielsen >:


Yes I fixed this particular problem in a driver recently, it was
waiting for autonegotiation to complete. 6th parameter to
netif_add is a function pointer to an init function in your code,
that's where you'll find your bug.

On 2017-10-12 10:33, Simon Goldschmidt wrote:

When the "netif_add" api is called without the cable being actually plugged 
the function just hangs and my wdog barks.

Now this can't be an lwIP bug: lwIP knows nothing of phys. That is part of 
your netif driver, which probably needs fixing.




___
lwip-users mailing list
lwip-users@nongnu.org 
https://lists.nongnu.org/mailman/listinfo/lwip-users





___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Pbuf_cat and pbuf_free question

2017-10-13 Thread Sergio R. Caprile
Well, I'm no expert on whatever you are trying to do with this, so take 
it with a grain of salt.


you alloc a pbuf (1)
then you concatenate to the tail of another pbuf (0)
now (1) does not exist anymore as a lonely pbuf but is attached to (0), 
all that exists now is (0).

Somehow, you are supposed to have alloced (0), because it exists, right ?
You then send (0)
You have to free (0), not (1), but (0), unless you plan to use it again, 
but in that case, you won't allocate another "(1)", will you ? No, you 
won't.


If this does not fit your line of thought, perhaps you need to use 
pbuf_chain() or develop another strategy for your application code.


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] LWIP v2.0.0 hangs without Phy

2017-10-13 Thread Gustavo Costa TAP
Hi Jens,

thank you for your colaboration. Is it possible that you share if me your
fix? I am trying not to reinvent the wheel.

As I said to Simon, I am trying to use the LWIP_NETIF_LINK_CALLBACK
and LWIP_NETIF_STATUS_CALLBACK functions to keep track of the Phy Link, but
these functions never gets called, even if I disconnect the cable.

My demicode is as below:


*#if LWIP_NETIF_STATUS_CALLBACK*
*void status_callback(void) {*
* LED_BLUE_TOGGLE();*
*}*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
*void link_callback(void) {*
* if (netif_is_link_up(_netif0)) {  //DES link up blink fast*
* LED_GREEN_ON();*
* dhcp_start(_netif0);*
* netif_set_up(_netif0);*
* } else {*
* LED_GREEN_OFF();*
* dhcp_stop(_netif0);*
* netif_set_down(_netif0);*
* }*
*}*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*

---

*PRINTF("TCP/IP initializing...\r\n");*
* tcpip_init(NULL, NULL);*
* PRINTF("TCP/IP initialized.\r\n");*

* xSemaphoreENET = xSemaphoreCreateBinary();*

* while (netif_add(_netif0, _netif0_ipaddr, _netif0_netmask,*
* _netif0_gw,*
* NULL, ethernetif_init, tcpip_input) == NULL) {*

* netif_remove(_netif0);*
* vTaskDelay(1000 / portTICK_PERIOD_MS);*
* }*

* WDOG_Refresh(WDOG);*

* netif_set_default(_netif0);*
* netif_set_up(_netif0);*

*#if LWIP_NETIF_STATUS_CALLBACK*
* netif_set_status_callback(_netif0, status_callback);*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
* netif_set_link_callback(_netif0, link_callback);*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*

* err = dhcp_start(_netif0);*


---

Thank you very much.

Best Regards,





*Gustavo Costa*
*Engenheiro Eletricista*

*Departamento de P*

*Tap Eletro Sistemas Ltda.*

*(31) 3395-1180/9 8769-8593 *

*gustavo.co...@tapeletro.com *




2017-10-12 12:24 GMT-03:00 Jens Nielsen :

> Yes I fixed this particular problem in a driver recently, it was waiting
> for autonegotiation to complete. 6th parameter to netif_add is a function
> pointer to an init function in your code, that's where you'll find your bug.
>
> On 2017-10-12 10:33, Simon Goldschmidt wrote:
>
> When the "netif_add" api is called without the cable being actually plugged 
> the function just hangs and my wdog barks.
>
> Now this can't be an lwIP bug: lwIP knows nothing of phys. That is part of 
> your netif driver, which probably needs fixing.
>
>
>
>
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] LWIP v2.0.0 hangs without Phy

2017-10-13 Thread Gustavo Costa TAP
*> Have you reported a problem? If not why are you surprised it's not
fixed?*
I'm Sorry if I sounded harsh or pretencious, it was not my intention. I did
not have reported this issue because as far as I could see it is well known
by the community.

*> Now this can't be an lwIP bug: lwIP knows nothing of phys. That is part
of your netif driver, which probably needs fixing.*
That's not necessarily true, during DHCP and AutoIP routines (which are
part of lwIP Stack) there is a need to know about the Phy Link status, so
when the network has changed it can take action. Anyway, my problem is a
bit bigger, I want to monitor the Phy Link using
the  LWIP_NETIF_LINK_CALLBACK, but, inspite of my code is setting this
function, it never gets called. See the demicode below:




*#if LWIP_NETIF_STATUS_CALLBACK*
*void status_callback(void) {*
* LED_BLUE_TOGGLE();*
*}*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
*void link_callback(void) {*
* if (netif_is_link_up(_netif0)) {  //DES link up blink fast*
* LED_GREEN_ON();*
* dhcp_start(_netif0);*
* netif_set_up(_netif0);*
* } else {*
* LED_GREEN_OFF();*
* dhcp_stop(_netif0);*
* netif_set_down(_netif0);*
* }*
*}*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*

---

*PRINTF("TCP/IP initializing...\r\n");*
* tcpip_init(NULL, NULL);*
* PRINTF("TCP/IP initialized.\r\n");*

* xSemaphoreENET = xSemaphoreCreateBinary();*

* while (netif_add(_netif0, _netif0_ipaddr, _netif0_netmask,*
* _netif0_gw,*
* NULL, ethernetif_init, tcpip_input) == NULL) {*

* netif_remove(_netif0);*
* vTaskDelay(1000 / portTICK_PERIOD_MS);*
* }*

* WDOG_Refresh(WDOG);*

* netif_set_default(_netif0);*
* netif_set_up(_netif0);*

*#if LWIP_NETIF_STATUS_CALLBACK*
* netif_set_status_callback(_netif0, status_callback);*
*#endif /* LWIP_NETIF_STATUS_CALLBACK */*
*#if LWIP_NETIF_LINK_CALLBACK*
* netif_set_link_callback(_netif0, link_callback);*
*#endif /* LWIP_NETIF_LINK_CALLBACK */*

* err = dhcp_start(_netif0);*

---

I've already modified the lwIP so I can olny add a new network if there's a
Phy Link. Now I need to continuously act over any Phy changes. As I could
see the link_call was the better way, but it never gets called.

Any thoughts abou it?

*> What are deeper layers? You need get someone fix your netif driver.*
By deeper layers I meant the lwIP stack itself. I need a fix that can be
done in my own code, if possible.

Thank you.

Best Regards,




*Gustavo Costa*
*Engenheiro Eletricista*

*Departamento de P*

*Tap Eletro Sistemas Ltda.*

*(31) 3395-1180/9 8769-8593 *

*gustavo.co...@tapeletro.com *




2017-10-12 5:33 GMT-03:00 Simon Goldschmidt :

> Gustavo Costa TAP wrote:
> > I've recently upgraded my project to lwIP v2.0.0, but to my surprise a
> problem was not fixed.
>
> Have you reported a problem? If not why are you surprised it's not fixed?
>
> > When the "netif_add" api is called without the cable being actually
> plugged the function just hangs and my wdog barks.
>
> Now this can't be an lwIP bug: lwIP knows nothing of phys. That is part of
> your netif driver, which probably needs fixing.
>
> > Any work arrounds for this issue without having to modify the deeper
> layers of the stack?
>
> What are deeper layers? You need get someone fix your netif driver.
>
> Simon
>
> ___
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users