From acd38152eb523a50da960ad0781398f8cf998925 Mon Sep 17 00:00:00 2001 From: Dan Ledger Date: Tue, 18 Feb 2020 08:52:48 -0500 Subject: [PATCH] Short delay to ensure port is flushed in OS X (and prevent download hang) on OS X, it appears that occasionally the _port->flush() may not always complete before writeBinary() is called. This results in an exception and an error during download (as it looks like we're running into the "SAM firmware bug" mentioned in the comments. Adding this short delay helps ensure that the flush() command competes before the binary write is called. --- src/Samba.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Samba.cpp b/src/Samba.cpp index 490e3936..5c080b14 100644 --- a/src/Samba.cpp +++ b/src/Samba.cpp @@ -35,6 +35,7 @@ #include #include #include +#include using namespace std; @@ -521,6 +522,8 @@ Samba::write(uint32_t addr, const uint8_t* buffer, int size) if (_isUsb) { _port->flush(); + // Short delay to ensure port is flushed in OS X + usleep(5000); writeBinary(buffer, size); } else