PageRenderTime 28ms CodeModel.GetById 20ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/abeaumont/factor
text | 25 lines | 23 code | 2 blank | 0 comment | 0 complexity | 90767339a29cb6d097e764fa457079d7 MD5 | raw file
 1! Copyright (C) 2008 Doug Coleman.
 2! See http://factorcode.org/license.txt for BSD license.
 3USING: accessors kernel math.bitwise io.serial io.serial.unix
 4literals ;
 5IN: io.serial.unix
 6
 7: serial-obj ( -- obj )
 8    serial new
 9    "/dev/ttyS0" >>path ! linux
10    ! "/dev/dty00" >>path ! netbsd
11    ! "/dev/ttyd0" >>path ! freebsd
12    ! "/dev/ttyU0" >>path ! openbsd
13    19200 >>baud
14    flags{ IGNPAR ICRNL } >>iflag
15    flags{ } >>oflag
16    flags{ CS8 CLOCAL CREAD } >>cflag
17    flags{ ICANON } >>lflag ;
18
19: serial-test ( -- serial )
20    serial-obj
21    open-serial
22    dup get-termios >>termios
23    dup configure-termios
24    dup tciflush
25    dup apply-termios ;