[svn-commits] tzafrir: tools/trunk r5134 - in /tools/trunk/xpp/perl_modules/Dahdi: ./ Xpp/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Oct 27 11:07:50 CDT 2008
Author: tzafrir
Date: Mon Oct 27 11:07:50 2008
New Revision: 5134
URL: http://svn.digium.com/view/dahdi?view=rev&rev=5134
Log:
perl xpp: Support for FXO batter attribute from sysfs (from r5133).
Still falls back to reading the battery status from procfs.
Also fixes error message.
Modified:
tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm
Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm?view=diff&rev=5134&r1=5133&r2=5134
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm Mon Oct 27 11:07:50 2008
@@ -40,7 +40,7 @@
unless(-f $file) {
my $procfile = sprintf "/proc/xpp/XBUS-%02d/XPD-%1d%1d/$attr",
$busnum, $unitnum, $subunitnum;
- warn "$0: OLD DRIVER: missing '$file'. Fall back to '$procfile'\n";
+ warn "$0: OLD DRIVER: missing '$file'. Fall back to /proc\n";
$file = $procfile;
}
next unless -f $file;
Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm?view=diff&rev=5134&r1=5133&r2=5134
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm Mon Oct 27 11:07:50 2008
@@ -69,23 +69,41 @@
}
$xpd->{LINES} = \@lines;
if($xpd->type eq 'FXO') {
- my ($infofile) = glob "$procdir/*_info";
- die "Failed globbing '$procdir/*_info'" unless defined $infofile;
- open(F, "$infofile") || die "Failed opening '$infofile': $!";
- my $battery_info = 0;
- while (<F>) {
- chomp;
- $battery_info = 1 if /^Battery:/;
- if($battery_info && s/^\s*on\s*:\s*//) {
- my @batt = split;
- foreach my $l (@lines) {
- die unless @batt;
- my $state = shift @batt;
- $l->{BATTERY} = ($state eq '+') ? 1 : 0;
+ my $file = Dahdi::Xpp::xpd_attr_path(
+ $xpd->xbus->num,
+ $xpd->unit,
+ $xpd->subunit, "fxo_battery");
+ if(defined $file) {
+ open(F, "$file") || die "Failed opening '$file': $!";
+ my $battery_line = <F>;
+ close F;
+ my @batt = split(/\s+/, $battery_line);
+ foreach my $l (@lines) {
+ die unless @batt;
+ my $state = shift @batt;
+ $l->{BATTERY} = ($state eq '+') ? 1 : 0;
+ }
+ } else {
+ # Fallback to old interface
+ my ($infofile) = glob "$procdir/*_info";
+ die "Failed globbing '$procdir/*_info'" unless defined $infofile;
+ open(F, "$infofile") || die "Failed opening '$infofile': $!";
+ my $battery_info = 0;
+ while (<F>) {
+ chomp;
+ $battery_info = 1 if /^Battery:/;
+ if($battery_info && s/^\s*on\s*:\s*//) {
+ my @batt = split;
+ foreach my $l (@lines) {
+ die unless @batt;
+ my $state = shift @batt;
+ $l->{BATTERY} = ($state eq '+') ? 1 : 0;
+ }
+ $battery_info = 0;
+ die if @batt;
}
- $battery_info = 0;
- die if @batt;
}
+ close F;
}
}
close F;
More information about the svn-commits
mailing list