X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=ftdipp%2Fftdi.cpp;h=dd777becb5be7c19d8332f4b118a3f6ff1d25d48;hp=8eb2ec2651f9d4b08c73dbf9093d0bd8b27ee3af;hb=ed46f09c1ccd1351e003a200ba50e3e4778ac478;hpb=fb56d9cf14f34dda2d7b154f16a0c08ad8b639f9 diff --git a/ftdipp/ftdi.cpp b/ftdipp/ftdi.cpp index 8eb2ec2..dd777be 100644 --- a/ftdipp/ftdi.cpp +++ b/ftdipp/ftdi.cpp @@ -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) @@ -144,12 +145,52 @@ int Context::reset() int Context::flush(int mask) { - int ret = 1; + int ret; - if (mask & Input) - ret &= ftdi_usb_purge_rx_buffer(d->ftdi); - if (mask & Output) - ret &= ftdi_usb_purge_tx_buffer(d->ftdi); + switch (mask & (Input | Output)) { + case Input: + ret = ftdi_usb_purge_rx_buffer(d->ftdi); + break; + + case Output: + ret = ftdi_usb_purge_tx_buffer(d->ftdi); + break; + + case Input | Output: + ret = ftdi_usb_purge_buffers(d->ftdi); + break; + + default: + // Emulate behavior of previous version. + ret = 1; + break; + } + + 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; }