In a configuration file for a remote control, I use 'post' to send a pulse
(30 us) and a space (460 us) after the data, then ptrail for a trailing pulse.
The 'post' cannot be part of 'data' as the space of 'zero' and 'one' is 650 us
and 830 us (not 460 us). The pulse and space configured in 'post' is, however,
not sent, i.e., the 'post' directive is silently ignored.
Looking into the source code I found the issue in lib/transmit.c:
'post' (i.e., a pulse and a space of specific lengths) is only sent if also
'post_data' (i.e., a sequence of 'zero' and 'one') is configured. The function
send_post(remote) checks if has_post(remote) is true; this is only true if
remote->post_data_bits > 0.
Same applies to 'pre' and 'pre_data'.
This limitation is not described in the documentation
(see http://www.lirc.org/html/lircd.conf.html). Thus, I suggest to either
update the documentation or fix the code. I prefer the latter as I see no logic
why a directive should be ignored. I attach a patch.
For my specific use case, I have a workaround: I replace 'ptrail' by a single
bit 'post_data'. This only works because the 'ptrail' pulse happens to have
the same duration as the pulse of 'one'. Thus, I now have 'post_data' and
therefore 'post' is no longer ignored. My workaround results in having two
spaces at the end (the space of the 'one' from 'post_data' and the 'gap'); this
does no harm.
I have not found a generic workaround that can be used if the trailing pulse
has a different duration than 'one' and 'zero', nor for repeat sequences.
First of all, since the code and the docs don't match we need to fix one
of those.
The question then becomes why you have stumbled over this. Do you have a
usecase where this bug (be it in the docs or in the code) shows up?
Last edit: Alec Leamas 2018-02-14
This tiicket is a tracker for downstream bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890374
Two .conf files to further clarify the usecase (see first paragraph of the original bug report). zehnderheating.conf does not send the 'post' pulse and space. zehnderheatingworkaround.conf is a workaround (that is possible as the trailing pulse happens to have the same duration as data pulses).
I previously wrote on the mailing list
As a principle, I still think it is important not to change an old, relatively spread system, "just because" you have found some quirks. But in this case, the current behavior is highly bizarre: Under some circumstances, data (pre and post) are quietly ignored (instead of thowing a warning or an error). It is highly unlikely that any "old" behavior depends on this, but of course this has to be checked. (Are there any files in lirc-remotes that defines post/pre without post_data/pre_data? This can and should be easily checked.)
After this has been checked, I would approve the fix (to the sources).
The most natural work-aroung would be to use raw codes, IMHO.
Excellent idea to check the publicly available remotes for use of pre and post.
I downloaded today a snapshot from https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/ , then run the following two grep commands to search for pre and post with a pulse length >0 (in the square brackets is a space and a literal tab):
There is no output from the second grep command; in all remote definitions returned by the first grep is also a pre_data_bits >0.
Thus, a fix to the source should not break the existing publicly available remote configurations.
"pre/post" was originally meant to be a separator between "data" and "pre_data/post_data". If pre_data/post_data is empty of course no separator would be required. Please update the documentation accordingly. What initially was intended by the OP could probably be implemented using the "foot" field.
Last edit: Christoph Bartelmus 2018-02-18
The 'foot' field does in my opinion not allow the behaviour possible with 'post': 'data' ends with a space; the required bahaviour is a following pulse space pulse (and a long gap until the next IR key)
As per http://www.lirc.org/html/lircd.conf.html, 'data' is only followed (if we cannot use 'post' and 'post_data') by ptrail (only a pulse), foot (pulse space) and gap (only a space) => pulse pulse space space. I.e., there is no option for a space between two pulses.
First, I have updated the manpage (master) according to Christoph's remark: [60ed3b].
Secondly, I see nothing wrong in the basic usescase here. So, the question then becomes if we can support it without breaking any eggs - changing these things should certainly not be taken lightly. That said, are there any specific reasons against applying the patch from the downstream bug?
Of course, applying this must be tested using the regression tests. I might be able to find some time for this if this is the final roadblock.
EDIT: Multiple embarrasing typos, linking.
Related
Commit: [60ed3b]
Last edit: Alec Leamas 2018-02-23
The specific reason is that it is not required.
The usecase can perfectly be implemented using ptrail and foot (foot is sent as "space pulse"). pre and post are separators between two compontents. If one component does not exist, there is no need for a separator. Please add a warning as suggested by Bengt.
Cheers, Christoph
A few comments:
Sorry, even with the new version I do not think it is clear at all that post/pre is ignored if post_data/pre_data is empty. Secondly, consider also to change
I do. As I quoted, the exact semantics of the keywords is not considered public API, so strictly speaking, this is not a supported use case. If a rendering engine is required, use a such. Having said that, already documenting the keywords makes users want to use them. Fixing problems might still be considered.
It is bad programming to accept a parameter, and then quietly ignoring it. If pre/post is prohibited without pre_data/post_data, then the program should detect it and barf.
Summing up. I think more arguments speak in favor of the change than against. Unless if some comes up with something that really breaks...
I've tested this and fixing this doesn't break any lircd.conf file I can have. I think it makes sense to fix it - it's just very unexpected, I think.
Last edit: Sean Young 2025-07-06
Actually, I think the code is buggy. For receive, the pre is parsed if there are no pre_bits, same for post without any post bits.
So, transmit is buggy compared to receive. This should be fixed.
Fixed in commit 52550a56db638d521ddcb5ba6bc20389acf5f178
Actually it turns out, receive did not implement this. I've fixed the receive side in commit 1dc29314729f193b148d10f4ac575582d303ab24