X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fserial%2Fserial.cxx;h=985cc8755e47c4761a2feafb83b0f471c3010896;hb=a131f442477a11894169933755591674bb7ad5e9;hp=b80082f768a32b0fb486239d71a7ae1a609916f7;hpb=3538631e8ec13777edc1f139c9365a5de251b33c;p=simgear.git diff --git a/simgear/serial/serial.cxx b/simgear/serial/serial.cxx index b80082f7..985cc875 100644 --- a/simgear/serial/serial.cxx +++ b/simgear/serial/serial.cxx @@ -14,25 +14,19 @@ // 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 -#include STL_IOSTREAM +#include +#include -#ifdef SG_HAVE_STD_INCLUDE -# include -#else -# include -#endif - -#if !defined( WIN32 ) || defined( __CYGWIN__) || defined( __CYGWIN32__ ) +#ifndef _WIN32 # include # include # include @@ -66,7 +60,7 @@ SGSerialPort::~SGSerialPort() { 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, @@ -123,6 +117,9 @@ bool SGSerialPort::open_port(const string& device) { // 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); @@ -150,7 +147,7 @@ bool SGSerialPort::open_port(const string& device) { bool SGSerialPort::close_port() { -#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ ) +#ifdef _WIN32 CloseHandle( fd ); #else close(fd); @@ -164,7 +161,7 @@ bool SGSerialPort::close_port() { bool SGSerialPort::set_baud(int baud) { -#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ ) +#ifdef _WIN32 DCB dcb; if ( GetCommState( fd, &dcb ) ) { @@ -277,7 +274,7 @@ string SGSerialPort::read_port() { 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 ) ) { @@ -329,7 +326,7 @@ string SGSerialPort::read_port() { 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 ) ) { @@ -386,7 +383,7 @@ int SGSerialPort::read_port(char *buf, int len) { int SGSerialPort::write_port(const string& value) { -#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ ) +#ifdef _WIN32 LPCVOID lpBuffer = value.data(); DWORD nNumberOfBytesToWrite = value.length(); @@ -460,7 +457,7 @@ int SGSerialPort::write_port(const string& value) { int SGSerialPort::write_port(const char* buf, int len) { -#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ ) +#ifdef _WIN32 LPCVOID lpBuffer = buf; DWORD nNumberOfBytesToWrite = len;