stbt.py: Support multiple lirc devices connected to the same host #9

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@szemate
Contributor
szemate commented Apr 18, 2013

To use multiple LIRC devices connected to the same host:

(1) Stop lirc service.

(2) Run multiple lircd instances, and set the TCP ports that each
device listens to:
sudo lircd --device=/dev/lirc0 --pidfile=/var/run/lirc/lirc0.pid --listen=8765 --output=/var/run/lirc/lircd
sudo lircd --device=/dev/lirc1 --pidfile=/var/run/lirc/lirc1.pid --listen=8766 --output=/var/run/lirc/lircd

lirc0 and lirc1 can be addressed individually using the assigned TCP
ports; but both send the received key codes to /var/run/lirc/lircd
therefore any of the two can be used as 'control_recorder'.

(3) Send keys the same way as to a Virtual Remote but with LIRC command
strings:
echo -e "SEND_ONCE humax MENU" | nc localhost 8765
It's also possible to output keys via a LIRC device of a remote computer.

To put both remotes into use by stb-tester, all we need is a new remote
type with "hostname", "port" and "remote_control_name" parameters that
uses 'VirtualRemote._connect()' to connect and 'LircRemote.press(key)'
to send keys.

@drothlis
Contributor

This is great news!

Comments inline on fa6c0d9.

@drothlis
Contributor
drothlis commented May 1, 2013

Once you've address my comment you can squash these up & resubmit by force-pushing to the same branch.

Unfortunately when you force-push, you lose all the history (including the comments) in the GitHub interface. I wonder if there's a way around that...

@drothlis
Contributor
drothlis commented May 2, 2013

Thanks. Please rebase onto the current master of drothlis/stb-tester.

@szemate szemate stbt.py: Support multiple lirc devices connected to the same host
To use multiple LIRC devices connected to the same host:

(1) Stop and disable lirc service:

sudo systemctl stop lirc.service
sudo systemctl disable lirc.service

(2) Run multiple `lircd` instances, and set the TCP ports that each
device listens to:

sudo lircd --device=/dev/lirc0 --pidfile=/var/run/lirc/lirc0.pid \
    --listen=8700 --output=/var/run/lirc/lircd
sudo lircd --device=/dev/lirc1 --pidfile=/var/run/lirc/lirc1.pid \
    --listen=8701

lirc0 and lirc1 can be addressed individually using the assigned TCP
ports.

(3) Send keys by sending a LIRC command string to the TCP socket:

echo -e "SEND_ONCE humax MENU" | nc localhost 8765

It's also possible to output keys via a LIRC device of a remote computer.

(4) To auto-launch lircd when a new device is attached, and auto-kill it
when the device is removed, add the following to
/etc/udev/rules.d/10-local.rules:

ACTION=="add", KERNEL=="lirc*", RUN+="/usr/bin/sh -c '/usr/sbin/lircd --device=/dev/$kernel --listen=$((8700 + $number)) --pidfile=/var/run/lirc/$kernel.pid 2>&1 | xargs -rL1 logger'"
ACTION=="remove", KERNEL=="lirc*", RUN+="/usr/bin/sh -c 'kill $(</var/run/lirc/$kernel.pid) 2>&1 | xargs -rL1 logger'"

Make sure not to break a rule to multiple lines.

It starts lircd listener on port (8700 + N) where 'N' is the device
number as in /dev/lircN. Errors are logged to /var/log/messages.

(These instructions were tested with Fedora 17.)

* * *

To put both IR devices into use by stb-tester, all we need is a new
remote type with "hostname", "port" and "remote_control_name" parameters
that uses 'VirtualRemote._connect' to connect and 'LircRemote.press' to
send keys. Similarly, for recording, a new listener type that uses
'VirtualRemote._connect' to connect and 'lirc_key_reader' to interpret
remote keys.
fa9034f
@drothlis drothlis added a commit that closed this pull request May 10, 2013
@szemate @drothlis szemate + drothlis stbt.py: Support multiple lirc devices connected to the same host
To use multiple LIRC devices connected to the same host:

(1) Stop and disable lirc service:

sudo systemctl stop lirc.service
sudo systemctl disable lirc.service

(2) Run multiple `lircd` instances, and set the TCP ports that each
device listens to:

sudo lircd --device=/dev/lirc0 --pidfile=/var/run/lirc/lirc0.pid \
    --listen=8700 --output=/var/run/lirc/lircd
sudo lircd --device=/dev/lirc1 --pidfile=/var/run/lirc/lirc1.pid \
    --listen=8701

lirc0 and lirc1 can be addressed individually using the assigned TCP
ports.

