diff --git a/.gitignore b/.gitignore
index db26ae491d365f3623e1d2d05c51acc02b9ee9fe..09f675ff3777a09796bca0bf30305485d5e8b638 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 *.jl.cov
 *.jl.*.cov
 *.jl.mem
-*.sh~
\ No newline at end of file
+*.sh~
+*.jl~
diff --git a/.travis.yml b/.travis.yml
index efdd0c8e683a6a6a5c39ea1c449a7c67a546c82e..8dbaadbfbbdfae1b45a9052b5a98e28d6079de14 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,9 +27,9 @@ git:
 
 ## uncomment the following lines to override the default test script
 #script:
-#  - julia -e 'Pkg.clone(pwd()); Pkg.build("LabConnection"); Pkg.test("LabConnection"; coverage=true)'
+#  - julia -e 'Pkg.clone(pwd()); Pkg.build("LabConnections"); Pkg.test("LabConnections"; coverage=true)'
 after_success:
   # push coverage results to Coveralls
-  - julia -e 'cd(Pkg.dir("LabConnection")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
+  - julia -e 'cd(Pkg.dir("LabConnections")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
   # push coverage results to Codecov
-  - julia -e 'cd(Pkg.dir("LabConnection")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
+  - julia -e 'cd(Pkg.dir("LabConnections")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
diff --git a/Examples/testLED.jl b/Examples/testLED.jl
index ef131791d714a3140ce60a924186ec34b97600df..a1ca59942854ca6c4542387967468c72f4478ef0 100644
--- a/Examples/testLED.jl
+++ b/Examples/testLED.jl
@@ -1,35 +1,44 @@
 #On beaglebone, run:
-# include("LabConnection/src/LabConnection.jl")
-# using LabConnection.BeagleBone
+# include("LabConnections/src/LabConnections.jl")
+# using LabConnections.BeagleBone
 # run_server()
 
-using LabConnection.Computer
+using LabConnections.Computer
 
 stream = BeagleBoneStream(ip"192.168.7.2")
+led1 = SysLED(1)
 led2 = SysLED(2)
 led3 = SysLED(3)
+led4 = SysLED(4)
 
 # Send info to steam about which inputs/otputs to initialize
 # and adds a ref in motor and led to stream
-init_devices!(stream, led2, led3)
+init_devices!(stream, led1, led2, led3, led4)
 ledon = true
-for i = 1:10
-    set!(led2, ledon)
-    set!(led3, !ledon)
-    send!(stream) #Sends all the outputs to the stream in one atomic call
+for i = 1:50
+    set!(led1, ledon)
+    set!(led2, !ledon)
+    set!(led3, ledon)
+    set!(led4, !ledon)
+    send(stream) #Sends all the outputs to the stream in one atomic call
     #read(stream) #Sends request to read, reads all inputs
-    sleep(1)
+    sleep(0.1)
     ledon = !ledon
 end
-for i = 1:10
-    send!(led2, ledon)
-    sleep(0.5)
-    send!(led3, !ledon)
-    #read(stream) #Sends request to read, reads all inputs
-    sleep(0.5)
+for i = 1:40
+    send(led1, ledon)
+    sleep(0.03)
+    send(led2, ledon)
+    sleep(0.03)
+    send(led3, ledon)
+    sleep(0.03)
+    send(led4, ledon)
+    sleep(0.03)
     ledon = !ledon
 end
+set!(led1, false)
 set!(led2, false)
 set!(led3, false)
-send!(stream)
+set!(led4, false)
+send(stream)
 close(stream) #Tells BeagleBone to stop listening and close outputs
diff --git a/LICENSE.md b/LICENSE.md
index b363325eca82b5f6d9f19dd04e0ec99c4df24fc3..c92dfc9e8f8ac6f76aca35d26e13ac3dbddb5e5e 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,4 +1,4 @@
-The LabConnection.jl package is licensed under the MIT "Expat" License:
+The LabConnections.jl package is licensed under the MIT "Expat" License:
 
 > Copyright (c) 2017: Mattias Fält.
 > 
diff --git a/README.md b/README.md
index 13b83086f6bee30fd176a0269884427b7bb90ef0..97e7287eba800b3629d8d2c0810efbd5d8f0b9cb 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-# LabConnection
+# LabConnections
 
