Install plasma TH

From xPL
Jump to: navigation, search

The Panasonic plasma screens are controlled via a serial port.

Install xPL serial port

Install the serial port driver.

Download the serial port xPL device script. Move it to xPL scripts directory:

su
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
mv xpl-serial_port.pl $SCRIPTS_BASE_DIR
chown control:users $SCRIPTS_BASE_DIR/*.pl
chmod 775 $SCRIPTS_BASE_DIR/*.pl

Test the serial port device:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
ll /dev/tty*
$SCRIPTS_BASE_DIR/xpl-serial_port.pl -v -n loungeScreen -b '\x02' -e '\x03' /dev/ttyUSB0 baudrate 9600 databits 8 parity none stopbits 1 handshake none

Open a 2nd terminal window and test the xPL RS-232 control:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -d dspc-serPort.loungeScreen -c serPort.basic command=POF
$SCRIPTS_BASE_DIR/xpl-send.pl -v -d dspc-serPort.loungeScreen -c serPort.basic command=PON

Install xPL screen controller

Download the screen controller script. Move it to xPL scripts directory:

su
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
mv xpl-screen-pana.pl $SCRIPTS_BASE_DIR
chown control:users $SCRIPTS_BASE_DIR/*.pl
chmod 775 $SCRIPTS_BASE_DIR/*.pl

Test the screen controller:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-screen-pana.pl -v -n loungeScreen -s loungeScreen

Open a 3rd terminal window and test the commands:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -d dspc-scrPana.loungeScreen -c screen.basic power=off
$SCRIPTS_BASE_DIR/xpl-send.pl -d dspc-scrPana.loungeScreen -c screen.basic power=on

Launch the scripts at startup

Ubuntu with upStart

Edit /etc/init/xpl-loungeScreenSerialPort.conf:

# xPL serial port for Panasonic screen
#
description "xPL lounge screen serial port"
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env SCRIPT_NAME='xpl-serial_port.pl'
env PARAMETERS='-n loungeScreen -b \\x02 -e \\x03 /dev/ttyUSB0 baudrate 9600 databits 8 parity none stopbits 1 handshake none'

#-------------------------------------------------------------------------------
# Start and stop conditions
#
start on xpl-hub_started
stop on shutdown
respawn
setuid control
setgid dialout

#-------------------------------------------------------------------------------
# Startup signalling
#
post-start script
  sudo initctl emit xpl-loungeScreenSerialPort_started
end script

#-------------------------------------------------------------------------------
# Start daemon
#
exec $SCRIPTS_DIR/$SCRIPT_NAME $PARAMETERS

Start the serial port and test it:

su root
service xpl-loungeScreenSerialPort start
service xpl-loungeScreenSerialPort status
initctl list | grep xpl

Edit /etc/init/xpl-loungeScreen.conf:

# xPL Panasonic screen controller
#
description "xPL lounge screen controller"
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env SCRIPT_NAME='xpl-screen-pana.pl'
env PARAMETERS='-n loungeScreen -s loungeScreen'

#-------------------------------------------------------------------------------
# Start and stop conditions
#
start on xpl-loungeScreenSerialPort_started
stop on shutdown
respawn
setuid control
setgid users
 
#-------------------------------------------------------------------------------
# Start daemon
#
exec $SCRIPTS_DIR/$SCRIPT_NAME $PARAMETERS

Start the screen controller and test it:

su root
service xpl-loungeScreen start
service xpl-loungeScreen status
initctl list | grep xpl

Debian with SystemD

On Debian with systemd (such as Raspbian), the scripts can be defined as services.

Edit /lib/systemd/system/xpl-screenSerialPort.service:

[Unit]
Description=serial port for Panasonic screen
After=network.target

[Service]
Type=simple
ExecStart=/home/control/Documents/Controls/xpl-serial_port.pl -n loungeScreen -b \\x02 -e \\x03 /dev/ttyUSB0 baudrate 9600 databits 8 parity none stopbits 1 handshake none -w 2
Restart=always

[Install]
WantedBy=multi-user.target

Activate the service:

su
systemctl enable xpl-screenSerialPort.service

Reboot and check:

ps ax | grep -v grep | grep -i xpl
service xpl-screenSerialPort status

Mac OS

Check the serial port device name:

ll /dev/tty.*

Edit /Library/LaunchDaemons/xpl-loungeScreenSerialPort.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>xPL Lounge screen serial port</string>
    <key>OnDemand</key>
    <false/>
    <key>UserName</key>
    <string>control</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/control/Documents/Controls/xpl-serial_port.pl</string>
      <string>-n</string>
      <string>loungeScreen</string>
      <string>-w</string>
      <string>25</string>
      <string>-b</string>
      <string>\x02</string>
      <string>-e</string>
      <string>\x03</string>
      <string>/dev/tty.PL2303-0022111D</string>
      <string>baudrate</string>
      <string>9600</string>
      <string>databits</string>
      <string>8</string>
      <string>parity</string>
      <string>none</string>
      <string>stopbits</string>
      <string>1</string>
      <string>handshake</string>
      <string>none</string>
    </array>
  </dict>
</plist>

Edit /Library/LaunchDaemons/xpl-loungeScreen.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>xPL Lounge screen controller</string>
    <key>OnDemand</key>
    <false/>
    <key>UserName</key>
    <string>control</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/control/Documents/Controls/xpl-screen-pana.pl</string>
      <string>-n</string>
      <string>loungeScreen</string>
      <string>-s</string>
      <string>loungeScreen</string>
      <string>-w</string>
      <string>25</string>
    </array>
  </dict>
</plist>

Load the daemons:

launchctl load /Library/LaunchDaemons/xpl-loungeScreenSerialPort.plist
launchctl load /Library/LaunchDaemons/xpl-loungeScreen.plist
launchctl list | grep -i xpl 
ps ax | grep -i xpl | grep -v grep