Skip to content

Commit f3174ff

Browse files
authored
fix: custom baudrate for OSX & Linux (#186)
1 parent 9f4de9f commit f3174ff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/serialport_unix.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ void ConnectionOptionsBaton::Execute() {
114114
// If there is a custom baud rate on linux you can do the following trick with B38400
115115
#if defined(__linux__) && defined(ASYNC_SPD_CUST)
116116
if (baudRate == -1) {
117-
int err = linuxSetCustomBaudRate(fd, baudRate);
117+
int err = linuxSetCustomBaudRate(fd, this->baudRate);
118118

119119
if (err == -1) {
120120
snprintf(errorString, sizeof(errorString), "Error: %s || while retrieving termios2 info", strerror(errno));
121121
this->SetError(errorString);
122122
return;
123123
} else if (err == -2) {
124-
snprintf(errorString, sizeof(errorString), "Error: %s || while setting custom baud rate of %d", strerror(errno), baudRate);
124+
snprintf(errorString, sizeof(errorString), "Error: %s || while setting custom baud rate of %d", strerror(errno), this->baudRate);
125125
this->SetError(errorString);
126126
return;
127127
}
@@ -133,7 +133,7 @@ void ConnectionOptionsBaton::Execute() {
133133
// On OS X, starting with Tiger, we can set a custom baud rate with ioctl
134134
#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
135135
if (-1 == baudRate) {
136-
speed_t speed = baudRate;
136+
speed_t speed = this->baudRate;
137137
if (-1 == ioctl(fd, IOSSIOSPEED, &speed)) {
138138
snprintf(errorString, sizeof(errorString), "Error: %s calling ioctl(.., IOSSIOSPEED, %ld )", strerror(errno), speed);
139139
this->SetError(errorString);

0 commit comments

Comments
 (0)