Log in

View Full Version : MPC-HC and WinLirc / Unwanted key repeats / Advise needed


NanoBot
3rd December 2011, 20:40
Hi everbody,

today, I built me an IR receiver for WinLirc and it is working like it should. Nevertheless I ran into a problem when I tried to use my Sony RM-AAU017 remote controller together with Media Playyer Classic HC.

I can start, pause and stop a movie without problems, but if I want to jump to the next or to the previous chapter, mpc-hc does not just jump one chapter, instead it jumps at least two chapters. If I keep the defined key on the remote controller pressed, it even jumps the chapters foreward or backward constantly until it reaches the end of the media file or I release the key.

The problem is that this remote transmits not a single signal when pressing a key, rather then transmitting a continues signal always repeating the same code. Until now I was not able to configure either WinLirc or mpc-hc to honor just the first signal and to ignore all repeats.

Does anyone has a advise for me how to solve this problem ? And what is the meaning of the field "RepCnt" in the key defintion window of mpc-hc ?

C.U. NanoBot

dukey
3rd December 2011, 21:57
Hi NanoBot, I am actually the winlirc author ... :)
Just disable key repeats in Winlirc, or set disable the first few key repeats. So it'll register your first button press, then throw away the next 2 or 3 of the next key repeats. It stops exactly this problem.

NanoBot
3rd December 2011, 22:47
Hi dukey,

thanks for the quick answer, but I already tried this setting and it does not help.

With "Disable all repeats" ticked on and holding the button pressed, WinLirc sends the following to the WinLirc clients:


000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
.....


So every message is marked as a "new" message, and mpc-hc of course jumps to next chapter again and again.

With "Disable all repeats" ticked off and mpc-hc inaktive ( no movie loaded ) and holding the button pressed, the following messages are sent:


000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 3 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 4 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 5 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 6 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 7 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 8 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 9 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 a Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 b Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 c Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 d Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 e Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 f Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 10 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 11 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 12 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 13 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 14 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 3 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 4 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 5 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 6 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 7 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 8 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 9 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 a Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 b Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 c Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 d Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 e Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 f Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 10 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 11 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 12 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 13 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 14 Next D:\Utils\WinLirc\Sony.conf
...


so the first message is the original, the next is the first repeat, then the second repeat etc., so the same keycode is repeated 20 times. After that, a new "original message" is sent. This looks ok to me, since I think it is the WinLirc clients task ( mpc-hc here ) to react only to the "original" message and to ignore the repeats.

Strange to say, if mpc-hc is active ( playing a movie ), the data with "Disable all repeats" ticked off and holding the button pressed changes to that:


000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 3 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 4 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 3 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 4 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 5 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 6 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 7 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 8 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 9 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 a Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 3 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 4 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 5 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 6 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 3 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 4 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 5 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 6 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 7 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 0 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 1 Next D:\Utils\WinLirc\Sony.conf
000000000008cb92 2 Next D:\Utils\WinLirc\Sony.conf
...


and after my opinion that is not ok, in particular, there must be no two messages with the "0" at all when holding the key. Instead, the repeat counter should advance from 0 to 0x14 like in the second log. So for some reason the repeat counter starts "to early" from 0 instead of the normal 20 repeats.

So I do not know if I am able to solve the problem without a modification within mpc-hc itself. If more logfiles / configfiles can be helpful to solve the problem please let me know.

C.U. NanoBot

dukey
3rd December 2011, 23:51
The problem with serial plugin is, if your CPU is busy, it can break the timing a little (since it's done on the cpu) so it can effect accurate decoding of the signal. Try recording a new config or messing with the signal gap value in the config. Failing that get something like the IRToy, it should be a drop in replacement for the serial receiver. It does the timing on the receiver itself, so high CPU load won't cause problems.

NanoBot
8th December 2011, 20:45
Hi dukey, hi everybody

neither recording a new config nor changing the value of the signal gap worked for me. Nevertheless I did some tests which for showed a possible solution.

At first, I tested the situation with another remote control, which belongs to my DVB-C card ( Twinhan / Azurewave ). This remote only transmits one single pulse when a key is pressed, even if the key is hold permanently. As expected, WinLirc together with mpc-hc are working perfect when using this remote, e.g. pressing the "next chapter" or "previous chapters" buttons always results in skipping exactly one chapter forward or backward. Only releasing the button and pressing it again makes mpc-hc to skip another chapter backward or forward, like it should be.


After that, I fired up xubuntu 10.10, installed the original "lirc" package and created the following "~/.lircrc" config file:


begin
remote = Sony
button = KEY_NEXT
prog = irexec
delay = 30
repeat = 0
config = echo "Vorwärts"
end

begin
remote = Sony
button = KEY_PREVIOUS
prog = irexec
delay = 30
repeat = 0
config = echo "Rückwärts"
end


And this configuration works exactly like it should, even with the Sony remote controller, which sends a countinues signal, whenever a button is pressed and hold permanently:

Only the first IR signal received by the lirc deamon results in a message send to irexec, therefore irexec outputs "Vorwärts" or "Rückwarts" exactly one time for each keypress. Only if the button is released and pressed again, another message is send to irexec, executing the appropriate echo command again.


Since Winlirc does not seem to have an equivalent to the .lircrc config file, I think a modification within the Winlirc client itself, here mpc-hc, would be neccessary to achieve the same behaviour as I found in linux using .lircrc and irexec ?

As far as I understand it, the WinLirc client must not rely on the "repeat counter" within the messages send from WinLirc, because the repeat counter might be unrealiable due to timing problems. Instead, the client would have to determine the time elapsed between two incoming identical messages from WinLirc by itself, and if the elapsed time is below a given delay value, the repeated message(s) must be ignored.

If my thoughts are correct, can anybody please tell me, in which part of the mpc-hc source the evaluation of incoming WinLirc messages is done ? I am really not a good programmer, but perhaps I could try to implement the functionally to ignore the repeated keys by myself.


Remark: English is not my native language, so if you have problems to understand the meaning of my thoughts and conclusions, please ask for a clarification :rolleyes:


C.U. Nanobot