diff --git a/include/boost/asio/detail/reactive_serial_port_service.hpp b/include/boost/asio/detail/reactive_serial_port_service.hpp index 9b3130c1..c6d719be 100644 --- a/include/boost/asio/detail/reactive_serial_port_service.hpp +++ b/include/boost/asio/detail/reactive_serial_port_service.hpp @@ -109,7 +109,16 @@ public: s = descriptor_ops::error_wrapper(::tcgetattr(fd, &ios), ec); if (s >= 0) { +#if defined(_BSD_SOURCE) ::cfmakeraw(&ios); +#else + ios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK + | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + ios.c_oflag &= ~OPOST; + ios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + ios.c_cflag &= ~(CSIZE | PARENB); + ios.c_cflag |= CS8; +#endif ios.c_iflag |= IGNPAR; descriptor_ops::clear_error(ec); s = descriptor_ops::error_wrapper(::tcsetattr(fd, TCSANOW, &ios), ec); diff --git a/include/boost/asio/impl/serial_port_base.ipp b/include/boost/asio/impl/serial_port_base.ipp index 24ed7e7b..3dd7ba89 100644 --- a/include/boost/asio/impl/serial_port_base.ipp +++ b/include/boost/asio/impl/serial_port_base.ipp @@ -108,7 +108,12 @@ inline boost::system::error_code serial_port_base::baud_rate::store( ec = boost::asio::error::invalid_argument; return ec; } +# if defined(_BSD_SOURCE) ::cfsetspeed(&storage, baud); +# else + ::cfsetispeed(&storage, baud); + ::cfsetospeed(&storage, baud); +# endif #endif ec = boost::system::error_code(); return ec; @@ -242,16 +247,25 @@ inline boost::system::error_code serial_port_base::flow_control::store( { case none: storage.c_iflag &= ~(IXOFF | IXON); +# if defined(_BSD_SOURCE) storage.c_cflag &= ~CRTSCTS; +# endif break; case software: storage.c_iflag |= IXOFF | IXON; +# if defined(_BSD_SOURCE) storage.c_cflag &= ~CRTSCTS; +# endif break; case hardware: +# if defined(_BSD_SOURCE) storage.c_iflag &= ~(IXOFF | IXON); storage.c_cflag |= CRTSCTS; break; +# else + ec = boost::asio::error::operation_not_supported; + return ec; +# endif default: break; }