pepijntje02
Posts: 18
Joined: Mon Jan 04, 2016 6:55 pm

[Solved] Flirc in python

Tue Aug 16, 2016 10:23 am

Hello,

at the moment I try to connect a FLIRC USB with my raspberry pi. I am not using any media player like XBMC. I want to use the input of the remote to start some parts of a program written in python.

I created a small script using pygame to catch all keyboard input. This works fine for my keyboard, but not when I try to catch the signals from the FLIRC USB. I thought that the USB will give keyboard commands.

I have installed and imported LIRC for python. I have configured the FLIRC USB on my laptop using the flirc software. I am not able to see any input from the USB, so this is not working.

When I search on the internet all information about the FLIRC USB is about the configuration of the USB with XBMC of some other media center.

I hope someone know how to deal with this stuff.

Kind regards,
pepijntje02
Last edited by pepijntje02 on Wed Aug 17, 2016 2:05 pm, edited 1 time in total.

User avatar
hansotten
Posts: 341
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: Flirc in python

Tue Aug 16, 2016 2:10 pm

If I understand the FLIRC specs it behaves as a HID device after programming it.

This means you assign keycodes to IR remote buttons.

Have you tried something simple: program a key IR remote key for example as 'A', plug in the FLIRC in the USB port and see if the A character appears on the commandline?
(full keybaord mapping http://www.howtogeek.com/217587/how-to- ... ia-center/ )
http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu

DieOma
Posts: 86
Joined: Mon Aug 03, 2015 4:02 pm

Re: Flirc in python

Tue Aug 16, 2016 2:42 pm

Hi,

I recently worked on Flirc and nothing happened until I added Flirc on the device tree

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Uncomment this to override the defaults for the lirc-rpi module
#dtparam=gpio_out_pin=16
#dtparam=gpio_in_pin=17
#dtparam=gpio_in_pull=down

did you do that?

User avatar
hansotten
Posts: 341
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: Flirc in python

Tue Aug 16, 2016 7:19 pm

Flirc usb is a diffeent device, to be inserted in the usb port, as HID device, keyboard. So lirc is not applicable.
http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu

pepijntje02
Posts: 18
Joined: Mon Jan 04, 2016 6:55 pm

Re: Flirc in python

Wed Aug 17, 2016 7:57 am

Hello,

thanks for your response. I tried to configure the FLIRC on my laptop with the FLIRC software. I tried to configure the buttons and I tried to configre some buttons as key-board keys. This did not work.

I did not install something for FLIRC or something else on the raspberry pi. I think that there is something missing. The part about the device tree I do not understand, sorry.

But I have installed lirc (not configured), but as you say that will not help to get the FLIRC keys in my python script?

I tried to install kodi to see if the remote is working there, but I am not able to run kodi from the RPI over ssh/vnc. I only have a laptop so there is no possibility to connect a screen (I think that that is the problem with kodi from raspbian).

I have tried the same program on my laptop with the FLIRC USB and then it works fine. So I think the raspberry pi do not recognize the USB, but I do not know what I have to install or configure on the PI itself to recognize the USB as input device?

DieOma
Posts: 86
Joined: Mon Aug 03, 2015 4:02 pm

Re: Flirc in python

Wed Aug 17, 2016 9:23 am

http://python-evdev.readthedocs.io/en/l ... orial.html


Hi, this is the tut for evdev. Seems to be a good Library

User avatar
hansotten
Posts: 341
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: Flirc in python

Wed Aug 17, 2016 10:11 am

pepijntje02 wrote:Hello,

thanks for your response. I tried to configure the FLIRC on my laptop with the FLIRC software. I tried to configure the buttons and I tried to configre some buttons as key-board keys. This did not work.

I did not install something for FLIRC or something else on the raspberry pi. I think that there is something missing. The part about the device tree I do not understand, sorry.

But I have installed lirc (not configured), but as you say that will not help to get the FLIRC keys in my python script?

I tried to install kodi to see if the remote is working there, but I am not able to run kodi from the RPI over ssh/vnc. I only have a laptop so there is no possibility to connect a screen (I think that that is the problem with kodi from raspbian).

I have tried the same program on my laptop with the FLIRC USB and then it works fine. So I think the raspberry pi do not recognize the USB, but I do not know what I have to install or configure on the PI itself to recognize the USB as input device?
Hi,

I just performed a simple experiment with my FLIRC:

1. On the PC with the FLIRC program. Full keyboard config, I recorded a key on my IR remote and assigned it to keyboard 'a'
2. Installed the FLIRC on the Pi (a recent Jessie) and checked if the FLIRC was detected:
$ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 20a0:0001 Clay Logic

The last one is the FLIRC device

$ usb-devices
..
T: Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#= 4 Spd=1.5 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=20a0 ProdID=0001 Rev=01.00
S: Manufacturer=flirc.tv
S: Product=flirc
C: #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=01 Driver=usbhid
I: If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)

So FLIRC is detected as USB HID device. Pressing the IR key delivers a 'a' on the screen. FLIRC works fine on the Pi!

Note that if you work via remote access to your Pi it will not see FLIRC (or any local keyboard/mouse!) as input device, only your remote keyboard.
Only on the console it will work as keyboard device.

FLIRC is this device:
/dev/input/by-id/usb-flirc.tv_flirc-event-kbd
http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu

pepijntje02
Posts: 18
Joined: Mon Jan 04, 2016 6:55 pm

Re: Flirc in python

Wed Aug 17, 2016 11:14 am

Hello,

thanks for your response.

I can see my FLIRC device with both commands, lsusb and usb-devices.

What I want to try is to create a program and that I can put the raspberry in a place and I can send commands to it using the remote. For example, when the raspberry is connected to a relay I want to use the remote to turn on or of the relay on a specific GPIO pin. This is thus the same as a web-app, but then with the remote.

I understand what you mean with that the remote is not recognized because I use vnc, this is the same for my mouse (I just tested it). Do you know a way to use the remote for my programs and that it is recognized as an input device?

thanks for your help so far, now I know that it is recognized but that the remote asses is the problem! :(

User avatar
hansotten
Posts: 341
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: Flirc in python

Wed Aug 17, 2016 11:49 am

http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu

pepijntje02
Posts: 18
Joined: Mon Jan 04, 2016 6:55 pm

Re: Flirc in python

Wed Aug 17, 2016 12:21 pm

Thank you very much. This works fine now!

I have to make it better and I have to teach myself how it actually works, but I get signals so now it time to learn and play.

I think that there is a lot of noise on the signal, since I get the same code for different buttons, but I think that that is noise from the remote or the control, but I have to find out how to deal with it.

As I said, it works for now, thank you very much now I can finally use the remote on my pi! :D

thank you!

Return to “Advanced users”