I've upgraded from Ubuntu 16.10 to 17.04, which is the first Ubuntu version including LIRC 0.9.4c-9, that includes support for IRToy out of the box.
After booting, the LED was always ON and a quick check revealed, that the device was put in flash mode having USB ID 04D8:FD0B instead of the normal operation mode 04D8:FD08.
Power cycling / re-pluging did not reactivate the device and i had to use the fw_update tool to perform a reset. The first time i reflashed the firmware because i thought it was broken but the 2nd time i only did a read:
The suggested command from the website "fw_update -reset -vid 0x04D8 -pid 0xFD0B" did not work and just gives "At least one command must be specified" as an error, so i though a simple read operation would be the least intrusive way, because all i needed was the reset function.
Now here's the nasty part. After disabling every LIRC service (about 3-4) within systemd other than the main lircd.service this behaviour went away and the device wasn't semi-bricked on every reboot. Also, just manually starting the LIRC daemon with the right option would also work fine. So it must be some additional LIRC related service or socket activation or whatever.
This behaviour was reproduceable with 2 different otherwise fully working IRToy devices. I highly doubt this is the fault of the hardware.
Since the Ubuntu LIRC packages are probably just imported from Debian, it could affect other systems too.
While its working it's always this: Device Status: 0x0000 (Bus Powered)
I notice others had this issue too but i think i've only noticed the Status change. It locks with all firmwares i've tried (21,22,23) but this could be the case only with 23. recently.
I've left it idle one whole day and it was still running until i accessed it 10 times. So assume i can rule any suspend stuff out and it's really an issue that only gets triggered by using it.
Virtually replugging the USB device using "ioctl(fd, USBDEVFS_RESET, 0)" on the device also works.
While this is easier than hardware based re-plugging, it's not suitable for automated use, because lircd dies and requires restarting too. This would result in nasty hacks unless it's called from within the usb_irtoy driver itself.
The device stops responding after a certain amount of successful operations. When reaching that state only a replug will fix it. Restarting the lirc daemon is not enough.
I first suspected some usb suspend but i noticed it was set off for that device. To be sure i booted with "usbcore.autosuspend=-1" kernel parameters. Also the amount of irsend requests seem more related to the problem than idle time.
Flashing firmware (v22), learning from a remote and similar operations worked just fine. After 6-15 times calling irsend it locks up and lircd dies off.
I suspeced some bad code in lircd at first, but the fact that a device replug is required, tells me that it's not in the daemon (it's just handling the event not gracefully enough).
lirc test client (executed with 1-2s pauses): ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power ~ # irsend SEND_ONCE PHILIPS_26PFL5604H Power (exit code 1 here)
lircd server daemon output: --------------------------------- # /usr/sbin/lircd -n -P /var/run/lirc/lircd.pid lircd-0.9.0[9471]: lircd(usb_irtoy) ready, using /var/run/lirc/lircd lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: removed client lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: removed client lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: removed client lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: removed client lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: removed client lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: removed client lircd-0.9.0[9471]: accepted new client on /var/run/lirc/lircd lircd-0.9.0[9471]: irtoy_getversion: couldn't read version lircd-0.9.0[9471]: please make sure you are using firmware v20 or higher lircd-0.9.0[9471]: usb_irtoy: No USB Irtoy device found at /dev/ttyACM0 lircd-0.9.0[9471]: Failed to initialize hardware lircd-0.9.0[9471]: select() failed lircd-0.9.0[9471]: Bad file descriptor Segmentation fault
GDB Output of lircd: ------------------------ Program received signal SIGTERM, Terminated. 0x00007ffff7a69235 in raise () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7a69235 in raise () from /lib64/libc.so.6 #1 0x0000000000406eed in waitfordata (maxusec=maxusec@entry=0) at lircd.c:1938 #2 0x000000000040761f in loop () at lircd.c:2022 #3 0x0000000000402839 in main (argc=<optimized out>, argv=0x7fffffffdd08) at lircd.c:2299