update io.serial structs
parent
5d3452b3cf
commit
6c400b44f3
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.syntax kernel sequences system ;
|
USING: alien.syntax classes.struct kernel sequences system ;
|
||||||
IN: io.serial.unix.termios
|
IN: io.serial.unix.termios
|
||||||
|
|
||||||
CONSTANT: NCCS 20
|
CONSTANT: NCCS 20
|
||||||
|
@ -9,11 +9,11 @@ TYPEDEF: uint tcflag_t
|
||||||
TYPEDEF: uchar cc_t
|
TYPEDEF: uchar cc_t
|
||||||
TYPEDEF: uint speed_t
|
TYPEDEF: uint speed_t
|
||||||
|
|
||||||
C-STRUCT: termios
|
STRUCT: termios
|
||||||
{ "tcflag_t" "iflag" } ! input mode flags
|
{ iflag tcflag_t }
|
||||||
{ "tcflag_t" "oflag" } ! output mode flags
|
{ oflag tcflag_t }
|
||||||
{ "tcflag_t" "cflag" } ! control mode flags
|
{ cflag tcflag_t }
|
||||||
{ "tcflag_t" "lflag" } ! local mode flags
|
{ lflag tcflag_t }
|
||||||
{ { "cc_t" NCCS } "cc" } ! control characters
|
{ cc { cc_t NCCS } }
|
||||||
{ "speed_t" "ispeed" } ! input speed
|
{ ispeed speed_t }
|
||||||
{ "speed_t" "ospeed" } ; ! output speed
|
{ ospeed speed_t } ;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.syntax kernel system unix ;
|
USING: alien.syntax classes.struct kernel system unix ;
|
||||||
IN: io.serial.unix.termios
|
IN: io.serial.unix.termios
|
||||||
|
|
||||||
CONSTANT: NCCS 32
|
CONSTANT: NCCS 32
|
||||||
|
@ -9,12 +9,12 @@ TYPEDEF: uchar cc_t
|
||||||
TYPEDEF: uint speed_t
|
TYPEDEF: uint speed_t
|
||||||
TYPEDEF: uint tcflag_t
|
TYPEDEF: uint tcflag_t
|
||||||
|
|
||||||
C-STRUCT: termios
|
STRUCT: termios
|
||||||
{ "tcflag_t" "iflag" } ! input mode flags
|
{ iflag tcflag_t }
|
||||||
{ "tcflag_t" "oflag" } ! output mode flags
|
{ oflag tcflag_t }
|
||||||
{ "tcflag_t" "cflag" } ! control mode flags
|
{ cflag tcflag_t }
|
||||||
{ "tcflag_t" "lflag" } ! local mode flags
|
{ lflag tcflag_t }
|
||||||
{ "cc_t" "line" } ! line discipline
|
{ line cc_t }
|
||||||
{ { "cc_t" NCCS } "cc" } ! control characters
|
{ cc { cc_t NCCS } }
|
||||||
{ "speed_t" "ispeed" } ! input speed
|
{ ispeed speed_t }
|
||||||
{ "speed_t" "ospeed" } ; ! output speed
|
{ ospeed speed_t } ;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types alien.syntax alien.data
|
USING: accessors alien.c-types alien.syntax alien.data
|
||||||
combinators io.ports io.streams.duplex system kernel
|
classes.struct combinators io.ports io.streams.duplex
|
||||||
math math.bitwise vocabs.loader unix io.serial
|
system kernel math math.bitwise vocabs.loader unix io.serial
|
||||||
io.serial.unix.termios io.backend.unix ;
|
io.serial.unix.termios io.backend.unix ;
|
||||||
IN: io.serial.unix
|
IN: io.serial.unix
|
||||||
|
|
||||||
|
@ -41,19 +41,19 @@ M: unix open-serial ( serial -- serial' )
|
||||||
|
|
||||||
: get-termios ( serial -- termios )
|
: get-termios ( serial -- termios )
|
||||||
serial-fd
|
serial-fd
|
||||||
"termios" <c-object> [ tcgetattr io-error ] keep ;
|
termios <struct> [ tcgetattr io-error ] keep ;
|
||||||
|
|
||||||
: configure-termios ( serial -- )
|
: configure-termios ( serial -- )
|
||||||
dup termios>>
|
dup termios>>
|
||||||
{
|
{
|
||||||
[ [ iflag>> ] dip over [ set-termios-iflag ] [ 2drop ] if ]
|
[ [ iflag>> ] dip over [ (>>iflag) ] [ 2drop ] if ]
|
||||||
[ [ oflag>> ] dip over [ set-termios-oflag ] [ 2drop ] if ]
|
[ [ oflag>> ] dip over [ (>>oflag) ] [ 2drop ] if ]
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
[ cflag>> 0 or ] [ baud>> lookup-baud ] bi bitor
|
[ cflag>> 0 or ] [ baud>> lookup-baud ] bi bitor
|
||||||
] dip set-termios-cflag
|
] dip (>>cflag)
|
||||||
]
|
]
|
||||||
[ [ lflag>> ] dip over [ set-termios-lflag ] [ 2drop ] if ]
|
[ [ lflag>> ] dip over [ (>>lflag) ] [ 2drop ] if ]
|
||||||
} 2cleave ;
|
} 2cleave ;
|
||||||
|
|
||||||
: tciflush ( serial -- )
|
: tciflush ( serial -- )
|
||||||
|
|
Loading…
Reference in New Issue