New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No code detected by next code() #10

Open
tripledee opened this Issue Jul 5, 2016 · 7 comments

Comments

Projects
None yet
6 participants
@tripledee

tripledee commented Jul 5, 2016

I try to build a rain sensor using 38 kHz IR transmitter/receiver. I set up the two components and installed LIRC and python-lirc on a Raspberry Pi (running Jessie Debian), and used irrecord to build a configuration (to mimick a TV IR Remote).

The LIRC configuration is OK, as I can use irsend or irw from the shell and get the appropriate code.

Using python-lirc from a small python script, I have no result. The lirc.nextcode() returns an empty list.

import lirc
lirc.init("myprog", blocking = False)  
while (True):
    try:
            list = lirc.nextcode()
            if len(list) != 0: print "match!"
    except KeyboardInterrupt:
            lirc.deinit()
            break;

The /etc/lirc/lircrc file is:

begin
  remote = myRemote
  button = KEY_UP          # what button is pressed on the remote
  prog = myprog    # program to handle this command
  config = KEY_UP # configs are given to program as list
  repeat = 0
end
@gnunicky

This comment has been minimized.

Show comment
Hide comment
@gnunicky

gnunicky Jul 28, 2016

Mee too the lirc.nextcode() returns an empty list. Why ? But irw work
$ irw
000000000000000a 00 BUT_0 car_mp3
000000000000000b 00 BUT_100 car_mp3
0000000000000008 00 BUT_VOL_UP car_mp3
000000000000000a 00 BUT_0 car_mp3
000000000000000b 00 BUT_100 car_mp3

gnunicky commented Jul 28, 2016

Mee too the lirc.nextcode() returns an empty list. Why ? But irw work
$ irw
000000000000000a 00 BUT_0 car_mp3
000000000000000b 00 BUT_100 car_mp3
0000000000000008 00 BUT_VOL_UP car_mp3
000000000000000a 00 BUT_0 car_mp3
000000000000000b 00 BUT_100 car_mp3

@tompreston

This comment has been minimized.

Show comment
Hide comment
@tompreston

tompreston Sep 5, 2016

Owner

Hi, I just received an email about this. What happens if you follow the example in the README exactly?

Have you tried looking into the function itself? It's only a couple of lines long: https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L218-L242

Perhaps the list isn't being built properly.

Owner

tompreston commented Sep 5, 2016

Hi, I just received an email about this. What happens if you follow the example in the README exactly?

Have you tried looking into the function itself? It's only a couple of lines long: https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L218-L242

Perhaps the list isn't being built properly.

@tripledee

This comment has been minimized.

Show comment
Hide comment
@tripledee

tripledee Sep 7, 2016

Hello,

When I follow the README example, I get the same problems: the nextcode() function always returns []. The same button presses are correctly seen by irw.

I didn’t understand why you asked my to look inside the function in the library… Should I modify it (how?) and then compile pylirc?

regards

Denis

Le 5 sept. 2016 à 20:55, Thomas Preston notifications@github.com a écrit :

Hi, I just received an email about this. What happens if you follow the example in the README exactly?

Have you tried looking into the function itself? It's only a couple of lines long: https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L218-L242 https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L218-L242
Perhaps the list isn't being built properly https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L232-L242.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #10 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ANH-qn1BgnFhJu6B5BZR6NKME9V_sUdRks5qnGWcgaJpZM4JE7Cq.

tripledee commented Sep 7, 2016

Hello,

When I follow the README example, I get the same problems: the nextcode() function always returns []. The same button presses are correctly seen by irw.

I didn’t understand why you asked my to look inside the function in the library… Should I modify it (how?) and then compile pylirc?

regards

Denis

Le 5 sept. 2016 à 20:55, Thomas Preston notifications@github.com a écrit :

Hi, I just received an email about this. What happens if you follow the example in the README exactly?

Have you tried looking into the function itself? It's only a couple of lines long: https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L218-L242 https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L218-L242
Perhaps the list isn't being built properly https://github.com/tompreston/python-lirc/blob/master/lirc/lirc.pyx#L232-L242.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #10 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/ANH-qn1BgnFhJu6B5BZR6NKME9V_sUdRks5qnGWcgaJpZM4JE7Cq.

@michaelarnauts

This comment has been minimized.

Show comment
Hide comment
@michaelarnauts

michaelarnauts Dec 12, 2016

I've noticed that nextcode() always returns [] on a keypress, unless you've defined a button for it in lircrc.

michaelarnauts commented Dec 12, 2016

I've noticed that nextcode() always returns [] on a keypress, unless you've defined a button for it in lircrc.

@tompreston

This comment has been minimized.

Show comment
Hide comment
@tompreston

tompreston Oct 24, 2017

Owner

Have you tried removing the comments in /etc/lirc/lircrc? As in issue #7 (comment)

Owner

tompreston commented Oct 24, 2017

Have you tried removing the comments in /etc/lirc/lircrc? As in issue #7 (comment)

@akkana

This comment has been minimized.

Show comment
Hide comment
@akkana

akkana Oct 24, 2017

I have the same problem: nextcode() function always returns []. I even wrote a script to take every key in my lircd.conf and add a stanza for it in .lircrc, so all the buttons would be defined, but it doesn't help: I still get [] every time. irw works fine and prints the name of each button when I press it, but I haven't found any way to get the same info from Python, short of running irw from subprocess and parsing the output.

akkana commented Oct 24, 2017

I have the same problem: nextcode() function always returns []. I even wrote a script to take every key in my lircd.conf and add a stanza for it in .lircrc, so all the buttons would be defined, but it doesn't help: I still get [] every time. irw works fine and prints the name of each button when I press it, but I haven't found any way to get the same info from Python, short of running irw from subprocess and parsing the output.

@inflexionist

This comment has been minimized.

Show comment
Hide comment
@inflexionist

inflexionist Jan 10, 2018

Hi @tripledee and @akkana. It seems to work fine for me. try moving the lirc.deinit() command into the try: rather than the except:

If you consider the output of irw, there is a count associated with long presses of buttons which increments. It seems that python-lirc interprets the first button press and offers the "config" arguments from your .lircrc file(as expected) and long presses are followed by multiple lines of empty lists []. if you do not deinitialize the socket every time you record a command, it will think that all subsequent presses are part of the original press. I used the following python script and it works great...

import lirc

while True:
    sockid = lirc.init("myprogram")
    code = lirc.nextcode()
    print (code)
    lirc.deinit()

producing the following output when I use the power button with different press durations:

['power, on']
['power, on']
[]
[]
[]
[]
['power, on']
[]
[]
['power, on']
[]
['power, on']

inflexionist commented Jan 10, 2018

Hi @tripledee and @akkana. It seems to work fine for me. try moving the lirc.deinit() command into the try: rather than the except:

If you consider the output of irw, there is a count associated with long presses of buttons which increments. It seems that python-lirc interprets the first button press and offers the "config" arguments from your .lircrc file(as expected) and long presses are followed by multiple lines of empty lists []. if you do not deinitialize the socket every time you record a command, it will think that all subsequent presses are part of the original press. I used the following python script and it works great...

import lirc

while True:
    sockid = lirc.init("myprogram")
    code = lirc.nextcode()
    print (code)
    lirc.deinit()

producing the following output when I use the power button with different press durations:

['power, on']
['power, on']
[]
[]
[]
[]
['power, on']
[]
[]
['power, on']
[]
['power, on']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment