.
Fork of WIZnet_Library by
Diff: WIZnetInterface/WIZnet/W5500.cpp
- Revision:
- 4:37a5586c4f64
- Parent:
- 2:c2eb7a08d7e6
- Child:
- 6:ca8405b9564d
--- a/WIZnetInterface/WIZnet/W5500.cpp Mon Jul 21 05:35:40 2014 +0000 +++ b/WIZnetInterface/WIZnet/W5500.cpp Wed Aug 20 02:17:02 2014 +0000 @@ -189,7 +189,15 @@ t.reset(); t.start(); while(1) { - int size = sreg<uint16_t>(socket, Sn_RX_RSR); + //int size = sreg<uint16_t>(socket, Sn_RX_RSR); + // during the reading Sn_RX_RXR, it has the possible change of this register. + // so read twice and get same value then use size information. + int size, size2; + do { + size = sreg<uint16_t>(socket, Sn_RX_RSR); + size2 = sreg<uint16_t>(socket, Sn_RX_RSR); + } while (size != size2); + if (size > req_size) { return size; } @@ -209,7 +217,15 @@ t.reset(); t.start(); while(1) { - int size = sreg<uint16_t>(socket, Sn_TX_FSR); + //int size = sreg<uint16_t>(socket, Sn_TX_FSR); + // during the reading Sn_TX_FSR, it has the possible change of this register. + // so read twice and get same value then use size information. + int size, size2; + do { + size = sreg<uint16_t>(socket, Sn_TX_FSR); + size2 = sreg<uint16_t>(socket, Sn_TX_FSR); + } while (size != size2); + if (size > req_size) { return size; }