Skip to content

Commit

Permalink
Add PJLINK Helper
Browse files Browse the repository at this point in the history
Added plink utility code from:
https://gist.github.com/1677547.git
  • Loading branch information
LightsOnHudson authored and LightsOnHudson committed Oct 6, 2015
1 parent 775b4f6 commit 01ad896
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
85 changes: 85 additions & 0 deletions pjlinkutil.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/perl

# ------------------------------------------------------------
# Projector PJLink Control Script
#
# ------------------------------------------------------------
# 2012 IT Services, Truman State University
#
# Maintained by Huan Truong, get the latest version at
# https://gist.github.com/1677547
# ------------------------------------------------------------

use Net::PJLink;
use Getopt::Std;
use Getopt::Long;
use Switch;
use Data::Dumper;

my $ip = $ARGV[0];
my $action = $ARGV[1];
my $password = '';
my $param = '';

# Process options.
if ( @ARGV > 0 ) {
GetOptions( 'p|password=s'=> \$password,
);
} else {
$help = <<END;
Usage:
./pjlinkutil.pl IP action param [-p password]
IP: The Hostname/IP Address of the PJLink enabled projector
action: Action to take, be one of the following
get_power_state: Get the current power state
set_power_state: Set power state
0: Turn off
1: Turn on
get_input: Get current input
set_input: Set input
{Array: INPUT_RGB,INPUT_VIDEO,INPUT_DIGITAL,INPUT_STORAGE,INPUT_NETWORK} {INPUT_NUMBER}
Examples:
./pjlinkutil.pl 192.168.0.1 turn 1 -p=1234
Will turn the projector on
./pjlinkutil.pl 192.168.0.1 set_input 1 1 -p=1234
Will set the current input of the projector to RGB(1) 1
END
print $help;
exit 0;
}

my $prj = Net::PJLink->new(
host => $ip,
# keep_alive => 1,
# auth_password => $password,
# This does NOT work -- the documentation is wrong
);

# If authentication is needed then we need to set it.
unless ($password == '') {
$prj->set_auth_password($password);
}

switch ($action) {
case 'set_power_state' {
$param = $ARGV[2];
print $prj->set_power($param);
}
case 'get_input' {
@current_input = $prj->get_input();
print $current_input[0][0] . ',' . $current_input[0][1];
}
case 'set_input' {
$param = $ARGV[2];
$inputnumber = $ARGV[3];
print $prj->set_input($param,$inputnumber);
}
else { # else, default to get power state
print $prj->get_power();
}
}

# Close all network connections to the projector.
$prj->close_all_connections;
3 changes: 1 addition & 2 deletions projectorCommands.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ $PROJECTORS = Array(
"RGB" => "set_input INPUT_RGB",
"VIDEO" => "set_input INPUT_VIDEO",
"DIGITAL" => "set_input INPUT_DIGITAL",
"VIDEO(RCA)" => "\xBE\xEF\x03\x06\x00\x6E\xD3\x01\x00\x00\x20\x01\x00",
"VIDEO(S)" => "\xBE\xEF\x03\x06\x00\x9E\xD3\x01\x00\x00\x20\x02\x00",

"IP" => "192.168.192.200",
"PASSWORD" => "1234"
//"BAUD_RATE" => "19200",
Expand Down

0 comments on commit 01ad896

Please sign in to comment.