This commit is contained in:
Cristian Maglie 2015-11-18 10:03:05 +01:00
commit ca5aff00e8
5 changed files with 13 additions and 20 deletions

View File

@ -2,6 +2,9 @@ ARDUINO 1.6.7
[libraries]
* SPI: Added SPI.transfer16(...) function to SAM core.
* Ethernet, WiFi, SoftwareSerial: Fixed flush() behaviour:
the flush function is no more dropping the receive buffer, as per
1.0 API specification. Thanks @drmpf
[core]
* Fixed wrong timings for HardwareSerial::flush() in SAM core. Thanks @borisff

View File

@ -469,13 +469,7 @@ size_t SoftwareSerial::write(uint8_t b)
void SoftwareSerial::flush()
{
if (!isListening())
return;
uint8_t oldSREG = SREG;
cli();
_receive_buffer_head = _receive_buffer_tail = 0;
SREG = oldSREG;
// There is no tx buffering, simply return
}
int SoftwareSerial::peek()

View File

@ -118,7 +118,12 @@ size_t EthernetUDP::write(const uint8_t *buffer, size_t size)
int EthernetUDP::parsePacket()
{
// discard any remaining bytes in the last packet
flush();
while (_remaining) {
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
// should only occur if recv fails after telling us the data is there, lets
// hope the w5100 always behaves :)
read();
}
if (recvAvailable(_sock) > 0)
{
@ -206,14 +211,7 @@ int EthernetUDP::peek()
void EthernetUDP::flush()
{
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
// should only occur if recv fails after telling us the data is there, lets
// hope the w5100 always behaves :)
while (_remaining)
{
read();
}
// TODO: we should wait for TX buffer to be emptied
}
/* Start EthernetUDP socket, listening at local port PORT */

View File

@ -140,8 +140,7 @@ int WiFiClient::peek() {
}
void WiFiClient::flush() {
while (available())
read();
// TODO: a real check to ensure transmission has been completed
}
void WiFiClient::stop() {

View File

@ -155,8 +155,7 @@ int WiFiUDP::peek()
void WiFiUDP::flush()
{
while (available())
read();
// TODO: a real check to ensure transmission has been completed
}
IPAddress WiFiUDP::remoteIP()