1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io.files.windows io.streams.duplex kernel math
4 math.bitwise windows.kernel32 accessors alien.c-types
5 windows io.files.windows fry locals continuations ;
8 : <serial-stream> ( path encoding -- duplex )
9 [ open-r/w dup ] dip <encoder-duplex> ;
11 : get-comm-state ( duplex -- dcb )
14 GetCommState win32-error=0/f ;
16 : set-comm-state ( duplex dcb -- )
18 SetCommState win32-error=0/f ;
20 :: with-comm-state ( duplex quot: ( dcb -- ) -- )
21 duplex get-comm-state :> dcb
22 dcb clone quot curry [ dcb set-comm-state ] recover ; inline