Skip to content
Snippets Groups Projects
Commit 926b8563 authored by Marcus Greiff's avatar Marcus Greiff
Browse files

Update docs

parent 395392c3
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
- [`Base.read`](lib/functions.md#Base.read) - [`Base.read`](lib/functions.md#Base.read)
- [`Base.read`](lib/functions.md#Base.read) - [`Base.read`](lib/functions.md#Base.read)
- [`LabConnections.BeagleBone.assert_pwm_write`](lib/functions.md#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}) - [`LabConnections.BeagleBone.assert_pwm_write`](lib/functions.md#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String})
- [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any})
- [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Any}) - [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Any})
- [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any})
- [`LabConnections.BeagleBone.closedev`](lib/functions.md#LabConnections.BeagleBone.closedev-Tuple{String,Int32}) - [`LabConnections.BeagleBone.closedev`](lib/functions.md#LabConnections.BeagleBone.closedev-Tuple{String,Int32})
- [`LabConnections.BeagleBone.export_gpio`](lib/functions.md#LabConnections.BeagleBone.export_gpio-Tuple{Int32}) - [`LabConnections.BeagleBone.export_gpio`](lib/functions.md#LabConnections.BeagleBone.export_gpio-Tuple{Int32})
- [`LabConnections.BeagleBone.export_led`](lib/functions.md#LabConnections.BeagleBone.export_led) - [`LabConnections.BeagleBone.export_led`](lib/functions.md#LabConnections.BeagleBone.export_led)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
- [`Base.read`](functions.md#Base.read) - [`Base.read`](functions.md#Base.read)
- [`Base.read`](functions.md#Base.read) - [`Base.read`](functions.md#Base.read)
- [`LabConnections.BeagleBone.assert_pwm_write`](functions.md#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}) - [`LabConnections.BeagleBone.assert_pwm_write`](functions.md#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String})
- [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any})
- [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Any}) - [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Any})
- [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any})
- [`LabConnections.BeagleBone.closedev`](functions.md#LabConnections.BeagleBone.closedev-Tuple{String,Int32}) - [`LabConnections.BeagleBone.closedev`](functions.md#LabConnections.BeagleBone.closedev-Tuple{String,Int32})
- [`LabConnections.BeagleBone.export_gpio`](functions.md#LabConnections.BeagleBone.export_gpio-Tuple{Int32}) - [`LabConnections.BeagleBone.export_gpio`](functions.md#LabConnections.BeagleBone.export_gpio-Tuple{Int32})
- [`LabConnections.BeagleBone.export_led`](functions.md#LabConnections.BeagleBone.export_led) - [`LabConnections.BeagleBone.export_led`](functions.md#LabConnections.BeagleBone.export_led)
...@@ -33,18 +33,18 @@ ...@@ -33,18 +33,18 @@
run_server(port=2001; debug=false) Run a server on `port` that listens for commands from computer Optional debug keyword disables blinking system leds ```
run_server(port=2001; debug=false)
```
Run a server on `port` that listens for commands from computer Optional debug keyword disables blinking system leds.
<a id='Base.read' href='#Base.read'>#</a> <a id='Base.read' href='#Base.read'>#</a>
**`Base.read`** &mdash; *Function*. **`Base.read`** &mdash; *Function*.
``` l = read(pwm::PWM, operation::Int32, debug::Bool=false) Reads the current value from an operation on a GPIO.
l = read(led::SysLED, debug::Bool=false)
```
Reads the current brightness value from the LED 'SysLED'.
<a id='Base.read' href='#Base.read'>#</a> <a id='Base.read' href='#Base.read'>#</a>
**`Base.read`** &mdash; *Function*. **`Base.read`** &mdash; *Function*.
...@@ -58,7 +58,11 @@ l = read(gpio::GPIO, operation::Int32, debug::Bool=false) Reads the current valu ...@@ -58,7 +58,11 @@ l = read(gpio::GPIO, operation::Int32, debug::Bool=false) Reads the current valu
l = read(pwm::PWM, operation::Int32, debug::Bool=false) Reads the current value from an operation on a GPIO. ```
l = read(led::SysLED, debug::Bool=false)
```
Reads the current brightness value from the LED 'SysLED'.
<a id='LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}' href='#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}'>#</a> <a id='LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}' href='#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}'>#</a>
**`LabConnections.BeagleBone.assert_pwm_write`** &mdash; *Method*. **`LabConnections.BeagleBone.assert_pwm_write`** &mdash; *Method*.
...@@ -76,23 +80,33 @@ Assertsion for the PWM input data ...@@ -76,23 +80,33 @@ Assertsion for the PWM input data
bbparse(cmd) Parse and execute the command `cmd` ```
bbparse(cmd)
```
Parse and execute the command `cmd`.
<a id='LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}' href='#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}'>#</a> <a id='LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}' href='#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}'>#</a>
**`LabConnections.BeagleBone.bbparse`** &mdash; *Method*. **`LabConnections.BeagleBone.bbparse`** &mdash; *Method*.
bbparse(l::Tuple, sock) Parse input on the form `l=(iswrite, ndev, cmd1, cmd2, ..., cmdn)` where if `iswrite` `cmdi = (devname, id, val)` and if not `iswrite` `cmdi = (devname, id)` ```
bbparse(l::Tuple, sock)
```
and send back on socket (vals, timestamps) Parse input on the form `l=(iswrite, ndev, cmd1, cmd2, ..., cmdn)` where if `iswrite` `cmdi = (devname, id, val)` and if not `iswrite` `cmdi = (devname, id)` and send back on socket (vals, timestamps).
<a id='LabConnections.BeagleBone.closedev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.closedev-Tuple{String,Int32}'>#</a> <a id='LabConnections.BeagleBone.closedev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.closedev-Tuple{String,Int32}'>#</a>
**`LabConnections.BeagleBone.closedev`** &mdash; *Method*. **`LabConnections.BeagleBone.closedev`** &mdash; *Method*.
closedev(dev_name::String, i::Int32) Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone, and removes it from the dict of currently active devices. ```
closedev(dev_name::String, i::Int32)
```
Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone, and removes it from the dict of currently active devices.
<a id='LabConnections.BeagleBone.export_gpio-Tuple{Int32}' href='#LabConnections.BeagleBone.export_gpio-Tuple{Int32}'>#</a> <a id='LabConnections.BeagleBone.export_gpio-Tuple{Int32}' href='#LabConnections.BeagleBone.export_gpio-Tuple{Int32}'>#</a>
**`LabConnections.BeagleBone.export_gpio`** &mdash; *Method*. **`LabConnections.BeagleBone.export_gpio`** &mdash; *Method*.
...@@ -124,28 +138,44 @@ export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for ...@@ -124,28 +138,44 @@ export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for
dev = getdev(dev_name::String, i::Int32) Retrieves the active device of type `dev_name` at index 'i' ```
dev = getdev(dev_name::String, i::Int32)
```
Retrieves the active device of type `dev_name` at index 'i'.
<a id='LabConnections.BeagleBone.initdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.initdev-Tuple{String,Int32}'>#</a> <a id='LabConnections.BeagleBone.initdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.initdev-Tuple{String,Int32}'>#</a>
**`LabConnections.BeagleBone.initdev`** &mdash; *Method*. **`LabConnections.BeagleBone.initdev`** &mdash; *Method*.
active_device = initdev(dev_name::String, i:Int32) Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone, and adds it to the dict of currently active devices. Returns the initialized device 'active_device'. ```
active_device = initdev(dev_name::String, i:Int32)
```
Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone, and adds it to the dict of currently active devices. Returns the initialized device 'active_device'.
<a id='LabConnections.BeagleBone.listdev-Tuple{}' href='#LabConnections.BeagleBone.listdev-Tuple{}'>#</a> <a id='LabConnections.BeagleBone.listdev-Tuple{}' href='#LabConnections.BeagleBone.listdev-Tuple{}'>#</a>
**`LabConnections.BeagleBone.listdev`** &mdash; *Method*. **`LabConnections.BeagleBone.listdev`** &mdash; *Method*.
message = listdev() Lists all the active devices as an insidence array for testing ```
message = listdev()
```
Lists all the active devices as an insidence array for testing.
<a id='LabConnections.BeagleBone.printdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.printdev-Tuple{String,Int32}'>#</a> <a id='LabConnections.BeagleBone.printdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.printdev-Tuple{String,Int32}'>#</a>
**`LabConnections.BeagleBone.printdev`** &mdash; *Method*. **`LabConnections.BeagleBone.printdev`** &mdash; *Method*.
message = printdev() Prints all the active devices and writes out specifics of a single devices ```
message = printdev()
```
Prints all the active devices and writes out specifics of a single devices.
<a id='LabConnections.BeagleBone.teardown' href='#LabConnections.BeagleBone.teardown'>#</a> <a id='LabConnections.BeagleBone.teardown' href='#LabConnections.BeagleBone.teardown'>#</a>
**`LabConnections.BeagleBone.teardown`** &mdash; *Function*. **`LabConnections.BeagleBone.teardown`** &mdash; *Function*.
...@@ -202,6 +232,13 @@ to_string(led::SysLED, debug::Bool=false) Generates a string representation of t ...@@ -202,6 +232,13 @@ to_string(led::SysLED, debug::Bool=false) Generates a string representation of t
write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) Writes an entry to an operation on a GPIO, of the form args = (operation, entry).
<a id='LabConnections.BeagleBone.write!' href='#LabConnections.BeagleBone.write!'>#</a>
**`LabConnections.BeagleBone.write!`** &mdash; *Function*.
``` ```
write!(pwm::PWM, args::Tuple{Int32,String}, debug::Bool=false) write!(pwm::PWM, args::Tuple{Int32,String}, debug::Bool=false)
``` ```
...@@ -219,10 +256,3 @@ write!(led::SysLED, val::Bool, debug::Bool=false) ...@@ -219,10 +256,3 @@ write!(led::SysLED, val::Bool, debug::Bool=false)
Turns the LED 'SysLed' on/off for val = true/false respectively. Turns the LED 'SysLed' on/off for val = true/false respectively.
<a id='LabConnections.BeagleBone.write!' href='#LabConnections.BeagleBone.write!'>#</a>
**`LabConnections.BeagleBone.write!`** &mdash; *Function*.
write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) Writes an entry to an operation on a GPIO, of the form args = (operation, entry).
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
Debug(i::Int32) Debug(i::Int32)
``` ```
Type for debugging and precompile Type for debugging and precompile.
<a id='LabConnections.BeagleBone.GPIO' href='#LabConnections.BeagleBone.GPIO'>#</a> <a id='LabConnections.BeagleBone.GPIO' href='#LabConnections.BeagleBone.GPIO'>#</a>
**`LabConnections.BeagleBone.GPIO`** &mdash; *Type*. **`LabConnections.BeagleBone.GPIO`** &mdash; *Type*.
...@@ -39,7 +39,9 @@ write!(gpio, (1, "1")) ...@@ -39,7 +39,9 @@ write!(gpio, (1, "1"))
The operation of reading the current output value of the GPIO is done by The operation of reading the current output value of the GPIO is done by
```
read(gpio, 1) read(gpio, 1)
```
See the test/BeagleBone/GPIO_test.jl for more examples. See the test/BeagleBone/GPIO_test.jl for more examples.
......
...@@ -11,10 +11,12 @@ const DEVICES = Dict("debug" => Debug, "sysled" => SysLED, "gpio" => GPIO, "pwm" ...@@ -11,10 +11,12 @@ const DEVICES = Dict("debug" => Debug, "sysled" => SysLED, "gpio" => GPIO, "pwm"
active_devices = Dict{String,Dict{Int32,IO_Object}}("debug" => Dict{Int32,Debug}(), "sysled" => Dict{Int32,SysLED}(), active_devices = Dict{String,Dict{Int32,IO_Object}}("debug" => Dict{Int32,Debug}(), "sysled" => Dict{Int32,SysLED}(),
"gpio" => Dict{Int32,GPIO}(), "pwm" => Dict{Int32,PWM}()) "gpio" => Dict{Int32,GPIO}(), "pwm" => Dict{Int32,PWM}())
""" active_device = initdev(dev_name::String, i:Int32) """
active_device = initdev(dev_name::String, i:Int32)
Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone, Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone,
and adds it to the dict of currently active devices. Returns the initialized and adds it to the dict of currently active devices. Returns the initialized
device 'active_device'.""" device 'active_device'.
"""
function initdev(dev_name::String, i::Int32) function initdev(dev_name::String, i::Int32)
#Check if the type of device is valid #Check if the type of device is valid
dev_constr = try dev_constr = try
...@@ -30,9 +32,11 @@ function initdev(dev_name::String, i::Int32) ...@@ -30,9 +32,11 @@ function initdev(dev_name::String, i::Int32)
return active_device return active_device
end end
""" closedev(dev_name::String, i::Int32) """
closedev(dev_name::String, i::Int32)
Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone, Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone,
and removes it from the dict of currently active devices.""" and removes it from the dict of currently active devices.
"""
function closedev(dev_name::String, i::Int32) function closedev(dev_name::String, i::Int32)
active_device = try active_device = try
active_devices[dev_name][i] active_devices[dev_name][i]
...@@ -47,8 +51,10 @@ function closedev(dev_name::String, i::Int32) ...@@ -47,8 +51,10 @@ function closedev(dev_name::String, i::Int32)
delete!(active_devices[dev_name], i) delete!(active_devices[dev_name], i)
end end
""" dev = getdev(dev_name::String, i::Int32) """
Retrieves the active device of type `dev_name` at index 'i'""" dev = getdev(dev_name::String, i::Int32)
Retrieves the active device of type `dev_name` at index 'i'.
"""
function getdev(dev_name::String, i::Int32) function getdev(dev_name::String, i::Int32)
dev = try dev = try
active_devices[dev_name][i] active_devices[dev_name][i]
...@@ -58,8 +64,10 @@ function getdev(dev_name::String, i::Int32) ...@@ -58,8 +64,10 @@ function getdev(dev_name::String, i::Int32)
return dev return dev
end end
""" message = listdev() """
Lists all the active devices as an insidence array for testing""" message = listdev()
Lists all the active devices as an insidence array for testing.
"""
function listdev() function listdev()
message = "Complete overview of active devices" message = "Complete overview of active devices"
count = zeros(length(keys(DEVICES))) count = zeros(length(keys(DEVICES)))
...@@ -69,8 +77,10 @@ function listdev() ...@@ -69,8 +77,10 @@ function listdev()
return count return count
end end
""" message = printdev() """
Prints all the active devices and writes out specifics of a single devices""" message = printdev()
Prints all the active devices and writes out specifics of a single devices.
"""
function printdev(dev_name::String, i::Int32) function printdev(dev_name::String, i::Int32)
println("Complete overview of active devices") println("Complete overview of active devices")
for (index, key) in enumerate(keys(DEVICES)) for (index, key) in enumerate(keys(DEVICES))
...@@ -84,23 +94,25 @@ function printdev(dev_name::String, i::Int32) ...@@ -84,23 +94,25 @@ function printdev(dev_name::String, i::Int32)
end end
end end
""" bbparse(cmd) """
Parse and execute the command `cmd`""" bbparse(cmd)
Parse and execute the command `cmd`.
"""
bbparse(any) = error("Unexpected input: $any") bbparse(any) = error("Unexpected input: $any")
function bbsend(sock, vals)#, timestamps) function bbsend(sock, vals)#, timestamps)
serialize(sock, vals)#, (timestamps...))) serialize(sock, vals)#, (timestamps...)))
end end
""" bbparse(l::Tuple, sock) """
bbparse(l::Tuple, sock)
Parse input on the form `l=(iswrite, ndev, cmd1, cmd2, ..., cmdn)` Parse input on the form `l=(iswrite, ndev, cmd1, cmd2, ..., cmdn)`
where if `iswrite` where if `iswrite`
`cmdi = (devname, id, val)` `cmdi = (devname, id, val)`
and if not `iswrite` and if not `iswrite`
`cmdi = (devname, id)` `cmdi = (devname, id)`
and send back on socket (vals, timestamps).
and send back on socket (vals, timestamps)""" """
function bbparse(l::Tuple, sock) function bbparse(l::Tuple, sock)
iswrite = l[1]::Bool #True if write command, false if read iswrite = l[1]::Bool #True if write command, false if read
ndev = l[2]::Int32 #Number of devices/commands ndev = l[2]::Int32 #Number of devices/commands
...@@ -127,9 +139,11 @@ function bbparse(l::Tuple, sock) ...@@ -127,9 +139,11 @@ function bbparse(l::Tuple, sock)
end end
global __waiting_first_connection__ = false global __waiting_first_connection__ = false
""" run_server(port=2001; debug=false) """
run_server(port=2001; debug=false)
Run a server on `port` that listens for commands from computer Run a server on `port` that listens for commands from computer
Optional debug keyword disables blinking system leds""" Optional debug keyword disables blinking system leds.
"""
function run_server(port=2001; debug=false) function run_server(port=2001; debug=false)
global __waiting_first_connection__ = true global __waiting_first_connection__ = true
server = listen(port) server = listen(port)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment