[dahdi-commits] tzafrir: branch tools/2.2 r7473 - in /tools/branches/2.2: ./ xpp/perl_modules...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Wed Nov 4 11:25:25 CST 2009
Author: tzafrir
Date: Wed Nov 4 11:25:21 2009
New Revision: 7473
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7473
Log:
dahdi-perl fixes, mostly xpp-specific.
* Fix pattern for PCI BRI cards
* Fix recognizing xpp devices by @connector in xpp_order
* Print more helpful comments in xpp_order
* Remove most (if not all) need of /proc/bus/usb
* Handle other similar "is_twinstar" errors.
Merged revisions 6975,7000,7223,7401,7462 via svnmerge from
http://svn.digium.com/svn/dahdi/tools/trunk
........
r6975 | tzafrir | 2009-08-12 22:02:00 +0300 (Wed, 12 Aug 2009) | 2 lines
dahdi-perl: Remove a pointless whitespace in BRI strings list
........
r7000 | tzafrir | 2009-08-14 00:40:01 +0300 (Fri, 14 Aug 2009) | 4 lines
dahdi-perl: don't re-append '@' when testing the Astribank connector string
xpp rev: 7291
........
r7223 | tzafrir | 2009-09-27 16:38:50 +0200 (Sun, 27 Sep 2009) | 7 lines
dahdi_genconf: xpp_order generator: Extra '#' after connector comment
Add an extra '#' right after the connector string to make it simpler
to use the connector string from the generated xpp_order.
xpp rev: 7292
........
r7401 | tzafrir | 2009-10-13 20:21:17 +0200 (Tue, 13 Oct 2009) | 12 lines
xpp: make /proc/bus/usb/devices optional
Get the information we read from /proc/bus/usb/devices from
/sys/bus/usb/devices . Tested on my Debian Unstable with 2.6.30 kernel.
The default is still /proc/bus/usb and sysfs is only used if the procfs
file is not found.
Also fixes a case of using the sysfs attribute busnum, that does not
exist in kernel 2.6.9 . Devise the bus number from the name of the node.
........
r7462 | tzafrir | 2009-11-04 13:48:43 +0200 (Wed, 04 Nov 2009) | 6 lines
dahdi-perl: Avoid '"is_twinstar" on unblessed reference'
Dpn't panic if a device is not found in the list of hardware. This
is not only indication of a bug, but can also happen if a device
appeared after the script was started.
........
Modified:
tools/branches/2.2/ (props changed)
tools/branches/2.2/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm
tools/branches/2.2/xpp/perl_modules/Dahdi/Hardware/USB.pm
tools/branches/2.2/xpp/perl_modules/Dahdi/Span.pm
tools/branches/2.2/xpp/perl_modules/Dahdi/Xpp.pm
Propchange: tools/branches/2.2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Nov 4 11:25:21 2009
@@ -1,1 +1,1 @@
-/tools/trunk:1-6678,6823,6829-6830,6832-6833,6835,6837-6886,6889-6974,6976-6982,6985-6986,6988-6992,6994-6998,7001-7011,7013,7015,7017,7020-7042,7044,7046-7131,7162-7163
+/tools/trunk:1-6678,6823,6829-6830,6832-6833,6835,6837-6886,6889-6982,6985-6986,6988-6992,6994-6998,7000-7011,7013,7015,7017,7020-7042,7044,7046-7131,7133,7135-7136,7139-7217,7220,7222-7223,7225-7251,7254-7255,7258-7262,7264-7332,7336-7408,7410-7460,7462
Modified: tools/branches/2.2/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm?view=diff&rev=7473&r1=7472&r2=7473
==============================================================================
--- tools/branches/2.2/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm (original)
+++ tools/branches/2.2/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm Wed Nov 4 11:25:21 2009
@@ -111,7 +111,7 @@
my $label = $xbus->label;
my $connector = $xbus->connector;
my $name = $xbus->name;
- printf "%s\t# %s (%s)\n", $label, $connector, $name;
+ printf "%s\t# %s #(%s)\n", $label, $connector, $name;
}
close F;
select $old;
Modified: tools/branches/2.2/xpp/perl_modules/Dahdi/Hardware/USB.pm
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/perl_modules/Dahdi/Hardware/USB.pm?view=diff&rev=7473&r1=7472&r2=7473
==============================================================================
--- tools/branches/2.2/xpp/perl_modules/Dahdi/Hardware/USB.pm (original)
+++ tools/branches/2.2/xpp/perl_modules/Dahdi/Hardware/USB.pm Wed Nov 4 11:25:21 2009
@@ -77,7 +77,6 @@
my $xbus = shift || die;
my $xbus_dir = shift;
my $transportdir = "$xbus_dir/transport";
- my $hwdev;
if(! -e "$transportdir/ep_00") {
warn "A trasnport in '$transportdir' is not USB";
return undef;
@@ -94,25 +93,69 @@
warn "Bad USB transportdir='$transportdir' usbdev='$usbdev'\n";
}
} elsif(-d "$transportdir/usb_endpoint") {
- $busnum = readval("$transportdir/busnum");
+ $transportdir =~ m|/(\d+)-\d+$|;
+ $busnum = $1;
$devnum = readval("$transportdir/devnum");
}
my $usbname = sprintf("%03d/%03d", $busnum, $devnum);
#printf STDERR "DEBUG: %03d/%03d\n", $busnum, $devnum;
$xbus->{USB_DEVNAME} = $usbname;
- $hwdev = Dahdi::Hardware->device_by_hwname("usb:$usbname");
- #print "set_transport: ", $hwdev, "\n";
- $xbus->{TRANSPORT} = $hwdev;
- $hwdev->{XBUS} = $xbus;
- $hwdev->{LOADED} = 'xpp_usb';
- $xbus->{IS_TWINSTAR} = $hwdev->is_twinstar;
+ my $hwdev = Dahdi::Hardware->device_by_hwname("usb:$usbname");
+ if(defined $hwdev) {
+ #print "set_transport: ", $hwdev, "\n";
+ $xbus->{TRANSPORT} = $hwdev;
+ $hwdev->{XBUS} = $xbus;
+ $hwdev->{LOADED} = 'xpp_usb';
+ $xbus->{IS_TWINSTAR} = $hwdev->is_twinstar;
+ }
return $hwdev;
+}
+
+sub _get_attr($) {
+ my $attr_file = shift;
+
+ open(ATTR, $attr_file) or die "Failed to read SysFS attribute $attr_file\n";
+ my $value = <ATTR>;
+ chomp $value;
+ return $value;
+}
+
+sub scan_devices_sysfs($) {
+ my $pack = shift || die;
+ my @devices = ();
+
+ while (</sys/bus/usb/devices/*-*>) {
+ next unless -r "$_/idVendor"; # endpoints
+
+ # Older kernels, e.g. 2.6.9, don't have the attribute
+ # busnum:
+ m|/(\d+)-\d+$|;
+ my $busnum = $1 || next;
+ my $devnum = _get_attr("$_/devnum");
+ my $vendor = _get_attr("$_/idVendor");
+ my $product = _get_attr("$_/idProduct");
+ my $serial = _get_attr("$_/serial");
+ my $devname = sprintf("%03d/%03d", $busnum, $devnum);
+ my $model = $usb_ids{"$vendor:$product"};
+ next unless defined $model;
+ my $d = Dahdi::Hardware::USB->new(
+ IS_ASTRIBANK => ($model->{DRIVER} eq 'xpp_usb')?1:0,
+ PRIV_DEVICE_NAME => $devname,
+ VENDOR => $vendor,
+ PRODUCT => $product,
+ SERIAL => $serial,
+ DESCRIPTION => $model->{DESCRIPTION},
+ DRIVER => $model->{DRIVER},
+ );
+ push(@devices, $d);
+ }
+ return @devices;
}
sub scan_devices($) {
my $pack = shift || die;
my $usb_device_list = "/proc/bus/usb/devices";
- return unless (-r $usb_device_list);
+ return $pack->scan_devices_sysfs() unless (-r $usb_device_list);
my @devices;
open(F, $usb_device_list) || die "Failed to open $usb_device_list: $!";
Modified: tools/branches/2.2/xpp/perl_modules/Dahdi/Span.pm
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/perl_modules/Dahdi/Span.pm?view=diff&rev=7473&r1=7472&r2=7473
==============================================================================
--- tools/branches/2.2/xpp/perl_modules/Dahdi/Span.pm (original)
+++ tools/branches/2.2/xpp/perl_modules/Dahdi/Span.pm Wed Nov 4 11:25:21 2009
@@ -131,7 +131,7 @@
my @bri_strings = (
'BRI_(NT|TE)',
- '(?:quad|octo)BRI PCI ISDN Card.* \[(NT|TE)\]\ ',
+ '(?:quad|octo)BRI PCI ISDN Card.* \[(NT|TE)\]',
'octoBRI \[(NT|TE)\] ',
'HFC-S PCI A ISDN.* \[(NT|TE)\] ',
'(B4XXP) \(PCI\) Card', # Does not expose NT/TE type
Modified: tools/branches/2.2/xpp/perl_modules/Dahdi/Xpp.pm
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.2/xpp/perl_modules/Dahdi/Xpp.pm?view=diff&rev=7473&r1=7472&r2=7473
==============================================================================
--- tools/branches/2.2/xpp/perl_modules/Dahdi/Xpp.pm (original)
+++ tools/branches/2.2/xpp/perl_modules/Dahdi/Xpp.pm Wed Nov 4 11:25:21 2009
@@ -206,10 +206,9 @@
# Overrides from config file
foreach my $xbus (@xbuses) {
my $label = $xbus->label;
- my $connector = '@' . $xbus->connector;
my $val;
$val = $order{$label};
- $val = $order{$connector} unless defined $val;
+ $val = $order{$xbus->connector} unless defined $val;
$xbus->{XPPORDER} = $val if defined $val;
}
}
More information about the dahdi-commits
mailing list