Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-tempmon
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-tempmon
Commits
653164b2
Commit
653164b2
authored
Sep 26, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add parameter enabling/disabling fan control
parent
36689810
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
4 deletions
+35
-4
tempmon.py
src/tempmon.py
+35
-4
No files found.
src/tempmon.py
View file @
653164b2
...
@@ -27,6 +27,7 @@ import sys
...
@@ -27,6 +27,7 @@ import sys
import
time
import
time
import
subprocess
import
subprocess
import
atexit
import
atexit
import
getopt
from
posix
import
EX_OSFILE
,
F_OK
from
posix
import
EX_OSFILE
,
F_OK
DEBUG
=
0
DEBUG
=
0
...
@@ -59,10 +60,11 @@ out_fn = {"core_temp_fn": "core_temp",
...
@@ -59,10 +60,11 @@ out_fn = {"core_temp_fn": "core_temp",
class
temp_monitor
():
class
temp_monitor
():
def
__init__
(
self
,
ctrl_path_pref
,
ctrl_file_names
,
hwmon_path_pref
,
hwmon_fn
,
def
__init__
(
self
,
ctrl_path_pref
,
ctrl_file_names
,
hwmon_path_pref
,
hwmon_fn
,
out_path_prefix
,
out_fnames
):
out_path_prefix
,
out_fnames
,
control_fan
):
self
.
is_fan_on
=
False
self
.
is_fan_on
=
False
self
.
is_vp5_enabled
=
False
self
.
is_vp5_enabled
=
False
self
.
is_10389_present
=
True
self
.
is_10389_present
=
True
self
.
control_fan
=
control_fan
self
.
ctrl_path_prefix
=
ctrl_path_pref
self
.
ctrl_path_prefix
=
ctrl_path_pref
self
.
ctrl_fnames
=
ctrl_file_names
self
.
ctrl_fnames
=
ctrl_file_names
self
.
hwmon_path_prefix
=
hwmon_path_pref
self
.
hwmon_path_prefix
=
hwmon_path_pref
...
@@ -124,9 +126,12 @@ class temp_monitor():
...
@@ -124,9 +126,12 @@ class temp_monitor():
def
fan_ctrl
(
self
,
ctrl
):
def
fan_ctrl
(
self
,
ctrl
):
"""
"""
Control fan by writing to sysfs files.
Control fan
(if this is allowed during script invocation)
by writing to sysfs files.
@param ctrl: can be "on" or "off" to turn fan on or off
@param ctrl: can be "on" or "off" to turn fan on or off
"""
"""
if
self
.
control_fan
is
False
:
return
if
ctrl
is
"on"
:
if
ctrl
is
"on"
:
""" check if +5V is active and turn it on if it is not (it should not happen) """
""" check if +5V is active and turn it on if it is not (it should not happen) """
with
open
(
self
.
ctrl_path_prefix
+
self
.
ctrl_fnames
[
"vp5_en_fn"
],
"r+"
)
as
f
:
with
open
(
self
.
ctrl_path_prefix
+
self
.
ctrl_fnames
[
"vp5_en_fn"
],
"r+"
)
as
f
:
...
@@ -217,15 +222,41 @@ class temp_monitor():
...
@@ -217,15 +222,41 @@ class temp_monitor():
self
.
core_temp_params_f
.
write
(
str
(
key
)
+
": "
+
str
(
val
)
+
"
\n
"
)
self
.
core_temp_params_f
.
write
(
str
(
key
)
+
": "
+
str
(
val
)
+
"
\n
"
)
self
.
core_temp_params_f
.
flush
()
self
.
core_temp_params_f
.
flush
()
def
print_help
():
"""
Print usage information.
"""
print
"tempmon.py [--control_fan on|off]"
print
"'control_fan' parameter enables or disables camera fan control. Default value for this parameter is 'on'."
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
if
DEBUG
:
if
DEBUG
:
ctrl_path_pref
=
""
ctrl_path_pref
=
""
hwmon_path_pref
=
""
hwmon_path_pref
=
""
out_path_pref
=
""
out_path_pref
=
""
tm
=
temp_monitor
(
ctrl_path_pref
,
ctrl_fn
,
hwmon_path_pref
,
hwmon_fn
,
out_path_pref
,
out_fn
)
# parse command line options
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"h"
,
[
"control_fan="
])
except
:
print_help
()
sys
.
exit
(
2
)
control_fan
=
True
for
opt
,
arg
in
opts
:
if
opt
==
"-h"
:
print_help
()
sys
.
exit
(
0
)
elif
opt
==
"--control_fan"
:
if
arg
==
"on"
:
control_fan
=
True
else
:
control_fan
=
False
tm
=
temp_monitor
(
ctrl_path_pref
,
ctrl_fn
,
hwmon_path_pref
,
hwmon_fn
,
out_path_pref
,
out_fn
,
control_fan
)
if
tm
.
check_files
():
if
tm
.
check_files
():
# unconditionally turn the fan on to set the driver to a known state
# unconditionally turn the fan on to set the driver to a known state
tm
.
fan_ctrl
(
"on"
)
if
control_fan
:
tm
.
fan_ctrl
(
"on"
)
tm
.
monitor
()
tm
.
monitor
()
else
:
else
:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
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