Skip to contentSkip to conversation

General question about IR remote signals from USB DVB tuner

DISCUSSION Jan Panteltje 2 participants 2 messages Feb 10, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

I recently bought a Terratec cinergy S2 USB HD receiver.
I got everything working just fine in Linux and get excellent reception.
This thing came with a small remote controller, and I notice that the output of this remote appears as ASCII characters on stdin, on any terminal that I open...
Wrote a small GUI application that sets the input focus to a hidden input field, and can process the numbers from this remote that way, but of course this only works if the mouse has selected that application.

Thinking about this I think that the driver dumps the received remote control characters simply to stdout.
If this is so, does there perhaps exists a /dev/dvb/adapterX/remoteX interface in the specs so I could modify that driver to send the codes there?
If not how about adding such a thing?
The application can then in a separate thread for example open this device and use those codes.
This little remote has it all:
numbers 0 to 9, ENTER, channel up /down, power, mute, EPG,
volume, what not.
Sorry I a am bit rusty, been many years since I did any programming for DVB, so may be this already exists?
So much seems to have changed.

Any suggestions would be appreciated

#1 lore raw
Quoted 11 lines · On Fri, 10 Feb 2012 08:34:49 -0800 (PST) Jan Panteltje <[email protected]>…

I recently bought a Terratec cinergy S2 USB HD receiver. I got everything working just fine in Linux and get excellent reception.
This thing came with a small remote controller, and I notice that the output of this remote appears as ASCII characters on stdin, on any terminal that I open...
Wrote a small GUI application that sets the input focus to a hidden input field, and can process the numbers from this remote that way, but of course this only works if the mouse has selected that application.

Quoted 2 lines

Thinking about this I think that the driver dumps the received remote control characters simply to stdout.

Something fairly low level processes the input events and converts them to keyboard events. IIRC this happens on the console as well as in X.

Quoted 3 lines

If this is so, does there perhaps exists a /dev/dvb/adapterX/remoteX interface in the specs so I could modify that driver to send the codes there?

The events can be read from /dev/input/eventX. You can do something like parse /proc/bus/input/devices to work out which device corresponds to your remote. The structure of the events etc is defined in /usr/include/linux/input.h. The EVIOCGRAB ioctl is useful to grab the events exclusively for your application and stop them appearing on the console.

I don't know exactly what the fields in input_event are supposed to mean, and IME their significance can vary with remote and with kernel version. If you can find more information about this, please send a copy to me because I'm about to unsubscribe from linux-media. If you can't find the information you'll probably find it useful to experiment with the attached python script (treat as Public Domain).

#!/usr/bin/env python

import os
import struct
import sys

SIZEOF_INPUT_EVENT = struct.calcsize('llHHi')

# time (2 * long), type, code, value

quiet = False

def main_loop(fd):

    while True:
        s = os.read(fd, SIZEOF_INPUT_EVENT)
        if len(s) != SIZEOF_INPUT_EVENT:
            print >>sys.stderr, "Read %d bytes, expected %d" % \
                    (len(s), SIZEOF_INPUT_EVENT)
            break
        [tsec, tusec, type, code, value] = struct.unpack('llHHi', s)
        if not quiet or type:
            print "T:%10.2f t:%02x c:%02x v:%02x" % \
                    (tsec + float(tusec) / 1000000, type, code, value)

def main():
if sys.argv[1] == '-q':
global quiet
quiet = True
filename = sys.argv[2]
else:
filename = sys.argv[1]
fd = os.open(filename, os.O_RDONLY)
main_loop(fd)

if __name__ == '__main__':

    main()