Commit 18340b64 authored by LM's avatar LM

Fixed serial port for mac os

parent dc2098b6
...@@ -93,8 +93,6 @@ public: ...@@ -93,8 +93,6 @@ public:
BAUDR_200, BAUDR_200,
BAUDR_1800, BAUDR_1800,
//BAUDR_76800, //BAUDR_76800,
#endif
#ifdef Q_OS_LINUX
BAUDR_500000, BAUDR_500000,
BAUDR_576000, BAUDR_576000,
#endif #endif
......
...@@ -276,34 +276,64 @@ void TermiosHelper::setBaudRate(QPortSettings::BaudRate baudRate) ...@@ -276,34 +276,64 @@ void TermiosHelper::setBaudRate(QPortSettings::BaudRate baudRate)
case QPortSettings::BAUDR_115200: case QPortSettings::BAUDR_115200:
baud = B115200; baud = B115200;
break; break;
#if defined(Q_OS_LINUX)
case QPortSettings::BAUDR_230400: case QPortSettings::BAUDR_230400:
baud = B230400; #ifdef B230400
baud = B230400;
#else
baud = (speed_t)230400;
#endif
break; break;
case QPortSettings::BAUDR_460800: case QPortSettings::BAUDR_460800:
#ifdef B460800
baud = B460800; baud = B460800;
#else
baud = (speed_t)460800;
#endif
break; break;
case QPortSettings::BAUDR_500000: case QPortSettings::BAUDR_500000:
#ifdef B500000
baud = B500000; baud = B500000;
#else
baud = (speed_t)500000;
#endif
break; break;
case QPortSettings::BAUDR_576000: case QPortSettings::BAUDR_576000:
#ifdef B576000
baud = B576000; baud = B576000;
#else
baud = (speed_t)576000;
#endif
break; break;
case QPortSettings::BAUDR_921600: case QPortSettings::BAUDR_921600:
#ifdef B921600
baud = B921600; baud = B921600;
break; #else
baud = (speed_t)921600;
#endif #endif
break;
default: default:
qWarning() << "TermiosHelper::setBaudRate(" << baudRate << "): " \ qWarning() << "TermiosHelper::setBaudRate(" << baudRate << "): " \
"Unsupported baud rate"; "Unsupported baud rate";
} }
//#ifdef Q_OS_MAC
// if ( ioctl( fileDescriptor_, IOSSIOSPEED, &baud ) == -1 )
// {
// qCritical() << QString("TermiosHelper::setBaudRate(file: %1) failed: %2(%3)")
// .arg(fileDescriptor_)
// .arg(strerror(errno))
// .arg(errno);
// return false;
// }
//#else
if ( cfsetspeed(currentAttrs_, baud) == -1 ) { if ( cfsetspeed(currentAttrs_, baud) == -1 ) {
qCritical() << QString("TermiosHelper::setBaudRate(file: %1) failed: %2(%3)") qCritical() << QString("TermiosHelper::setBaudRate(file: %1) failed: %2(%3)")
.arg(fileDescriptor_) .arg(fileDescriptor_)
.arg(strerror(errno)) .arg(strerror(errno))
.arg(errno); .arg(errno);
} }
//#endif
} }
/*! /*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment