1
From: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2
Subject: Not all Astribanks have a 'serial' attribute. Make it optional.
3
Origin: http://svn.digium.com/svn/dahdi/tools/trunk@7953
4
Last-Update: 2010-01-24
6
Backport from current trunk. Will be included in dahdi-tools 2.3.
9
xpp/perl_modules/Dahdi/Hardware/USB.pm | 11 ++++++++++-
10
1 files changed, 10 insertions(+), 1 deletions(-)
12
diff --git a/xpp/perl_modules/Dahdi/Hardware/USB.pm b/xpp/perl_modules/Dahdi/Hardware/USB.pm
13
index 3eb9fe6..dff25ef 100644
14
--- a/xpp/perl_modules/Dahdi/Hardware/USB.pm
15
+++ b/xpp/perl_modules/Dahdi/Hardware/USB.pm
16
@@ -121,6 +121,15 @@ sub _get_attr($) {
20
+sub _get_attr_optional($$) {
21
+ my ($attr_file, $def_val) = $@;
23
+ eval {return _get_attr($attr_file)};
25
+ # If we got here, _get_attr exploded. Return the default value:
29
sub scan_devices_sysfs($) {
30
my $pack = shift || die;
32
@@ -137,7 +146,7 @@ sub scan_devices_sysfs($) {
33
my $model = $usb_ids{"$vendor:$product"};
34
next unless defined $model;
35
my $devnum = _get_attr("$_/devnum");
36
- my $serial = _get_attr("$_/serial");
37
+ my $serial = _get_attr_optional("$_/serial", '');
38
my $devname = sprintf("%03d/%03d", $busnum, $devnum);
39
my $d = Dahdi::Hardware::USB->new(
40
IS_ASTRIBANK => ($model->{DRIVER} eq 'xpp_usb')?1:0,