Commit 9313a009 authored by Mattias Fält's avatar Mattias Fält

Working version

parent c324aa20
......@@ -17,13 +17,13 @@ initialize(::AnalogInput10V) = nothing
initialize(::AnalogOutput10V) = nothing
close(::AnalogInput10V) = nothing
close(input::AnalogOutput10V) = ccall(:comedi_write_zero, comedipath, Void, (Int32, Int32, Int32), 0, 1, input.i)
close(input::AnalogOutput10V) = ccall((:comedi_write_zero, comedipath), Void, (Int32, Int32, Int32), Int32(0), Int32(1), input.i)
getwritecommand(stream::LabStream, input::AnalogIntput10V, val) = error("Can't write to device $input")
getwritecommand(stream::LabStream, input::AnalogInput10V, val) = error("Can't write to device $input")
getreadcommand(stream::LabStream, output::AnalogOutput10V, val) = error("Can't read from device $output")
function getwritecommand(stream::BeagleBoneStream, input::AnalogOutput10V, val::Float64)
abs(val) < 10 || error("Volatage $val not in range [-10,10]")
abs(val) <= 10 || error("Volatage $val not in range [-10,10]")
return ("analogin10", input.i, val)
end
function getreadcommand(stream::BeagleBoneStream, input::AnalogInput10V)
......@@ -31,9 +31,9 @@ function getreadcommand(stream::BeagleBoneStream, input::AnalogInput10V)
end
function getwritecommand(stream::ComediStream, input::AnalogOutput10V, val::Float64)
abs(val) < 10 || error("Volatage $val not in range [-10,10]")
return (0,1,input.i,val)
abs(val) <= 10 || error("Volatage $val not in range [-10,10]")
return (Int32(0),Int32(1),input.i,val)
end
function getreadcommand(stream::ComediStream, input::AnalogInput10V)
return (0,0,input.i)
return (Int32(0),Int32(0),input.i)
end
......@@ -16,7 +16,7 @@ function ComediStream()
ComediStream(AbstractDevice[], SendTuple[], ReadTuple[])
end
function init_devices!(stream::ComediStream, devs::AbstractDevice...)
function init_devices!(comedistream::ComediStream, devs::AbstractDevice...)
for dev in devs
if dev comedistream.devices
setstream!(dev, comedistream)
......@@ -30,12 +30,11 @@ function init_devices!(stream::ComediStream, devs::AbstractDevice...)
end
function send(comedistream::ComediStream, cmd::SendTuple)
ccall((:comedi_write, comedipath),Int32,(Int32,Int32,Int32,Float64), cmd[1], cmd[2], cmd[3], cmd[4])
ccall((:comedi_write, comedipath), Int32, (Int32,Int32,Int32,Float64), cmd[1], cmd[2], cmd[3], cmd[4])
return
end
function read(comedistream::ComediStream, cmd::ReadTuple)
ccall((:comedi_read, comedipath),Int32,(Int32,Int32,Int32), cmd[1], cmd[2], cmd[3])
return
return ccall((:comedi_read, comedipath), Float64, (Int32,Int32,Int32), cmd[1], cmd[2], cmd[3])
end
function send(comedistream::ComediStream)
......@@ -51,6 +50,6 @@ end
function close(stream::ComediStream)
foreach(close, stream.devices)
ccall((:comedi_stop, comedipath),Int32,(Int32,), 0)
ccall((:comedi_stop, comedipath), Int32, (Int32,), 0)
return
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment