1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-23 04:04:54 +08:00

Merge 3db36faa1445843eb70b227ca9d482549836ebf2 into a20acb2a0004a0d2eab4d3e49b9c72119dcbb903

This commit is contained in:
William Woodall 2013-08-11 10:43:19 -07:00
commit 1686b61221

View File

@ -36,6 +36,10 @@
#endif #endif
#endif #endif
#if defined(MAC_OS_X_VERSION_10_3) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3)
#include <IOKit/serial/ioss.h>
#endif
using std::string; using std::string;
using std::stringstream; using std::stringstream;
using std::invalid_argument; using std::invalid_argument;
@ -238,10 +242,13 @@ Serial::SerialImpl::reconfigurePort ()
#endif #endif
default: default:
custom_baud = true; custom_baud = true;
// Mac OS X 10.x Support // OS X support
#if defined(__APPLE__) && defined(__MACH__) #if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
#define IOSSIOSPEED _IOW('T', 2, speed_t) // Starting with Tiger, the IOSSIOSPEED ioctl can be used to set arbitrary baud rates
int new_baud = static_cast<int> (baudrate_); // other than those specified by POSIX. The driver for the underlying serial hardware
// ultimately determines which baud rates can be used. This ioctl sets both the input
// and output speed.
speed_t new_baud = static_cast<speed_t>(baudrate_);
if (ioctl (fd_, IOSSIOSPEED, &new_baud, 1) < 0) { if (ioctl (fd_, IOSSIOSPEED, &new_baud, 1) < 0) {
THROW (IOException, errno); THROW (IOException, errno);
} }