OSDN Git Service

BSL: ftdi.flush() fix for linux
authorPawel Jewstafjew <Pawel.Jewstafjew@gmail.com>
Thu, 30 Jul 2015 19:11:38 +0000 (20:11 +0100)
committerPawel Jewstafjew <Pawel.Jewstafjew@gmail.com>
Thu, 30 Jul 2015 19:11:38 +0000 (20:11 +0100)
BSL/BSL_5.cc
BSL/BSL_IO_FTDI.h

index 46cc526..985292f 100644 (file)
@@ -48,7 +48,7 @@ enum {
    BSL_MSG_LOCKED = 0x04, // BSL locked
 };
 
-//#define IO_DEBUG
+//#define BSL_IO_DEBUG
 
 // adapted from TI's published BSL source code
 static unsigned crc_ccitt(const uint8_t *data, int len)
@@ -121,7 +121,7 @@ void BSL::log_response(const uint8_t * resp, unsigned level) const {
 }
 
 
-#ifdef IO_DEBUG
+#ifdef BSL_IO_DEBUG
 static void dump(Logger & log, BSL_IO & io)
 {
    uint8_t ch;
@@ -167,7 +167,7 @@ bool BSL::send(const uint8_t *data, unsigned len)
       return true;
 
    log_ack(ack);
-#ifdef IO_DEBUG
+#ifdef BSL_IO_DEBUG
    log.printf("%02x ", ack);
    dump(log, io);
 #endif
@@ -406,7 +406,7 @@ bool BSL::open(const uint8_t password[PASSWORD_LEN], unsigned attempts)
       if (!start())
          return false;
 
-#ifdef IO_DEBUG
+#ifdef BSL_IO_DEBUG
       dump(log, io);
 #else
       io.flush();
index 4c3e7d5..ee49773 100644 (file)
@@ -44,7 +44,12 @@ public:
 #endif
 
    void flush() {
+#ifdef __linux__
+      uint8_t ch;
+      while(ftdi.read(&ch, 1) > 0) {}
+#else
       ftdi.purge(FT_PURGE_RX);
+#endif
    }
 
 #ifdef BSL_nDTR_RTS