@@ -71,6 +71,15 @@ function brokenfocus {
71
71
get_param " cam ${cam} " v4l2ctl | grep -c " focus_absolute"
72
72
}
73
73
74
+ # checks if device has "focus_absolute"
75
+ # call has_focus_absolute <mycamnameornumber>
76
+ # returns greater 0 if true, 0 if false
77
+ function has_focus_absolute {
78
+ local cam
79
+ cam=" ${1} "
80
+ v4l2-ctl -d " ${cam} " -L 2> /dev/null | grep -c " focus_absolute"
81
+ }
82
+
74
83
# call get_conf_value <mycamnameornumber>
75
84
# spits out value from config file
76
85
function get_conf_value {
@@ -91,7 +100,7 @@ function brokenfocus {
91
100
# ex.: get_current_value /dev/video0
92
101
# spits out focus_absolute=20 ( if set to 20 )
93
102
function get_current_value {
94
- v4l2-ctl -d " ${1} " -C " focus_absolute" | sed ' s/:[[:space:]]/=/'
103
+ v4l2-ctl -d " ${1} " -C " focus_absolute" 2> /dev/null | sed ' s/:[[:space:]]/=/'
95
104
}
96
105
97
106
# call set_current_value <device> <value>
@@ -109,7 +118,8 @@ function brokenfocus {
109
118
device=" $( get_param " cam ${cam} " device) "
110
119
cur_val=" $( get_current_value " ${device} " ) "
111
120
conf_val=" $( get_conf_value " ${cam} " ) "
112
- if [ " $( if_focus_absolute " ${cam} " ) " == " 1" ] &&
121
+ if [ " $( has_focus_absolute " ${cam} " ) " != " 0" ] &&
122
+ [ " $( if_focus_absolute " ${cam} " ) " == " 1" ] &&
113
123
[ " ${cur_val} " != " ${conf_val} " ]; then
114
124
detected_broken_dev_msg
115
125
set_focus_absolute " ${device} " " ${conf_val} "
0 commit comments