X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=ftdipp%2Fftdi.cpp;h=afb84fb9367ef8e26eb39b8ef1247522ce80a0c7;hp=bdd85f5ab81fb0db6e7802ce109acce987f53f65;hb=928bc100257e5d2bc18a35ede7597da1e9b92ee1;hpb=26537a2dec68c3be9d597ae903dc0ffde7d1a599 diff --git a/ftdipp/ftdi.cpp b/ftdipp/ftdi.cpp index bdd85f5..afb84fb 100644 --- a/ftdipp/ftdi.cpp +++ b/ftdipp/ftdi.cpp @@ -1,8 +1,8 @@ /*************************************************************************** - ftdi.cpp - C++ wraper for libftdi + ftdi.cpp - C++ wrapper for libftdi ------------------- begin : Mon Oct 13 2008 - copyright : (C) 2008-2017 by Marek Vavruša / libftdi developers + copyright : (C) 2008-2020 by Marek Vavruša / libftdi developers email : opensource@intra2net.com and marek@vavrusa.com ***************************************************************************/ /* @@ -27,6 +27,7 @@ This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ #include +#define _FTDI_DISABLE_DEPRECATED #include "ftdi.hpp" #include "ftdi_i.h" #include "ftdi.h" @@ -106,7 +107,7 @@ int Context::open(int vendor, int product, const std::string& description, const if (ret < 0) return ret; - return get_strings_and_reopen(false,description.empty(),serial.empty()); + return get_strings_and_reopen(false,!description.empty(),!serial.empty()); } int Context::open(const std::string& description) @@ -168,6 +169,32 @@ int Context::flush(int mask) return ret; } +int Context::tcflush(int mask) +{ + int ret; + + switch (mask & (Input | Output)) { + case Input: + ret = ftdi_tciflush(d->ftdi); + break; + + case Output: + ret = ftdi_tcoflush(d->ftdi); + break; + + case Input | Output: + ret = ftdi_tcioflush(d->ftdi); + break; + + default: + // Emulate behavior of previous version. + ret = 1; + break; + } + + return ret; +} + int Context::set_interface(enum ftdi_interface interface) { return ftdi_set_interface(d->ftdi, interface);