// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the
-// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <simgear/compiler.h>
-#include STL_IOSTREAM
+#include <iostream>
+#include <cerrno>
-#ifdef SG_HAVE_STD_INCLUDE
-# include <cerrno>
-#else
-# include <errno.h>
-#endif
-
-#if !defined( WIN32 ) || defined( __CYGWIN__) || defined( __CYGWIN32__ )
+#ifndef _WIN32
# include <termios.h>
# include <sys/types.h>
# include <sys/stat.h>
bool SGSerialPort::open_port(const string& device) {
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
fd = CreateFile( device.c_str(),
GENERIC_READ | GENERIC_WRITE,
// cout << "config.c_iflag = " << config.c_iflag << endl;
+ // disable LF expanded to CR-LF
+ config.c_oflag &= ~(ONLCR);
+
// disable software flow control
config.c_iflag &= ~(IXON | IXOFF | IXANY);
bool SGSerialPort::close_port() {
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
CloseHandle( fd );
#else
close(fd);
bool SGSerialPort::set_baud(int baud) {
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
DCB dcb;
if ( GetCommState( fd, &dcb ) ) {
char buffer[max_count+1];
string result;
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
DWORD count;
if ( ReadFile( fd, buffer, max_count, &count, 0 ) ) {
int SGSerialPort::read_port(char *buf, int len) {
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
DWORD count;
if ( ReadFile( fd, buf, len, &count, 0 ) ) {
int SGSerialPort::write_port(const string& value) {
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
LPCVOID lpBuffer = value.data();
DWORD nNumberOfBytesToWrite = value.length();
int SGSerialPort::write_port(const char* buf, int len) {
-#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
+#ifdef _WIN32
LPCVOID lpBuffer = buf;
DWORD nNumberOfBytesToWrite = len;