Skip to content
Snippets Groups Projects
Commit b7076b2a authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Julia debugging cleanup

parent 3613f613
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ mutable struct AnalogIn ...@@ -20,7 +20,7 @@ mutable struct AnalogIn
end end
function close(ain::AnalogIn) function close(ain::AnalogIn)
# println("closing $(ain)") DEBUG && println("closing $(ain)")
checkOK(ccall((:moberg_analog_in_close, "libmoberg"), checkOK(ccall((:moberg_analog_in_close, "libmoberg"),
Status, Status,
(Moberg, Cint, AnalogInChannel), (Moberg, Cint, AnalogInChannel),
......
...@@ -20,7 +20,7 @@ mutable struct AnalogOut ...@@ -20,7 +20,7 @@ mutable struct AnalogOut
end end
function close(aout::AnalogOut) function close(aout::AnalogOut)
# println("closing $(aout)") DEBUG && println("closing $(aout)")
checkOK(ccall((:moberg_analog_out_close, "libmoberg"), checkOK(ccall((:moberg_analog_out_close, "libmoberg"),
Status, Status,
(Moberg, Cint, AnalogOutChannel), (Moberg, Cint, AnalogOutChannel),
......
...@@ -20,7 +20,7 @@ mutable struct DigitalIn ...@@ -20,7 +20,7 @@ mutable struct DigitalIn
end end
function close(din::DigitalIn) function close(din::DigitalIn)
# println("closing $(din)") DEBUG && println("closing $(din)")
checkOK(ccall((:moberg_digital_in_close, "libmoberg"), checkOK(ccall((:moberg_digital_in_close, "libmoberg"),
Status, Status,
(Moberg, Cint, DigitalInChannel), (Moberg, Cint, DigitalInChannel),
......
...@@ -20,7 +20,7 @@ mutable struct DigitalOut ...@@ -20,7 +20,7 @@ mutable struct DigitalOut
end end
function close(dout::DigitalOut) function close(dout::DigitalOut)
# println("closing $(dout)") DEBUG && println("closing $(dout)")
checkOK(ccall((:moberg_digital_out_close, "libmoberg"), checkOK(ccall((:moberg_digital_out_close, "libmoberg"),
Status, Status,
(Moberg, Cint, DigitalOutChannel), (Moberg, Cint, DigitalOutChannel),
......
...@@ -20,7 +20,7 @@ mutable struct EncoderIn ...@@ -20,7 +20,7 @@ mutable struct EncoderIn
end end
function close(ein::EncoderIn) function close(ein::EncoderIn)
# println("closing $(ein)") DEBUG && println("closing $(ein)")
checkOK(ccall((:moberg_encoder_in_close, "libmoberg"), checkOK(ccall((:moberg_encoder_in_close, "libmoberg"),
Status, Status,
(Moberg, Cint, EncoderInChannel), (Moberg, Cint, EncoderInChannel),
......
module MobergIO module MobergIO
const DEBUG = false
struct Status struct Status
result::Clong result::Clong
...@@ -23,6 +24,7 @@ function Moberg() ...@@ -23,6 +24,7 @@ function Moberg()
end end
function close(h::Moberg) function close(h::Moberg)
DEBUG && println("Destroy $(h)")
ccall((:moberg_free, "libmoberg"), Nothing, (Moberg,), h) ccall((:moberg_free, "libmoberg"), Nothing, (Moberg,), h)
end end
......
...@@ -7,7 +7,7 @@ import MobergIO: read, write ...@@ -7,7 +7,7 @@ import MobergIO: read, write
function test() function test()
m = MobergIO.Moberg() m = MobergIO.Moberg()
println(m) println(stderr,m)
for v in -10.0:2.0:10 for v in -10.0:2.0:10
for i in 0:1 for i in 0:1
...@@ -17,21 +17,23 @@ function test() ...@@ -17,21 +17,23 @@ function test()
write(aout, value) write(aout, value)
print("$value ") print("$value ")
catch ex catch ex
println("analog_out $i does not exist $(ex)") println(stderr,"analog_out $i does not exist $(ex)")
end end
end end
println() println(stderr)
flush(stderr)
sleep(0.01) sleep(0.01)
for j in 0:3 for j in 0:3
try try
ain = MobergIO.AnalogIn(m, Unsigned(j)) ain = MobergIO.AnalogIn(m, Unsigned(j))
println(read(ain)) println(stderr,read(ain))
catch ex catch ex
println("analog_in $j does not exist $(ex)") println(stderr,"analog_in $j does not exist $(ex)")
end end
flush(stderr)
end end
println() println(stderr)
# GC.gc() flush(stderr)
end end
for v in false:true for v in false:true
for i in 0:6 for i in 0:6
...@@ -41,27 +43,34 @@ function test() ...@@ -41,27 +43,34 @@ function test()
write(dout, value) write(dout, value)
print("$value ") print("$value ")
catch ex catch ex
println("digital_out $i does not exist $(ex)") println(stderr,"digital_out $i does not exist $(ex)")
end end
flush(stderr)
end end
println() println(stderr)
flush(stderr)
for i in 0:6 for i in 0:6
try try
din = MobergIO.DigitalIn(m, Unsigned(i)) din = MobergIO.DigitalIn(m, Unsigned(i))
print("$(read(din)) ") print("$(read(din)) ")
catch ex catch ex
println("digital_out $i does not exist $(ex)") println(stderr,"digital_in $i does not exist $(ex)")
end end
flush(stderr)
end end
println() println(stderr)
println() println(stderr)
sleep(0.01) sleep(0.01)
end end
end end
test() test()
println("DONE") println(stderr,"DONE")
flush(stderr)
GC.gc() GC.gc()
println(stderr,"....")
flush(stderr)
GC.gc() # See https://github.com/JuliaCI/BenchmarkTools.jl/blob/af35d0513fe1e336ad0d8b9a35f924e8461aefa2/src/execution.jl#L1 GC.gc() # See https://github.com/JuliaCI/BenchmarkTools.jl/blob/af35d0513fe1e336ad0d8b9a35f924e8461aefa2/src/execution.jl#L1
println("Really DONE") println(stderr,"Really DONE")
flush(stderr)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment