Arduino参考

Arduino参考 > Libraries > SoftwareSerial > overflow()

SoftwareSerial.overflow()

Tests to see if a SoftwareSerial buffer overflow has occurred. Calling this function clears the overflow flag, meaning that subsequent calls will return false unless another byte of data has been received and discarded in the meantime. The SoftwareSerial buffer can hold up to 64 bytes.

Syntax

mySerial.overflow()

Parameters

None.

Returns

Boolean.

Example

#include <SoftwareSerial.h>

// Set up a new SoftwareSerial object with RX in digital pin 10 and TX in digital pin 11
SoftwareSerial portOne(10, 11);

void setup() {
    // Set the baud rate for the Serial port
    Serial.begin(9600);
 
    // Set the baud rate for the SerialSoftware object
    portOne.begin(9600);
}

void loop() {
    if (portOne.overflow()) {
        Serial.println("portOne overflow!");
    }

 // ...