diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2010-01-24 19:57:40 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2010-01-24 19:57:40 +0000 |
commit | 789f6481b53542ff939c2dd7746dd702541089a0 (patch) | |
tree | 79d22a2f9f2929657e2bd6a0f10154109cc9ba79 /xpp/perl_modules/Dahdi/Hardware | |
parent | ee6cdf75cac47ca2642d18c7357ac7ce480756f0 (diff) |
Not all Astribanks have a 'serial' attribute. Make it optional.
Originally r7824 from the perl-sysstate branch.
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@7953 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/perl_modules/Dahdi/Hardware')
-rw-r--r-- | xpp/perl_modules/Dahdi/Hardware/USB.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/xpp/perl_modules/Dahdi/Hardware/USB.pm b/xpp/perl_modules/Dahdi/Hardware/USB.pm index 3eb9fe6..dff25ef 100644 --- a/xpp/perl_modules/Dahdi/Hardware/USB.pm +++ b/xpp/perl_modules/Dahdi/Hardware/USB.pm @@ -121,6 +121,15 @@ sub _get_attr($) { 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 @@ sub scan_devices_sysfs($) { 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, |