]> gitweb.factorcode.org Git - factor.git/blob - extra/io/serial/unix/unix-tests.factor
f4c0c6b45a4cbc91ce9862867c11dc20291c4b2b
[factor.git] / extra / io / serial / unix / unix-tests.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel math.bitwise io.serial io.serial.unix ;
4 IN: io.serial.unix
5
6 : serial-obj ( -- obj )
7     serial new
8     "/dev/ttyS0" >>path ! linux
9     ! "/dev/dty00" >>path ! netbsd
10     ! "/dev/ttyd0" >>path ! freebsd
11     ! "/dev/ttyU0" >>path ! openbsd
12     19200 >>baud
13     { IGNPAR ICRNL } flags >>iflag
14     { } flags >>oflag
15     { CS8 CLOCAL CREAD } flags >>cflag
16     { ICANON } flags >>lflag ;
17
18 : serial-test ( -- serial )
19     serial-obj
20     open-serial
21     dup get-termios >>termios
22     dup configure-termios
23     dup tciflush
24     dup apply-termios ;