Install AVR 3808 serial

From xPL
Revision as of 08:21, 25 May 2015 by Fcorthay (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Denon AV receivers can be controlled via a serial port or via Ethernet.

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 loungeAmp -e '\x0D' /dev/ttyUSB1 baudrate 9600 databits 8 parity none stopbits 1 handshake none

Open a 2nd terminal window and view the xPL messages:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/SCRIPTS_BASE_DIR/xpl-monitor.pl -vf

Open a 3rd 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.loungeAmp -c serPort.basic command='PWON'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -d dspc-serPort.loungeAmp -c serPort.basic command='PW?'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -d dspc-serPort.loungeAmp -c serPort.basic command='PWSTANDBY'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -d dspc-serPort.loungeAmp -c serPort.basic command='PW?'

Install xPL audio-video controller

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

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

Test the AVR controller:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-avController-DenonAVR-serial.pl -v -n loungeAmp -s loungeAmp

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-ampDenon.loungeAmp -c media.basic mute=on
$SCRIPTS_BASE_DIR/xpl-send.pl -d dspc-ampDenon.loungeAmp -c media.basic mute=off

Launch the scripts at startup

Ubuntu

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

# xPL serial port for Denon AV receiver
#
description "xPL lounge audio-video controller 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 loungeAmp -e '\x0D' /dev/ttyUSB1 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-loungeAvControllerSerialPort_started
end script

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

Start the serial port and test it:

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

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

# xPL Denon AVR controller
#
description "xPL lounge audio-video controller"
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env SCRIPT_NAME='xpl-avController-DenonAVR-serial.pl'
env PARAMETERS='-n loungeAmp -s loungeAmp'

#-------------------------------------------------------------------------------
# Start and stop conditions
#
start on xpl-loungeAvControllerSerialPort_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-loungeAvController start
service xpl-loungeAvController status
initctl list | grep xpl

Mac OS

Check the serial port device name:

ll /dev/tty.*

Edit /Library/LaunchDaemons/xpl-loungeAvControllerSerialPort.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 audio/video controller 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>loungeAmp</string>
      <string>-e</string>
      <string>\x0D</string>
      <string>/dev/tty.PL2303-0021111D</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-loungeAvController.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 audio/video controller</string>
    <key>OnDemand</key>
    <false/>
    <key>UserName</key>
    <string>control</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/control/Documents/Controls/xpl-avController-DenonAVR-serial.pl</string>
      <string>-n</string>
      <string>loungeAmp</string>
      <string>-v</string>
      <string>loungeAmp</string>
    </array>
  </dict>
</plist>

Load the daemons:

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