X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fserial%2Fserial.cxx;h=2d273090803165e24ac4ebe7e599301a49f3b270;hb=0a2264cad465fcca6ea9679f1db139d6ee6cd3e6;hp=405e9b04c76f2f2162e8d3ab64f6283868544669;hpb=18703ce02d64e0d696404e1a441ec9ce1e9a673a;p=simgear.git diff --git a/simgear/serial/serial.cxx b/simgear/serial/serial.cxx index 405e9b04..2d273090 100644 --- a/simgear/serial/serial.cxx +++ b/simgear/serial/serial.cxx @@ -14,23 +14,17 @@ // 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 - -#ifdef SG_HAVE_STD_INCLUDE -# include -#else -# include -#endif +#include +#include #if !defined( WIN32 ) || defined( __CYGWIN__) || defined( __CYGWIN32__ ) # include @@ -102,7 +96,7 @@ bool SGSerialPort::open_port(const string& device) { struct termios config; - fd = open(device.c_str(), O_RDWR | O_NONBLOCK); + fd = open(device.c_str(), O_RDWR | O_NOCTTY| O_NDELAY); SG_LOG( SG_EVENT, SG_DEBUG, "Serial fd created = " << fd); if ( fd == -1 ) { @@ -123,11 +117,14 @@ bool SGSerialPort::open_port(const string& device) { // cout << "config.c_iflag = " << config.c_iflag << endl; - // software flow control on - config.c_iflag |= IXON; - // config.c_iflag |= IXOFF; + // disable LF expanded to CR-LF + config.c_oflag &= ~(ONLCR); - // config.c_cflag |= CLOCAL; + // disable software flow control + config.c_iflag &= ~(IXON | IXOFF | IXANY); + + // enable the receiver and set local mode + config.c_cflag |= (CLOCAL | CREAD); #if !defined( sgi ) && !defined(_AIX) // disable hardware flow control @@ -135,6 +132,9 @@ bool SGSerialPort::open_port(const string& device) { #endif // cout << "config.c_iflag = " << config.c_iflag << endl; + + // Raw (not cooked/canonical) input mode + config.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); if ( tcsetattr( fd, TCSANOW, &config ) != 0 ) { SG_LOG( SG_IO, SG_ALERT, "Unable to update port settings" );