Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabConnections.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labdev
LabConnections.jl
Commits
55f09f2d
Commit
55f09f2d
authored
7 years ago
by
Marcus Greiff
Browse files
Options
Downloads
Patches
Plain Diff
Tested and wrote new tests for the SysLED (dummy file systems not yet included)
parent
53025c26
No related branches found
No related tags found
1 merge request
!2
Rewrote devices on Beaglebone. Passes precompile, but needs proper testing.
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/BeagleBone/SysLED.jl
+8
-7
8 additions, 7 deletions
src/BeagleBone/SysLED.jl
src/BeagleBone/precompile.jl
+1
-1
1 addition, 1 deletion
src/BeagleBone/precompile.jl
test/BeagleBone/Sys_LED_test.jl
+22
-19
22 additions, 19 deletions
test/BeagleBone/Sys_LED_test.jl
with
31 additions
and
27 deletions
src/BeagleBone/SysLED.jl
+
8
−
7
View file @
55f09f2d
...
...
@@ -5,7 +5,7 @@ i ∈ [1,2,3,4].
"""
type
SysLED
<:
IO_Object
i
::
Int32
brightness_
filestream
::
IOStream
filestream
::
IOStream
function
SysLED
(
i
::
Int32
)
i
∉
[
1
,
2
,
3
,
4
]
&&
error
(
"Invalid SysLED index:
$
i"
)
#Note, in the future we should interface to config and retrieve IOStream from there
...
...
@@ -18,10 +18,11 @@ end
write!(led::SysLED, val::Bool, debug::Bool=false)
Turns the LED 'SysLed' on/off for val = true/false respectively.
"""
function
write!
(
led
::
SysLED
,
val
::
Bool
,
debug
::
Bool
=
false
)
function
write!
(
led
::
SysLED
,
entry
::
String
,
debug
::
Bool
=
false
)
debug
&&
return
write
(
led
.
brightness_filestream
,
val
?
"1"
:
"0"
)
seekstart
(
led
.
brightness_filestream
)
entry
∉
[
"0"
,
"1"
]
&&
error
(
"Invalid SysLED entry
$(entry)
, valid options are 0 and 1 (string)"
)
write
(
led
.
filestream
,
entry
)
seekstart
(
led
.
filestream
)
end
"""
...
...
@@ -30,9 +31,9 @@ Reads the current brightness value from the LED 'SysLED'.
"""
function
read
(
led
::
SysLED
,
debug
::
Bool
=
false
)
debug
&&
return
l
=
read
(
led
.
brightness_
filestream
,
Char
)
l
=
read
(
filestream
,
Char
)
(
l
!=
'1'
&&
l
!=
'0'
)
&&
error
(
"Invalid value
\"
$
l
\"
read from SysLed"
)
seekstart
(
led
.
brightness_
filestream
)
seekstart
(
led
.
filestream
)
return
l
end
...
...
@@ -42,5 +43,5 @@ Closes all open filestreams for the SysLED 'led'.
"""
function
teardown
(
led
::
SysLED
,
debug
::
Bool
=
false
)
debug
&&
return
close
(
led
.
brightness_
filestream
)
close
(
led
.
filestream
)
end
This diff is collapsed.
Click to expand it.
src/BeagleBone/precompile.jl
+
1
−
1
View file @
55f09f2d
...
...
@@ -24,7 +24,7 @@ function precompile_bb()
debug
=
true
#Precompile SysLED
led
=
initdev
(
"sysled"
,
Int32
(
1
))
write!
(
led
,
true
,
debug
)
write!
(
led
,
"1"
,
debug
)
read
(
led
,
debug
)
ind
=
1
...
...
This diff is collapsed.
Click to expand it.
test/BeagleBone/Sys_LED_test.jl
+
22
−
19
View file @
55f09f2d
using
LabConnections
.
BeagleBone
import
LabConnections
.
BeagleBone
:
getdev
,
write!
import
LabConnections
.
BeagleBone
:
getdev
,
write!
,
closedev
,
read
,
initdev
using
Base
.
Test
#Fixture
device
=
getdev
(
"sysled"
)
ledon
=
true
@testset
"SYS LED Tests"
begin
@testset
"Error Handling"
begin
# Attempt to initialize faulty device
@test_throws
ErrorException
getdev
(
"wrong_device_name"
)
# Test that an exception is thrown when a faulty ID is given
@test_throws
ErrorException
write!
(
device
,
5
,
ledon
)
device
=
initdev
(
"sysled"
,
1
)
# Test that an exception is thrown when a faulty ID is given
@test_throws
ErrorException
write!
(
device
,
0
,
ledon
)
@test_throws
ErrorException
write!
(
device
,
"bad_entry"
)
# Close device
closedev
(
"sysled"
,
1
)
end
@testset
"IO Communication"
begin
# Instanciate all possible leds and perform 10 read/write commands
device1
=
initdev
(
"sysled"
,
1
)
device2
=
initdev
(
"sysled"
,
2
)
device3
=
initdev
(
"sysled"
,
3
)
device4
=
initdev
(
"sysled"
,
4
)
for
i
=
1
:
10
for
j
=
1
:
4
write!
(
device
,
j
,
ledon
)
end
sleep
(
0.001
)
for
j
=
1
:
4
val
=
read
(
device
,
j
)
@test
val
==
ledon
end
ledon
=
!
ledon
state
=
write!
(
device1
,
"
$
(i%2)"
)
write!
(
device2
,
"
$
((i+1)%2)"
)
write!
(
device3
,
"
$
(i%2)"
)
write!
(
device4
,
"
$
((i+1)%2)"
)
sleep
(
0.1
)
end
closedev
(
"sysled"
,
1
)
closedev
(
"sysled"
,
2
)
closedev
(
"sysled"
,
3
)
closedev
(
"sysled"
,
4
)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment