Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393_sata
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393_sata
Commits
c9553bd4
Commit
c9553bd4
authored
Mar 02, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no SSD - no waiting
parent
22c3a8b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
9 deletions
+23
-9
x393sata_eyesis4pi_control.py
py393sata/x393sata_eyesis4pi_control.py
+23
-9
No files found.
py393sata/x393sata_eyesis4pi_control.py
View file @
c9553bd4
...
@@ -17,13 +17,13 @@ LOGFILE = "/var/log/x393sata_eyesis4pi.log"
...
@@ -17,13 +17,13 @@ LOGFILE = "/var/log/x393sata_eyesis4pi.log"
STATEFILE
=
"/var/state/ssd"
STATEFILE
=
"/var/state/ssd"
# constants
# constants
RESET_LIMIT
=
10
RESET_LIMIT
=
3
DRIVER_RELOAD_LIMIT
=
5
DRIVER_RELOAD_LIMIT
=
5
DRIVER_WAIT_TIME
=
10
DRIVER_WAIT_TIME
=
10
DRIVER_UNLOAD_TRIES
=
30
DRIVER_UNLOAD_TRIES
=
30
#global
#global
DEVICE_
NOT_CONNECTED
=
Tru
e
DEVICE_
CONNECTED
=
Fals
e
def
colorize
(
string
,
color
,
bold
):
def
colorize
(
string
,
color
,
bold
):
color
=
color
.
upper
()
color
=
color
.
upper
()
...
@@ -78,7 +78,7 @@ def shout(cmd):
...
@@ -78,7 +78,7 @@ def shout(cmd):
def
connection_errors
():
def
connection_errors
():
global
DEVICE_
NOT_
CONNECTED
global
DEVICE_CONNECTED
result
=
True
result
=
True
skip0
=
True
skip0
=
True
...
@@ -100,7 +100,7 @@ def connection_errors():
...
@@ -100,7 +100,7 @@ def connection_errors():
if
first_line
:
if
first_line
:
log_msg
(
"
%
s: 0x
%08
x [
%08
x]"
%
(
group_range
,
data
,
byte_addr
))
log_msg
(
"
%
s: 0x
%08
x [
%08
x]"
%
(
group_range
,
data
,
byte_addr
))
if
data
!=
0
:
if
data
!=
0
:
DEVICE_
NOT_CONNECTED
=
Fals
e
DEVICE_
CONNECTED
=
Tru
e
first_line
=
False
first_line
=
False
if
fld_value
or
not
skip0
:
if
fld_value
or
not
skip0
:
log_msg
(
"
%8
x :
%
s (
%
s)"
%
(
fld_value
,
fld
[
'name'
],
fld
[
'description'
]
))
log_msg
(
"
%8
x :
%
s (
%
s)"
%
(
fld_value
,
fld
[
'name'
],
fld
[
'description'
]
))
...
@@ -112,12 +112,18 @@ def connection_errors():
...
@@ -112,12 +112,18 @@ def connection_errors():
def
reset_device
():
def
reset_device
():
global
DEVICE_CONNECTED
result
=
False
result
=
False
sleep
(
0.5
)
sleep
(
0.5
)
for
i
in
range
(
RESET_LIMIT
):
for
i
in
range
(
RESET_LIMIT
):
if
not
connection_errors
():
if
not
connection_errors
():
if
i
==
0
:
DEVICE_CONNECTED
=
False
log_msg
(
"connection error ("
+
str
(
i
)
+
"), resetting device"
,
4
)
log_msg
(
"connection error ("
+
str
(
i
)
+
"), resetting device"
,
4
)
sata
.
reset_ie
()
sata
.
reset_ie
()
sata
.
reset_device
()
sata
.
reset_device
()
...
@@ -126,9 +132,10 @@ def reset_device():
...
@@ -126,9 +132,10 @@ def reset_device():
if
i
!=
0
:
if
i
!=
0
:
log_msg
(
"resetting device: success"
)
log_msg
(
"resetting device: success"
)
result
=
True
result
=
True
load_driver
()
break
break
# load driver in any case
load_driver
()
return
result
return
result
def
load_ahci_elphel_driver
():
def
load_ahci_elphel_driver
():
...
@@ -185,7 +192,7 @@ def load_driver():
...
@@ -185,7 +192,7 @@ def load_driver():
log_msg
(
"SATA failed, SSD was not detected: reconnect SSD"
,
2
)
log_msg
(
"SATA failed, SSD was not detected: reconnect SSD"
,
2
)
shout
(
"echo 0 > "
+
STATEFILE
)
shout
(
"echo 0 > "
+
STATEFILE
)
else
:
else
:
if
DEVICE_NOT
_CONNECTED
:
if
not
DEVICE
_CONNECTED
:
log_msg
(
"SSD was not detected, ahci_elphel driver is loaded"
,
4
)
log_msg
(
"SSD was not detected, ahci_elphel driver is loaded"
,
4
)
else
:
else
:
log_msg
(
"SATA ok, SSD detected after "
+
str
(
i
)
+
" tries"
)
log_msg
(
"SATA ok, SSD detected after "
+
str
(
i
)
+
" tries"
)
...
@@ -219,10 +226,17 @@ def reload_driver():
...
@@ -219,10 +226,17 @@ def reload_driver():
connection_errors
()
connection_errors
()
load_ahci_elphel_driver
()
load_ahci_elphel_driver
()
sleep
(
DRIVER_WAIT_TIME
)
result
=
check_device
()
if
DEVICE_NOT_CONNECTED
:
if
DEVICE_CONNECTED
:
sleep
(
DRIVER_WAIT_TIME
)
result
=
check_device
()
# one more try
if
not
result
:
log_msg
(
colorize
(
"SSD was not detected: waiting for another "
+
str
(
DRIVER_WAIT_TIME
)
+
" seconds"
,
'YELLOW'
,
True
))
sleep
(
DRIVER_WAIT_TIME
)
result
=
check_device
()
else
:
result
=
True
result
=
True
return
result
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment