From 559dc4bb5d3f156cf3b9c50c45aaeb842426466e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 10 Jul 2013 15:07:39 -0700 Subject: [PATCH] Flush the queue so that we don't get any funny data on the initial read. --- interface/src/SerialInterface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index 1fb5ef8985..733ba0386f 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -99,6 +99,9 @@ void SerialInterface::initializePort(char* portname) { int currentFlags = fcntl(_serialDescriptor, F_GETFL); fcntl(_serialDescriptor, F_SETFL, currentFlags & ~O_NONBLOCK); + // make sure there's nothing queued up to be read + tcflush(_serialDescriptor, TCIOFLUSH); + // this disables streaming so there's no garbage data on reads write(_serialDescriptor, "SD\n", 3); char result[4];