Debian Codegraph @

xpp/lsdahdi

raw
1 #! /usr/bin/perl -w
2 #
3 # Written by Oron Peled <[email protected]>
4 # Copyright (C) 2007, Xorcom
5 # This program is free software; you can redistribute and/or
6 # modify it under the same terms as Perl itself.
7 #
8 # $Id$
9 #
10 use strict;
11 use File::Basename;
12 BEGIN { my $dir = dirname($0); unshift(@INC, "$dir", "$dir/perl_modules"); }
13
14 use Dahdi;
15 use Dahdi::Span;
16 use Dahdi::Xpp;
17 use Dahdi::Xpp::Xbus;
18 use Dahdi::Xpp::Xpd;
19
20 my @xbuses = Dahdi::Xpp::xbuses;
21 my @xpds = map { $_->xpds } @xbuses;
22
23 foreach my $span (Dahdi::spans()) {
24 my $spanno = $span->num;
25 my $xpd = Dahdi::Xpp::xpd_of_span($span);
26 my @lines;
27 my $index = 0;
28
29 @lines = @{$xpd->lines} if defined $xpd;
30 printf "### Span %2d: %s %s\n", $span->num, $span->name, $span->description;
31 foreach my $chan ($span->chans()) {
32 my %type_map = (
33 OUT => 'Output',
34 IN => 'Input'
35 );
36 my ($type) = map { $type_map{$_} or $_ } $chan->type || ("unknown");
37 my $batt = "";
38 $batt = "(battery)" if $chan->battery;
39 my @alarms = $chan->alarms;
40 my $alarm_str = join(" ", @alarms);
41 printf "%3d %-10s %-10s %s %s %s\n",
42 $chan->num, $type, $chan->signalling, $chan->info, $batt, $alarm_str;
43 $index++;
44 }
45 }
46
47 __END__
48
49 =head1 NAME
50
51 lsdahdi - List all Dahdi channels with their types and spans.
52
53 =head1 SYNOPSIS
54
55 lsdahdi
56
57 =head1 DESCRIPTION
58
59 Example output:
60
61 ### Span 1: WCTDM/0 "Wildcard TDM400P REV E/F Board 1"
62 1 FXO FXOLS (In use)
63 2 FXS FXSKS
64 3 FXS FXSKS
65 4 FXS FXSKS
66 ### Span 2: XBUS-00/XPD-00 "Xorcom XPD #00/00: FXO"
67 5 FXO FXSKS (In use)
68 6 FXO FXSKS (In use) (no pcm)
69 7 FXO FXSKS (In use) (no pcm)
70 8 FXO FXSKS (In use) (no pcm)
71 9 FXO FXSKS (In use) (no pcm)
72 10 FXO FXSKS (In use) (no pcm)
73 11 FXO FXSKS (In use) (no pcm)
74 12 FXO FXSKS (In use) (no pcm)
75 ### Span 3: XBUS-00/XPD-10 "Xorcom XPD #00/10: FXO"
76 13 FXO FXSKS (In use) (no pcm)
77 14 FXO FXSKS (In use) (no pcm)
78 15 FXO FXSKS (In use) (no pcm)
79 16 FXO FXSKS (In use) (no pcm)
80 17 FXO FXSKS (In use) (no pcm)
81 18 FXO FXSKS (In use) (no pcm)
82 19 FXO FXSKS (In use) (no pcm)
83 20 FXO FXSKS (In use) (no pcm)
84
85 ...
86
87 ### Span 6: XBUS-01/XPD-00 "Xorcom XPD #01/00: FXS"
88 37 FXS FXOLS (In use)
89 38 FXS FXOLS (In use) (no pcm)
90 39 FXS FXOLS (In use) (no pcm)
91 40 FXS FXOLS (In use) (no pcm)
92 41 FXS FXOLS (In use) (no pcm)
93 42 FXS FXOLS (In use) (no pcm)
94 43 FXS FXOLS (In use) (no pcm)
95 44 FXS FXOLS (In use) (no pcm)
96 45 Output FXOLS (In use) (no pcm)
97 46 Output FXOLS (In use) (no pcm)
98 47 Input FXOLS (In use) (no pcm)
99 48 Input FXOLS (In use) (no pcm)
100 49 Input FXOLS (In use) (no pcm)
101 50 Input FXOLS (In use) (no pcm)
102
103 The first column is the type of the channel (port, for an analog device)
104 and the second one is the signalling (if set).
105
106 =head1 FILES
107
108 lsdahdi is a somewhat glorified 'cat /proc/dahdi/*' . Unlike that
109 command, it sorts the spans with the proper order. It also formats the
110 output slightly differently.