Pages: [1]   Go Down
Author Topic: Possible Bug in the WiFi Library  (Read 213 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I open up the WifiChatServer example sketch and change the loop to this...

Code:
void loop() {
  server.write('a');
}

...and then telnet to the WifiChatServer IP/Port I get some weird behaviour. Approximately every 2 seconds I get a burst of 'a' characters in the terminal. However, if I start tapping <enter> in the terminal 'a' characters come through as soon as I tap <enter> (ie. more frequent than a burst every 2 seconds).

I traced the problem as far as this function in the WiFi library (in server_drv.cpp)...

Code:
uint8_t ServerDrv::checkDataSent(uint8_t sock)
{
const uint16_t TIMEOUT_DATA_SENT = 25;
    uint16_t timeout = 0;
uint8_t _data = 0;
uint8_t _dataLen = 0;

do {
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1);
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);

//Wait the reply elaboration
SpiDrv::waitForSlaveReady();

// Wait for reply
if (!SpiDrv::waitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse isDataSent");
}
SpiDrv::spiSlaveDeselect();

if (_data) timeout = 0;
else{
++timeout;
delay(100);
}

}while((_data==0)&&(timeout<TIMEOUT_DATA_SENT));
    return (timeout==TIMEOUT_DATA_SENT)?0:1;
}

The timeout counter above regularly reaches around 18 (an 1800 second delay) if I don't press <enter> in the terminal. However, if I do repeatedly press <enter> in the terminal the timeout rarely goes above 0 sometimes it gets to 2.

It seems as though if I just stream data to a client it takes a long time for the DATA_SENT_TCP_CMD to be registered. However, if the client sends a small amount of data back the DATA_SENT_TCP_CMD seems to be immediately registered. Anyone else experienced this? Or know of a fix? (other than getting the client to send back a small amount of data each time it receives a packet from the server running on the arduino)
Logged

Pages: [1]   Go Up
Jump to: