1
From: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2
Subject: [PATCH 1/2] 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
7
xpp/perl_modules/Dahdi/Hardware/USB.pm | 11 ++++++++++-
8
1 files changed, 10 insertions(+), 1 deletions(-)
10
diff --git a/xpp/perl_modules/Dahdi/Hardware/USB.pm b/xpp/perl_modules/Dahdi/Hardware/USB.pm
11
index 3eb9fe6..dff25ef 100644
12
--- a/xpp/perl_modules/Dahdi/Hardware/USB.pm
13
+++ b/xpp/perl_modules/Dahdi/Hardware/USB.pm
14
@@ -121,6 +121,15 @@ sub _get_attr($) {
18
+sub _get_attr_optional($$) {
19
+ my ($attr_file, $def_val) = $@;
21
+ eval {return _get_attr($attr_file)};
23
+ # If we got here, _get_attr exploded. Return the default value:
27
sub scan_devices_sysfs($) {
28
my $pack = shift || die;
30
@@ -137,7 +146,7 @@ sub scan_devices_sysfs($) {
31
my $model = $usb_ids{"$vendor:$product"};
32
next unless defined $model;
33
my $devnum = _get_attr("$_/devnum");
34
- my $serial = _get_attr("$_/serial");
35
+ my $serial = _get_attr_optional("$_/serial", '');
36
my $devname = sprintf("%03d/%03d", $busnum, $devnum);
37
my $d = Dahdi::Hardware::USB->new(
38
IS_ASTRIBANK => ($model->{DRIVER} eq 'xpp_usb')?1:0,