(3) Send keys by sending a LIRC command string to the TCP socket:

echo -e "SEND_ONCE humax MENU" | nc localhost 8765

It's also possible to output keys via a LIRC device of a remote computer.

(4) To auto-launch lircd when a new device is attached, and auto-kill it
when the device is removed, add the following to
/etc/udev/rules.d/10-local.rules:

ACTION=="add", KERNEL=="lirc*", RUN+="/usr/bin/sh -c '/usr/sbin/lircd --device=/dev/$kernel --listen=$((8700 + $number)) --pidfile=/var/run/lirc/$kernel.pid 2>&1 | xargs -rL1 logger'"
ACTION=="remove", KERNEL=="lirc*", RUN+="/usr/bin/sh -c 'kill $(</var/run/lirc/$kernel.pid) 2>&1 | xargs -rL1 logger'"

Make sure not to break a rule to multiple lines.

It starts lircd listener on port (8700 + N) where 'N' is the device
number as in /dev/lircN. Errors are logged to /var/log/messages.

(These instructions were tested with Fedora 17.)

* * *

To put both IR devices into use by stb-tester, all we need is a new
remote type with "hostname", "port" and "remote_control_name" parameters
that uses 'VirtualRemote._connect' to connect and 'LircRemote.press' to
send keys. Similarly, for recording, a new listener type that uses
'VirtualRemote._connect' to connect and 'lirc_key_reader' to interpret
remote keys.

Closes #9.
1ccc2b1
@drothlis drothlis closed this in 1ccc2b1 May 10, 2013
@drothlis
Contributor

@szemate: Did you test stbt record with --control-recorder using
tcp-style lirc? I couldn't get it to work. stbt record just doesn't
react to signals from the remote control. It sits at:

$ ~/bin/stbt record -v --control-recorder lirc:8700:humax --control lirc:8701:humax 
stbt-record: control-recorder connecting to lirc TCP socket localhost:8700...
stbt-record: control-recorder connected to lirc TCP socket
stbt-record: TCPLircRemote: Connecting to localhost:8701
stbt-record: TCPLircRemote: Connected to localhost:8701

Here's my setup:

/usr/sbin/lircd --device=/dev/lirc0 --listen=8700 --pidfile=/var/run/lirc/lirc0.pid --output=/var/run/lirc/lircd
/usr/sbin/lircd --device=/dev/lirc1 --listen=8701 --pidfile=/var/run/lirc/lirc1.pid

I can successfully send infrared signals with
echo -e "SEND_ONCE humax MENU" | nc localhost 8700 (and 8701).

@szemate
Contributor
szemate commented May 14, 2013

Did you test stbt record with --control-recorder using tcp-style lirc?

Yes I did. I will try it again and post a follow-up.

@szemate
Contributor
szemate commented May 15, 2013

@drothlis: may I ask you to try to run stbt record with --control-recorder=lirc:/var/run/lirc/lircd:humax using the released version of stbt? I have difficulties making it work too.

@szemate
Contributor
szemate commented May 15, 2013

@drothlis: Sorry, I found that I had problems with my Humax RCU. Please ignore #9 (comment).

@szemate
Contributor
szemate commented May 15, 2013

I could make it work but the instructions in the commit message are incomplete. (They work for stbt-run though.) Where do you think I should publish the complete set up instructions?

@szemate
Contributor
szemate commented May 15, 2013

The corrected step is the following (the --connect parameter was missing):

(2) Run multiple lircd instances, and set the TCP ports that each
device listens to:

sudo lircd --device=/dev/lirc0 --pidfile=/var/run/lirc/lirc0.pid \
    --listen=8765 --connect=localhost:8765 --output=/var/run/lirc/lircd
sudo lircd --device=/dev/lirc1 --pidfile=/var/run/lirc/lirc1.pid \
    --listen=8766 --connect=localhost:8766 --output=/var/run/lirc/lircd
@drothlis
Contributor

Where do you think I should publish the complete set up instructions?

How about an article on stb-tester.com?

Fork https://github.com/drothlis/stb-tester.com
write an article in reStructuredText
add it to the Makefile and to index.html.in
submit pull request. :-)

@drothlis
Contributor

I've written the article:
drothlis/stb-tester.com@413a61e

(And by "written" I mean I mostly copied @szemate's commit message.)

I won't publish it on http://stb-tester.com until the 0.13 release.

@dichen001 dichen001 referenced this pull request in dichen001/Paper-Reading Jun 28, 2016
Open

Summary of the 20 issues in Herbsleb's 2014 FSE paper. #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment