[svn-commits] tzafrir: tools/trunk r7953 - /tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jan 24 13:57:45 CST 2010


Author: tzafrir
Date: Sun Jan 24 13:57:40 2010
New Revision: 7953

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7953
Log:
Not all Astribanks have a 'serial' attribute. Make it optional.

Originally r7824 from the perl-sysstate branch.

Modified:
    tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm

Modified: tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm?view=diff&rev=7953&r1=7952&r2=7953
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Hardware/USB.pm Sun Jan 24 13:57:40 2010
@@ -121,6 +121,15 @@
 	return $value;
 }
 
+sub _get_attr_optional($$) {
+	my ($attr_file, $def_val) = $@;
+
+	eval {return _get_attr($attr_file)};
+	
+	# If we got here, _get_attr exploded. Return the default value:
+	return $def_val;
+}
+
 sub scan_devices_sysfs($) {
 	my $pack = shift || die;
 	my @devices = ();
@@ -137,7 +146,7 @@
 		my $model = $usb_ids{"$vendor:$product"};
 		next unless defined $model;
 		my $devnum = _get_attr("$_/devnum");
-		my $serial = _get_attr("$_/serial");
+		my $serial = _get_attr_optional("$_/serial", '');
 		my $devname = sprintf("%03d/%03d", $busnum, $devnum);
 		my $d = Dahdi::Hardware::USB->new(
 			IS_ASTRIBANK		=> ($model->{DRIVER} eq 'xpp_usb')?1:0,




More information about the svn-commits mailing list