8000 GitHub - fadein/chicken-stty: stty-style interface to termios
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fadein/chicken-stty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[[toc:]]
[[tags: egg]]

== stty

stty-style interface to termios

=== Repository

[[https://github.com/fadein/chicken-stty|https://github.com/fadein/chicken-stty]]


=== Requirements

[[srfi-69]], [[foreigners]]


=== High-level interface

==== stty

<procedure>(stty [port-or-fd] settings ...)</procedure>

Sets the terminal attributes for PORT (defaulting to current-input-port; a
fixnum representing a valid file descriptor is also accepted) according to
the SETTINGS, which should be a list of symbols corresponding to modes in
the stty(1) man page, or one or more symbols wrapped in a (not ...) list.

To enable a character setting, use a list of the setting name
followed by the character (or #f to disable), as in

<enscript highlight=scheme>
     (stty '(erase #\delete))
</enscript>

To set a baudrate, set the '''ispeed''' and '''ospeed''' settings in the
same way, as in

<enscript highlight=scheme>
     (define (set-baudrate! port baudrate)
       (stty port `((ispeed ,baudrate) (ospeed ,baudrate))))

     (let ((S0 (file-open "/dev/ttyS0" (+ open/rdwr open/excl))))
       ;;set baudrate to 9600
       (set-baudrate! S0 9600)
       ;;send some stuff
       (write "HELLO AT 9600" S0)
       (flush-output S0)
       ;;set baudrate to 38400
       (set-baudrate! S0 38400)
       ;;send some stuff
       (write "HELLO AT 38400" S0)
       (flush-output S0))
</enscript>

The following settings are supported:

     clocal cread crtscts cs5 cs6 cs7 cs8 cstopb hup hupcl parenb
     parodd brkint icrnl ignbrk igncr ignpar imaxbel inpck ispeed
     istrip ixany ixoff ixon parmrk tandem ocrnl onlcr onlret onocr
     opost ospeed tab0 tab1 tab2 tab3 tabs crterase crtkill ctlecho
     echo echoctl echoe echoke echonl echoprt icanon iexten isig
     noflsh prterase tostop xcase eof eol eol2 erase intr kill lnext
     quit rprnt start stop susp werase raw sane

==== with-stty

<procedure>(with-stty '(setting ...) thunk)</procedure>

Sets the terminal attributes with STTY, evaluates THUNK, then
restores the original attributes and returns the value from
THUNK.

Example:

<enscript highlight=scheme>
  (define (read-password prompt)
    (display prompt)
    (with-stty '(not echo) read-line))
</enscript>

=== Low-level interface

You shouldn't need to use this.

<procedure>(get-terminal-attributes [port-or-fd])</procedure>
<procedure>(set-terminal-attributes! port-or-fd action attrs)</procedure>

<procedure>(make-term-attrs)</procedure>
<procedure>(free-term-attrs attrs)</procedure>
<procedure>(term-attrs-iflag attrs)</procedure>
<procedure>(term-attrs-oflag attrs)</procedure>
<procedure>(term-attrs-cflag attrs)</procedure>
<procedure>(term-attrs-lflag attrs)</procedure>
<procedure>(term-attrs-cc attrs i)</procedure>
<procedure>(term-attrs-iflag-set! attrs int)</procedure>
<procedure>(term-attrs-oflag-set! attrs int)</procedure>
<procedure>(term-attrs-cflag-set! attrs int)</procedure>
<procedure>(term-attrs-lflag-set! attrs int)</procedure>
<procedure>(term-attrs-cc-set! attrs i char)</procedure>

=== Version history

; 0.7 : A fixnum representing a valid file descriptor is also accepted (thanks, wasamasa!)
; 0.6 : Use posix accessors to access ispeed and ospeed termios members
; 0.5 : Fix bsd/linux commit
; 0.4 : Remove unusable flags, conform to bsd/linux stty (thanks, dieggsy!)
; 0.3 : Ported to CHICKEN 5
; 0.2.2 : Bugfix release

About

stty-style interface to termios

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0