Skip to content

Support other baud rates #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 4 additions & 1 deletion System/Posix/Terminal/Common.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module System.Posix.Terminal.Common (

import Data.Bits
import Data.Char
import Data.Word
import Foreign.C.Error ( throwErrnoIfMinus1, throwErrnoIfMinus1_ )
import Foreign.C.Types
import Foreign.ForeignPtr ( ForeignPtr, withForeignPtr, mallocForeignPtrBytes )
Expand Down Expand Up @@ -329,6 +330,7 @@ data BaudRate
| B38400
| B57600
| B115200
| BOther Word64

inputSpeed :: TerminalAttributes -> BaudRate
inputSpeed termios = unsafePerformIO $ do
Expand Down Expand Up @@ -550,6 +552,7 @@ baud2Word B115200 = (#const B115200)
#else
baud2Word B115200 = error "B115200 not available on this system"
#endif
baud2Word (BOther x) = CSpeed x

-- And convert a word back to a baud rate
-- We really need some cpp macros here.
Expand Down Expand Up @@ -578,7 +581,7 @@ word2Baud x =
#ifdef B115200
else if x == (#const B115200) then B115200
#endif
else error "unknown baud rate"
else case x of CSpeed y -> BOther y

-- Clear termios i_flag

Expand Down