summaryrefslogtreecommitdiff
path: root/kernel/xpp/utils/xpp_blink
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/xpp/utils/xpp_blink')
-rwxr-xr-xkernel/xpp/utils/xpp_blink53
1 files changed, 38 insertions, 15 deletions
diff --git a/kernel/xpp/utils/xpp_blink b/kernel/xpp/utils/xpp_blink
index 8a96502..bf68d80 100755
--- a/kernel/xpp/utils/xpp_blink
+++ b/kernel/xpp/utils/xpp_blink
@@ -17,16 +17,16 @@ use Zaptel::Xpp;
use Zaptel::Xpp::Xbus;
sub usage {
- die "Usage: $0 {on|off|bzzt} {span <number> | xpd <bus num> [<xpd num>] | label <label>}\n";
+ die "Usage: $0 {on|off|bzzt} {span <number> | chan <number> | xpd <bus num> [<xpd num>] | label <label>}\n";
}
my $state = shift;
my $selector = shift;
usage unless defined($state) and $state =~ /^(on|off|bzzt)$/;
-usage unless defined($selector) and $selector =~ /^(span|xpd|label)$/i;
+usage unless defined($selector) and $selector =~ /^(span|chan|xpd|label)$/i;
my $xpd;
-my @xpds;
+my @blinklist;
my @channels;
if($selector =~ /^span$/i) {
@@ -39,13 +39,24 @@ if($selector =~ /^span$/i) {
my $xpdname = $xpd->fqn;
my $connector = $xpd->xbus->connector;
die "$xpdname is not connected\n" unless defined $connector;
- push(@xpds, $xpd);
+ push(@blinklist, $xpd);
my @chans = $span->chans();
@channels = join(' ', map { $_->num } @chans);
printf "Using %s (connected via $connector): channels @channels\n", $xpd->fqn;
+} elsif($selector =~ /^chan$/i) {
+ my $channo = shift;
+ usage unless defined($channo) and $channo =~ /^\d+/;
+ my @spans = Zaptel::spans();
+ my @chans = map { $_->chans() } @spans;
+ my ($chan) = grep { $_->num eq $channo } @chans;
+ die "Channel $channo was not found\n" unless defined $chan;
+ die "Cannot blink Input ports\n" if $chan->type eq 'IN';
+ die "Cannot blink Output ports\n" if $chan->type eq 'OUT';
+ push(@blinklist, $chan);
} elsif($selector =~ /^xpd$/i) {
my $busnum = shift;
my $xpdnum = shift;
+ my $linenum = shift;
usage unless defined($busnum) and $busnum =~ /^\d+/;
my $xbus = Zaptel::Xpp::Xbus::by_number($busnum);
die "Unkown XBUS number $busnum\n" unless defined $xbus;
@@ -53,28 +64,36 @@ if($selector =~ /^span$/i) {
usage unless $xpdnum =~ /^\d+/;
$xpd = $xbus->get_xpd_by_number($xpdnum);
die "Unkown XPD number $xpdnum on XBUS number $busnum\n" unless defined $xpd;
- push(@xpds, $xpd);
+ if(defined $linenum) {
+ usage unless $linenum =~ /^\d+/;
+ my $lines = $xpd->lines;
+ my $l = @{$lines}[$linenum];
+ die "Bad line number $linenum on XPD $xpd->fqn\n" unless defined $l;
+ push(@blinklist, $l);
+ } else {
+ push(@blinklist, $xpd);
+ }
} else {
- @xpds = $xbus->xpds;
- die "XBUS number $busnum has no XPDS!\n" unless @xpds;
+ @blinklist = $xbus->xpds;
+ die "XBUS number $busnum has no XPDS!\n" unless @blinklist;
}
} elsif($selector =~ /^label$/i) {
my $label = shift;
usage unless defined($label);
my $xbus = Zaptel::Xpp::Xbus::by_label($label);
die "Unkown XBUS label $label\n" unless defined $xbus;
- @xpds = $xbus->xpds;
- die "XBUS label '$label' has no XPDS!\n" unless @xpds;
+ @blinklist = $xbus->xpds;
+ die "XBUS label '$label' has no XPDS!\n" unless @blinklist;
}
if($state eq 'on') {
- $_->blink(1) foreach (@xpds);
+ $_->blink(1) foreach (@blinklist);
} elsif($state eq 'off') {
- $_->blink(0) foreach (@xpds);
+ $_->blink(0) foreach (@blinklist);
} elsif($state eq 'bzzt') {
- $_->blink(1) foreach (@xpds);
+ $_->blink(1) foreach (@blinklist);
sleep 1;
- $_->blink(0) foreach (@xpds);
+ $_->blink(0) foreach (@blinklist);
}
__END__
@@ -85,7 +104,7 @@ xpp_blink - Blink the leds of a specified XPD
=head1 SYNOPSIS
-xpp_blink {on|off|bzzt} {span <number> | xpd <bus num> [<xpd num>]}\n";
+xpp_blink {on|off|bzzt} {span <number> | chan <number> | xpd <bus num> [<xpd num> [<lineno>]]}
=head1 DESCRIPTION
@@ -111,6 +130,8 @@ Blink all the leds of an XPD.
will also print the zaptel channels of the span and the
xbus/xpd this span represents.
+=item chan Select by channel number. This only work for XPD registered to zaptel.
+
=item xpd Select by xbus + xpd numbers. If only xbus number is given, all the
XPDs of the selected xbus (Astribank) are blinked.
@@ -123,7 +144,9 @@ Blink all the leds of an XPD.
$ xpp_blink bzzt span 2
Using XBUS-04/XPD-10 (connected via usb-0000:00:1d.7-1): channels 15 16 17 18 19 20 21 22
- $ xpp_blink on xpd 0 1
+ $ xpp_blink bzzt chan 18
+
+ $ xpp_blink on xpd 0 1 5
$ xpp_blink off xpd 0