I will summarize quickly and then describe in details:
Summary:
On boot when the printer is turned on udev uploads the firmware and printing is fine. In the started linux environment I can manually upload the firmware and printing is fine. When the printer is restarted udev uploads the firmware, the printer indicates that, but I can't print - in /var/log/messages I get -"error -110 reading printer status".
With all details:
I use a HP1018 printer with a properly yum-installed foo2zjs driver and manually downloaded firmware copied in "/usr/share/foo2zjs/firmware/sihp1018.dl".
The firmware has to be loaded on printer start (before printing) with
cat /usr/share/foo2zjs/firmware/sihp1018.dl > /dev/usb/lp0
and it all works great after this step. In order to automate the process I load the firmware with udev rule:
/etc/udev/rules.d/51-hp1018-firmware.rules
Code:
# udev rule for uploading the HP1018 firmware
# the ATTR{dev}=="180:0" should be enough in order not to confuse the HP1018 with some other HP printer
# Note that the KERNEL and NAME keys haven't been used, because in this way 50-udev.rules performs its rules on lp0, usb/lp0, par0, etc. and the 51-hp1018-firmware.rules is used as well)
SUBSYSTEM=="usb", ATTR{dev}=="180:0", RUN+="/usr/bin/hp1018-load-firmware"
and the script
/usr/bin/hp1018-load-firmware
Code:
LIMIT=9
for printer in /sys/class/usb/lp* ; do
output=$(udevinfo -a -p $printer | grep 'ATTR{dev}=="180:0"')
if [ ! -z "$output" ]; then
devpath="/dev${printer:10}"
echo "found HP1018 on $devpath, uploading firmware"
cat /usr/share/foo2zjs/firmware/sihp1018.dl > $devpath
fi
done
exit
The rule detects the printer every time - on startup and after that. I can clearly see that, because when a firmware is loaded, the printer "reinitializes" - performing its mechanical startup routines.
And I end up like that:
-> If I don't use the rule and run the script manually after I've started the printer everything is ok. I can start/restart the printer and manually execute the script every time - it's ok.
-> If the printer is started and I reboot/boot up the computer with the udev rule activated, the firmware is being uploaded and when fedora starts printing is ok.
(Note that in the both cases above if a previous firmware was loaded it's being overwritten and there is no problem with that)
-> if I start/restart the printer with fedora already running and I use the udev rule the firmware is being loaded but I can't print -> in /var/log/messages I get "usblp error -110 reading printer status" but CUPS marks all jobs as completed. I can't upload the firmware manually - although /dev/usb/lp0 isn't used by any process, when I "cat..." the firmware the terminal "freezes" with no error message, I have to Ctrl+C to get back.
(Note that if I comment only the "cat /usr/share/foo2zjs/firmware/sihp1018.dl > $devpath" line in the script, restart the printer and execute it manually "cat /usr/share/foo2zjs/firmware/sihp1018.dl > /dev/usb/lp0" everything is fine again!)
So my question is: What could provoke this weird udev behavior, and is there something about udev rules in runtime that I'm missing?