Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] HP officejet and scanner
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Frautoincnam
Apprentice
Apprentice


Joined: 19 May 2017
Posts: 294

PostPosted: Thu Jun 24, 2021 7:43 pm    Post subject: [SOLVED] HP officejet and scanner Reply with quote

Hi,

I have a server with a USB scanner connected, saned works and find my USB scanner (Epson).
On my clients, I juste have sane-backends and server hostname in /etc/saned/net.conf

On my server, I have cups working too, and using a network wireless HP printer (HP6100, no scanner)
All is fine here for years.

I just bought a HP Officejet pro 8023.
Cups found it, and I could add it to printers. All is ok here too.

I've managed to get my server seeing the scanner :
Code:
# scanimage -L
device `hpaio:/net/HP_OfficeJet_Pro_8020_series?ip=192.168.5.198' is a Hewlett-Packard HP_OfficeJet_Pro_8020_series all-in-one
device `genesys:libusb:001:002' is a Canon LiDE 120 flatbed scanner


but I can't get my clients seeing it, over my server saned :
Code:
$ scanimage -L
device `net:sane.novazur.fr:genesys:libusb:001:002' is a Canon LiDE 120 flatbed scanner


Everything I tried were unsuccessful.
I would not have to install hplip and certainly not to start saned on the client.

Any idea please ?

[SOLVED] hplip need to be patched to make sane hpaio net discovering. See below


Last edited by Frautoincnam on Fri Jun 25, 2021 1:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
Frautoincnam
Apprentice
Apprentice


Joined: 19 May 2017
Posts: 294

PostPosted: Thu Jun 24, 2021 8:07 pm    Post subject: Reply with quote

I can get it on the client by installing hplip with the USE scanner and snmp but, I think it doesn't go through the saned server saned.
Code:
$ scanimage -L
device `hpaio:/net/HP_OfficeJet_Pro_8020_series?ip=192.168.5.198' is a Hewlett-Packard HP_OfficeJet_Pro_8020_series all-in-one
device `net:sane.novazur.fr:genesys:libusb:001:002' is a Canon LiDE 120 flatbed scanner

I don't really know if it's worse or not.
And I find that it doesn't necessarily make a lot of sense to have to install hplip on every client.
What do you think please?
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2964
Location: Edge of marsh USA

PostPosted: Fri Jun 25, 2021 4:06 am    Post subject: Reply with quote

I think it makes perfect sense. Don't need saned on the client, but if you want to process the scan on the client, you need the software for each scanner on the clients. Are your clients remote to the server? Seeing the full domain name of the server in the scanimage -L output seemed strange. Here is mine, server is hostname "bethel" and client is on the LAN with the server.
Code:
$ scanimage -L
device `v4l:/dev/video0' is a Noname VGA Single Chip virtual device
device `net:bethel:epkowa:interpreter:002:004' is a Epson Perfection V500 flatbed scanner
device `net:bethel:epkowa:interpreter:002:004' is a Epson Perfection V500 flatbed scanner
device `net:bethel:hpaio:/usb/HP_LaserJet_3055?serial=00CNRK255240' is a Hewlett-Packard HP_LaserJet_3055 all-in-one

I think the Epson scanner is being recognized by both the net.conf and dll.conf. I get FOUR of them on the server; need some fine tuning. :-)
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 812

PostPosted: Fri Jun 25, 2021 5:22 am    Post subject: Reply with quote

By default the sane backend (i guess you are using hpaio at your server, provided by the hplip package) only makes it available to the sane server, it is set "local only" which means it doesn't get redistributed to other clients which connect to the server over the network.

I only way to change this that i'm aware of is with a small user patch I have for hplip. The latest version I have is for hplip-3.20.6 and saved in /etc/portage/patches/net-print/hplip-3.20.6/localOnly.patch:
Code:
diff -Naur hplip-3.20.6-org/scan/sane/hpaio.c hplip-3.20.6/scan/sane/hpaio.c
--- hplip-3.20.6-org/scan/sane/hpaio.c   2020-06-18 15:07:36.000000000 +0200
+++ hplip-3.20.6/scan/sane/hpaio.c   2020-10-27 23:08:41.729986029 +0100
@@ -368,7 +368,7 @@
 {
    DBG(8, "sane_hpaio_get_devices(local=%d): %s %d\n", localOnly, __FILE__, __LINE__);
    ResetDeviceList(&DeviceList);
-   DevDiscovery(localOnly);
+   DevDiscovery(0);
    *deviceList = (const SANE_Device **)DeviceList;
    SANE_Device*** devList;
    orblite_get_devices(devList, localOnly);


This forces "localOnly" to 0, effectively allowing network clients to use the scanner. If anyone has a better idea than to do this with a patch, please let me know :)
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Frautoincnam
Apprentice
Apprentice


Joined: 19 May 2017
Posts: 294

PostPosted: Fri Jun 25, 2021 1:48 pm    Post subject: Reply with quote

pa4wdh wrote:
By default the sane backend (i guess you are using hpaio at your server, provided by the hplip package) only makes it available to the sane server, it is set "local only" which means it doesn't get redistributed to other clients which connect to the server over the network.

Awesome !
You give me THE solution and in addition you prove that I am not crazy and that my reasoning holds up.
You are my savior !
Thank you so much.
After adding patch to server hplip, from the client :
Code:
$ scanimage -L
device `hpaio:/net/HP_OfficeJet_Pro_8020_series?ip=192.168.5.198' is a Hewlett-Packard HP_OfficeJet_Pro_8020_series all-in-one
device `net:sane.novazur.fr:hpaio:/net/HP_OfficeJet_Pro_8020_series?ip=192.168.5.198' is a Hewlett-Packard HP_OfficeJet_Pro_8020_series all-in-one
device `net:sane.novazur.fr:genesys:libusb:001:002' is a Canon LiDE 120 flatbed scanner

