Skip to content
Snippets Groups Projects
Commit cb48ab87 authored by Mattias Fält's avatar Mattias Fält
Browse files

updates startupscript and precompile

parent b2a2f41b
No related branches found
No related tags found
No related merge requests found
Pipeline #712 failed
......@@ -152,6 +152,18 @@ function bbparse(l::Tuple, sock)
end
end
function close_all_devices()
# When connection fails or closes, close devices
for key in keys(DEVICES)
for (devkey, active_device) in active_devices[key]
println("teardown $active_device")
teardown(active_device)
#Remove the device from the dict of active devices
delete!(active_devices[key], devkey)
end
end
end
global __waiting_first_connection__ = false
"""
run_server(port=2001; debug=false)
......@@ -181,8 +193,8 @@ function run_server(port=2001; debug=false)
@async while isopen(sock)
try
l = deserialize(sock);
println("deserialized:")
println(l)
# println("deserialized:")
# println(l)
try
bbparse(l, sock)
catch err
......@@ -192,7 +204,7 @@ function run_server(port=2001; debug=false)
catch err
if !isopen(sock) && (isa(err, Base.EOFError) || isa(err, Base.UVError))
println("Connection to server closed")
# TODO teardown and remove all devices
close_all_devices()
else
println("error: $(typeof(err))")
println("err: $err")
......@@ -201,10 +213,11 @@ function run_server(port=2001; debug=false)
end
end
catch err
close_all_devices()
if isa(err,Base.UVError) && err.prefix == "accept"
println("Server closed successfully")
else
rethrow()
rethrow(err)
end
end
end
......
......@@ -64,7 +64,7 @@ end
# Default to reading "value"
function read(gpio::GPIO, debug::Bool=false)
read(gpio, GPIO_VALUE, debug=debug)
read(gpio, GPIO_VALUE, debug)
end
"""
l = read(gpio::GPIO, operation::Int32, debug::Bool=false)
......
......@@ -8,26 +8,38 @@ function precompile_bb()
#Precompile serialize
initdev("debug", Int32(1))
serialize(clientside, (true, Int32(2), ("debug", Int32(1), true), ("debug", Int32(1), (1,2.0,"asd"))))
serialize(clientside, (true, Int32(2), ("debug", Int32(1), Int32(1)), ("debug", Int32(1), 1.0)))
serialize(clientside, (false, Int32(2), ("debug", Int32(1)), ("debug", Int32(1))))
serialize(clientside, (true, Int32(1), ("debug", Int32(1), true)))
serialize(clientside, (false, Int32(1), ("debug", Int32(1))))
serialize(clientside, (true, Int32(4), ("debug", Int32(1), true), ("debug", Int32(2), false), ("debug", Int32(3), true), ("debug", Int32(4), false)))
serialize(clientside, (WRITE, Int32(2), ("debug", Int32(1), true), ("debug", Int32(1), (1,2.0,"asd"))))
serialize(clientside, (WRITE, Int32(2), ("debug", Int32(1), Int32(1)), ("debug", Int32(1), 1.0)))
serialize(clientside, (READ, Int32(2), ("debug", Int32(1)), ("debug", Int32(1))))
serialize(clientside, (WRITE, Int32(1), ("debug", Int32(1), true)))
serialize(clientside, (READ, Int32(1), ("debug", Int32(1))))
initdev("debug", Int32(2))
initdev("debug", Int32(3))
initdev("debug", Int32(4))
serialize(clientside, (WRITE, Int32(4), ("debug", Int32(1), true), ("debug", Int32(2), false), ("debug", Int32(3), true), ("debug", Int32(4), false)))
closedev("debug", Int32(1))
closedev("debug", Int32(2))
closedev("debug", Int32(3))
closedev("debug", Int32(4))
println("closing clientside")
# Close the client side
close(clientside)
println("closing server")
#Close server
close(server)
debug = true
println("initdev")
#Precompile SysLED
led = initdev("sysled",Int32(1))
write!(led, "1", debug)
read(led, debug)
println("closedev")
closedev("sysled", Int32(1))
ind = 1
println("False: $(ind ∉ [1,2,3,4])")
......@@ -36,11 +48,13 @@ function precompile_bb()
gpio = initdev("gpio",Int32(1))
write!(gpio, (Int32(1), "1"), debug)
closedev("gpio", Int32(1))
#read(gpio, ind, args, debug)
# TODO activate when pwn is working
# Precompile PWM
pwm = initdev("pwm", Int32(1))
write!(pwm, (Int32(1),"1"), debug)
#pwm = initdev("pwm", Int32(1))
#write!(pwm, (Int32(1),"1"), debug)
#Do read/write to file
val = true
......
......@@ -2,7 +2,7 @@
Description=JuliaServer service
[Service]
ExecStart=/home/debian/julia/bin/julia -i -e 'include("/home/debian/juliapackages/LabConnections/src/BeagleBone/startup/startup.jl")' &
ExecStart=/usr/bin/screen -Dm /home/debian/julia/bin/julia -i -e 'include("/home/debian/juliapackages/LabConnections/src/BeagleBone/startup/startup.jl")' &
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment