Dell 2300MP RS-232 Remote Control

From MythTV Official Wiki
Jump to: navigation, search

This is a guide for setting up the RS232 control for a Dell 2300MP projector on a Fedora Core 6 MythTV box with a remote controlled by irexec and lircd, via a script called with a switch.

Introduction

I've got a 2300MP with no remote, and wanted to control all my devices with one remote. So I included the projector controls with my MythTV setup. I'm posting my results here so that others can interface thier device in a similar manner. I implimented power on, power off and resync. More features can be easily added if one wants to add to the script.

Instructions

Hardware

There are three electrical connections from the serial port to the projector RX, TX and GND. The RX from the projector is connected to the TX of the computer. The TX from the projector is connected to the RX on the projector. Ground is connected to ground. I made my cable from chopping off an old keyboard with a PS2 connector on it. Then I crimped on the DB9 on the other end. I'm sure one can probably purchase one of these, as serial mice used to be popular.

Software

To start you will need lircd and irexec installed and working. (Note in Fedora Core 6 you need to create /etc/irexec.conf see http://mythdora.com/?q=node/1679#comment-13201 for more infomation)

I've updated to MythDora5 w/ FC8 as well as MythDora10 w/ FC10 and the below works great.

install pyserial

# yum -y install pyserial

I only chose to impliment a handful of the features found at

http://support.dell.com/support/edocs/acc/2300MP/en/specs.htm

I found the recommended power sequence was incorrect. The command Dell claims is for power is in fact for the menu. Also the Commands seem to be reversed some times, but it works none the less. Also also, the power off command doesn't appear to work, I had to use the power command twice separated by about a second or so to make the projector go off. I do this by pressing the remote control button twice.

To control the projector via command line, I created the following script

# emacs /usr/local/bin/projector

#!/usr/bin/python
import sys              #allows you to capture the command switches
import serial           #get serial features for python
import time             #perhaps I don't need this. I think it was just extra for a time test once.

#this next line sets up the serial port to allow for communition and opens the serial port.
#you may need to change ttyS0 to S1, S2, ect. The rest shouldn't need to change.
ser = serial.Serial('/dev/ttyS0', 19200, 8, serial.PARITY_NONE, serial.STOPBITS_ONE, xonxoff=0, rtscts=0, timeout=1) 

H = "\xBE\xEF"       #these are always the same
AC = "\x10"
SoP = "\x05\x00"
ID  = "\x11\x11"
SoM = "\x01\x00"

#The CRC and the COMMAND change from serial command to serial command. 
#This is a table that allows for easier visual checking
CRC = "nope"         #default CRC is bogus
CRCpwr = "\xC6\xFF"
CRCmen = "\xC7\xBF"
CRCrsy = "\xc4\x7f"
CRCasp = "\x08\x7e"
CRCoff = "\x0C\x3E"
CRCfir = "\x12\x3e"

COMMAND = "nope"    #default COMMAND is bogus
COMMANDpwr = "\x01" #2300MP worked
COMMANDmen = "\x02" #2300MP worked
COMMANDrsy = "\x07" #2300MP worked
COMMANDasp = "\x17" #2300MP worked
COMMANDoff = "\x18"
COMMANDfir = "\x30"


#Now to correct the bogus CRC and COMMAND sequences
if sys.argv[1:] == ['-power'] :
    CRC = CRCpwr
    COMMAND = COMMANDpwr
    print 'power'
    
if sys.argv[1:] == ['-menu'] :
    CRC = CRCmen
    COMMAND = COMMANDmen
    print 'menu'
    
if sys.argv[1:] == ['-aspect'] :
    CRC = CRCasp
    COMMAND = COMMANDasp
    print 'aspect ratio'

if sys.argv[1:] == ['-resync'] :
    CRC = CRCrsy
    COMMAND = COMMANDrsy
    print 'resync'

#A debug command. May be handy if you impliment an unlisted command
#print sys.argv[1:]

#This is when it actually writes the command to the serial port. 
#This probably could be combined to one line, but I din't bother once I got it working.
ser.write(H)        #Write projector command
ser.write(AC)       
ser.write(SoP)     
ser.write(CRC)   
ser.write(ID)       
ser.write(SoM)     
ser.write(COMMAND)  

#Some commands like firmware may require you to capture the data, so I'm leaving this here.
#s = ser.read(10000) #read up to x bytes (timeout)
#print s

#all done now close the port.
ser.close()         #close serial port

Don't for get to make it executable

# chmod 755 /usr/local/bin/projector

I checked that I had at least gotten the PC listening to the projector by modifying the above to put what ever it heard on standard out. After I had confirmed the projector could talk to the PC, I confirmed the PC could transmit by bridging the TX and RX pin on the connector for the projector, then sent info to ttyS0, when it echoed back, it meant I had good connections.

Now to you should be able to run the command

# /usr/local/bin/projector -power

And either turn on the projector, or get a pop up on the display. Once you have that then it's time to link it with your remote via irexec and lircd. Once that works your in good shape. You can now with a command prompt command the projector. Now to run the script from the remote.

Create these additional scripts. I find them handy for trouble shooting, couldn't find the remote, ect. Also allows for beep option included at the end of this article.

# emacs /usr/local/bin/projector-on.sh
#! /bin/sh
/usr/local/bin/projector -power
# emacs /usr/local/bin/projector-off.sh
#! /bin/sh
/usr/local/bin/projector-on.sh; sleep 2; /usr/local/bin/projector-on.sh

And of course don't forget this

# chmod 755 /usr/local/bin/projector-on.sh
# chmod 755 /usr/local/bin/projector-off.sh

Add the following to your users lirc file and irexec.conf file. In my case it was

# emacs /home/mythtv/.lircrc

and

# emacs /etc/irexec.conf

### added for dell projector

begin
prog = irexec
button = Power
repeat = 3
config = /usr/local/bin/projector-on.sh
end

begin
prog = irexec
button = Green
repeat = 3
config = projector -resync
end

### end added for dell projector

irexec.conf doesn't exist, you have to create it. If you don't create it irexec doesn't seem to start reliably.

In lircrc don't forget to comment out the original "Power" and "Green" sections.

Your lircrc might also be under /home/mythtv/.mythtv/lircrc many have them linked together.

Either reboot, or run this

# service lircd restart
Stopping infrared command execution daemon:                [  OK  ]
Stopping infrared remote control daemon:                   [  OK  ]
Starting infrared remote control daemon:                   [  OK  ]
Starting infrared command execution daemon:                [  OK  ]

You need to see the command execution has started OK.

Once you have done this, you should now be able to use the remote to control the projector. Reboot to make sure it all works and you should be good to go.

Enjoy.

Beep option

I didn't like having to wait for the projector to power up to know that I hit the power button. So I added a beep to the above scripts to let me know the remote sent the command.

Get the beep rpm

 $ cd /home/mythtv/misc/
 $ wget http://www.johnath.com/beep/beep-1.2.2-1rh71.i386.rpm

install it

# rpm -i /home/mythtv/misc/beep-1.2.2-1rh71.i386.rpm

edit the projector script

 emacs /usr/local/bin/projector-on.sh

add beep to the end of the script

#! /bin/sh
/usr/local/bin/projector -power
beep

If the beep option doesn't work, it's likely a permission problem. Open it up with this command.

chmod 4755 /usr/bin/beep

This should now beep when you hit the power button on the remote.