luci-app-p910nd: convert to JS
@jow- @hnyman @feckert
Comments welcome. There's a million ways one could implement this, but this is solid, and works well for me.
some eye-candy:


The interface cannot be displayed.

The interface cannot be displayed.
you've no printers connected? I've pushed a fix - can you re-test?
Still unusable. Sorry, I cannot connect to an available printer.

Perhaps it should be allowed to open the interface without connecting to the printer?
The app never connects to the printer. It only looks at the resources available.
Can you paste a copy of your dmesg kernel log which causes the error please?
I noticed that the script reads the /dev/usb directory, but that directory usually does not exist. After manually creating the /dev/usb directory, the interface can be displayed normally.

Ah. Good point. Although there's no reason to use this app if you haven't a USB printer.
Have you?
When I need an old printer, maybe I can use it.
Hmm. OK. I've pushed some fixes with more error handling for this case which you can test.
good.
@jow- so I took a good look at this before xmas. And as things are, it works well enough. It attempts to parse dmesg logs for current USB devices, but I think luci in general would benefit from a clean way of querying what USB devices are currently connected. Although as things are in 50_ script, some assembly is required.
The accompanying 50_ script attempts to load firmware for the specified USB ID, since there is no reliable way to pass those from config to the script yet. We verify the USB ID so we don't brick a printer with the wrong firmware. This is not strictly p910nd functionality, but it's very helpful.
If the underlying p910 were to expose a variable usbvidpid then... this would work to uniquely identify devices, and load firmwares, I think. The underlying p910 is where uci gets its info from? e.g.
uci get p910nd.@p910nd[0].device
I want to do:
USB_IDS=uci batch << EOI
get p910nd.@p910nd[0].usbvidpid
get p910nd.@p910nd[1].usbvidpid
get p910nd.@p910nd[2].usbvidpid
get p910nd.@p910nd[3].usbvidpid
get p910nd.@p910nd[4].usbvidpid
get p910nd.@p910nd[5].usbvidpid
get p910nd.@p910nd[6].usbvidpid
get p910nd.@p910nd[7].usbvidpid
get p910nd.@p910nd[8].usbvidpid
get p910nd.@p910nd[9].usbvidpid
EOI
Is that all set here?: https://github.com/openwrt/packages/blob/master/net/p910nd/files/p910nd.init ?