Skip to content

Raw mode enable patch? #2

@tfc

Description

@tfc

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions