diff --git a/src/TERMIOS.jl b/src/TERMIOS.jl index f813097..264c4eb 100644 --- a/src/TERMIOS.jl +++ b/src/TERMIOS.jl @@ -1,3 +1,20 @@ +""" +This package provides an interface to the POSIX calls for tty I/O control. + +For a complete description of these calls, see the [termios(3)](http://man7.org/linux/man-pages/man3/termios.3.html) manual page. + +**Usage** + +Example: + + using TERMIOS + const T = TERMIOS + term_stdin = T.termios() + T.tcgetattr(stdin, term_stdin) + term_stdin.c_iflag |= T.IGNBRK + T.tcsetattr(stdin, T.TCSANOW, term_stdin) + +""" module TERMIOS struct TERMIOSError <: Exception @@ -6,119 +23,279 @@ end Base.showerror(io::IO, e::TERMIOSError) = print(io, "TERMIOSError: $(e.msg)") -const cc_t = Sys.islinux() ? Cuchar : Cvoid -const tcflag_t = Sys.islinux() ? Cuint : Culong -const char = Sys.islinux() ? Cchar : Cchar -const speed_t = Sys.islinux() ? Cuint : Culong - -const VEOF = Sys.islinux() ? 4 : 0 #= End-of-file character ICANON =# -const VEOL = Sys.islinux() ? 11 : 1 #= End-of-line character ICANON =# -const VEOL2 = Sys.islinux() ? 16 : 2 #= Second EOL character ICANON together with IEXTEN =# -const VERASE = Sys.islinux() ? 2 : 3 #= Erase character ICANON =# -const VWERASE = Sys.islinux() ? 14 : 4 #= Word-erase character ICANON together with IEXTEN =# -const VKILL = Sys.islinux() ? 3 : 5 #= Kill-line character ICANON =# -const VREPRINT = Sys.islinux() ? 12 : 6 #= Reprint-line character ICANON together with IEXTEN =# -const VINTR = Sys.islinux() ? 0 : 8 #= Interrupt character ISIG =# -const VQUIT = Sys.islinux() ? 1 : 9 #= Quit character ISIG =# -const VSUSP = Sys.islinux() ? 10 : 10 #= Suspend character ISIG =# -const VDSUSP = Sys.islinux() ? nothing : 11 #= Delayed suspend character ISIG together with IEXTEN =# -const VSTART = Sys.islinux() ? 8 : 12 #= Start (X-ON) character IXON, IXOFF =# -const VSTOP = Sys.islinux() ? 9 : 13 #= Stop (X-OFF) character IXON, IXOFF =# -const VLNEXT = Sys.islinux() ? 15 : 14 #= Literal-next character IEXTEN =# -const VDISCARD = Sys.islinux() ? 13 : 15 #= Discard character IEXTEN =# -const VMIN = Sys.islinux() ? 6 : 16 #= Minimum number of bytes read at once !ICANON =# -const VTIME = Sys.islinux() ? 5 : 17 #= Time-out value (tenths of a second) !ICANON =# -const VSTATUS = Sys.islinux() ? nothing : 18 #= Status character ICANON together with IEXTEN =# -const NCCS = Sys.islinux() ? 32 : 20 - -const VSWTC = Sys.islinux() ? 7 : nothing +const cc_t = Sys.islinux() ? Cuchar : Cvoid +const tcflag_t = Sys.islinux() ? Cuint : Culong +const char = Sys.islinux() ? Cchar : Cchar +const speed_t = Sys.islinux() ? Cuint : Culong + +"""End-of-file character ICANON""" +const VEOF = Sys.islinux() ? 4 : 0 + +"""End-of-line character ICANON""" +const VEOL = Sys.islinux() ? 11 : 1 + +"""Second EOL character ICANON together with IEXTEN """ +const VEOL2 = Sys.islinux() ? 16 : 2 + +"""Erase character ICANON""" +const VERASE = Sys.islinux() ? 2 : 3 + +"""Word-erase character ICANON together with IEXTEN""" +const VWERASE = Sys.islinux() ? 14 : 4 + +"""Kill-line character ICANON""" +const VKILL = Sys.islinux() ? 3 : 5 + +"""Reprint-line character ICANON together with IEXTEN""" +const VREPRINT = Sys.islinux() ? 12 : 6 + +"""Interrupt character ISIG""" +const VINTR = Sys.islinux() ? 0 : 8 + +"""Quit character ISIG""" +const VQUIT = Sys.islinux() ? 1 : 9 + +"""Suspend character ISIG""" +const VSUSP = Sys.islinux() ? 10 : 10 + +"""Delayed suspend character ISIG together with IEXTEN""" +const VDSUSP = Sys.islinux() ? nothing : 11 + +"""Start (X-ON) character IXON, IXOFF""" +const VSTART = Sys.islinux() ? 8 : 12 + +"""Stop (X-OFF) character IXON, IXOFF""" +const VSTOP = Sys.islinux() ? 9 : 13 + +"""Literal-next character IEXTEN""" +const VLNEXT = Sys.islinux() ? 15 : 14 + +"""Discard character IEXTEN""" +const VDISCARD = Sys.islinux() ? 13 : 15 + +"""Minimum number of bytes read at once !ICANON""" +const VMIN = Sys.islinux() ? 6 : 16 + +"""Time-out value (tenths of a second) !ICANON""" +const VTIME = Sys.islinux() ? 5 : 17 + +"""Status character ICANON together with IEXTEN""" +const VSTATUS = Sys.islinux() ? nothing : 18 + +const NCCS = Sys.islinux() ? 32 : 20 + +const VSWTC = Sys.islinux() ? 7 : nothing # # Input flags - software input processing # -const IGNBRK = 0x00000001 #= ignore BREAK condition =# -const BRKINT = 0x00000002 #= map BREAK to SIGINTR =# -const IGNPAR = 0x00000004 #= ignore (discard) parity errors =# -const PARMRK = 0x00000008 #= mark parity and framing errors =# -const INPCK = 0x00000010 #= enable checking of parity errors =# -const ISTRIP = 0x00000020 #= strip 8th bit off chars =# -const INLCR = 0x00000040 #= map NL into CR =# -const IGNCR = 0x00000080 #= ignore CR =# -const ICRNL = 0x00000100 #= map CR to NL (ala CRMOD) =# -const IXON = Sys.islinux() ? 0x00000400 : 0x00000200 #= enable output flow control =# -const IXOFF = Sys.islinux() ? 0x00001000 : 0x00000400 #= enable input flow control =# -const IXANY = 0x00000800 #= any char will restart after stop =# -const IMAXBEL = Sys.islinux() ? nothing : 0x00002000 #= ring bell on input queue full =# -const IUTF8 = Sys.islinux() ? nothing : 0x00004000 #= (macos) maintain state for UTF-8 VERASE =# -const IUCLC = Sys.islinux() ? (1 << 14) : nothing #= (glibc) Translate upper case input to lower case. =# +"""Ignore BREAK condition""" +const IGNBRK = 0x00000001 + +"""Map BREAK to SIGINTR""" +const BRKINT = 0x00000002 + +"""Ignore (discard) parity errors""" +const IGNPAR = 0x00000004 + +"""Mark parity and framing errors""" +const PARMRK = 0x00000008 + +"""Enable checking of parity errors""" +const INPCK = 0x00000010 + +"""Strip 8th bit off chars""" +const ISTRIP = 0x00000020 + +"""Map NL into CR""" +const INLCR = 0x00000040 + +"""Ignore CR""" +const IGNCR = 0x00000080 + +"""Map CR to NL (ala CRMOD)""" +const ICRNL = 0x00000100 + +"""Enable output flow control""" +const IXON = Sys.islinux() ? 0x00000400 : 0x00000200 + +"""Enable input flow control""" +const IXOFF = Sys.islinux() ? 0x00001000 : 0x00000400 + +"""Any char will restart after stop""" +const IXANY = 0x00000800 + +"""Ring bell on input queue full""" +const IMAXBEL = Sys.islinux() ? nothing : 0x00002000 + +"""(macos) maintain state for UTF-8 VERASE""" +const IUTF8 = Sys.islinux() ? nothing : 0x00004000 + +"""(glibc) Translate upper case input to lower case.""" +const IUCLC = Sys.islinux() ? (1 << 14) : nothing # # Output flags - software output processing # -const OPOST = 0x00000001 #= enable following output processing =# -const ONLCR = Sys.islinux() ? 0x00000004 : 0x00000002 #= map NL to CR-NL (ala CRMOD) =# -const OXTABS = 0x00000004 #= expand tabs to spaces =# -const ONOEOT = 0x00000008 #= discard EOT's (^D) on output) =# - -const OCRNL = Sys.islinux() ? 0x00000008 : 0x00000010 #= map CR to NL on output =# -const ONOCR = Sys.islinux() ? 0x00000010 : 0x00000020 #= no CR output at column 0 =# -const ONLRET = Sys.islinux() ? 0x00000020 : 0x00000040 #= NL performs CR function =# -const NLDLY = Sys.islinux() ? 0x00000100 : 0x00000300 #= \n delay =# -const TABDLY = Sys.islinux() ? 0x00001800 : 0x00000c04 #= horizontal tab delay =# -const CRDLY = Sys.islinux() ? 0x00000600 : 0x00003000 #= \r delay =# -const FFDLY = Sys.islinux() ? 0x00008000 : 0x00004000 #= form feed delay =# -const BSDLY = Sys.islinux() ? 0x00002000 : 0x00008000 #= \b delay =# -const VTDLY = Sys.islinux() ? 0x00004000 : 0x00010000 #= vertical tab delay =# - -const NL0 = 0x00000000 #= NL type 0. =# -const NL1 = 0x00000100 #= NL type 1. =# -const NL2 = Sys.islinux() ? nothing : 0x00000200 -const NL3 = Sys.islinux() ? nothing : 0x00000300 -const TAB0 = 0x00000000 #= TAB delay type 0. =# -const TAB1 = Sys.islinux() ? 0x00000800 : 0x00000400 #= TAB delay type 1. =# -const TAB2 = Sys.islinux() ? 0x00001000 : 0x00000800 #= TAB delay type 2. =# -const TAB3 = Sys.islinux() ? 0x00001800 : 0x00000004 #= Expand tabs to spaces. =# -const CR0 = 0x00000000 #= CR delay type 0. =# -const CR1 = Sys.islinux() ? 0x00000200 : 0x00001000 #= CR delay type 1. =# -const CR2 = Sys.islinux() ? 0x00000400 : 0x00002000 #= CR delay type 2. =# -const CR3 = Sys.islinux() ? 0x00000600 : 0x00003000 #= CR delay type 3. =# -const FF0 = 0x00000000 #= FF delay type 0. =# -const FF1 = Sys.islinux() ? 0x00008000 : 0x00004000 #= FF delay type 1. =# -const BS0 = 0x00000000 #= BS delay type 0. =# -const BS1 = Sys.islinux() ? 0x00002000 : 0x00008000 #= BS delay type 0. =# -const VT0 = 0x00000000 #= VT delay type 0. =# -const VT1 = Sys.islinux() ? 0x00004000 : 0x00010000 #= VT delay type 0. =# - -const OLCUC = Sys.islinux() ? (1 << 17) : nothing #= (glibc) Translate lower case output to upper case. =# - -const OFILL = Sys.islinux() ? 0x00000040 : 0x00000080 #= use fill characters for delay =# -const OFDEL = Sys.islinux() ? nothing : 0x00020000 #= fill is DEL, else NUL =# +"""Enable following output processing """ +const OPOST = 0x00000001 + +"""Map NL to CR-NL (ala CRMOD)""" +const ONLCR = Sys.islinux() ? 0x00000004 : 0x00000002 + +"""Expand tabs to spaces""" +const OXTABS = 0x00000004 + +"""Discard EOT's (^D) on output)""" +const ONOEOT = 0x00000008 + +"""Map CR to NL on output""" +const OCRNL = Sys.islinux() ? 0x00000008 : 0x00000010 + +"""No CR output at column 0""" +const ONOCR = Sys.islinux() ? 0x00000010 : 0x00000020 + +"""NL performs CR function""" +const ONLRET = Sys.islinux() ? 0x00000020 : 0x00000040 + +raw"""\n delay""" +const NLDLY = Sys.islinux() ? 0x00000100 : 0x00000300 + +"""Horizontal tab delay""" +const TABDLY = Sys.islinux() ? 0x00001800 : 0x00000c04 + +raw"""\r delay""" +const CRDLY = Sys.islinux() ? 0x00000600 : 0x00003000 + +"""Form feed delay""" +const FFDLY = Sys.islinux() ? 0x00008000 : 0x00004000 + +raw"""\b delay""" +const BSDLY = Sys.islinux() ? 0x00002000 : 0x00008000 + +"""Vertical tab delay""" +const VTDLY = Sys.islinux() ? 0x00004000 : 0x00010000 + +"""NL type 0.""" +const NL0 = 0x00000000 + +"""NL type 1.""" + +const NL1 = 0x00000100 +const NL2 = Sys.islinux() ? nothing : 0x00000200 +const NL3 = Sys.islinux() ? nothing : 0x00000300 + +"""TAB delay type 0.""" +const TAB0 = 0x00000000 + +"""TAB delay type 1.""" +const TAB1 = Sys.islinux() ? 0x00000800 : 0x00000400 + +"""TAB delay type 2.""" +const TAB2 = Sys.islinux() ? 0x00001000 : 0x00000800 + +"""Expand tabs to spaces.""" +const TAB3 = Sys.islinux() ? 0x00001800 : 0x00000004 + +"""CR delay type 0.""" +const CR0 = 0x00000000 + +"""CR delay type 1.""" +const CR1 = Sys.islinux() ? 0x00000200 : 0x00001000 + +"""CR delay type 2.""" +const CR2 = Sys.islinux() ? 0x00000400 : 0x00002000 + +"""CR delay type 3.""" +const CR3 = Sys.islinux() ? 0x00000600 : 0x00003000 + +"""FF delay type 0.""" +const FF0 = 0x00000000 + +"""FF delay type 1.""" +const FF1 = Sys.islinux() ? 0x00008000 : 0x00004000 + +"""BS delay type 0.""" +const BS0 = 0x00000000 + +"""BS delay type 1.""" +const BS1 = Sys.islinux() ? 0x00002000 : 0x00008000 + +"""VT delay type 0.""" +const VT0 = 0x00000000 + +"""VT delay type 1.""" +const VT1 = Sys.islinux() ? 0x00004000 : 0x00010000 + +"""(glibc) Translate lower case output to upper case.""" +const OLCUC = Sys.islinux() ? (1 << 17) : nothing + +"""Use fill characters for delay""" +const OFILL = Sys.islinux() ? 0x00000040 : 0x00000080 + +"""Fill is DEL, else NUL""" +const OFDEL = Sys.islinux() ? nothing : 0x00020000 # # Control flags - hardware control of terminal # -const CIGNORE = Sys.islinux() ? nothing : 0x00000001 #= ignore control flags =# -const CS5 = 0x00000000 #= 5 bits (pseudo) =# -const CS6 = Sys.islinux() ? 0x00000010 : 0x00000100 #= 6 bits =# -const CS7 = Sys.islinux() ? 0x00000020 : 0x00000200 #= 7 bits =# -const CS8 = CS6 | CS7 #= 8 bits =# -const CSIZE = CS5 | CS6 | CS7 | CS8 #= character size mask =# -const CSTOPB = Sys.islinux() ? 0x00000040 : 0x00000400 #= send 2 stop bits =# -const CREAD = Sys.islinux() ? 0x00000080 : 0x00000800 #= enable receiver =# -const PARENB = Sys.islinux() ? 0x00000100 : 0x00001000 #= parity enable =# -const PARODD = Sys.islinux() ? 0x00000200 : 0x00002000 #= odd parity, else even =# -const HUPCL = Sys.islinux() ? 0x00000400 : 0x00004000 #= hang up on last close =# -const CLOCAL = Sys.islinux() ? 0x00000800 : 0x00008000 #= ignore modem status lines =# -const CCTS_OFLOW = Sys.islinux() ? nothing : 0x00010000 #= CTS flow control of output =# -const CRTS_IFLOW = Sys.islinux() ? nothing : 0x00020000 #= RTS flow control of input =# -const CDTR_IFLOW = Sys.islinux() ? nothing : 0x00040000 #= DTR flow control of input =# -const CDSR_OFLOW = Sys.islinux() ? nothing : 0x00080000 #= DSR flow control of output =# -const CCAR_OFLOW = Sys.islinux() ? nothing : 0x00100000 #= DCD flow control of output =# -const MDMBUF = Sys.islinux() ? nothing : 0x00100000 #= old name for CCAR_OFLOW =# -const CRTSCTS = Sys.islinux() ? nothing : (CCTS_OFLOW | CRTS_IFLOW) +"""Ignore control flags""" +const CIGNORE = Sys.islinux() ? nothing : 0x00000001 + +"""5 bits (pseudo)""" +const CS5 = 0x00000000 + +"""6 bits""" +const CS6 = Sys.islinux() ? 0x00000010 : 0x00000100 + +"""7 bits""" +const CS7 = Sys.islinux() ? 0x00000020 : 0x00000200 + +"""8 bits""" +const CS8 = CS6 | CS7 + +"""Character size mask""" +const CSIZE = CS5 | CS6 | CS7 | CS8 + +"""Send 2 stop bits""" +const CSTOPB = Sys.islinux() ? 0x00000040 : 0x00000400 + +"""Enable receiver""" +const CREAD = Sys.islinux() ? 0x00000080 : 0x00000800 + +"""Parity enable""" +const PARENB = Sys.islinux() ? 0x00000100 : 0x00001000 + +"""Odd parity, else even""" +const PARODD = Sys.islinux() ? 0x00000200 : 0x00002000 + +"""Hang up on last close""" +const HUPCL = Sys.islinux() ? 0x00000400 : 0x00004000 + +"""Ignore modem status lines""" +const CLOCAL = Sys.islinux() ? 0x00000800 : 0x00008000 + +"""CTS flow control of output""" +const CCTS_OFLOW = Sys.islinux() ? nothing : 0x00010000 + +"""RTS flow control of input""" +const CRTS_IFLOW = Sys.islinux() ? nothing : 0x00020000 + +"""DTR flow control of input""" +const CDTR_IFLOW = Sys.islinux() ? nothing : 0x00040000 + +"""DSR flow control of output""" +const CDSR_OFLOW = Sys.islinux() ? nothing : 0x00080000 + +"""DCD flow control of output""" +const CCAR_OFLOW = Sys.islinux() ? nothing : 0x00100000 + +"""Old name for CCAR_OFLOW""" +const MDMBUF = Sys.islinux() ? nothing : 0x00100000 +const CRTSCTS = Sys.islinux() ? nothing : (CCTS_OFLOW | CRTS_IFLOW) # # "Local" flags - dumping ground for other state @@ -128,68 +305,107 @@ const CRTSCTS = Sys.islinux() ? nothing : (CCTS_OFLOW | CRTS_IFLOW) # input flag. # -const ECHOKE = Sys.islinux() ? nothing : 0x00000001 #= visual erase for line kill =# -const ECHOE = Sys.islinux() ? 0x00000010 : 0x00000002 #= visually erase chars =# -const ECHOK = Sys.islinux() ? 0x00000020 : 0x00000004 #= echo NL after line kill =# -const ECHO = 0x00000008 #= enable echoing =# -const ECHONL = Sys.islinux() ? 0x00000040 : 0x00000010 #= echo NL even if ECHO is off =# -const ECHOPRT = Sys.islinux() ? nothing : 0x00000020 #= visual erase mode for hardcopy =# -const ECHOCTL = Sys.islinux() ? nothing : 0x00000040 #= echo control chars as ^(Char) =# -const ISIG = Sys.islinux() ? 0x00000001 : 0x00000080 #= enable signals INTR, QUIT, [D]SUSP =# -const ICANON = Sys.islinux() ? 0x00000002 : 0x00000100 #= canonicalize input lines =# -const ALTWERASE = Sys.islinux() ? nothing : 0x00000200 #= use alternate WERASE algorithm =# -const IEXTEN = Sys.islinux() ? 0x00008000 : 0x00000400 #= enable DISCARD and LNEXT =# -const EXTPROC = Sys.islinux() ? nothing : 0x00000800 #= external processing =# -const TOSTOP = Sys.islinux() ? 0x00000100 : 0x00400000 #= stop background jobs from output =# -const FLUSHO = Sys.islinux() ? nothing : 0x00800000 #= output being flushed (state) =# -const NOKERNINFO = Sys.islinux() ? nothing : 0x02000000 #= no kernel output from VSTATUS =# -const PENDIN = Sys.islinux() ? nothing : 0x20000000 #= XXX retype pending input (state) =# -const NOFLSH = Sys.islinux() ? 0x00000080 : 0x80000000 #= don't flush after interrupt =# +"""Visual erase for line kill""" +const ECHOKE = Sys.islinux() ? nothing : 0x00000001 + +"""Visually erase chars""" +const ECHOE = Sys.islinux() ? 0x00000010 : 0x00000002 + +"""Echo NL after line kill""" +const ECHOK = Sys.islinux() ? 0x00000020 : 0x00000004 + +"""Enable echoing""" +const ECHO = 0x00000008 + +"""Echo NL even if ECHO is off""" +const ECHONL = Sys.islinux() ? 0x00000040 : 0x00000010 + +"""Visual erase mode for hardcopy""" +const ECHOPRT = Sys.islinux() ? nothing : 0x00000020 + +"""Echo control chars as ^(Char)""" +const ECHOCTL = Sys.islinux() ? nothing : 0x00000040 + +"""Enable signals INTR, QUIT, [D]SUSP""" +const ISIG = Sys.islinux() ? 0x00000001 : 0x00000080 + +"""Canonicalize input lines""" +const ICANON = Sys.islinux() ? 0x00000002 : 0x00000100 + +"""Use alternate WERASE algorithm""" +const ALTWERASE = Sys.islinux() ? nothing : 0x00000200 + +"""Enable DISCARD and LNEXT""" +const IEXTEN = Sys.islinux() ? 0x00008000 : 0x00000400 + +"""External processing""" +const EXTPROC = Sys.islinux() ? nothing : 0x00000800 + +"""Stop background jobs from output""" +const TOSTOP = Sys.islinux() ? 0x00000100 : 0x00400000 + +"""Output being flushed (state)""" +const FLUSHO = Sys.islinux() ? nothing : 0x00800000 + +"""No kernel output from VSTATUS""" +const NOKERNINFO = Sys.islinux() ? nothing : 0x02000000 + +"""XXX retype pending input (state)""" +const PENDIN = Sys.islinux() ? nothing : 0x20000000 + +"""Don't flush after interrupt""" +const NOFLSH = Sys.islinux() ? 0x00000080 : 0x80000000 # # Commands passed to tcsetattr() for setting the termios structure. # -const TCSANOW = 0 #= make change immediate =# -const TCSADRAIN = 1 #= drain output, then change =# -const TCSAFLUSH = 2 #= drain output, flush input =# +"""Make change immediate""" +const TCSANOW = 0 + +"""Drain output, then change""" +const TCSADRAIN = 1 -const TCSASOFT = Sys.islinux() ? nothing : 0x10 #= flag - don't alter h.w. state =# +"""Drain output, flush input""" +const TCSAFLUSH = 2 + +"""Flag - don't alter h.w. state""" +const TCSASOFT = Sys.islinux() ? nothing : 0x10 # # Standard speeds # -const B0 = Sys.islinux() ? 0 : 0 -const B50 = Sys.islinux() ? 1 : 50 -const B75 = Sys.islinux() ? 2 : 75 -const B110 = Sys.islinux() ? 3 : 110 -const B134 = Sys.islinux() ? 4 : 134 -const B150 = Sys.islinux() ? 5 : 150 -const B200 = Sys.islinux() ? 6 : 200 -const B300 = Sys.islinux() ? 7 : 300 -const B600 = Sys.islinux() ? 8 : 600 -const B1200 = Sys.islinux() ? 9 : 1200 -const B1800 = Sys.islinux() ? 10 : 1800 -const B2400 = Sys.islinux() ? 11 : 2400 -const B4800 = Sys.islinux() ? 12 : 4800 -const B7200 = Sys.islinux() ? 13 : 7200 -const B19200 = Sys.islinux() ? 14 : 19200 -const B38400 = Sys.islinux() ? 15 : 38400 -const B9600 = 9600 -const B14400 = 14400 -const B28800 = 28800 -const B57600 = 57600 -const B76800 = 76800 -const B115200 = 115200 -const B230400 = 230400 -const EXTA = 19200 -const EXTB = 38400 - -const B460800 = 460800 -const B500000 = 500000 -const B576000 = 576000 -const B921600 = 921600 +const B0 = Sys.islinux() ? 0 : 0 +const B50 = Sys.islinux() ? 1 : 50 +const B75 = Sys.islinux() ? 2 : 75 +const B110 = Sys.islinux() ? 3 : 110 +const B134 = Sys.islinux() ? 4 : 134 +const B150 = Sys.islinux() ? 5 : 150 +const B200 = Sys.islinux() ? 6 : 200 +const B300 = Sys.islinux() ? 7 : 300 +const B600 = Sys.islinux() ? 8 : 600 +const B1200 = Sys.islinux() ? 9 : 1200 +const B1800 = Sys.islinux() ? 10 : 1800 +const B2400 = Sys.islinux() ? 11 : 2400 +const B4800 = Sys.islinux() ? 12 : 4800 +const B7200 = Sys.islinux() ? 13 : 7200 +const B19200 = Sys.islinux() ? 14 : 19200 +const B38400 = Sys.islinux() ? 15 : 38400 +const B9600 = 9600 +const B14400 = 14400 +const B28800 = 28800 +const B57600 = 57600 +const B76800 = 76800 +const B115200 = 115200 +const B230400 = 230400 +const EXTA = 19200 +const EXTB = 38400 + +const B460800 = 460800 +const B500000 = 500000 +const B576000 = 576000 +const B921600 = 921600 const B1000000 = 1000000 const B1152000 = 1152000 const B1500000 = 1500000 @@ -202,29 +418,49 @@ const B4000000 = 4000000 # # Values for the QUEUE_SELECTOR argument to `tcflush'. # -const TCIFLUSH = 1 #= Discard data received but not yet read. =# -const TCOFLUSH = 2 #= Discard data written but not yet sent. =# -const TCIOFLUSH = 3 #= Discard all pending data. =# +"""Discard data received but not yet read.""" +const TCIFLUSH = 1 + +"""Discard data written but not yet sent.""" +const TCOFLUSH = 2 + +"""Discard all pending data.""" +const TCIOFLUSH = 3 # # Values for the ACTION argument to `tcflow'. # -const TCOOFF = Sys.islinux() ? 16 : 1 #= Suspend output. =# -const TCOON = Sys.islinux() ? 32 : 2 #= Restart suspended output. =# -const TCIOFF = Sys.islinux() ? 4 : 3 #= Send a STOP character. =# -const TCION = Sys.islinux() ? 8 : 4 #= Send a START character. =# + +"""Suspend output.""" +const TCOOFF = Sys.islinux() ? 16 : 1 + +"""Restart suspended output.""" +const TCOON = Sys.islinux() ? 32 : 2 + +"""Send a STOP character.""" +const TCIOFF = Sys.islinux() ? 4 : 3 + +"""Send a START character.""" +const TCION = Sys.islinux() ? 8 : 4 mutable struct termios - c_iflag::tcflag_t #= input flags =# - c_oflag::tcflag_t #= output flags =# - c_cflag::tcflag_t #= control flags =# - c_lflag::tcflag_t #= local flags =# + """Input flags""" + c_iflag::tcflag_t + """Output flags""" + c_oflag::tcflag_t + """Control flags""" + c_cflag::tcflag_t + """Local flags""" + c_lflag::tcflag_t @static if Sys.islinux() c_line::cc_t end - c_cc::NTuple{NCCS, UInt8} #= control chars =# - c_ispeed::speed_t #= input speed =# - c_ospeed::speed_t #= output speed =# + """Control chars""" + c_cc::NTuple{NCCS, UInt8} + """Input speed""" + c_ispeed::speed_t + """Output speed""" + c_ospeed::speed_t end function termios()