MQTT client test with W5200 ethernet shield
Dependents: IBMIoTClientEthernetExample_W5200
Fork of W5500Interface by
Diff: WIZnet/W5500.cpp
- Revision:
- 3:a5d99521e9cc
- Parent:
- 2:e02950866c42
- Child:
- 5:8aefaef88f79
diff -r e02950866c42 -r a5d99521e9cc WIZnet/W5500.cpp --- a/WIZnet/W5500.cpp Wed Aug 20 05:09:16 2014 +0000 +++ b/WIZnet/W5500.cpp Wed Aug 20 05:37:05 2014 +0000 @@ -169,7 +169,6 @@ int WIZnet_Chip::wait_readable(int socket, int wait_time_ms, int req_size) { - int size, size2; if (socket < 0) { return -1; } @@ -177,7 +176,14 @@ t.reset(); t.start(); while(1) { - int size = sreg<uint16_t>(socket, Sn_RX_RSR); + //int size = sreg<uint16_t>(socket, Sn_RX_RSR); + int size, size2; + // during the reading Sn_RX_RSR, it has the possible change of this register. + // so read twice and get same value then use size information. + 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; @@ -191,7 +197,6 @@ int WIZnet_Chip::wait_writeable(int socket, int wait_time_ms, int req_size) { - int size, size2; if (socket < 0) { return -1; } @@ -200,6 +205,7 @@ t.start(); while(1) { //int size = sreg<uint16_t>(socket, Sn_TX_FSR); + int size, size2; // 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. do {