test.icl 630 Bytes
Newer Older
1 2 3 4 5 6
module test

import StdEnv

import TTY

Mart Lubbers's avatar
Mart Lubbers committed
7 8 9 10 11 12 13 14
TTYerrorclose :: !*File !*World -> *World
TTYerrorclose f w
# (err, w) = TTYerror w
# (ok, w) = fclose (f <<< err <<< "\n") w
| not ok = abort "Couldn't close file"
= w

Start :: *World -> *World
15
Start w
Mart Lubbers's avatar
Mart Lubbers committed
16
# (io, w) = stdio w
Mart Lubbers's avatar
Mart Lubbers committed
17
# (ok, tty, w) = TTYopen {zero & devicePath="/dev/ttyUSB0"} w
Mart Lubbers's avatar
Mart Lubbers committed
18
| not ok = TTYerrorclose io w
Mart Lubbers's avatar
Mart Lubbers committed
19
#! tty = TTYwrite "echo123\n" tty
20
#! (av, e, tty) = TTYavailable tty
Mart Lubbers's avatar
Mart Lubbers committed
21 22 23
# io = io <<< ("Bytes available: " +++ toString av +++ "\n")
#! (l, tty) = TTYreadline tty
# io = io <<< ("Line read: " +++ l)
24
#! (ok, w) = TTYclose tty w
Mart Lubbers's avatar
Mart Lubbers committed
25 26
| not ok = TTYerrorclose io w
= snd (fclose io w)