2

I'm developing a RPi application that uses an external IR remote with LIRC. For some reason when I press certain keys on the remote, like the number keys, characters get entered into my current command shell - whatever shell is active at the time.

Why is this happening and is there a way to disable it? It really threw me when I saw all these extra characters in the shell.

I've got an empty .lircrc file, so there should be no conflict there.

EDIT: I'm using Raspberry PI Raspian with a DELL USB keyboard hanging off it. The remote is RC6-based remote that I pulled away from a Hauppage TV Tuner card. The receiver device is an external IR component (TSO38238) that is tied directly to the GPIO pins.

3
  • 2
    What OS are you using? What type of keyboard are you using? What type of remote are you using (is it an MCE remote)? Dec 29, 2015 at 2:54
  • What device is it? If it is emulating a keyboard at all then that is what is happening! Does the receiver device (I'm assuming a USB dongle-type device) appear as a HID device - if it is a USB device what does lsusb tell you (and eventually us when you edit your question to inform us) about the device!
    – SlySven
    Dec 29, 2015 at 4:20
  • Added more details.
    – pathrider
    Dec 30, 2015 at 23:19

3 Answers 3

2

In the file, /etc/lirc/hardware.conf, remove the --uinput flag from LIRCD_ARGS.

0
systemctl stop lircd-uinput.service
systemctl disable lircd-uinput.service
1
  • 4
    Can you edit your answer and provide an explanation as to what your commands do? May 5, 2019 at 22:39
0

I'm having a similar issue. It doesn't matter whether I run a new kernel or an older one. The garbage is printed to the console (tty1) whether irexec is running or not. The hardware.conf file is no longer used, so that solution is out-of-date, although I think the ultimate solution has something to do with disabling uinput.

2nd UPDATE:

I found that the lircd-uinput.service is used to send keyboard events to /dev/uinput, basically to the console. This is a handy service if you want to use a remote to send a keyboard key to a custom menu or program running on the console. The problem with the service, is that it keeps repeating the key until it receives a release code. This behavior is by design, but it doesn't work for my application. I found an easy solution to the repeat problem, so now I can use the service to fake a keyboard using an ir remote.

To make the lircd-uinput.service register the release event automatically, and stop repeating the key, edit the service and add the --add-release-events option.

sudo nano /lib/systemd/system/lircd-uinput.service

####find this line####
ExecStart=/usr/sbin/lircd-uinput 

####change to#########
ExecStart=/usr/sbin/lircd-uinput --add-release-events

Restart the services and make sure they're active.

sudo systemctl force-reload lircd
sudo systemctl force-reload lircd-uinput
sudo systemctl status lircd
sudo systemctl status lircd-uinput

#I had to start lircd-uinput, since force-reload didn't: 
sudo systemctl start lircd-uinput

Now the service only enters one keypress for each remote button press.

I think this should be the default setting, otherwise, your application has to send a release code back to the lircd-uinput service, which may be a nice feature if you know how to do that.

To list all possible keyboard events supported by the kernel run:

irrecord -l

For example, if you want your remote to press the down arrow key on your console, the corresponding remote key is 'KEY_DOWN'. Then your remote file (/etc/lirc/lircd.conf.d/myremote.conf) would contain that key name.

begin remote

  name  myremote
 #<sniped...remote stuff here...>
      begin codes
 #    <sniped other codes>

          KEY_DOWN                 0x00FF

 #    <sniped other codes>
      end codes

end remote

Now that I figured out how to stop the repeating, this is a really useful service. I was able to set up a simple dialog menu and make a quick-loading, basic and responsive remote-controlled media player using a Pi Zero.

1st UPDATE:

I looked at the suggestion to disable the lircd-uinput.service and found that this corrects the problem. This is a good solution for my situation, as I don't need the uinput service, and this stops characters being sent to the console. I upvoted the other answer as it is a better solution than my original one. Your case may be different if you use the uinput service.

I'm not sure what uinput would be used for, but it sends characters to the console after a remote button is pressed. The problem is that the service keeps repeating the character indefinitely, even after you've stopped pressing the remote button. I don't know if this behavior is intentional or the service is faulty.

#solution if uinput is not needed for your application
systemctl stop lircd-uinput.service
systemctl disable lircd-uinput.service

ORIGINAL WORKAROUND (This is the workaround used before discovering that disabling uinput service corrects the problem):

The only workaround I've found is to disable both lircd and irexec services, and start them in a custom starup script.

#workaround
sudo systemctl disable lircd.service
sudo systemctl disable irexec.service

Create a custom startup service

sudo nano /etc/systemd/system/run-at-startup.service
##contents of /etc/systemd/system/run-at-startup.service
[Unit]
Description=Run script at startup after network becomes reachable
After=network.target

[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/home/pi/startup_script.sh
TimeoutStartSec=0

[Install]
WantedBy=default.target

Enable the new startup service

#set the execute bit (not sure if this is needed, but I do it anyway)
sudo chmod+x /etc/systemd/system/run-at-startup.service 
sudo systemctl enable run-at-startup.service

Create the startup_script.sh in /home/pi/

nano /home/pi/startup_script.sh
##contents of /home/pi/startup_script.sh
#!/bin/bash
/usr/sbin/lircd 
irexec -d /etc/lirc/irexec.lircrc
#put anything else after this you want to start
#set the execute bit
chmod+x /home/pi/startup_script.sh

Hardware and software info, occurs with either kernel, 5.4.71+, 4.14.34+, pizero, running console only, OS is Raspbian GNU/Linux 9 (stretch)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.