Use the IOSSIOSPEED ioctl to set non-standard port speeds on OS X.

This commit is contained in:
Sean Wilson 2017-02-13 21:20:02 -05:00
parent 46790676e6
commit e61a54267f
1 changed files with 9 additions and 1 deletions

View File

@ -243,7 +243,15 @@ JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configPort(J
// Apply changes
ioctl(serialPortFD, TIOCEXCL); // Block other non-root users from using this port
return ((tcsetattr(serialPortFD, TCSANOW, &options) == 0) ? JNI_TRUE : JNI_FALSE);
jboolean rc = ((tcsetattr(serialPortFD, TCSANOW, &options) == 0) ? JNI_TRUE : JNI_FALSE);
if (baudRateCode == 0) {
// use IOSSIOSPEED to set non-standard baud rate
speed_t speed = (speed_t)baudRate;
ioctl(serialPortFD, IOSSIOSPEED, &speed);
}
return rc;
}
JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configTimeouts(JNIEnv *env, jobject obj, jlong serialPortFD)