From 6c400b44f3ee56b0ad76382a8ca2afc3d8719e25 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 19 Sep 2009 21:10:53 -0500 Subject: [PATCH] update io.serial structs --- extra/io/serial/unix/termios/bsd/bsd.factor | 18 ++++++++--------- .../io/serial/unix/termios/linux/linux.factor | 20 +++++++++---------- extra/io/serial/unix/unix.factor | 14 ++++++------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/extra/io/serial/unix/termios/bsd/bsd.factor b/extra/io/serial/unix/termios/bsd/bsd.factor index 63d0157780..1d1e217ba0 100644 --- a/extra/io/serial/unix/termios/bsd/bsd.factor +++ b/extra/io/serial/unix/termios/bsd/bsd.factor @@ -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 } ; diff --git a/extra/io/serial/unix/termios/linux/linux.factor b/extra/io/serial/unix/termios/linux/linux.factor index 4b8c52c7fb..0982339cf8 100644 --- a/extra/io/serial/unix/termios/linux/linux.factor +++ b/extra/io/serial/unix/termios/linux/linux.factor @@ -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 } ; diff --git a/extra/io/serial/unix/unix.factor b/extra/io/serial/unix/unix.factor index 57c30dde15..8ee115ca45 100644 --- a/extra/io/serial/unix/unix.factor +++ b/extra/io/serial/unix/unix.factor @@ -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" [ tcgetattr io-error ] keep ; + termios [ 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 -- )