luci icon indicating copy to clipboard operation
luci copied to clipboard

luci-app-p910nd: convert to JS

Open systemcrash opened this issue 4 years ago • 12 comments

Tested on: 21.02.1

Signed-off-by: Paul Dee [email protected]

systemcrash avatar Dec 15 '21 23:12 systemcrash

@jow- @hnyman @feckert

Comments welcome. There's a million ways one could implement this, but this is solid, and works well for me.

systemcrash avatar Dec 15 '21 23:12 systemcrash

some eye-candy:

Screenshot 2021-12-23 at 03 05 40 Screenshot 2021-12-16 at 00 36 35 Screenshot 2021-12-16 at 00 36 00 Screenshot 2021-12-16 at 00 38 09

Screenshot 2021-12-23 at 03 06 48

systemcrash avatar Dec 15 '21 23:12 systemcrash

The interface cannot be displayed. Snipaste_2021-12-23_19-38-45

zdz2019 avatar Dec 23 '21 11:12 zdz2019

The interface cannot be displayed. Snipaste_2021-12-23_19-38-45

you've no printers connected? I've pushed a fix - can you re-test?

systemcrash avatar Dec 23 '21 12:12 systemcrash

Still unusable. Sorry, I cannot connect to an available printer. Snipaste_2021-12-24_07-06-45

Perhaps it should be allowed to open the interface without connecting to the printer?

zdz2019 avatar Dec 23 '21 23:12 zdz2019

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?

systemcrash avatar Dec 25 '21 12:12 systemcrash

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.

Snipaste_2021-12-25_22-05-20

zdz2019 avatar Dec 25 '21 14:12 zdz2019

Ah. Good point. Although there's no reason to use this app if you haven't a USB printer.

Have you?

systemcrash avatar Dec 25 '21 14:12 systemcrash

When I need an old printer, maybe I can use it.

zdz2019 avatar Dec 25 '21 14:12 zdz2019

Hmm. OK. I've pushed some fixes with more error handling for this case which you can test.

systemcrash avatar Dec 25 '21 15:12 systemcrash

good.

zdz2019 avatar Dec 26 '21 00:12 zdz2019

@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 ?

systemcrash avatar Feb 24 '22 00:02 systemcrash