flush()


Description

Waits for the transmission of outgoing serial data to complete.

Syntax

port.flush()

Parameters

none

Returns

none

Example

#include <PhpocExpansion.h>
#include <Phpoc.h>

byte spcId = 1;

ExpansionSerial port(spcId);

// read and write buffer
byte wbuf[] = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789";

void setup() {
  Serial.begin(9600);
  while(!Serial)
    ;

  Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
  Expansion.begin();

  port.begin("9600N81N");
}

void loop() {
  int txfree = port.availableForWrite();
  Serial.println(txfree);

  if(txfree >= 72) {

    port.write(wbuf, 72);
  }

  else {

    Serial.println("waits until sending data ...");

    // waits for the transmission of outgoing serial data to complete
    port.flush();
  }

  delay(1);
}