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

http://github.com/abeaumont/factor · Factor · 25 lines · 18 code · 2 blank · 5 comment · 0 complexity · 90767339a29cb6d097e764fa457079d7 MD5 · raw file

  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. literals ;
  5. IN: io.serial.unix
  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. flags{ IGNPAR ICRNL } >>iflag
  14. flags{ } >>oflag
  15. flags{ CS8 CLOCAL CREAD } >>cflag
  16. flags{ ICANON } >>lflag ;
  17. : serial-test ( -- serial )
  18. serial-obj
  19. open-serial
  20. dup get-termios >>termios
  21. dup configure-termios
  22. dup tciflush
  23. dup apply-termios ;