diff --git a/sub/src/MobergIOSub.jl b/sub/src/MobergIOSub.jl new file mode 100644 index 0000000000000000000000000000000000000000..7c917b8ffae880a03daf27da0c70282fe91f3fe2 --- /dev/null +++ b/sub/src/MobergIOSub.jl @@ -0,0 +1,38 @@ +module MobergIO + +const DEBUG = false + +struct Status + result::Clong +end + +function checkOK(status::Status) + if status.result != 0 + error("Moberg call failed with errno $(status.result)") + end +end + +mutable struct Moberg + handle::Ptr{Nothing} +end + +function Moberg() + handle = ccall((:moberg_new, "libmoberg"), Ptr{Moberg}, ()) + m = Moberg(handle) + finalizer(close, m) + m +end + +function close(h::Moberg) + DEBUG && println("Destroy $(h)") + ccall((:moberg_free, "libmoberg"), Nothing, (Moberg,), h) + h.handle = Ptr{Nothing}(0) +end + +include("AnalogIn.jl") +include("AnalogOut.jl") +include("DigitalIn.jl") +include("DigitalOut.jl") +include("EncoderIn.jl") + +end