when testing exceptional conditions with the Ethernet communication on a Zynq I found out a small inconvenience.
The tested condition is: Pull the cable during an existing connection and plug it in after a while.
In 'NetworkInterface.c' inside prvEMACHandlerTask() it is recognized after 15 seconds, that the
cable is pulled.
The debug-message "prvEMACHandlerTask: PHY LS now 0" is written and the check-timeout is set to
a short time, 1 second.
When the cable is plugged in again and a packet is received before the ulPHYLinkStatus is read,
the timeout will be set to 15 seconds. And if then within 15 seconds a new packet is received, the
link-status will never be reset again to the correct value.
So I added a small piece of code at the place where a packet was received to solve this nasty situation:
if( xResult > 0 )
/* A packet was received. No need to check for the PHY status now,
but set a timer to check it later on. /
vTaskSetTimeOutState( &xPhyTime );
xPhyRemTime = pdMSTOTICKS( PHYLSHIGHCHECKTIME_MS );
xResult = 0;
/ If ulPHYLinkStatus was set to off previously, the status has to be checked again.
* Otherwise ulPHYLinkStatus would never be set to on, if a packet is received during timeout.
if( ( ulPHYLinkStatus & BMSRLINKSTATUS ) == 0 )
xStatus = ulReadMDIO( PHYREG01_BMSR );
if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != ( xStatus & BMSR_LINK_STATUS ) )
ulPHYLinkStatus = xStatus;
FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) );
Maybe that this problem occurs only under special conditions, which I have, and maybe that a better
code could be used, but as a fast change the addition helped.
The link off is seen after 15 seconds, and the link on is recognized immediately.
Hi Johannes, I'm sorry to discover that the current release of
portable/NetworkInterface/Zynq/NetworkInterface.c still have this problem.
Here you find an alternative solution for the problem that you encountered.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.