factor/extra/io/serial/unix/unix-tests.factor

26 lines
660 B
Factor
Raw Normal View History

2008-08-13 16:18:50 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel math.bitwise io.serial io.serial.unix
literals ;
2009-02-22 18:50:29 -05:00
IN: io.serial.unix
2008-08-13 16:18:50 -04:00
: serial-obj ( -- obj )
serial new
"/dev/ttyS0" >>path ! linux
! "/dev/dty00" >>path ! netbsd
! "/dev/ttyd0" >>path ! freebsd
! "/dev/ttyU0" >>path ! openbsd
2008-08-13 16:18:50 -04:00
19200 >>baud
flags{ IGNPAR ICRNL } >>iflag
flags{ } >>oflag
flags{ CS8 CLOCAL CREAD } >>cflag
flags{ ICANON } >>lflag ;
2008-08-13 16:18:50 -04:00
: serial-test ( -- serial )
serial-obj
open-serial
dup get-termios >>termios
dup configure-termios
dup tciflush
dup apply-termios ;