From 09658f679a0d7f47dd77c44b1894de7157b183d9 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 25 Nov 2011 16:09:27 +0000 Subject: [PATCH] Fix FTDI Adaptor on Linux and Mac Eric Brandt provided a fix for the new FTDI adaptor sold with Computrainers from late 2009. It only fixed the problem under Windows. This fix applies the same modification to turn off hardware flow-control for Linux and Mac. Fixes #523. --- src/Computrainer.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Computrainer.cpp b/src/Computrainer.cpp index 95b353f8b..e3e759a77 100644 --- a/src/Computrainer.cpp +++ b/src/Computrainer.cpp @@ -821,15 +821,22 @@ int Computrainer::openPort() cfsetspeed(&deviceSettings, B2400); // further attributes - deviceSettings.c_iflag= IGNPAR; - deviceSettings.c_oflag=0; + deviceSettings.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ICANON | ISTRIP | IXON | IXOFF | IXANY); + deviceSettings.c_iflag |= IGNPAR; deviceSettings.c_cflag &= (~CSIZE & ~CSTOPB); + deviceSettings.c_oflag=0; + #if defined(Q_OS_MACX) - deviceSettings.c_cflag |= (CS8 | CREAD | HUPCL | CCTS_OFLOW | CRTS_IFLOW); + deviceSettings.c_cflag &= (~CCTS_OFLOW & ~CRTS_IFLOW); // no hardware flow control + deviceSettings.c_cflag |= (CS8 | CLOCAL | CREAD | HUPCL); #else - deviceSettings.c_cflag |= (CS8 | CREAD | HUPCL | CRTSCTS); + deviceSettings.c_cflag &= (~CRTSCTS); // no hardware flow control + deviceSettings.c_cflag |= (CS8 | CLOCAL | CREAD | HUPCL); #endif deviceSettings.c_lflag=0; + deviceSettings.c_cc[VSTART] = 0x11; + deviceSettings.c_cc[VSTOP] = 0x13; + deviceSettings.c_cc[VEOF] = 0x20; deviceSettings.c_cc[VMIN]=0; deviceSettings.c_cc[VTIME]=0; @@ -837,6 +844,7 @@ int Computrainer::openPort() if(tcsetattr(devicePort, TCSANOW, &deviceSettings) == -1) return errno; tcgetattr(devicePort, &deviceSettings); + tcflush(devicePort, TCIOFLUSH); // clear out the garbage #else // WINDOWS USES SET/GETCOMMSTATE AND READ/WRITEFILE