diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-12-18 14:31:07 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-12-18 14:31:07 +0000 |
commit | cfd61537b47387b0fb5c8228baad6cec16d8f6e6 (patch) | |
tree | 108deea65c09c7c273a9b981f8783efcd433eaea /xpp/utils/zconf/Zaptel/Xpp.pm | |
parent | 4391b4a6ee42bdfd8e097c5ee5485e9eb13f19a0 (diff) |
xpp r5151:
* xpd_pri: Basically ready.
* PCM synchronization changes:
- Each Astribank unit ticks independently. Each with its own PLL.
- HOST synchronization is gone. Loading of xpp will no longer cause
useless 250 ticks per second if you have no Astribank.
- Synchronization from the zaptel sync master requires setting
ZAPTEL as sync source (xpp_sync ZAPTEL).
* rx_tasklet is now a parameter of the module xpp, rather than of xpp_usb.
* New FPGA firmware: 5128 (1151) / 5122 (1141, 1131):
- Fixes synchronization issues.
- PRI module: E1 should now work.
* perl module and utilities:
- Modules no longer magically scan system on initialization.
- Scanning is by calling explicit methods.
- "Serial" has been renamed "Label". It is basically unique, but
should be modifieble.
- Some basic documentation of zaptel perl modules.
* Default sort order of zt_registration is back to SORT_CONNCTOR.
* zt_registration proc file now shows the number of span registered to
if registered. Try: grep . /proc/xpp/XBUS-*/XPD-*/zt_registration
* genzaptelconf: Allow using a custom command instead of
/etc/init.d/asterisk to start/stop asterisk.
* Fixed the typo "Slagish".
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@3506 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/zconf/Zaptel/Xpp.pm')
-rw-r--r-- | xpp/utils/zconf/Zaptel/Xpp.pm | 113 |
1 files changed, 93 insertions, 20 deletions
diff --git a/xpp/utils/zconf/Zaptel/Xpp.pm b/xpp/utils/zconf/Zaptel/Xpp.pm index 3c4b52c..8a2a6eb 100644 --- a/xpp/utils/zconf/Zaptel/Xpp.pm +++ b/xpp/utils/zconf/Zaptel/Xpp.pm @@ -10,35 +10,89 @@ package Zaptel::Xpp; use strict; use Zaptel::Xpp::Xbus; -my $proc_base = "/proc/xpp"; +=head1 NAME + +Zaptel::Xpp - Perl interface to the Xorcom Astribank drivers. + +=head1 SYNOPSIS -# Static Functions + # Listing all Astribanks: + use Zaptel::Xpp; + # scans hardware: + my @xbuses = Zaptel::Xpp::xbuses("SORT_CONNECTOR"); + for my $xbus (@xbuses) { + print $xbus->name." (".$xbus->label .", ". $xbus->connector .")\n"; + for my $xpd ($xbus->xpds) { + print " - ".$xpd->fqn,"\n"; + } + } +=cut + + +my $proc_base = "/proc/xpp"; # Nominal sorters for xbuses sub by_name { - return $a cmp $b; + return $a->name cmp $b->name; } sub by_connector { return $a->connector cmp $b->connector; } -sub by_serial { - my $cmp = $a->serial cmp $b->serial; +sub by_label { + my $cmp = $a->label cmp $b->label; return $cmp if $cmp != 0; return $a->connector cmp $b->connector; } +=head1 xbuses([sort_order]) + +Scans system (/proc and /sys) and returns a list of Astribank (Xbus) +objects. The optional parameter sort_order is the order in which +the Astribanks will be returns: + +=over + +=item SORT_CONNECTOR + +Sort by the connector string. For USB this defines the "path" to get to +the device through controllers, hubs etc. + +=item SORT_LABEL + +Sorts by the label of the Astribank. The label field is unique to the +Astribank. It can also be viewed through 'lsusb -v' without the drivers +loaded (the iSerial field in the Device Descriptor). + +=item SORT_NAME + +Sort by the "name". e.g: "XBUS-00". The order of Astribank names depends +on the load order, and hence may change between different runs. + +=item custom function + +Instead of using a predefined sorter, you can pass your own sorting +function. See the example sorters in the code of this module. + +=back + +=cut + sub xbuses { - my $optsort = shift || 'SORT_NAME'; + my $optsort = shift || 'SORT_CONNECTOR'; my @xbuses; - -d "/proc/xpp" or return (); + -d "$proc_base" or return (); + my @lines; + local $/ = "\n"; open(F, "$proc_base/xbuses") || die "$0: Failed to open $proc_base/xbuses: $!\n"; - while(<F>) { - chomp; - my ($name, @attr) = split; + @lines = <F>; + close F; + foreach my $line (@lines) { + chomp $line; + my ($name, @attr) = split(/\s+/, $line); $name =~ s/://; $name =~ /XBUS-(\d\d)/ or die "Bad XBUS number: $name"; my $num = $1; @@ -46,20 +100,20 @@ sub xbuses { my $xbus = Zaptel::Xpp::Xbus->new(NAME => $name, NUM => $num, @attr); push(@xbuses, $xbus); } - close F; my $sorter; if($optsort eq "SORT_CONNECTOR") { $sorter = \&by_connector; } elsif($optsort eq "SORT_NAME") { $sorter = \&by_name; - } elsif($optsort eq "SORT_SERIAL") { - $sorter = \&by_serial; + } elsif($optsort eq "SORT_LABEL") { + $sorter = \&by_label; } elsif(ref($optsort) eq 'CODE') { $sorter = $optsort; } else { die "Unknown optional sorter '$optsort'"; } - return sort $sorter @xbuses; + @xbuses = sort $sorter @xbuses; + return @xbuses; } sub xpd_of_span($) { @@ -73,6 +127,16 @@ sub xpd_of_span($) { return undef; } +=head1 sync([new_sync_source]) + +Gets (and optionally sets) the internal Astribanks synchronization +source. When used to set sync source, returns the original sync source. + +A synchronization source is a value valid writing into /proc/xpp/sync . +For more information read that file and see README.Astribank . + +=cut + sub sync { my $newsync = shift; my $result; @@ -94,17 +158,26 @@ sub sync { } close F; if(defined($newsync)) { # Now change - open(F, ">$file") or die "Failed to open $file for writing: $!"; - if($newsync eq 'HOST') { - print F "HOST"; - } elsif($newsync =~ /^(\d+)$/) { - print F ($newapi)? "SYNC=$1" : "$1 0"; - } else { + $newsync =~ s/.*/\U$&/; + if($newsync =~ /^(\d+)$/) { + $newsync = ($newapi)? "SYNC=$1" : "$1 0"; + } elsif($newsync ne 'ZAPTEL') { die "Bad sync parameter '$newsync'"; } + open(F, ">$file") or die "Failed to open $file for writing: $!"; + print F $newsync; close(F) or die "Failed in closing $file: $!"; } return $result; } +=head1 SEE ALSO + +For the documentation of xbus objects, see L<Zaptel::Xpp::Xbus>. For +information about XPD objects, see L<Zaptel::Xpp::Xpd>. + +General documentation can be found in the master package L<Zaptel>. + +=cut + 1; |