summaryrefslogtreecommitdiff
path: root/kernel/xpp/utils/zconf
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-03-21 01:51:39 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-03-21 01:51:39 +0000
commitd2bf4b90b68c4010d46398858cbfc589e1d9ff54 (patch)
tree87b3f40ee02b4ea949acd2c9bf2113417a38a6b2 /kernel/xpp/utils/zconf
parente0c4098698e7a7b4aa911c2bd292be398e78aa82 (diff)
* Earleier initialization of PRI module's register.
* Fix zaptel-perl reporting of battery after procfs changes. * Documentation updates. * Block hdlcstress/test fixes that followed: already merged. Merged revisions 4036 via svnmerge from http://svn.digium.com/svn/zaptel/branches/1.2 git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4039 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/utils/zconf')
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Hardware.pm108
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm8
2 files changed, 114 insertions, 2 deletions
diff --git a/kernel/xpp/utils/zconf/Zaptel/Hardware.pm b/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
index 5af22f7..ff7aeea 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
@@ -11,6 +11,88 @@ use strict;
use Zaptel::Hardware::USB;
use Zaptel::Hardware::PCI;
+=head1 NAME
+
+Zaptel::Hardware - Perl interface to a Zaptel devices listing
+
+
+ use Zaptel::Hardware;
+
+ my $hardware = Zaptel::Hardware->scan;
+
+ # mini zaptel_hardware:
+ foreach my $device ($hardware->device_list) {
+ print "Vendor: device->{VENDOR}, Product: $device->{PRODUCT}\n"
+ }
+
+ # let's see if there are devices without loaded drivers, and sugggest
+ # drivers to load:
+ my @to_load = ();
+ foreach my $device ($hardware->device_list) {
+ if (! $device->{LOADED} ) {
+ push @to_load, ($device->${DRIVER});
+ }
+ }
+ if (@to_load) {
+ print "To support the extra devices you probably need to run:\n"
+ print " modprobe ". (join ' ', @to_load). "\n";
+ }
+
+
+This module provides information about available Zaptel devices on the
+system. It identifies devices by (USB/PCI) bus IDs.
+
+
+=head1 Device Attributes
+As usual, object attributes can be used in either upp-case or
+lower-case, or lower-case functions.
+
+=head2 bus_type
+
+'PCI' or 'USB'.
+
+
+=head2 description
+
+A one-line description of the device.
+
+
+=head2 driver
+
+Name of a Zaptel device driver that should handle this device. This is
+based on a pre-made list.
+
+
+=head2 vendor, product, subvendor, subproduct
+
+The PCI and USB vendor ID, product ID, sub-vendor ID and sub-product ID.
+(The standard short lspci and lsusb listings show only vendor and
+product IDs).
+
+
+=head2 loaded
+
+If the device is handled by a module - the name of the module. Else -
+undef.
+
+
+=head2 priv_device_name
+
+A string that shows the "location" of that device on the bus.
+
+
+=head2 is_astribank
+
+True if the device is a Xorcom Astribank (which may provide some extra
+attributes).
+
+=head2 serial
+
+(Astribank-specific attrribute) - the serial number string of the
+Astribank.
+
+=cut
+
sub device_detected($$) {
my $dev = shift || die;
my $name = shift || die;
@@ -25,6 +107,15 @@ sub device_removed($) {
die "Missing zaptel device hardware name" unless $name;
}
+
+=head1 device_list()
+
+Returns a list of the hardware devices on the system.
+
+You must run scan() first for this function to run meaningful output.
+
+=cut
+
sub device_list($) {
my $self = shift || die;
my @types = @_;
@@ -37,6 +128,15 @@ sub device_list($) {
return @list;
}
+
+=head1 drivers()
+
+Returns a list of drivers (currently sorted by name) that are used by
+the devices in the current system (regardless to whether or not they are
+loaded.
+
+=cut
+
sub drivers($) {
my $self = shift || die;
my @devs = $self->device_list;
@@ -47,6 +147,14 @@ sub drivers($) {
return sort keys %drivers;
}
+
+=head1 scan()
+
+Scan the system for Zaptel devices (PCI and USB). Returns nothing but
+must be run to initialize the module.
+
+=cut
+
sub scan($) {
my $pack = shift || die;
my $self = {};
diff --git a/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm b/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
index e3e04f0..0014aed 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
@@ -39,15 +39,19 @@ sub create_all($$) {
die "Failed globbing '$procdir/*_info'" unless defined $infofile;
my $type = $xpd->type;
open(F, "$infofile") || die "Failed opening '$infofile': $!";
+ my $battery_info = 0;
while (<F>) {
chomp;
if($type eq 'FXO') {
- if(s/^\s*battery\s*:\s*//) {
+ $battery_info = 1 if /^Battery:/;
+ if($battery_info && s/^\s*on\s*:\s*//) {
my @batt = split;
foreach my $l (@lines) {
die unless @batt;
- $l->{BATTERY} = shift @batt;
+ my $state = shift @batt;
+ $l->{BATTERY} = ($state eq '+') ? 1 : 0;
}
+ $battery_info = 0;
die if @batt;
}
}