[svn-commits] tzafrir: branch tzafrir/sysfs r3316 - /team/tzafrir/sysfs/xpp/utils/zconf/Zap...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 4 20:13:41 CST 2007


Author: tzafrir
Date: Tue Dec  4 20:13:41 2007
New Revision: 3316

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3316
Log:
Some basic support of sysfs attributes in zaptel-perl.
In theory zapconf should now preserve framing and coding. 

Modified:
    team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Chans.pm
    team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm

Modified: team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Chans.pm
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Chans.pm?view=diff&rev=3316&r1=3315&r2=3316
==============================================================================
--- team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Chans.pm (original)
+++ team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Chans.pm Tue Dec  4 20:13:41 2007
@@ -8,6 +8,7 @@
 # $Id$
 #
 use strict;
+my $sysfs_base = "/sys/bus/zaptel/devices";
 
 # Accessors (miniperl does not have Class:Accessor)
 our $AUTOLOAD;
@@ -36,6 +37,23 @@
 	$self->fqn($fqn);
 	$self->signalling($signalling);
 	$self->info($info);
+	# Get sysfs information, if available:
+	my $sysfs_dir = sprintf("$sysfs_base/span-%02d/chan-%02d-%02d", 
+		$span, $span, $num);
+	if ( -d $sysfs_dir ) {
+		$self->{CHANPOS} = 
+			_read_one_line_file("$sysfs_dir/chanpos");
+		$self->{ECHOCANCEL} = 
+			_read_one_line_file("$sysfs_dir/chan_echocancel");
+		$self->{NAME} = 
+			_read_one_line_file("$sysfs_dir/chan_name");
+		$self->{SIGNALLING} = 
+			_read_one_line_file("$sysfs_dir/chan_sig");
+		$self->{SIGCAP} = 
+			_read_one_line_file("$sysfs_dir/chan_sigcap");
+		$self->{TOENZONE} = 
+			_read_one_line_file("$sysfs_dir/chan_tonezone");
+	}
 	my $type;
 	if($fqn =~ m|\bXPP_(\w+)/.*$|) {
 		$type = $1;		# One of our AB

Modified: team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm?view=diff&rev=3316&r1=3315&r2=3316
==============================================================================
--- team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm (original)
+++ team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm Tue Dec  4 20:13:41 2007
@@ -11,6 +11,7 @@
 use Zaptel::Chans;
 
 my $proc_base = "/proc/zaptel";
+my $sysfs_base = "/sys/bus/zaptel/devices";
 
 sub chans($) {
 	my $span = shift;
@@ -56,12 +57,33 @@
 our $ZAPPRI_NET = 'pri_net';
 our $ZAPPRI_CPE = 'pri_cpe';
 
+sub _read_one_line_file($) {
+	my $file = shift;
+	open(FILE, $file) or return undef;
+	my $content = <FILE>;
+	chomp $content;
+	return $content;
+}
+
 sub new($$) {
 	my $pack = shift or die "Wasn't called as a class method\n";
 	my $num = shift or die "Missing a span number parameter\n";
 	my $self = { NUM => $num };
 	bless $self, $pack;
 	$self->{TYPE} = "UNKNOWN";
+	my $sysfs_dir = sprintf("$sysfs_base/span-%02d", $num);
+	if ( -d $sysfs_dir ) {
+		$self->{CODING} = 
+			_read_one_line_file("$sysfs_dir/digital_coding");
+		$self->{FRAMING} = 
+			_read_one_line_file("$sysfs_dir/digital_framing");
+		$self->{FLAGS} = 
+			_read_one_line_file("$sysfs_dir/flags");
+		$self->{IS_ZAPTEL_SYNC_MASTER} = 
+			_read_one_line_file("$sysfs_dir/sync_master");
+		$self->{NAME} = 
+			_read_one_line_file("$sysfs_dir/name");
+	}
 	open(F, "$proc_base/$num") or die "Failed to open '$proc_base/$num\n";
 	my $head = <F>;
 	chomp $head;
@@ -106,7 +128,7 @@
 	}
 	close F;
 	if($self->is_bri()) {
-		$self->{CODING} = 'ami';
+		$self->{CODING_GUESSED} = 'ami';
 		$self->{YELLOW} = undef;
 		$self->{DCHAN} = ($self->chans())[$self->{DCHAN_IDX}];
 		$self->{BCHANS} = [ ($self->chans())[@{$self->{BCHAN_LIST}}] ];
@@ -114,22 +136,30 @@
 		my $first_chan = ($self->chans())[0] || die "$0: No channels in span #$num\n";
 		my $chan_fqn = $first_chan->fqn();
 		if($chan_fqn =~ m(ZTHFC.*/|ztqoz.*/|XPP_BRI_.*/)) {		# BRI
-			$self->{FRAMING} = 'ccs';
+			$self->{FRAMING_GUESSED} = 'ccs';
 			$self->{SWITCHTYPE} = 'euroisdn';
 			$self->{SIGNALLING} = ($self->{TERMTYPE} eq 'NT') ? $ZAPBRI_NET : $ZAPBRI_CPE ;
 		} elsif($chan_fqn =~ m(ztgsm.*/)) {				# Junghanns's GSM cards. 
-			$self->{FRAMING} = 'ccs';
+			$self->{FRAMING_GUESSED} = 'ccs';
 			$self->{SIGNALLING} = 'gsm';
 		}
 	}
 	if($self->is_pri()) {
 		$self->{DCHAN} = ($self->chans())[$self->{DCHAN_IDX}];
 		$self->{BCHANS} = [ ($self->chans())[@{$self->{BCHAN_LIST}}] ];
-		$self->{CODING} = 'hdb3';
+		$self->{CODING_GUESSED} = 'hdb3';
 		$self->{YELLOW} = undef;
-		$self->{FRAMING} = 'ccs';
+		$self->{FRAMING_GUESSED} = 'ccs';
 		$self->{SIGNALLING} = ($self->{TERMTYPE} eq 'NT') ? $ZAPPRI_NET : $ZAPPRI_CPE ;
 		$self->{SWITCHTYPE} = 'euroisdn';
+	}
+	if ((! defined($self->{FRAMING})) && 
+		(exists $self->{FRAMING_GUESSED}) ) {
+		$self->{FRAMING} = $self->{FRAMING_GUESSED};
+	}
+	if ((! defined($self->{CODING})) && 
+		(exists $self->{CODING_GUESSED}) ) {
+		$self->{CODING} = $self->{CODING_GUESSED};
 	}
 	return $self;
 }




More information about the svn-commits mailing list