From 9313a009c8e6be3c024bc779e6e8d8b8ece5e751 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20F=C3=A4lt?= <faldt.mattias@gmail.com>
Date: Mon, 28 Aug 2017 21:31:00 +0200
Subject: [PATCH] Working version

---
 src/Computer/10V.jl          | 12 ++++++------
 src/Computer/ComediStream.jl |  9 ++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/Computer/10V.jl b/src/Computer/10V.jl
index facf505..4c84a49 100644
--- a/src/Computer/10V.jl
+++ b/src/Computer/10V.jl
@@ -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
diff --git a/src/Computer/ComediStream.jl b/src/Computer/ComediStream.jl
index a89fab3..59a570d 100644
--- a/src/Computer/ComediStream.jl
+++ b/src/Computer/ComediStream.jl
@@ -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
-- 
GitLab