The recent commit c9afda9 added support for duty_cycle to the ftdi driver.
This worked for lircd config files that actually specified duty_cycle
but broke it for config files that didn't as it would default to 0 rather
than 50.
Before this commit it was the responsibility of each driver that implements
duty_cycle to know about this default. This fix centralises the defaults
in config_file.c, simplifying the drivers. As a result, even though this
patch is to fix a bug in ftdi it doesn't actually touch ftdi.c.
This issue didn't come up in testing c9afda9 because I'd only tested it
with config files that actually explicitly set duty_cycle. I've tested this
fix with both, but only with the ftdi driver.
hm... First of all: good catch!
That said, I'm not enterely happy with this patch. For better or worse, the overall convention in lircd.conf and the remote struct is that the value 0 reflects the default, unconfigured value. Furthermore, the lircd.conf manpage explicitly states the the configured value is between 1 and 100 i. e. , not 0.
I think it would be better if you kept the current handling in config_file.c and friends and instead parsed the value 0 in ftdix.c as 'unconfigured' i, e., 50 in the same way as the default driver. Some more text in lirc.conf.5 on this issue would of course also be great.
Ok. I figured that
duty_cyclewas likefreqin that it is a property of the carrier, thus should always be set, but I'm happy to change it. I still like the idea of centralising the default however so I'll make an accessor function inir_remote.hif that would be acceptable?An accessor providing the default value if it's set to 0? Looks reasonable. But if you do, please also update the default.c driver so it's used in a consistent manner.
Here's a patch implementing this with an accessor. Please don't apply it yet, I won't have a chance to test it until tomorrow.
I have tested Will's patch second patch ("0001-plugins-ftdi-Specify-duty_cycle-to-fix-ftdi-driver.patch" in the previous comment) successfully will all the following variations:
Thanks Dave
Thanks to both of you for a nice piece of work! Committed as [f164c8]
Related
Commit: [f164c8]