After removing hplip on the client :
Code:
$ scanimage -L
device `net:sane.novazur.fr:hpaio:/net/HP_OfficeJet_Pro_8020_series?ip=192.168.5.198' is a Hewlett-Packard HP_OfficeJet_Pro_8020_series all-in-one
device `net:sane.novazur.fr:genesys:libusb:001:002' is a Canon LiDE 120 flatbed scanner


This could be a very usefull choice option when compiling hplip.
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 812

PostPosted: Fri Jun 25, 2021 2:17 pm    Post subject: Reply with quote

I'm glad i could help, and no, you are not crazy :D

When i had this problem I could find discussions about that is reasonable to expect from saned point of view (if it's networked, don't pass it on to networked clients, probably to prevent loops) and from user point of view (it's connected to my server and i want to use it from my client).

Keep in mind that you'll have to patch hplip again when it updates, my experience in doing this for a few years now is that it's not hard but annoying :), sometimes there are other changes to the same file and the patch has to be changed.

Maybe it's nice to have a patch like this distributed with the ebuild and a use flag to control if it's applied :)
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Frautoincnam
Apprentice
Apprentice


Joined: 19 May 2017
Posts: 294

PostPosted: Fri Jun 25, 2021 2:33 pm    Post subject: Reply with quote

pa4wdh wrote:
I'm glad i could help, and no, you are not crazy :D

;)

Quote:
When i had this problem I could find discussions about that is reasonable to expect from saned point of view (if it's networked, don't pass it on to networked clients, probably to prevent loops) and from user point of view (it's connected to my server and i want to use it from my client).

I did find these answers after yours, but never before. Probably because of my badly turned request.

Quote:
Keep in mind that you'll have to patch hplip again when it updates, my experience in doing this for a few years now is that it's not hard but annoying :), sometimes there are other changes to the same file and the patch has to be changed.

