|
|
|
@ -317,6 +317,10 @@ list_long() {
|
|
|
|
|
|
|
|
|
|
## Trying to find the desired device by watching plug-in effects
|
|
|
|
|
plug_in_watcher() {
|
|
|
|
|
# How long to wait for a first device to appear, how long to wait for more
|
|
|
|
|
wait_span_0=10
|
|
|
|
|
wait_span_1=5
|
|
|
|
|
|
|
|
|
|
found_devices=
|
|
|
|
|
echo >&2
|
|
|
|
|
echo "Caused by option -plug_test: Attempt to find the desired device" >&2
|
|
|
|
@ -339,26 +343,23 @@ plug_in_watcher() {
|
|
|
|
|
echo "Step 2:" >&2
|
|
|
|
|
echo "Please plug in the desired target device and then press the Enter key." >&2
|
|
|
|
|
read dummy
|
|
|
|
|
echo -n "Waiting up to 10 seconds for a new device to be listed ..." >&2
|
|
|
|
|
end_time="$(expr $(date +'%s') + 10)"
|
|
|
|
|
echo -n "Waiting up to $wait_span_0 seconds for a new device to be listed ..." >&2
|
|
|
|
|
end_time="$(expr $(date +'%s') + "$wait_span_0")"
|
|
|
|
|
while test $(date +'%s') -le "$end_time"
|
|
|
|
|
do
|
|
|
|
|
new_device_list=' '$(collect_devices)' '
|
|
|
|
|
if test "$old_device_list" = "$new_device_list"
|
|
|
|
|
then
|
|
|
|
|
sleep 1
|
|
|
|
|
echo -n '.' >&2
|
|
|
|
|
else
|
|
|
|
|
for i in $new_device_list
|
|
|
|
|
do
|
|
|
|
|
if echo "$old_device_list" | grep -F -v ' '"$i"' ' >/dev/null
|
|
|
|
|
then
|
|
|
|
|
found_devices="$found_devices $i"
|
|
|
|
|
fi
|
|
|
|
|
# Break the waiting loop
|
|
|
|
|
end_time=0
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
for i in $new_device_list
|
|
|
|
|
do
|
|
|
|
|
if echo "$old_device_list $found_devices " | grep -F -v ' '"$i"' ' >/dev/null
|
|
|
|
|
then
|
|
|
|
|
echo " found: $i" >&2
|
|
|
|
|
found_devices="$found_devices $i"
|
|
|
|
|
end_time=$(expr $(date +'%s') + "$wait_span_1")
|
|
|
|
|
echo -n "Now waiting $wait_span_1 seconds to let it settle ..." >&2
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
sleep 1
|
|
|
|
|
echo -n '.' >&2
|
|
|
|
|
done
|
|
|
|
|
echo >&2
|
|
|
|
|
if test -z "$found_devices"
|
|
|
|
@ -388,8 +389,6 @@ plug_in_watcher() {
|
|
|
|
|
devs=$(echo -n $found_devices)
|
|
|
|
|
echo >&2
|
|
|
|
|
|
|
|
|
|
# Give new device a second to settle
|
|
|
|
|
sleep 1
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|