Skip to content
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

Raw mode enable patch? #2

Open
tfc opened this issue Apr 28, 2022 · 0 comments
Open

Raw mode enable patch? #2

tfc opened this issue Apr 28, 2022 · 0 comments

Comments

@tfc
Copy link

tfc commented Apr 28, 2022

Hi @jmct,

in one project, we use a hard fork of this library where we enable "raw mode" (reference to raw mode in man page of termios).

the code basically just differs at the point where setTerminalAttributes is called, like this:

openSerial device baudrate = do
    -- ....
    setTerminalAttributes fd (makeRaw termOpts `withSpeed` baudrate) Immediately
    closeFd fd
    h <- openFile device ReadWriteMode
    hSetBuffering h NoBuffering
    hSetEcho h False
    return h

and where makeRaw is defined like this:

-- | Disables all necessary flags for raw mode according to
--   http://man7.org/linux/man-pages/man3/termios.3.html
makeRaw :: TerminalAttributes -> TerminalAttributes
makeRaw termOpts = termOpts
    -- input flags
    `withoutMode` IgnoreBreak
    `withoutMode` InterruptOnBreak
    `withoutMode` MarkParityErrors
    `withoutMode` StripHighBit
    `withoutMode` MapLFtoCR
    `withoutMode` IgnoreCR
    `withoutMode` MapCRtoLF
    `withoutMode` StartStopOutput
    -- output flags
    `withoutMode` ProcessOutput
    -- local flags
    `withoutMode` EnableEcho
    `withoutMode` EchoLF
    `withoutMode` ProcessInput
    `withoutMode` KeyboardInterrupts
    `withoutMode` ExtendedFunctions
    -- control flags
    `withoutMode` TwoStopBits
    `withBits` 8
    `withoutMode` EnableParity

What do you think about a patch on this lib that adds some kind of openSerialRaw call or adds a parameter to openSerial for raw mode yes/no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant