[qlandkartegt] - unbundle qextserial library (#872883)

Dan Horák sharkcz at fedoraproject.org
Tue Mar 25 22:08:13 UTC 2014


commit 264d3553012b0165e1612affe2ace8d344f26337
Author: Dan Horák <dan at danny.cz>
Date:   Tue Mar 25 23:08:15 2014 +0100

    - unbundle qextserial library (#872883)

 qlandkartegt-1.7.6-qextserialport.patch |11152 +++++++++++++++++++++++++++++++
 qlandkartegt.spec                       |   11 +-
 2 files changed, 11161 insertions(+), 2 deletions(-)
---
diff --git a/qlandkartegt-1.7.6-qextserialport.patch b/qlandkartegt-1.7.6-qextserialport.patch
new file mode 100644
index 0000000..4e30503
--- /dev/null
+++ b/qlandkartegt-1.7.6-qextserialport.patch
@@ -0,0 +1,11152 @@
+From 5d72974c1e2a82b5a1c914b1c03b53dbcb2aab4a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan at danny.cz>
+Date: Sun, 23 Mar 2014 10:46:58 +0100
+Subject: [PATCH 1/3] move qetxserialport to own directory
+
+---
+ 3rdparty/SerialPort/CMakeLists.txt                 |   16 +-
+ 3rdparty/SerialPort/ManageSerialPort.h             |    2 +-
+ 3rdparty/SerialPort/posix_qextserialport.cpp       | 1114 --------------------
+ 3rdparty/SerialPort/posix_qextserialport.h         |   56 -
+ 3rdparty/SerialPort/qextserialbase.cpp             |  250 -----
+ 3rdparty/SerialPort/qextserialbase.h               |  196 ----
+ 3rdparty/SerialPort/qextserialport.cpp             |   98 --
+ 3rdparty/SerialPort/qextserialport.h               |   27 -
+ .../qextserialport/posix_qextserialport.cpp        | 1114 ++++++++++++++++++++
+ .../qextserialport/posix_qextserialport.h          |   56 +
+ .../SerialPort/qextserialport/qextserialbase.cpp   |  250 +++++
+ .../SerialPort/qextserialport/qextserialbase.h     |  196 ++++
+ .../SerialPort/qextserialport/qextserialport.cpp   |   98 ++
+ .../SerialPort/qextserialport/qextserialport.h     |   27 +
+ .../qextserialport/win_qextserialport.cpp          |  877 +++++++++++++++
+ .../SerialPort/qextserialport/win_qextserialport.h |   48 +
+ 3rdparty/SerialPort/win_qextserialport.cpp         |  877 ---------------
+ 3rdparty/SerialPort/win_qextserialport.h           |   48 -
+ 18 files changed, 2675 insertions(+), 2675 deletions(-)
+ delete mode 100644 3rdparty/SerialPort/posix_qextserialport.cpp
+ delete mode 100644 3rdparty/SerialPort/posix_qextserialport.h
+ delete mode 100644 3rdparty/SerialPort/qextserialbase.cpp
+ delete mode 100644 3rdparty/SerialPort/qextserialbase.h
+ delete mode 100644 3rdparty/SerialPort/qextserialport.cpp
+ delete mode 100644 3rdparty/SerialPort/qextserialport.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp
+ create mode 100644 3rdparty/SerialPort/qextserialport/posix_qextserialport.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialbase.cpp
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialbase.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialport.cpp
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialport.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/win_qextserialport.cpp
+ create mode 100644 3rdparty/SerialPort/qextserialport/win_qextserialport.h
+ delete mode 100644 3rdparty/SerialPort/win_qextserialport.cpp
+ delete mode 100644 3rdparty/SerialPort/win_qextserialport.h
+
+diff --git a/3rdparty/SerialPort/CMakeLists.txt b/3rdparty/SerialPort/CMakeLists.txt
+index cafad11..99fd911 100644
+--- a/3rdparty/SerialPort/CMakeLists.txt
++++ b/3rdparty/SerialPort/CMakeLists.txt
+@@ -13,16 +13,16 @@ include(${QT_USE_FILE})
+ set(SRCS
+     ManageSerialPort.cpp
+ #    posix_qextserialport.cpp
+-    qextserialbase.cpp
+-    qextserialport.cpp
++    qextserialport/qextserialbase.cpp
++    qextserialport/qextserialport.cpp
+ #    win_qextserialport.cpp
+ )
+ 
+ set(HDRS
+     ManageSerialPort.h
+ #    posix_qextserialport.h
+-    qextserialbase.h
+-    qextserialport.h
++    qextserialport/qextserialbase.h
++    qextserialport/qextserialport.h
+ #    win_qextserialport.h
+ )
+ 
+@@ -36,11 +36,11 @@ set(RCS
+ )
+ 
+ if(WIN32)
+-    set(SRCS ${SRCS} win_qextserialport.cpp)
+-    set(HDRS ${HDRS} win_qextserialport.h)
++    set(SRCS ${SRCS} qextserialport/win_qextserialport.cpp)
++    set(HDRS ${HDRS} qextserialport/win_qextserialport.h)
+ else (WIN32)
+-    set(SRCS ${SRCS} posix_qextserialport.cpp)
+-    set(HDRS ${HDRS} posix_qextserialport.h)
++    set(SRCS ${SRCS} qextserialport/posix_qextserialport.cpp)
++    set(HDRS ${HDRS} qextserialport/posix_qextserialport.h)
+     add_definitions(-D_TTY_POSIX_)
+ endif(WIN32)
+ 
+diff --git a/3rdparty/SerialPort/ManageSerialPort.h b/3rdparty/SerialPort/ManageSerialPort.h
+index 99aefc5..863b8ec 100644
+--- a/3rdparty/SerialPort/ManageSerialPort.h
++++ b/3rdparty/SerialPort/ManageSerialPort.h
+@@ -13,7 +13,7 @@
+ #include <QQueue>
+ #include <QMetaType>
+ #include <QMutex>
+-#include "qextserialport.h"
++#include "qextserialport/qextserialport.h"
+ 
+ Q_DECLARE_METATYPE(BaudRateType);
+ Q_DECLARE_METATYPE(DataBitsType);
+diff --git a/3rdparty/SerialPort/posix_qextserialport.cpp b/3rdparty/SerialPort/posix_qextserialport.cpp
+deleted file mode 100644
+index 0982349..0000000
+--- a/3rdparty/SerialPort/posix_qextserialport.cpp
++++ /dev/null
+@@ -1,1114 +0,0 @@
+-
+-/*!
+-		\class Posix_QextSerialPort
+-		\version 1.0.0
+-		\author Stefan Sander
+-
+-A cross-platform serial port class.
+-		This class encapsulates the POSIX portion of QextSerialPort.  The user will be notified of errors
+-		and possible portability conflicts at run-time by default - this behavior can be turned off by
+-		defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off portability
+-		warnings) in the project.  Note that _TTY_NOWARN_ will also turn off portability warnings.
+-*/
+-
+-#include <stdio.h>
+-#include "posix_qextserialport.h"
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort()
+-			Default constructor.  Note that the name of the device used by a QextSerialPort constructed with
+-			this constructor will be determined by #defined constants, or lack thereof - the default behavior
+-			is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:
+-
+-\verbatim
+-
+-Constant         Used By         Naming Convention
+-		----------       -------------   ------------------------
+-		_TTY_WIN_        Windows         COM1, COM2
+-		_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
+-		_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
+-		_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
+-		_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
+-		_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
+-		_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
+-		<none>           Linux           /dev/ttyS0, /dev/ttyS1
+-		\endverbatim
+-
+-This constructor assigns the device name to the name of the first port on the specified system.
+-		See the other constructors if you need to open a different port.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort()
+-	: QextSerialBase()
+-{
+-	Posix_File=new QFile();
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort&)
+-			Copy constructor.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort& s)
+-	: QextSerialBase(s.port)
+-{
+-	setOpenMode(s.openMode());
+-	port = s.port;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	lastErr=s.lastErr;
+-	
+-	Posix_File=new QFile();
+-	Posix_File=s.Posix_File;
+-	memcpy(&Posix_Timeout, &s.Posix_Timeout, sizeof(struct timeval));
+-	memcpy(&Posix_Copy_Timeout, &s.Posix_Copy_Timeout, sizeof(struct timeval));
+-	memcpy(&Posix_CommConfig, &s.Posix_CommConfig, sizeof(struct termios));
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name)
+-			Constructs a serial port attached to the port specified by name.
+-			name is the name of the device, which is windowsystem-specific,
+-			e.g."COM1" or "/dev/ttyS0".
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const QString & name)
+-	: QextSerialBase(name)
+-{
+-	Posix_File=new QFile();
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
+-			Constructs a port with default name and specified settings.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
+-	: QextSerialBase()
+-{
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setParity(settings.Parity);
+-	setStopBits(settings.StopBits);
+-	setFlowControl(settings.FlowControl);
+-	
+-	Posix_File=new QFile();
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings)
+-			Constructs a port with specified name and settings.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings)
+-	: QextSerialBase(name)
+-{
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setParity(settings.Parity);
+-	setStopBits(settings.StopBits);
+-	setFlowControl(settings.FlowControl);
+-	
+-	Posix_File=new QFile();
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
+-			Override the = operator.
+-*/
+-Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
+-{
+-	setOpenMode(s.openMode());
+-	port = s.port;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	lastErr=s.lastErr;
+-	
+-	Posix_File=s.Posix_File;
+-	memcpy(&Posix_Timeout, &(s.Posix_Timeout), sizeof(struct timeval));
+-	memcpy(&Posix_Copy_Timeout, &(s.Posix_Copy_Timeout), sizeof(struct timeval));
+-	memcpy(&Posix_CommConfig, &(s.Posix_CommConfig), sizeof(struct termios));
+-	return *this;
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::~Posix_QextSerialPort()
+-			Standard destructor.
+-*/
+-Posix_QextSerialPort::~Posix_QextSerialPort()
+-{
+-	if (isOpen()) {
+-		close();
+-	}
+-	Posix_File->close();
+-	delete Posix_File;
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
+-			Sets the baud rate of the serial port.  Note that not all rates are applicable on
+-			all platforms.  The following table shows translations of the various baud rate
+-			constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
+-			are speeds that are usable on both Windows and POSIX.
+-
+-\note
+-		BAUD76800 may not be supported on all POSIX systems.  SGI/IRIX systems do not support
+-		BAUD1800.
+-
+-\verbatim
+-
+-RATE          Windows Speed   POSIX Speed
+-		-----------   -------------   -----------
+-		BAUD50                 110          50
+-		BAUD75                 110          75
+-		*BAUD110                110         110
+-		BAUD134                110         134.5
+-		BAUD150                110         150
+-		BAUD200                110         200
+-		*BAUD300                300         300
+-		*BAUD600                600         600
+-		*BAUD1200              1200        1200
+-		BAUD1800              1200        1800
+-		*BAUD2400              2400        2400
+-		*BAUD4800              4800        4800
+-		*BAUD9600              9600        9600
+-		BAUD14400            14400        9600
+-		*BAUD19200            19200       19200
+-		*BAUD38400            38400       38400
+-		BAUD56000            56000       38400
+-		*BAUD57600            57600       57600
+-		BAUD76800            57600       76800
+-		*BAUD115200          115200      115200
+-		BAUD128000          128000      115200
+-		BAUD256000          256000      115200
+-		\endverbatim
+-*/
+-void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.BaudRate!=baudRate) {
+-		switch (baudRate) {
+-			case BAUD14400:
+-				Settings.BaudRate=BAUD9600;
+-				break;
+-				
+-			case BAUD56000:
+-				Settings.BaudRate=BAUD38400;
+-				break;
+-				
+-			case BAUD76800:
+-				
+-				#ifndef B76800
+-							Settings.BaudRate=BAUD57600;
+-				#else
+-				Settings.BaudRate=baudRate;
+-				#endif
+-							break;
+-				
+-			case BAUD128000:
+-			case BAUD256000:
+-				Settings.BaudRate=BAUD115200;
+-				break;
+-				
+-			default:
+-				Settings.BaudRate=baudRate;
+-				break;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (baudRate) {
+-				
+-				/*50 baud*/
+-			case BAUD50:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 50 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B50;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B50);
+-				cfsetospeed(&Posix_CommConfig, B50);
+-				#endif
+-							break;
+-				
+-				/*75 baud*/
+-			case BAUD75:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 75 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B75;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B75);
+-				cfsetospeed(&Posix_CommConfig, B75);
+-				#endif
+-							break;
+-				
+-				/*110 baud*/
+-			case BAUD110:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B110;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B110);
+-				cfsetospeed(&Posix_CommConfig, B110);
+-				#endif
+-							break;
+-				
+-				/*134.5 baud*/
+-			case BAUD134:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 134.5 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B134;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B134);
+-				cfsetospeed(&Posix_CommConfig, B134);
+-				#endif
+-							break;
+-				
+-				/*150 baud*/
+-			case BAUD150:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 150 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B150;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B150);
+-				cfsetospeed(&Posix_CommConfig, B150);
+-				#endif
+-							break;
+-				
+-				/*200 baud*/
+-			case BAUD200:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 200 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B200);
+-				cfsetospeed(&Posix_CommConfig, B200);
+-				#endif
+-							break;
+-				
+-				/*300 baud*/
+-			case BAUD300:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B300;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B300);
+-				cfsetospeed(&Posix_CommConfig, B300);
+-				#endif
+-							break;
+-				
+-				/*600 baud*/
+-			case BAUD600:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B600);
+-				cfsetospeed(&Posix_CommConfig, B600);
+-				#endif
+-							break;
+-				
+-				/*1200 baud*/
+-			case BAUD1200:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B1200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B1200);
+-				cfsetospeed(&Posix_CommConfig, B1200);
+-				#endif
+-							break;
+-				
+-				/*1800 baud*/
+-			case BAUD1800:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and IRIX do not support 1800 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B1800;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B1800);
+-				cfsetospeed(&Posix_CommConfig, B1800);
+-				#endif
+-							break;
+-				
+-				/*2400 baud*/
+-			case BAUD2400:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B2400;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B2400);
+-				cfsetospeed(&Posix_CommConfig, B2400);
+-				#endif
+-							break;
+-				
+-				/*4800 baud*/
+-			case BAUD4800:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B4800;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B4800);
+-				cfsetospeed(&Posix_CommConfig, B4800);
+-				#endif
+-							break;
+-				
+-				/*9600 baud*/
+-			case BAUD9600:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B9600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B9600);
+-				cfsetospeed(&Posix_CommConfig, B9600);
+-				#endif
+-							break;
+-				
+-				/*14400 baud*/
+-			case BAUD14400:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 14400 baud operation.  Switching to 9600 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B9600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B9600);
+-				cfsetospeed(&Posix_CommConfig, B9600);
+-				#endif
+-							break;
+-				
+-				/*19200 baud*/
+-			case BAUD19200:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B19200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B19200);
+-				cfsetospeed(&Posix_CommConfig, B19200);
+-				#endif
+-							break;
+-				
+-				/*38400 baud*/
+-			case BAUD38400:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B38400;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B38400);
+-				cfsetospeed(&Posix_CommConfig, B38400);
+-				#endif
+-							break;
+-				
+-				/*56000 baud*/
+-			case BAUD56000:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 56000 baud operation.  Switching to 38400 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B38400;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B38400);
+-				cfsetospeed(&Posix_CommConfig, B38400);
+-				#endif
+-							break;
+-				
+-				/*57600 baud*/
+-			case BAUD57600:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B57600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B57600);
+-				cfsetospeed(&Posix_CommConfig, B57600);
+-				#endif
+-							break;
+-				
+-				/*76800 baud*/
+-			case BAUD76800:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and some POSIX systems do not support 76800 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				
+-				#ifdef B76800
+-							Posix_CommConfig.c_cflag|=B76800;
+-				#else
+-				TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
+-				Posix_CommConfig.c_cflag|=B57600;
+-				#endif //B76800
+-				#else  //CBAUD
+-				#ifdef B76800
+-							cfsetispeed(&Posix_CommConfig, B76800);
+-				cfsetospeed(&Posix_CommConfig, B76800);
+-				#else
+-				TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
+-				cfsetispeed(&Posix_CommConfig, B57600);
+-				cfsetospeed(&Posix_CommConfig, B57600);
+-				#endif //B76800
+-				#endif //CBAUD
+-							break;
+-				
+-				/*115200 baud*/
+-			case BAUD115200:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B115200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B115200);
+-				cfsetospeed(&Posix_CommConfig, B115200);
+-				#endif
+-							break;
+-				
+-				/*128000 baud*/
+-			case BAUD128000:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 128000 baud operation.  Switching to 115200 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B115200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B115200);
+-				cfsetospeed(&Posix_CommConfig, B115200);
+-				#endif
+-							break;
+-				
+-				/*256000 baud*/
+-			case BAUD256000:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 256000 baud operation.  Switching to 115200 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B115200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B115200);
+-				cfsetospeed(&Posix_CommConfig, B115200);
+-				#endif
+-							break;
+-			}
+-			tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setDataBits(DataBitsType dataBits)
+-			Sets the number of data bits used by the serial port.  Possible values of dataBits are:
+-\verbatim
+-		DATA_5      5 data bits
+-		DATA_6      6 data bits
+-		DATA_7      7 data bits
+-		DATA_8      8 data bits
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following restrictions:
+-\par
+-		5 data bits cannot be used with 2 stop bits.
+-		\par
+-		8 data bits cannot be used with space parity on POSIX systems.
+-
+-*/
+-void Posix_QextSerialPort::setDataBits(DataBitsType dataBits)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.DataBits!=dataBits) {
+-		if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
+-				(Settings.StopBits==STOP_1_5 && dataBits!=DATA_5) ||
+-				(Settings.Parity==PAR_SPACE && dataBits==DATA_8)) {
+-				}
+-		else {
+-			Settings.DataBits=dataBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch(dataBits) {
+-				
+-				/*5 data bits*/
+-			case DATA_5:
+-				if (Settings.StopBits==STOP_2) {
+-					TTY_WARNING("Posix_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS5;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*6 data bits*/
+-			case DATA_6:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS6;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*7 data bits*/
+-			case DATA_7:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS7;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*8 data bits*/
+-			case DATA_8:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS8;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setParity(ParityType parity)
+-			Sets the parity associated with the serial port.  The possible values of parity are:
+-\verbatim
+-		PAR_SPACE       Space Parity
+-		PAR_MARK        Mark Parity
+-		PAR_NONE        No Parity
+-		PAR_EVEN        Even Parity
+-		PAR_ODD         Odd Parity
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following limitations:
+-\par
+-		POSIX systems do not support mark parity.
+-		\par
+-		POSIX systems support space parity only if tricked into doing so, and only with
+-		fewer than 8 data bits.  Use space parity very carefully with POSIX systems.
+-
+-*/
+-void Posix_QextSerialPort::setParity(ParityType parity)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.Parity!=parity) {
+-		if (parity==PAR_MARK || (parity==PAR_SPACE && Settings.DataBits==DATA_8)) {
+-		}
+-		else {
+-			Settings.Parity=parity;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (parity) {
+-				
+-				/*space parity*/
+-			case PAR_SPACE:
+-				if (Settings.DataBits==DATA_8) {
+-					TTY_PORTABILITY_WARNING("Posix_QextSerialPort:  Space parity is only supported in POSIX with 7 or fewer data bits");
+-				}
+-				else {
+-					
+-					/*space parity not directly supported - add an extra data bit to simulate it*/
+-					Posix_CommConfig.c_cflag&=~(PARENB|CSIZE);
+-				switch(Settings.DataBits) {
+-					case DATA_5:
+-						Settings.DataBits=DATA_6;
+-						Posix_CommConfig.c_cflag|=CS6;
+-						break;
+-						
+-					case DATA_6:
+-						Settings.DataBits=DATA_7;
+-						Posix_CommConfig.c_cflag|=CS7;
+-						break;
+-						
+-					case DATA_7:
+-						Settings.DataBits=DATA_8;
+-						Posix_CommConfig.c_cflag|=CS8;
+-						break;
+-						
+-					case DATA_8:
+-						break;
+-					}
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*mark parity - WINDOWS ONLY*/
+-			case PAR_MARK:
+-				TTY_WARNING("Posix_QextSerialPort: Mark parity is not supported by POSIX.");
+-				break;
+-				
+-				/*no parity*/
+-			case PAR_NONE:
+-				Posix_CommConfig.c_cflag&=(~PARENB);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*even parity*/
+-			case PAR_EVEN:
+-				Posix_CommConfig.c_cflag&=(~PARODD);
+-				Posix_CommConfig.c_cflag|=PARENB;
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*odd parity*/
+-			case PAR_ODD:
+-				Posix_CommConfig.c_cflag|=(PARENB|PARODD);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setStopBits(StopBitsType stopBits)
+-			Sets the number of stop bits used by the serial port.  Possible values of stopBits are:
+-\verbatim
+-		STOP_1      1 stop bit
+-		STOP_1_5    1.5 stop bits
+-		STOP_2      2 stop bits
+-		\endverbatim
+-		\note
+-		This function is subject to the following restrictions:
+-\par
+-		2 stop bits cannot be used with 5 data bits.
+-		\par
+-		POSIX does not support 1.5 stop bits.
+-
+-*/
+-void Posix_QextSerialPort::setStopBits(StopBitsType stopBits)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.StopBits!=stopBits) {
+-		if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) || stopBits==STOP_1_5) {}
+-		else {
+-			Settings.StopBits=stopBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (stopBits) {
+-				
+-				/*one stop bit*/
+-			case STOP_1:
+-				Settings.StopBits=stopBits;
+-				Posix_CommConfig.c_cflag&=(~CSTOPB);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*1.5 stop bits*/
+-			case STOP_1_5:
+-				TTY_WARNING("Posix_QextSerialPort: 1.5 stop bit operation is not supported by POSIX.");
+-				break;
+-				
+-				/*two stop bits*/
+-			case STOP_2:
+-				if (Settings.DataBits==DATA_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
+-				}
+-				else {
+-					Settings.StopBits=stopBits;
+-					Posix_CommConfig.c_cflag|=CSTOPB;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setFlowControl(FlowType flow)
+-			Sets the flow control used by the port.  Possible values of flow are:
+-\verbatim
+-		FLOW_OFF            No flow control
+-		FLOW_HARDWARE       Hardware (RTS/CTS) flow control
+-		FLOW_XONXOFF        Software (XON/XOFF) flow control
+-		\endverbatim
+-		\note
+-		FLOW_HARDWARE may not be supported on all versions of UNIX.  In cases where it is
+-		unsupported, FLOW_HARDWARE is the same as FLOW_OFF.
+-
+-*/
+-void Posix_QextSerialPort::setFlowControl(FlowType flow)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.FlowControl!=flow) {
+-		Settings.FlowControl=flow;
+-	}
+-	if (isOpen()) {
+-		switch(flow) {
+-				
+-				/*no flow control*/
+-			case FLOW_OFF:
+-				Posix_CommConfig.c_cflag&=(~CRTSCTS);
+-				Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*software (XON/XOFF) flow control*/
+-			case FLOW_XONXOFF:
+-				Posix_CommConfig.c_cflag&=(~CRTSCTS);
+-				Posix_CommConfig.c_iflag|=(IXON|IXOFF|IXANY);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-			case FLOW_HARDWARE:
+-				Posix_CommConfig.c_cflag|=CRTSCTS;
+-				Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec);
+-Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.
+-		Note that this is a per-character timeout, i.e. the port will wait this long for each
+-		individual character, not for the whole read operation.  This timeout also applies to the
+-		bytesWaiting() function.
+-
+-\note
+-		POSIX does not support millisecond-level control for I/O timeout values.  Any
+-		timeout set using this function will be set to the next lowest tenth of a second for
+-		the purposes of detecting read or write timeouts.  For example a timeout of 550 milliseconds
+-		will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and
+-		writing the port.  However millisecond-level control is allowed by the select() system call,
+-		so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for
+-		the purpose of detecting available bytes in the read buffer.
+-
+-*/
+-void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec)
+-{
+-	LOCK_MUTEX();
+-	Settings.Timeout_Sec=sec;
+-	Settings.Timeout_Millisec=millisec;
+-	Posix_Copy_Timeout.tv_sec=sec;
+-	Posix_Copy_Timeout.tv_usec=millisec;
+-	if (isOpen()) {
+-		tcgetattr(Posix_File->handle(), &Posix_CommConfig);
+-		Posix_CommConfig.c_cc[VTIME]=sec*10+millisec/100;
+-		tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn bool Posix_QextSerialPort::open(OpenMode mode)
+-			Opens the serial port associated to this class.
+-			This function has no effect if the port associated with the class is already open.
+-			The port is also configured to the current settings, as stored in the Settings structure.
+-*/
+-bool Posix_QextSerialPort::open(OpenMode mode)
+-{
+-	LOCK_MUTEX();
+-	if (mode == QIODevice::NotOpen)
+-		return isOpen();
+-	if (!isOpen()) {
+-		/*open the port*/
+-		Posix_File->setFileName(port);
+-		if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
+-			/*set open mode*/
+-			QIODevice::open(mode);
+-			
+-			/*configure port settings*/
+-			tcgetattr(Posix_File->handle(), &Posix_CommConfig);
+-			
+-			/*set up other port settings*/
+-			Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
+-			Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
+-			Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
+-			Posix_CommConfig.c_oflag&=(~OPOST);
+-			Posix_CommConfig.c_cc[VMIN]=0;
+-			Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
+-			setBaudRate(Settings.BaudRate);
+-			setDataBits(Settings.DataBits);
+-			setParity(Settings.Parity);
+-			setStopBits(Settings.StopBits);
+-			setFlowControl(Settings.FlowControl);
+-			setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
+-			tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-		} else {
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return isOpen();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::close()
+-			Closes a serial port.  This function has no effect if the serial port associated with the class
+-			is not currently open.
+-*/
+-void Posix_QextSerialPort::close()
+-{
+-	LOCK_MUTEX();
+-	Posix_File->close();
+-	QIODevice::close();
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::flush()
+-			Flushes all pending I/O to the serial port.  This function has no effect if the serial port
+-			associated with the class is not currently open.
+-*/
+-void Posix_QextSerialPort::flush()
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		Posix_File->flush();
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::size() const
+-This function will return the number of bytes waiting in the receive queue of the serial port.
+-		It is included primarily to provide a complete QIODevice interface, and will not record errors
+-		in the lastErr member (because it is const).  This function is also not thread-safe - in
+-		multithreading situations, use Posix_QextSerialPort::bytesWaiting() instead.
+-*/
+-qint64 Posix_QextSerialPort::size() const
+-{
+-	int numBytes;
+-	if (ioctl(Posix_File->handle(), FIONREAD, &numBytes)<0) {
+-		numBytes=0;
+-	}
+-	return (qint64)numBytes;
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::bytesAvailable()
+-			Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
+-			the port is not currently open, or -1 on error.  Error information can be retrieved by calling
+-			Posix_QextSerialPort::getLastError().
+-*/
+-qint64 Posix_QextSerialPort::bytesAvailable()
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		int bytesQueued;
+-		fd_set fileSet;
+-		FD_ZERO(&fileSet);
+-		FD_SET(Posix_File->handle(), &fileSet);
+-		
+-		/*on Linux systems the Posix_Timeout structure will be altered by the select() call.
+-				Make sure we use the right timeout values*/
+-		//memcpy(&Posix_Timeout, &Posix_Copy_Timeout, sizeof(struct timeval));
+-		Posix_Timeout = Posix_Copy_Timeout;
+-		int n=select(Posix_File->handle()+1, &fileSet, NULL, &fileSet, &Posix_Timeout);
+-		if (!n) {
+-			lastErr=E_PORT_TIMEOUT;
+-			UNLOCK_MUTEX();
+-			return -1;
+-		}
+-		if (n==-1 || ioctl(Posix_File->handle(), FIONREAD, &bytesQueued)==-1) {
+-			translateError(errno);
+-			UNLOCK_MUTEX();
+-			return -1;
+-		}
+-		lastErr=E_NO_ERROR;
+-		UNLOCK_MUTEX();
+-		return bytesQueued + QIODevice::bytesAvailable();
+-	}
+-	UNLOCK_MUTEX();
+-	return 0;
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::ungetChar(char)
+-			This function is included to implement the full QIODevice interface, and currently has no
+-			purpose within this class.  This function is meaningless on an unbuffered device and currently
+-			only prints a warning message to that effect.
+-*/
+-void Posix_QextSerialPort::ungetChar(char)
+-{
+-	/*meaningless on unbuffered sequential device - return error and print a warning*/
+-	TTY_WARNING("Posix_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::translateError(ulong error)
+-			Translates a system-specific error code to a QextSerialPort error code.  Used internally.
+-*/
+-void Posix_QextSerialPort::translateError(ulong error)
+-{
+-	switch (error) {
+-		case EBADF:
+-		case ENOTTY:
+-			lastErr=E_INVALID_FD;
+-			break;
+-			
+-		case EINTR:
+-			lastErr=E_CAUGHT_NON_BLOCKED_SIGNAL;
+-			break;
+-			
+-		case ENOMEM:
+-			lastErr=E_NO_MEMORY;
+-			break;
+-		}
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setDtr(bool set)
+-			Sets DTR line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Posix_QextSerialPort::setDtr(bool set)
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		int status;
+-		ioctl(Posix_File->handle(), TIOCMGET, &status);
+-		if (set) {
+-			status|=TIOCM_DTR;
+-		}
+-		else {
+-			status&=~TIOCM_DTR;
+-		}
+-		ioctl(Posix_File->handle(), TIOCMSET, &status);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setRts(bool set)
+-			Sets RTS line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Posix_QextSerialPort::setRts(bool set)
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		int status;
+-		ioctl(Posix_File->handle(), TIOCMGET, &status);
+-		if (set) {
+-			status|=TIOCM_RTS;
+-		}
+-		else {
+-			status&=~TIOCM_RTS;
+-		}
+-		ioctl(Posix_File->handle(), TIOCMSET, &status);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn unsigned long Posix_QextSerialPort::lineStatus()
+-			returns the line status as stored by the port function.  This function will retrieve the states
+-			of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
+-			can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
+-			long with specific bits indicating which lines are high.  The following constants should be used
+-			to examine the states of individual lines:
+-
+-\verbatim
+-		Mask        Line
+-		------      ----
+-		LS_CTS      CTS
+-		LS_DSR      DSR
+-		LS_DCD      DCD
+-		LS_RI       RI
+-		LS_RTS      RTS (POSIX only)
+-			LS_DTR      DTR (POSIX only)
+-				LS_ST       Secondary TXD (POSIX only)
+-					LS_SR       Secondary RXD (POSIX only)
+-						\endverbatim
+-
+-This function will return 0 if the port associated with the class is not currently open.
+-*/
+-unsigned long Posix_QextSerialPort::lineStatus()
+-{
+-	unsigned long Status=0, Temp=0;
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		ioctl(Posix_File->handle(), TIOCMGET, &Temp);
+-		if (Temp&TIOCM_CTS) {
+-			Status|=LS_CTS;
+-		}
+-		if (Temp&TIOCM_DSR) {
+-			Status|=LS_DSR;
+-		}
+-		if (Temp&TIOCM_RI) {
+-			Status|=LS_RI;
+-		}
+-		if (Temp&TIOCM_CD) {
+-			Status|=LS_DCD;
+-		}
+-		if (Temp&TIOCM_DTR) {
+-			Status|=LS_DTR;
+-		}
+-		if (Temp&TIOCM_RTS) {
+-			Status|=LS_RTS;
+-		}
+-		if (Temp&TIOCM_ST) {
+-			Status|=LS_ST;
+-		}
+-		if (Temp&TIOCM_SR) {
+-			Status|=LS_SR;
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return Status;
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize)
+-			Reads a block of data from the serial port.  This function will read at most maxSize bytes from
+-			the serial port and place them in the buffer pointed to by data.  Return value is the number of
+-			bytes actually read, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	retVal=Posix_File->read(data, maxSize);
+-	if (retVal==-1)
+-		lastErr=E_READ_FAILED;
+-	UNLOCK_MUTEX();
+-	
+-	return retVal;
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize)
+-			Writes a block of data to the serial port.  This function will write maxSize bytes
+-			from the buffer pointed to by data to the serial port.  Return value is the number
+-			of bytes actually written, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	retVal=Posix_File->write(data, maxSize);
+-	if (retVal==-1)
+-		lastErr=E_WRITE_FAILED;
+-	UNLOCK_MUTEX();
+-	
+-	flush();
+-	return retVal;
+-}
+diff --git a/3rdparty/SerialPort/posix_qextserialport.h b/3rdparty/SerialPort/posix_qextserialport.h
+deleted file mode 100644
+index efdee3c..0000000
+--- a/3rdparty/SerialPort/posix_qextserialport.h
++++ /dev/null
+@@ -1,56 +0,0 @@
+-
+-#ifndef _POSIX_QEXTSERIALPORT_H_
+-#define _POSIX_QEXTSERIALPORT_H_
+-
+-#include <stdio.h>
+-#include <termios.h>
+-#include <errno.h>
+-#include <unistd.h>
+-#include <sys/time.h>
+-#include <sys/ioctl.h>
+-#include <sys/select.h>
+-#include "qextserialbase.h"
+-
+-class Posix_QextSerialPort:public QextSerialBase {
+-public:
+-	Posix_QextSerialPort();
+-	Posix_QextSerialPort(const Posix_QextSerialPort& s);
+-	Posix_QextSerialPort(const QString & name);
+-	Posix_QextSerialPort(const PortSettings& settings);
+-	Posix_QextSerialPort(const QString & name, const PortSettings& settings);
+-	Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
+-	virtual ~Posix_QextSerialPort();
+-	
+-	virtual void setBaudRate(BaudRateType);
+-	virtual void setDataBits(DataBitsType);
+-	virtual void setParity(ParityType);
+-	virtual void setStopBits(StopBitsType);
+-	virtual void setFlowControl(FlowType);
+-	virtual void setTimeout(ulong, ulong);
+-	
+-	virtual bool open(OpenMode mode=0);
+-	virtual void close();
+-	virtual void flush();
+-	
+-	virtual qint64 size() const;
+-	virtual qint64 bytesAvailable();
+-	
+-	virtual void ungetChar(char c);
+-	
+-	virtual void translateError(ulong error);
+-	
+-	virtual void setDtr(bool set=true);
+-	virtual void setRts(bool set=true);
+-	virtual ulong lineStatus();
+-	
+-protected:
+-	QFile* Posix_File;
+-	struct termios Posix_CommConfig;
+-	struct timeval Posix_Timeout;
+-	struct timeval Posix_Copy_Timeout;
+-	
+-	virtual qint64 readData(char * data, qint64 maxSize);
+-	virtual qint64 writeData(const char * data, qint64 maxSize);
+-};
+-
+-#endif
+diff --git a/3rdparty/SerialPort/qextserialbase.cpp b/3rdparty/SerialPort/qextserialbase.cpp
+deleted file mode 100644
+index 3ea2561..0000000
+--- a/3rdparty/SerialPort/qextserialbase.cpp
++++ /dev/null
+@@ -1,250 +0,0 @@
+-
+-#include "qextserialbase.h"
+-
+-/*!
+-\class QextSerialBase
+-\version 1.0.0
+-\author Stefan Sander
+-
+-A common base class for Win_QextSerialBase, Posix_QextSerialBase and QextSerialPort.
+-*/
+-#ifdef QT_THREAD_SUPPORT
+-QMutex* QextSerialBase::mutex=NULL;
+-unsigned long QextSerialBase::refCount=0;
+-#endif
+-
+-/*!
+-\fn QextSerialBase::QextSerialBase()
+-Default constructor.
+-*/
+-QextSerialBase::QextSerialBase()
+- : QIODevice()
+-{
+-
+-#ifdef _TTY_WIN_
+-    setPortName("COM1");
+-
+-#elif defined(_TTY_IRIX_)
+-    setPortName("/dev/ttyf1");
+-
+-#elif defined(_TTY_HPUX_)
+-    setPortName("/dev/tty1p0");
+-
+-#elif defined(_TTY_SUN_)
+-    setPortName("/dev/ttya");
+-
+-#elif defined(_TTY_DIGITAL_)
+-    setPortName("/dev/tty01");
+-
+-#elif defined(_TTY_FREEBSD_)
+-    setPortName("/dev/ttyd1");
+-
+-#else
+-    setPortName("/dev/ttyS0");
+-#endif
+-
+-    construct();
+-}
+-
+-/*!
+-\fn QextSerialBase::QextSerialBase(const QString & name)
+-Construct a port and assign it to the device specified by the name parameter.
+-*/
+-QextSerialBase::QextSerialBase(const QString & name)
+- : QIODevice()
+-{
+-    setPortName(name);
+-    construct();
+-}
+-
+-/*!
+-\fn QextSerialBase::~QextSerialBase()
+-Standard destructor.
+-*/
+-QextSerialBase::~QextSerialBase()
+-{
+-
+-#ifdef QT_THREAD_SUPPORT
+-    refCount--;
+-    if (mutex && refCount==0) {
+-        delete mutex;
+-        mutex=NULL;
+-    }
+-#endif
+-
+-}
+-
+-/*!
+-\fn void QextSerialBase::construct()
+-Common constructor function for setting up default port settings.
+-(9600 Baud, 8N1, no flow control where supported, otherwise no flow control, and 20 ms timeout).
+-*/
+-void QextSerialBase::construct()
+-{
+-    Settings.BaudRate=BAUD9600;
+-    Settings.DataBits=DATA_8;
+-    Settings.Parity=PAR_NONE;
+-    Settings.StopBits=STOP_1;
+-    Settings.FlowControl=FLOW_OFF;
+-    Settings.Timeout_Sec=0;
+-    Settings.Timeout_Millisec=20;
+-
+-#ifdef QT_THREAD_SUPPORT
+-    if (!mutex) {
+-        mutex=new QMutex( QMutex::Recursive );
+-    }
+-    refCount++;
+-#endif
+-
+-	setOpenMode(QIODevice::NotOpen);
+-}
+-
+-/*!
+-\fn void QextSerialBase::setPortName(const QString & name)
+-Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
+-*/
+-void QextSerialBase::setPortName(const QString & name)
+-{
+-    port = name;
+-}
+-
+-/*!
+-\fn QString QextSerialBase::portName() const
+-Returns the name set by setPortName().
+-*/
+-QString QextSerialBase::portName() const
+-{
+-    return port;
+-}
+-
+-/*!
+-\fn BaudRateType QextSerialBase::baudRate(void) const
+-Returns the baud rate of the serial port.  For a list of possible return values see
+-the definition of the enum BaudRateType.
+-*/
+-BaudRateType QextSerialBase::baudRate(void) const
+-{
+-    return Settings.BaudRate;
+-}
+-
+-/*!
+-\fn DataBitsType QextSerialBase::dataBits() const
+-Returns the number of data bits used by the port.  For a list of possible values returned by
+-this function, see the definition of the enum DataBitsType.
+-*/
+-DataBitsType QextSerialBase::dataBits() const
+-{
+-    return Settings.DataBits;
+-}
+-
+-/*!
+-\fn ParityType QextSerialBase::parity() const
+-Returns the type of parity used by the port.  For a list of possible values returned by
+-this function, see the definition of the enum ParityType.
+-*/
+-ParityType QextSerialBase::parity() const
+-{
+-    return Settings.Parity;
+-}
+-
+-/*!
+-\fn StopBitsType QextSerialBase::stopBits() const
+-Returns the number of stop bits used by the port.  For a list of possible return values, see
+-the definition of the enum StopBitsType.
+-*/
+-StopBitsType QextSerialBase::stopBits() const
+-{
+-    return Settings.StopBits;
+-}
+-
+-/*!
+-\fn FlowType QextSerialBase::flowControl() const
+-Returns the type of flow control used by the port.  For a list of possible values returned
+-by this function, see the definition of the enum FlowType.
+-*/
+-FlowType QextSerialBase::flowControl() const
+-{
+-    return Settings.FlowControl;
+-}
+-
+-/*!
+-\fn bool QextSerialBase::isSequential() const
+-Returns true if device is sequential, otherwise returns false. Serial port is sequential device
+-so this function always returns true. Check QIODevice::isSequential() documentation for more 
+-information.
+-*/
+-bool QextSerialBase::isSequential() const
+-{
+-	return true;
+-}
+-
+-/*!
+-\fn bool QextSerialBase::atEnd() const
+-This function will return true if the input buffer is empty (or on error), and false otherwise.
+-Call QextSerialBase::lastError() for error information.
+-*/
+-bool QextSerialBase::atEnd() const
+-{
+-    if (size()) {
+-        return true;
+-    }
+-    return false;
+-}
+-
+-/*!
+-\fn qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
+-This function will read a line of buffered input from the port, stopping when either maxSize bytes
+-have been read, the port has no more data available, or a newline is encountered.
+-The value returned is the length of the string that was read.
+-*/
+-qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
+-{
+-    qint64 numBytes = bytesAvailable();
+-    char* pData = data;
+-
+-	if (maxSize < 2)	//maxSize must be larger than 1
+-		return -1;
+-
+-    /*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
+-    while (pData<(data+numBytes) && --maxSize) {
+-        readData(pData, 1);
+-        if (*pData++ == '\n') {
+-            break;
+-        }
+-    }
+-    *pData='\0';
+-
+-    /*return size of data read*/
+-    return (pData-data);
+-}
+-
+-/*!
+-\fn ulong QextSerialBase::lastError() const
+-Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port
+-operation was successful.  Possible error codes are:
+-
+-\verbatim
+-Error                           Explanation
+----------------------------     -------------------------------------------------------------
+-E_NO_ERROR                      No Error has occured
+-E_INVALID_FD                    Invalid file descriptor (port was not opened correctly)
+-E_NO_MEMORY                     Unable to allocate memory tables (POSIX)
+-E_CAUGHT_NON_BLOCKED_SIGNAL     Caught a non-blocked signal (POSIX)
+-E_PORT_TIMEOUT                  Operation timed out (POSIX)
+-E_INVALID_DEVICE                The file opened by the port is not a character device (POSIX)
+-E_BREAK_CONDITION               The port detected a break condition
+-E_FRAMING_ERROR                 The port detected a framing error
+-                                (usually caused by incorrect baud rate settings)
+-E_IO_ERROR                      There was an I/O error while communicating with the port
+-E_BUFFER_OVERRUN                Character buffer overrun
+-E_RECEIVE_OVERFLOW              Receive buffer overflow
+-E_RECEIVE_PARITY_ERROR          The port detected a parity error in the received data
+-E_TRANSMIT_OVERFLOW             Transmit buffer overflow
+-E_READ_FAILED                   General read operation failure
+-E_WRITE_FAILED                  General write operation failure
+-\endverbatim
+-*/
+-ulong QextSerialBase::lastError() const
+-{
+-    return lastErr;
+-}
+diff --git a/3rdparty/SerialPort/qextserialbase.h b/3rdparty/SerialPort/qextserialbase.h
+deleted file mode 100644
+index 1af6575..0000000
+--- a/3rdparty/SerialPort/qextserialbase.h
++++ /dev/null
+@@ -1,196 +0,0 @@
+-
+-#ifndef _QEXTSERIALBASE_H_
+-#define _QEXTSERIALBASE_H_
+-
+-#include <QIODevice>
+-#include <QFile>
+-
+-#ifdef QT_THREAD_SUPPORT
+-#include <QThread>
+-#include <QMutex>
+-#endif
+-
+-/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
+-#ifdef _TTY_NOWARN_
+-#define _TTY_NOWARN_PORT_
+-#endif
+-
+-/*macros for thread support*/
+-#ifdef QT_THREAD_SUPPORT
+-#define LOCK_MUTEX() mutex->lock()
+-#define UNLOCK_MUTEX() mutex->unlock()
+-#else
+-#define LOCK_MUTEX()
+-#define UNLOCK_MUTEX()
+-#endif
+-
+-/*macros for warning messages*/
+-#ifdef _TTY_NOWARN_PORT_
+-#define TTY_PORTABILITY_WARNING(s)
+-#else
+-#define TTY_PORTABILITY_WARNING(s) qWarning(s)
+-#endif
+-#ifdef _TTY_NOWARN_
+-#define TTY_WARNING(s)
+-#else
+-#define TTY_WARNING(s) qWarning(s)
+-#endif
+-
+-
+-/*line status constants*/
+-#define LS_CTS  0x01
+-#define LS_DSR  0x02
+-#define LS_DCD  0x04
+-#define LS_RI   0x08
+-#define LS_RTS  0x10
+-#define LS_DTR  0x20
+-#define LS_ST   0x40
+-#define LS_SR   0x80
+-
+-/*error constants*/
+-#define E_NO_ERROR                   0
+-#define E_INVALID_FD                 1
+-#define E_NO_MEMORY                  2
+-#define E_CAUGHT_NON_BLOCKED_SIGNAL  3
+-#define E_PORT_TIMEOUT               4
+-#define E_INVALID_DEVICE             5
+-#define E_BREAK_CONDITION            6
+-#define E_FRAMING_ERROR              7
+-#define E_IO_ERROR                   8
+-#define E_BUFFER_OVERRUN             9
+-#define E_RECEIVE_OVERFLOW          10
+-#define E_RECEIVE_PARITY_ERROR      11
+-#define E_TRANSMIT_OVERFLOW         12
+-#define E_READ_FAILED               13
+-#define E_WRITE_FAILED              14
+-
+-/*enums for port settings*/
+-enum NamingConvention {
+-    WIN_NAMES,
+-    IRIX_NAMES,
+-    HPUX_NAMES,
+-    SUN_NAMES,
+-    DIGITAL_NAMES,
+-    FREEBSD_NAMES,
+-    LINUX_NAMES
+-};
+-
+-enum BaudRateType {
+-    BAUD50,                //POSIX ONLY
+-    BAUD75,                //POSIX ONLY
+-    BAUD110,
+-    BAUD134,               //POSIX ONLY
+-    BAUD150,               //POSIX ONLY
+-    BAUD200,               //POSIX ONLY
+-    BAUD300,
+-    BAUD600,
+-    BAUD1200,
+-    BAUD1800,              //POSIX ONLY
+-    BAUD2400,
+-    BAUD4800,
+-    BAUD9600,
+-    BAUD14400,             //WINDOWS ONLY
+-    BAUD19200,
+-    BAUD38400,
+-    BAUD56000,             //WINDOWS ONLY
+-    BAUD57600,
+-    BAUD76800,             //POSIX ONLY
+-    BAUD115200,
+-    BAUD128000,            //WINDOWS ONLY
+-    BAUD256000             //WINDOWS ONLY
+-};
+-
+-enum DataBitsType {
+-    DATA_5,
+-    DATA_6,
+-    DATA_7,
+-    DATA_8
+-};
+-
+-enum ParityType {
+-    PAR_NONE,
+-    PAR_ODD,
+-    PAR_EVEN,
+-    PAR_MARK,               //WINDOWS ONLY
+-    PAR_SPACE
+-};
+-
+-enum StopBitsType {
+-    STOP_1,
+-    STOP_1_5,               //WINDOWS ONLY
+-    STOP_2
+-};
+-
+-enum FlowType {
+-    FLOW_OFF,
+-    FLOW_HARDWARE,
+-    FLOW_XONXOFF
+-};
+-
+-/*structure to contain port settings*/
+-struct PortSettings {
+-    BaudRateType BaudRate;
+-    DataBitsType DataBits;
+-    ParityType Parity;
+-    StopBitsType StopBits;
+-    FlowType FlowControl;
+-    ulong Timeout_Sec;
+-    ulong Timeout_Millisec;
+-};
+-
+-class QextSerialBase : public QIODevice {
+-public:
+-    QextSerialBase();
+-    QextSerialBase(const QString & name);
+-    virtual ~QextSerialBase();
+-    virtual void construct();
+-    virtual void setPortName(const QString & name);
+-    virtual QString portName() const;
+-
+-    virtual void setBaudRate(BaudRateType)=0;
+-    virtual BaudRateType baudRate() const;
+-    virtual void setDataBits(DataBitsType)=0;
+-    virtual DataBitsType dataBits() const;
+-    virtual void setParity(ParityType)=0;
+-    virtual ParityType parity() const;
+-    virtual void setStopBits(StopBitsType)=0;
+-    virtual StopBitsType stopBits() const;
+-    virtual void setFlowControl(FlowType)=0;
+-    virtual FlowType flowControl() const;
+-    virtual void setTimeout(ulong, ulong)=0;
+-
+-    virtual bool open(OpenMode mode=0)=0;
+-    virtual bool isSequential() const;
+-    virtual void close()=0;
+-    virtual void flush()=0;
+-
+-    virtual qint64 size() const=0;
+-    virtual qint64 bytesAvailable()=0;
+-    virtual bool atEnd() const;
+-
+-    virtual void ungetChar(char c)=0;
+-    virtual qint64 readLine(char * data, qint64 maxSize);
+-
+-    virtual ulong lastError() const;
+-    virtual void translateError(ulong error)=0;
+-
+-    virtual void setDtr(bool set=true)=0;
+-    virtual void setRts(bool set=true)=0;
+-    virtual ulong lineStatus()=0;
+-
+-protected:
+-    QString port;
+-    PortSettings Settings;
+-    ulong lastErr;
+-
+-#ifdef QT_THREAD_SUPPORT
+-    static QMutex* mutex;
+-    static ulong refCount;
+-#endif
+-
+-    virtual qint64 readData(char * data, qint64 maxSize)=0;
+-    virtual qint64 writeData(const char * data, qint64 maxSize)=0;
+-
+-};
+-
+-#endif
+diff --git a/3rdparty/SerialPort/qextserialport.cpp b/3rdparty/SerialPort/qextserialport.cpp
+deleted file mode 100644
+index 9d3fff4..0000000
+--- a/3rdparty/SerialPort/qextserialport.cpp
++++ /dev/null
+@@ -1,98 +0,0 @@
+-
+-/*!
+-\class QextSerialPort
+-\version 1.0.0
+-\author Stefan Sander
+-
+-A cross-platform serial port class.
+-This class encapsulates a serial port on both POSIX and Windows systems.  The user will be
+-notified of errors and possible portability conflicts at run-time by default - this behavior can
+-be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn
+-off portability warnings) in the project.
+-
+-\note
+-On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
+-select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
+-make no guarantees as to the quality of POSIX support under NT/2000 however.
+-
+-*/
+-
+-#include <stdio.h>
+-#include "qextserialport.h"
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort()
+-Default constructor.  Note that the naming convention used by a QextSerialPort constructed with
+-this constructor will be determined by #defined constants, or lack thereof - the default behavior
+-is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:
+-
+-\verbatim
+-
+-Constant         Used By         Naming Convention
+-----------       -------------   ------------------------
+-_TTY_WIN_        Windows         COM1, COM2
+-_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
+-_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
+-_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
+-_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
+-_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
+-_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
+-<none>           Linux           /dev/ttyS0, /dev/ttyS1
+-\endverbatim
+-
+-The object will be associated with the first port in the system, e.g. COM1 on Windows systems.
+-See the other constructors if you need to use a port other than the first.
+-*/
+-QextSerialPort::QextSerialPort()
+- : QextBaseType()
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(const QString & name)
+-Constructs a serial port attached to the port specified by name.
+-name is the name of the device, which is windowsystem-specific,
+-e.g."COM1" or "/dev/ttyS0".
+-*/
+-QextSerialPort::QextSerialPort(const QString & name)
+- : QextBaseType(name)
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(PortSettings const& settings)
+-Constructs a port with default name and settings specified by the settings parameter.
+-*/
+-QextSerialPort::QextSerialPort(PortSettings const& settings)
+- : QextBaseType(settings)
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
+-Constructs a port with the name and settings specified.
+-*/
+-QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
+- : QextBaseType(name, settings)
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(const QextSerialPort& s)
+-Copy constructor.
+-*/
+-QextSerialPort::QextSerialPort(const QextSerialPort& s)
+- : QextBaseType(s)
+-{}
+-
+-/*!
+-\fn QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
+-Overrides the = operator.
+-*/
+-QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
+-{
+-    return (QextSerialPort&)QextBaseType::operator=(s);
+-}
+-
+-/*!
+-\fn QextSerialPort::~QextSerialPort()
+-Standard destructor.
+-*/
+-QextSerialPort::~QextSerialPort()
+-{}
+diff --git a/3rdparty/SerialPort/qextserialport.h b/3rdparty/SerialPort/qextserialport.h
+deleted file mode 100644
+index 2ae5560..0000000
+--- a/3rdparty/SerialPort/qextserialport.h
++++ /dev/null
+@@ -1,27 +0,0 @@
+-
+-#ifndef _QEXTSERIALPORT_H_
+-#define _QEXTSERIALPORT_H_
+-
+-/*POSIX CODE*/
+-#ifdef _TTY_POSIX_
+-#include "posix_qextserialport.h"
+-#define QextBaseType Posix_QextSerialPort
+-
+-/*MS WINDOWS CODE*/
+-#else
+-#include "win_qextserialport.h"
+-#define QextBaseType Win_QextSerialPort
+-#endif
+-
+-class QextSerialPort: public QextBaseType {
+-public:
+-    QextSerialPort();
+-    QextSerialPort(const QString & name);
+-    QextSerialPort(PortSettings const& s);
+-    QextSerialPort(const QString & name, PortSettings const& s);
+-    QextSerialPort(const QextSerialPort& s);
+-    QextSerialPort& operator=(const QextSerialPort&);
+-    virtual ~QextSerialPort();
+-};
+-
+-#endif
+diff --git a/3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp b/3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp
+new file mode 100644
+index 0000000..0982349
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp
+@@ -0,0 +1,1114 @@
++
++/*!
++		\class Posix_QextSerialPort
++		\version 1.0.0
++		\author Stefan Sander
++
++A cross-platform serial port class.
++		This class encapsulates the POSIX portion of QextSerialPort.  The user will be notified of errors
++		and possible portability conflicts at run-time by default - this behavior can be turned off by
++		defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off portability
++		warnings) in the project.  Note that _TTY_NOWARN_ will also turn off portability warnings.
++*/
++
++#include <stdio.h>
++#include "posix_qextserialport.h"
++
++/*!
++		\fn Posix_QextSerialPort::Posix_QextSerialPort()
++			Default constructor.  Note that the name of the device used by a QextSerialPort constructed with
++			this constructor will be determined by #defined constants, or lack thereof - the default behavior
++			is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:
++
++\verbatim
++
++Constant         Used By         Naming Convention
++		----------       -------------   ------------------------
++		_TTY_WIN_        Windows         COM1, COM2
++		_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
++		_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
++		_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
++		_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
++		_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
++		_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
++		<none>           Linux           /dev/ttyS0, /dev/ttyS1
++		\endverbatim
++
++This constructor assigns the device name to the name of the first port on the specified system.
++		See the other constructors if you need to open a different port.
++*/
++Posix_QextSerialPort::Posix_QextSerialPort()
++	: QextSerialBase()
++{
++	Posix_File=new QFile();
++}
++
++/*!
++		\fn Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort&)
++			Copy constructor.
++*/
++Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort& s)
++	: QextSerialBase(s.port)
++{
++	setOpenMode(s.openMode());
++	port = s.port;
++	Settings.BaudRate=s.Settings.BaudRate;
++	Settings.DataBits=s.Settings.DataBits;
++	Settings.Parity=s.Settings.Parity;
++	Settings.StopBits=s.Settings.StopBits;
++	Settings.FlowControl=s.Settings.FlowControl;
++	lastErr=s.lastErr;
++	
++	Posix_File=new QFile();
++	Posix_File=s.Posix_File;
++	memcpy(&Posix_Timeout, &s.Posix_Timeout, sizeof(struct timeval));
++	memcpy(&Posix_Copy_Timeout, &s.Posix_Copy_Timeout, sizeof(struct timeval));
++	memcpy(&Posix_CommConfig, &s.Posix_CommConfig, sizeof(struct termios));
++}
++
++/*!
++		\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name)
++			Constructs a serial port attached to the port specified by name.
++			name is the name of the device, which is windowsystem-specific,
++			e.g."COM1" or "/dev/ttyS0".
++*/
++Posix_QextSerialPort::Posix_QextSerialPort(const QString & name)
++	: QextSerialBase(name)
++{
++	Posix_File=new QFile();
++}
++
++/*!
++		\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
++			Constructs a port with default name and specified settings.
++*/
++Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
++	: QextSerialBase()
++{
++	setBaudRate(settings.BaudRate);
++	setDataBits(settings.DataBits);
++	setParity(settings.Parity);
++	setStopBits(settings.StopBits);
++	setFlowControl(settings.FlowControl);
++	
++	Posix_File=new QFile();
++	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
++}
++
++/*!
++		\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings)
++			Constructs a port with specified name and settings.
++*/
++Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings)
++	: QextSerialBase(name)
++{
++	setBaudRate(settings.BaudRate);
++	setDataBits(settings.DataBits);
++	setParity(settings.Parity);
++	setStopBits(settings.StopBits);
++	setFlowControl(settings.FlowControl);
++	
++	Posix_File=new QFile();
++	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
++}
++
++/*!
++		\fn Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
++			Override the = operator.
++*/
++Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
++{
++	setOpenMode(s.openMode());
++	port = s.port;
++	Settings.BaudRate=s.Settings.BaudRate;
++	Settings.DataBits=s.Settings.DataBits;
++	Settings.Parity=s.Settings.Parity;
++	Settings.StopBits=s.Settings.StopBits;
++	Settings.FlowControl=s.Settings.FlowControl;
++	lastErr=s.lastErr;
++	
++	Posix_File=s.Posix_File;
++	memcpy(&Posix_Timeout, &(s.Posix_Timeout), sizeof(struct timeval));
++	memcpy(&Posix_Copy_Timeout, &(s.Posix_Copy_Timeout), sizeof(struct timeval));
++	memcpy(&Posix_CommConfig, &(s.Posix_CommConfig), sizeof(struct termios));
++	return *this;
++}
++
++/*!
++		\fn Posix_QextSerialPort::~Posix_QextSerialPort()
++			Standard destructor.
++*/
++Posix_QextSerialPort::~Posix_QextSerialPort()
++{
++	if (isOpen()) {
++		close();
++	}
++	Posix_File->close();
++	delete Posix_File;
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
++			Sets the baud rate of the serial port.  Note that not all rates are applicable on
++			all platforms.  The following table shows translations of the various baud rate
++			constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
++			are speeds that are usable on both Windows and POSIX.
++
++\note
++		BAUD76800 may not be supported on all POSIX systems.  SGI/IRIX systems do not support
++		BAUD1800.
++
++\verbatim
++
++RATE          Windows Speed   POSIX Speed
++		-----------   -------------   -----------
++		BAUD50                 110          50
++		BAUD75                 110          75
++		*BAUD110                110         110
++		BAUD134                110         134.5
++		BAUD150                110         150
++		BAUD200                110         200
++		*BAUD300                300         300
++		*BAUD600                600         600
++		*BAUD1200              1200        1200
++		BAUD1800              1200        1800
++		*BAUD2400              2400        2400
++		*BAUD4800              4800        4800
++		*BAUD9600              9600        9600
++		BAUD14400            14400        9600
++		*BAUD19200            19200       19200
++		*BAUD38400            38400       38400
++		BAUD56000            56000       38400
++		*BAUD57600            57600       57600
++		BAUD76800            57600       76800
++		*BAUD115200          115200      115200
++		BAUD128000          128000      115200
++		BAUD256000          256000      115200
++		\endverbatim
++*/
++void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
++{
++	LOCK_MUTEX();
++	if (Settings.BaudRate!=baudRate) {
++		switch (baudRate) {
++			case BAUD14400:
++				Settings.BaudRate=BAUD9600;
++				break;
++				
++			case BAUD56000:
++				Settings.BaudRate=BAUD38400;
++				break;
++				
++			case BAUD76800:
++				
++				#ifndef B76800
++							Settings.BaudRate=BAUD57600;
++				#else
++				Settings.BaudRate=baudRate;
++				#endif
++							break;
++				
++			case BAUD128000:
++			case BAUD256000:
++				Settings.BaudRate=BAUD115200;
++				break;
++				
++			default:
++				Settings.BaudRate=baudRate;
++				break;
++		}
++	}
++	if (isOpen()) {
++		switch (baudRate) {
++				
++				/*50 baud*/
++			case BAUD50:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 50 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B50;
++				#else
++				cfsetispeed(&Posix_CommConfig, B50);
++				cfsetospeed(&Posix_CommConfig, B50);
++				#endif
++							break;
++				
++				/*75 baud*/
++			case BAUD75:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 75 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B75;
++				#else
++				cfsetispeed(&Posix_CommConfig, B75);
++				cfsetospeed(&Posix_CommConfig, B75);
++				#endif
++							break;
++				
++				/*110 baud*/
++			case BAUD110:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B110;
++				#else
++				cfsetispeed(&Posix_CommConfig, B110);
++				cfsetospeed(&Posix_CommConfig, B110);
++				#endif
++							break;
++				
++				/*134.5 baud*/
++			case BAUD134:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 134.5 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B134;
++				#else
++				cfsetispeed(&Posix_CommConfig, B134);
++				cfsetospeed(&Posix_CommConfig, B134);
++				#endif
++							break;
++				
++				/*150 baud*/
++			case BAUD150:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 150 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B150;
++				#else
++				cfsetispeed(&Posix_CommConfig, B150);
++				cfsetospeed(&Posix_CommConfig, B150);
++				#endif
++							break;
++				
++				/*200 baud*/
++			case BAUD200:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 200 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B200;
++				#else
++				cfsetispeed(&Posix_CommConfig, B200);
++				cfsetospeed(&Posix_CommConfig, B200);
++				#endif
++							break;
++				
++				/*300 baud*/
++			case BAUD300:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B300;
++				#else
++				cfsetispeed(&Posix_CommConfig, B300);
++				cfsetospeed(&Posix_CommConfig, B300);
++				#endif
++							break;
++				
++				/*600 baud*/
++			case BAUD600:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B600;
++				#else
++				cfsetispeed(&Posix_CommConfig, B600);
++				cfsetospeed(&Posix_CommConfig, B600);
++				#endif
++							break;
++				
++				/*1200 baud*/
++			case BAUD1200:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B1200;
++				#else
++				cfsetispeed(&Posix_CommConfig, B1200);
++				cfsetospeed(&Posix_CommConfig, B1200);
++				#endif
++							break;
++				
++				/*1800 baud*/
++			case BAUD1800:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and IRIX do not support 1800 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B1800;
++				#else
++				cfsetispeed(&Posix_CommConfig, B1800);
++				cfsetospeed(&Posix_CommConfig, B1800);
++				#endif
++							break;
++				
++				/*2400 baud*/
++			case BAUD2400:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B2400;
++				#else
++				cfsetispeed(&Posix_CommConfig, B2400);
++				cfsetospeed(&Posix_CommConfig, B2400);
++				#endif
++							break;
++				
++				/*4800 baud*/
++			case BAUD4800:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B4800;
++				#else
++				cfsetispeed(&Posix_CommConfig, B4800);
++				cfsetospeed(&Posix_CommConfig, B4800);
++				#endif
++							break;
++				
++				/*9600 baud*/
++			case BAUD9600:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B9600;
++				#else
++				cfsetispeed(&Posix_CommConfig, B9600);
++				cfsetospeed(&Posix_CommConfig, B9600);
++				#endif
++							break;
++				
++				/*14400 baud*/
++			case BAUD14400:
++				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 14400 baud operation.  Switching to 9600 baud.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B9600;
++				#else
++				cfsetispeed(&Posix_CommConfig, B9600);
++				cfsetospeed(&Posix_CommConfig, B9600);
++				#endif
++							break;
++				
++				/*19200 baud*/
++			case BAUD19200:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B19200;
++				#else
++				cfsetispeed(&Posix_CommConfig, B19200);
++				cfsetospeed(&Posix_CommConfig, B19200);
++				#endif
++							break;
++				
++				/*38400 baud*/
++			case BAUD38400:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B38400;
++				#else
++				cfsetispeed(&Posix_CommConfig, B38400);
++				cfsetospeed(&Posix_CommConfig, B38400);
++				#endif
++							break;
++				
++				/*56000 baud*/
++			case BAUD56000:
++				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 56000 baud operation.  Switching to 38400 baud.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B38400;
++				#else
++				cfsetispeed(&Posix_CommConfig, B38400);
++				cfsetospeed(&Posix_CommConfig, B38400);
++				#endif
++							break;
++				
++				/*57600 baud*/
++			case BAUD57600:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B57600;
++				#else
++				cfsetispeed(&Posix_CommConfig, B57600);
++				cfsetospeed(&Posix_CommConfig, B57600);
++				#endif
++							break;
++				
++				/*76800 baud*/
++			case BAUD76800:
++				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and some POSIX systems do not support 76800 baud operation.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				
++				#ifdef B76800
++							Posix_CommConfig.c_cflag|=B76800;
++				#else
++				TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
++				Posix_CommConfig.c_cflag|=B57600;
++				#endif //B76800
++				#else  //CBAUD
++				#ifdef B76800
++							cfsetispeed(&Posix_CommConfig, B76800);
++				cfsetospeed(&Posix_CommConfig, B76800);
++				#else
++				TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
++				cfsetispeed(&Posix_CommConfig, B57600);
++				cfsetospeed(&Posix_CommConfig, B57600);
++				#endif //B76800
++				#endif //CBAUD
++							break;
++				
++				/*115200 baud*/
++			case BAUD115200:
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B115200;
++				#else
++				cfsetispeed(&Posix_CommConfig, B115200);
++				cfsetospeed(&Posix_CommConfig, B115200);
++				#endif
++							break;
++				
++				/*128000 baud*/
++			case BAUD128000:
++				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 128000 baud operation.  Switching to 115200 baud.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B115200;
++				#else
++				cfsetispeed(&Posix_CommConfig, B115200);
++				cfsetospeed(&Posix_CommConfig, B115200);
++				#endif
++							break;
++				
++				/*256000 baud*/
++			case BAUD256000:
++				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 256000 baud operation.  Switching to 115200 baud.");
++				#ifdef CBAUD
++							Posix_CommConfig.c_cflag&=(~CBAUD);
++				Posix_CommConfig.c_cflag|=B115200;
++				#else
++				cfsetispeed(&Posix_CommConfig, B115200);
++				cfsetospeed(&Posix_CommConfig, B115200);
++				#endif
++							break;
++			}
++			tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setDataBits(DataBitsType dataBits)
++			Sets the number of data bits used by the serial port.  Possible values of dataBits are:
++\verbatim
++		DATA_5      5 data bits
++		DATA_6      6 data bits
++		DATA_7      7 data bits
++		DATA_8      8 data bits
++		\endverbatim
++
++\note
++		This function is subject to the following restrictions:
++\par
++		5 data bits cannot be used with 2 stop bits.
++		\par
++		8 data bits cannot be used with space parity on POSIX systems.
++
++*/
++void Posix_QextSerialPort::setDataBits(DataBitsType dataBits)
++{
++	LOCK_MUTEX();
++	if (Settings.DataBits!=dataBits) {
++		if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
++				(Settings.StopBits==STOP_1_5 && dataBits!=DATA_5) ||
++				(Settings.Parity==PAR_SPACE && dataBits==DATA_8)) {
++				}
++		else {
++			Settings.DataBits=dataBits;
++		}
++	}
++	if (isOpen()) {
++		switch(dataBits) {
++				
++				/*5 data bits*/
++			case DATA_5:
++				if (Settings.StopBits==STOP_2) {
++					TTY_WARNING("Posix_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
++				}
++				else {
++					Settings.DataBits=dataBits;
++					Posix_CommConfig.c_cflag&=(~CSIZE);
++					Posix_CommConfig.c_cflag|=CS5;
++					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				}
++				break;
++				
++				/*6 data bits*/
++			case DATA_6:
++				if (Settings.StopBits==STOP_1_5) {
++					TTY_WARNING("Posix_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
++				}
++				else {
++					Settings.DataBits=dataBits;
++					Posix_CommConfig.c_cflag&=(~CSIZE);
++					Posix_CommConfig.c_cflag|=CS6;
++					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				}
++				break;
++				
++				/*7 data bits*/
++			case DATA_7:
++				if (Settings.StopBits==STOP_1_5) {
++					TTY_WARNING("Posix_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
++				}
++				else {
++					Settings.DataBits=dataBits;
++					Posix_CommConfig.c_cflag&=(~CSIZE);
++					Posix_CommConfig.c_cflag|=CS7;
++					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				}
++				break;
++				
++				/*8 data bits*/
++			case DATA_8:
++				if (Settings.StopBits==STOP_1_5) {
++					TTY_WARNING("Posix_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
++				}
++				else {
++					Settings.DataBits=dataBits;
++					Posix_CommConfig.c_cflag&=(~CSIZE);
++					Posix_CommConfig.c_cflag|=CS8;
++					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				}
++				break;
++			}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setParity(ParityType parity)
++			Sets the parity associated with the serial port.  The possible values of parity are:
++\verbatim
++		PAR_SPACE       Space Parity
++		PAR_MARK        Mark Parity
++		PAR_NONE        No Parity
++		PAR_EVEN        Even Parity
++		PAR_ODD         Odd Parity
++		\endverbatim
++
++\note
++		This function is subject to the following limitations:
++\par
++		POSIX systems do not support mark parity.
++		\par
++		POSIX systems support space parity only if tricked into doing so, and only with
++		fewer than 8 data bits.  Use space parity very carefully with POSIX systems.
++
++*/
++void Posix_QextSerialPort::setParity(ParityType parity)
++{
++	LOCK_MUTEX();
++	if (Settings.Parity!=parity) {
++		if (parity==PAR_MARK || (parity==PAR_SPACE && Settings.DataBits==DATA_8)) {
++		}
++		else {
++			Settings.Parity=parity;
++		}
++	}
++	if (isOpen()) {
++		switch (parity) {
++				
++				/*space parity*/
++			case PAR_SPACE:
++				if (Settings.DataBits==DATA_8) {
++					TTY_PORTABILITY_WARNING("Posix_QextSerialPort:  Space parity is only supported in POSIX with 7 or fewer data bits");
++				}
++				else {
++					
++					/*space parity not directly supported - add an extra data bit to simulate it*/
++					Posix_CommConfig.c_cflag&=~(PARENB|CSIZE);
++				switch(Settings.DataBits) {
++					case DATA_5:
++						Settings.DataBits=DATA_6;
++						Posix_CommConfig.c_cflag|=CS6;
++						break;
++						
++					case DATA_6:
++						Settings.DataBits=DATA_7;
++						Posix_CommConfig.c_cflag|=CS7;
++						break;
++						
++					case DATA_7:
++						Settings.DataBits=DATA_8;
++						Posix_CommConfig.c_cflag|=CS8;
++						break;
++						
++					case DATA_8:
++						break;
++					}
++					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				}
++				break;
++				
++				/*mark parity - WINDOWS ONLY*/
++			case PAR_MARK:
++				TTY_WARNING("Posix_QextSerialPort: Mark parity is not supported by POSIX.");
++				break;
++				
++				/*no parity*/
++			case PAR_NONE:
++				Posix_CommConfig.c_cflag&=(~PARENB);
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++				
++				/*even parity*/
++			case PAR_EVEN:
++				Posix_CommConfig.c_cflag&=(~PARODD);
++				Posix_CommConfig.c_cflag|=PARENB;
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++				
++				/*odd parity*/
++			case PAR_ODD:
++				Posix_CommConfig.c_cflag|=(PARENB|PARODD);
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++			}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setStopBits(StopBitsType stopBits)
++			Sets the number of stop bits used by the serial port.  Possible values of stopBits are:
++\verbatim
++		STOP_1      1 stop bit
++		STOP_1_5    1.5 stop bits
++		STOP_2      2 stop bits
++		\endverbatim
++		\note
++		This function is subject to the following restrictions:
++\par
++		2 stop bits cannot be used with 5 data bits.
++		\par
++		POSIX does not support 1.5 stop bits.
++
++*/
++void Posix_QextSerialPort::setStopBits(StopBitsType stopBits)
++{
++	LOCK_MUTEX();
++	if (Settings.StopBits!=stopBits) {
++		if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) || stopBits==STOP_1_5) {}
++		else {
++			Settings.StopBits=stopBits;
++		}
++	}
++	if (isOpen()) {
++		switch (stopBits) {
++				
++				/*one stop bit*/
++			case STOP_1:
++				Settings.StopBits=stopBits;
++				Posix_CommConfig.c_cflag&=(~CSTOPB);
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++				
++				/*1.5 stop bits*/
++			case STOP_1_5:
++				TTY_WARNING("Posix_QextSerialPort: 1.5 stop bit operation is not supported by POSIX.");
++				break;
++				
++				/*two stop bits*/
++			case STOP_2:
++				if (Settings.DataBits==DATA_5) {
++					TTY_WARNING("Posix_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
++				}
++				else {
++					Settings.StopBits=stopBits;
++					Posix_CommConfig.c_cflag|=CSTOPB;
++					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				}
++				break;
++			}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setFlowControl(FlowType flow)
++			Sets the flow control used by the port.  Possible values of flow are:
++\verbatim
++		FLOW_OFF            No flow control
++		FLOW_HARDWARE       Hardware (RTS/CTS) flow control
++		FLOW_XONXOFF        Software (XON/XOFF) flow control
++		\endverbatim
++		\note
++		FLOW_HARDWARE may not be supported on all versions of UNIX.  In cases where it is
++		unsupported, FLOW_HARDWARE is the same as FLOW_OFF.
++
++*/
++void Posix_QextSerialPort::setFlowControl(FlowType flow)
++{
++	LOCK_MUTEX();
++	if (Settings.FlowControl!=flow) {
++		Settings.FlowControl=flow;
++	}
++	if (isOpen()) {
++		switch(flow) {
++				
++				/*no flow control*/
++			case FLOW_OFF:
++				Posix_CommConfig.c_cflag&=(~CRTSCTS);
++				Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++				
++				/*software (XON/XOFF) flow control*/
++			case FLOW_XONXOFF:
++				Posix_CommConfig.c_cflag&=(~CRTSCTS);
++				Posix_CommConfig.c_iflag|=(IXON|IXOFF|IXANY);
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++				
++			case FLOW_HARDWARE:
++				Posix_CommConfig.c_cflag|=CRTSCTS;
++				Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
++				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++				break;
++			}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec);
++Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.
++		Note that this is a per-character timeout, i.e. the port will wait this long for each
++		individual character, not for the whole read operation.  This timeout also applies to the
++		bytesWaiting() function.
++
++\note
++		POSIX does not support millisecond-level control for I/O timeout values.  Any
++		timeout set using this function will be set to the next lowest tenth of a second for
++		the purposes of detecting read or write timeouts.  For example a timeout of 550 milliseconds
++		will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and
++		writing the port.  However millisecond-level control is allowed by the select() system call,
++		so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for
++		the purpose of detecting available bytes in the read buffer.
++
++*/
++void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec)
++{
++	LOCK_MUTEX();
++	Settings.Timeout_Sec=sec;
++	Settings.Timeout_Millisec=millisec;
++	Posix_Copy_Timeout.tv_sec=sec;
++	Posix_Copy_Timeout.tv_usec=millisec;
++	if (isOpen()) {
++		tcgetattr(Posix_File->handle(), &Posix_CommConfig);
++		Posix_CommConfig.c_cc[VTIME]=sec*10+millisec/100;
++		tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn bool Posix_QextSerialPort::open(OpenMode mode)
++			Opens the serial port associated to this class.
++			This function has no effect if the port associated with the class is already open.
++			The port is also configured to the current settings, as stored in the Settings structure.
++*/
++bool Posix_QextSerialPort::open(OpenMode mode)
++{
++	LOCK_MUTEX();
++	if (mode == QIODevice::NotOpen)
++		return isOpen();
++	if (!isOpen()) {
++		/*open the port*/
++		Posix_File->setFileName(port);
++		if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
++			/*set open mode*/
++			QIODevice::open(mode);
++			
++			/*configure port settings*/
++			tcgetattr(Posix_File->handle(), &Posix_CommConfig);
++			
++			/*set up other port settings*/
++			Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
++			Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
++			Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
++			Posix_CommConfig.c_oflag&=(~OPOST);
++			Posix_CommConfig.c_cc[VMIN]=0;
++			Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
++			Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
++			Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
++			Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
++			Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
++			setBaudRate(Settings.BaudRate);
++			setDataBits(Settings.DataBits);
++			setParity(Settings.Parity);
++			setStopBits(Settings.StopBits);
++			setFlowControl(Settings.FlowControl);
++			setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
++			tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
++		} else {
++		}
++	}
++	UNLOCK_MUTEX();
++	return isOpen();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::close()
++			Closes a serial port.  This function has no effect if the serial port associated with the class
++			is not currently open.
++*/
++void Posix_QextSerialPort::close()
++{
++	LOCK_MUTEX();
++	Posix_File->close();
++	QIODevice::close();
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::flush()
++			Flushes all pending I/O to the serial port.  This function has no effect if the serial port
++			associated with the class is not currently open.
++*/
++void Posix_QextSerialPort::flush()
++{
++	LOCK_MUTEX();
++	if (isOpen()) {
++		Posix_File->flush();
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn qint64 Posix_QextSerialPort::size() const
++This function will return the number of bytes waiting in the receive queue of the serial port.
++		It is included primarily to provide a complete QIODevice interface, and will not record errors
++		in the lastErr member (because it is const).  This function is also not thread-safe - in
++		multithreading situations, use Posix_QextSerialPort::bytesWaiting() instead.
++*/
++qint64 Posix_QextSerialPort::size() const
++{
++	int numBytes;
++	if (ioctl(Posix_File->handle(), FIONREAD, &numBytes)<0) {
++		numBytes=0;
++	}
++	return (qint64)numBytes;
++}
++
++/*!
++		\fn qint64 Posix_QextSerialPort::bytesAvailable()
++			Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
++			the port is not currently open, or -1 on error.  Error information can be retrieved by calling
++			Posix_QextSerialPort::getLastError().
++*/
++qint64 Posix_QextSerialPort::bytesAvailable()
++{
++	LOCK_MUTEX();
++	if (isOpen()) {
++		int bytesQueued;
++		fd_set fileSet;
++		FD_ZERO(&fileSet);
++		FD_SET(Posix_File->handle(), &fileSet);
++		
++		/*on Linux systems the Posix_Timeout structure will be altered by the select() call.
++				Make sure we use the right timeout values*/
++		//memcpy(&Posix_Timeout, &Posix_Copy_Timeout, sizeof(struct timeval));
++		Posix_Timeout = Posix_Copy_Timeout;
++		int n=select(Posix_File->handle()+1, &fileSet, NULL, &fileSet, &Posix_Timeout);
++		if (!n) {
++			lastErr=E_PORT_TIMEOUT;
++			UNLOCK_MUTEX();
++			return -1;
++		}
++		if (n==-1 || ioctl(Posix_File->handle(), FIONREAD, &bytesQueued)==-1) {
++			translateError(errno);
++			UNLOCK_MUTEX();
++			return -1;
++		}
++		lastErr=E_NO_ERROR;
++		UNLOCK_MUTEX();
++		return bytesQueued + QIODevice::bytesAvailable();
++	}
++	UNLOCK_MUTEX();
++	return 0;
++}
++
++/*!
++		\fn void Posix_QextSerialPort::ungetChar(char)
++			This function is included to implement the full QIODevice interface, and currently has no
++			purpose within this class.  This function is meaningless on an unbuffered device and currently
++			only prints a warning message to that effect.
++*/
++void Posix_QextSerialPort::ungetChar(char)
++{
++	/*meaningless on unbuffered sequential device - return error and print a warning*/
++	TTY_WARNING("Posix_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
++}
++
++/*!
++		\fn void Posix_QextSerialPort::translateError(ulong error)
++			Translates a system-specific error code to a QextSerialPort error code.  Used internally.
++*/
++void Posix_QextSerialPort::translateError(ulong error)
++{
++	switch (error) {
++		case EBADF:
++		case ENOTTY:
++			lastErr=E_INVALID_FD;
++			break;
++			
++		case EINTR:
++			lastErr=E_CAUGHT_NON_BLOCKED_SIGNAL;
++			break;
++			
++		case ENOMEM:
++			lastErr=E_NO_MEMORY;
++			break;
++		}
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setDtr(bool set)
++			Sets DTR line to the requested state (high by default).  This function will have no effect if
++			the port associated with the class is not currently open.
++*/
++void Posix_QextSerialPort::setDtr(bool set)
++{
++	LOCK_MUTEX();
++	if (isOpen()) {
++		int status;
++		ioctl(Posix_File->handle(), TIOCMGET, &status);
++		if (set) {
++			status|=TIOCM_DTR;
++		}
++		else {
++			status&=~TIOCM_DTR;
++		}
++		ioctl(Posix_File->handle(), TIOCMSET, &status);
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Posix_QextSerialPort::setRts(bool set)
++			Sets RTS line to the requested state (high by default).  This function will have no effect if
++			the port associated with the class is not currently open.
++*/
++void Posix_QextSerialPort::setRts(bool set)
++{
++	LOCK_MUTEX();
++	if (isOpen()) {
++		int status;
++		ioctl(Posix_File->handle(), TIOCMGET, &status);
++		if (set) {
++			status|=TIOCM_RTS;
++		}
++		else {
++			status&=~TIOCM_RTS;
++		}
++		ioctl(Posix_File->handle(), TIOCMSET, &status);
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn unsigned long Posix_QextSerialPort::lineStatus()
++			returns the line status as stored by the port function.  This function will retrieve the states
++			of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
++			can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
++			long with specific bits indicating which lines are high.  The following constants should be used
++			to examine the states of individual lines:
++
++\verbatim
++		Mask        Line
++		------      ----
++		LS_CTS      CTS
++		LS_DSR      DSR
++		LS_DCD      DCD
++		LS_RI       RI
++		LS_RTS      RTS (POSIX only)
++			LS_DTR      DTR (POSIX only)
++				LS_ST       Secondary TXD (POSIX only)
++					LS_SR       Secondary RXD (POSIX only)
++						\endverbatim
++
++This function will return 0 if the port associated with the class is not currently open.
++*/
++unsigned long Posix_QextSerialPort::lineStatus()
++{
++	unsigned long Status=0, Temp=0;
++	LOCK_MUTEX();
++	if (isOpen()) {
++		ioctl(Posix_File->handle(), TIOCMGET, &Temp);
++		if (Temp&TIOCM_CTS) {
++			Status|=LS_CTS;
++		}
++		if (Temp&TIOCM_DSR) {
++			Status|=LS_DSR;
++		}
++		if (Temp&TIOCM_RI) {
++			Status|=LS_RI;
++		}
++		if (Temp&TIOCM_CD) {
++			Status|=LS_DCD;
++		}
++		if (Temp&TIOCM_DTR) {
++			Status|=LS_DTR;
++		}
++		if (Temp&TIOCM_RTS) {
++			Status|=LS_RTS;
++		}
++		if (Temp&TIOCM_ST) {
++			Status|=LS_ST;
++		}
++		if (Temp&TIOCM_SR) {
++			Status|=LS_SR;
++		}
++	}
++	UNLOCK_MUTEX();
++	return Status;
++}
++
++/*!
++		\fn qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize)
++			Reads a block of data from the serial port.  This function will read at most maxSize bytes from
++			the serial port and place them in the buffer pointed to by data.  Return value is the number of
++			bytes actually read, or -1 on error.
++
++\warning before calling this function ensure that serial port associated with this class
++		is currently open (use isOpen() function to check if port is open).
++*/
++qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize)
++{
++	LOCK_MUTEX();
++	int retVal=0;
++	retVal=Posix_File->read(data, maxSize);
++	if (retVal==-1)
++		lastErr=E_READ_FAILED;
++	UNLOCK_MUTEX();
++	
++	return retVal;
++}
++
++/*!
++		\fn qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize)
++			Writes a block of data to the serial port.  This function will write maxSize bytes
++			from the buffer pointed to by data to the serial port.  Return value is the number
++			of bytes actually written, or -1 on error.
++
++\warning before calling this function ensure that serial port associated with this class
++		is currently open (use isOpen() function to check if port is open).
++*/
++qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize)
++{
++	LOCK_MUTEX();
++	int retVal=0;
++	retVal=Posix_File->write(data, maxSize);
++	if (retVal==-1)
++		lastErr=E_WRITE_FAILED;
++	UNLOCK_MUTEX();
++	
++	flush();
++	return retVal;
++}
+diff --git a/3rdparty/SerialPort/qextserialport/posix_qextserialport.h b/3rdparty/SerialPort/qextserialport/posix_qextserialport.h
+new file mode 100644
+index 0000000..efdee3c
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/posix_qextserialport.h
+@@ -0,0 +1,56 @@
++
++#ifndef _POSIX_QEXTSERIALPORT_H_
++#define _POSIX_QEXTSERIALPORT_H_
++
++#include <stdio.h>
++#include <termios.h>
++#include <errno.h>
++#include <unistd.h>
++#include <sys/time.h>
++#include <sys/ioctl.h>
++#include <sys/select.h>
++#include "qextserialbase.h"
++
++class Posix_QextSerialPort:public QextSerialBase {
++public:
++	Posix_QextSerialPort();
++	Posix_QextSerialPort(const Posix_QextSerialPort& s);
++	Posix_QextSerialPort(const QString & name);
++	Posix_QextSerialPort(const PortSettings& settings);
++	Posix_QextSerialPort(const QString & name, const PortSettings& settings);
++	Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
++	virtual ~Posix_QextSerialPort();
++	
++	virtual void setBaudRate(BaudRateType);
++	virtual void setDataBits(DataBitsType);
++	virtual void setParity(ParityType);
++	virtual void setStopBits(StopBitsType);
++	virtual void setFlowControl(FlowType);
++	virtual void setTimeout(ulong, ulong);
++	
++	virtual bool open(OpenMode mode=0);
++	virtual void close();
++	virtual void flush();
++	
++	virtual qint64 size() const;
++	virtual qint64 bytesAvailable();
++	
++	virtual void ungetChar(char c);
++	
++	virtual void translateError(ulong error);
++	
++	virtual void setDtr(bool set=true);
++	virtual void setRts(bool set=true);
++	virtual ulong lineStatus();
++	
++protected:
++	QFile* Posix_File;
++	struct termios Posix_CommConfig;
++	struct timeval Posix_Timeout;
++	struct timeval Posix_Copy_Timeout;
++	
++	virtual qint64 readData(char * data, qint64 maxSize);
++	virtual qint64 writeData(const char * data, qint64 maxSize);
++};
++
++#endif
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialbase.cpp b/3rdparty/SerialPort/qextserialport/qextserialbase.cpp
+new file mode 100644
+index 0000000..3ea2561
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialbase.cpp
+@@ -0,0 +1,250 @@
++
++#include "qextserialbase.h"
++
++/*!
++\class QextSerialBase
++\version 1.0.0
++\author Stefan Sander
++
++A common base class for Win_QextSerialBase, Posix_QextSerialBase and QextSerialPort.
++*/
++#ifdef QT_THREAD_SUPPORT
++QMutex* QextSerialBase::mutex=NULL;
++unsigned long QextSerialBase::refCount=0;
++#endif
++
++/*!
++\fn QextSerialBase::QextSerialBase()
++Default constructor.
++*/
++QextSerialBase::QextSerialBase()
++ : QIODevice()
++{
++
++#ifdef _TTY_WIN_
++    setPortName("COM1");
++
++#elif defined(_TTY_IRIX_)
++    setPortName("/dev/ttyf1");
++
++#elif defined(_TTY_HPUX_)
++    setPortName("/dev/tty1p0");
++
++#elif defined(_TTY_SUN_)
++    setPortName("/dev/ttya");
++
++#elif defined(_TTY_DIGITAL_)
++    setPortName("/dev/tty01");
++
++#elif defined(_TTY_FREEBSD_)
++    setPortName("/dev/ttyd1");
++
++#else
++    setPortName("/dev/ttyS0");
++#endif
++
++    construct();
++}
++
++/*!
++\fn QextSerialBase::QextSerialBase(const QString & name)
++Construct a port and assign it to the device specified by the name parameter.
++*/
++QextSerialBase::QextSerialBase(const QString & name)
++ : QIODevice()
++{
++    setPortName(name);
++    construct();
++}
++
++/*!
++\fn QextSerialBase::~QextSerialBase()
++Standard destructor.
++*/
++QextSerialBase::~QextSerialBase()
++{
++
++#ifdef QT_THREAD_SUPPORT
++    refCount--;
++    if (mutex && refCount==0) {
++        delete mutex;
++        mutex=NULL;
++    }
++#endif
++
++}
++
++/*!
++\fn void QextSerialBase::construct()
++Common constructor function for setting up default port settings.
++(9600 Baud, 8N1, no flow control where supported, otherwise no flow control, and 20 ms timeout).
++*/
++void QextSerialBase::construct()
++{
++    Settings.BaudRate=BAUD9600;
++    Settings.DataBits=DATA_8;
++    Settings.Parity=PAR_NONE;
++    Settings.StopBits=STOP_1;
++    Settings.FlowControl=FLOW_OFF;
++    Settings.Timeout_Sec=0;
++    Settings.Timeout_Millisec=20;
++
++#ifdef QT_THREAD_SUPPORT
++    if (!mutex) {
++        mutex=new QMutex( QMutex::Recursive );
++    }
++    refCount++;
++#endif
++
++	setOpenMode(QIODevice::NotOpen);
++}
++
++/*!
++\fn void QextSerialBase::setPortName(const QString & name)
++Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
++*/
++void QextSerialBase::setPortName(const QString & name)
++{
++    port = name;
++}
++
++/*!
++\fn QString QextSerialBase::portName() const
++Returns the name set by setPortName().
++*/
++QString QextSerialBase::portName() const
++{
++    return port;
++}
++
++/*!
++\fn BaudRateType QextSerialBase::baudRate(void) const
++Returns the baud rate of the serial port.  For a list of possible return values see
++the definition of the enum BaudRateType.
++*/
++BaudRateType QextSerialBase::baudRate(void) const
++{
++    return Settings.BaudRate;
++}
++
++/*!
++\fn DataBitsType QextSerialBase::dataBits() const
++Returns the number of data bits used by the port.  For a list of possible values returned by
++this function, see the definition of the enum DataBitsType.
++*/
++DataBitsType QextSerialBase::dataBits() const
++{
++    return Settings.DataBits;
++}
++
++/*!
++\fn ParityType QextSerialBase::parity() const
++Returns the type of parity used by the port.  For a list of possible values returned by
++this function, see the definition of the enum ParityType.
++*/
++ParityType QextSerialBase::parity() const
++{
++    return Settings.Parity;
++}
++
++/*!
++\fn StopBitsType QextSerialBase::stopBits() const
++Returns the number of stop bits used by the port.  For a list of possible return values, see
++the definition of the enum StopBitsType.
++*/
++StopBitsType QextSerialBase::stopBits() const
++{
++    return Settings.StopBits;
++}
++
++/*!
++\fn FlowType QextSerialBase::flowControl() const
++Returns the type of flow control used by the port.  For a list of possible values returned
++by this function, see the definition of the enum FlowType.
++*/
++FlowType QextSerialBase::flowControl() const
++{
++    return Settings.FlowControl;
++}
++
++/*!
++\fn bool QextSerialBase::isSequential() const
++Returns true if device is sequential, otherwise returns false. Serial port is sequential device
++so this function always returns true. Check QIODevice::isSequential() documentation for more 
++information.
++*/
++bool QextSerialBase::isSequential() const
++{
++	return true;
++}
++
++/*!
++\fn bool QextSerialBase::atEnd() const
++This function will return true if the input buffer is empty (or on error), and false otherwise.
++Call QextSerialBase::lastError() for error information.
++*/
++bool QextSerialBase::atEnd() const
++{
++    if (size()) {
++        return true;
++    }
++    return false;
++}
++
++/*!
++\fn qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
++This function will read a line of buffered input from the port, stopping when either maxSize bytes
++have been read, the port has no more data available, or a newline is encountered.
++The value returned is the length of the string that was read.
++*/
++qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
++{
++    qint64 numBytes = bytesAvailable();
++    char* pData = data;
++
++	if (maxSize < 2)	//maxSize must be larger than 1
++		return -1;
++
++    /*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
++    while (pData<(data+numBytes) && --maxSize) {
++        readData(pData, 1);
++        if (*pData++ == '\n') {
++            break;
++        }
++    }
++    *pData='\0';
++
++    /*return size of data read*/
++    return (pData-data);
++}
++
++/*!
++\fn ulong QextSerialBase::lastError() const
++Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port
++operation was successful.  Possible error codes are:
++
++\verbatim
++Error                           Explanation
++---------------------------     -------------------------------------------------------------
++E_NO_ERROR                      No Error has occured
++E_INVALID_FD                    Invalid file descriptor (port was not opened correctly)
++E_NO_MEMORY                     Unable to allocate memory tables (POSIX)
++E_CAUGHT_NON_BLOCKED_SIGNAL     Caught a non-blocked signal (POSIX)
++E_PORT_TIMEOUT                  Operation timed out (POSIX)
++E_INVALID_DEVICE                The file opened by the port is not a character device (POSIX)
++E_BREAK_CONDITION               The port detected a break condition
++E_FRAMING_ERROR                 The port detected a framing error
++                                (usually caused by incorrect baud rate settings)
++E_IO_ERROR                      There was an I/O error while communicating with the port
++E_BUFFER_OVERRUN                Character buffer overrun
++E_RECEIVE_OVERFLOW              Receive buffer overflow
++E_RECEIVE_PARITY_ERROR          The port detected a parity error in the received data
++E_TRANSMIT_OVERFLOW             Transmit buffer overflow
++E_READ_FAILED                   General read operation failure
++E_WRITE_FAILED                  General write operation failure
++\endverbatim
++*/
++ulong QextSerialBase::lastError() const
++{
++    return lastErr;
++}
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialbase.h b/3rdparty/SerialPort/qextserialport/qextserialbase.h
+new file mode 100644
+index 0000000..1af6575
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialbase.h
+@@ -0,0 +1,196 @@
++
++#ifndef _QEXTSERIALBASE_H_
++#define _QEXTSERIALBASE_H_
++
++#include <QIODevice>
++#include <QFile>
++
++#ifdef QT_THREAD_SUPPORT
++#include <QThread>
++#include <QMutex>
++#endif
++
++/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
++#ifdef _TTY_NOWARN_
++#define _TTY_NOWARN_PORT_
++#endif
++
++/*macros for thread support*/
++#ifdef QT_THREAD_SUPPORT
++#define LOCK_MUTEX() mutex->lock()
++#define UNLOCK_MUTEX() mutex->unlock()
++#else
++#define LOCK_MUTEX()
++#define UNLOCK_MUTEX()
++#endif
++
++/*macros for warning messages*/
++#ifdef _TTY_NOWARN_PORT_
++#define TTY_PORTABILITY_WARNING(s)
++#else
++#define TTY_PORTABILITY_WARNING(s) qWarning(s)
++#endif
++#ifdef _TTY_NOWARN_
++#define TTY_WARNING(s)
++#else
++#define TTY_WARNING(s) qWarning(s)
++#endif
++
++
++/*line status constants*/
++#define LS_CTS  0x01
++#define LS_DSR  0x02
++#define LS_DCD  0x04
++#define LS_RI   0x08
++#define LS_RTS  0x10
++#define LS_DTR  0x20
++#define LS_ST   0x40
++#define LS_SR   0x80
++
++/*error constants*/
++#define E_NO_ERROR                   0
++#define E_INVALID_FD                 1
++#define E_NO_MEMORY                  2
++#define E_CAUGHT_NON_BLOCKED_SIGNAL  3
++#define E_PORT_TIMEOUT               4
++#define E_INVALID_DEVICE             5
++#define E_BREAK_CONDITION            6
++#define E_FRAMING_ERROR              7
++#define E_IO_ERROR                   8
++#define E_BUFFER_OVERRUN             9
++#define E_RECEIVE_OVERFLOW          10
++#define E_RECEIVE_PARITY_ERROR      11
++#define E_TRANSMIT_OVERFLOW         12
++#define E_READ_FAILED               13
++#define E_WRITE_FAILED              14
++
++/*enums for port settings*/
++enum NamingConvention {
++    WIN_NAMES,
++    IRIX_NAMES,
++    HPUX_NAMES,
++    SUN_NAMES,
++    DIGITAL_NAMES,
++    FREEBSD_NAMES,
++    LINUX_NAMES
++};
++
++enum BaudRateType {
++    BAUD50,                //POSIX ONLY
++    BAUD75,                //POSIX ONLY
++    BAUD110,
++    BAUD134,               //POSIX ONLY
++    BAUD150,               //POSIX ONLY
++    BAUD200,               //POSIX ONLY
++    BAUD300,
++    BAUD600,
++    BAUD1200,
++    BAUD1800,              //POSIX ONLY
++    BAUD2400,
++    BAUD4800,
++    BAUD9600,
++    BAUD14400,             //WINDOWS ONLY
++    BAUD19200,
++    BAUD38400,
++    BAUD56000,             //WINDOWS ONLY
++    BAUD57600,
++    BAUD76800,             //POSIX ONLY
++    BAUD115200,
++    BAUD128000,            //WINDOWS ONLY
++    BAUD256000             //WINDOWS ONLY
++};
++
++enum DataBitsType {
++    DATA_5,
++    DATA_6,
++    DATA_7,
++    DATA_8
++};
++
++enum ParityType {
++    PAR_NONE,
++    PAR_ODD,
++    PAR_EVEN,
++    PAR_MARK,               //WINDOWS ONLY
++    PAR_SPACE
++};
++
++enum StopBitsType {
++    STOP_1,
++    STOP_1_5,               //WINDOWS ONLY
++    STOP_2
++};
++
++enum FlowType {
++    FLOW_OFF,
++    FLOW_HARDWARE,
++    FLOW_XONXOFF
++};
++
++/*structure to contain port settings*/
++struct PortSettings {
++    BaudRateType BaudRate;
++    DataBitsType DataBits;
++    ParityType Parity;
++    StopBitsType StopBits;
++    FlowType FlowControl;
++    ulong Timeout_Sec;
++    ulong Timeout_Millisec;
++};
++
++class QextSerialBase : public QIODevice {
++public:
++    QextSerialBase();
++    QextSerialBase(const QString & name);
++    virtual ~QextSerialBase();
++    virtual void construct();
++    virtual void setPortName(const QString & name);
++    virtual QString portName() const;
++
++    virtual void setBaudRate(BaudRateType)=0;
++    virtual BaudRateType baudRate() const;
++    virtual void setDataBits(DataBitsType)=0;
++    virtual DataBitsType dataBits() const;
++    virtual void setParity(ParityType)=0;
++    virtual ParityType parity() const;
++    virtual void setStopBits(StopBitsType)=0;
++    virtual StopBitsType stopBits() const;
++    virtual void setFlowControl(FlowType)=0;
++    virtual FlowType flowControl() const;
++    virtual void setTimeout(ulong, ulong)=0;
++
++    virtual bool open(OpenMode mode=0)=0;
++    virtual bool isSequential() const;
++    virtual void close()=0;
++    virtual void flush()=0;
++
++    virtual qint64 size() const=0;
++    virtual qint64 bytesAvailable()=0;
++    virtual bool atEnd() const;
++
++    virtual void ungetChar(char c)=0;
++    virtual qint64 readLine(char * data, qint64 maxSize);
++
++    virtual ulong lastError() const;
++    virtual void translateError(ulong error)=0;
++
++    virtual void setDtr(bool set=true)=0;
++    virtual void setRts(bool set=true)=0;
++    virtual ulong lineStatus()=0;
++
++protected:
++    QString port;
++    PortSettings Settings;
++    ulong lastErr;
++
++#ifdef QT_THREAD_SUPPORT
++    static QMutex* mutex;
++    static ulong refCount;
++#endif
++
++    virtual qint64 readData(char * data, qint64 maxSize)=0;
++    virtual qint64 writeData(const char * data, qint64 maxSize)=0;
++
++};
++
++#endif
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport.cpp b/3rdparty/SerialPort/qextserialport/qextserialport.cpp
+new file mode 100644
+index 0000000..9d3fff4
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialport.cpp
+@@ -0,0 +1,98 @@
++
++/*!
++\class QextSerialPort
++\version 1.0.0
++\author Stefan Sander
++
++A cross-platform serial port class.
++This class encapsulates a serial port on both POSIX and Windows systems.  The user will be
++notified of errors and possible portability conflicts at run-time by default - this behavior can
++be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn
++off portability warnings) in the project.
++
++\note
++On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
++select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
++make no guarantees as to the quality of POSIX support under NT/2000 however.
++
++*/
++
++#include <stdio.h>
++#include "qextserialport.h"
++
++/*!
++\fn QextSerialPort::QextSerialPort()
++Default constructor.  Note that the naming convention used by a QextSerialPort constructed with
++this constructor will be determined by #defined constants, or lack thereof - the default behavior
++is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:
++
++\verbatim
++
++Constant         Used By         Naming Convention
++----------       -------------   ------------------------
++_TTY_WIN_        Windows         COM1, COM2
++_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
++_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
++_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
++_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
++_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
++_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
++<none>           Linux           /dev/ttyS0, /dev/ttyS1
++\endverbatim
++
++The object will be associated with the first port in the system, e.g. COM1 on Windows systems.
++See the other constructors if you need to use a port other than the first.
++*/
++QextSerialPort::QextSerialPort()
++ : QextBaseType()
++{}
++
++/*!
++\fn QextSerialPort::QextSerialPort(const QString & name)
++Constructs a serial port attached to the port specified by name.
++name is the name of the device, which is windowsystem-specific,
++e.g."COM1" or "/dev/ttyS0".
++*/
++QextSerialPort::QextSerialPort(const QString & name)
++ : QextBaseType(name)
++{}
++
++/*!
++\fn QextSerialPort::QextSerialPort(PortSettings const& settings)
++Constructs a port with default name and settings specified by the settings parameter.
++*/
++QextSerialPort::QextSerialPort(PortSettings const& settings)
++ : QextBaseType(settings)
++{}
++
++/*!
++\fn QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
++Constructs a port with the name and settings specified.
++*/
++QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
++ : QextBaseType(name, settings)
++{}
++
++/*!
++\fn QextSerialPort::QextSerialPort(const QextSerialPort& s)
++Copy constructor.
++*/
++QextSerialPort::QextSerialPort(const QextSerialPort& s)
++ : QextBaseType(s)
++{}
++
++/*!
++\fn QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
++Overrides the = operator.
++*/
++QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
++{
++    return (QextSerialPort&)QextBaseType::operator=(s);
++}
++
++/*!
++\fn QextSerialPort::~QextSerialPort()
++Standard destructor.
++*/
++QextSerialPort::~QextSerialPort()
++{}
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport.h b/3rdparty/SerialPort/qextserialport/qextserialport.h
+new file mode 100644
+index 0000000..2ae5560
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialport.h
+@@ -0,0 +1,27 @@
++
++#ifndef _QEXTSERIALPORT_H_
++#define _QEXTSERIALPORT_H_
++
++/*POSIX CODE*/
++#ifdef _TTY_POSIX_
++#include "posix_qextserialport.h"
++#define QextBaseType Posix_QextSerialPort
++
++/*MS WINDOWS CODE*/
++#else
++#include "win_qextserialport.h"
++#define QextBaseType Win_QextSerialPort
++#endif
++
++class QextSerialPort: public QextBaseType {
++public:
++    QextSerialPort();
++    QextSerialPort(const QString & name);
++    QextSerialPort(PortSettings const& s);
++    QextSerialPort(const QString & name, PortSettings const& s);
++    QextSerialPort(const QextSerialPort& s);
++    QextSerialPort& operator=(const QextSerialPort&);
++    virtual ~QextSerialPort();
++};
++
++#endif
+diff --git a/3rdparty/SerialPort/qextserialport/win_qextserialport.cpp b/3rdparty/SerialPort/qextserialport/win_qextserialport.cpp
+new file mode 100644
+index 0000000..8cfc635
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/win_qextserialport.cpp
+@@ -0,0 +1,877 @@
++/*!
++		\class Win_QextSerialPort
++		\version 1.0.0
++		\author Stefan Sander
++
++A cross-platform serial port class.
++		This class encapsulates the Windows portion of QextSerialPort.  The user will be notified of
++		errors and possible portability conflicts at run-time by default - this behavior can be turned
++		off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off
++		portability warnings) in the project.  Note that defining _TTY_NOWARN_ also defines
++		_TTY_NOWARN_PORT_.
++
++\note
++		On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
++		select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
++		make no guarantees as to the quality of POSIX support under NT/2000 however.
++
++*/
++
++#include <stdio.h>
++#include "win_qextserialport.h"
++
++/*!
++		\fn Win_QextSerialPort::Win_QextSerialPort()
++			Default constructor.  Note that the name of the device used by a Win_QextSerialPort constructed
++			with this constructor will be determined by #defined constants, or lack thereof - the default
++			behavior is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants
++			are:
++
++\verbatim
++
++Constant         Used By         Naming Convention
++		----------       -------------   ------------------------
++		_TTY_WIN_        Windows         COM1, COM2
++		_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
++		_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
++		_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
++		_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
++		_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
++		_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
++		<none>           Linux           /dev/ttyS0, /dev/ttyS1
++		\endverbatim
++
++This constructor associates the object with the first port on the system, e.g. COM1 for Windows
++		platforms.  See the other constructor if you need a port other than the first.
++*/
++Win_QextSerialPort::Win_QextSerialPort():QextSerialBase() {
++	Win_Handle=INVALID_HANDLE_VALUE;
++}
++
++/*!Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort&)
++	Copy constructor.
++*/
++Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort& s):QextSerialBase(s.port) {
++	Win_Handle=INVALID_HANDLE_VALUE;
++	setOpenMode(s.openMode());
++	lastErr=s.lastErr;
++	port = s.port;
++	Settings.FlowControl=s.Settings.FlowControl;
++	Settings.Parity=s.Settings.Parity;
++	Settings.DataBits=s.Settings.DataBits;
++	Settings.StopBits=s.Settings.StopBits;
++	Settings.BaudRate=s.Settings.BaudRate;
++	Win_Handle=s.Win_Handle;
++	memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG));
++	memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS));
++}
++
++/*!
++		\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name)
++			Constructs a serial port attached to the port specified by devName.
++			devName is the name of the device, which is windowsystem-specific,
++			e.g."COM2" or "/dev/ttyS0".
++*/
++Win_QextSerialPort::Win_QextSerialPort(const QString & name):QextSerialBase(name) {
++	Win_Handle=INVALID_HANDLE_VALUE;
++}
++
++/*!
++		\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
++			Constructs a port with default name and specified settings.
++*/
++Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) {
++	Win_Handle=INVALID_HANDLE_VALUE;
++	setBaudRate(settings.BaudRate);
++	setDataBits(settings.DataBits);
++	setStopBits(settings.StopBits);
++	setParity(settings.Parity);
++	setFlowControl(settings.FlowControl);
++	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
++}
++
++/*!
++		\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings)
++			Constructs a port with specified name and settings.
++*/
++Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings) {
++	Win_Handle=INVALID_HANDLE_VALUE;
++	setPortName(name);
++	setBaudRate(settings.BaudRate);
++	setDataBits(settings.DataBits);
++	setStopBits(settings.StopBits);
++	setParity(settings.Parity);
++	setFlowControl(settings.FlowControl);
++	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
++}
++
++/*!
++		\fn Win_QextSerialPort::~Win_QextSerialPort()
++			Standard destructor.
++*/
++Win_QextSerialPort::~Win_QextSerialPort() {
++	if (isOpen()) {
++		close();
++	}
++}
++
++/*!
++		\fn Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s)
++			overrides the = operator
++*/
++Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) {
++	setOpenMode(s.openMode());
++	lastErr=s.lastErr;
++	port = s.port;
++	Settings.FlowControl=s.Settings.FlowControl;
++	Settings.Parity=s.Settings.Parity;
++	Settings.DataBits=s.Settings.DataBits;
++	Settings.StopBits=s.Settings.StopBits;
++	Settings.BaudRate=s.Settings.BaudRate;
++	Win_Handle=s.Win_Handle;
++	memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG));
++	memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS));
++	return *this;
++}
++
++/*!
++		\fn bool Win_QextSerialPort::open(OpenMode mode)
++			Opens a serial port.  Note that this function does not specify which device to open.  If you need
++			to open a device by name, see Win_QextSerialPort::open(const char*).  This function has no effect
++			if the port associated with the class is already open.  The port is also configured to the current
++			settings, as stored in the Settings structure.
++*/
++bool Win_QextSerialPort::open(OpenMode mode) {
++	unsigned long confSize = sizeof(COMMCONFIG);
++	Win_CommConfig.dwSize = confSize;
++	
++	LOCK_MUTEX();
++	if (mode == QIODevice::NotOpen)
++		return isOpen();
++	if (!isOpen()) {
++		/*open the port*/
++		Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE,
++				FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
++		if (Win_Handle!=INVALID_HANDLE_VALUE) {
++			/*set open mode*/
++			QIODevice::open(mode);
++			
++			/*configure port settings*/
++			GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
++			GetCommState(Win_Handle, &(Win_CommConfig.dcb));
++			
++			/*set up parameters*/
++			Win_CommConfig.dcb.fBinary=TRUE;
++			Win_CommConfig.dcb.fInX=FALSE;
++			Win_CommConfig.dcb.fOutX=FALSE;
++			Win_CommConfig.dcb.fAbortOnError=FALSE;
++			Win_CommConfig.dcb.fNull=FALSE;
++			setBaudRate(Settings.BaudRate);
++			setDataBits(Settings.DataBits);
++			setStopBits(Settings.StopBits);
++			setParity(Settings.Parity);
++			setFlowControl(Settings.FlowControl);
++			setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
++			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++		}
++	}
++	UNLOCK_MUTEX();
++	return isOpen();
++}
++
++/*!
++		\fn void Win_QextSerialPort::close()
++			Closes a serial port.  This function has no effect if the serial port associated with the class
++			is not currently open.
++*/
++void Win_QextSerialPort::close() {
++	LOCK_MUTEX();
++	CloseHandle(Win_Handle);
++	QIODevice::close();
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::flush()
++			Flushes all pending I/O to the serial port.  This function has no effect if the serial port
++			associated with the class is not currently open.
++*/
++void Win_QextSerialPort::flush() {
++	LOCK_MUTEX();
++	if (isOpen()) {
++		FlushFileBuffers(Win_Handle);
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn qint64 Win_QextSerialPort::size() const
++This function will return the number of bytes waiting in the receive queue of the serial port.
++		It is included primarily to provide a complete QIODevice interface, and will not record errors
++		in the lastErr member (because it is const).  This function is also not thread-safe - in
++		multithreading situations, use Win_QextSerialPort::bytesAvailable() instead.
++*/
++qint64 Win_QextSerialPort::size() const {
++	int availBytes;
++	COMSTAT Win_ComStat;
++	DWORD Win_ErrorMask=0;
++	ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat);
++	availBytes = Win_ComStat.cbInQue;
++	return (qint64)availBytes;
++}
++
++/*!
++		\fn qint64 Win_QextSerialPort::bytesAvailable()
++			Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
++			the port is not currently open, or -1 on error.  Error information can be retrieved by calling
++			Win_QextSerialPort::getLastError().
++*/
++qint64 Win_QextSerialPort::bytesAvailable() {
++	LOCK_MUTEX();
++	if (isOpen()) {
++		DWORD Errors;
++		COMSTAT Status;
++		bool success=ClearCommError(Win_Handle, &Errors, &Status);
++		translateError(Errors);
++		if (success) {
++			lastErr=E_NO_ERROR;
++			UNLOCK_MUTEX();
++			return Status.cbInQue + QIODevice::bytesAvailable();
++		}
++		UNLOCK_MUTEX();
++		return (unsigned int)-1;
++	}
++	UNLOCK_MUTEX();
++	return 0;
++}
++
++/*!
++		\fn void Win_QextSerialPort::translateError(ulong error)
++			Translates a system-specific error code to a QextSerialPort error code.  Used internally.
++*/
++void Win_QextSerialPort::translateError(ulong error) {
++	if (error&CE_BREAK) {
++		lastErr=E_BREAK_CONDITION;
++	}
++	else if (error&CE_FRAME) {
++		lastErr=E_FRAMING_ERROR;
++	}
++	else if (error&CE_IOE) {
++		lastErr=E_IO_ERROR;
++	}
++	else if (error&CE_MODE) {
++		lastErr=E_INVALID_FD;
++	}
++	else if (error&CE_OVERRUN) {
++		lastErr=E_BUFFER_OVERRUN;
++	}
++	else if (error&CE_RXPARITY) {
++		lastErr=E_RECEIVE_PARITY_ERROR;
++	}
++	else if (error&CE_RXOVER) {
++		lastErr=E_RECEIVE_OVERFLOW;
++	}
++	else if (error&CE_TXFULL) {
++		lastErr=E_TRANSMIT_OVERFLOW;
++	}
++}
++
++/*!
++		\fn qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
++			Reads a block of data from the serial port.  This function will read at most maxlen bytes from
++			the serial port and place them in the buffer pointed to by data.  Return value is the number of
++			bytes actually read, or -1 on error.
++
++\warning before calling this function ensure that serial port associated with this class
++		is currently open (use isOpen() function to check if port is open).
++*/
++qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
++{
++	LOCK_MUTEX();
++	int retVal=0;
++	COMSTAT Win_ComStat;
++	DWORD Win_BytesRead=0;
++	DWORD Win_ErrorMask=0;
++	ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat);
++	if (Win_ComStat.cbInQue &&
++			(!ReadFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesRead, NULL)
++			|| Win_BytesRead==0)) {
++				lastErr=E_READ_FAILED;
++		retVal=-1;
++	}
++	else {
++		retVal=((int)Win_BytesRead);
++	}
++	UNLOCK_MUTEX();
++	
++	return retVal;
++}
++
++/*!
++		\fn qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize)
++			Writes a block of data to the serial port.  This function will write len bytes
++			from the buffer pointed to by data to the serial port.  Return value is the number
++			of bytes actually written, or -1 on error.
++
++\warning before calling this function ensure that serial port associated with this class
++		is currently open (use isOpen() function to check if port is open).
++*/
++qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize)
++{
++	LOCK_MUTEX();
++	int retVal=0;
++	DWORD Win_BytesWritten;
++	if (!WriteFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesWritten, NULL)) {
++		lastErr=E_WRITE_FAILED;
++		retVal=-1;
++	}
++	else {
++		retVal=((int)Win_BytesWritten);
++	}
++	UNLOCK_MUTEX();
++	
++	flush();
++	return retVal;
++}
++
++/*!
++		\fn void Win_QextSerialPort::ungetChar(char c)
++			This function is included to implement the full QIODevice interface, and currently has no
++			purpose within this class.  This function is meaningless on an unbuffered device and currently
++			only prints a warning message to that effect.
++*/
++void Win_QextSerialPort::ungetChar(char c) {
++	
++	/*meaningless on unbuffered sequential device - return error and print a warning*/
++	TTY_WARNING("Win_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
++}
++
++/*!
++		\fn void Win_QextSerialPort::setFlowControl(FlowType flow)
++			Sets the flow control used by the port.  Possible values of flow are:
++\verbatim
++		FLOW_OFF            No flow control
++		FLOW_HARDWARE       Hardware (RTS/CTS) flow control
++		FLOW_XONXOFF        Software (XON/XOFF) flow control
++		\endverbatim
++*/
++void Win_QextSerialPort::setFlowControl(FlowType flow) {
++	LOCK_MUTEX();
++	if (Settings.FlowControl!=flow) {
++		Settings.FlowControl=flow;
++	}
++	if (isOpen()) {
++		switch(flow) {
++				
++				/*no flow control*/
++			case FLOW_OFF:
++				Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
++				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
++				Win_CommConfig.dcb.fInX=FALSE;
++				Win_CommConfig.dcb.fOutX=FALSE;
++				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				break;
++				
++				/*software (XON/XOFF) flow control*/
++			case FLOW_XONXOFF:
++				Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
++				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
++				Win_CommConfig.dcb.fInX=TRUE;
++				Win_CommConfig.dcb.fOutX=TRUE;
++				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				break;
++				
++			case FLOW_HARDWARE:
++				Win_CommConfig.dcb.fOutxCtsFlow=TRUE;
++				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_HANDSHAKE;
++				Win_CommConfig.dcb.fInX=FALSE;
++				Win_CommConfig.dcb.fOutX=FALSE;
++				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				break;
++		}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::setParity(ParityType parity)
++			Sets the parity associated with the serial port.  The possible values of parity are:
++\verbatim
++		PAR_SPACE       Space Parity
++		PAR_MARK        Mark Parity
++		PAR_NONE        No Parity
++		PAR_EVEN        Even Parity
++		PAR_ODD         Odd Parity
++		\endverbatim
++*/
++void Win_QextSerialPort::setParity(ParityType parity) {
++	LOCK_MUTEX();
++	if (Settings.Parity!=parity) {
++		Settings.Parity=parity;
++	}
++	if (isOpen()) {
++		Win_CommConfig.dcb.Parity=(unsigned char)parity;
++		switch (parity) {
++				
++				/*space parity*/
++			case PAR_SPACE:
++				if (Settings.DataBits==DATA_8) {
++					TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: Space parity with 8 data bits is not supported by POSIX systems.");
++				}
++				Win_CommConfig.dcb.fParity=TRUE;
++				break;
++				
++				/*mark parity - WINDOWS ONLY*/
++			case PAR_MARK:
++				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning:  Mark parity is not supported by POSIX systems");
++				Win_CommConfig.dcb.fParity=TRUE;
++				break;
++				
++				/*no parity*/
++			case PAR_NONE:
++				Win_CommConfig.dcb.fParity=FALSE;
++				break;
++				
++				/*even parity*/
++			case PAR_EVEN:
++				Win_CommConfig.dcb.fParity=TRUE;
++				break;
++				
++				/*odd parity*/
++			case PAR_ODD:
++				Win_CommConfig.dcb.fParity=TRUE;
++				break;
++			}
++			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::setDataBits(DataBitsType dataBits)
++			Sets the number of data bits used by the serial port.  Possible values of dataBits are:
++\verbatim
++		DATA_5      5 data bits
++		DATA_6      6 data bits
++		DATA_7      7 data bits
++		DATA_8      8 data bits
++		\endverbatim
++
++\note
++		This function is subject to the following restrictions:
++\par
++		5 data bits cannot be used with 2 stop bits.
++		\par
++		1.5 stop bits can only be used with 5 data bits.
++		\par
++		8 data bits cannot be used with space parity on POSIX systems.
++
++*/
++void Win_QextSerialPort::setDataBits(DataBitsType dataBits) {
++	LOCK_MUTEX();
++	if (Settings.DataBits!=dataBits) {
++		if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
++				(Settings.StopBits==STOP_1_5 && dataBits!=DATA_5)) {
++				}
++		else {
++			Settings.DataBits=dataBits;
++		}
++	}
++	if (isOpen()) {
++		switch(dataBits) {
++				
++				/*5 data bits*/
++			case DATA_5:
++				if (Settings.StopBits==STOP_2) {
++					TTY_WARNING("Win_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
++				}
++				else {
++					Win_CommConfig.dcb.ByteSize=5;
++					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				}
++				break;
++				
++				/*6 data bits*/
++			case DATA_6:
++				if (Settings.StopBits==STOP_1_5) {
++					TTY_WARNING("Win_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
++				}
++				else {
++					Win_CommConfig.dcb.ByteSize=6;
++					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				}
++				break;
++				
++				/*7 data bits*/
++			case DATA_7:
++				if (Settings.StopBits==STOP_1_5) {
++					TTY_WARNING("Win_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
++				}
++				else {
++					Win_CommConfig.dcb.ByteSize=7;
++					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				}
++				break;
++				
++				/*8 data bits*/
++			case DATA_8:
++				if (Settings.StopBits==STOP_1_5) {
++					TTY_WARNING("Win_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
++				}
++				else {
++					Win_CommConfig.dcb.ByteSize=8;
++					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				}
++				break;
++			}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::setStopBits(StopBitsType stopBits)
++			Sets the number of stop bits used by the serial port.  Possible values of stopBits are:
++\verbatim
++		STOP_1      1 stop bit
++		STOP_1_5    1.5 stop bits
++		STOP_2      2 stop bits
++		\endverbatim
++
++\note
++		This function is subject to the following restrictions:
++\par
++		2 stop bits cannot be used with 5 data bits.
++		\par
++		1.5 stop bits cannot be used with 6 or more data bits.
++		\par
++		POSIX does not support 1.5 stop bits.
++*/
++void Win_QextSerialPort::setStopBits(StopBitsType stopBits) {
++	LOCK_MUTEX();
++	if (Settings.StopBits!=stopBits) {
++		if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) ||
++				(stopBits==STOP_1_5 && Settings.DataBits!=DATA_5)) {
++				}
++		else {
++			Settings.StopBits=stopBits;
++		}
++	}
++	if (isOpen()) {
++		switch (stopBits) {
++				
++				/*one stop bit*/
++			case STOP_1:
++				Win_CommConfig.dcb.StopBits=ONESTOPBIT;
++				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				break;
++				
++				/*1.5 stop bits*/
++			case STOP_1_5:
++				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX.");
++				if (Settings.DataBits!=DATA_5) {
++					TTY_WARNING("Win_QextSerialPort: 1.5 stop bits can only be used with 5 data bits");
++				}
++				else {
++					Win_CommConfig.dcb.StopBits=ONE5STOPBITS;
++					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				}
++				break;
++				
++				/*two stop bits*/
++			case STOP_2:
++				if (Settings.DataBits==DATA_5) {
++					TTY_WARNING("Win_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
++				}
++				else {
++					Win_CommConfig.dcb.StopBits=TWOSTOPBITS;
++					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++				}
++				break;
++			}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::setBaudRate(BaudRateType baudRate)
++			Sets the baud rate of the serial port.  Note that not all rates are applicable on
++			all platforms.  The following table shows translations of the various baud rate
++			constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
++			are speeds that are usable on both Windows and POSIX.
++			\verbatim
++
++RATE          Windows Speed   POSIX Speed
++		-----------   -------------   -----------
++		BAUD50                 110          50
++		BAUD75                 110          75
++		*BAUD110                110         110
++		BAUD134                110         134.5
++		BAUD150                110         150
++		BAUD200                110         200
++		*BAUD300                300         300
++		*BAUD600                600         600
++		*BAUD1200              1200        1200
++		BAUD1800              1200        1800
++		*BAUD2400              2400        2400
++		*BAUD4800              4800        4800
++		*BAUD9600              9600        9600
++		BAUD14400            14400        9600
++		*BAUD19200            19200       19200
++		*BAUD38400            38400       38400
++		BAUD56000            56000       38400
++		*BAUD57600            57600       57600
++		BAUD76800            57600       76800
++		*BAUD115200          115200      115200
++		BAUD128000          128000      115200
++		BAUD256000          256000      115200
++		\endverbatim
++*/
++void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) {
++	LOCK_MUTEX();
++	if (Settings.BaudRate!=baudRate) {
++		switch (baudRate) {
++			case BAUD50:
++			case BAUD75:
++			case BAUD134:
++			case BAUD150:
++			case BAUD200:
++				Settings.BaudRate=BAUD110;
++				break;
++				
++			case BAUD1800:
++				Settings.BaudRate=BAUD1200;
++				break;
++				
++			case BAUD76800:
++				Settings.BaudRate=BAUD57600;
++				break;
++				
++			default:
++				Settings.BaudRate=baudRate;
++				break;
++			}
++	}
++	if (isOpen()) {
++		switch (baudRate) {
++				
++				/*50 baud*/
++			case BAUD50:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 50 baud operation.  Switching to 110 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_110;
++				break;
++				
++				/*75 baud*/
++			case BAUD75:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 75 baud operation.  Switching to 110 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_110;
++				break;
++				
++				/*110 baud*/
++			case BAUD110:
++				Win_CommConfig.dcb.BaudRate=CBR_110;
++				break;
++				
++				/*134.5 baud*/
++			case BAUD134:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 134.5 baud operation.  Switching to 110 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_110;
++				break;
++				
++				/*150 baud*/
++			case BAUD150:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 150 baud operation.  Switching to 110 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_110;
++				break;
++				
++				/*200 baud*/
++			case BAUD200:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 200 baud operation.  Switching to 110 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_110;
++				break;
++				
++				/*300 baud*/
++			case BAUD300:
++				Win_CommConfig.dcb.BaudRate=CBR_300;
++				break;
++				
++				/*600 baud*/
++			case BAUD600:
++				Win_CommConfig.dcb.BaudRate=CBR_600;
++				break;
++				
++				/*1200 baud*/
++			case BAUD1200:
++				Win_CommConfig.dcb.BaudRate=CBR_1200;
++				break;
++				
++				/*1800 baud*/
++			case BAUD1800:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 1800 baud operation.  Switching to 1200 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_1200;
++				break;
++				
++				/*2400 baud*/
++			case BAUD2400:
++				Win_CommConfig.dcb.BaudRate=CBR_2400;
++				break;
++				
++				/*4800 baud*/
++			case BAUD4800:
++				Win_CommConfig.dcb.BaudRate=CBR_4800;
++				break;
++				
++				/*9600 baud*/
++			case BAUD9600:
++				Win_CommConfig.dcb.BaudRate=CBR_9600;
++				break;
++				
++				/*14400 baud*/
++			case BAUD14400:
++				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 14400 baud operation.");
++				Win_CommConfig.dcb.BaudRate=CBR_14400;
++				break;
++				
++				/*19200 baud*/
++			case BAUD19200:
++				Win_CommConfig.dcb.BaudRate=CBR_19200;
++				break;
++				
++				/*38400 baud*/
++			case BAUD38400:
++				Win_CommConfig.dcb.BaudRate=CBR_38400;
++				break;
++				
++				/*56000 baud*/
++			case BAUD56000:
++				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 56000 baud operation.");
++				Win_CommConfig.dcb.BaudRate=CBR_56000;
++				break;
++				
++				/*57600 baud*/
++			case BAUD57600:
++				Win_CommConfig.dcb.BaudRate=CBR_57600;
++				break;
++				
++				/*76800 baud*/
++			case BAUD76800:
++				TTY_WARNING("Win_QextSerialPort: Windows does not support 76800 baud operation.  Switching to 57600 baud.");
++				Win_CommConfig.dcb.BaudRate=CBR_57600;
++				break;
++				
++				/*115200 baud*/
++			case BAUD115200:
++				Win_CommConfig.dcb.BaudRate=CBR_115200;
++				break;
++				
++				/*128000 baud*/
++			case BAUD128000:
++				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 128000 baud operation.");
++				Win_CommConfig.dcb.BaudRate=CBR_128000;
++				break;
++				
++				/*256000 baud*/
++			case BAUD256000:
++				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 256000 baud operation.");
++				Win_CommConfig.dcb.BaudRate=CBR_256000;
++				break;
++			}
++			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::setDtr(bool set)
++			Sets DTR line to the requested state (high by default).  This function will have no effect if
++			the port associated with the class is not currently open.
++*/
++void Win_QextSerialPort::setDtr(bool set) {
++	LOCK_MUTEX();
++	if (isOpen()) {
++		if (set) {
++			EscapeCommFunction(Win_Handle, SETDTR);
++		}
++		else {
++			EscapeCommFunction(Win_Handle, CLRDTR);
++		}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn void Win_QextSerialPort::setRts(bool set)
++			Sets RTS line to the requested state (high by default).  This function will have no effect if
++			the port associated with the class is not currently open.
++*/
++void Win_QextSerialPort::setRts(bool set) {
++	LOCK_MUTEX();
++	if (isOpen()) {
++		if (set) {
++			EscapeCommFunction(Win_Handle, SETRTS);
++		}
++		else {
++			EscapeCommFunction(Win_Handle, CLRRTS);
++		}
++	}
++	UNLOCK_MUTEX();
++}
++
++/*!
++		\fn ulong Win_QextSerialPort::lineStatus(void)
++			returns the line status as stored by the port function.  This function will retrieve the states
++			of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
++			can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
++			long with specific bits indicating which lines are high.  The following constants should be used
++			to examine the states of individual lines:
++
++\verbatim
++		Mask        Line
++		------      ----
++		LS_CTS      CTS
++		LS_DSR      DSR
++		LS_DCD      DCD
++		LS_RI       RI
++		\endverbatim
++
++This function will return 0 if the port associated with the class is not currently open.
++*/
++ulong Win_QextSerialPort::lineStatus(void) {
++	unsigned long Status=0, Temp=0;
++	LOCK_MUTEX();
++	if (isOpen()) {
++		GetCommModemStatus(Win_Handle, &Temp);
++		if (Temp&MS_CTS_ON) {
++			Status|=LS_CTS;
++		}
++		if (Temp&MS_DSR_ON) {
++			Status|=LS_DSR;
++		}
++		if (Temp&MS_RING_ON) {
++			Status|=LS_RI;
++		}
++		if (Temp&MS_RLSD_ON) {
++			Status|=LS_DCD;
++		}
++	}
++	UNLOCK_MUTEX();
++	return Status;
++}
++
++/*!
++		\fn void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec);
++Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.
++*/
++void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec) {
++	LOCK_MUTEX();
++	Settings.Timeout_Sec=sec;
++	Settings.Timeout_Millisec=millisec;
++	if(isOpen()) {
++		Win_CommTimeouts.ReadIntervalTimeout = sec*1000+millisec;
++		Win_CommTimeouts.ReadTotalTimeoutMultiplier = sec*1000+millisec;
++		Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
++		Win_CommTimeouts.WriteTotalTimeoutMultiplier = sec*1000+millisec;
++		Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
++		SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
++	}
++	UNLOCK_MUTEX();
++}
+diff --git a/3rdparty/SerialPort/qextserialport/win_qextserialport.h b/3rdparty/SerialPort/qextserialport/win_qextserialport.h
+new file mode 100644
+index 0000000..09a28c7
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/win_qextserialport.h
+@@ -0,0 +1,48 @@
++#ifndef _WIN_QEXTSERIALPORT_H_
++#define _WIN_QEXTSERIALPORT_H_
++
++#include "qextserialbase.h"
++
++/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
++#ifdef _TTY_NOWARN_
++#define _TTY_NOWARN_PORT_
++#endif
++
++#include <windows.h>
++
++class Win_QextSerialPort:public QextSerialBase {
++public:
++	Win_QextSerialPort();
++	Win_QextSerialPort(Win_QextSerialPort const& s);
++	Win_QextSerialPort(const QString & name);
++	Win_QextSerialPort(const PortSettings& settings);
++	Win_QextSerialPort(const QString & name, const PortSettings& settings);
++	Win_QextSerialPort& operator=(const Win_QextSerialPort& s);
++	virtual ~Win_QextSerialPort();
++	virtual bool open(OpenMode mode=0);
++	virtual void close();
++	virtual void flush();
++	virtual qint64 size() const;
++	virtual void ungetChar(char c);
++	virtual void setFlowControl(FlowType);
++	virtual void setParity(ParityType);
++	virtual void setDataBits(DataBitsType);
++	virtual void setStopBits(StopBitsType);
++	virtual void setBaudRate(BaudRateType);
++	virtual void setDtr(bool set=true);
++	virtual void setRts(bool set=true);
++	virtual ulong lineStatus(void);
++	virtual qint64 bytesAvailable();
++	virtual void translateError(ulong);
++	virtual void setTimeout(ulong, ulong);
++	
++protected:
++	HANDLE Win_Handle;
++	COMMCONFIG Win_CommConfig;
++	COMMTIMEOUTS Win_CommTimeouts;
++	
++	virtual qint64 readData(char *data, qint64 maxSize);
++	virtual qint64 writeData(const char *data, qint64 maxSize);
++};
++
++#endif
+diff --git a/3rdparty/SerialPort/win_qextserialport.cpp b/3rdparty/SerialPort/win_qextserialport.cpp
+deleted file mode 100644
+index 8cfc635..0000000
+--- a/3rdparty/SerialPort/win_qextserialport.cpp
++++ /dev/null
+@@ -1,877 +0,0 @@
+-/*!
+-		\class Win_QextSerialPort
+-		\version 1.0.0
+-		\author Stefan Sander
+-
+-A cross-platform serial port class.
+-		This class encapsulates the Windows portion of QextSerialPort.  The user will be notified of
+-		errors and possible portability conflicts at run-time by default - this behavior can be turned
+-		off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off
+-		portability warnings) in the project.  Note that defining _TTY_NOWARN_ also defines
+-		_TTY_NOWARN_PORT_.
+-
+-\note
+-		On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
+-		select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
+-		make no guarantees as to the quality of POSIX support under NT/2000 however.
+-
+-*/
+-
+-#include <stdio.h>
+-#include "win_qextserialport.h"
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort()
+-			Default constructor.  Note that the name of the device used by a Win_QextSerialPort constructed
+-			with this constructor will be determined by #defined constants, or lack thereof - the default
+-			behavior is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants
+-			are:
+-
+-\verbatim
+-
+-Constant         Used By         Naming Convention
+-		----------       -------------   ------------------------
+-		_TTY_WIN_        Windows         COM1, COM2
+-		_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
+-		_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
+-		_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
+-		_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
+-		_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
+-		_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
+-		<none>           Linux           /dev/ttyS0, /dev/ttyS1
+-		\endverbatim
+-
+-This constructor associates the object with the first port on the system, e.g. COM1 for Windows
+-		platforms.  See the other constructor if you need a port other than the first.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort():QextSerialBase() {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-}
+-
+-/*!Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort&)
+-	Copy constructor.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort& s):QextSerialBase(s.port) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-	setOpenMode(s.openMode());
+-	lastErr=s.lastErr;
+-	port = s.port;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Win_Handle=s.Win_Handle;
+-	memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG));
+-	memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS));
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name)
+-			Constructs a serial port attached to the port specified by devName.
+-			devName is the name of the device, which is windowsystem-specific,
+-			e.g."COM2" or "/dev/ttyS0".
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const QString & name):QextSerialBase(name) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
+-			Constructs a port with default name and specified settings.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setStopBits(settings.StopBits);
+-	setParity(settings.Parity);
+-	setFlowControl(settings.FlowControl);
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings)
+-			Constructs a port with specified name and settings.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-	setPortName(name);
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setStopBits(settings.StopBits);
+-	setParity(settings.Parity);
+-	setFlowControl(settings.FlowControl);
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::~Win_QextSerialPort()
+-			Standard destructor.
+-*/
+-Win_QextSerialPort::~Win_QextSerialPort() {
+-	if (isOpen()) {
+-		close();
+-	}
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s)
+-			overrides the = operator
+-*/
+-Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) {
+-	setOpenMode(s.openMode());
+-	lastErr=s.lastErr;
+-	port = s.port;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Win_Handle=s.Win_Handle;
+-	memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG));
+-	memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS));
+-	return *this;
+-}
+-
+-/*!
+-		\fn bool Win_QextSerialPort::open(OpenMode mode)
+-			Opens a serial port.  Note that this function does not specify which device to open.  If you need
+-			to open a device by name, see Win_QextSerialPort::open(const char*).  This function has no effect
+-			if the port associated with the class is already open.  The port is also configured to the current
+-			settings, as stored in the Settings structure.
+-*/
+-bool Win_QextSerialPort::open(OpenMode mode) {
+-	unsigned long confSize = sizeof(COMMCONFIG);
+-	Win_CommConfig.dwSize = confSize;
+-	
+-	LOCK_MUTEX();
+-	if (mode == QIODevice::NotOpen)
+-		return isOpen();
+-	if (!isOpen()) {
+-		/*open the port*/
+-		Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE,
+-				FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+-		if (Win_Handle!=INVALID_HANDLE_VALUE) {
+-			/*set open mode*/
+-			QIODevice::open(mode);
+-			
+-			/*configure port settings*/
+-			GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
+-			GetCommState(Win_Handle, &(Win_CommConfig.dcb));
+-			
+-			/*set up parameters*/
+-			Win_CommConfig.dcb.fBinary=TRUE;
+-			Win_CommConfig.dcb.fInX=FALSE;
+-			Win_CommConfig.dcb.fOutX=FALSE;
+-			Win_CommConfig.dcb.fAbortOnError=FALSE;
+-			Win_CommConfig.dcb.fNull=FALSE;
+-			setBaudRate(Settings.BaudRate);
+-			setDataBits(Settings.DataBits);
+-			setStopBits(Settings.StopBits);
+-			setParity(Settings.Parity);
+-			setFlowControl(Settings.FlowControl);
+-			setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
+-			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return isOpen();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::close()
+-			Closes a serial port.  This function has no effect if the serial port associated with the class
+-			is not currently open.
+-*/
+-void Win_QextSerialPort::close() {
+-	LOCK_MUTEX();
+-	CloseHandle(Win_Handle);
+-	QIODevice::close();
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::flush()
+-			Flushes all pending I/O to the serial port.  This function has no effect if the serial port
+-			associated with the class is not currently open.
+-*/
+-void Win_QextSerialPort::flush() {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		FlushFileBuffers(Win_Handle);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::size() const
+-This function will return the number of bytes waiting in the receive queue of the serial port.
+-		It is included primarily to provide a complete QIODevice interface, and will not record errors
+-		in the lastErr member (because it is const).  This function is also not thread-safe - in
+-		multithreading situations, use Win_QextSerialPort::bytesAvailable() instead.
+-*/
+-qint64 Win_QextSerialPort::size() const {
+-	int availBytes;
+-	COMSTAT Win_ComStat;
+-	DWORD Win_ErrorMask=0;
+-	ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat);
+-	availBytes = Win_ComStat.cbInQue;
+-	return (qint64)availBytes;
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::bytesAvailable()
+-			Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
+-			the port is not currently open, or -1 on error.  Error information can be retrieved by calling
+-			Win_QextSerialPort::getLastError().
+-*/
+-qint64 Win_QextSerialPort::bytesAvailable() {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		DWORD Errors;
+-		COMSTAT Status;
+-		bool success=ClearCommError(Win_Handle, &Errors, &Status);
+-		translateError(Errors);
+-		if (success) {
+-			lastErr=E_NO_ERROR;
+-			UNLOCK_MUTEX();
+-			return Status.cbInQue + QIODevice::bytesAvailable();
+-		}
+-		UNLOCK_MUTEX();
+-		return (unsigned int)-1;
+-	}
+-	UNLOCK_MUTEX();
+-	return 0;
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::translateError(ulong error)
+-			Translates a system-specific error code to a QextSerialPort error code.  Used internally.
+-*/
+-void Win_QextSerialPort::translateError(ulong error) {
+-	if (error&CE_BREAK) {
+-		lastErr=E_BREAK_CONDITION;
+-	}
+-	else if (error&CE_FRAME) {
+-		lastErr=E_FRAMING_ERROR;
+-	}
+-	else if (error&CE_IOE) {
+-		lastErr=E_IO_ERROR;
+-	}
+-	else if (error&CE_MODE) {
+-		lastErr=E_INVALID_FD;
+-	}
+-	else if (error&CE_OVERRUN) {
+-		lastErr=E_BUFFER_OVERRUN;
+-	}
+-	else if (error&CE_RXPARITY) {
+-		lastErr=E_RECEIVE_PARITY_ERROR;
+-	}
+-	else if (error&CE_RXOVER) {
+-		lastErr=E_RECEIVE_OVERFLOW;
+-	}
+-	else if (error&CE_TXFULL) {
+-		lastErr=E_TRANSMIT_OVERFLOW;
+-	}
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
+-			Reads a block of data from the serial port.  This function will read at most maxlen bytes from
+-			the serial port and place them in the buffer pointed to by data.  Return value is the number of
+-			bytes actually read, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	COMSTAT Win_ComStat;
+-	DWORD Win_BytesRead=0;
+-	DWORD Win_ErrorMask=0;
+-	ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat);
+-	if (Win_ComStat.cbInQue &&
+-			(!ReadFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesRead, NULL)
+-			|| Win_BytesRead==0)) {
+-				lastErr=E_READ_FAILED;
+-		retVal=-1;
+-	}
+-	else {
+-		retVal=((int)Win_BytesRead);
+-	}
+-	UNLOCK_MUTEX();
+-	
+-	return retVal;
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize)
+-			Writes a block of data to the serial port.  This function will write len bytes
+-			from the buffer pointed to by data to the serial port.  Return value is the number
+-			of bytes actually written, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	DWORD Win_BytesWritten;
+-	if (!WriteFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesWritten, NULL)) {
+-		lastErr=E_WRITE_FAILED;
+-		retVal=-1;
+-	}
+-	else {
+-		retVal=((int)Win_BytesWritten);
+-	}
+-	UNLOCK_MUTEX();
+-	
+-	flush();
+-	return retVal;
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::ungetChar(char c)
+-			This function is included to implement the full QIODevice interface, and currently has no
+-			purpose within this class.  This function is meaningless on an unbuffered device and currently
+-			only prints a warning message to that effect.
+-*/
+-void Win_QextSerialPort::ungetChar(char c) {
+-	
+-	/*meaningless on unbuffered sequential device - return error and print a warning*/
+-	TTY_WARNING("Win_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setFlowControl(FlowType flow)
+-			Sets the flow control used by the port.  Possible values of flow are:
+-\verbatim
+-		FLOW_OFF            No flow control
+-		FLOW_HARDWARE       Hardware (RTS/CTS) flow control
+-		FLOW_XONXOFF        Software (XON/XOFF) flow control
+-		\endverbatim
+-*/
+-void Win_QextSerialPort::setFlowControl(FlowType flow) {
+-	LOCK_MUTEX();
+-	if (Settings.FlowControl!=flow) {
+-		Settings.FlowControl=flow;
+-	}
+-	if (isOpen()) {
+-		switch(flow) {
+-				
+-				/*no flow control*/
+-			case FLOW_OFF:
+-				Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
+-				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
+-				Win_CommConfig.dcb.fInX=FALSE;
+-				Win_CommConfig.dcb.fOutX=FALSE;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-				
+-				/*software (XON/XOFF) flow control*/
+-			case FLOW_XONXOFF:
+-				Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
+-				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
+-				Win_CommConfig.dcb.fInX=TRUE;
+-				Win_CommConfig.dcb.fOutX=TRUE;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-				
+-			case FLOW_HARDWARE:
+-				Win_CommConfig.dcb.fOutxCtsFlow=TRUE;
+-				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_HANDSHAKE;
+-				Win_CommConfig.dcb.fInX=FALSE;
+-				Win_CommConfig.dcb.fOutX=FALSE;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setParity(ParityType parity)
+-			Sets the parity associated with the serial port.  The possible values of parity are:
+-\verbatim
+-		PAR_SPACE       Space Parity
+-		PAR_MARK        Mark Parity
+-		PAR_NONE        No Parity
+-		PAR_EVEN        Even Parity
+-		PAR_ODD         Odd Parity
+-		\endverbatim
+-*/
+-void Win_QextSerialPort::setParity(ParityType parity) {
+-	LOCK_MUTEX();
+-	if (Settings.Parity!=parity) {
+-		Settings.Parity=parity;
+-	}
+-	if (isOpen()) {
+-		Win_CommConfig.dcb.Parity=(unsigned char)parity;
+-		switch (parity) {
+-				
+-				/*space parity*/
+-			case PAR_SPACE:
+-				if (Settings.DataBits==DATA_8) {
+-					TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: Space parity with 8 data bits is not supported by POSIX systems.");
+-				}
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-				
+-				/*mark parity - WINDOWS ONLY*/
+-			case PAR_MARK:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning:  Mark parity is not supported by POSIX systems");
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-				
+-				/*no parity*/
+-			case PAR_NONE:
+-				Win_CommConfig.dcb.fParity=FALSE;
+-				break;
+-				
+-				/*even parity*/
+-			case PAR_EVEN:
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-				
+-				/*odd parity*/
+-			case PAR_ODD:
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-			}
+-			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setDataBits(DataBitsType dataBits)
+-			Sets the number of data bits used by the serial port.  Possible values of dataBits are:
+-\verbatim
+-		DATA_5      5 data bits
+-		DATA_6      6 data bits
+-		DATA_7      7 data bits
+-		DATA_8      8 data bits
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following restrictions:
+-\par
+-		5 data bits cannot be used with 2 stop bits.
+-		\par
+-		1.5 stop bits can only be used with 5 data bits.
+-		\par
+-		8 data bits cannot be used with space parity on POSIX systems.
+-
+-*/
+-void Win_QextSerialPort::setDataBits(DataBitsType dataBits) {
+-	LOCK_MUTEX();
+-	if (Settings.DataBits!=dataBits) {
+-		if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
+-				(Settings.StopBits==STOP_1_5 && dataBits!=DATA_5)) {
+-				}
+-		else {
+-			Settings.DataBits=dataBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch(dataBits) {
+-				
+-				/*5 data bits*/
+-			case DATA_5:
+-				if (Settings.StopBits==STOP_2) {
+-					TTY_WARNING("Win_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=5;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*6 data bits*/
+-			case DATA_6:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Win_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=6;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*7 data bits*/
+-			case DATA_7:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Win_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=7;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*8 data bits*/
+-			case DATA_8:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Win_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=8;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setStopBits(StopBitsType stopBits)
+-			Sets the number of stop bits used by the serial port.  Possible values of stopBits are:
+-\verbatim
+-		STOP_1      1 stop bit
+-		STOP_1_5    1.5 stop bits
+-		STOP_2      2 stop bits
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following restrictions:
+-\par
+-		2 stop bits cannot be used with 5 data bits.
+-		\par
+-		1.5 stop bits cannot be used with 6 or more data bits.
+-		\par
+-		POSIX does not support 1.5 stop bits.
+-*/
+-void Win_QextSerialPort::setStopBits(StopBitsType stopBits) {
+-	LOCK_MUTEX();
+-	if (Settings.StopBits!=stopBits) {
+-		if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) ||
+-				(stopBits==STOP_1_5 && Settings.DataBits!=DATA_5)) {
+-				}
+-		else {
+-			Settings.StopBits=stopBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (stopBits) {
+-				
+-				/*one stop bit*/
+-			case STOP_1:
+-				Win_CommConfig.dcb.StopBits=ONESTOPBIT;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-				
+-				/*1.5 stop bits*/
+-			case STOP_1_5:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX.");
+-				if (Settings.DataBits!=DATA_5) {
+-					TTY_WARNING("Win_QextSerialPort: 1.5 stop bits can only be used with 5 data bits");
+-				}
+-				else {
+-					Win_CommConfig.dcb.StopBits=ONE5STOPBITS;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*two stop bits*/
+-			case STOP_2:
+-				if (Settings.DataBits==DATA_5) {
+-					TTY_WARNING("Win_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
+-				}
+-				else {
+-					Win_CommConfig.dcb.StopBits=TWOSTOPBITS;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setBaudRate(BaudRateType baudRate)
+-			Sets the baud rate of the serial port.  Note that not all rates are applicable on
+-			all platforms.  The following table shows translations of the various baud rate
+-			constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
+-			are speeds that are usable on both Windows and POSIX.
+-			\verbatim
+-
+-RATE          Windows Speed   POSIX Speed
+-		-----------   -------------   -----------
+-		BAUD50                 110          50
+-		BAUD75                 110          75
+-		*BAUD110                110         110
+-		BAUD134                110         134.5
+-		BAUD150                110         150
+-		BAUD200                110         200
+-		*BAUD300                300         300
+-		*BAUD600                600         600
+-		*BAUD1200              1200        1200
+-		BAUD1800              1200        1800
+-		*BAUD2400              2400        2400
+-		*BAUD4800              4800        4800
+-		*BAUD9600              9600        9600
+-		BAUD14400            14400        9600
+-		*BAUD19200            19200       19200
+-		*BAUD38400            38400       38400
+-		BAUD56000            56000       38400
+-		*BAUD57600            57600       57600
+-		BAUD76800            57600       76800
+-		*BAUD115200          115200      115200
+-		BAUD128000          128000      115200
+-		BAUD256000          256000      115200
+-		\endverbatim
+-*/
+-void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) {
+-	LOCK_MUTEX();
+-	if (Settings.BaudRate!=baudRate) {
+-		switch (baudRate) {
+-			case BAUD50:
+-			case BAUD75:
+-			case BAUD134:
+-			case BAUD150:
+-			case BAUD200:
+-				Settings.BaudRate=BAUD110;
+-				break;
+-				
+-			case BAUD1800:
+-				Settings.BaudRate=BAUD1200;
+-				break;
+-				
+-			case BAUD76800:
+-				Settings.BaudRate=BAUD57600;
+-				break;
+-				
+-			default:
+-				Settings.BaudRate=baudRate;
+-				break;
+-			}
+-	}
+-	if (isOpen()) {
+-		switch (baudRate) {
+-				
+-				/*50 baud*/
+-			case BAUD50:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 50 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*75 baud*/
+-			case BAUD75:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 75 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*110 baud*/
+-			case BAUD110:
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*134.5 baud*/
+-			case BAUD134:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 134.5 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*150 baud*/
+-			case BAUD150:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 150 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*200 baud*/
+-			case BAUD200:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 200 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*300 baud*/
+-			case BAUD300:
+-				Win_CommConfig.dcb.BaudRate=CBR_300;
+-				break;
+-				
+-				/*600 baud*/
+-			case BAUD600:
+-				Win_CommConfig.dcb.BaudRate=CBR_600;
+-				break;
+-				
+-				/*1200 baud*/
+-			case BAUD1200:
+-				Win_CommConfig.dcb.BaudRate=CBR_1200;
+-				break;
+-				
+-				/*1800 baud*/
+-			case BAUD1800:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 1800 baud operation.  Switching to 1200 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_1200;
+-				break;
+-				
+-				/*2400 baud*/
+-			case BAUD2400:
+-				Win_CommConfig.dcb.BaudRate=CBR_2400;
+-				break;
+-				
+-				/*4800 baud*/
+-			case BAUD4800:
+-				Win_CommConfig.dcb.BaudRate=CBR_4800;
+-				break;
+-				
+-				/*9600 baud*/
+-			case BAUD9600:
+-				Win_CommConfig.dcb.BaudRate=CBR_9600;
+-				break;
+-				
+-				/*14400 baud*/
+-			case BAUD14400:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 14400 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_14400;
+-				break;
+-				
+-				/*19200 baud*/
+-			case BAUD19200:
+-				Win_CommConfig.dcb.BaudRate=CBR_19200;
+-				break;
+-				
+-				/*38400 baud*/
+-			case BAUD38400:
+-				Win_CommConfig.dcb.BaudRate=CBR_38400;
+-				break;
+-				
+-				/*56000 baud*/
+-			case BAUD56000:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 56000 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_56000;
+-				break;
+-				
+-				/*57600 baud*/
+-			case BAUD57600:
+-				Win_CommConfig.dcb.BaudRate=CBR_57600;
+-				break;
+-				
+-				/*76800 baud*/
+-			case BAUD76800:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 76800 baud operation.  Switching to 57600 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_57600;
+-				break;
+-				
+-				/*115200 baud*/
+-			case BAUD115200:
+-				Win_CommConfig.dcb.BaudRate=CBR_115200;
+-				break;
+-				
+-				/*128000 baud*/
+-			case BAUD128000:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 128000 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_128000;
+-				break;
+-				
+-				/*256000 baud*/
+-			case BAUD256000:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 256000 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_256000;
+-				break;
+-			}
+-			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setDtr(bool set)
+-			Sets DTR line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Win_QextSerialPort::setDtr(bool set) {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		if (set) {
+-			EscapeCommFunction(Win_Handle, SETDTR);
+-		}
+-		else {
+-			EscapeCommFunction(Win_Handle, CLRDTR);
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setRts(bool set)
+-			Sets RTS line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Win_QextSerialPort::setRts(bool set) {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		if (set) {
+-			EscapeCommFunction(Win_Handle, SETRTS);
+-		}
+-		else {
+-			EscapeCommFunction(Win_Handle, CLRRTS);
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn ulong Win_QextSerialPort::lineStatus(void)
+-			returns the line status as stored by the port function.  This function will retrieve the states
+-			of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
+-			can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
+-			long with specific bits indicating which lines are high.  The following constants should be used
+-			to examine the states of individual lines:
+-
+-\verbatim
+-		Mask        Line
+-		------      ----
+-		LS_CTS      CTS
+-		LS_DSR      DSR
+-		LS_DCD      DCD
+-		LS_RI       RI
+-		\endverbatim
+-
+-This function will return 0 if the port associated with the class is not currently open.
+-*/
+-ulong Win_QextSerialPort::lineStatus(void) {
+-	unsigned long Status=0, Temp=0;
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		GetCommModemStatus(Win_Handle, &Temp);
+-		if (Temp&MS_CTS_ON) {
+-			Status|=LS_CTS;
+-		}
+-		if (Temp&MS_DSR_ON) {
+-			Status|=LS_DSR;
+-		}
+-		if (Temp&MS_RING_ON) {
+-			Status|=LS_RI;
+-		}
+-		if (Temp&MS_RLSD_ON) {
+-			Status|=LS_DCD;
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return Status;
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec);
+-Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.
+-*/
+-void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec) {
+-	LOCK_MUTEX();
+-	Settings.Timeout_Sec=sec;
+-	Settings.Timeout_Millisec=millisec;
+-	if(isOpen()) {
+-		Win_CommTimeouts.ReadIntervalTimeout = sec*1000+millisec;
+-		Win_CommTimeouts.ReadTotalTimeoutMultiplier = sec*1000+millisec;
+-		Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
+-		Win_CommTimeouts.WriteTotalTimeoutMultiplier = sec*1000+millisec;
+-		Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
+-		SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
+-	}
+-	UNLOCK_MUTEX();
+-}
+diff --git a/3rdparty/SerialPort/win_qextserialport.h b/3rdparty/SerialPort/win_qextserialport.h
+deleted file mode 100644
+index 09a28c7..0000000
+--- a/3rdparty/SerialPort/win_qextserialport.h
++++ /dev/null
+@@ -1,48 +0,0 @@
+-#ifndef _WIN_QEXTSERIALPORT_H_
+-#define _WIN_QEXTSERIALPORT_H_
+-
+-#include "qextserialbase.h"
+-
+-/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
+-#ifdef _TTY_NOWARN_
+-#define _TTY_NOWARN_PORT_
+-#endif
+-
+-#include <windows.h>
+-
+-class Win_QextSerialPort:public QextSerialBase {
+-public:
+-	Win_QextSerialPort();
+-	Win_QextSerialPort(Win_QextSerialPort const& s);
+-	Win_QextSerialPort(const QString & name);
+-	Win_QextSerialPort(const PortSettings& settings);
+-	Win_QextSerialPort(const QString & name, const PortSettings& settings);
+-	Win_QextSerialPort& operator=(const Win_QextSerialPort& s);
+-	virtual ~Win_QextSerialPort();
+-	virtual bool open(OpenMode mode=0);
+-	virtual void close();
+-	virtual void flush();
+-	virtual qint64 size() const;
+-	virtual void ungetChar(char c);
+-	virtual void setFlowControl(FlowType);
+-	virtual void setParity(ParityType);
+-	virtual void setDataBits(DataBitsType);
+-	virtual void setStopBits(StopBitsType);
+-	virtual void setBaudRate(BaudRateType);
+-	virtual void setDtr(bool set=true);
+-	virtual void setRts(bool set=true);
+-	virtual ulong lineStatus(void);
+-	virtual qint64 bytesAvailable();
+-	virtual void translateError(ulong);
+-	virtual void setTimeout(ulong, ulong);
+-	
+-protected:
+-	HANDLE Win_Handle;
+-	COMMCONFIG Win_CommConfig;
+-	COMMTIMEOUTS Win_CommTimeouts;
+-	
+-	virtual qint64 readData(char *data, qint64 maxSize);
+-	virtual qint64 writeData(const char *data, qint64 maxSize);
+-};
+-
+-#endif
+-- 
+1.8.5.3
+
+
+From ee3af7fa3cade2ab3efa90edb3262899f75737c1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan at danny.cz>
+Date: Sun, 23 Mar 2014 14:22:22 +0100
+Subject: [PATCH 2/3] rebase QExtserialPort to version 1.2
+
+---
+ 3rdparty/SerialPort/CMakeLists.txt                 |   21 +-
+ 3rdparty/SerialPort/ManageSerialPort.cpp           |   55 +-
+ 3rdparty/SerialPort/ManageSerialPort.h             |    2 +-
+ 3rdparty/SerialPort/qextserialport/CMakeLists.txt  |   44 +
+ .../qextserialport/posix_qextserialport.cpp        | 1114 --------------------
+ .../qextserialport/posix_qextserialport.h          |   56 -
+ .../SerialPort/qextserialport/qextserialbase.cpp   |  250 -----
+ .../SerialPort/qextserialport/qextserialbase.h     |  196 ----
+ .../SerialPort/qextserialport/qextserialport.cpp   | 1109 +++++++++++++++++--
+ .../SerialPort/qextserialport/qextserialport.h     |  267 ++++-
+ .../qextserialport/qextserialport_global.h         |   72 ++
+ .../SerialPort/qextserialport/qextserialport_p.h   |  257 +++++
+ .../qextserialport/qextserialport_unix.cpp         |  455 ++++++++
+ .../qextserialport/qextserialport_win.cpp          |  427 ++++++++
+ .../qextserialport/win_qextserialport.cpp          |  877 ---------------
+ .../SerialPort/qextserialport/win_qextserialport.h |   48 -
+ CMakeLists.txt                                     |    1 +
+ src/CMakeLists.txt                                 |    1 +
+ 18 files changed, 2517 insertions(+), 2735 deletions(-)
+ create mode 100644 3rdparty/SerialPort/qextserialport/CMakeLists.txt
+ delete mode 100644 3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp
+ delete mode 100644 3rdparty/SerialPort/qextserialport/posix_qextserialport.h
+ delete mode 100644 3rdparty/SerialPort/qextserialport/qextserialbase.cpp
+ delete mode 100644 3rdparty/SerialPort/qextserialport/qextserialbase.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialport_global.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialport_p.h
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialport_unix.cpp
+ create mode 100644 3rdparty/SerialPort/qextserialport/qextserialport_win.cpp
+ delete mode 100644 3rdparty/SerialPort/qextserialport/win_qextserialport.cpp
+ delete mode 100644 3rdparty/SerialPort/qextserialport/win_qextserialport.h
+
+diff --git a/3rdparty/SerialPort/CMakeLists.txt b/3rdparty/SerialPort/CMakeLists.txt
+index 99fd911..c878380 100644
+--- a/3rdparty/SerialPort/CMakeLists.txt
++++ b/3rdparty/SerialPort/CMakeLists.txt
+@@ -12,18 +12,10 @@ include(${QT_USE_FILE})
+ 
+ set(SRCS
+     ManageSerialPort.cpp
+-#    posix_qextserialport.cpp
+-    qextserialport/qextserialbase.cpp
+-    qextserialport/qextserialport.cpp
+-#    win_qextserialport.cpp
+ )
+ 
+ set(HDRS
+     ManageSerialPort.h
+-#    posix_qextserialport.h
+-    qextserialport/qextserialbase.h
+-    qextserialport/qextserialport.h
+-#    win_qextserialport.h
+ )
+ 
+ set(UIS
+@@ -35,15 +27,6 @@ set(RCS
+ 
+ )
+ 
+-if(WIN32)
+-    set(SRCS ${SRCS} qextserialport/win_qextserialport.cpp)
+-    set(HDRS ${HDRS} qextserialport/win_qextserialport.h)
+-else (WIN32)
+-    set(SRCS ${SRCS} qextserialport/posix_qextserialport.cpp)
+-    set(HDRS ${HDRS} qextserialport/posix_qextserialport.h)
+-    add_definitions(-D_TTY_POSIX_)
+-endif(WIN32)
+-
+ 
+ qt4_wrap_cpp(MOC_SRCS ${HDRS})
+ qt4_wrap_ui(UI_HDRS ${UIS})
+@@ -52,7 +35,7 @@ qt4_add_resources(RC_SRCS ${RCS})
+ 
+ 
+ include_directories(
+-
++    qextserialport
+ )
+ 
+ link_directories(
+@@ -69,5 +52,5 @@ add_library(SerialPort
+ )
+ 
+ target_link_libraries( SerialPort
+-      ${QT_LIBRARIES}
++      ${QT_LIBRARIES} qextserialport
+ )
+diff --git a/3rdparty/SerialPort/ManageSerialPort.cpp b/3rdparty/SerialPort/ManageSerialPort.cpp
+index 86ff143..ddbac2e 100644
+--- a/3rdparty/SerialPort/ManageSerialPort.cpp
++++ b/3rdparty/SerialPort/ManageSerialPort.cpp
+@@ -148,54 +148,7 @@ void ManageSerialPort::setBaudRate(const BaudRateType baudRate)
+ 
+ QString ManageSerialPort::getBaudRate()
+ {
+-	switch (extSerialPort.baudRate())
+-	{
+-		case BAUD50:
+-			return QString("50");
+-		case BAUD75:
+-			return QString("75");
+-		case BAUD110:
+-			return QString("110");
+-		case BAUD134:
+-			return QString("134");
+-		case BAUD150:
+-			return QString("150");
+-		case BAUD200:
+-			return QString("200");
+-		case BAUD300:
+-			return QString("300");
+-		case BAUD600:
+-			return QString("600");
+-		case BAUD1200:
+-			return QString("1200");
+-		case BAUD1800:
+-			return QString("1800");
+-		case BAUD2400:
+-			return QString("2400");
+-		case BAUD4800:
+-			return QString("4800");
+-		case BAUD9600:
+-			return QString("9600");
+-		case BAUD14400:
+-			return QString("14400");
+-		case BAUD19200:
+-			return QString("19200");
+-		case BAUD38400:
+-			return QString("38400");
+-		case BAUD56000:
+-			return QString("56000");
+-		case BAUD57600:
+-			return QString("57600");
+-		case BAUD76800:
+-			return QString("76800");
+-		case BAUD115200:
+-			return QString("115200");
+-		case BAUD128000:
+-			return QString("128000");
+-		case BAUD256000:
+-			return QString("256000");
+-	}
+-	return 0;
++	return QString::number(extSerialPort.baudRate());
+ }
+ 
+ 
+@@ -236,8 +189,10 @@ QString ManageSerialPort::getParity()
+ 			return QString(tr("Odd"));
+ 		case PAR_EVEN:
+ 			return QString(tr("Even"));
++#ifdef Q_OS_WIN
+ 		case PAR_MARK:
+ 			return QString(tr("Mark"));
++#endif
+ 		case PAR_SPACE:
+ 			return QString(tr("Space"));
+ 		}
+@@ -256,8 +211,10 @@ QString ManageSerialPort::getStopBit()
+ 	{
+ 		case STOP_1:
+ 			return QString("1");
++#ifdef Q_OS_WIN
+ 		case STOP_1_5:
+ 			return QString("1.5");
++#endif
+ 		case STOP_2:
+ 			return QString("2");
+ 		}
+@@ -287,7 +244,7 @@ QString ManageSerialPort::getFlowControl()
+ 
+ void ManageSerialPort::setTimeout(ulong seconds, ulong milliseconds)
+ {
+-	extSerialPort.setTimeout(seconds,milliseconds);
++	extSerialPort.setTimeout(seconds * 1000 + milliseconds);
+ }
+ 
+ /*
+diff --git a/3rdparty/SerialPort/ManageSerialPort.h b/3rdparty/SerialPort/ManageSerialPort.h
+index 863b8ec..1754cd9 100644
+--- a/3rdparty/SerialPort/ManageSerialPort.h
++++ b/3rdparty/SerialPort/ManageSerialPort.h
+@@ -13,7 +13,7 @@
+ #include <QQueue>
+ #include <QMetaType>
+ #include <QMutex>
+-#include "qextserialport/qextserialport.h"
++#include <qextserialport.h>
+ 
+ Q_DECLARE_METATYPE(BaudRateType);
+ Q_DECLARE_METATYPE(DataBitsType);
+diff --git a/3rdparty/SerialPort/qextserialport/CMakeLists.txt b/3rdparty/SerialPort/qextserialport/CMakeLists.txt
+new file mode 100644
+index 0000000..8e167f5
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/CMakeLists.txt
+@@ -0,0 +1,44 @@
++project(qextserialport)
++
++# Required cmake version
++cmake_minimum_required(VERSION 2.8.6)
++
++
++set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
++
++find_package(Qt4 REQUIRED)
++
++include(${QT_USE_FILE})
++
++set(SRCS
++    qextserialport.cpp
++)
++
++set(HDRS
++    qextserialport.h
++)
++
++if(WIN32)
++    set(SRCS ${SRCS} qextserialport_win.cpp)
++else (WIN32)
++    set(SRCS ${SRCS} qextserialport_unix.cpp)
++endif(WIN32)
++
++
++include_directories(
++)
++
++link_directories(
++    ${CMAKE_BINARY_DIR}/lib
++)
++
++add_library(qextserialport
++  ${SRCS}
++  ${HDRS}
++)
++
++set_target_properties(qextserialport PROPERTIES AUTOMOC TRUE)
++
++target_link_libraries( qextserialport
++      ${QT_LIBRARIES}
++)
+diff --git a/3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp b/3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp
+deleted file mode 100644
+index 0982349..0000000
+--- a/3rdparty/SerialPort/qextserialport/posix_qextserialport.cpp
++++ /dev/null
+@@ -1,1114 +0,0 @@
+-
+-/*!
+-		\class Posix_QextSerialPort
+-		\version 1.0.0
+-		\author Stefan Sander
+-
+-A cross-platform serial port class.
+-		This class encapsulates the POSIX portion of QextSerialPort.  The user will be notified of errors
+-		and possible portability conflicts at run-time by default - this behavior can be turned off by
+-		defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off portability
+-		warnings) in the project.  Note that _TTY_NOWARN_ will also turn off portability warnings.
+-*/
+-
+-#include <stdio.h>
+-#include "posix_qextserialport.h"
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort()
+-			Default constructor.  Note that the name of the device used by a QextSerialPort constructed with
+-			this constructor will be determined by #defined constants, or lack thereof - the default behavior
+-			is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:
+-
+-\verbatim
+-
+-Constant         Used By         Naming Convention
+-		----------       -------------   ------------------------
+-		_TTY_WIN_        Windows         COM1, COM2
+-		_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
+-		_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
+-		_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
+-		_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
+-		_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
+-		_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
+-		<none>           Linux           /dev/ttyS0, /dev/ttyS1
+-		\endverbatim
+-
+-This constructor assigns the device name to the name of the first port on the specified system.
+-		See the other constructors if you need to open a different port.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort()
+-	: QextSerialBase()
+-{
+-	Posix_File=new QFile();
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort&)
+-			Copy constructor.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort& s)
+-	: QextSerialBase(s.port)
+-{
+-	setOpenMode(s.openMode());
+-	port = s.port;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	lastErr=s.lastErr;
+-	
+-	Posix_File=new QFile();
+-	Posix_File=s.Posix_File;
+-	memcpy(&Posix_Timeout, &s.Posix_Timeout, sizeof(struct timeval));
+-	memcpy(&Posix_Copy_Timeout, &s.Posix_Copy_Timeout, sizeof(struct timeval));
+-	memcpy(&Posix_CommConfig, &s.Posix_CommConfig, sizeof(struct termios));
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name)
+-			Constructs a serial port attached to the port specified by name.
+-			name is the name of the device, which is windowsystem-specific,
+-			e.g."COM1" or "/dev/ttyS0".
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const QString & name)
+-	: QextSerialBase(name)
+-{
+-	Posix_File=new QFile();
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
+-			Constructs a port with default name and specified settings.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
+-	: QextSerialBase()
+-{
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setParity(settings.Parity);
+-	setStopBits(settings.StopBits);
+-	setFlowControl(settings.FlowControl);
+-	
+-	Posix_File=new QFile();
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings)
+-			Constructs a port with specified name and settings.
+-*/
+-Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings)
+-	: QextSerialBase(name)
+-{
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setParity(settings.Parity);
+-	setStopBits(settings.StopBits);
+-	setFlowControl(settings.FlowControl);
+-	
+-	Posix_File=new QFile();
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
+-			Override the = operator.
+-*/
+-Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s)
+-{
+-	setOpenMode(s.openMode());
+-	port = s.port;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	lastErr=s.lastErr;
+-	
+-	Posix_File=s.Posix_File;
+-	memcpy(&Posix_Timeout, &(s.Posix_Timeout), sizeof(struct timeval));
+-	memcpy(&Posix_Copy_Timeout, &(s.Posix_Copy_Timeout), sizeof(struct timeval));
+-	memcpy(&Posix_CommConfig, &(s.Posix_CommConfig), sizeof(struct termios));
+-	return *this;
+-}
+-
+-/*!
+-		\fn Posix_QextSerialPort::~Posix_QextSerialPort()
+-			Standard destructor.
+-*/
+-Posix_QextSerialPort::~Posix_QextSerialPort()
+-{
+-	if (isOpen()) {
+-		close();
+-	}
+-	Posix_File->close();
+-	delete Posix_File;
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
+-			Sets the baud rate of the serial port.  Note that not all rates are applicable on
+-			all platforms.  The following table shows translations of the various baud rate
+-			constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
+-			are speeds that are usable on both Windows and POSIX.
+-
+-\note
+-		BAUD76800 may not be supported on all POSIX systems.  SGI/IRIX systems do not support
+-		BAUD1800.
+-
+-\verbatim
+-
+-RATE          Windows Speed   POSIX Speed
+-		-----------   -------------   -----------
+-		BAUD50                 110          50
+-		BAUD75                 110          75
+-		*BAUD110                110         110
+-		BAUD134                110         134.5
+-		BAUD150                110         150
+-		BAUD200                110         200
+-		*BAUD300                300         300
+-		*BAUD600                600         600
+-		*BAUD1200              1200        1200
+-		BAUD1800              1200        1800
+-		*BAUD2400              2400        2400
+-		*BAUD4800              4800        4800
+-		*BAUD9600              9600        9600
+-		BAUD14400            14400        9600
+-		*BAUD19200            19200       19200
+-		*BAUD38400            38400       38400
+-		BAUD56000            56000       38400
+-		*BAUD57600            57600       57600
+-		BAUD76800            57600       76800
+-		*BAUD115200          115200      115200
+-		BAUD128000          128000      115200
+-		BAUD256000          256000      115200
+-		\endverbatim
+-*/
+-void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.BaudRate!=baudRate) {
+-		switch (baudRate) {
+-			case BAUD14400:
+-				Settings.BaudRate=BAUD9600;
+-				break;
+-				
+-			case BAUD56000:
+-				Settings.BaudRate=BAUD38400;
+-				break;
+-				
+-			case BAUD76800:
+-				
+-				#ifndef B76800
+-							Settings.BaudRate=BAUD57600;
+-				#else
+-				Settings.BaudRate=baudRate;
+-				#endif
+-							break;
+-				
+-			case BAUD128000:
+-			case BAUD256000:
+-				Settings.BaudRate=BAUD115200;
+-				break;
+-				
+-			default:
+-				Settings.BaudRate=baudRate;
+-				break;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (baudRate) {
+-				
+-				/*50 baud*/
+-			case BAUD50:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 50 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B50;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B50);
+-				cfsetospeed(&Posix_CommConfig, B50);
+-				#endif
+-							break;
+-				
+-				/*75 baud*/
+-			case BAUD75:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 75 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B75;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B75);
+-				cfsetospeed(&Posix_CommConfig, B75);
+-				#endif
+-							break;
+-				
+-				/*110 baud*/
+-			case BAUD110:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B110;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B110);
+-				cfsetospeed(&Posix_CommConfig, B110);
+-				#endif
+-							break;
+-				
+-				/*134.5 baud*/
+-			case BAUD134:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 134.5 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B134;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B134);
+-				cfsetospeed(&Posix_CommConfig, B134);
+-				#endif
+-							break;
+-				
+-				/*150 baud*/
+-			case BAUD150:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 150 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B150;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B150);
+-				cfsetospeed(&Posix_CommConfig, B150);
+-				#endif
+-							break;
+-				
+-				/*200 baud*/
+-			case BAUD200:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 200 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B200);
+-				cfsetospeed(&Posix_CommConfig, B200);
+-				#endif
+-							break;
+-				
+-				/*300 baud*/
+-			case BAUD300:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B300;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B300);
+-				cfsetospeed(&Posix_CommConfig, B300);
+-				#endif
+-							break;
+-				
+-				/*600 baud*/
+-			case BAUD600:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B600);
+-				cfsetospeed(&Posix_CommConfig, B600);
+-				#endif
+-							break;
+-				
+-				/*1200 baud*/
+-			case BAUD1200:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B1200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B1200);
+-				cfsetospeed(&Posix_CommConfig, B1200);
+-				#endif
+-							break;
+-				
+-				/*1800 baud*/
+-			case BAUD1800:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and IRIX do not support 1800 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B1800;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B1800);
+-				cfsetospeed(&Posix_CommConfig, B1800);
+-				#endif
+-							break;
+-				
+-				/*2400 baud*/
+-			case BAUD2400:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B2400;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B2400);
+-				cfsetospeed(&Posix_CommConfig, B2400);
+-				#endif
+-							break;
+-				
+-				/*4800 baud*/
+-			case BAUD4800:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B4800;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B4800);
+-				cfsetospeed(&Posix_CommConfig, B4800);
+-				#endif
+-							break;
+-				
+-				/*9600 baud*/
+-			case BAUD9600:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B9600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B9600);
+-				cfsetospeed(&Posix_CommConfig, B9600);
+-				#endif
+-							break;
+-				
+-				/*14400 baud*/
+-			case BAUD14400:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 14400 baud operation.  Switching to 9600 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B9600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B9600);
+-				cfsetospeed(&Posix_CommConfig, B9600);
+-				#endif
+-							break;
+-				
+-				/*19200 baud*/
+-			case BAUD19200:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B19200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B19200);
+-				cfsetospeed(&Posix_CommConfig, B19200);
+-				#endif
+-							break;
+-				
+-				/*38400 baud*/
+-			case BAUD38400:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B38400;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B38400);
+-				cfsetospeed(&Posix_CommConfig, B38400);
+-				#endif
+-							break;
+-				
+-				/*56000 baud*/
+-			case BAUD56000:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 56000 baud operation.  Switching to 38400 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B38400;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B38400);
+-				cfsetospeed(&Posix_CommConfig, B38400);
+-				#endif
+-							break;
+-				
+-				/*57600 baud*/
+-			case BAUD57600:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B57600;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B57600);
+-				cfsetospeed(&Posix_CommConfig, B57600);
+-				#endif
+-							break;
+-				
+-				/*76800 baud*/
+-			case BAUD76800:
+-				TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and some POSIX systems do not support 76800 baud operation.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				
+-				#ifdef B76800
+-							Posix_CommConfig.c_cflag|=B76800;
+-				#else
+-				TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
+-				Posix_CommConfig.c_cflag|=B57600;
+-				#endif //B76800
+-				#else  //CBAUD
+-				#ifdef B76800
+-							cfsetispeed(&Posix_CommConfig, B76800);
+-				cfsetospeed(&Posix_CommConfig, B76800);
+-				#else
+-				TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
+-				cfsetispeed(&Posix_CommConfig, B57600);
+-				cfsetospeed(&Posix_CommConfig, B57600);
+-				#endif //B76800
+-				#endif //CBAUD
+-							break;
+-				
+-				/*115200 baud*/
+-			case BAUD115200:
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B115200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B115200);
+-				cfsetospeed(&Posix_CommConfig, B115200);
+-				#endif
+-							break;
+-				
+-				/*128000 baud*/
+-			case BAUD128000:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 128000 baud operation.  Switching to 115200 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B115200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B115200);
+-				cfsetospeed(&Posix_CommConfig, B115200);
+-				#endif
+-							break;
+-				
+-				/*256000 baud*/
+-			case BAUD256000:
+-				TTY_WARNING("Posix_QextSerialPort: POSIX does not support 256000 baud operation.  Switching to 115200 baud.");
+-				#ifdef CBAUD
+-							Posix_CommConfig.c_cflag&=(~CBAUD);
+-				Posix_CommConfig.c_cflag|=B115200;
+-				#else
+-				cfsetispeed(&Posix_CommConfig, B115200);
+-				cfsetospeed(&Posix_CommConfig, B115200);
+-				#endif
+-							break;
+-			}
+-			tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setDataBits(DataBitsType dataBits)
+-			Sets the number of data bits used by the serial port.  Possible values of dataBits are:
+-\verbatim
+-		DATA_5      5 data bits
+-		DATA_6      6 data bits
+-		DATA_7      7 data bits
+-		DATA_8      8 data bits
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following restrictions:
+-\par
+-		5 data bits cannot be used with 2 stop bits.
+-		\par
+-		8 data bits cannot be used with space parity on POSIX systems.
+-
+-*/
+-void Posix_QextSerialPort::setDataBits(DataBitsType dataBits)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.DataBits!=dataBits) {
+-		if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
+-				(Settings.StopBits==STOP_1_5 && dataBits!=DATA_5) ||
+-				(Settings.Parity==PAR_SPACE && dataBits==DATA_8)) {
+-				}
+-		else {
+-			Settings.DataBits=dataBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch(dataBits) {
+-				
+-				/*5 data bits*/
+-			case DATA_5:
+-				if (Settings.StopBits==STOP_2) {
+-					TTY_WARNING("Posix_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS5;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*6 data bits*/
+-			case DATA_6:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS6;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*7 data bits*/
+-			case DATA_7:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS7;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*8 data bits*/
+-			case DATA_8:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Settings.DataBits=dataBits;
+-					Posix_CommConfig.c_cflag&=(~CSIZE);
+-					Posix_CommConfig.c_cflag|=CS8;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setParity(ParityType parity)
+-			Sets the parity associated with the serial port.  The possible values of parity are:
+-\verbatim
+-		PAR_SPACE       Space Parity
+-		PAR_MARK        Mark Parity
+-		PAR_NONE        No Parity
+-		PAR_EVEN        Even Parity
+-		PAR_ODD         Odd Parity
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following limitations:
+-\par
+-		POSIX systems do not support mark parity.
+-		\par
+-		POSIX systems support space parity only if tricked into doing so, and only with
+-		fewer than 8 data bits.  Use space parity very carefully with POSIX systems.
+-
+-*/
+-void Posix_QextSerialPort::setParity(ParityType parity)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.Parity!=parity) {
+-		if (parity==PAR_MARK || (parity==PAR_SPACE && Settings.DataBits==DATA_8)) {
+-		}
+-		else {
+-			Settings.Parity=parity;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (parity) {
+-				
+-				/*space parity*/
+-			case PAR_SPACE:
+-				if (Settings.DataBits==DATA_8) {
+-					TTY_PORTABILITY_WARNING("Posix_QextSerialPort:  Space parity is only supported in POSIX with 7 or fewer data bits");
+-				}
+-				else {
+-					
+-					/*space parity not directly supported - add an extra data bit to simulate it*/
+-					Posix_CommConfig.c_cflag&=~(PARENB|CSIZE);
+-				switch(Settings.DataBits) {
+-					case DATA_5:
+-						Settings.DataBits=DATA_6;
+-						Posix_CommConfig.c_cflag|=CS6;
+-						break;
+-						
+-					case DATA_6:
+-						Settings.DataBits=DATA_7;
+-						Posix_CommConfig.c_cflag|=CS7;
+-						break;
+-						
+-					case DATA_7:
+-						Settings.DataBits=DATA_8;
+-						Posix_CommConfig.c_cflag|=CS8;
+-						break;
+-						
+-					case DATA_8:
+-						break;
+-					}
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-				
+-				/*mark parity - WINDOWS ONLY*/
+-			case PAR_MARK:
+-				TTY_WARNING("Posix_QextSerialPort: Mark parity is not supported by POSIX.");
+-				break;
+-				
+-				/*no parity*/
+-			case PAR_NONE:
+-				Posix_CommConfig.c_cflag&=(~PARENB);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*even parity*/
+-			case PAR_EVEN:
+-				Posix_CommConfig.c_cflag&=(~PARODD);
+-				Posix_CommConfig.c_cflag|=PARENB;
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*odd parity*/
+-			case PAR_ODD:
+-				Posix_CommConfig.c_cflag|=(PARENB|PARODD);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setStopBits(StopBitsType stopBits)
+-			Sets the number of stop bits used by the serial port.  Possible values of stopBits are:
+-\verbatim
+-		STOP_1      1 stop bit
+-		STOP_1_5    1.5 stop bits
+-		STOP_2      2 stop bits
+-		\endverbatim
+-		\note
+-		This function is subject to the following restrictions:
+-\par
+-		2 stop bits cannot be used with 5 data bits.
+-		\par
+-		POSIX does not support 1.5 stop bits.
+-
+-*/
+-void Posix_QextSerialPort::setStopBits(StopBitsType stopBits)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.StopBits!=stopBits) {
+-		if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) || stopBits==STOP_1_5) {}
+-		else {
+-			Settings.StopBits=stopBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (stopBits) {
+-				
+-				/*one stop bit*/
+-			case STOP_1:
+-				Settings.StopBits=stopBits;
+-				Posix_CommConfig.c_cflag&=(~CSTOPB);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*1.5 stop bits*/
+-			case STOP_1_5:
+-				TTY_WARNING("Posix_QextSerialPort: 1.5 stop bit operation is not supported by POSIX.");
+-				break;
+-				
+-				/*two stop bits*/
+-			case STOP_2:
+-				if (Settings.DataBits==DATA_5) {
+-					TTY_WARNING("Posix_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
+-				}
+-				else {
+-					Settings.StopBits=stopBits;
+-					Posix_CommConfig.c_cflag|=CSTOPB;
+-					tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setFlowControl(FlowType flow)
+-			Sets the flow control used by the port.  Possible values of flow are:
+-\verbatim
+-		FLOW_OFF            No flow control
+-		FLOW_HARDWARE       Hardware (RTS/CTS) flow control
+-		FLOW_XONXOFF        Software (XON/XOFF) flow control
+-		\endverbatim
+-		\note
+-		FLOW_HARDWARE may not be supported on all versions of UNIX.  In cases where it is
+-		unsupported, FLOW_HARDWARE is the same as FLOW_OFF.
+-
+-*/
+-void Posix_QextSerialPort::setFlowControl(FlowType flow)
+-{
+-	LOCK_MUTEX();
+-	if (Settings.FlowControl!=flow) {
+-		Settings.FlowControl=flow;
+-	}
+-	if (isOpen()) {
+-		switch(flow) {
+-				
+-				/*no flow control*/
+-			case FLOW_OFF:
+-				Posix_CommConfig.c_cflag&=(~CRTSCTS);
+-				Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-				/*software (XON/XOFF) flow control*/
+-			case FLOW_XONXOFF:
+-				Posix_CommConfig.c_cflag&=(~CRTSCTS);
+-				Posix_CommConfig.c_iflag|=(IXON|IXOFF|IXANY);
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-				
+-			case FLOW_HARDWARE:
+-				Posix_CommConfig.c_cflag|=CRTSCTS;
+-				Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
+-				tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec);
+-Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.
+-		Note that this is a per-character timeout, i.e. the port will wait this long for each
+-		individual character, not for the whole read operation.  This timeout also applies to the
+-		bytesWaiting() function.
+-
+-\note
+-		POSIX does not support millisecond-level control for I/O timeout values.  Any
+-		timeout set using this function will be set to the next lowest tenth of a second for
+-		the purposes of detecting read or write timeouts.  For example a timeout of 550 milliseconds
+-		will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and
+-		writing the port.  However millisecond-level control is allowed by the select() system call,
+-		so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for
+-		the purpose of detecting available bytes in the read buffer.
+-
+-*/
+-void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec)
+-{
+-	LOCK_MUTEX();
+-	Settings.Timeout_Sec=sec;
+-	Settings.Timeout_Millisec=millisec;
+-	Posix_Copy_Timeout.tv_sec=sec;
+-	Posix_Copy_Timeout.tv_usec=millisec;
+-	if (isOpen()) {
+-		tcgetattr(Posix_File->handle(), &Posix_CommConfig);
+-		Posix_CommConfig.c_cc[VTIME]=sec*10+millisec/100;
+-		tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn bool Posix_QextSerialPort::open(OpenMode mode)
+-			Opens the serial port associated to this class.
+-			This function has no effect if the port associated with the class is already open.
+-			The port is also configured to the current settings, as stored in the Settings structure.
+-*/
+-bool Posix_QextSerialPort::open(OpenMode mode)
+-{
+-	LOCK_MUTEX();
+-	if (mode == QIODevice::NotOpen)
+-		return isOpen();
+-	if (!isOpen()) {
+-		/*open the port*/
+-		Posix_File->setFileName(port);
+-		if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
+-			/*set open mode*/
+-			QIODevice::open(mode);
+-			
+-			/*configure port settings*/
+-			tcgetattr(Posix_File->handle(), &Posix_CommConfig);
+-			
+-			/*set up other port settings*/
+-			Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
+-			Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
+-			Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
+-			Posix_CommConfig.c_oflag&=(~OPOST);
+-			Posix_CommConfig.c_cc[VMIN]=0;
+-			Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
+-			Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
+-			setBaudRate(Settings.BaudRate);
+-			setDataBits(Settings.DataBits);
+-			setParity(Settings.Parity);
+-			setStopBits(Settings.StopBits);
+-			setFlowControl(Settings.FlowControl);
+-			setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
+-			tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
+-		} else {
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return isOpen();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::close()
+-			Closes a serial port.  This function has no effect if the serial port associated with the class
+-			is not currently open.
+-*/
+-void Posix_QextSerialPort::close()
+-{
+-	LOCK_MUTEX();
+-	Posix_File->close();
+-	QIODevice::close();
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::flush()
+-			Flushes all pending I/O to the serial port.  This function has no effect if the serial port
+-			associated with the class is not currently open.
+-*/
+-void Posix_QextSerialPort::flush()
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		Posix_File->flush();
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::size() const
+-This function will return the number of bytes waiting in the receive queue of the serial port.
+-		It is included primarily to provide a complete QIODevice interface, and will not record errors
+-		in the lastErr member (because it is const).  This function is also not thread-safe - in
+-		multithreading situations, use Posix_QextSerialPort::bytesWaiting() instead.
+-*/
+-qint64 Posix_QextSerialPort::size() const
+-{
+-	int numBytes;
+-	if (ioctl(Posix_File->handle(), FIONREAD, &numBytes)<0) {
+-		numBytes=0;
+-	}
+-	return (qint64)numBytes;
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::bytesAvailable()
+-			Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
+-			the port is not currently open, or -1 on error.  Error information can be retrieved by calling
+-			Posix_QextSerialPort::getLastError().
+-*/
+-qint64 Posix_QextSerialPort::bytesAvailable()
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		int bytesQueued;
+-		fd_set fileSet;
+-		FD_ZERO(&fileSet);
+-		FD_SET(Posix_File->handle(), &fileSet);
+-		
+-		/*on Linux systems the Posix_Timeout structure will be altered by the select() call.
+-				Make sure we use the right timeout values*/
+-		//memcpy(&Posix_Timeout, &Posix_Copy_Timeout, sizeof(struct timeval));
+-		Posix_Timeout = Posix_Copy_Timeout;
+-		int n=select(Posix_File->handle()+1, &fileSet, NULL, &fileSet, &Posix_Timeout);
+-		if (!n) {
+-			lastErr=E_PORT_TIMEOUT;
+-			UNLOCK_MUTEX();
+-			return -1;
+-		}
+-		if (n==-1 || ioctl(Posix_File->handle(), FIONREAD, &bytesQueued)==-1) {
+-			translateError(errno);
+-			UNLOCK_MUTEX();
+-			return -1;
+-		}
+-		lastErr=E_NO_ERROR;
+-		UNLOCK_MUTEX();
+-		return bytesQueued + QIODevice::bytesAvailable();
+-	}
+-	UNLOCK_MUTEX();
+-	return 0;
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::ungetChar(char)
+-			This function is included to implement the full QIODevice interface, and currently has no
+-			purpose within this class.  This function is meaningless on an unbuffered device and currently
+-			only prints a warning message to that effect.
+-*/
+-void Posix_QextSerialPort::ungetChar(char)
+-{
+-	/*meaningless on unbuffered sequential device - return error and print a warning*/
+-	TTY_WARNING("Posix_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::translateError(ulong error)
+-			Translates a system-specific error code to a QextSerialPort error code.  Used internally.
+-*/
+-void Posix_QextSerialPort::translateError(ulong error)
+-{
+-	switch (error) {
+-		case EBADF:
+-		case ENOTTY:
+-			lastErr=E_INVALID_FD;
+-			break;
+-			
+-		case EINTR:
+-			lastErr=E_CAUGHT_NON_BLOCKED_SIGNAL;
+-			break;
+-			
+-		case ENOMEM:
+-			lastErr=E_NO_MEMORY;
+-			break;
+-		}
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setDtr(bool set)
+-			Sets DTR line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Posix_QextSerialPort::setDtr(bool set)
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		int status;
+-		ioctl(Posix_File->handle(), TIOCMGET, &status);
+-		if (set) {
+-			status|=TIOCM_DTR;
+-		}
+-		else {
+-			status&=~TIOCM_DTR;
+-		}
+-		ioctl(Posix_File->handle(), TIOCMSET, &status);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Posix_QextSerialPort::setRts(bool set)
+-			Sets RTS line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Posix_QextSerialPort::setRts(bool set)
+-{
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		int status;
+-		ioctl(Posix_File->handle(), TIOCMGET, &status);
+-		if (set) {
+-			status|=TIOCM_RTS;
+-		}
+-		else {
+-			status&=~TIOCM_RTS;
+-		}
+-		ioctl(Posix_File->handle(), TIOCMSET, &status);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn unsigned long Posix_QextSerialPort::lineStatus()
+-			returns the line status as stored by the port function.  This function will retrieve the states
+-			of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
+-			can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
+-			long with specific bits indicating which lines are high.  The following constants should be used
+-			to examine the states of individual lines:
+-
+-\verbatim
+-		Mask        Line
+-		------      ----
+-		LS_CTS      CTS
+-		LS_DSR      DSR
+-		LS_DCD      DCD
+-		LS_RI       RI
+-		LS_RTS      RTS (POSIX only)
+-			LS_DTR      DTR (POSIX only)
+-				LS_ST       Secondary TXD (POSIX only)
+-					LS_SR       Secondary RXD (POSIX only)
+-						\endverbatim
+-
+-This function will return 0 if the port associated with the class is not currently open.
+-*/
+-unsigned long Posix_QextSerialPort::lineStatus()
+-{
+-	unsigned long Status=0, Temp=0;
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		ioctl(Posix_File->handle(), TIOCMGET, &Temp);
+-		if (Temp&TIOCM_CTS) {
+-			Status|=LS_CTS;
+-		}
+-		if (Temp&TIOCM_DSR) {
+-			Status|=LS_DSR;
+-		}
+-		if (Temp&TIOCM_RI) {
+-			Status|=LS_RI;
+-		}
+-		if (Temp&TIOCM_CD) {
+-			Status|=LS_DCD;
+-		}
+-		if (Temp&TIOCM_DTR) {
+-			Status|=LS_DTR;
+-		}
+-		if (Temp&TIOCM_RTS) {
+-			Status|=LS_RTS;
+-		}
+-		if (Temp&TIOCM_ST) {
+-			Status|=LS_ST;
+-		}
+-		if (Temp&TIOCM_SR) {
+-			Status|=LS_SR;
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return Status;
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize)
+-			Reads a block of data from the serial port.  This function will read at most maxSize bytes from
+-			the serial port and place them in the buffer pointed to by data.  Return value is the number of
+-			bytes actually read, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	retVal=Posix_File->read(data, maxSize);
+-	if (retVal==-1)
+-		lastErr=E_READ_FAILED;
+-	UNLOCK_MUTEX();
+-	
+-	return retVal;
+-}
+-
+-/*!
+-		\fn qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize)
+-			Writes a block of data to the serial port.  This function will write maxSize bytes
+-			from the buffer pointed to by data to the serial port.  Return value is the number
+-			of bytes actually written, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	retVal=Posix_File->write(data, maxSize);
+-	if (retVal==-1)
+-		lastErr=E_WRITE_FAILED;
+-	UNLOCK_MUTEX();
+-	
+-	flush();
+-	return retVal;
+-}
+diff --git a/3rdparty/SerialPort/qextserialport/posix_qextserialport.h b/3rdparty/SerialPort/qextserialport/posix_qextserialport.h
+deleted file mode 100644
+index efdee3c..0000000
+--- a/3rdparty/SerialPort/qextserialport/posix_qextserialport.h
++++ /dev/null
+@@ -1,56 +0,0 @@
+-
+-#ifndef _POSIX_QEXTSERIALPORT_H_
+-#define _POSIX_QEXTSERIALPORT_H_
+-
+-#include <stdio.h>
+-#include <termios.h>
+-#include <errno.h>
+-#include <unistd.h>
+-#include <sys/time.h>
+-#include <sys/ioctl.h>
+-#include <sys/select.h>
+-#include "qextserialbase.h"
+-
+-class Posix_QextSerialPort:public QextSerialBase {
+-public:
+-	Posix_QextSerialPort();
+-	Posix_QextSerialPort(const Posix_QextSerialPort& s);
+-	Posix_QextSerialPort(const QString & name);
+-	Posix_QextSerialPort(const PortSettings& settings);
+-	Posix_QextSerialPort(const QString & name, const PortSettings& settings);
+-	Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
+-	virtual ~Posix_QextSerialPort();
+-	
+-	virtual void setBaudRate(BaudRateType);
+-	virtual void setDataBits(DataBitsType);
+-	virtual void setParity(ParityType);
+-	virtual void setStopBits(StopBitsType);
+-	virtual void setFlowControl(FlowType);
+-	virtual void setTimeout(ulong, ulong);
+-	
+-	virtual bool open(OpenMode mode=0);
+-	virtual void close();
+-	virtual void flush();
+-	
+-	virtual qint64 size() const;
+-	virtual qint64 bytesAvailable();
+-	
+-	virtual void ungetChar(char c);
+-	
+-	virtual void translateError(ulong error);
+-	
+-	virtual void setDtr(bool set=true);
+-	virtual void setRts(bool set=true);
+-	virtual ulong lineStatus();
+-	
+-protected:
+-	QFile* Posix_File;
+-	struct termios Posix_CommConfig;
+-	struct timeval Posix_Timeout;
+-	struct timeval Posix_Copy_Timeout;
+-	
+-	virtual qint64 readData(char * data, qint64 maxSize);
+-	virtual qint64 writeData(const char * data, qint64 maxSize);
+-};
+-
+-#endif
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialbase.cpp b/3rdparty/SerialPort/qextserialport/qextserialbase.cpp
+deleted file mode 100644
+index 3ea2561..0000000
+--- a/3rdparty/SerialPort/qextserialport/qextserialbase.cpp
++++ /dev/null
+@@ -1,250 +0,0 @@
+-
+-#include "qextserialbase.h"
+-
+-/*!
+-\class QextSerialBase
+-\version 1.0.0
+-\author Stefan Sander
+-
+-A common base class for Win_QextSerialBase, Posix_QextSerialBase and QextSerialPort.
+-*/
+-#ifdef QT_THREAD_SUPPORT
+-QMutex* QextSerialBase::mutex=NULL;
+-unsigned long QextSerialBase::refCount=0;
+-#endif
+-
+-/*!
+-\fn QextSerialBase::QextSerialBase()
+-Default constructor.
+-*/
+-QextSerialBase::QextSerialBase()
+- : QIODevice()
+-{
+-
+-#ifdef _TTY_WIN_
+-    setPortName("COM1");
+-
+-#elif defined(_TTY_IRIX_)
+-    setPortName("/dev/ttyf1");
+-
+-#elif defined(_TTY_HPUX_)
+-    setPortName("/dev/tty1p0");
+-
+-#elif defined(_TTY_SUN_)
+-    setPortName("/dev/ttya");
+-
+-#elif defined(_TTY_DIGITAL_)
+-    setPortName("/dev/tty01");
+-
+-#elif defined(_TTY_FREEBSD_)
+-    setPortName("/dev/ttyd1");
+-
+-#else
+-    setPortName("/dev/ttyS0");
+-#endif
+-
+-    construct();
+-}
+-
+-/*!
+-\fn QextSerialBase::QextSerialBase(const QString & name)
+-Construct a port and assign it to the device specified by the name parameter.
+-*/
+-QextSerialBase::QextSerialBase(const QString & name)
+- : QIODevice()
+-{
+-    setPortName(name);
+-    construct();
+-}
+-
+-/*!
+-\fn QextSerialBase::~QextSerialBase()
+-Standard destructor.
+-*/
+-QextSerialBase::~QextSerialBase()
+-{
+-
+-#ifdef QT_THREAD_SUPPORT
+-    refCount--;
+-    if (mutex && refCount==0) {
+-        delete mutex;
+-        mutex=NULL;
+-    }
+-#endif
+-
+-}
+-
+-/*!
+-\fn void QextSerialBase::construct()
+-Common constructor function for setting up default port settings.
+-(9600 Baud, 8N1, no flow control where supported, otherwise no flow control, and 20 ms timeout).
+-*/
+-void QextSerialBase::construct()
+-{
+-    Settings.BaudRate=BAUD9600;
+-    Settings.DataBits=DATA_8;
+-    Settings.Parity=PAR_NONE;
+-    Settings.StopBits=STOP_1;
+-    Settings.FlowControl=FLOW_OFF;
+-    Settings.Timeout_Sec=0;
+-    Settings.Timeout_Millisec=20;
+-
+-#ifdef QT_THREAD_SUPPORT
+-    if (!mutex) {
+-        mutex=new QMutex( QMutex::Recursive );
+-    }
+-    refCount++;
+-#endif
+-
+-	setOpenMode(QIODevice::NotOpen);
+-}
+-
+-/*!
+-\fn void QextSerialBase::setPortName(const QString & name)
+-Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
+-*/
+-void QextSerialBase::setPortName(const QString & name)
+-{
+-    port = name;
+-}
+-
+-/*!
+-\fn QString QextSerialBase::portName() const
+-Returns the name set by setPortName().
+-*/
+-QString QextSerialBase::portName() const
+-{
+-    return port;
+-}
+-
+-/*!
+-\fn BaudRateType QextSerialBase::baudRate(void) const
+-Returns the baud rate of the serial port.  For a list of possible return values see
+-the definition of the enum BaudRateType.
+-*/
+-BaudRateType QextSerialBase::baudRate(void) const
+-{
+-    return Settings.BaudRate;
+-}
+-
+-/*!
+-\fn DataBitsType QextSerialBase::dataBits() const
+-Returns the number of data bits used by the port.  For a list of possible values returned by
+-this function, see the definition of the enum DataBitsType.
+-*/
+-DataBitsType QextSerialBase::dataBits() const
+-{
+-    return Settings.DataBits;
+-}
+-
+-/*!
+-\fn ParityType QextSerialBase::parity() const
+-Returns the type of parity used by the port.  For a list of possible values returned by
+-this function, see the definition of the enum ParityType.
+-*/
+-ParityType QextSerialBase::parity() const
+-{
+-    return Settings.Parity;
+-}
+-
+-/*!
+-\fn StopBitsType QextSerialBase::stopBits() const
+-Returns the number of stop bits used by the port.  For a list of possible return values, see
+-the definition of the enum StopBitsType.
+-*/
+-StopBitsType QextSerialBase::stopBits() const
+-{
+-    return Settings.StopBits;
+-}
+-
+-/*!
+-\fn FlowType QextSerialBase::flowControl() const
+-Returns the type of flow control used by the port.  For a list of possible values returned
+-by this function, see the definition of the enum FlowType.
+-*/
+-FlowType QextSerialBase::flowControl() const
+-{
+-    return Settings.FlowControl;
+-}
+-
+-/*!
+-\fn bool QextSerialBase::isSequential() const
+-Returns true if device is sequential, otherwise returns false. Serial port is sequential device
+-so this function always returns true. Check QIODevice::isSequential() documentation for more 
+-information.
+-*/
+-bool QextSerialBase::isSequential() const
+-{
+-	return true;
+-}
+-
+-/*!
+-\fn bool QextSerialBase::atEnd() const
+-This function will return true if the input buffer is empty (or on error), and false otherwise.
+-Call QextSerialBase::lastError() for error information.
+-*/
+-bool QextSerialBase::atEnd() const
+-{
+-    if (size()) {
+-        return true;
+-    }
+-    return false;
+-}
+-
+-/*!
+-\fn qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
+-This function will read a line of buffered input from the port, stopping when either maxSize bytes
+-have been read, the port has no more data available, or a newline is encountered.
+-The value returned is the length of the string that was read.
+-*/
+-qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
+-{
+-    qint64 numBytes = bytesAvailable();
+-    char* pData = data;
+-
+-	if (maxSize < 2)	//maxSize must be larger than 1
+-		return -1;
+-
+-    /*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
+-    while (pData<(data+numBytes) && --maxSize) {
+-        readData(pData, 1);
+-        if (*pData++ == '\n') {
+-            break;
+-        }
+-    }
+-    *pData='\0';
+-
+-    /*return size of data read*/
+-    return (pData-data);
+-}
+-
+-/*!
+-\fn ulong QextSerialBase::lastError() const
+-Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port
+-operation was successful.  Possible error codes are:
+-
+-\verbatim
+-Error                           Explanation
+----------------------------     -------------------------------------------------------------
+-E_NO_ERROR                      No Error has occured
+-E_INVALID_FD                    Invalid file descriptor (port was not opened correctly)
+-E_NO_MEMORY                     Unable to allocate memory tables (POSIX)
+-E_CAUGHT_NON_BLOCKED_SIGNAL     Caught a non-blocked signal (POSIX)
+-E_PORT_TIMEOUT                  Operation timed out (POSIX)
+-E_INVALID_DEVICE                The file opened by the port is not a character device (POSIX)
+-E_BREAK_CONDITION               The port detected a break condition
+-E_FRAMING_ERROR                 The port detected a framing error
+-                                (usually caused by incorrect baud rate settings)
+-E_IO_ERROR                      There was an I/O error while communicating with the port
+-E_BUFFER_OVERRUN                Character buffer overrun
+-E_RECEIVE_OVERFLOW              Receive buffer overflow
+-E_RECEIVE_PARITY_ERROR          The port detected a parity error in the received data
+-E_TRANSMIT_OVERFLOW             Transmit buffer overflow
+-E_READ_FAILED                   General read operation failure
+-E_WRITE_FAILED                  General write operation failure
+-\endverbatim
+-*/
+-ulong QextSerialBase::lastError() const
+-{
+-    return lastErr;
+-}
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialbase.h b/3rdparty/SerialPort/qextserialport/qextserialbase.h
+deleted file mode 100644
+index 1af6575..0000000
+--- a/3rdparty/SerialPort/qextserialport/qextserialbase.h
++++ /dev/null
+@@ -1,196 +0,0 @@
+-
+-#ifndef _QEXTSERIALBASE_H_
+-#define _QEXTSERIALBASE_H_
+-
+-#include <QIODevice>
+-#include <QFile>
+-
+-#ifdef QT_THREAD_SUPPORT
+-#include <QThread>
+-#include <QMutex>
+-#endif
+-
+-/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
+-#ifdef _TTY_NOWARN_
+-#define _TTY_NOWARN_PORT_
+-#endif
+-
+-/*macros for thread support*/
+-#ifdef QT_THREAD_SUPPORT
+-#define LOCK_MUTEX() mutex->lock()
+-#define UNLOCK_MUTEX() mutex->unlock()
+-#else
+-#define LOCK_MUTEX()
+-#define UNLOCK_MUTEX()
+-#endif
+-
+-/*macros for warning messages*/
+-#ifdef _TTY_NOWARN_PORT_
+-#define TTY_PORTABILITY_WARNING(s)
+-#else
+-#define TTY_PORTABILITY_WARNING(s) qWarning(s)
+-#endif
+-#ifdef _TTY_NOWARN_
+-#define TTY_WARNING(s)
+-#else
+-#define TTY_WARNING(s) qWarning(s)
+-#endif
+-
+-
+-/*line status constants*/
+-#define LS_CTS  0x01
+-#define LS_DSR  0x02
+-#define LS_DCD  0x04
+-#define LS_RI   0x08
+-#define LS_RTS  0x10
+-#define LS_DTR  0x20
+-#define LS_ST   0x40
+-#define LS_SR   0x80
+-
+-/*error constants*/
+-#define E_NO_ERROR                   0
+-#define E_INVALID_FD                 1
+-#define E_NO_MEMORY                  2
+-#define E_CAUGHT_NON_BLOCKED_SIGNAL  3
+-#define E_PORT_TIMEOUT               4
+-#define E_INVALID_DEVICE             5
+-#define E_BREAK_CONDITION            6
+-#define E_FRAMING_ERROR              7
+-#define E_IO_ERROR                   8
+-#define E_BUFFER_OVERRUN             9
+-#define E_RECEIVE_OVERFLOW          10
+-#define E_RECEIVE_PARITY_ERROR      11
+-#define E_TRANSMIT_OVERFLOW         12
+-#define E_READ_FAILED               13
+-#define E_WRITE_FAILED              14
+-
+-/*enums for port settings*/
+-enum NamingConvention {
+-    WIN_NAMES,
+-    IRIX_NAMES,
+-    HPUX_NAMES,
+-    SUN_NAMES,
+-    DIGITAL_NAMES,
+-    FREEBSD_NAMES,
+-    LINUX_NAMES
+-};
+-
+-enum BaudRateType {
+-    BAUD50,                //POSIX ONLY
+-    BAUD75,                //POSIX ONLY
+-    BAUD110,
+-    BAUD134,               //POSIX ONLY
+-    BAUD150,               //POSIX ONLY
+-    BAUD200,               //POSIX ONLY
+-    BAUD300,
+-    BAUD600,
+-    BAUD1200,
+-    BAUD1800,              //POSIX ONLY
+-    BAUD2400,
+-    BAUD4800,
+-    BAUD9600,
+-    BAUD14400,             //WINDOWS ONLY
+-    BAUD19200,
+-    BAUD38400,
+-    BAUD56000,             //WINDOWS ONLY
+-    BAUD57600,
+-    BAUD76800,             //POSIX ONLY
+-    BAUD115200,
+-    BAUD128000,            //WINDOWS ONLY
+-    BAUD256000             //WINDOWS ONLY
+-};
+-
+-enum DataBitsType {
+-    DATA_5,
+-    DATA_6,
+-    DATA_7,
+-    DATA_8
+-};
+-
+-enum ParityType {
+-    PAR_NONE,
+-    PAR_ODD,
+-    PAR_EVEN,
+-    PAR_MARK,               //WINDOWS ONLY
+-    PAR_SPACE
+-};
+-
+-enum StopBitsType {
+-    STOP_1,
+-    STOP_1_5,               //WINDOWS ONLY
+-    STOP_2
+-};
+-
+-enum FlowType {
+-    FLOW_OFF,
+-    FLOW_HARDWARE,
+-    FLOW_XONXOFF
+-};
+-
+-/*structure to contain port settings*/
+-struct PortSettings {
+-    BaudRateType BaudRate;
+-    DataBitsType DataBits;
+-    ParityType Parity;
+-    StopBitsType StopBits;
+-    FlowType FlowControl;
+-    ulong Timeout_Sec;
+-    ulong Timeout_Millisec;
+-};
+-
+-class QextSerialBase : public QIODevice {
+-public:
+-    QextSerialBase();
+-    QextSerialBase(const QString & name);
+-    virtual ~QextSerialBase();
+-    virtual void construct();
+-    virtual void setPortName(const QString & name);
+-    virtual QString portName() const;
+-
+-    virtual void setBaudRate(BaudRateType)=0;
+-    virtual BaudRateType baudRate() const;
+-    virtual void setDataBits(DataBitsType)=0;
+-    virtual DataBitsType dataBits() const;
+-    virtual void setParity(ParityType)=0;
+-    virtual ParityType parity() const;
+-    virtual void setStopBits(StopBitsType)=0;
+-    virtual StopBitsType stopBits() const;
+-    virtual void setFlowControl(FlowType)=0;
+-    virtual FlowType flowControl() const;
+-    virtual void setTimeout(ulong, ulong)=0;
+-
+-    virtual bool open(OpenMode mode=0)=0;
+-    virtual bool isSequential() const;
+-    virtual void close()=0;
+-    virtual void flush()=0;
+-
+-    virtual qint64 size() const=0;
+-    virtual qint64 bytesAvailable()=0;
+-    virtual bool atEnd() const;
+-
+-    virtual void ungetChar(char c)=0;
+-    virtual qint64 readLine(char * data, qint64 maxSize);
+-
+-    virtual ulong lastError() const;
+-    virtual void translateError(ulong error)=0;
+-
+-    virtual void setDtr(bool set=true)=0;
+-    virtual void setRts(bool set=true)=0;
+-    virtual ulong lineStatus()=0;
+-
+-protected:
+-    QString port;
+-    PortSettings Settings;
+-    ulong lastErr;
+-
+-#ifdef QT_THREAD_SUPPORT
+-    static QMutex* mutex;
+-    static ulong refCount;
+-#endif
+-
+-    virtual qint64 readData(char * data, qint64 maxSize)=0;
+-    virtual qint64 writeData(const char * data, qint64 maxSize)=0;
+-
+-};
+-
+-#endif
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport.cpp b/3rdparty/SerialPort/qextserialport/qextserialport.cpp
+index 9d3fff4..c3d5fd8 100644
+--- a/3rdparty/SerialPort/qextserialport/qextserialport.cpp
++++ b/3rdparty/SerialPort/qextserialport/qextserialport.cpp
+@@ -1,98 +1,1011 @@
+-
+-/*!
+-\class QextSerialPort
+-\version 1.0.0
+-\author Stefan Sander
+-
+-A cross-platform serial port class.
+-This class encapsulates a serial port on both POSIX and Windows systems.  The user will be
+-notified of errors and possible portability conflicts at run-time by default - this behavior can
+-be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn
+-off portability warnings) in the project.
+-
+-\note
+-On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
+-select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
+-make no guarantees as to the quality of POSIX support under NT/2000 however.
+-
+-*/
+-
+-#include <stdio.h>
+-#include "qextserialport.h"
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort()
+-Default constructor.  Note that the naming convention used by a QextSerialPort constructed with
+-this constructor will be determined by #defined constants, or lack thereof - the default behavior
+-is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:
+-
+-\verbatim
+-
+-Constant         Used By         Naming Convention
+-----------       -------------   ------------------------
+-_TTY_WIN_        Windows         COM1, COM2
+-_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
+-_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
+-_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
+-_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
+-_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
+-_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
+-<none>           Linux           /dev/ttyS0, /dev/ttyS1
+-\endverbatim
+-
+-The object will be associated with the first port in the system, e.g. COM1 on Windows systems.
+-See the other constructors if you need to use a port other than the first.
+-*/
+-QextSerialPort::QextSerialPort()
+- : QextBaseType()
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(const QString & name)
+-Constructs a serial port attached to the port specified by name.
+-name is the name of the device, which is windowsystem-specific,
+-e.g."COM1" or "/dev/ttyS0".
+-*/
+-QextSerialPort::QextSerialPort(const QString & name)
+- : QextBaseType(name)
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(PortSettings const& settings)
+-Constructs a port with default name and settings specified by the settings parameter.
+-*/
+-QextSerialPort::QextSerialPort(PortSettings const& settings)
+- : QextBaseType(settings)
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
+-Constructs a port with the name and settings specified.
+-*/
+-QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
+- : QextBaseType(name, settings)
+-{}
+-
+-/*!
+-\fn QextSerialPort::QextSerialPort(const QextSerialPort& s)
+-Copy constructor.
+-*/
+-QextSerialPort::QextSerialPort(const QextSerialPort& s)
+- : QextBaseType(s)
+-{}
+-
+-/*!
+-\fn QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
+-Overrides the = operator.
+-*/
+-QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
+-{
+-    return (QextSerialPort&)QextBaseType::operator=(s);
+-}
+-
+-/*!
+-\fn QextSerialPort::~QextSerialPort()
+-Standard destructor.
+-*/
+-QextSerialPort::~QextSerialPort()
+-{}
++/****************************************************************************
++** Copyright (c) 2000-2003 Wayne Roth
++** Copyright (c) 2004-2007 Stefan Sander
++** Copyright (c) 2007 Michal Policht
++** Copyright (c) 2008 Brandon Fosdick
++** Copyright (c) 2009-2010 Liam Staskawicz
++** Copyright (c) 2011 Debao Zhang
++** All right reserved.
++** Web: http://code.google.com/p/qextserialport/
++**
++** Permission is hereby granted, free of charge, to any person obtaining
++** a copy of this software and associated documentation files (the
++** "Software"), to deal in the Software without restriction, including
++** without limitation the rights to use, copy, modify, merge, publish,
++** distribute, sublicense, and/or sell copies of the Software, and to
++** permit persons to whom the Software is furnished to do so, subject to
++** the following conditions:
++**
++** The above copyright notice and this permission notice shall be
++** included in all copies or substantial portions of the Software.
++**
++** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++**
++****************************************************************************/
++
++#include "qextserialport.h"
++#include "qextserialport_p.h"
++#include <stdio.h>
++#include <QtCore/QDebug>
++#include <QtCore/QReadLocker>
++#include <QtCore/QWriteLocker>
++
++/*!
++    \class PortSettings
++
++    \brief The PortSettings class contain port settings
++
++    Structure to contain port settings.
++
++    \code
++    BaudRateType BaudRate;
++    DataBitsType DataBits;
++    ParityType Parity;
++    StopBitsType StopBits;
++    FlowType FlowControl;
++    long Timeout_Millisec;
++    \endcode
++*/
++
++QextSerialPortPrivate::QextSerialPortPrivate(QextSerialPort *q)
++    :lock(QReadWriteLock::Recursive), q_ptr(q)
++{
++    lastErr = E_NO_ERROR;
++    Settings.BaudRate = BAUD9600;
++    Settings.Parity = PAR_NONE;
++    Settings.FlowControl = FLOW_OFF;
++    Settings.DataBits = DATA_8;
++    Settings.StopBits = STOP_1;
++    Settings.Timeout_Millisec = 10;
++    settingsDirtyFlags = DFE_ALL;
++
++    platformSpecificInit();
++}
++
++QextSerialPortPrivate::~QextSerialPortPrivate()
++{
++    platformSpecificDestruct();
++}
++
++void QextSerialPortPrivate::setBaudRate(BaudRateType baudRate, bool update)
++{
++    switch (baudRate) {
++#ifdef Q_OS_WIN
++    //Windows Special
++    case BAUD14400:
++    case BAUD56000:
++    case BAUD128000:
++    case BAUD256000:
++        QESP_PORTABILITY_WARNING()<<"QextSerialPort Portability Warning: POSIX does not support baudRate:"<<baudRate;
++#elif defined(Q_OS_UNIX)
++    //Unix Special
++    case BAUD50:
++    case BAUD75:
++    case BAUD134:
++    case BAUD150:
++    case BAUD200:
++    case BAUD1800:
++#  ifdef B76800
++    case BAUD76800:
++#  endif
++#  if defined(B230400) && defined(B4000000)
++    case BAUD230400:
++    case BAUD460800:
++    case BAUD500000:
++    case BAUD576000:
++    case BAUD921600:
++    case BAUD1000000:
++    case BAUD1152000:
++    case BAUD1500000:
++    case BAUD2000000:
++    case BAUD2500000:
++    case BAUD3000000:
++    case BAUD3500000:
++    case BAUD4000000:
++#  endif
++        QESP_PORTABILITY_WARNING()<<"QextSerialPort Portability Warning: Windows does not support baudRate:"<<baudRate;
++#endif
++    case BAUD110:
++    case BAUD300:
++    case BAUD600:
++    case BAUD1200:
++    case BAUD2400:
++    case BAUD4800:
++    case BAUD9600:
++    case BAUD19200:
++    case BAUD38400:
++    case BAUD57600:
++    case BAUD115200:
++#ifdef Q_OS_WIN
++    default:
++#endif
++        Settings.BaudRate=baudRate;
++        settingsDirtyFlags |= DFE_BaudRate;
++        if (update && q_func()->isOpen())
++            updatePortSettings();
++        break;
++#ifndef Q_OS_WIN
++    default:
++        QESP_WARNING()<<"QextSerialPort does not support baudRate:"<<baudRate;
++#endif
++    }
++}
++
++void QextSerialPortPrivate::setParity(ParityType parity, bool update)
++{
++    switch (parity) {
++    case PAR_SPACE:
++        if (Settings.DataBits==DATA_8) {
++#ifdef Q_OS_WIN
++            QESP_PORTABILITY_WARNING("QextSerialPort Portability Warning: Space parity with 8 data bits is not supported by POSIX systems.");
++#else
++            QESP_WARNING("Space parity with 8 data bits is not supported by POSIX systems.");
++#endif
++        }
++        break;
++
++#ifdef Q_OS_WIN
++        /*mark parity - WINDOWS ONLY*/
++    case PAR_MARK:
++        QESP_PORTABILITY_WARNING("QextSerialPort Portability Warning:  Mark parity is not supported by POSIX systems");
++        break;
++#endif
++
++    case PAR_NONE:
++    case PAR_EVEN:
++    case PAR_ODD:
++        break;
++    default:
++        QESP_WARNING()<<"QextSerialPort does not support Parity:" << parity;
++    }
++
++    Settings.Parity=parity;
++    settingsDirtyFlags |= DFE_Parity;
++    if (update && q_func()->isOpen())
++        updatePortSettings();
++}
++
++void QextSerialPortPrivate::setDataBits(DataBitsType dataBits, bool update)
++{
++    switch(dataBits) {
++
++    case DATA_5:
++        if (Settings.StopBits==STOP_2) {
++            QESP_WARNING("QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
++        }
++        else {
++            Settings.DataBits=dataBits;
++            settingsDirtyFlags |= DFE_DataBits;
++        }
++        break;
++
++    case DATA_6:
++#ifdef Q_OS_WIN
++        if (Settings.StopBits==STOP_1_5) {
++            QESP_WARNING("QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
++        }
++        else
++#endif
++        {
++            Settings.DataBits=dataBits;
++            settingsDirtyFlags |= DFE_DataBits;
++        }
++        break;
++
++    case DATA_7:
++#ifdef Q_OS_WIN
++        if (Settings.StopBits==STOP_1_5) {
++            QESP_WARNING("QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
++        }
++        else
++#endif
++        {
++            Settings.DataBits=dataBits;
++            settingsDirtyFlags |= DFE_DataBits;
++        }
++        break;
++
++    case DATA_8:
++#ifdef Q_OS_WIN
++        if (Settings.StopBits==STOP_1_5) {
++            QESP_WARNING("QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
++        }
++        else
++#endif
++        {
++            Settings.DataBits=dataBits;
++            settingsDirtyFlags |= DFE_DataBits;
++        }
++        break;
++    default:
++        QESP_WARNING()<<"QextSerialPort does not support Data bits:"<<dataBits;
++    }
++    if (update && q_func()->isOpen())
++        updatePortSettings();
++}
++
++void QextSerialPortPrivate::setStopBits(StopBitsType stopBits, bool update)
++{
++    switch (stopBits) {
++
++        /*one stop bit*/
++    case STOP_1:
++        Settings.StopBits = stopBits;
++        settingsDirtyFlags |= DFE_StopBits;
++        break;
++
++#ifdef Q_OS_WIN
++        /*1.5 stop bits*/
++    case STOP_1_5:
++        QESP_PORTABILITY_WARNING("QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX.");
++        if (Settings.DataBits!=DATA_5) {
++            QESP_WARNING("QextSerialPort: 1.5 stop bits can only be used with 5 data bits");
++        }
++        else {
++            Settings.StopBits = stopBits;
++            settingsDirtyFlags |= DFE_StopBits;
++        }
++        break;
++#endif
++
++        /*two stop bits*/
++    case STOP_2:
++        if (Settings.DataBits==DATA_5) {
++            QESP_WARNING("QextSerialPort: 2 stop bits cannot be used with 5 data bits");
++        }
++        else {
++            Settings.StopBits = stopBits;
++            settingsDirtyFlags |= DFE_StopBits;
++        }
++        break;
++    default:
++        QESP_WARNING()<<"QextSerialPort does not support stop bits: "<<stopBits;
++    }
++    if (update && q_func()->isOpen())
++        updatePortSettings();
++}
++
++void QextSerialPortPrivate::setFlowControl(FlowType flow, bool update)
++{
++    Settings.FlowControl=flow;
++    settingsDirtyFlags |= DFE_Flow;
++    if (update && q_func()->isOpen())
++        updatePortSettings();
++}
++
++void QextSerialPortPrivate::setTimeout(long millisec, bool update)
++{
++    Settings.Timeout_Millisec = millisec;
++    settingsDirtyFlags |= DFE_TimeOut;
++    if (update && q_func()->isOpen())
++        updatePortSettings();
++}
++
++void QextSerialPortPrivate::setPortSettings(const PortSettings &settings, bool update)
++{
++    setBaudRate(settings.BaudRate, false);
++    setDataBits(settings.DataBits, false);
++    setStopBits(settings.StopBits, false);
++    setParity(settings.Parity, false);
++    setFlowControl(settings.FlowControl, false);
++    setTimeout(settings.Timeout_Millisec, false);
++    settingsDirtyFlags = DFE_ALL;
++    if (update && q_func()->isOpen())
++        updatePortSettings();
++}
++
++
++void QextSerialPortPrivate::_q_canRead()
++{
++    qint64 maxSize = bytesAvailable_sys();
++    if (maxSize > 0) {
++        char * writePtr = readBuffer.reserve(size_t(maxSize));
++        qint64 bytesRead = readData_sys(writePtr, maxSize);
++        if (bytesRead < maxSize)
++            readBuffer.chop(maxSize - bytesRead);
++        Q_Q(QextSerialPort);
++        Q_EMIT q->readyRead();
++    }
++}
++
++/*! \class QextSerialPort
++
++    \brief The QextSerialPort class encapsulates a serial port on both POSIX and Windows systems.
++
++    \section1 Usage
++    QextSerialPort offers both a polling and event driven API.  Event driven
++    is typically easier to use, since you never have to worry about checking
++    for new data.
++
++    \bold Example
++    \code
++    QextSerialPort* port = new QextSerialPort("COM1");
++    connect(port, SIGNAL(readyRead()), myClass, SLOT(onDataAvailable()));
++    port->open();
++
++    void MyClass::onDataAvailable()
++    {
++        QByteArray data = port->readAll();
++        processNewData(usbdata);
++    }
++    \endcode
++
++    \section1 Compatibility
++    The user will be notified of errors and possible portability conflicts at run-time
++    by default.
++
++    For example, if a application has used BAUD1800, when it is runing under unix, you
++    will get following message.
++
++    \code
++    QextSerialPort Portability Warning: Windows does not support baudRate:1800
++    \endcode
++
++    This behavior can be turned off by defining macro QESP_NO_WARN (to turn off all warnings)
++    or QESP_NO_PORTABILITY_WARN (to turn off portability warnings) in the project.
++
++
++    \bold Author: Stefan Sander, Michal Policht, Brandon Fosdick, Liam Staskawicz, Debao Zhang
++*/
++
++/*!
++  \enum QextSerialPort::QueryMode
++
++  This enum type specifies query mode used in a serial port:
++
++  \value Polling
++     asynchronously read and write
++  \value EventDriven
++     synchronously read and write
++*/
++
++/*!
++    \fn void QextSerialPort::dsrChanged(bool status)
++    This signal is emitted whenever dsr line has changed its state. You may
++    use this signal to check if device is connected.
++
++    \a status true when DSR signal is on, false otherwise.
++ */
++
++
++/*!
++    \fn QueryMode QextSerialPort::queryMode() const
++    Get query mode.
++ */
++
++/*!
++    Default constructor.  Note that the name of the device used by a QextSerialPort is dependent on
++    your OS. Possible naming conventions and their associated OS are:
++
++    \code
++
++    OS Constant       Used By         Naming Convention
++    -------------     -------------   ------------------------
++    Q_OS_WIN          Windows         COM1, COM2
++    Q_OS_IRIX         SGI/IRIX        /dev/ttyf1, /dev/ttyf2
++    Q_OS_HPUX         HP-UX           /dev/tty1p0, /dev/tty2p0
++    Q_OS_SOLARIS      SunOS/Slaris    /dev/ttya, /dev/ttyb
++    Q_OS_OSF          Digital UNIX    /dev/tty01, /dev/tty02
++    Q_OS_FREEBSD      FreeBSD         /dev/ttyd0, /dev/ttyd1
++    Q_OS_OPENBSD      OpenBSD         /dev/tty00, /dev/tty01
++    Q_OS_LINUX        Linux           /dev/ttyS0, /dev/ttyS1
++    <none>                            /dev/ttyS0, /dev/ttyS1
++    \endcode
++
++    This constructor assigns the device name to the name of the first port on the specified system.
++    See the other constructors if you need to open a different port. Default \a mode is EventDriven.
++    As a subclass of QObject, \a parent can be specified.
++*/
++
++QextSerialPort::QextSerialPort(QextSerialPort::QueryMode mode, QObject *parent)
++    : QIODevice(parent), d_ptr(new QextSerialPortPrivate(this))
++{
++#ifdef Q_OS_WIN
++    setPortName(QLatin1String("COM1"));
++
++#elif defined(Q_OS_IRIX)
++    setPortName(QLatin1String("/dev/ttyf1"));
++
++#elif defined(Q_OS_HPUX)
++    setPortName(QLatin1String("/dev/tty1p0"));
++
++#elif defined(Q_OS_SOLARIS)
++    setPortName(QLatin1String("/dev/ttya"));
++
++#elif defined(Q_OS_OSF) //formally DIGITAL UNIX
++    setPortName(QLatin1String("/dev/tty01"));
++
++#elif defined(Q_OS_FREEBSD)
++    setPortName(QLatin1String("/dev/ttyd1"));
++
++#elif defined(Q_OS_OPENBSD)
++    setPortName(QLatin1String("/dev/tty00"));
++
++#else
++    setPortName(QLatin1String("/dev/ttyS0"));
++#endif
++    setQueryMode(mode);
++}
++
++/*!
++    Constructs a serial port attached to the port specified by name.
++    \a name is the name of the device, which is windowsystem-specific,
++    e.g."COM1" or "/dev/ttyS0". \a mode
++*/
++QextSerialPort::QextSerialPort(const QString & name, QextSerialPort::QueryMode mode, QObject *parent)
++    : QIODevice(parent), d_ptr(new QextSerialPortPrivate(this))
++{
++    setQueryMode(mode);
++    setPortName(name);
++}
++
++/*!
++    Constructs a port with default name and specified \a settings.
++*/
++QextSerialPort::QextSerialPort(const PortSettings& settings, QextSerialPort::QueryMode mode, QObject *parent)
++    : QIODevice(parent), d_ptr(new QextSerialPortPrivate(this))
++{
++    Q_D(QextSerialPort);
++    setQueryMode(mode);
++    d->setPortSettings(settings);
++}
++
++/*!
++    Constructs a port with specified \a name , \a mode and \a settings.
++*/
++QextSerialPort::QextSerialPort(const QString & name, const PortSettings& settings, QextSerialPort::QueryMode mode, QObject *parent)
++    : QIODevice(parent), d_ptr(new QextSerialPortPrivate(this))
++{
++    Q_D(QextSerialPort);
++    setPortName(name);
++    setQueryMode(mode);
++    d->setPortSettings(settings);
++}
++
++/*!
++    Opens a serial port and sets its OpenMode to \a mode.
++    Note that this function does not specify which device to open.
++    Returns true if successful; otherwise returns false.This function has no effect
++    if the port associated with the class is already open.  The port is also
++    configured to the current settings, as stored in the Settings structure.
++*/
++bool QextSerialPort::open(OpenMode mode)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (mode != QIODevice::NotOpen && !isOpen())
++        d->open_sys(mode);
++
++    return isOpen();
++}
++
++
++/*! \reimp
++    Closes a serial port.  This function has no effect if the serial port associated with the class
++    is not currently open.
++*/
++void QextSerialPort::close()
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (isOpen()) {
++        // Be a good QIODevice and call QIODevice::close() before really close()
++        //  so the aboutToClose() signal is emitted at the proper time
++        QIODevice::close(); // mark ourselves as closed
++        d->close_sys();
++        d->readBuffer.clear();
++    }
++}
++
++/*!
++    Flushes all pending I/O to the serial port.  This function has no effect if the serial port
++    associated with the class is not currently open.
++*/
++void QextSerialPort::flush()
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (isOpen())
++        d->flush_sys();
++}
++
++/*! \reimp
++    Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
++    the port is not currently open, or -1 on error.
++*/
++qint64 QextSerialPort::bytesAvailable() const
++{
++    QWriteLocker locker(&d_func()->lock);
++    if (isOpen()) {
++        qint64 bytes = d_func()->bytesAvailable_sys();
++        if (bytes != -1) {
++            return bytes + d_func()->readBuffer.size()
++                    + QIODevice::bytesAvailable();
++        } else {
++            return -1;
++        }
++    }
++    return 0;
++}
++
++/*! \reimp
++
++*/
++bool QextSerialPort::canReadLine() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return QIODevice::canReadLine() || d_func()->readBuffer.canReadLine();
++}
++
++/*!
++ * Set desired serial communication handling style. You may choose from polling
++ * or event driven approach. This function does nothing when port is open; to
++ * apply changes port must be reopened.
++ *
++ * In event driven approach read() and write() functions are acting
++ * asynchronously. They return immediately and the operation is performed in
++ * the background, so they doesn't freeze the calling thread.
++ * To determine when operation is finished, QextSerialPort runs separate thread
++ * and monitors serial port events. Whenever the event occurs, adequate signal
++ * is emitted.
++ *
++ * When polling is set, read() and write() are acting synchronously. Signals are
++ * not working in this mode and some functions may not be available. The advantage
++ * of polling is that it generates less overhead due to lack of signals emissions
++ * and it doesn't start separate thread to monitor events.
++ *
++ * Generally event driven approach is more capable and friendly, although some
++ * applications may need as low overhead as possible and then polling comes.
++ *
++ * \a mode query mode.
++ */
++void QextSerialPort::setQueryMode(QueryMode mode)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (mode != d->_queryMode) {
++        d->_queryMode = mode;
++    }
++}
++
++/*!
++    Sets the \a name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
++*/
++void QextSerialPort::setPortName(const QString & name)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    d->port = name;
++}
++
++/*!
++    Returns the name set by setPortName().
++*/
++QString QextSerialPort::portName() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->port;
++}
++
++QextSerialPort::QueryMode QextSerialPort::queryMode() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->_queryMode;
++}
++
++/*!
++    Reads all available data from the device, and returns it as a QByteArray.
++    This function has no way of reporting errors; returning an empty QByteArray()
++    can mean either that no data was currently available for reading, or that an error occurred.
++*/
++QByteArray QextSerialPort::readAll()
++{
++    int avail = this->bytesAvailable();
++    return (avail > 0) ? this->read(avail) : QByteArray();
++}
++
++/*!
++    Returns the baud rate of the serial port.  For a list of possible return values see
++    the definition of the enum BaudRateType.
++*/
++BaudRateType QextSerialPort::baudRate() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->Settings.BaudRate;
++}
++
++/*!
++    Returns the number of data bits used by the port.  For a list of possible values returned by
++    this function, see the definition of the enum DataBitsType.
++*/
++DataBitsType QextSerialPort::dataBits() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->Settings.DataBits;
++}
++
++/*!
++    Returns the type of parity used by the port.  For a list of possible values returned by
++    this function, see the definition of the enum ParityType.
++*/
++ParityType QextSerialPort::parity() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->Settings.Parity;
++}
++
++/*!
++    Returns the number of stop bits used by the port.  For a list of possible return values, see
++    the definition of the enum StopBitsType.
++*/
++StopBitsType QextSerialPort::stopBits() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->Settings.StopBits;
++}
++
++/*!
++    Returns the type of flow control used by the port.  For a list of possible values returned
++    by this function, see the definition of the enum FlowType.
++*/
++FlowType QextSerialPort::flowControl() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->Settings.FlowControl;
++}
++
++/*!
++    \reimp
++    Returns true if device is sequential, otherwise returns false. Serial port is sequential device
++    so this function always returns true. Check QIODevice::isSequential() documentation for more
++    information.
++*/
++bool QextSerialPort::isSequential() const
++{
++    return true;
++}
++
++/*!
++    Return the error number, or 0 if no error occurred.
++*/
++ulong QextSerialPort::lastError() const
++{
++    QReadLocker locker(&d_func()->lock);
++    return d_func()->lastErr;
++}
++
++/*!
++    Returns the line status as stored by the port function.  This function will retrieve the states
++    of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
++    can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
++    long with specific bits indicating which lines are high.  The following constants should be used
++    to examine the states of individual lines:
++
++    \code
++    Mask        Line
++    ------      ----
++    LS_CTS      CTS
++    LS_DSR      DSR
++    LS_DCD      DCD
++    LS_RI       RI
++    LS_RTS      RTS (POSIX only)
++    LS_DTR      DTR (POSIX only)
++    LS_ST       Secondary TXD (POSIX only)
++    LS_SR       Secondary RXD (POSIX only)
++    \endcode
++
++    This function will return 0 if the port associated with the class is not currently open.
++*/
++unsigned long QextSerialPort::lineStatus()
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (isOpen())
++        return d->lineStatus_sys();
++    return 0;
++}
++
++/*!
++  Returns a human-readable description of the last device error that occurred.
++*/
++QString QextSerialPort::errorString()
++{
++    Q_D(QextSerialPort);
++    QReadLocker locker(&d->lock);
++    switch(d->lastErr) {
++    case E_NO_ERROR:
++        return tr("No Error has occurred");
++    case E_INVALID_FD:
++        return tr("Invalid file descriptor (port was not opened correctly)");
++    case E_NO_MEMORY:
++        return tr("Unable to allocate memory tables (POSIX)");
++    case E_CAUGHT_NON_BLOCKED_SIGNAL:
++        return tr("Caught a non-blocked signal (POSIX)");
++    case E_PORT_TIMEOUT:
++        return tr("Operation timed out (POSIX)");
++    case E_INVALID_DEVICE:
++        return tr("The file opened by the port is not a valid device");
++    case E_BREAK_CONDITION:
++        return tr("The port detected a break condition");
++    case E_FRAMING_ERROR:
++        return tr("The port detected a framing error (usually caused by incorrect baud rate settings)");
++    case E_IO_ERROR:
++        return tr("There was an I/O error while communicating with the port");
++    case E_BUFFER_OVERRUN:
++        return tr("Character buffer overrun");
++    case E_RECEIVE_OVERFLOW:
++        return tr("Receive buffer overflow");
++    case E_RECEIVE_PARITY_ERROR:
++        return tr("The port detected a parity error in the received data");
++    case E_TRANSMIT_OVERFLOW:
++        return tr("Transmit buffer overflow");
++    case E_READ_FAILED:
++        return tr("General read operation failure");
++    case E_WRITE_FAILED:
++        return tr("General write operation failure");
++    case E_FILE_NOT_FOUND:
++        return tr("The %1 file doesn't exists").arg(this->portName());
++    case E_PERMISSION_DENIED:
++        return tr("Permission denied");
++    case E_AGAIN:
++        return tr("Device is already locked");
++    default:
++        return tr("Unknown error: %1").arg(d->lastErr);
++    }
++}
++
++/*!
++   Destructs the QextSerialPort object.
++*/
++QextSerialPort::~QextSerialPort()
++{
++    if (isOpen()) {
++        close();
++    }
++    delete d_ptr;
++}
++
++/*!
++    Sets the flow control used by the port to \a flow.  Possible values of flow are:
++    \code
++        FLOW_OFF            No flow control
++        FLOW_HARDWARE       Hardware (RTS/CTS) flow control
++        FLOW_XONXOFF        Software (XON/XOFF) flow control
++    \endcode
++*/
++void QextSerialPort::setFlowControl(FlowType flow)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (d->Settings.FlowControl != flow)
++        d->setFlowControl(flow, true);
++}
++
++/*!
++    Sets the parity associated with the serial port to \a parity.  The possible values of parity are:
++    \code
++        PAR_SPACE       Space Parity
++        PAR_MARK        Mark Parity
++        PAR_NONE        No Parity
++        PAR_EVEN        Even Parity
++        PAR_ODD         Odd Parity
++    \endcode
++*/
++void QextSerialPort::setParity(ParityType parity)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (d->Settings.Parity != parity)
++        d->setParity(parity, true);
++}
++
++/*!
++    Sets the number of data bits used by the serial port to \a dataBits.  Possible values of dataBits are:
++    \code
++        DATA_5      5 data bits
++        DATA_6      6 data bits
++        DATA_7      7 data bits
++        DATA_8      8 data bits
++    \endcode
++
++    \bold note:
++    This function is subject to the following restrictions:
++    \list
++    \o 5 data bits cannot be used with 2 stop bits.
++    \o 1.5 stop bits can only be used with 5 data bits.
++    \o 8 data bits cannot be used with space parity on POSIX systems.
++    \endlist
++    */
++void QextSerialPort::setDataBits(DataBitsType dataBits)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (d->Settings.DataBits != dataBits)
++        d->setDataBits(dataBits, true);
++}
++
++/*!
++    Sets the number of stop bits used by the serial port to \a stopBits.  Possible values of stopBits are:
++    \code
++        STOP_1      1 stop bit
++        STOP_1_5    1.5 stop bits
++        STOP_2      2 stop bits
++    \endcode
++
++    \bold note:
++    This function is subject to the following restrictions:
++    \list
++    \o 2 stop bits cannot be used with 5 data bits.
++    \o 1.5 stop bits cannot be used with 6 or more data bits.
++    \o POSIX does not support 1.5 stop bits.
++    \endlist
++*/
++void QextSerialPort::setStopBits(StopBitsType stopBits)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (d->Settings.StopBits != stopBits)
++        d->setStopBits(stopBits, true);
++}
++
++/*!
++    Sets the baud rate of the serial port to \a baudRate.  Note that not all rates are applicable on
++    all platforms.  The following table shows translations of the various baud rate
++    constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
++    are speeds that are usable on both Windows and POSIX.
++    \code
++
++      RATE          Windows Speed   POSIX Speed
++      -----------   -------------   -----------
++       BAUD50                   X          50
++       BAUD75                   X          75
++      *BAUD110                110         110
++       BAUD134                  X         134.5
++       BAUD150                  X         150
++       BAUD200                  X         200
++      *BAUD300                300         300
++      *BAUD600                600         600
++      *BAUD1200              1200        1200
++       BAUD1800                 X        1800
++      *BAUD2400              2400        2400
++      *BAUD4800              4800        4800
++      *BAUD9600              9600        9600
++       BAUD14400            14400           X
++      *BAUD19200            19200       19200
++      *BAUD38400            38400       38400
++       BAUD56000            56000           X
++      *BAUD57600            57600       57600
++       BAUD76800                X       76800
++      *BAUD115200          115200      115200
++       BAUD128000          128000           X
++       BAUD230400               X      230400
++       BAUD256000          256000           X
++       BAUD460800               X      460800
++       BAUD500000               X      500000
++       BAUD576000               X      576000
++       BAUD921600               X      921600
++       BAUD1000000              X     1000000
++       BAUD1152000              X     1152000
++       BAUD1500000              X     1500000
++       BAUD2000000              X     2000000
++       BAUD2500000              X     2500000
++       BAUD3000000              X     3000000
++       BAUD3500000              X     3500000
++       BAUD4000000              X     4000000
++    \endcode
++*/
++
++void QextSerialPort::setBaudRate(BaudRateType baudRate)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (d->Settings.BaudRate != baudRate)
++        d->setBaudRate(baudRate, true);
++}
++
++/*!
++    For Unix:
++
++    Sets the read and write timeouts for the port to \a millisec milliseconds.
++    Note that this is a per-character timeout, i.e. the port will wait this long for each
++    individual character, not for the whole read operation.  This timeout also applies to the
++    bytesWaiting() function.
++
++    \bold note:
++    POSIX does not support millisecond-level control for I/O timeout values.  Any
++    timeout set using this function will be set to the next lowest tenth of a second for
++    the purposes of detecting read or write timeouts.  For example a timeout of 550 milliseconds
++    will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and
++    writing the port.  However millisecond-level control is allowed by the select() system call,
++    so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for
++    the purpose of detecting available bytes in the read buffer.
++
++    For Windows:
++
++    Sets the read and write timeouts for the port to \a millisec milliseconds.
++    Setting 0 indicates that timeouts are not used for read nor write operations;
++    however read() and write() functions will still block. Set -1 to provide
++    non-blocking behaviour (read() and write() will return immediately).
++
++    \bold note: this function does nothing in event driven mode.
++*/
++void QextSerialPort::setTimeout(long millisec)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (d->Settings.Timeout_Millisec != millisec)
++        d->setTimeout(millisec, true);
++}
++
++/*!
++    Sets DTR line to the requested state (\a set default to high).  This function will have no effect if
++    the port associated with the class is not currently open.
++*/
++void QextSerialPort::setDtr(bool set)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (isOpen())
++        d->setDtr_sys(set);
++}
++
++/*!
++    Sets RTS line to the requested state \a set (high by default).
++    This function will have no effect if
++    the port associated with the class is not currently open.
++*/
++void QextSerialPort::setRts(bool set)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    if (isOpen())
++        d->setRts_sys(set);
++}
++
++/*! \reimp
++    Reads a block of data from the serial port.  This function will read at most maxlen bytes from
++    the serial port and place them in the buffer pointed to by data.  Return value is the number of
++    bytes actually read, or -1 on error.
++
++    \warning before calling this function ensure that serial port associated with this class
++    is currently open (use isOpen() function to check if port is open).
++*/
++qint64 QextSerialPort::readData(char *data, qint64 maxSize)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    qint64 bytesFromBuffer = 0;
++    if (!d->readBuffer.isEmpty()) {
++        bytesFromBuffer = d->readBuffer.read(data, maxSize);
++        if (bytesFromBuffer == maxSize)
++            return bytesFromBuffer;
++    }
++    qint64 bytesFromDevice = d->readData_sys(data+bytesFromBuffer, maxSize-bytesFromBuffer);
++    if (bytesFromDevice < 0) {
++        return -1;
++    }
++    return bytesFromBuffer + bytesFromDevice;
++}
++
++/*! \reimp
++    Writes a block of data to the serial port.  This function will write len bytes
++    from the buffer pointed to by data to the serial port.  Return value is the number
++    of bytes actually written, or -1 on error.
++
++    \warning before calling this function ensure that serial port associated with this class
++    is currently open (use isOpen() function to check if port is open).
++*/
++qint64 QextSerialPort::writeData(const char *data, qint64 maxSize)
++{
++    Q_D(QextSerialPort);
++    QWriteLocker locker(&d->lock);
++    return d->writeData_sys(data, maxSize);
++}
++
++#include "moc_qextserialport.cpp"
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport.h b/3rdparty/SerialPort/qextserialport/qextserialport.h
+index 2ae5560..cd079ef 100644
+--- a/3rdparty/SerialPort/qextserialport/qextserialport.h
++++ b/3rdparty/SerialPort/qextserialport/qextserialport.h
+@@ -1,27 +1,240 @@
+-
+-#ifndef _QEXTSERIALPORT_H_
+-#define _QEXTSERIALPORT_H_
+-
+-/*POSIX CODE*/
+-#ifdef _TTY_POSIX_
+-#include "posix_qextserialport.h"
+-#define QextBaseType Posix_QextSerialPort
+-
+-/*MS WINDOWS CODE*/
+-#else
+-#include "win_qextserialport.h"
+-#define QextBaseType Win_QextSerialPort
+-#endif
+-
+-class QextSerialPort: public QextBaseType {
+-public:
+-    QextSerialPort();
+-    QextSerialPort(const QString & name);
+-    QextSerialPort(PortSettings const& s);
+-    QextSerialPort(const QString & name, PortSettings const& s);
+-    QextSerialPort(const QextSerialPort& s);
+-    QextSerialPort& operator=(const QextSerialPort&);
+-    virtual ~QextSerialPort();
+-};
+-
+-#endif
++/****************************************************************************
++** Copyright (c) 2000-2003 Wayne Roth
++** Copyright (c) 2004-2007 Stefan Sander
++** Copyright (c) 2007 Michal Policht
++** Copyright (c) 2008 Brandon Fosdick
++** Copyright (c) 2009-2010 Liam Staskawicz
++** Copyright (c) 2011 Debao Zhang
++** All right reserved.
++** Web: http://code.google.com/p/qextserialport/
++**
++** Permission is hereby granted, free of charge, to any person obtaining
++** a copy of this software and associated documentation files (the
++** "Software"), to deal in the Software without restriction, including
++** without limitation the rights to use, copy, modify, merge, publish,
++** distribute, sublicense, and/or sell copies of the Software, and to
++** permit persons to whom the Software is furnished to do so, subject to
++** the following conditions:
++**
++** The above copyright notice and this permission notice shall be
++** included in all copies or substantial portions of the Software.
++**
++** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++**
++****************************************************************************/
++
++#ifndef _QEXTSERIALPORT_H_
++#define _QEXTSERIALPORT_H_
++
++#include <QtCore/QIODevice>
++#include "qextserialport_global.h"
++#ifdef Q_OS_UNIX
++#include <termios.h>
++#endif
++/*line status constants*/
++// ### QESP2.0 move to enum
++#define LS_CTS  0x01
++#define LS_DSR  0x02
++#define LS_DCD  0x04
++#define LS_RI   0x08
++#define LS_RTS  0x10
++#define LS_DTR  0x20
++#define LS_ST   0x40
++#define LS_SR   0x80
++
++/*error constants*/
++// ### QESP2.0 move to enum
++#define E_NO_ERROR                   0
++#define E_INVALID_FD                 1
++#define E_NO_MEMORY                  2
++#define E_CAUGHT_NON_BLOCKED_SIGNAL  3
++#define E_PORT_TIMEOUT               4
++#define E_INVALID_DEVICE             5
++#define E_BREAK_CONDITION            6
++#define E_FRAMING_ERROR              7
++#define E_IO_ERROR                   8
++#define E_BUFFER_OVERRUN             9
++#define E_RECEIVE_OVERFLOW          10
++#define E_RECEIVE_PARITY_ERROR      11
++#define E_TRANSMIT_OVERFLOW         12
++#define E_READ_FAILED               13
++#define E_WRITE_FAILED              14
++#define E_FILE_NOT_FOUND            15
++#define E_PERMISSION_DENIED         16
++#define E_AGAIN                     17
++
++enum BaudRateType
++{
++#if defined(Q_OS_UNIX) || defined(qdoc)
++    BAUD50 = 50,                //POSIX ONLY
++    BAUD75 = 75,                //POSIX ONLY
++    BAUD134 = 134,              //POSIX ONLY
++    BAUD150 = 150,              //POSIX ONLY
++    BAUD200 = 200,              //POSIX ONLY
++    BAUD1800 = 1800,            //POSIX ONLY
++#  if defined(B76800) || defined(qdoc)
++    BAUD76800 = 76800,          //POSIX ONLY
++#  endif
++#  if (defined(B230400) && defined(B4000000)) || defined(qdoc)
++    BAUD230400 = 230400,        //POSIX ONLY
++    BAUD460800 = 460800,        //POSIX ONLY
++    BAUD500000 = 500000,        //POSIX ONLY
++    BAUD576000 = 576000,        //POSIX ONLY
++    BAUD921600 = 921600,        //POSIX ONLY
++    BAUD1000000 = 1000000,      //POSIX ONLY
++    BAUD1152000 = 1152000,      //POSIX ONLY
++    BAUD1500000 = 1500000,      //POSIX ONLY
++    BAUD2000000 = 2000000,      //POSIX ONLY
++    BAUD2500000 = 2500000,      //POSIX ONLY
++    BAUD3000000 = 3000000,      //POSIX ONLY
++    BAUD3500000 = 3500000,      //POSIX ONLY
++    BAUD4000000 = 4000000,      //POSIX ONLY
++#  endif
++#endif //Q_OS_UNIX
++#if defined(Q_OS_WIN) || defined(qdoc)
++    BAUD14400 = 14400,          //WINDOWS ONLY
++    BAUD56000 = 56000,          //WINDOWS ONLY
++    BAUD128000 = 128000,        //WINDOWS ONLY
++    BAUD256000 = 256000,        //WINDOWS ONLY
++#endif  //Q_OS_WIN
++    BAUD110 = 110,
++    BAUD300 = 300,
++    BAUD600 = 600,
++    BAUD1200 = 1200,
++    BAUD2400 = 2400,
++    BAUD4800 = 4800,
++    BAUD9600 = 9600,
++    BAUD19200 = 19200,
++    BAUD38400 = 38400,
++    BAUD57600 = 57600,
++    BAUD115200 = 115200
++};
++
++enum DataBitsType
++{
++    DATA_5 = 5,
++    DATA_6 = 6,
++    DATA_7 = 7,
++    DATA_8 = 8
++};
++
++enum ParityType
++{
++    PAR_NONE,
++    PAR_ODD,
++    PAR_EVEN,
++#if defined(Q_OS_WIN) || defined(qdoc)
++    PAR_MARK,               //WINDOWS ONLY
++#endif
++    PAR_SPACE
++};
++
++enum StopBitsType
++{
++    STOP_1,
++#if defined(Q_OS_WIN) || defined(qdoc)
++    STOP_1_5,               //WINDOWS ONLY
++#endif
++    STOP_2
++};
++
++enum FlowType
++{
++    FLOW_OFF,
++    FLOW_HARDWARE,
++    FLOW_XONXOFF
++};
++
++/**
++ * structure to contain port settings
++ */
++struct PortSettings
++{
++    BaudRateType BaudRate;
++    DataBitsType DataBits;
++    ParityType Parity;
++    StopBitsType StopBits;
++    FlowType FlowControl;
++    long Timeout_Millisec;
++};
++
++class QextSerialPortPrivate;
++class QEXTSERIALPORT_EXPORT QextSerialPort: public QIODevice
++{
++    Q_OBJECT
++    Q_DECLARE_PRIVATE(QextSerialPort)
++    Q_ENUMS(QueryMode)
++    Q_PROPERTY(QString portName READ portName WRITE setPortName)
++    Q_PROPERTY(QueryMode queryMode READ queryMode WRITE setQueryMode)
++public:
++    enum QueryMode {
++        Polling,
++        EventDriven
++    };
++
++    explicit QextSerialPort(QueryMode mode = EventDriven, QObject* parent = 0);
++    explicit QextSerialPort(const QString & name, QueryMode mode = EventDriven, QObject * parent = 0);
++    explicit QextSerialPort(const PortSettings & s, QueryMode mode = EventDriven, QObject * parent = 0);
++    QextSerialPort(const QString & name, const PortSettings& s, QueryMode mode = EventDriven, QObject *parent=0);
++
++    ~QextSerialPort();
++
++    QString portName() const;
++    QueryMode queryMode() const;
++    BaudRateType baudRate() const;
++    DataBitsType dataBits() const;
++    ParityType parity() const;
++    StopBitsType stopBits() const;
++    FlowType flowControl() const;
++
++    bool open(OpenMode mode);
++    bool isSequential() const;
++    void close();
++    void flush();
++    qint64 bytesAvailable() const;
++    bool canReadLine() const;
++    QByteArray readAll();
++
++    ulong lastError() const;
++
++    ulong lineStatus();
++    QString errorString();
++
++public Q_SLOTS:
++    void setPortName(const QString & name);
++    void setQueryMode(QueryMode mode);
++    void setBaudRate(BaudRateType);
++    void setDataBits(DataBitsType);
++    void setParity(ParityType);
++    void setStopBits(StopBitsType);
++    void setFlowControl(FlowType);
++    void setTimeout(long);
++
++    void setDtr(bool set=true);
++    void setRts(bool set=true);
++
++Q_SIGNALS:
++    void dsrChanged(bool status);
++
++protected:
++    qint64 readData(char * data, qint64 maxSize);
++    qint64 writeData(const char * data, qint64 maxSize);
++
++private:
++    Q_DISABLE_COPY(QextSerialPort)
++
++#ifdef Q_OS_WIN
++    Q_PRIVATE_SLOT(d_func(), void _q_onWinEvent(HANDLE))
++#endif
++    Q_PRIVATE_SLOT(d_func(), void _q_canRead())
++
++    QextSerialPortPrivate * const d_ptr;
++};
++
++#endif
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport_global.h b/3rdparty/SerialPort/qextserialport/qextserialport_global.h
+new file mode 100644
+index 0000000..fe26871
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialport_global.h
+@@ -0,0 +1,72 @@
++/****************************************************************************
++** Copyright (c) 2000-2003 Wayne Roth
++** Copyright (c) 2004-2007 Stefan Sander
++** Copyright (c) 2007 Michal Policht
++** Copyright (c) 2008 Brandon Fosdick
++** Copyright (c) 2009-2010 Liam Staskawicz
++** Copyright (c) 2011 Debao Zhang
++** All right reserved.
++** Web: http://code.google.com/p/qextserialport/
++**
++** Permission is hereby granted, free of charge, to any person obtaining
++** a copy of this software and associated documentation files (the
++** "Software"), to deal in the Software without restriction, including
++** without limitation the rights to use, copy, modify, merge, publish,
++** distribute, sublicense, and/or sell copies of the Software, and to
++** permit persons to whom the Software is furnished to do so, subject to
++** the following conditions:
++**
++** The above copyright notice and this permission notice shall be
++** included in all copies or substantial portions of the Software.
++**
++** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++**
++****************************************************************************/
++
++#ifndef QEXTSERIALPORT_GLOBAL_H
++#define QEXTSERIALPORT_GLOBAL_H
++
++#include <QtCore/QtGlobal>
++
++#ifdef QEXTSERIALPORT_BUILD_SHARED
++#  define QEXTSERIALPORT_EXPORT Q_DECL_EXPORT
++#elif defined(QEXTSERIALPORT_USING_SHARED)
++#  define QEXTSERIALPORT_EXPORT Q_DECL_IMPORT
++#else
++#  define QEXTSERIALPORT_EXPORT
++#endif
++
++// ### for compatible with old version. should be removed in QESP 2.0
++#ifdef _TTY_NOWARN_
++#  define QESP_NO_WARN
++#endif
++#ifdef _TTY_NOWARN_PORT_
++#  define QESP_NO_PORTABILITY_WARN
++#endif
++
++/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
++#ifdef QESP_NO_WARN
++#  define QESP_NO_PORTABILITY_WARN
++#endif
++
++/*macros for warning and debug messages*/
++#ifdef QESP_NO_PORTABILITY_WARN
++#  define QESP_PORTABILITY_WARNING  while(false)qWarning
++#else
++#  define QESP_PORTABILITY_WARNING qWarning
++#endif /*QESP_NOWARN_PORT*/
++
++#ifdef QESP_NO_WARN
++#  define QESP_WARNING while(false)qWarning
++#else
++#  define QESP_WARNING qWarning
++#endif /*QESP_NOWARN*/
++
++#endif // QEXTSERIALPORT_GLOBAL_H
++
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport_p.h b/3rdparty/SerialPort/qextserialport/qextserialport_p.h
+new file mode 100644
+index 0000000..56146d3
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialport_p.h
+@@ -0,0 +1,257 @@
++/****************************************************************************
++** Copyright (c) 2000-2003 Wayne Roth
++** Copyright (c) 2004-2007 Stefan Sander
++** Copyright (c) 2007 Michal Policht
++** Copyright (c) 2008 Brandon Fosdick
++** Copyright (c) 2009-2010 Liam Staskawicz
++** Copyright (c) 2011 Debao Zhang
++** All right reserved.
++** Web: http://code.google.com/p/qextserialport/
++**
++** Permission is hereby granted, free of charge, to any person obtaining
++** a copy of this software and associated documentation files (the
++** "Software"), to deal in the Software without restriction, including
++** without limitation the rights to use, copy, modify, merge, publish,
++** distribute, sublicense, and/or sell copies of the Software, and to
++** permit persons to whom the Software is furnished to do so, subject to
++** the following conditions:
++**
++** The above copyright notice and this permission notice shall be
++** included in all copies or substantial portions of the Software.
++**
++** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++**
++****************************************************************************/
++
++#ifndef _QEXTSERIALPORT_P_H_
++#define _QEXTSERIALPORT_P_H_
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the QESP API.  It exists for the convenience
++// of other QESP classes.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qextserialport.h"
++#include <QtCore/QReadWriteLock>
++#ifdef Q_OS_UNIX
++#  include <termios.h>
++#elif (defined Q_OS_WIN)
++#  include <QtCore/qt_windows.h>
++#endif
++#include <stdlib.h>
++
++// This is QextSerialPort's read buffer, needed by posix system.
++// ref: QRingBuffer & QIODevicePrivateLinearBuffer
++class QextReadBuffer
++{
++public:
++    inline QextReadBuffer(size_t growth=4096)
++        : len(0), first(0), buf(0), capacity(0), basicBlockSize(growth) {
++    }
++
++    ~QextReadBuffer() {
++        delete [] buf;
++    }
++
++    inline void clear() {
++        first = buf;
++        len = 0;
++    }
++
++    inline int size() const {
++        return len;
++    }
++
++    inline bool isEmpty() const {
++        return len == 0;
++    }
++
++    inline int read(char* target, int size) {
++        int r = qMin(size, len);
++        if (r == 1) {
++            *target = *first;
++            --len;
++            ++first;
++        } else {
++            memcpy(target, first, r);
++            len -= r;
++            first += r;
++        }
++        return r;
++    }
++
++    inline char* reserve(size_t size) {
++        if ((first - buf) + len + size > capacity) {
++            size_t newCapacity = qMax(capacity, basicBlockSize);
++            while (newCapacity < size)
++                newCapacity *= 2;
++            if (newCapacity > capacity) {
++                // allocate more space
++                char* newBuf = new char[newCapacity];
++                memmove(newBuf, first, len);
++                delete [] buf;
++                buf = newBuf;
++                capacity = newCapacity;
++            } else {
++                // shift any existing data to make space
++                memmove(buf, first, len);
++            }
++            first = buf;
++        }
++        char* writePtr = first + len;
++        len += (int)size;
++        return writePtr;
++    }
++
++    inline void chop(int size) {
++        if (size >= len) {
++            clear();
++        } else {
++            len -= size;
++        }
++    }
++
++    inline void squeeze() {
++        if (first != buf) {
++            memmove(buf, first, len);
++            first = buf;
++        }
++        size_t newCapacity = basicBlockSize;
++        while (newCapacity < size_t(len))
++            newCapacity *= 2;
++        if (newCapacity < capacity) {
++            char * tmp = static_cast<char*>(realloc(buf, newCapacity));
++            if (tmp) {
++                buf = tmp;
++                capacity = newCapacity;
++            }
++        }
++    }
++
++    inline QByteArray readAll() {
++        char* f = first;
++        int l = len;
++        clear();
++        return QByteArray(f, l);
++    }
++
++    inline int readLine(char* target, int size) {
++        int r = qMin(size, len);
++        char* eol = static_cast<char*>(memchr(first, '\n', r));
++        if (eol)
++            r = 1+(eol-first);
++        memcpy(target, first, r);
++        len -= r;
++        first += r;
++        return int(r);
++    }
++
++    inline bool canReadLine() const {
++        return memchr(first, '\n', len);
++    }
++
++private:
++    int len;
++    char* first;
++    char* buf;
++    size_t capacity;
++    size_t basicBlockSize;
++};
++
++class QextWinEventNotifier;
++class QWinEventNotifier;
++class QReadWriteLock;
++class QSocketNotifier;
++
++class QextSerialPortPrivate
++{
++    Q_DECLARE_PUBLIC(QextSerialPort)
++public:
++    QextSerialPortPrivate(QextSerialPort * q);
++    ~QextSerialPortPrivate();
++    enum DirtyFlagEnum
++    {
++        DFE_BaudRate = 0x0001,
++        DFE_Parity = 0x0002,
++        DFE_StopBits = 0x0004,
++        DFE_DataBits = 0x0008,
++        DFE_Flow = 0x0010,
++        DFE_TimeOut = 0x0100,
++        DFE_ALL = 0x0fff,
++        DFE_Settings_Mask = 0x00ff //without TimeOut
++    };
++    mutable QReadWriteLock lock;
++    QString port;
++    PortSettings Settings;
++    QextReadBuffer readBuffer;
++    int settingsDirtyFlags;
++    ulong lastErr;
++    QextSerialPort::QueryMode _queryMode;
++
++    // platform specific members
++#ifdef Q_OS_UNIX
++    int fd;
++    QSocketNotifier *readNotifier;
++    struct termios Posix_CommConfig;
++    struct termios old_termios;
++#elif (defined Q_OS_WIN)
++    HANDLE Win_Handle;
++    OVERLAPPED overlap;
++    COMMCONFIG Win_CommConfig;
++    COMMTIMEOUTS Win_CommTimeouts;
++#  ifndef QESP_NO_QT4_PRIVATE
++    QWinEventNotifier *winEventNotifier;
++#  else
++    QextWinEventNotifier *winEventNotifier;
++#  endif
++    DWORD eventMask;
++    QList<OVERLAPPED*> pendingWrites;
++    QReadWriteLock* bytesToWriteLock;
++    qint64 _bytesToWrite;
++#endif
++
++    /*fill PortSettings*/
++    void setBaudRate(BaudRateType baudRate, bool update=true);
++    void setDataBits(DataBitsType dataBits, bool update=true);
++    void setParity(ParityType parity, bool update=true);
++    void setStopBits(StopBitsType stopbits, bool update=true);
++    void setFlowControl(FlowType flow, bool update=true);
++    void setTimeout(long millisec, bool update=true);
++    void setPortSettings(const PortSettings& settings, bool update=true);
++
++    void platformSpecificDestruct();
++    void platformSpecificInit();
++    void translateError(ulong error);
++    void updatePortSettings();
++
++    qint64 readData_sys(char * data, qint64 maxSize);
++    qint64 writeData_sys(const char * data, qint64 maxSize);
++    void setDtr_sys(bool set=true);
++    void setRts_sys(bool set=true);
++    bool open_sys(QIODevice::OpenMode mode);
++    bool close_sys();
++    bool flush_sys();
++    ulong lineStatus_sys();
++    qint64 bytesAvailable_sys() const;
++
++#ifdef Q_OS_WIN
++    void _q_onWinEvent(HANDLE h);
++#endif
++    void _q_canRead();
++
++    QextSerialPort * q_ptr;
++};
++
++#endif //_QEXTSERIALPORT_P_H_
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport_unix.cpp b/3rdparty/SerialPort/qextserialport/qextserialport_unix.cpp
+new file mode 100644
+index 0000000..3508fe1
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialport_unix.cpp
+@@ -0,0 +1,455 @@
++/****************************************************************************
++** Copyright (c) 2000-2003 Wayne Roth
++** Copyright (c) 2004-2007 Stefan Sander
++** Copyright (c) 2007 Michal Policht
++** Copyright (c) 2008 Brandon Fosdick
++** Copyright (c) 2009-2010 Liam Staskawicz
++** Copyright (c) 2011 Debao Zhang
++** All right reserved.
++** Web: http://code.google.com/p/qextserialport/
++**
++** Permission is hereby granted, free of charge, to any person obtaining
++** a copy of this software and associated documentation files (the
++** "Software"), to deal in the Software without restriction, including
++** without limitation the rights to use, copy, modify, merge, publish,
++** distribute, sublicense, and/or sell copies of the Software, and to
++** permit persons to whom the Software is furnished to do so, subject to
++** the following conditions:
++**
++** The above copyright notice and this permission notice shall be
++** included in all copies or substantial portions of the Software.
++**
++** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++**
++****************************************************************************/
++
++#include "qextserialport.h"
++#include "qextserialport_p.h"
++#include <fcntl.h>
++#include <stdio.h>
++#include <errno.h>
++#include <unistd.h>
++#include <sys/time.h>
++#include <sys/ioctl.h>
++#include <sys/select.h>
++#include <QtCore/QMutexLocker>
++#include <QtCore/QDebug>
++#include <QtCore/QSocketNotifier>
++
++void QextSerialPortPrivate::platformSpecificInit()
++{
++    fd = 0;
++    readNotifier = 0;
++}
++
++/*!
++    Standard destructor.
++*/
++void QextSerialPortPrivate::platformSpecificDestruct()
++{
++}
++
++static QString fullPortName(const QString &name)
++{
++    if (name.startsWith(QLatin1Char('/')))
++        return name;
++    return QLatin1String("/dev/")+name;
++}
++
++bool QextSerialPortPrivate::open_sys(QIODevice::OpenMode mode)
++{
++    Q_Q(QextSerialPort);
++    //note: linux 2.6.21 seems to ignore O_NDELAY flag
++    if ((fd = ::open(fullPortName(port).toLatin1() ,O_RDWR | O_NOCTTY | O_NDELAY)) != -1) {
++
++        /*In the Private class, We can not call QIODevice::open()*/
++        q->setOpenMode(mode);             // Flag the port as opened
++        ::tcgetattr(fd, &old_termios);    // Save the old termios
++        Posix_CommConfig = old_termios;   // Make a working copy
++        ::cfmakeraw(&Posix_CommConfig);   // Enable raw access
++
++        /*set up other port settings*/
++        Posix_CommConfig.c_cflag |= CREAD|CLOCAL;
++        Posix_CommConfig.c_lflag &= (~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
++        Posix_CommConfig.c_iflag &= (~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
++        Posix_CommConfig.c_oflag &= (~OPOST);
++        Posix_CommConfig.c_cc[VMIN] = 0;
++#ifdef _POSIX_VDISABLE  // Is a disable character available on this system?
++        // Some systems allow for per-device disable-characters, so get the
++        //  proper value for the configured device
++        const long vdisable = ::fpathconf(fd, _PC_VDISABLE);
++        Posix_CommConfig.c_cc[VINTR] = vdisable;
++        Posix_CommConfig.c_cc[VQUIT] = vdisable;
++        Posix_CommConfig.c_cc[VSTART] = vdisable;
++        Posix_CommConfig.c_cc[VSTOP] = vdisable;
++        Posix_CommConfig.c_cc[VSUSP] = vdisable;
++#endif //_POSIX_VDISABLE
++        settingsDirtyFlags = DFE_ALL;
++        updatePortSettings();
++
++        if (_queryMode == QextSerialPort::EventDriven) {
++            readNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, q);
++            q->connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_canRead()));
++        }
++        return true;
++    } else {
++        translateError(errno);
++        return false;
++    }
++}
++
++bool QextSerialPortPrivate::close_sys()
++{
++    // Force a flush and then restore the original termios
++    flush_sys();
++    // Using both TCSAFLUSH and TCSANOW here discards any pending input
++    ::tcsetattr(fd, TCSAFLUSH | TCSANOW, &old_termios);   // Restore termios
++    ::close(fd);
++    if(readNotifier) {
++        delete readNotifier;
++        readNotifier = 0;
++    }
++    return true;
++}
++
++bool QextSerialPortPrivate::flush_sys()
++{
++    ::tcdrain(fd);
++    return true;
++}
++
++qint64 QextSerialPortPrivate::bytesAvailable_sys() const
++{
++    int bytesQueued;
++    if (::ioctl(fd, FIONREAD, &bytesQueued) == -1) {
++        return (qint64)-1;
++    }
++    return bytesQueued;
++}
++
++/*!
++    Translates a system-specific error code to a QextSerialPort error code.  Used internally.
++*/
++void QextSerialPortPrivate::translateError(ulong error)
++{
++    switch (error) {
++    case EBADF:
++    case ENOTTY:
++        lastErr = E_INVALID_FD;
++        break;
++    case EINTR:
++        lastErr = E_CAUGHT_NON_BLOCKED_SIGNAL;
++        break;
++    case ENOMEM:
++        lastErr = E_NO_MEMORY;
++        break;
++    case EACCES:
++        lastErr = E_PERMISSION_DENIED;
++        break;
++    case EAGAIN:
++        lastErr = E_AGAIN;
++        break;
++    }
++}
++
++void QextSerialPortPrivate::setDtr_sys(bool set)
++{
++    int status;
++    ::ioctl(fd, TIOCMGET, &status);
++    if (set)
++        status |= TIOCM_DTR;
++    else
++        status &= ~TIOCM_DTR;
++    ::ioctl(fd, TIOCMSET, &status);
++}
++
++void QextSerialPortPrivate::setRts_sys(bool set)
++{
++    int status;
++    ::ioctl(fd, TIOCMGET, &status);
++    if (set)
++        status |= TIOCM_RTS;
++    else
++        status &= ~TIOCM_RTS;
++    ::ioctl(fd, TIOCMSET, &status);
++}
++
++unsigned long QextSerialPortPrivate::lineStatus_sys()
++{
++    unsigned long Status=0, Temp=0;
++    ::ioctl(fd, TIOCMGET, &Temp);
++    if (Temp & TIOCM_CTS) Status |= LS_CTS;
++    if (Temp & TIOCM_DSR) Status |= LS_DSR;
++    if (Temp & TIOCM_RI ) Status |= LS_RI;
++    if (Temp & TIOCM_CD ) Status |= LS_DCD;
++    if (Temp & TIOCM_DTR) Status |= LS_DTR;
++    if (Temp & TIOCM_RTS) Status |= LS_RTS;
++    if (Temp & TIOCM_ST ) Status |= LS_ST;
++    if (Temp & TIOCM_SR ) Status |= LS_SR;
++    return Status;
++}
++
++/*!
++    Reads a block of data from the serial port.  This function will read at most maxSize bytes from
++    the serial port and place them in the buffer pointed to by data.  Return value is the number of
++    bytes actually read, or -1 on error.
++    
++    \warning before calling this function ensure that serial port associated with this class
++    is currently open (use isOpen() function to check if port is open).
++*/
++qint64 QextSerialPortPrivate::readData_sys(char * data, qint64 maxSize)
++{
++    int retVal = ::read(fd, data, maxSize);
++    if (retVal == -1)
++        lastErr = E_READ_FAILED;
++
++    return retVal;
++}
++
++/*!
++    Writes a block of data to the serial port.  This function will write maxSize bytes
++    from the buffer pointed to by data to the serial port.  Return value is the number
++    of bytes actually written, or -1 on error.
++    
++    \warning before calling this function ensure that serial port associated with this class
++    is currently open (use isOpen() function to check if port is open).
++*/
++qint64 QextSerialPortPrivate::writeData_sys(const char * data, qint64 maxSize)
++{
++    int retVal = ::write(fd, data, maxSize);
++    if (retVal == -1)
++        lastErr = E_WRITE_FAILED;
++
++    return (qint64)retVal;
++}
++
++static void setBaudRate2Termios(termios *config, int baudRate)
++{
++#ifdef CBAUD
++    config->c_cflag &= (~CBAUD);
++    config->c_cflag |= baudRate;
++#else
++    ::cfsetispeed(config, baudRate);
++    ::cfsetospeed(config, baudRate);
++#endif
++}
++
++/*
++    All the platform settings was performed in this function.
++*/
++void QextSerialPortPrivate::updatePortSettings()
++{
++    if (!q_func()->isOpen() || !settingsDirtyFlags)
++        return;
++
++    if (settingsDirtyFlags & DFE_BaudRate) {
++        switch (Settings.BaudRate) {
++        case BAUD50:
++            setBaudRate2Termios(&Posix_CommConfig, B50);
++            break;
++        case BAUD75:
++            setBaudRate2Termios(&Posix_CommConfig, B75);
++            break;
++        case BAUD110:
++            setBaudRate2Termios(&Posix_CommConfig, B110);
++            break;
++        case BAUD134:
++            setBaudRate2Termios(&Posix_CommConfig, B134);
++            break;
++        case BAUD150:
++            setBaudRate2Termios(&Posix_CommConfig, B150);
++            break;
++        case BAUD200:
++            setBaudRate2Termios(&Posix_CommConfig, B200);
++            break;
++        case BAUD300:
++            setBaudRate2Termios(&Posix_CommConfig, B300);
++            break;
++        case BAUD600:
++            setBaudRate2Termios(&Posix_CommConfig, B600);
++            break;
++        case BAUD1200:
++            setBaudRate2Termios(&Posix_CommConfig, B1200);
++            break;
++        case BAUD1800:
++            setBaudRate2Termios(&Posix_CommConfig, B1800);
++            break;
++        case BAUD2400:
++            setBaudRate2Termios(&Posix_CommConfig, B2400);
++            break;
++        case BAUD4800:
++            setBaudRate2Termios(&Posix_CommConfig, B4800);
++            break;
++        case BAUD9600:
++            setBaudRate2Termios(&Posix_CommConfig, B9600);
++            break;
++        case BAUD19200:
++            setBaudRate2Termios(&Posix_CommConfig, B19200);
++            break;
++        case BAUD38400:
++            setBaudRate2Termios(&Posix_CommConfig, B38400);
++            break;
++        case BAUD57600:
++            setBaudRate2Termios(&Posix_CommConfig, B57600);
++            break;
++#ifdef B76800
++        case BAUD76800:
++            setBaudRate2Termios(&Posix_CommConfig, B76800);
++            break;
++#endif
++        case BAUD115200:
++            setBaudRate2Termios(&Posix_CommConfig, B115200);
++            break;
++#if defined(B230400) && defined(B4000000)
++        case BAUD230400:
++            setBaudRate2Termios(&Posix_CommConfig, B230400);
++            break;
++        case BAUD460800:
++            setBaudRate2Termios(&Posix_CommConfig, B460800);
++            break;
++        case BAUD500000:
++            setBaudRate2Termios(&Posix_CommConfig, B500000);
++            break;
++        case BAUD576000:
++            setBaudRate2Termios(&Posix_CommConfig, B576000);
++            break;
++        case BAUD921600:
++            setBaudRate2Termios(&Posix_CommConfig, B921600);
++            break;
++        case BAUD1000000:
++            setBaudRate2Termios(&Posix_CommConfig, B1000000);
++            break;
++        case BAUD1152000:
++            setBaudRate2Termios(&Posix_CommConfig, B1152000);
++            break;
++        case BAUD1500000:
++            setBaudRate2Termios(&Posix_CommConfig, B1500000);
++            break;
++        case BAUD2000000:
++            setBaudRate2Termios(&Posix_CommConfig, B2000000);
++            break;
++        case BAUD2500000:
++            setBaudRate2Termios(&Posix_CommConfig, B2500000);
++            break;
++        case BAUD3000000:
++            setBaudRate2Termios(&Posix_CommConfig, B3000000);
++            break;
++        case BAUD3500000:
++            setBaudRate2Termios(&Posix_CommConfig, B3500000);
++            break;
++        case BAUD4000000:
++            setBaudRate2Termios(&Posix_CommConfig, B4000000);
++            break;
++#endif
++        }
++    }
++    if (settingsDirtyFlags & DFE_Parity) {
++        switch (Settings.Parity) {
++        case PAR_SPACE:
++            /*space parity not directly supported - add an extra data bit to simulate it*/
++            settingsDirtyFlags |= DFE_DataBits;
++            break;
++        case PAR_NONE:
++            Posix_CommConfig.c_cflag &= (~PARENB);
++            break;
++        case PAR_EVEN:
++            Posix_CommConfig.c_cflag &= (~PARODD);
++            Posix_CommConfig.c_cflag |= PARENB;
++            break;
++        case PAR_ODD:
++            Posix_CommConfig.c_cflag |= (PARENB|PARODD);
++            break;
++        }
++    }
++    /*must after Parity settings*/
++    if (settingsDirtyFlags & DFE_DataBits) {
++        if (Settings.Parity != PAR_SPACE) {
++            Posix_CommConfig.c_cflag &= (~CSIZE);
++            switch(Settings.DataBits) {
++            case DATA_5:
++                Posix_CommConfig.c_cflag |= CS5;
++                break;
++            case DATA_6:
++                Posix_CommConfig.c_cflag |= CS6;
++                break;
++            case DATA_7:
++                Posix_CommConfig.c_cflag |= CS7;
++                break;
++            case DATA_8:
++                Posix_CommConfig.c_cflag |= CS8;
++                break;
++            }
++        } else {
++            /*space parity not directly supported - add an extra data bit to simulate it*/
++            Posix_CommConfig.c_cflag &= ~(PARENB|CSIZE);
++            switch(Settings.DataBits) {
++            case DATA_5:
++                Posix_CommConfig.c_cflag |= CS6;
++                break;
++            case DATA_6:
++                Posix_CommConfig.c_cflag |= CS7;
++                break;
++            case DATA_7:
++                Posix_CommConfig.c_cflag |= CS8;
++                break;
++            case DATA_8:
++                /*this will never happen, put here to Suppress an warning*/
++                break;
++            }
++        }
++    }
++    if (settingsDirtyFlags & DFE_StopBits) {
++        switch (Settings.StopBits) {
++        case STOP_1:
++            Posix_CommConfig.c_cflag &= (~CSTOPB);
++            break;
++        case STOP_2:
++            Posix_CommConfig.c_cflag |= CSTOPB;
++            break;
++        }
++    }
++    if (settingsDirtyFlags & DFE_Flow) {
++        switch(Settings.FlowControl) {
++        case FLOW_OFF:
++            Posix_CommConfig.c_cflag &= (~CRTSCTS);
++            Posix_CommConfig.c_iflag &= (~(IXON|IXOFF|IXANY));
++            break;
++        case FLOW_XONXOFF:
++            /*software (XON/XOFF) flow control*/
++            Posix_CommConfig.c_cflag &= (~CRTSCTS);
++            Posix_CommConfig.c_iflag |= (IXON|IXOFF|IXANY);
++            break;
++        case FLOW_HARDWARE:
++            Posix_CommConfig.c_cflag |= CRTSCTS;
++            Posix_CommConfig.c_iflag &= (~(IXON|IXOFF|IXANY));
++            break;
++        }
++    }
++
++    /*if any thing in Posix_CommConfig changed, flush*/
++    if (settingsDirtyFlags & DFE_Settings_Mask)
++        ::tcsetattr(fd, TCSAFLUSH, &Posix_CommConfig);
++
++    if (settingsDirtyFlags & DFE_TimeOut) {
++        int millisec = Settings.Timeout_Millisec;
++        if (millisec == -1) {
++            ::fcntl(fd, F_SETFL, O_NDELAY);
++        }
++        else {
++            //O_SYNC should enable blocking ::write()
++            //however this seems not working on Linux 2.6.21 (works on OpenBSD 4.2)
++            ::fcntl(fd, F_SETFL, O_SYNC);
++        }
++        ::tcgetattr(fd, & Posix_CommConfig);
++        Posix_CommConfig.c_cc[VTIME] = millisec/100;
++        ::tcsetattr(fd, TCSAFLUSH, & Posix_CommConfig);
++    }
++
++    settingsDirtyFlags = 0;
++}
+diff --git a/3rdparty/SerialPort/qextserialport/qextserialport_win.cpp b/3rdparty/SerialPort/qextserialport/qextserialport_win.cpp
+new file mode 100644
+index 0000000..2b1a849
+--- /dev/null
++++ b/3rdparty/SerialPort/qextserialport/qextserialport_win.cpp
+@@ -0,0 +1,427 @@
++/****************************************************************************
++** Copyright (c) 2000-2003 Wayne Roth
++** Copyright (c) 2004-2007 Stefan Sander
++** Copyright (c) 2007 Michal Policht
++** Copyright (c) 2008 Brandon Fosdick
++** Copyright (c) 2009-2010 Liam Staskawicz
++** Copyright (c) 2011 Debao Zhang
++** All right reserved.
++** Web: http://code.google.com/p/qextserialport/
++**
++** Permission is hereby granted, free of charge, to any person obtaining
++** a copy of this software and associated documentation files (the
++** "Software"), to deal in the Software without restriction, including
++** without limitation the rights to use, copy, modify, merge, publish,
++** distribute, sublicense, and/or sell copies of the Software, and to
++** permit persons to whom the Software is furnished to do so, subject to
++** the following conditions:
++**
++** The above copyright notice and this permission notice shall be
++** included in all copies or substantial portions of the Software.
++**
++** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
++** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
++** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
++** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++**
++****************************************************************************/
++
++#include "qextserialport.h"
++#include "qextserialport_p.h"
++#include <QtCore/QThread>
++#include <QtCore/QReadWriteLock>
++#include <QtCore/QMutexLocker>
++#include <QtCore/QDebug>
++#include <QtCore/QRegExp>
++#include <QtCore/QMetaType>
++#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
++#  include <QtCore/QWinEventNotifier>
++#  define WinEventNotifier QWinEventNotifier
++#elif !defined(QESP_NO_QT4_PRIVATE)
++#  include <QtCore/private/qwineventnotifier_p.h>
++#  define WinEventNotifier QWinEventNotifier
++#else
++#  include "qextwineventnotifier_p.h"
++#  define WinEventNotifier QextWinEventNotifier
++#endif
++void QextSerialPortPrivate::platformSpecificInit()
++{
++    Win_Handle=INVALID_HANDLE_VALUE;
++    ZeroMemory(&overlap, sizeof(OVERLAPPED));
++    overlap.hEvent = CreateEvent(NULL, true, false, NULL);
++    winEventNotifier = 0;
++    bytesToWriteLock = new QReadWriteLock;
++    _bytesToWrite = 0;
++}
++
++void QextSerialPortPrivate::platformSpecificDestruct() {
++    CloseHandle(overlap.hEvent);
++    delete bytesToWriteLock;
++}
++
++
++/*!
++    \internal
++    COM ports greater than 9 need \\.\ prepended
++
++    This is only need when open the port.
++*/
++static QString fullPortNameWin(const QString & name)
++{
++    QRegExp rx(QLatin1String("^COM(\\d+)"));
++    QString fullName(name);
++    if(fullName.contains(rx))
++        fullName.prepend(QLatin1String("\\\\.\\"));
++    return fullName;
++}
++
++bool QextSerialPortPrivate::open_sys(QIODevice::OpenMode mode)
++{
++    Q_Q(QextSerialPort);
++    DWORD confSize = sizeof(COMMCONFIG);
++    Win_CommConfig.dwSize = confSize;
++    DWORD dwFlagsAndAttributes = 0;
++    if (_queryMode == QextSerialPort::EventDriven)
++        dwFlagsAndAttributes += FILE_FLAG_OVERLAPPED;
++
++    /*open the port*/
++    Win_Handle=CreateFileW((wchar_t*)fullPortNameWin(port).utf16(), GENERIC_READ|GENERIC_WRITE,
++                           0, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL);
++    if (Win_Handle!=INVALID_HANDLE_VALUE) {
++        q->setOpenMode(mode);
++        /*configure port settings*/
++        GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
++        GetCommState(Win_Handle, &(Win_CommConfig.dcb));
++
++        /*set up parameters*/
++        Win_CommConfig.dcb.fBinary=TRUE;
++        Win_CommConfig.dcb.fInX=FALSE;
++        Win_CommConfig.dcb.fOutX=FALSE;
++        Win_CommConfig.dcb.fAbortOnError=FALSE;
++        Win_CommConfig.dcb.fNull=FALSE;
++        /* Dtr default to true. See Issue 122*/
++        Win_CommConfig.dcb.fDtrControl=TRUE;
++        /*flush all settings*/
++        settingsDirtyFlags = DFE_ALL;
++        updatePortSettings();
++
++        //init event driven approach
++        if (_queryMode == QextSerialPort::EventDriven) {
++            if (!SetCommMask( Win_Handle, EV_TXEMPTY | EV_RXCHAR | EV_DSR)) {
++                QESP_WARNING()<<"failed to set Comm Mask. Error code:"<<GetLastError();
++                return false;
++            }
++            winEventNotifier = new WinEventNotifier(overlap.hEvent, q);
++            qRegisterMetaType<HANDLE>("HANDLE");
++            q->connect(winEventNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_onWinEvent(HANDLE)), Qt::DirectConnection);
++            WaitCommEvent(Win_Handle, &eventMask, &overlap);
++        }
++        return true;
++    }
++    return false;
++}
++
++bool QextSerialPortPrivate::close_sys()
++{
++    flush_sys();
++    CancelIo(Win_Handle);
++    if (CloseHandle(Win_Handle))
++        Win_Handle = INVALID_HANDLE_VALUE;
++    if (winEventNotifier){
++        winEventNotifier->setEnabled(false);
++        winEventNotifier->deleteLater();
++        winEventNotifier = 0;
++    }
++    _bytesToWrite = 0;
++
++    foreach(OVERLAPPED* o, pendingWrites) {
++        CloseHandle(o->hEvent);
++        delete o;
++    }
++    pendingWrites.clear();
++    return true;
++}
++
++bool QextSerialPortPrivate::flush_sys()
++{
++    FlushFileBuffers(Win_Handle);
++    return true;
++}
++
++qint64 QextSerialPortPrivate::bytesAvailable_sys() const
++{
++    DWORD Errors;
++    COMSTAT Status;
++    if (ClearCommError(Win_Handle, &Errors, &Status)) {
++        return Status.cbInQue;
++    }
++    return (qint64)-1;
++}
++
++/*
++    Translates a system-specific error code to a QextSerialPort error code.  Used internally.
++*/
++void QextSerialPortPrivate::translateError(ulong error)
++{
++    if (error&CE_BREAK) {
++        lastErr=E_BREAK_CONDITION;
++    }
++    else if (error&CE_FRAME) {
++        lastErr=E_FRAMING_ERROR;
++    }
++    else if (error&CE_IOE) {
++        lastErr=E_IO_ERROR;
++    }
++    else if (error&CE_MODE) {
++        lastErr=E_INVALID_FD;
++    }
++    else if (error&CE_OVERRUN) {
++        lastErr=E_BUFFER_OVERRUN;
++    }
++    else if (error&CE_RXPARITY) {
++        lastErr=E_RECEIVE_PARITY_ERROR;
++    }
++    else if (error&CE_RXOVER) {
++        lastErr=E_RECEIVE_OVERFLOW;
++    }
++    else if (error&CE_TXFULL) {
++        lastErr=E_TRANSMIT_OVERFLOW;
++    }
++}
++
++/*
++    Reads a block of data from the serial port.  This function will read at most maxlen bytes from
++    the serial port and place them in the buffer pointed to by data.  Return value is the number of
++    bytes actually read, or -1 on error.
++    
++    \warning before calling this function ensure that serial port associated with this class
++    is currently open (use isOpen() function to check if port is open).
++*/
++qint64 QextSerialPortPrivate::readData_sys(char *data, qint64 maxSize)
++{
++    DWORD bytesRead = 0;
++    bool failed = false;
++    if (_queryMode == QextSerialPort::EventDriven) {
++        OVERLAPPED overlapRead;
++        ZeroMemory(&overlapRead, sizeof(OVERLAPPED));
++        if (!ReadFile(Win_Handle, (void*)data, (DWORD)maxSize, & bytesRead, & overlapRead)) {
++            if (GetLastError() == ERROR_IO_PENDING)
++                GetOverlappedResult(Win_Handle, & overlapRead, & bytesRead, true);
++            else
++                failed = true;
++        }
++    } else if (!ReadFile(Win_Handle, (void*)data, (DWORD)maxSize, & bytesRead, NULL)) {
++        failed = true;
++    }
++    if (!failed)
++        return (qint64)bytesRead;
++
++    lastErr = E_READ_FAILED;
++    return -1;
++}
++
++/*
++    Writes a block of data to the serial port.  This function will write len bytes
++    from the buffer pointed to by data to the serial port.  Return value is the number
++    of bytes actually written, or -1 on error.
++    
++    \warning before calling this function ensure that serial port associated with this class
++    is currently open (use isOpen() function to check if port is open).
++*/
++qint64 QextSerialPortPrivate::writeData_sys(const char *data, qint64 maxSize)
++{
++    DWORD bytesWritten = 0;
++    bool failed = false;
++    if (_queryMode == QextSerialPort::EventDriven) {
++        OVERLAPPED* newOverlapWrite = new OVERLAPPED;
++        ZeroMemory(newOverlapWrite, sizeof(OVERLAPPED));
++        newOverlapWrite->hEvent = CreateEvent(NULL, true, false, NULL);
++        if (WriteFile(Win_Handle, (void*)data, (DWORD)maxSize, & bytesWritten, newOverlapWrite)) {
++            CloseHandle(newOverlapWrite->hEvent);
++            delete newOverlapWrite;
++        }
++        else if (GetLastError() == ERROR_IO_PENDING) {
++            // writing asynchronously...not an error
++            QWriteLocker writelocker(bytesToWriteLock);
++            _bytesToWrite += maxSize;
++            pendingWrites.append(newOverlapWrite);
++        }
++        else {
++            QESP_WARNING()<<"QextSerialPort write error:"<<GetLastError();
++            failed = true;
++            if(!CancelIo(newOverlapWrite->hEvent))
++                QESP_WARNING("QextSerialPort: couldn't cancel IO");
++            if(!CloseHandle(newOverlapWrite->hEvent))
++                QESP_WARNING("QextSerialPort: couldn't close OVERLAPPED handle");
++            delete newOverlapWrite;
++        }
++    } else if (!WriteFile(Win_Handle, (void*)data, (DWORD)maxSize, & bytesWritten, NULL)) {
++        failed = true;
++    }
++
++    if (!failed)
++        return (qint64)bytesWritten;
++
++    lastErr = E_WRITE_FAILED;
++    return -1;
++}
++
++void QextSerialPortPrivate::setDtr_sys(bool set) {
++    EscapeCommFunction(Win_Handle, set ? SETDTR : CLRDTR);
++}
++
++void QextSerialPortPrivate::setRts_sys(bool set) {
++    EscapeCommFunction(Win_Handle, set ? SETRTS : CLRRTS);
++}
++
++ulong QextSerialPortPrivate::lineStatus_sys(void) {
++    unsigned long Status=0, Temp=0;
++    GetCommModemStatus(Win_Handle, &Temp);
++    if (Temp & MS_CTS_ON) Status|=LS_CTS;
++    if (Temp & MS_DSR_ON) Status|=LS_DSR;
++    if (Temp & MS_RING_ON) Status|=LS_RI;
++    if (Temp & MS_RLSD_ON) Status|=LS_DCD;
++    return Status;
++}
++
++/*
++  Triggered when there's activity on our HANDLE.
++*/
++void QextSerialPortPrivate::_q_onWinEvent(HANDLE h)
++{
++    Q_Q(QextSerialPort);
++    if(h == overlap.hEvent) {
++        if (eventMask & EV_RXCHAR) {
++            if (q->sender() != q && bytesAvailable_sys() > 0)
++                _q_canRead();
++        }
++        if (eventMask & EV_TXEMPTY) {
++            /*
++              A write completed.  Run through the list of OVERLAPPED writes, and if
++              they completed successfully, take them off the list and delete them.
++              Otherwise, leave them on there so they can finish.
++            */
++            qint64 totalBytesWritten = 0;
++            QList<OVERLAPPED*> overlapsToDelete;
++            foreach(OVERLAPPED* o, pendingWrites) {
++                DWORD numBytes = 0;
++                if (GetOverlappedResult(Win_Handle, o, & numBytes, false)) {
++                    overlapsToDelete.append(o);
++                    totalBytesWritten += numBytes;
++                } else if( GetLastError() != ERROR_IO_INCOMPLETE ) {
++                    overlapsToDelete.append(o);
++                    QESP_WARNING()<<"CommEvent overlapped write error:" << GetLastError();
++                }
++            }
++
++            if (q->sender() != q && totalBytesWritten > 0) {
++                QWriteLocker writelocker(bytesToWriteLock);
++                Q_EMIT q->bytesWritten(totalBytesWritten);
++                _bytesToWrite = 0;
++            }
++
++            foreach(OVERLAPPED* o, overlapsToDelete) {
++                OVERLAPPED *toDelete = pendingWrites.takeAt(pendingWrites.indexOf(o));
++                CloseHandle(toDelete->hEvent);
++                delete toDelete;
++            }
++        }
++        if (eventMask & EV_DSR) {
++            if (lineStatus_sys() & LS_DSR)
++                Q_EMIT q->dsrChanged(true);
++            else
++                Q_EMIT q->dsrChanged(false);
++        }
++    }
++    WaitCommEvent(Win_Handle, &eventMask, &overlap);
++}
++
++void QextSerialPortPrivate::updatePortSettings()
++{
++    if (!q_ptr->isOpen() || !settingsDirtyFlags)
++        return;
++
++    //fill struct : COMMCONFIG
++    if (settingsDirtyFlags & DFE_BaudRate) {
++        Win_CommConfig.dcb.BaudRate = Settings.BaudRate;
++    }
++    if (settingsDirtyFlags & DFE_Parity) {
++        Win_CommConfig.dcb.Parity = (BYTE)Settings.Parity;
++        Win_CommConfig.dcb.fParity = (Settings.Parity == PAR_NONE) ? FALSE : TRUE;
++    }
++    if (settingsDirtyFlags & DFE_DataBits) {
++        Win_CommConfig.dcb.ByteSize = (BYTE)Settings.DataBits;
++    }
++    if (settingsDirtyFlags & DFE_StopBits) {
++        switch (Settings.StopBits) {
++        case STOP_1:
++            Win_CommConfig.dcb.StopBits = ONESTOPBIT;
++            break;
++        case STOP_1_5:
++            Win_CommConfig.dcb.StopBits = ONE5STOPBITS;
++            break;
++        case STOP_2:
++            Win_CommConfig.dcb.StopBits = TWOSTOPBITS;
++            break;
++        }
++    }
++    if (settingsDirtyFlags & DFE_Flow) {
++        switch(Settings.FlowControl) {
++        /*no flow control*/
++        case FLOW_OFF:
++            Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
++            Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
++            Win_CommConfig.dcb.fInX=FALSE;
++            Win_CommConfig.dcb.fOutX=FALSE;
++            break;
++        /*software (XON/XOFF) flow control*/
++        case FLOW_XONXOFF:
++            Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
++            Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
++            Win_CommConfig.dcb.fInX=TRUE;
++            Win_CommConfig.dcb.fOutX=TRUE;
++            break;
++        /*hardware flow control*/
++        case FLOW_HARDWARE:
++            Win_CommConfig.dcb.fOutxCtsFlow=TRUE;
++            Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_HANDSHAKE;
++            Win_CommConfig.dcb.fInX=FALSE;
++            Win_CommConfig.dcb.fOutX=FALSE;
++            break;
++        }
++    }
++
++    //fill struct : COMMTIMEOUTS
++    if (settingsDirtyFlags & DFE_TimeOut) {
++        if (_queryMode != QextSerialPort::EventDriven) {
++            int millisec = Settings.Timeout_Millisec;
++            if (millisec == -1) {
++                Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD;
++                Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
++            } else {
++                Win_CommTimeouts.ReadIntervalTimeout = millisec;
++                Win_CommTimeouts.ReadTotalTimeoutConstant = millisec;
++            }
++            Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
++            Win_CommTimeouts.WriteTotalTimeoutMultiplier = millisec;
++            Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
++        }
++        else {
++            Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD;
++            Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
++            Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
++            Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
++            Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
++        }
++    }
++
++
++    if (settingsDirtyFlags & DFE_Settings_Mask)
++        SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
++    if ((settingsDirtyFlags & DFE_TimeOut))
++        SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
++    settingsDirtyFlags = 0;
++}
+diff --git a/3rdparty/SerialPort/qextserialport/win_qextserialport.cpp b/3rdparty/SerialPort/qextserialport/win_qextserialport.cpp
+deleted file mode 100644
+index 8cfc635..0000000
+--- a/3rdparty/SerialPort/qextserialport/win_qextserialport.cpp
++++ /dev/null
+@@ -1,877 +0,0 @@
+-/*!
+-		\class Win_QextSerialPort
+-		\version 1.0.0
+-		\author Stefan Sander
+-
+-A cross-platform serial port class.
+-		This class encapsulates the Windows portion of QextSerialPort.  The user will be notified of
+-		errors and possible portability conflicts at run-time by default - this behavior can be turned
+-		off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off
+-		portability warnings) in the project.  Note that defining _TTY_NOWARN_ also defines
+-		_TTY_NOWARN_PORT_.
+-
+-\note
+-		On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
+-		select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
+-		make no guarantees as to the quality of POSIX support under NT/2000 however.
+-
+-*/
+-
+-#include <stdio.h>
+-#include "win_qextserialport.h"
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort()
+-			Default constructor.  Note that the name of the device used by a Win_QextSerialPort constructed
+-			with this constructor will be determined by #defined constants, or lack thereof - the default
+-			behavior is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants
+-			are:
+-
+-\verbatim
+-
+-Constant         Used By         Naming Convention
+-		----------       -------------   ------------------------
+-		_TTY_WIN_        Windows         COM1, COM2
+-		_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
+-		_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
+-		_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
+-		_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
+-		_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
+-		_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
+-		<none>           Linux           /dev/ttyS0, /dev/ttyS1
+-		\endverbatim
+-
+-This constructor associates the object with the first port on the system, e.g. COM1 for Windows
+-		platforms.  See the other constructor if you need a port other than the first.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort():QextSerialBase() {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-}
+-
+-/*!Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort&)
+-	Copy constructor.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort& s):QextSerialBase(s.port) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-	setOpenMode(s.openMode());
+-	lastErr=s.lastErr;
+-	port = s.port;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Win_Handle=s.Win_Handle;
+-	memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG));
+-	memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS));
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name)
+-			Constructs a serial port attached to the port specified by devName.
+-			devName is the name of the device, which is windowsystem-specific,
+-			e.g."COM2" or "/dev/ttyS0".
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const QString & name):QextSerialBase(name) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
+-			Constructs a port with default name and specified settings.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setStopBits(settings.StopBits);
+-	setParity(settings.Parity);
+-	setFlowControl(settings.FlowControl);
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings)
+-			Constructs a port with specified name and settings.
+-*/
+-Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings) {
+-	Win_Handle=INVALID_HANDLE_VALUE;
+-	setPortName(name);
+-	setBaudRate(settings.BaudRate);
+-	setDataBits(settings.DataBits);
+-	setStopBits(settings.StopBits);
+-	setParity(settings.Parity);
+-	setFlowControl(settings.FlowControl);
+-	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort::~Win_QextSerialPort()
+-			Standard destructor.
+-*/
+-Win_QextSerialPort::~Win_QextSerialPort() {
+-	if (isOpen()) {
+-		close();
+-	}
+-}
+-
+-/*!
+-		\fn Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s)
+-			overrides the = operator
+-*/
+-Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) {
+-	setOpenMode(s.openMode());
+-	lastErr=s.lastErr;
+-	port = s.port;
+-	Settings.FlowControl=s.Settings.FlowControl;
+-	Settings.Parity=s.Settings.Parity;
+-	Settings.DataBits=s.Settings.DataBits;
+-	Settings.StopBits=s.Settings.StopBits;
+-	Settings.BaudRate=s.Settings.BaudRate;
+-	Win_Handle=s.Win_Handle;
+-	memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG));
+-	memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS));
+-	return *this;
+-}
+-
+-/*!
+-		\fn bool Win_QextSerialPort::open(OpenMode mode)
+-			Opens a serial port.  Note that this function does not specify which device to open.  If you need
+-			to open a device by name, see Win_QextSerialPort::open(const char*).  This function has no effect
+-			if the port associated with the class is already open.  The port is also configured to the current
+-			settings, as stored in the Settings structure.
+-*/
+-bool Win_QextSerialPort::open(OpenMode mode) {
+-	unsigned long confSize = sizeof(COMMCONFIG);
+-	Win_CommConfig.dwSize = confSize;
+-	
+-	LOCK_MUTEX();
+-	if (mode == QIODevice::NotOpen)
+-		return isOpen();
+-	if (!isOpen()) {
+-		/*open the port*/
+-		Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE,
+-				FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+-		if (Win_Handle!=INVALID_HANDLE_VALUE) {
+-			/*set open mode*/
+-			QIODevice::open(mode);
+-			
+-			/*configure port settings*/
+-			GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
+-			GetCommState(Win_Handle, &(Win_CommConfig.dcb));
+-			
+-			/*set up parameters*/
+-			Win_CommConfig.dcb.fBinary=TRUE;
+-			Win_CommConfig.dcb.fInX=FALSE;
+-			Win_CommConfig.dcb.fOutX=FALSE;
+-			Win_CommConfig.dcb.fAbortOnError=FALSE;
+-			Win_CommConfig.dcb.fNull=FALSE;
+-			setBaudRate(Settings.BaudRate);
+-			setDataBits(Settings.DataBits);
+-			setStopBits(Settings.StopBits);
+-			setParity(Settings.Parity);
+-			setFlowControl(Settings.FlowControl);
+-			setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
+-			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return isOpen();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::close()
+-			Closes a serial port.  This function has no effect if the serial port associated with the class
+-			is not currently open.
+-*/
+-void Win_QextSerialPort::close() {
+-	LOCK_MUTEX();
+-	CloseHandle(Win_Handle);
+-	QIODevice::close();
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::flush()
+-			Flushes all pending I/O to the serial port.  This function has no effect if the serial port
+-			associated with the class is not currently open.
+-*/
+-void Win_QextSerialPort::flush() {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		FlushFileBuffers(Win_Handle);
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::size() const
+-This function will return the number of bytes waiting in the receive queue of the serial port.
+-		It is included primarily to provide a complete QIODevice interface, and will not record errors
+-		in the lastErr member (because it is const).  This function is also not thread-safe - in
+-		multithreading situations, use Win_QextSerialPort::bytesAvailable() instead.
+-*/
+-qint64 Win_QextSerialPort::size() const {
+-	int availBytes;
+-	COMSTAT Win_ComStat;
+-	DWORD Win_ErrorMask=0;
+-	ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat);
+-	availBytes = Win_ComStat.cbInQue;
+-	return (qint64)availBytes;
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::bytesAvailable()
+-			Returns the number of bytes waiting in the port's receive queue.  This function will return 0 if
+-			the port is not currently open, or -1 on error.  Error information can be retrieved by calling
+-			Win_QextSerialPort::getLastError().
+-*/
+-qint64 Win_QextSerialPort::bytesAvailable() {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		DWORD Errors;
+-		COMSTAT Status;
+-		bool success=ClearCommError(Win_Handle, &Errors, &Status);
+-		translateError(Errors);
+-		if (success) {
+-			lastErr=E_NO_ERROR;
+-			UNLOCK_MUTEX();
+-			return Status.cbInQue + QIODevice::bytesAvailable();
+-		}
+-		UNLOCK_MUTEX();
+-		return (unsigned int)-1;
+-	}
+-	UNLOCK_MUTEX();
+-	return 0;
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::translateError(ulong error)
+-			Translates a system-specific error code to a QextSerialPort error code.  Used internally.
+-*/
+-void Win_QextSerialPort::translateError(ulong error) {
+-	if (error&CE_BREAK) {
+-		lastErr=E_BREAK_CONDITION;
+-	}
+-	else if (error&CE_FRAME) {
+-		lastErr=E_FRAMING_ERROR;
+-	}
+-	else if (error&CE_IOE) {
+-		lastErr=E_IO_ERROR;
+-	}
+-	else if (error&CE_MODE) {
+-		lastErr=E_INVALID_FD;
+-	}
+-	else if (error&CE_OVERRUN) {
+-		lastErr=E_BUFFER_OVERRUN;
+-	}
+-	else if (error&CE_RXPARITY) {
+-		lastErr=E_RECEIVE_PARITY_ERROR;
+-	}
+-	else if (error&CE_RXOVER) {
+-		lastErr=E_RECEIVE_OVERFLOW;
+-	}
+-	else if (error&CE_TXFULL) {
+-		lastErr=E_TRANSMIT_OVERFLOW;
+-	}
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
+-			Reads a block of data from the serial port.  This function will read at most maxlen bytes from
+-			the serial port and place them in the buffer pointed to by data.  Return value is the number of
+-			bytes actually read, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	COMSTAT Win_ComStat;
+-	DWORD Win_BytesRead=0;
+-	DWORD Win_ErrorMask=0;
+-	ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat);
+-	if (Win_ComStat.cbInQue &&
+-			(!ReadFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesRead, NULL)
+-			|| Win_BytesRead==0)) {
+-				lastErr=E_READ_FAILED;
+-		retVal=-1;
+-	}
+-	else {
+-		retVal=((int)Win_BytesRead);
+-	}
+-	UNLOCK_MUTEX();
+-	
+-	return retVal;
+-}
+-
+-/*!
+-		\fn qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize)
+-			Writes a block of data to the serial port.  This function will write len bytes
+-			from the buffer pointed to by data to the serial port.  Return value is the number
+-			of bytes actually written, or -1 on error.
+-
+-\warning before calling this function ensure that serial port associated with this class
+-		is currently open (use isOpen() function to check if port is open).
+-*/
+-qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize)
+-{
+-	LOCK_MUTEX();
+-	int retVal=0;
+-	DWORD Win_BytesWritten;
+-	if (!WriteFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesWritten, NULL)) {
+-		lastErr=E_WRITE_FAILED;
+-		retVal=-1;
+-	}
+-	else {
+-		retVal=((int)Win_BytesWritten);
+-	}
+-	UNLOCK_MUTEX();
+-	
+-	flush();
+-	return retVal;
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::ungetChar(char c)
+-			This function is included to implement the full QIODevice interface, and currently has no
+-			purpose within this class.  This function is meaningless on an unbuffered device and currently
+-			only prints a warning message to that effect.
+-*/
+-void Win_QextSerialPort::ungetChar(char c) {
+-	
+-	/*meaningless on unbuffered sequential device - return error and print a warning*/
+-	TTY_WARNING("Win_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setFlowControl(FlowType flow)
+-			Sets the flow control used by the port.  Possible values of flow are:
+-\verbatim
+-		FLOW_OFF            No flow control
+-		FLOW_HARDWARE       Hardware (RTS/CTS) flow control
+-		FLOW_XONXOFF        Software (XON/XOFF) flow control
+-		\endverbatim
+-*/
+-void Win_QextSerialPort::setFlowControl(FlowType flow) {
+-	LOCK_MUTEX();
+-	if (Settings.FlowControl!=flow) {
+-		Settings.FlowControl=flow;
+-	}
+-	if (isOpen()) {
+-		switch(flow) {
+-				
+-				/*no flow control*/
+-			case FLOW_OFF:
+-				Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
+-				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
+-				Win_CommConfig.dcb.fInX=FALSE;
+-				Win_CommConfig.dcb.fOutX=FALSE;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-				
+-				/*software (XON/XOFF) flow control*/
+-			case FLOW_XONXOFF:
+-				Win_CommConfig.dcb.fOutxCtsFlow=FALSE;
+-				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE;
+-				Win_CommConfig.dcb.fInX=TRUE;
+-				Win_CommConfig.dcb.fOutX=TRUE;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-				
+-			case FLOW_HARDWARE:
+-				Win_CommConfig.dcb.fOutxCtsFlow=TRUE;
+-				Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_HANDSHAKE;
+-				Win_CommConfig.dcb.fInX=FALSE;
+-				Win_CommConfig.dcb.fOutX=FALSE;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setParity(ParityType parity)
+-			Sets the parity associated with the serial port.  The possible values of parity are:
+-\verbatim
+-		PAR_SPACE       Space Parity
+-		PAR_MARK        Mark Parity
+-		PAR_NONE        No Parity
+-		PAR_EVEN        Even Parity
+-		PAR_ODD         Odd Parity
+-		\endverbatim
+-*/
+-void Win_QextSerialPort::setParity(ParityType parity) {
+-	LOCK_MUTEX();
+-	if (Settings.Parity!=parity) {
+-		Settings.Parity=parity;
+-	}
+-	if (isOpen()) {
+-		Win_CommConfig.dcb.Parity=(unsigned char)parity;
+-		switch (parity) {
+-				
+-				/*space parity*/
+-			case PAR_SPACE:
+-				if (Settings.DataBits==DATA_8) {
+-					TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: Space parity with 8 data bits is not supported by POSIX systems.");
+-				}
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-				
+-				/*mark parity - WINDOWS ONLY*/
+-			case PAR_MARK:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning:  Mark parity is not supported by POSIX systems");
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-				
+-				/*no parity*/
+-			case PAR_NONE:
+-				Win_CommConfig.dcb.fParity=FALSE;
+-				break;
+-				
+-				/*even parity*/
+-			case PAR_EVEN:
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-				
+-				/*odd parity*/
+-			case PAR_ODD:
+-				Win_CommConfig.dcb.fParity=TRUE;
+-				break;
+-			}
+-			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setDataBits(DataBitsType dataBits)
+-			Sets the number of data bits used by the serial port.  Possible values of dataBits are:
+-\verbatim
+-		DATA_5      5 data bits
+-		DATA_6      6 data bits
+-		DATA_7      7 data bits
+-		DATA_8      8 data bits
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following restrictions:
+-\par
+-		5 data bits cannot be used with 2 stop bits.
+-		\par
+-		1.5 stop bits can only be used with 5 data bits.
+-		\par
+-		8 data bits cannot be used with space parity on POSIX systems.
+-
+-*/
+-void Win_QextSerialPort::setDataBits(DataBitsType dataBits) {
+-	LOCK_MUTEX();
+-	if (Settings.DataBits!=dataBits) {
+-		if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
+-				(Settings.StopBits==STOP_1_5 && dataBits!=DATA_5)) {
+-				}
+-		else {
+-			Settings.DataBits=dataBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch(dataBits) {
+-				
+-				/*5 data bits*/
+-			case DATA_5:
+-				if (Settings.StopBits==STOP_2) {
+-					TTY_WARNING("Win_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=5;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*6 data bits*/
+-			case DATA_6:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Win_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=6;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*7 data bits*/
+-			case DATA_7:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Win_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=7;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*8 data bits*/
+-			case DATA_8:
+-				if (Settings.StopBits==STOP_1_5) {
+-					TTY_WARNING("Win_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
+-				}
+-				else {
+-					Win_CommConfig.dcb.ByteSize=8;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setStopBits(StopBitsType stopBits)
+-			Sets the number of stop bits used by the serial port.  Possible values of stopBits are:
+-\verbatim
+-		STOP_1      1 stop bit
+-		STOP_1_5    1.5 stop bits
+-		STOP_2      2 stop bits
+-		\endverbatim
+-
+-\note
+-		This function is subject to the following restrictions:
+-\par
+-		2 stop bits cannot be used with 5 data bits.
+-		\par
+-		1.5 stop bits cannot be used with 6 or more data bits.
+-		\par
+-		POSIX does not support 1.5 stop bits.
+-*/
+-void Win_QextSerialPort::setStopBits(StopBitsType stopBits) {
+-	LOCK_MUTEX();
+-	if (Settings.StopBits!=stopBits) {
+-		if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) ||
+-				(stopBits==STOP_1_5 && Settings.DataBits!=DATA_5)) {
+-				}
+-		else {
+-			Settings.StopBits=stopBits;
+-		}
+-	}
+-	if (isOpen()) {
+-		switch (stopBits) {
+-				
+-				/*one stop bit*/
+-			case STOP_1:
+-				Win_CommConfig.dcb.StopBits=ONESTOPBIT;
+-				SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				break;
+-				
+-				/*1.5 stop bits*/
+-			case STOP_1_5:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX.");
+-				if (Settings.DataBits!=DATA_5) {
+-					TTY_WARNING("Win_QextSerialPort: 1.5 stop bits can only be used with 5 data bits");
+-				}
+-				else {
+-					Win_CommConfig.dcb.StopBits=ONE5STOPBITS;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-				
+-				/*two stop bits*/
+-			case STOP_2:
+-				if (Settings.DataBits==DATA_5) {
+-					TTY_WARNING("Win_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
+-				}
+-				else {
+-					Win_CommConfig.dcb.StopBits=TWOSTOPBITS;
+-					SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-				}
+-				break;
+-			}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setBaudRate(BaudRateType baudRate)
+-			Sets the baud rate of the serial port.  Note that not all rates are applicable on
+-			all platforms.  The following table shows translations of the various baud rate
+-			constants on Windows(including NT/2000) and POSIX platforms.  Speeds marked with an *
+-			are speeds that are usable on both Windows and POSIX.
+-			\verbatim
+-
+-RATE          Windows Speed   POSIX Speed
+-		-----------   -------------   -----------
+-		BAUD50                 110          50
+-		BAUD75                 110          75
+-		*BAUD110                110         110
+-		BAUD134                110         134.5
+-		BAUD150                110         150
+-		BAUD200                110         200
+-		*BAUD300                300         300
+-		*BAUD600                600         600
+-		*BAUD1200              1200        1200
+-		BAUD1800              1200        1800
+-		*BAUD2400              2400        2400
+-		*BAUD4800              4800        4800
+-		*BAUD9600              9600        9600
+-		BAUD14400            14400        9600
+-		*BAUD19200            19200       19200
+-		*BAUD38400            38400       38400
+-		BAUD56000            56000       38400
+-		*BAUD57600            57600       57600
+-		BAUD76800            57600       76800
+-		*BAUD115200          115200      115200
+-		BAUD128000          128000      115200
+-		BAUD256000          256000      115200
+-		\endverbatim
+-*/
+-void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) {
+-	LOCK_MUTEX();
+-	if (Settings.BaudRate!=baudRate) {
+-		switch (baudRate) {
+-			case BAUD50:
+-			case BAUD75:
+-			case BAUD134:
+-			case BAUD150:
+-			case BAUD200:
+-				Settings.BaudRate=BAUD110;
+-				break;
+-				
+-			case BAUD1800:
+-				Settings.BaudRate=BAUD1200;
+-				break;
+-				
+-			case BAUD76800:
+-				Settings.BaudRate=BAUD57600;
+-				break;
+-				
+-			default:
+-				Settings.BaudRate=baudRate;
+-				break;
+-			}
+-	}
+-	if (isOpen()) {
+-		switch (baudRate) {
+-				
+-				/*50 baud*/
+-			case BAUD50:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 50 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*75 baud*/
+-			case BAUD75:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 75 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*110 baud*/
+-			case BAUD110:
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*134.5 baud*/
+-			case BAUD134:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 134.5 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*150 baud*/
+-			case BAUD150:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 150 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*200 baud*/
+-			case BAUD200:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 200 baud operation.  Switching to 110 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_110;
+-				break;
+-				
+-				/*300 baud*/
+-			case BAUD300:
+-				Win_CommConfig.dcb.BaudRate=CBR_300;
+-				break;
+-				
+-				/*600 baud*/
+-			case BAUD600:
+-				Win_CommConfig.dcb.BaudRate=CBR_600;
+-				break;
+-				
+-				/*1200 baud*/
+-			case BAUD1200:
+-				Win_CommConfig.dcb.BaudRate=CBR_1200;
+-				break;
+-				
+-				/*1800 baud*/
+-			case BAUD1800:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 1800 baud operation.  Switching to 1200 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_1200;
+-				break;
+-				
+-				/*2400 baud*/
+-			case BAUD2400:
+-				Win_CommConfig.dcb.BaudRate=CBR_2400;
+-				break;
+-				
+-				/*4800 baud*/
+-			case BAUD4800:
+-				Win_CommConfig.dcb.BaudRate=CBR_4800;
+-				break;
+-				
+-				/*9600 baud*/
+-			case BAUD9600:
+-				Win_CommConfig.dcb.BaudRate=CBR_9600;
+-				break;
+-				
+-				/*14400 baud*/
+-			case BAUD14400:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 14400 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_14400;
+-				break;
+-				
+-				/*19200 baud*/
+-			case BAUD19200:
+-				Win_CommConfig.dcb.BaudRate=CBR_19200;
+-				break;
+-				
+-				/*38400 baud*/
+-			case BAUD38400:
+-				Win_CommConfig.dcb.BaudRate=CBR_38400;
+-				break;
+-				
+-				/*56000 baud*/
+-			case BAUD56000:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 56000 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_56000;
+-				break;
+-				
+-				/*57600 baud*/
+-			case BAUD57600:
+-				Win_CommConfig.dcb.BaudRate=CBR_57600;
+-				break;
+-				
+-				/*76800 baud*/
+-			case BAUD76800:
+-				TTY_WARNING("Win_QextSerialPort: Windows does not support 76800 baud operation.  Switching to 57600 baud.");
+-				Win_CommConfig.dcb.BaudRate=CBR_57600;
+-				break;
+-				
+-				/*115200 baud*/
+-			case BAUD115200:
+-				Win_CommConfig.dcb.BaudRate=CBR_115200;
+-				break;
+-				
+-				/*128000 baud*/
+-			case BAUD128000:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 128000 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_128000;
+-				break;
+-				
+-				/*256000 baud*/
+-			case BAUD256000:
+-				TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 256000 baud operation.");
+-				Win_CommConfig.dcb.BaudRate=CBR_256000;
+-				break;
+-			}
+-			SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setDtr(bool set)
+-			Sets DTR line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Win_QextSerialPort::setDtr(bool set) {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		if (set) {
+-			EscapeCommFunction(Win_Handle, SETDTR);
+-		}
+-		else {
+-			EscapeCommFunction(Win_Handle, CLRDTR);
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setRts(bool set)
+-			Sets RTS line to the requested state (high by default).  This function will have no effect if
+-			the port associated with the class is not currently open.
+-*/
+-void Win_QextSerialPort::setRts(bool set) {
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		if (set) {
+-			EscapeCommFunction(Win_Handle, SETRTS);
+-		}
+-		else {
+-			EscapeCommFunction(Win_Handle, CLRRTS);
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-}
+-
+-/*!
+-		\fn ulong Win_QextSerialPort::lineStatus(void)
+-			returns the line status as stored by the port function.  This function will retrieve the states
+-			of the following lines: DCD, CTS, DSR, and RI.  On POSIX systems, the following additional lines
+-			can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD.  The value returned is an unsigned
+-			long with specific bits indicating which lines are high.  The following constants should be used
+-			to examine the states of individual lines:
+-
+-\verbatim
+-		Mask        Line
+-		------      ----
+-		LS_CTS      CTS
+-		LS_DSR      DSR
+-		LS_DCD      DCD
+-		LS_RI       RI
+-		\endverbatim
+-
+-This function will return 0 if the port associated with the class is not currently open.
+-*/
+-ulong Win_QextSerialPort::lineStatus(void) {
+-	unsigned long Status=0, Temp=0;
+-	LOCK_MUTEX();
+-	if (isOpen()) {
+-		GetCommModemStatus(Win_Handle, &Temp);
+-		if (Temp&MS_CTS_ON) {
+-			Status|=LS_CTS;
+-		}
+-		if (Temp&MS_DSR_ON) {
+-			Status|=LS_DSR;
+-		}
+-		if (Temp&MS_RING_ON) {
+-			Status|=LS_RI;
+-		}
+-		if (Temp&MS_RLSD_ON) {
+-			Status|=LS_DCD;
+-		}
+-	}
+-	UNLOCK_MUTEX();
+-	return Status;
+-}
+-
+-/*!
+-		\fn void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec);
+-Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.
+-*/
+-void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec) {
+-	LOCK_MUTEX();
+-	Settings.Timeout_Sec=sec;
+-	Settings.Timeout_Millisec=millisec;
+-	if(isOpen()) {
+-		Win_CommTimeouts.ReadIntervalTimeout = sec*1000+millisec;
+-		Win_CommTimeouts.ReadTotalTimeoutMultiplier = sec*1000+millisec;
+-		Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
+-		Win_CommTimeouts.WriteTotalTimeoutMultiplier = sec*1000+millisec;
+-		Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
+-		SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
+-	}
+-	UNLOCK_MUTEX();
+-}
+diff --git a/3rdparty/SerialPort/qextserialport/win_qextserialport.h b/3rdparty/SerialPort/qextserialport/win_qextserialport.h
+deleted file mode 100644
+index 09a28c7..0000000
+--- a/3rdparty/SerialPort/qextserialport/win_qextserialport.h
++++ /dev/null
+@@ -1,48 +0,0 @@
+-#ifndef _WIN_QEXTSERIALPORT_H_
+-#define _WIN_QEXTSERIALPORT_H_
+-
+-#include "qextserialbase.h"
+-
+-/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
+-#ifdef _TTY_NOWARN_
+-#define _TTY_NOWARN_PORT_
+-#endif
+-
+-#include <windows.h>
+-
+-class Win_QextSerialPort:public QextSerialBase {
+-public:
+-	Win_QextSerialPort();
+-	Win_QextSerialPort(Win_QextSerialPort const& s);
+-	Win_QextSerialPort(const QString & name);
+-	Win_QextSerialPort(const PortSettings& settings);
+-	Win_QextSerialPort(const QString & name, const PortSettings& settings);
+-	Win_QextSerialPort& operator=(const Win_QextSerialPort& s);
+-	virtual ~Win_QextSerialPort();
+-	virtual bool open(OpenMode mode=0);
+-	virtual void close();
+-	virtual void flush();
+-	virtual qint64 size() const;
+-	virtual void ungetChar(char c);
+-	virtual void setFlowControl(FlowType);
+-	virtual void setParity(ParityType);
+-	virtual void setDataBits(DataBitsType);
+-	virtual void setStopBits(StopBitsType);
+-	virtual void setBaudRate(BaudRateType);
+-	virtual void setDtr(bool set=true);
+-	virtual void setRts(bool set=true);
+-	virtual ulong lineStatus(void);
+-	virtual qint64 bytesAvailable();
+-	virtual void translateError(ulong);
+-	virtual void setTimeout(ulong, ulong);
+-	
+-protected:
+-	HANDLE Win_Handle;
+-	COMMCONFIG Win_CommConfig;
+-	COMMTIMEOUTS Win_CommTimeouts;
+-	
+-	virtual qint64 readData(char *data, qint64 maxSize);
+-	virtual qint64 writeData(const char *data, qint64 maxSize);
+-};
+-
+-#endif
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f0b5196..97a2d2c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -63,6 +63,7 @@ configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+ 
+ option(WITH_PROFILING "BUILD WITH PROFILING" OFF)
+ 
++add_subdirectory(3rdparty/SerialPort/qextserialport)
+ add_subdirectory(3rdparty/SerialPort)
+ add_subdirectory(3rdparty/QMKToolBox)
+ add_subdirectory(3rdparty/QZip)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 5bda737..c0a045b 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -650,6 +650,7 @@ include_directories(
+   ${QL_OPENGL_INCLUDE_DIR}
+   ${CMAKE_SOURCE_DIR}/include
+   ${CMAKE_SOURCE_DIR}/3rdparty/SerialPort
++  ${CMAKE_SOURCE_DIR}/3rdparty/SerialPort/qextserialport
+   ${CMAKE_SOURCE_DIR}/3rdparty/QMKToolBox
+   ${CMAKE_SOURCE_DIR}/3rdparty/QZip
+   ${CMAKE_SOURCE_DIR}/3rdparty/QTextHtmlExporter
+-- 
+1.8.5.3
+
+
+From c30290b33a880533227445feab71f1509fe9cdda Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan at danny.cz>
+Date: Sun, 23 Mar 2014 14:43:53 +0100
+Subject: [PATCH 3/3] unbundle QextSerialPort library
+
+---
+ 3rdparty/SerialPort/CMakeLists.txt     |  4 +-
+ CMakeLists.txt                         |  5 +++
+ cmake/Modules/FindQextSerialPort.cmake | 73 ++++++++++++++++++++++++++++++++++
+ src/CMakeLists.txt                     |  2 +-
+ 4 files changed, 81 insertions(+), 3 deletions(-)
+ create mode 100644 cmake/Modules/FindQextSerialPort.cmake
+
+diff --git a/3rdparty/SerialPort/CMakeLists.txt b/3rdparty/SerialPort/CMakeLists.txt
+index c878380..ac289cb 100644
+--- a/3rdparty/SerialPort/CMakeLists.txt
++++ b/3rdparty/SerialPort/CMakeLists.txt
+@@ -35,7 +35,7 @@ qt4_add_resources(RC_SRCS ${RCS})
+ 
+ 
+ include_directories(
+-    qextserialport
++    ${QEXTSERIALPORT_INCLUDE_DIRS}
+ )
+ 
+ link_directories(
+@@ -52,5 +52,5 @@ add_library(SerialPort
+ )
+ 
+ target_link_libraries( SerialPort
+-      ${QT_LIBRARIES} qextserialport
++      ${QT_LIBRARIES} ${QEXTSERIALPORT_LIBRARIES}
+ )
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 97a2d2c..f3981c3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -63,7 +63,12 @@ configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+ 
+ option(WITH_PROFILING "BUILD WITH PROFILING" OFF)
+ 
++find_package(QextSerialPort)
++if (NOT QEXTSERIALPORT_FOUND)
+ add_subdirectory(3rdparty/SerialPort/qextserialport)
++set(QEXTSERIALPORT_LIBRARIES qextserialport)
++set(QEXTSERIALPORT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/3rdparty/SerialPort/qextserialport)
++endif()
+ add_subdirectory(3rdparty/SerialPort)
+ add_subdirectory(3rdparty/QMKToolBox)
+ add_subdirectory(3rdparty/QZip)
+diff --git a/cmake/Modules/FindQextSerialPort.cmake b/cmake/Modules/FindQextSerialPort.cmake
+new file mode 100644
+index 0000000..faf6d9f
+--- /dev/null
++++ b/cmake/Modules/FindQextSerialPort.cmake
+@@ -0,0 +1,73 @@
++# - Try to find QextSerialPort
++# Once done this will define
++#
++#  QEXTSERIALPORT_FOUND - system has QEXTSERIALPORT
++#  QEXTSERIALPORT_INCLUDE_DIRS - the QEXTSERIALPORT include directory
++#  QEXTSERIALPORT_LIBRARIES - Link these to use QEXTSERIALPORT
++#  QEXTSERIALPORT_DEFINITIONS - Compiler switches required for using QEXTSERIALPORT
++#
++#  Copyright (c) 2006 Andreas Schneider <mail at cynapses.org>
++#  updated for QextSerialPort by Dan Horák
++#
++#  Redistribution and use is allowed according to the terms of the New
++#  BSD license.
++#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
++#
++
++
++if (QEXTSERIALPORT_LIBRARIES AND QEXTSERIALPORT_INCLUDE_DIRS)
++  # in cache already
++  set(QEXTSERIALPORT_FOUND TRUE)
++else (QEXTSERIALPORT_LIBRARIES AND QEXTSERIALPORT_INCLUDE_DIRS)
++  find_path(QEXTSERIALPORT_INCLUDE_DIRS
++    NAMES
++      qextserialport.h
++    PATHS
++        /usr/include
++        /usr/local/include
++        /opt/local/include
++        /sw/include
++        /usr/include/QtExtSerialPort
++        /usr/local/include/QtExtSerialPort
++        /opt/local/include/QtExtSerialPort
++        /sw/include/QtExtSerialPort
++  )
++
++  # debian uses version suffixes
++  # add suffix evey new release
++  find_library(QEXTSERIALPORT_LIBRARIES
++    NAMES
++        qextserialport-1.2
++    PATHS
++      /usr/lib64
++      /usr/lib
++      /usr/local/lib
++      /opt/local/lib
++      /sw/lib
++  )
++
++  if (QEXTSERIALPORT_INCLUDE_DIRS AND QEXTSERIALPORT_LIBRARIES)
++     set(QEXTSERIALPORT_FOUND TRUE)
++  endif (QEXTSERIALPORT_INCLUDE_DIRS AND QEXTSERIALPORT_LIBRARIES)
++
++  if (QEXTSERIALPORT_FOUND)
++    if (NOT QEXTSERIALPORT_FIND_QUIETLY)
++      message(STATUS "Found QtExtSerialPort: ${QEXTSERIALPORT_LIBRARIES}")
++    endif (NOT QEXTSERIALPORT_FIND_QUIETLY)
++  else (QEXTSERIALPORT_FOUND)
++    if (QEXTSERIALPORT_FIND_REQUIRED)
++      message(FATAL_ERROR "Could not find QtExtSerialPort")
++    endif (QEXTSERIALPORT_FIND_REQUIRED)
++  endif (QEXTSERIALPORT_FOUND)
++
++  # show the QEXTSERIALPORT_INCLUDE_DIRS and QEXTSERIALPORT_LIBRARIES variables only in the advanced view
++  mark_as_advanced(QEXTSERIALPORT_INCLUDE_DIRS QEXTSERIALPORT_LIBRARIES)
++
++endif (QEXTSERIALPORT_LIBRARIES AND QEXTSERIALPORT_INCLUDE_DIRS)
++
++if (WIN32)
++set(QEXTSERIALPORT_FOUND FALSE)
++set(QEXTSERIALPORT_LIBRARIES "")
++set(QEXTSERIALPORT_INCLUDE_DIRS "")
++endif (WIN32)
++
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index c0a045b..ea02ef5 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -650,7 +650,6 @@ include_directories(
+   ${QL_OPENGL_INCLUDE_DIR}
+   ${CMAKE_SOURCE_DIR}/include
+   ${CMAKE_SOURCE_DIR}/3rdparty/SerialPort
+-  ${CMAKE_SOURCE_DIR}/3rdparty/SerialPort/qextserialport
+   ${CMAKE_SOURCE_DIR}/3rdparty/QMKToolBox
+   ${CMAKE_SOURCE_DIR}/3rdparty/QZip
+   ${CMAKE_SOURCE_DIR}/3rdparty/QTextHtmlExporter
+@@ -661,6 +660,7 @@ include_directories(
+   ${EXIF_INCLUDE_DIRS}
+   ${DMTX_INCLUDE_DIRS}
+   ${GPSD_INCLUDE_DIRS}
++  ${QEXTSERIALPORT_INCLUDE_DIRS}
+ )
+ 
+ set(qlandkarte_ALLINP
+-- 
+1.8.5.3
+
diff --git a/qlandkartegt.spec b/qlandkartegt.spec
index 4f212ca..658c314 100644
--- a/qlandkartegt.spec
+++ b/qlandkartegt.spec
@@ -1,6 +1,6 @@
 Name: qlandkartegt
 Version: 1.7.6
-Release: 1%{?dist}
+Release: 2%{?dist}
 Summary: GPS device mapping tool
 
 Group: Applications/Communications
@@ -9,6 +9,8 @@ URL: http://www.qlandkarte.org/
 Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
 # <GL/glu.h> not included by qt >= 4.8
 Patch0: %{name}-1.3.0-glu.patch
+# unbundle qextserialport (#872883)
+Patch1: %{name}-1.7.6-qextserialport.patch
 Requires: garmindev(interface) = 1.18
 Requires: gpsbabel
 Requires: proj-epsg
@@ -25,6 +27,7 @@ BuildRequires: libdmtx-devel
 BuildRequires: gpsd-devel
 BuildRequires: qt-webkit-devel
 BuildRequires: qtsoap-devel
+BuildRequires: qextserialport-devel
 %if 0%{?fedora} >= 16
 BuildRequires: libjpeg-devel
 %endif
@@ -52,9 +55,10 @@ GDAL tools, but it will simplify their use to the demands of most users.
 %prep
 %setup -q
 %patch0 -p1 -b .glu
+%patch1 -p1 -b .qqextsp
 
 # remove unbundled stuff
-rm -rf 3rdparty/qtsoap
+rm -rf 3rdparty/qtsoap 3rdparty/SerialPort/qextserialport
 
 # create build direcotory
 mkdir build
@@ -88,6 +92,9 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop
 
 
 %changelog
+* Sun Mar 23 2014 Dan Horák <dan[at]danny.cz> - 1.7.6-2
+- unbundle qextserial library (#872883)
+
 * Sun Feb 16 2014 Dan Horák <dan[at]danny.cz> - 1.7.6-1
 - update to 1.7.6
 


More information about the scm-commits mailing list