-[![Build Status](https://travis-ci.org/mfalt/LabConnection.jl.svg?branch=master)](https://travis-ci.org/mfalt/LabConnection.jl)
+[![Build Status](https://travis-ci.org/mfalt/LabConnections.jl.svg?branch=master)](https://travis-ci.org/mfalt/LabConnections.jl)
 
-[![Coverage Status](https://coveralls.io/repos/mfalt/LabConnection.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/mfalt/LabConnection.jl?branch=master)
+[![Coverage Status](https://coveralls.io/repos/mfalt/LabConnections.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/mfalt/LabConnections.jl?branch=master)
 
-[![codecov.io](http://codecov.io/github/mfalt/LabConnection.jl/coverage.svg?branch=master)](http://codecov.io/github/mfalt/LabConnection.jl?branch=master)
+[![codecov.io](http://codecov.io/github/mfalt/LabConnections.jl/coverage.svg?branch=master)](http://codecov.io/github/mfalt/LabConnections.jl?branch=master)
diff --git a/appveyor.yml b/appveyor.yml
index 5c62a1fff3c52fe86bc19d0133242d1231794b4b..c22350dad0f2875ad325383276856cff5079ba49 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -41,7 +41,7 @@ build_script:
 # Need to convert from shallow to complete for Pkg.clone to work
   - IF EXIST .git\shallow (git fetch --unshallow)
   - C:\projects\julia\bin\julia -e "versioninfo();
-      Pkg.clone(pwd(), \"LabConnection\"); Pkg.build(\"LabConnection\")"
+      Pkg.clone(pwd(), \"LabConnections\"); Pkg.build(\"LabConnections\")"
 
 test_script:
-  - C:\projects\julia\bin\julia -e "Pkg.test(\"LabConnection\")"
+  - C:\projects\julia\bin\julia -e "Pkg.test(\"LabConnections\")"
diff --git a/src/BeagleBone/BeagleBone.jl b/src/BeagleBone/BeagleBone.jl
index 0799a05c3695129fe9e01382dfaf70cc5de04967..e7d2e6e419215234404f056ab0449623f674c61e 100644
--- a/src/BeagleBone/BeagleBone.jl
+++ b/src/BeagleBone/BeagleBone.jl
@@ -1,4 +1,4 @@
-# Devices should define a type `T` with methods:
+# AbstractDevice should define a type `T` with methods:
 # write!(::T, identifier, val)
 # read(::T, identifier)
 
diff --git a/src/BeagleBone/precompile.jl b/src/BeagleBone/precompile.jl
index eb9b76eebe1cd98a81e6c01dc3045b7120f45c5e..bf714ec3fbede44bfe021ca0d9ebda58de76e3af 100644
--- a/src/BeagleBone/precompile.jl
+++ b/src/BeagleBone/precompile.jl
@@ -28,6 +28,8 @@ function precompile_bb()
     write!(gpio, Int32(1), ("value", "1"), debug)
     #read(gpio, ind, args, debug)
 
+#TODO write/read
+
     try getdev("nonexistent")       catch end
     try bbparse("Invalid input")    catch end
     try bbparse(("Invalid input"))  catch end
diff --git a/src/Computer/10V.jl b/src/Computer/10V.jl
new file mode 100644
index 0000000000000000000000000000000000000000..4c84a4914a7a46a053e4e4057da6bd0ea333171a
--- /dev/null
+++ b/src/Computer/10V.jl
@@ -0,0 +1,39 @@
+export AnalogInput10V, AnalogOutput10V
+
+mutable struct AnalogInput10V <: AbstractDevice
+    i::Int32
+    stream::LabStream
+    AnalogInput10V(i::Int32) = new(i)
+end
+mutable struct AnalogOutput10V <: AbstractDevice
+    i::Int32
+    stream::LabStream
+    AnalogOutput10V(i::Int32) = new(i)
+end
+AnalogInput10V(i::Int64) = AnalogInput10V(convert(Int32, i))
+AnalogOutput10V(i::Int64) = AnalogOutput10V(convert(Int32, i))
+
+initialize(::AnalogInput10V) = nothing
+initialize(::AnalogOutput10V) = nothing
+
+close(::AnalogInput10V) = nothing
+close(input::AnalogOutput10V) = ccall((:comedi_write_zero, comedipath), Void, (Int32, Int32, Int32), Int32(0), Int32(1), input.i)
+
+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]")
+    return ("analogin10", input.i, val)
+end
+function getreadcommand(stream::BeagleBoneStream, input::AnalogInput10V)
+    return ("analogin10", input.i, val)
+end
+
+function getwritecommand(stream::ComediStream, input::AnalogOutput10V, val::Float64)
+    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 (Int32(0),Int32(0),input.i)
+end
diff --git a/src/Computer/AbstractDevice.jl b/src/Computer/AbstractDevice.jl
new file mode 100644
index 0000000000000000000000000000000000000000..f4d65c3907517a26fd2ebd5387d0203a67193bf0
--- /dev/null
+++ b/src/Computer/AbstractDevice.jl
@@ -0,0 +1,53 @@
+export initialize, getstream, setstream!, send, set!
+
+###### Defaults for AbstractDevice
+#What to do when connecting
+initialize(::AbstractDevice) = nothing
+#What to do when disconnecting
+close(::AbstractDevice) = nothing
+#Which stream is the AbstractDevice connected to
+getstream(dev::AbstractDevice) = dev.stream
+#Set the stream the AbstractDevice is connected to
+setstream!(dev::AbstractDevice, stream::LabStream) = dev.stream = stream
+
+
+function safe_getwritecommand(dev::AbstractDevice, val)
+    stream = try getstream(dev) catch
+        error("Device $dev not connected to a stream")
+    end
+    cmd = try getwritecommand(stream, dev, val) catch
+        error("Device $dev with output val $val not supported on stream $stream")
+    end
+    return cmd, stream
+end
+function safe_getreadcommand(dev::AbstractDevice)
+    stream = try getstream(dev) catch
+        error("Device $dev not connected to a stream")
+    end
+    cmd = try getreadcommand(stream, dev) catch
+        error("Device $dev not supported  to read from on stream $stream")
+    end
+    return cmd, stream
+end
+
+function send(dev::AbstractDevice, val)
+    cmd, stream = safe_getwritecommand(dev, val)
+    send(stream, cmd)
+    return
+end
+function read(dev::AbstractDevice)
+    cmd, stream = safe_getreadcommand(dev)
+    return read(stream, cmd)
+end
+
+function set!(dev::AbstractDevice, val)
+    cmd, stream = safe_getwritecommand(dev, val)
+    push!(stream.sendbuffer,cmd)
+    return
+end
+
+function get(dev::AbstractDevice, val)
+    cmd, stream = safe_getreadcommand(dev, val)
+    push!(stream.readbuffer,cmd)
+    return
+end
diff --git a/src/Computer/BeagleBoneStream.jl b/src/Computer/BeagleBoneStream.jl
index 557da8f5feedf00fcd8c48ad1d844c573bc01205..ee9253d020075872e47ff79dc10d190209b6f571 100644
--- a/src/Computer/BeagleBoneStream.jl
+++ b/src/Computer/BeagleBoneStream.jl
@@ -1,19 +1,21 @@
-export BeagleBoneStream, init_devices!, send!
+export BeagleBoneStream, init_devices!
 
 struct BeagleBoneStream <: LabStream
-    devices::Array{Device,1}
+    devices::Array{AbstractDevice,1}
+    sendbuffer::Array{Tuple,1}
+    readbuffer::Array{Tuple,1}
     stream::TCPSocket
 end
 
 function BeagleBoneStream(addr::IPAddr, port::Int64=2001)
     clientside = connect(addr, port)
-    BeagleBoneStream(Device[], clientside)
+    BeagleBoneStream(AbstractDevice[], Tuple[], Tuple[], clientside)
 end
 
 #For BeagleBoneStream we can directly serialize the data, other streams might want to send binary data
 serialize(bbstream::BeagleBoneStream, cmd) = serialize(bbstream.stream, cmd)
 
-function init_devices!(bbstream::BeagleBoneStream, devs::Device...)
+function init_devices!(bbstream::BeagleBoneStream, devs::AbstractDevice...)
     for dev in devs
         if dev ∉ bbstream.devices
             setstream!(dev, bbstream)
@@ -26,37 +28,68 @@ function init_devices!(bbstream::BeagleBoneStream, devs::Device...)
     return
 end
 
-function send!(stream::BeagleBoneStream)
-    cmds = Tuple[]
-    for dev in stream.devices
-        val = getsetvalue(dev)
-        cmd, devstream = safe_getwritecommand(dev, val)
-        devstream == stream || error("Device $dev is connected to other stream $devstream")
-        push!(cmds, cmd)
-    end
-    ncmds = Int32(length(cmds))
-    if ncmds > 0
-        allcmds = (true, ncmds, cmds...)
-        println("Sending command: $allcmds")
-        serialize(stream, allcmds)
-    end
+function send(bbstream::BeagleBoneStream)
+    ncmds = length(bbstream.sendbuffer)
+    serialize(bbstream.stream, (true, Int32(ncmds), bbstream.sendbuffer...))
+    empty!(bbstream.sendbuffer)
     return
 end
-function read(stream::BeagleBoneStream)
-    cmds = Tuple[]
-    for dev in stream.devices
-        cmd, devstream = safe_getreadcommand(dev)
-        devstream == stream || error("Device $dev is connected to other stream $devstream")
-        push!(cmds, cmd)
-    end
-    ncmds = Int32(length(cmds))
-    if ncmds > 0
-        allcmds = (false, ncmds, cmds...)
-        println("Sending command: $allcmds")
-        serialize(stream, allcmds)
-        #TODO save values in dev
-        # update_read_vale!(dev, val)
-    end
+function read(comedistream::BeagleBoneStream)
+    ncmds = length(bbstream.readbuffer)
+    serialize(bbstream.stream, (false, Int32(ncmds), bbstream.readbuffer...))
+    #TODO wait for answer
+    vals = nothing
+    empty!(bbstream.readbuffer)
+    return vals
+end
+#
+# function send(stream::BeagleBoneStream)
+#     cmds = Tuple[]
+#     for dev in stream.devices
+#         val = getsetvalue(dev)
+#         cmd, devstream = safe_getwritecommand(dev, val)
+#         devstream == stream || error("Device $dev is connected to other stream $devstream")
+#         push!(cmds, cmd)
+#     end
+#     ncmds = Int32(length(cmds))
+#     if ncmds > 0
+#         allcmds = (true, ncmds, cmds...)
+#         println("Sending command: $allcmds")
+#         serialize(stream, allcmds)
+#     end
+#     return
+# end
+# function read(stream::BeagleBoneStream)
+#     cmds = Tuple[]
+#     for dev in stream.devices
+#         cmd, devstream = safe_getreadcommand(dev)
+#         devstream == stream || error("Device $dev is connected to other stream $devstream")
+#         push!(cmds, cmd)
+#     end
+#     ncmds = Int32(length(cmds))
+#     if ncmds > 0
+#         allcmds = (false, ncmds, cmds...)
+#         println("Sending command: $allcmds")
+#         serialize(stream, allcmds)
+#         #TODO save values in dev
+#         # update_read_vale!(dev, val)
+#     end
+#     return
+# end
+
+
+#Maybe rethink a bit to support IObox
+function send(bbstream::BeagleBoneStream, cmd)
+    allcmds = (true, Int32(1), cmd)
+    println("Sending single command: $allcmds")
+    serialize(bbstream.stream, allcmds)
+    return
+end
+function read(bbstream::BeagleBoneStream, cmd)
+    allcmds = (false, Int32(1), cmd)
+    println("Sending single command: $allcmds")
+    serialize(bbstream.stream, allcmds)
+    #TODO get, wait for and return response
     return
 end
 
diff --git a/src/Computer/ComediStream.jl b/src/Computer/ComediStream.jl
new file mode 100644
index 0000000000000000000000000000000000000000..59a570d9750f52d9fc026bb0607e3ee5e04c84dc
--- /dev/null
+++ b/src/Computer/ComediStream.jl
@@ -0,0 +1,55 @@
+export ComediStream, init_devices!
+
+const comedipath = joinpath(@__DIR__,"comedi","comedi_bridge.so")
+const comediname = "/dev/comedi0"
+const SendTuple = Tuple{Int32,Int32,Int32,Float64}
+const ReadTuple = Tuple{Int32,Int32,Int32}
+
+struct ComediStream <: LabStream
+    devices::Array{AbstractDevice,1}
+    sendbuffer::Array{SendTuple,1}
+    readbuffer::Array{ReadTuple,1}
+end
+
+function ComediStream()
+    ccall((:comedi_start, comedipath),Int32,(Ptr{UInt8},), comediname)
+    ComediStream(AbstractDevice[], SendTuple[], ReadTuple[])
+end
+
+function init_devices!(comedistream::ComediStream, devs::AbstractDevice...)
+    for dev in devs
+        if dev ∉ comedistream.devices
+            setstream!(dev, comedistream)
+            push!(comedistream.devices, dev)
+            initialize(dev)
+        else
+            warn("Device $dev already added to the stream")
+        end
+    end
+    return
+end
+
+function send(comedistream::ComediStream, cmd::SendTuple)
+    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)
+    return ccall((:comedi_read, comedipath), Float64, (Int32,Int32,Int32), cmd[1], cmd[2], cmd[3])
+end
+
+function send(comedistream::ComediStream)
+    map(cmd -> send(comedistream, cmd), comedistream.sendbuffer)
+    empty!(comedistream.readbuffer)
+    return
+end
+function read(comedistream::ComediStream)
+    vals = map(cmd -> read(comedistream, cmd), comedistream.sendbuffer)
+    empty!(comedistream.readbuffer)
+    return vals
+end
+
+function close(stream::ComediStream)
+    foreach(close, stream.devices)
+    ccall((:comedi_stop, comedipath), Int32, (Int32,), 0)
+    return
+end
diff --git a/src/Computer/Computer.jl b/src/Computer/Computer.jl
index eeb58a6de8fb4fca8ce29ea6a4ec11747ccec238..19e6ab5c6c85f634f35355db6c701c018ec1b13e 100644
--- a/src/Computer/Computer.jl
+++ b/src/Computer/Computer.jl
@@ -1,36 +1,37 @@
-abstract type LabStream end
-abstract type Device end
+abstract type AbstractDevice end
 
-include("Device.jl")
+include("LabStream.jl")
+include("AbstractDevice.jl")
 
 ##### General interface for LabStream
 ## A stream of type T <: LabStream should define the methods
 # serialize(::T, cmd)                   # Send data `cmd`
-# init_devices!(::T, devs::Device...)   # Initialize devices and connect them to stream
-# send!(::T)                            # Send set! commands for all devices to stream, using getwritecommand(stream::LabStream, dev::Device, getsetvalue(dev::Device))
-# read(::T)                             # Send read commands for all devices to stream, sing get(dev::Device)
-# init_devices!                         # Initialize all connected devises, using initialize(::Device)
-# close                                # Close connection, call close(::Device) on all connected devices
+# init_devices!(::T, devs::AbstractDevice...)   # Initialize devices and connect them to stream
+# send(::T)                            # Send set! commands for all devices to stream, using getwritecommand(stream::LabStream, dev::AbstractDevice, getsetvalue(dev::AbstractDevice))
+# read(::T)                             # Send read commands for all devices to stream, sing get(dev::AbstractDevice)
+# init_devices!                         # Initialize all connected devises, using initialize(::AbstractDevice)
+# close                                # Close connection, call close(::AbstractDevice) on all connected devices
 
 #Include the stream definitions
+include("ComediStream.jl")
 include("BeagleBoneStream.jl")
 
 
 ##### General interface for devices
-## A device to type T<:Device should define the methods
-# set!(dev::T, val)    # Remember val for next send!(::LabStream) command
-# getsetvalue(dev::T)  # Get the value that was saved to send
+## A device to type T<:AbstractDevice should define the methods
+# set!(dev::T, val)    # Remember val for next send(::LabStream) command
 # get(dev::T)          # Get val from last next read(::LabStream) command
 
 # getwritecommand(stream::LabStream, dev::T, val)   #Get canonlical representation of send command
 # getreadcommand(stream::LabStream, dev::T)         #Get canonlical representation of read command
 
 ## Default methods:
-# initialize(::Device) = nothing    #What to do when initializing
-# close(::Device) = nothing          #What to do when disconnecting
-# getstream(dev::Device) = dev.stream #Which stream is the Device connected to
-# setstream!(dev::Device, stream::LabStream) = dev.stream = stream #Set the stream the Device is connected to
+# initialize(::AbstractDevice) = nothing    #What to do when initializing
+# close(::AbstractDevice) = nothing          #What to do when disconnecting
+# getstream(dev::AbstractDevice) = dev.stream #Which stream is the Device connected to
+# setstream!(dev::AbstractDevice, stream::LabStream) = dev.stream = stream #Set the stream the Device is connected to
 ##### END General interface for devices
 
 #Include the device definitions
 include("SysLED.jl")
+include("10V.jl")
diff --git a/src/Computer/Device.jl b/src/Computer/Device.jl
deleted file mode 100644
index 96c299cfa731493411680d4db041b90eed1ee4bc..0000000000000000000000000000000000000000
--- a/src/Computer/Device.jl
+++ /dev/null
@@ -1,50 +0,0 @@
-export initialize, getstream, setstream!, send!, set!, getsetvalue
-
-###### Defaults for Device
-#What to do when connecting
-initialize(::Device) = nothing
-#What to do when disconnecting
-close(::Device) = nothing
-#Which stream is the Device connected to
-getstream(dev::Device) = dev.stream
-#Set the stream the Device is connected to
-setstream!(dev::Device, stream::LabStream) = dev.stream = stream
-
-
-function safe_getwritecommand(dev::Device, val)
-    stream = try getstream(dev) catch
-        error("Device $dev not connected to a stream")
-    end
-    cmd = try getwritecommand(stream, dev, val) catch
-        error("Device $dev with output val $val not supported on stream $stream")
-    end
-    return cmd, stream
-end
-function safe_getreadcommand(dev::Device)
-    stream = try getstream(dev) catch
-        error("Device $dev not connected to a stream")
-    end
-    cmd = try getreadcommand(stream, dev) catch
-        error("Device $dev not supported  to read from on stream $stream")
-    end
-    return cmd, stream
-end
-
-#Maybe rethink a bit to support IObox
-function send!(dev::Device, val)
-    cmd, stream = safe_getwritecommand(dev, val)
-    #TODO This is not very general
-    allcmds = (true, Int32(1), cmd)
-    println("Sending single command: $allcmds")
-    serialize(stream, allcmds)
-    return
-end
-function read(dev::Device)
-    cmd, stream = safe_getreadcommand(dev)
-    allcmds = (false, Int32(1), cmd)
-    println("Sending single command: $allcmds")
-    serialize(stream, allcmds)
-
-    #TODO get, wait for and return response
-    return
-end
diff --git a/src/Computer/LabStream.jl b/src/Computer/LabStream.jl
new file mode 100644
index 0000000000000000000000000000000000000000..9f8738d8b4479778f8b37b03a569eecb221ca2a2
--- /dev/null
+++ b/src/Computer/LabStream.jl
@@ -0,0 +1,11 @@
+export LabStream
+
+abstract type LabStream end
+
+function close(stream::LabStream)
+    for dev in stream.devices
+        close(dev)
+    end
+    close(stream.stream)
+    return
+end
diff --git a/src/Computer/SysLED.jl b/src/Computer/SysLED.jl
index 94a6962cdd4c0cb6b0d6cd7ed94eb22e99b69d5d..855858f232c4a8c4396e02801471bc664540cff1 100644
--- a/src/Computer/SysLED.jl
+++ b/src/Computer/SysLED.jl
@@ -1,21 +1,12 @@
 export SysLED
 
-mutable struct SysLED <: Device
+mutable struct SysLED <: AbstractDevice
     i::Int32
-    nextout::Bool
-    latestread::Bool
     stream::LabStream
-    SysLED(i::Int32) = new(i, false, false)
+    SysLED(i::Int32) = new(i)
 end
 SysLED(i::Int64) = SysLED(convert(Int32, i))
 
-#Save value to send later
-set!(led::SysLED, val::Bool) = led.nextout = val
-#Get the value from set! back for use
-getsetvalue(led::SysLED) = led.nextout
-#Get value that was read erlier
-get(led::SysLED) = led.latestread
-
 #No definition for IOBox since there are no LEDs
 #Stream specific methods
 function getwritecommand(stream::BeagleBoneStream, led::SysLED, val::Bool)
diff --git a/src/Computer/comedi/Makefile b/src/Computer/comedi/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..2983d113d7fac4c5b0ebea540ebf3948ca263af9
--- /dev/null
+++ b/src/Computer/comedi/Makefile
@@ -0,0 +1,15 @@
+CC=gcc 
+
+CFLAGS=-c -Wall -fPIC
+
+SOURCES=comedi_bridge.c 
+OBJECTS=$(SOURCES:.c=.o)
+
+.c.o:
+	$(CC) $(CFLAGS) $< -o $@ 
+
+lib: $(OBJECTS)
+	$(CC) -shared -fPIC -lcomedi -lm -o comedi_bridge.so $(OBJECTS)
+
+clean:
+	rm *.o *.so
diff --git a/src/Computer/comedi/comedi.c b/src/Computer/comedi/comedi.c
new file mode 100644
index 0000000000000000000000000000000000000000..27cc729e874d1b82114888010f7bb5b394f445b5
--- /dev/null
+++ b/src/Computer/comedi/comedi.c
@@ -0,0 +1,57 @@
+/* This is a bridge between Julia and Comedi, written by Martin Karlsson
+ * and Jacob Mejvik at Dept. Automatic Control, Lund University.*/
+
+#include <stdio.h>      /* for printf() */
+#include <comedilib.h>
+
+
+int range = 0;
+int aref = AREF_GROUND;
+comedi_t *device;
+comedi_range * range_info;
+lsampl_t maxdata;
+
+int comedi_write(int comediNbr, int subdev, int chan, double physical_value) {
+	static int comedi_value;
+	static int retval;
+	range_info = comedi_get_range(device, subdev, chan, range);
+	maxdata = comedi_get_maxdata(device, subdev, chan);
+	comedi_value = comedi_from_phys(physical_value, range_info, maxdata);
+	retval = comedi_data_write(device, subdev, chan, range, aref, comedi_value);
+    return retval;
+}
+
+double comedi_read(int comediNbr, int subdev, int chan) {
+	static double physical_value;
+	lsampl_t comedi_value;
+	comedi_data_read(device, subdev, chan, range, aref, &comedi_value);
+	range_info = comedi_get_range(device, subdev, chan, range);
+	maxdata = comedi_get_maxdata(device, subdev, chan);
+	physical_value = comedi_to_phys(comedi_value, range_info, maxdata);
+	return physical_value;
+}
+
+// comedi_path example: "/dev/comedi0"
+int comedi_start(char* comedi_name) {
+	device = comedi_open(comedi_name);
+		if(device == NULL)
+	{
+		comedi_perror("comedi_open_error");
+		return -1;
+	}
+	comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER);
+	return 0;
+}
+
+void comedi_write_zero(int comediNbr, int subdev, int chan) {
+	static double physical_value_zero = 0.0;
+	static lsampl_t comedi_value;
+	range_info = comedi_get_range(device, subdev, chan, range);
+	maxdata = comedi_get_maxdata(device, subdev, chan);
+	comedi_value = comedi_from_phys(physical_value_zero, range_info, maxdata);
+	comedi_data_write(device, subdev, chan, range, aref, comedi_value);
+}
+
+void comedi_stop(int comediNbr) {
+	comedi_close(device);
+}
diff --git a/src/Computer/comedi/comedi_bridge.o b/src/Computer/comedi/comedi_bridge.o
new file mode 100644
index 0000000000000000000000000000000000000000..91d8dd79812bcd5cc4888231b243e8f5ab44ab9e
Binary files /dev/null and b/src/Computer/comedi/comedi_bridge.o differ
diff --git a/src/Computer/comedi/comedi_bridge.so b/src/Computer/comedi/comedi_bridge.so
new file mode 100755
index 0000000000000000000000000000000000000000..0526f55afaf161f8fb3d8f6c7d73eaddfae02472
Binary files /dev/null and b/src/Computer/comedi/comedi_bridge.so differ
diff --git a/src/LabConnection.jl b/src/LabConnection.jl
index f2319055e922856ea0d4c8dba85dd93af68a9227..c564687919f676a8a6a64950235bb674f3973680 100644
--- a/src/LabConnection.jl
+++ b/src/LabConnection.jl
@@ -1,4 +1,5 @@
-module LabConnection
+__precompile__()
+module LabConnections
 
     module BeagleBone
         export run_server
@@ -12,7 +13,7 @@ module LabConnection
     end
 
     module Computer
-        import Base: read, close, get, serialize
+        import Base: read, send, close, get, serialize
         println("Initializing Computer")
         include(joinpath("Computer","Computer.jl"))
     end
diff --git a/test/BeagleBone/GPIO_test.jl b/test/BeagleBone/GPIO_test.jl
index fff3f10cd311848ac98e394bf1c6ff448a7d2594..90afe80d2711c605e05ca8db430eb0ea5ed6a44e 100644
--- a/test/BeagleBone/GPIO_test.jl
+++ b/test/BeagleBone/GPIO_test.jl
@@ -1,6 +1,6 @@
-include("../../src/LabConnection.jl")
-using LabConnection.BeagleBone
-import LabConnection.BeagleBone: getdev, write!, channels
+include("../../src/LabConnections.jl")
+using LabConnections.BeagleBone
+import LabConnections.BeagleBone: getdev, write!, channels
 
 using Base.Test
 
diff --git a/test/BeagleBone/PWM_test.jl b/test/BeagleBone/PWM_test.jl
index 2f9a2b165b0d2aefa923c7c0d0c780767818d109..41a630a72eb0acd20ffe8ae0e4d1d175eb09e010 100644
--- a/test/BeagleBone/PWM_test.jl
+++ b/test/BeagleBone/PWM_test.jl
@@ -1,6 +1,6 @@
-include("../../src/LabConnection.jl")
-using LabConnection.BeagleBone
-import LabConnection.BeagleBone: getdev, write!, setup, teardown
+include("../../src/LabConnections.jl")
+using LabConnections.BeagleBone
+import LabConnections.BeagleBone: getdev, write!, setup, teardown
 
 pins = Dict(
     "P9.22" => ("PWM0A", "pwmchip0", "0"),
diff --git a/test/BeagleBone/PWM_test.jl~ b/test/BeagleBone/PWM_test.jl~
deleted file mode 100644
index 2f9a2b165b0d2aefa923c7c0d0c780767818d109..0000000000000000000000000000000000000000
--- a/test/BeagleBone/PWM_test.jl~
+++ /dev/null
@@ -1,40 +0,0 @@
-include("../../src/LabConnection.jl")
-using LabConnection.BeagleBone
-import LabConnection.BeagleBone: getdev, write!, setup, teardown
-
-pins = Dict(
-    "P9.22" => ("PWM0A", "pwmchip0", "0"),
-    "P9.21" => ("PWM0B", "pwmchip0", "1"),
-    "P9.14" => ("PWM1A", "pwmchip0", "0"),
-    "P9.16" => ("PWM1B", "pwmchip0", "1"),
-    "P8.19" => ("PWM2A", "pwmchip0", "0"),
-    "P8.13" => ("PWM2B", "pwmchip0", "1"),
-)
-
-dev = getdev("pwm")
-
-println("Running first experiment on selected pins...")
-for pin in keys(pins)
-    println("Testing pin $(pin)")
-    setup(dev, pin)
-    write!(dev, pin, 2, "100000000")
-    write!(dev, pin, 3, "50000000")
-    write!(dev, pin, 1, "1")
-    sleep(1)
-    write!(dev, pin, 1, "0")
-    teardown(dev, pin)
-end
-
-
-println("Running second experiment on pin $(pin)...")
-pin = "P9.22"
-setup(dev, pin)
-write!(dev, pin, 2, "1000000000")
-write!(dev, pin, 3, "250000000")
-write!(dev, pin, 1, "1")
-sleep(5.0)
-write!(dev, pin, 3, "500000000")
-sleep(5.0)
-write!(dev, pin, 3, "750000000")
-write!(dev, pin, 1, "0")
-teardown(dev, pin)
diff --git a/test/BeagleBone/Sys_LED_test.jl b/test/BeagleBone/Sys_LED_test.jl
index 8c1e8265f5874f2f91b52c046b54679a14395b6b..b52ef567d07db2899f438893656f21638d6d95b5 100644
--- a/test/BeagleBone/Sys_LED_test.jl
+++ b/test/BeagleBone/Sys_LED_test.jl
@@ -1,6 +1,6 @@
-include("../../src/LabConnection.jl")
-using LabConnection.BeagleBone
-import LabConnection.BeagleBone: getdev, write!
+include("../../src/LabConnections.jl")
+using LabConnections.BeagleBone
+import LabConnections.BeagleBone: getdev, write!
 
 using Base.Test
 
diff --git a/test/runtests.jl b/test/runtests.jl
index 0f194849e84610c91872523d7829686fa9b6b524..833ef7555fb22ab1285e70cce11631aafdb37510 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,4 +1,4 @@
-using LabConnection
+using LabConnections
 using Base.Test
 
 # write your own tests here
diff --git a/util/connect_BBB.sh b/util/connect_BBB.sh
index 3b412bba63923c38b7f13210cbfd078fd24e87cf..fa8a340f5f49e9239694ce4a381d66f897c5ca1d 100755
--- a/util/connect_BBB.sh
+++ b/util/connect_BBB.sh
@@ -5,4 +5,4 @@
 #
 # The code may be executed from anywhere on the HOST computer.
 ###############################################################################
-ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l"
+ssh -t debian@192.168.7.2 "./LabConnections.jl/util/startup.sh; bash -l"
diff --git a/util/connect_BBB.sh~ b/util/connect_BBB.sh~
deleted file mode 100755
index 3b412bba63923c38b7f13210cbfd078fd24e87cf..0000000000000000000000000000000000000000
--- a/util/connect_BBB.sh~
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-###############################################################################
-# This line of code connects to the BBB via ssh, runs the startup file and
-# remains in the shell of the BBB after executing startup.sh on the BBB
-#
-# The code may be executed from anywhere on the HOST computer.
-###############################################################################
-ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l"
diff --git a/util/copyfoldertobb.sh b/util/copyfoldertobb.sh
index a38f4cca2af96f90121912ab7c6a45adfd94f02d..a9c9d052e2c51ae0a9374063353baf822b871591 100755
--- a/util/copyfoldertobb.sh
+++ b/util/copyfoldertobb.sh
@@ -8,7 +8,7 @@ printf "${BLUE}Updating project${NC}\n..."
 
 codeHost=gitlab.control.lth.se
 codeUser=labdev
-projects=(LabConnection)
+projects=LabConnections
 flag=false
 
 printf "${BLUE}Initializing Transferring files to BBB${NC}\n"
diff --git a/util/flash_BBB.sh b/util/flash_BBB.sh
index f8102e1a7b9a285f4f490ffcac52db3df8ac799e..ef9bde0d901ba256d990a07621df1692879a62ce 100755
--- a/util/flash_BBB.sh
+++ b/util/flash_BBB.sh
@@ -15,7 +15,7 @@ printf "${BLUE}Updating project${NC}\n..."
 
 codeHost=gitlab.control.lth.se
 codeUser=labdev
-projects=(LabConnection.jl)
+projects=(LabConnections.jl)
 flag=false
 
 for project in "${projects[@]}"; do
@@ -63,7 +63,7 @@ done
 
 printf "${BLUE}Connecting to the BBB...${NC}\n"
 {
-  ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l"
+  ssh -t debian@192.168.7.2 "./LabConnections.jl/util/startup.sh; bash -l"
 } || {
    printf "${RED}Could Connect to the BBB!${NC}\n"
 }
diff --git a/util/flash_BBB.sh~ b/util/flash_BBB.sh~
deleted file mode 100755
index f8102e1a7b9a285f4f490ffcac52db3df8ac799e..0000000000000000000000000000000000000000
--- a/util/flash_BBB.sh~
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/bash
-###############################################################################
-# This code clones or upps the most recent code from github and transfers it to
-# the BBB before connecting to it and running the startup file on the BBB.
-#
-# The code may be executed from anywhere on the HOST computer.
-###############################################################################
-
-BLUE='\033[0;34m'
-GREEN='\033[0;32m'
-RED='\033[0;31m'
-NC='\033[0m'
-
-printf "${BLUE}Updating project${NC}\n..."
-
-codeHost=gitlab.control.lth.se
-codeUser=labdev
-projects=(LabConnection.jl)
-flag=false
-
-for project in "${projects[@]}"; do
-  {
-    if [ -d "${project}" ]; then
-      # Try to clone repository
-      printf "${GREEN}Pulling /${project}...${NC}\n"
-      cd "${project}"
-      echo $(ls)
-      git pull "https://${codeHost}/${codeUser}/${project}.git"
-      cd ".."
-    else
-      printf "${GREEN}Cloning /${project}...${NC}\n"
-      git clone "https://${codeHost}/${codeUser}/${project}.git"
-    fi
-  } || { # catch
-    # save log for exception
-    flag=false
-    printf "${RED}Could not udate repository /${project}${NC}, aborting.\n"
-  }
-done
-
-printf "${BLUE}Initializing Transferring files to BBB${NC}\n"
-if [ "{flag}"=true ]; then
-  for project in "${projects[@]}"; do
-    {
-      printf "${GREEN}Transferring /${project}...${NC}\n"
-      scp -r ${project} debian@192.168.7.2:/home/debian
-    } || { # catch
-      # save log for exception
-      flag=false
-      printf "${RED}Could not send project /${project} to the BBB, aborting!${NC}\n"
-    }
-  done
-fi
-
-printf "${BLUE}Deleting temporary files...${NC}\n"
-for project in "${projects[@]}"; do
-  {
-    rm -rf ${project}
-  } || {
-    printf "${RED}Could not delete project /${project}, aborting!${NC}\n"
-}
-done
-
-printf "${BLUE}Connecting to the BBB...${NC}\n"
-{
-  ssh -t debian@192.168.7.2 "./LabConnection.jl/util/startup.sh; bash -l"
-} || {
-   printf "${RED}Could Connect to the BBB!${NC}\n"
-}
diff --git a/util/getfrom_BBB.sh~ b/util/getfrom_BBB.sh~
deleted file mode 100755
index 00246845492ec516ca249cf0cb3866c0a1da6b0e..0000000000000000000000000000000000000000
--- a/util/getfrom_BBB.sh~
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-###############################################################################
-# This pice of tries to scp files from the BBB to a directory $PWD/temp
-#
-# The code may be executed from anywhere on the HOST computer.
-###############################################################################
-{
-  if [ ! -d "temp" ]; then
-    mkdir temp
-  fi
-  sudo scp -r debian@192.168.7.2:/home/debian/$1 $PWD/temp
-} || {
-  echo "Could not find or transfer $1, check that the file exists on the BBB"
-}
diff --git a/util/startup.sh b/util/startup.sh
index d556f1b05fa45910545a3d1f71545bd77b2d57d6..f7fd68da423aa464898d3fbaa8413d956cca8cea 100755
--- a/util/startup.sh
+++ b/util/startup.sh
@@ -1,4 +1,4 @@
 #!/bin/sh
 ls
-cd "LabConnection.jl/test/BeagleBone"
+cd "LabConnections.jl/test/BeagleBone"
 sudo /home/debian/julia-903644385b/bin/julia
diff --git a/util/startup.sh~ b/util/startup.sh~
deleted file mode 100755
index 78a8c75b74c62a7e02de9283fb4bd10d5ba94a0a..0000000000000000000000000000000000000000
--- a/util/startup.sh~
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-ls
-cd "LabConnection.jl/test/BeagleBone"
-sudo /home/debian/julia-903644385b/bin/julia
-