Slinke Python Linux Support Tidbits
Eric Woudenberg
May, 2000
Here are a few collected goodies for people wishing to use the Nirvis
Slink-e box under Linux/Python. I have tested it with Python 1.5.2 and
Linux 2.2.14 and it runs fine.
Table of Contents
- User Manual
- Slink-e Controller Class in Python
- Standalone Slink-e Controller Program
- Connecting your Slink-e to Linux
User Manual
First, a Slinke user manual "for the
rest of us." It uses frames and dispenses with the java-script fold-up
Table of Contents buttons which didn't work right for me under
Linux/Netscape. I created it by running this python script in the Slinke
"help" directory.
Python Slink-e Controller Class
Next, a Python "Slinke" Class ("slinke.py") which can be
incorporated into Python programs for controlling a Slink-e device. It
can read-in and use Nirvis devices files. It can also read and write
simple Python "pickle" based code files if all you want to do is
memorize new remote codes and play them back.
Class Methods
To learn how to use this class, I recommend reading the
the "main" and "test" routines at the end of slinke.py, which are implemented with it.
Here is a listing of its public members:
- __init__(self, filename=None, dev='/dev/ttyS0', controlS=0, helpclass=None)
Initialize class, supply: button codes filename, serial device,
whether to use baseband (Control-S) coding, and a helper class (default helper:
"slinke_devfile", which handles Nirvis device files, the other option is
the "pickled_helper", which uses Python pickle format for storing the
internal codes table).
- id(self)
Ask Slink-e to report its firmware.
- learn(self, cmdname)
Wait for a button push on the remote and add it to the internal codes table under the given button code name.
- do(self, args)
Given a string of space separated button code names, send them to the Slink-e.
- set_delay(self, delay)
Set the intercode delay in seconds (default 0).
- txrx(self, cd, *args, port=None)
Send a Slinke-command (listing of commands is within program) and return its response. For
commands that use more than one port, a port number must be supplied.
- port_receive(self, port)
Receive the parallel port value.
- load(self, filename)
Load a button code file into the internal codes table.
- store(self, filename)
Store the internal codes table into a button code file (currently supports only pickle
format code files).
- set_debug(self, on)
Turn on simple debugging output (prints every recieved command)
Standalone Slink-e Controller Program
If the slinke.py Class program is run standalone, it functions as a
simple Slink-e controller. Here is the help message:
Slinke control program, usage:
slinke.py [options] learn | do | tty | test | nop [buttons]
commands:
learn <button> ; learn IR code from remote,
wait for button to be pressed and store it as <button>
do <button> [<button> ...]
; send IR codes, given button names
tty ; send IR codes read one per line from tty
options:
-s seconds ; set intercode delay (default 0s)
-f codefile ; set button code file (default 'device_files/Sony/dvd3.cde' or 'dvd.codes')
-S ; use control-S (baseband) coding
-P ; use simple pickle type helper class (supports 'learn' command)
buttons:
symbol names from button files
Examples
-
You can simply verify that your Slink-e is connected and happy with this command, which
returns the Slink-e firmware revision:
$ slinke.py nop
Slink-e Version 2.5
-
The "test" command runs a bit more elaborate test, using several
Slinke commands and returning info:
$ ./slinke.py test
Slink-e Version 2.5
Serial number: 1834c938c3c2b114
disabled port 0 1 2 3 4 5 7
enabled port 0 1 2 3 4 5 7
sample period 100.0 microseconds
timeout period 500 sample periods
minimum message length 14
transmit ports ff
receive ports 1
receive polarities ff
route list 0 0 0 0 0 0 0 0
carriers 7c 7c 7c 7c 7c 7c 7c 7c
handshaking 0
direction ff
parallel port data 0
- You can learn new remote codes easily. In a darkened room point
your remote at the Slink-e's IR receiver and type:
./slinke learn mybutton
then push a button on the remote. The program should exit after
you push the button on the remote.
You can then send it to a device within range of the Slinke's IR transmitter
by typing:
./slinke do mybutton
All the codes are kept in Python "pickle" format in the file
'mycodes.pickle', if you want to store or retrieve them using a
different file, use the '-f' switch. If you specifiy a Nirvis codes
file (with a '.cde' extension) you will be able to 'do' button
commands, but not learn new ones, since the slinke_devfile helper class does
not know how to create entries in a Nirvis .cde file.
Connecting your Slink-e to Linux
It is important to follow the Nirvis directions for making the serial
connection. Here are some points to bear in mind.
- You must connect the CTS (clear to send) flow control line, otherwise you will overflow the Slink-e's internal buffer and things will not work.
- The control program must turn on RTSCTS handling
(for the reason listed in 1). Slinke.py does this for you with an
"stty" command during initialzation.
- I connected the Slink-e to /dev/ttyS0, you will need to change
slinke.py if you use a different port for your serial connection.
- I found that my Slink-e would receive spurious codes
occasionally, especially in sunlight or with bright fluorescent
lights. The slinke.py software is designed to ignore them in general,
but it can get confused if you are trying to learn new codes. I found
it easiest to keep black tape over the IR reciever port and uncover it
whenever I needed to learn new codes.
Good luck! I hope you find this helpful, and of course I'm
always interested in your
comments.