Do not worry about that :)
I just put it in /etc/portage/patches/net-print/hplip
Code:
# cat /etc/portage/patches/net-print/hplip/hpaio_net_discorery.patch
diff -ur hplip-3.20.11.orig/scan/sane/hpaio.c hplip-3.20.11/scan/sane/hpaio.c
--- hplip-3.20.11.orig/scan/sane/hpaio.c        2020-11-29 20:03:52.000000000 -0400
+++ hplip-3.20.11/scan/sane/hpaio.c     2021-06-25 09:26:11.786204535 -0400
@@ -376,7 +376,7 @@
 {
    DBG(8, "sane_hpaio_get_devices(local=%d): %s %d\n", localOnly, __FILE__, __LINE__);
    ResetDeviceList(&DeviceList);
-   DevDiscovery(localOnly);
+   DevDiscovery(0);
    *deviceList = (const SANE_Device **)DeviceList;
    SANE_Device*** devList;
    orblite_get_devices(devList, localOnly);

And if it makes problem with futures versions, I'll adapt it easyly.

Quote:
Maybe it's nice to have a patch like this distributed with the ebuild and a use flag to control if it's applied :)

That's what I mean.

Thanks again !
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21630

PostPosted: Fri Jun 25, 2021 4:35 pm    Post subject: Reply with quote

This seems like the kind of option that should be configurable via a preferences file, rather than built into the program. Is the value of the parameter localOnly forced from higher up, or can it be influenced with the right configuration change?
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 812

PostPosted: Fri Jun 25, 2021 4:54 pm    Post subject: Reply with quote

I agree that would be the right thing to do, as far as i know it's not possible to do this with configuration. I only wrote the patch because i didn't see an other solution :D
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
Frautoincnam
Apprentice
Apprentice


Joined: 19 May 2017
Posts: 294

PostPosted: Fri Jun 25, 2021 4:55 pm    Post subject: Reply with quote

Hu wrote:
This seems like the kind of option that should be configurable via a preferences file, rather than built into the program.

It would indeed be the ideal solution
Quote:
Is the value of the parameter localOnly forced from higher up, or can it be influenced with the right configuration change?

I hope you're not asking me the question :D
In none of the discussions on the subject did I see the possibility of a run option and not a build option.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21630

PostPosted: Fri Jun 25, 2021 5:18 pm    Post subject: Reply with quote

The code snippet from pa4wdh shows that the value is a parameter to the function. Without digging into the code, it's not clear whether that parameter is hardcoded in the parent function, or passed down from somewhere that it could be configured.
Back to top
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 812

PostPosted: Fri Jun 25, 2021 8:18 pm    Post subject: Reply with quote

I also haven't checked the complete code, but the documentation doesn't mention it as a configuration option or commandline argument.
_________________
The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1530
Location: South America

PostPosted: Sat Jun 26, 2021 3:25 pm    Post subject: Reply with quote

Hu wrote:
[...] it's not clear whether that parameter is hardcoded in the parent function, or passed down from somewhere that it could be configured.

TL;DR it looks like it is hardcoded in the parent function.

As far as I can tell, sane_hpaio_get_devices() is a function of backend library libsane-hpaio. Library libsane from sane-backends loads libsane-hpaio using dlopen(), function sane_get_devices() from libsane calls sane_dll_get_devices(), and that iterates over all loaded backend libraries, calling their corresponding sane_<BACKEND_NAME>_get_devices() function.

Then, saned calls sane_get_devices() with localOnly == SANE_TRUE, and scanimage calls sane_get_devices() with localOnly == SANE_FALSE.

include/sane/sane.h
Code:
#define SANE_FALSE      0
#define SANE_TRUE       1
frontend/saned.c
Code:
static int
process_request (Wire * w)
{
// ...
  switch (current_request)
    {
    case SANE_NET_GET_DEVICES:
      {
        // ...
        reply.status =
          sane_get_devices ((const SANE_Device ***) &reply.device_list,
                            SANE_TRUE);
        // ...
      }
      break;
    // ...
    }

  return 0;
}
frontend/scanimage.c
Code:
int
main (int argc, char **argv)
{
// ...
  while ((ch = getopt_long (argc, argv, "-" BASE_OPTSTRING, basic_options,
                            &index)) != EOF)
    {
      switch (ch)
        {
        // ...
        case 'L':
        case 'f':
          {
            // ...
            status = sane_get_devices (&device_list, SANE_FALSE);
            // ...
            break;
          }
        // ...
        }
    }
// ...
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum