test_moberg.jl 1.5 KB
Newer Older
Anders Blomdell's avatar
Anders Blomdell committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/julia

push!(LOAD_PATH, ".")

using MobergIO
import MobergIO: read, write

function test()
    m = MobergIO.Moberg()
    println(m)
    
    for v in -10.0:2.0:10 
        for i in 30:31
            try
                aout = MobergIO.AnalogOut(m, Unsigned(i))
                value = v + i - 32;
                write(aout, value)
                print("$value ")
            catch ex
                println("analog_out $i does not exist $(ex)")
            end
        end
        println()
        sleep(0.01)
        for j in 30:33
            try
                ain = MobergIO.AnalogIn(m, Unsigned(j))
                println(read(ain))
            catch ex
                println("analog_in $j does not exist $(ex)")
            end
        end
        println()
#        GC.gc()
    end
    for v in false:true
        for i in 30:36
            try
                dout = MobergIO.DigitalOut(m, Unsigned(i))
                value = xor(v, isodd(i))
                write(dout, value)
                print("$value ")
            catch ex
                println("digital_out $i does not exist $(ex)")
            end
        end
        println()
        for i in 30:36
            try
                din = MobergIO.DigitalIn(m, Unsigned(i))
                print("$(read(din)) ")
            catch ex
                println("digital_out $i does not exist $(ex)")
            end
        end
        println()
        println()
        sleep(0.01)
    end
end

test()

println("DONE")
GC.gc()
println("Really DONE")