Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion floppybridge/SerialIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,18 @@ SerialIO::Response SerialIO::configurePort(const Configuration& configuration) {
term.c_ospeed = configuration.baudRate;
if (ioctl(m_portHandle, TCSETS2, &term) < 0) return Response::rUnknownError;
#else
// Passing raw numeric baud rates to cfsetspeed() is non-portable across
// libc implementations and glibc ABIs. Use Linux's B2000000 explicitly.
if (baud == 2000000) {
#ifdef B2000000
baud = B2000000;
#else
return Response::rUnknownError;
#endif
}
term.c_cflag &= ~CBAUD;
term.c_cflag |= CBAUDEX;
if (cfsetspeed(&term, baud) < 0) return Response::rUnknownError;
if (cfsetspeed(&term, static_cast<speed_t>(baud)) < 0) return Response::rUnknownError;
#endif
}
#endif
Expand Down