[svn-commits] tzafrir: branch tools/2.6 r10737 - /tools/branches/2.6/xpp/waitfor_xpds
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Nov 22 10:55:42 CST 2012
Author: tzafrir
Date: Thu Nov 22 10:55:38 2012
New Revision: 10737
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10737
Log:
xpp: improved waitfor_xpds
* Fix an issue due to long firmware load time:
- When one Astribank has an echo canceler (long firmware loading) and
and another one does not.
- The EC-less Astribank finishes initialization before the Astribank
with EC is detected.
- Thus waitfor_xpds terminates too early.
* We now iteratively build two sets of serial numbers:
- One from wha we see in all Xorcom (e4e4:11[3456]x) USB devices.
- The other is those that were detected in the driver.
- Only when the two sets are equal (and > 0) we know we are done.
- This is resilient to many problems (e.g: disconnect/reconnect of
same device during initialization).
* The progress output was also improved: Now each detected AB
show the total number so far.
* The timeout was also increased to 100sec
* Woraround for an Astribank with no serial (but just a single one on
the system).
Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10465
Modified:
tools/branches/2.6/xpp/waitfor_xpds
Modified: tools/branches/2.6/xpp/waitfor_xpds
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.6/xpp/waitfor_xpds?view=diff&rev=10737&r1=10736&r2=10737
==============================================================================
--- tools/branches/2.6/xpp/waitfor_xpds (original)
+++ tools/branches/2.6/xpp/waitfor_xpds Thu Nov 22 10:55:38 2012
@@ -29,14 +29,53 @@
# For lab testing
mydir=`dirname $0`
PATH="${mydir}:${PATH}"
-XPP_WAIT_AB_TIMEOUT=80
+XPP_WAIT_AB_TIMEOUT=100
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
ab_list() {
+ find /sys/devices -name idVendor 2>/dev/null | \
+ xargs grep -H 'e4e4' 2>/dev/null | \
+ sed -e 's/idVendor.*/idProduct/' | xargs grep -H '11[3456]' | \
+ sed 's,/[^/]*$,,' || :
+}
+
+ab_serial_nums() {
+ ab_list | \
+ sed 's,$,/serial,' | \
+ xargs grep -H '' 2>/dev/null | \
+ sed 's,.*/serial:,,' | \
+ sed 's/^$/NO-SERIAL/' | \
+ sort -u
+}
+
+detected_serial_nums() {
+ cat /sys/bus/astribanks/devices/*/transport/serial 2> /dev/null | \
+ sed 's/^$/NO-SERIAL/' | \
+ sort -u || :
+}
+
+calc_union() {
+ echo "$@" | tr -s ' ' '\n' | sort -u
+}
+
+detected_ab_list() {
# Only check /sys info (don't use /proc anymore).
- ab=`find /sys/bus/astribanks/devices/xbus-*/ -name waitfor_xpds 2> /dev/null || :`
- echo $ab
+ find /sys/bus/astribanks/devices/*/ -name waitfor_xpds 2> /dev/null || :
+}
+
+waitfor_ab_initialization() {
+ oldab=''
+ while
+ if ! ab=`detected_ab_list`; then
+ exit 1
+ fi
+ test "$oldab" != "$ab"
+ do
+ oldab="$ab"
+ cat $ab
+ #echo -n 1>&2 "_"
+ done
}
# Any hardware?
@@ -55,10 +94,25 @@
exit 0
fi
-# Wait for driver and first device
+serial_nums=`ab_serial_nums`
+
+# Loop until detected (hopefully) all astribanks and they are initialized
echo -n 1>&2 "Astribanks detection "
tries="$XPP_WAIT_AB_TIMEOUT"
-while [ ! -e "/sys/bus/astribanks/devices/xbus-00" ]
+last_detected=0
+while
+ new_serial_nums=`ab_serial_nums`
+ detected_serial_nums=`detected_serial_nums`
+ curr_union=`calc_union $curr_union $serial_nums $new_serial_nums`
+ num_detected=`detected_ab_list | wc -l`
+ if [ "$num_detected" != "$last_detected" ]; then
+ # Visual feedback (number of detected AB so far)
+ echo -n 1>&2 "[$num_detected]"
+ last_detected="$num_detected"
+ waitfor_ab_initialization > /dev/null
+ fi
+ # Break only when we have something and it's stable
+ test "$curr_union" != "$detected_serial_nums" -o "$detected_serial_nums" = ''
do
if [ "$tries" -le 0 ]; then
echo 1>&2 "TIMEOUT"
@@ -67,21 +121,15 @@
echo -n 1>&2 "."
sleep 1
: $((tries-=1))
+ serial_nums="$new_serial_nums"
done
+
+# Finished: Show a nice output
echo ""
+cat /sys/bus/astribanks/devices/*/waitfor_xpds 2> /dev/null || :
# Wait for device to stabilize and XPD's to finish initalizations
echo 1>&2 "Astribanks initializing spans"
-while
- if ! ab=`ab_list`; then
- exit 1
- fi
- test "$oldab" != "$ab"
-do
- oldab="$ab"
- cat $ab
-done
-
if [ "$XPP_HOTPLUG_DAHDI" = yes ]; then
if [ "$CALLED_FROM_ATRIBANK_HOOK" = '' ]; then
# Now we can wait until the hotplug run would remove the semaphore
More information about the svn-commits
mailing list