ioLibrary_Driver icon indicating copy to clipboard operation
ioLibrary_Driver copied to clipboard

socket.c infinite loop

Open Tomsiik opened this issue 5 years ago • 3 comments

In functions socket() and close() is an infinite loop for checking Sn_CR register when W5100 not responds or it not connected to MCU.

while( getSn_CR(sn) );

I solved it by adding a check of repeat attempts.

uint8_t repeat = 0; do { if (repeat > 10) { return SOCKERR_TIMEOUT; } repeat++; } while (getSn_CR(sn));

Tomsiik avatar Jan 08 '20 10:01 Tomsiik

这里确实是个问题,RT-THread的wiz软件包基于V1.0.3版本,新建的socke(前端无路由器,直接接在交换机上)居然不是closed状态而是0x22,造成直接-1返回造成一直无法通讯。大家有这个问题可以讨论QQ2730122869

zhigangbox avatar Sep 26 '20 02:09 zhigangbox

Hi everybody,

@Tomsiik is right. infinite loop is a no go in bare metal programming. @zhigangbox Could you please write in englisch?

Best regards Hannes

hp-beko avatar Sep 26 '20 08:09 hp-beko

I actually stuck in infinite loop in W5300 with 28335, and solved it by modifying the following:

https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/W5300/w5300.h#L1925

#define getSn_CR(sn) \
   ((uint8_t)WIZCHIP_READ(Sn_CR(sn)) & 0xFF)

I think it occurred because 28335 does not have a 1byte data type. (getSn_CR() returned 0x0100 before modification.)

If it's the same cause, try fixing it like this

https://github.com/Wiznet/ioLibrary_Driver/blob/master/Ethernet/W5100/w5100.h#L1431

#define getSn_SR(sn) \
		WIZCHIP_READ(Sn_SR(sn) & 0xFF)

ApmTIMEmqA avatar Feb 02 '21 04:02 ApmTIMEmqA