Hello,
it’s been reproduced quite many times that connect() function does not return SOCKERR_TIMEOUT error even though it should do it.
the func is stuck in the section of:
Well, as I said the problem is that the connect procedure fails, as socket did not get to SOCK_ESTABLISHED state.
I expect the w5500 to return timeout error upon checking the proper register getSn_IR(sn) & Sn_IR_TIMEOUT
For some reason w5500 does not identify that timeout has passed, though the timeout register is set to 15000 (the timeout value is read from the w5500 using ctlnetwork(CN_GET_TIMEOUT,...)
As NO timeout occurred - the loop is endless.
Can you figure out why w5500 does not get into timeout?
Hi~ avivf
I tested our driver.I’m having a bit of trouble with our driver and I modified connect() function in socket.c
The conditional statement added a end conditions(if(getSn_SR(sn) == SOCK_CLOSED)).
It have to confirm the Sn_SR value if SOCK_CLOSED or not.
the fix is correct, though it still misses the case where the socket is disconnected (and not closed).
This is actually the case I was encountered.
I fixed the bug by the following code (which I think needs to be merged with your fix):
while(getSn_SR(sn) != SOCK_ESTABLISHED)
{
/**
* Upon server sending a disconnection msg - getSn_IR(sn) returns "0x2" ( = Sn_IR_DISCON) for ever,
* and no time is generated by the w5500.
* This leads connect() func to be stuck in endless loop, as NO timeout is received by getSn_IR(sn).
*
* The fix is adding a Sn_IR_DISCON condition, in order to exit loop.
*/
if (getSn_IR(sn) & Sn_IR_TIMEOUT)
{
setSn_IR(sn, Sn_IR_TIMEOUT);
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
setSUBR((uint8_t*)"\x00\x00\x00\x00");
#endif
return SOCKERR_TIMEOUT;
}
else if (getSn_IR(sn) & Sn_IR_DISCON)
{
setSn_IR(sn, Sn_IR_DISCON);
return (SOCKERR_SOCKSTATUS);
}
}