mirror of
https://github.com/boostorg/asio.git
synced 2026-02-25 14:32:08 +00:00
Fix serial port support on POSIX platforms that don't provide the BSD
extensions cfmakeraw, cfsetspeed and CRTSCTS. [SVN r46507]
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user