[svn-commits] tzafrir: branch tools/tzafrir/sysfs r8748 - in /tools/team/tzafrir/sysfs/xpp:...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 3 16:57:01 CDT 2010


Author: tzafrir
Date: Thu Jun  3 16:56:58 2010
New Revision: 8748

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8748
Log:
Move span aliases to /dev/dahdi/span-aliases:

* Alow tools to use non-dialbyname unless DAHDI_DIALBYNAME=1:
  - make 'lsdahdi -p' set it
* Add 'hwid' mode to xpp_blink
* Also, better debug messages in /usr/share/dahdi/symlink_span

Modified:
    tools/team/tzafrir/sysfs/xpp/lsdahdi
    tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
    tools/team/tzafrir/sysfs/xpp/symlink_span
    tools/team/tzafrir/sysfs/xpp/xpp_blink

Modified: tools/team/tzafrir/sysfs/xpp/lsdahdi
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/lsdahdi?view=diff&rev=8748&r1=8747&r2=8748
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/lsdahdi (original)
+++ tools/team/tzafrir/sysfs/xpp/lsdahdi Thu Jun  3 16:56:58 2010
@@ -23,6 +23,7 @@
 
 my @xbuses = Dahdi::Xpp::xbuses;
 my @xpds = map { $_->xpds } @xbuses;
+$ENV{'DAHDI_DIALBYNAME'} = 1 if $opts{'p'};
 
 foreach my $span (Dahdi::spans()) {
 	my $spanno = $span->num;

Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm?view=diff&rev=8748&r1=8747&r2=8748
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm Thu Jun  3 16:56:58 2010
@@ -310,7 +310,7 @@
 	my $span_num = $span->num;
 	my $hardware_id = $span->hardware_id;
 	my $location = $span->location;
-	my $name_base = '/dev/dahdi/span-names';
+	my $name_base = '/dev/dahdi/span-aliases';
 	my @names = glob "$name_base/*";
 	$span->{ALIAS} = '';
 	foreach my $n (@names) {
@@ -362,8 +362,11 @@
 	$self->{MANUFACTURER} = $self->_get_dev_attr('manufacturer');
 	# FIXME: the following is a number, rather than a readable value:
 	$self->{ALARMS} = $self->_get_dev_attr('alarms');
-	my $hwname = $self->alias || $self->hardware_id || $self->location;
-	if (defined $hwname && $ENV{DAHDI_DIALBYNAME}) {
+	my $hwname = $self->hardware_id || $self->location;
+	if (defined $self->alias) {
+		my $unique_string = sprintf "span-aliases!%s(%s)", $self->alias, $self->{SPAN_ID};
+		$self->{UNIQUE_STRING} = $unique_string;
+	} elsif (defined $hwname && $ENV{DAHDI_DIALBYNAME}) {
 		my $unique_string = sprintf "span-names!%s(%s)", $hwname, $self->{SPAN_ID};
 		$self->{UNIQUE_STRING} = $unique_string;
 	} else {

Modified: tools/team/tzafrir/sysfs/xpp/symlink_span
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/symlink_span?view=diff&rev=8748&r1=8747&r2=8748
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/symlink_span (original)
+++ tools/team/tzafrir/sysfs/xpp/symlink_span Thu Jun  3 16:56:58 2010
@@ -34,12 +34,12 @@
 
 ARGS=`getopt -o "H:L:S:" -- "$@"`
 [ $? -eq 0 ] || {
-	echo "$0: getopt failed" >&2
+	echo "$0($ACTION): getopt failed" >&2
 	exit 1
 }
 eval set -- "$ARGS"
 
-echo >&2 "$0: DEBUG($# args): '$*'"
+echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
 
 while [ $# -gt 0 ]; do
         case "$1" in
@@ -47,7 +47,7 @@
                 -L) export LOCATION="$2" ; shift 2 ;;
                 -S) export SPAN_ID="$2" ; shift 2 ;;
                 --) shift ; break ;;
-                *) echo 1>&2 "$0: Internal error!" ; exit 1 ;;
+                *) echo 1>&2 "$0($ACTION): Internal error!" ; exit 1 ;;
         esac
 done
 
@@ -57,8 +57,9 @@
 [ -r "$initfile" ] && . "$initfile"
 
 SPANNAMES="/dev/dahdi/span-names"
+SPANALIASES="/dev/dahdi/span-aliases"
 LINK_DEST="/dev/dahdi/spans/${SPAN_NUM}"
-ALIASES_FILE='/etc/dahdi/hardware_aliases'
+ALIASES_FILE="$dahdiconfdir/hardware_aliases"
 
 span_alias() {
 	if [ -r "$ALIASES_FILE" ]; then
@@ -68,9 +69,10 @@
 
 create_links() {
 	mkdir -p "$SPANNAMES"
+	mkdir -p "$SPANALIASES"
 
 	if [ "$SPAN_ID" = '' ]; then
-		echo >&2 "$0: Missing span_id attribute for '$DEVPATH'"
+		echo >&2 "$0($ACTION): Missing span_id attribute for '$DEVPATH'"
 		exit 1
 	fi
 	SPAN_ID=`sysfs_attr_clean "$SPAN_ID"`
@@ -83,7 +85,7 @@
 		ln -s "$LINK_DEST" "$LINK"
 		ALIAS=`span_alias "$HARDWARE_ID"`
 	else
-		echo >&2 "$0: Missing hardware_id attribute for '$DEVPATH'"
+		echo >&2 "$0($ACTION): Missing hardware_id attribute for '$DEVPATH'"
 	fi
 	if [ "$LOCATION" != '' ]; then
 		LOCATION=`sysfs_attr_clean "$LOCATION"`
@@ -95,30 +97,31 @@
 			ALIAS=`span_alias "$LOCATION"`
 		fi
 	else
-		echo >&2 "$0: Missing location attribute for '$DEVPATH'"
+		echo >&2 "$0($ACTION): Missing location attribute for '$DEVPATH'"
 	fi
 	if [ "$ALIAS" != '' ]; then
-		ALIAS="${SPANNAMES}/$ALIAS($SPAN_ID)"
-		#echo "$0: alias: '$ALIAS'" 1>&2
+		ALIAS="${SPANALIASES}/$ALIAS($SPAN_ID)"
+		echo "$0($ACTION): alias: '$ALIAS'" 1>&2
 		rm -f "$ALIAS"
 		ln -s "$LINK_DEST" "$ALIAS"
 	fi
 }
 
 remove_links() {
-	for i in "$SPANNAMES/"*
+	for i in "$SPANNAMES/"* "$SPANALIASES/"*
 	do
 		if [ -L "$i" ]; then
 			LINK_DEST=`readlink "$i"`
 			REAL_SPAN_NUM=`echo "$DEVPATH" | sed 's/.*-//'`
 			if [ "$LINK_DEST" = "/dev/dahdi/spans/$REAL_SPAN_NUM" ]; then
-				#echo >&2 "$0: Removing '$i'"
+				#echo >&2 "$0($ACTION): Removing '$i'"
 				rm -f "$i" 1>&2
 			fi
 		fi
 	done
-	#echo "$0: Try to remove '$SPANNAMES'"
+	#echo "$0($ACTION): Try to remove '$SPANNAMES'"
 	rmdir "$SPANNAMES" 1>&2
+	rmdir "$SPANALIASES" 1>&2
 }
 
 case "$ACTION" in

Modified: tools/team/tzafrir/sysfs/xpp/xpp_blink
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/xpp_blink?view=diff&rev=8748&r1=8747&r2=8748
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/xpp_blink (original)
+++ tools/team/tzafrir/sysfs/xpp/xpp_blink Thu Jun  3 16:56:58 2010
@@ -23,7 +23,7 @@
 my $state = shift;
 my $selector = shift;
 usage unless defined($state) and $state =~ /^(on|off|bzzt)$/;
-usage unless defined($selector) and $selector =~ /^(span|chan|xpd|label)$/i;
+usage unless defined($selector) and $selector =~ /^(span|chan|xpd|hwid|label)$/i;
 
 my $xpd;
 my @blinklist;
@@ -77,6 +77,21 @@
 		@blinklist = $xbus->xpds;
 		die "XBUS number $busnum has no XPDS!\n" unless @blinklist;
 	}
+} elsif($selector =~ /^hwid$/i) {
+	my $hwid = shift;
+	usage unless defined($hwid);
+	my @spans = Dahdi::Span::match_hardware_id($hwid);
+	my $span = $spans[0];
+	die "Unkown Span Hardware ID $hwid\n" unless $span;
+	$xpd = Dahdi::Xpp::xpd_of_span($span);
+	die "Span Hardware ID $hwid is not and XPD\n" unless $xpd;
+	my $xpdname = $xpd->fqn;
+	my $connector = $xpd->xbus->connector;
+	die "$xpdname is not connected\n" unless defined $connector;
+	push(@blinklist, $xpd);
+	my @chans = $span->chans();
+	@channels = join(' ', map { $_->num } @chans);
+	printf "Using %s (connected via $connector): channels @channels\n", $xpd->fqn;
 } elsif($selector =~ /^label$/i) {
 	my $label = shift;
 	usage unless defined($label);




More information about the svn-commits mailing list