2009-01-13 20:01:01 -05:00
|
|
|
! Copyright (C) 2009 Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: io.files.windows io.streams.duplex kernel math
|
2010-02-20 23:42:40 -05:00
|
|
|
math.bitwise windows windows.kernel32 windows.errors accessors
|
|
|
|
alien.c-types fry locals continuations classes.struct ;
|
2009-02-22 18:50:29 -05:00
|
|
|
IN: io.serial.windows
|
2009-01-13 20:01:01 -05:00
|
|
|
|
|
|
|
: <serial-stream> ( path encoding -- duplex )
|
|
|
|
[ open-r/w dup ] dip <encoder-duplex> ;
|
|
|
|
|
|
|
|
: get-comm-state ( duplex -- dcb )
|
|
|
|
in>> handle>>
|
2009-11-05 23:22:21 -05:00
|
|
|
DCB <struct> [ GetCommState win32-error=0/f ] keep ;
|
2009-01-13 20:01:01 -05:00
|
|
|
|
|
|
|
: set-comm-state ( duplex dcb -- )
|
|
|
|
[ in>> handle>> ] dip
|
|
|
|
SetCommState win32-error=0/f ;
|
|
|
|
|
|
|
|
:: with-comm-state ( duplex quot: ( dcb -- ) -- )
|
|
|
|
duplex get-comm-state :> dcb
|
|
|
|
dcb clone quot curry [ dcb set-comm-state ] recover ; inline
|