Go Down

Topic: Possible Bug in the WiFi Library (Read 343 times) previous topic - next topic

mdelbo

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

Code: [Select]

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: [Select]

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)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy