Detecting link state

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

Detecting link state

Philipp Burch-2
Hi everyone,

is there a good way to detect if an Ethernet link has been established
when using Ethernut? I see that this has been discussed in the past, but
could not find any outcome:

http://microcontrollers.2385.n7.nabble.com/detecting-an-unplugged-network-cable-td160042.html

Thanks.

Best regards,
Philipp
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Detecting link state

Ole Reinhardt-2
Hi Philipp,

which platform are you using? I implemented a link state detection in
several projects running on the LPC plattform.

But as the code mainly uses PHY communication it should run with any
plattform with external PHY.

Later today I'll have access to the code and can send you an example.

Best regards,

Ole Reinhardt

Am 10.07.2018 um 10:43 schrieb Philipp Burch:

> Hi everyone,
>
> is there a good way to detect if an Ethernet link has been established
> when using Ethernut? I see that this has been discussed in the past, but
> could not find any outcome:
>
> http://microcontrollers.2385.n7.nabble.com/detecting-an-unplugged-network-cable-td160042.html
>
> Thanks.
>
> Best regards,
> Philipp
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>

--
Embedded-IT
Alter Weg 3
57223 Kreuztal
http://www.embedded-it.de

Tel.: +49-177-7420433
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Detecting link state

Philipp Burch-2
Hi Ole,

it's for the TIVA microcontrollers, which have an integrated PHY. But as
far as I remember, it is used the same way as an external standard PHY.

Thanks!

Best regards,
Philipp

On 21.07.2018 13:41, Ole Reinhardt wrote:

> Hi Philipp,
>
> which platform are you using? I implemented a link state detection in
> several projects running on the LPC plattform.
>
> But as the code mainly uses PHY communication it should run with any
> plattform with external PHY.
>
> Later today I'll have access to the code and can send you an example.
>
> Best regards,
>
> Ole Reinhardt
>
> Am 10.07.2018 um 10:43 schrieb Philipp Burch:
>> Hi everyone,
>>
>> is there a good way to detect if an Ethernet link has been established
>> when using Ethernut? I see that this has been discussed in the past, but
>> could not find any outcome:
>>
>> http://microcontrollers.2385.n7.nabble.com/detecting-an-unplugged-network-cable-td160042.html
>>
>> Thanks.
>>
>> Best regards,
>> Philipp
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Detecting link state

Ole Reinhardt-2
Hi Philipp,

here is my link detection code, this should run at least with any common
PHY that uses the NutOS PHY driver.

#include <dev/phy.h>

/*!
 * \brief test if the physical network link is present
 *
 * \param retry      number of retry cycles. Should be one for only a
short test
 * \param retry_wait time to wait between retries. in ms
 *
 * \return 0: link established, -1: no network link
 */
int CheckPhysicalNetworkLink(int retry, int retry_wait)
{
    uint32_t phyval = 0;

    int link_ok = 0;

    while (!link_ok && (retry > 0)) {
        if (NutPhyCtl(PHY_GET_STATUS, &phyval) != 0) {
            link_ok = 0;
        } else {
            if (! ((phyval & PHY_STATUS_HAS_LINK) && (phyval &
PHY_STATUS_AUTONEG_OK))) {
                link_ok = 0;
            } else {
                link_ok = 1;
            }
        }
        if (retry > 0) {
            retry --;
            if ((retry > 0) && (retry_wait > 0)) NutSleep(retry_wait);
        }
    }

    return link_ok ? 0 : -1;
}


Best regards,

Ole


Am 21.07.2018 um 20:08 schrieb Philipp Burch:

> Hi Ole,
>
> it's for the TIVA microcontrollers, which have an integrated PHY. But as
> far as I remember, it is used the same way as an external standard PHY.
>
> Thanks!
>
> Best regards,
> Philipp
>
> On 21.07.2018 13:41, Ole Reinhardt wrote:
>> Hi Philipp,
>>
>> which platform are you using? I implemented a link state detection in
>> several projects running on the LPC plattform.
>>
>> But as the code mainly uses PHY communication it should run with any
>> plattform with external PHY.
>>
>> Later today I'll have access to the code and can send you an example.
>>
>> Best regards,
>>
>> Ole Reinhardt
>>
>> Am 10.07.2018 um 10:43 schrieb Philipp Burch:
>>> Hi everyone,
>>>
>>> is there a good way to detect if an Ethernet link has been established
>>> when using Ethernut? I see that this has been discussed in the past, but
>>> could not find any outcome:
>>>
>>> http://microcontrollers.2385.n7.nabble.com/detecting-an-unplugged-network-cable-td160042.html
>>>
>>> Thanks.
>>>
>>> Best regards,
>>> Philipp
>>> _______________________________________________
>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>

--
Embedded-IT
Alter Weg 3
57223 Kreuztal
http://www.embedded-it.de

Tel.: +49-177-7420433
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Detecting link state

Uwe Bonnes
>>>>> "Ole" == Ole Reinhardt <[hidden email]> writes:

    Ole> Hi Philipp, here is my link detection code, this should run at
    Ole> least with any common PHY that uses the NutOS PHY driver.

Do you have some codes snipplets showing the usage?

It always helps if some of the apps contains an example usage of the API ;-)

Bye
--
Uwe Bonnes                [hidden email]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Detecting link state

Philipp Burch-2
In reply to this post by Ole Reinhardt-2
Hi Ole,

thanks, that should well serve my needs. I had hoped that such
functionality would already be included in the Ethernut tree, but it
doesn't matter that much right now.

Bye,
Philipp

On 22.07.2018 15:53, Ole Reinhardt wrote:

> Hi Philipp,
>
> here is my link detection code, this should run at least with any common
> PHY that uses the NutOS PHY driver.
>
> #include <dev/phy.h>
>
> /*!
>  * \brief test if the physical network link is present
>  *
>  * \param retry      number of retry cycles. Should be one for only a
> short test
>  * \param retry_wait time to wait between retries. in ms
>  *
>  * \return 0: link established, -1: no network link
>  */
> int CheckPhysicalNetworkLink(int retry, int retry_wait)
> {
>     uint32_t phyval = 0;
>
>     int link_ok = 0;
>
>     while (!link_ok && (retry > 0)) {
>         if (NutPhyCtl(PHY_GET_STATUS, &phyval) != 0) {
>             link_ok = 0;
>         } else {
>             if (! ((phyval & PHY_STATUS_HAS_LINK) && (phyval &
> PHY_STATUS_AUTONEG_OK))) {
>                 link_ok = 0;
>             } else {
>                 link_ok = 1;
>             }
>         }
>         if (retry > 0) {
>             retry --;
>             if ((retry > 0) && (retry_wait > 0)) NutSleep(retry_wait);
>         }
>     }
>
>     return link_ok ? 0 : -1;
> }
>
>
> Best regards,
>
> Ole
>
>
> Am 21.07.2018 um 20:08 schrieb Philipp Burch:
>> Hi Ole,
>>
>> it's for the TIVA microcontrollers, which have an integrated PHY. But as
>> far as I remember, it is used the same way as an external standard PHY.
>>
>> Thanks!
>>
>> Best regards,
>> Philipp
>>
>> On 21.07.2018 13:41, Ole Reinhardt wrote:
>>> Hi Philipp,
>>>
>>> which platform are you using? I implemented a link state detection in
>>> several projects running on the LPC plattform.
>>>
>>> But as the code mainly uses PHY communication it should run with any
>>> plattform with external PHY.
>>>
>>> Later today I'll have access to the code and can send you an example.
>>>
>>> Best regards,
>>>
>>> Ole Reinhardt
>>>
>>> Am 10.07.2018 um 10:43 schrieb Philipp Burch:
>>>> Hi everyone,
>>>>
>>>> is there a good way to detect if an Ethernet link has been established
>>>> when using Ethernut? I see that this has been discussed in the past, but
>>>> could not find any outcome:
>>>>
>>>> http://microcontrollers.2385.n7.nabble.com/detecting-an-unplugged-network-cable-td160042.html
>>>>
>>>> Thanks.
>>>>
>>>> Best regards,
>>>> Philipp
>>>> _______________________________________________
>>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>>
>>>
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Detecting link state

Philipp Burch-2
In reply to this post by Ole Reinhardt-2
Hi Ole,

I just integrated the function in my code and it works like a charm :)

Many thanks and best regards,
Philipp

On 22.07.2018 15:53, Ole Reinhardt wrote:

> Hi Philipp,
>
> here is my link detection code, this should run at least with any common
> PHY that uses the NutOS PHY driver.
>
> #include <dev/phy.h>
>
> /*!
>  * \brief test if the physical network link is present
>  *
>  * \param retry      number of retry cycles. Should be one for only a
> short test
>  * \param retry_wait time to wait between retries. in ms
>  *
>  * \return 0: link established, -1: no network link
>  */
> int CheckPhysicalNetworkLink(int retry, int retry_wait)
> {
>     uint32_t phyval = 0;
>
>     int link_ok = 0;
>
>     while (!link_ok && (retry > 0)) {
>         if (NutPhyCtl(PHY_GET_STATUS, &phyval) != 0) {
>             link_ok = 0;
>         } else {
>             if (! ((phyval & PHY_STATUS_HAS_LINK) && (phyval &
> PHY_STATUS_AUTONEG_OK))) {
>                 link_ok = 0;
>             } else {
>                 link_ok = 1;
>             }
>         }
>         if (retry > 0) {
>             retry --;
>             if ((retry > 0) && (retry_wait > 0)) NutSleep(retry_wait);
>         }
>     }
>
>     return link_ok ? 0 : -1;
> }
>
>
> Best regards,
>
> Ole
>
>
> Am 21.07.2018 um 20:08 schrieb Philipp Burch:
>> Hi Ole,
>>
>> it's for the TIVA microcontrollers, which have an integrated PHY. But as
>> far as I remember, it is used the same way as an external standard PHY.
>>
>> Thanks!
>>
>> Best regards,
>> Philipp
>>
>> On 21.07.2018 13:41, Ole Reinhardt wrote:
>>> Hi Philipp,
>>>
>>> which platform are you using? I implemented a link state detection in
>>> several projects running on the LPC plattform.
>>>
>>> But as the code mainly uses PHY communication it should run with any
>>> plattform with external PHY.
>>>
>>> Later today I'll have access to the code and can send you an example.
>>>
>>> Best regards,
>>>
>>> Ole Reinhardt
>>>
>>> Am 10.07.2018 um 10:43 schrieb Philipp Burch:
>>>> Hi everyone,
>>>>
>>>> is there a good way to detect if an Ethernet link has been established
>>>> when using Ethernut? I see that this has been discussed in the past, but
>>>> could not find any outcome:
>>>>
>>>> http://microcontrollers.2385.n7.nabble.com/detecting-an-unplugged-network-cable-td160042.html
>>>>
>>>> Thanks.
>>>>
>>>> Best regards,
>>>> Philipp
>>>> _______________________________________________
>>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>>
>>>
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion