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