SULDR Forums Supported Printers Printing Questions Scanning Questions General Questions Samsung Installer

Scan to PC in Linux (Development)

Started by angelnu, December 20, 2012, 07:00:41

Previous topic - Next topic

angelnu

Ok, then I will let my setup using 4.0.39.

I think that this time I registered correctly to receive notifications for this thread so that I am informed of updates/problems of other users. If I did not not I guess that I will notice next time I have to install a new computer at home ;-)

rombas

Hello,

could somebody help me to find out why ScannerServer cannot connect to Saned? The package was installed from a repository.
I can perform scanning with Sane client from Windows without issues. First notice is that ScannerServer tries to connect to 80 port instead of 6566.
Well, I configured Saned to run on 80 port, also tried several options in configuration but without success. All details are in the attachment.

Thank you in advance.


angelnu

Hi,

the scannerServer packages is only for those scanners that have a screen and allow to trigger the scan directly from the scanners. For theses scanners the scannerServer package connects to the web interface (therefore port 80) to find out when you press the "scan" key and what settings you selected. Afterwards it uses Sane to scan the page.

Does Sane work for you from Linux? Can you trigger scann from your Samsung scanners that end as file in your PC?

rombas

Thank you for the quick response.

Does that mean that Scanner must have web interface and ethernet or wireless port?
My device SCX-3405 has USB port only, but it also has a panel with a button "Scan to". If I connect this
scanner to Windows machine, where Samsung Easy Print Manager runs, I can click "scan to" and "start"
on the device, and scanned image arrives to Windows folder. I would want the same functionality with Linux
server.
I can do the scanning through Sane already:
1) using Xsane on the same Linux server (direct USB connection or via IP);
2) using SaneTwain interface from Windows (via IP)
But "Scan to" button doesn't work with Linux machine. Can ScannerServer help here?

angelnu

The scanerServer is for scanners connected via network only so it will not work if you connect your scanner via USB.

Supporting a USB connected scanner will require the reverse-engineering of the USB protocol. If your scanner just have a key to trigger the scan then maybe the following tool works for you: http://scanbuttond.sourceforge.net/ There is an (old) tutorial at http://archive09.linux.com/feature/59138

rombas

Tried scanbuttond. Unfortunately, Samsung is not supported there.
BTW, thanks for your support.


smika

#36
Sorry fot this post. I see that my other post was moved.

totally-king

Thanks a lot to angelnu and bchemnet for your support and effort! And sorry I was leaving you alone lately. Well, the thing is I don't always have an MFP to test scantopc with, since I wrote this program mainly for my partner, who is living in another town. But now I'm back. ;)

Now v0.4.2:

I did a few bugfixes (compatibility to modified sane method was broken), and made some changes to the GUI part, so that it works with angelnu's improvements of the server backend and doesn't print out fuzzy messages. (= (See binary files destined for /usr/bin in attachment.)

The package description of suldr-scantopc-gui still refers to samsungmfp-scantopc, this should be updated to suldr-scantopc.

Also I would appreciate having the changelogs within the deb files as I originally implemented them (see attachment). When I created the deb packages I just renamed them to changelog and put them in the debian folder.

And maybe one could add a postinst routine to suld-scantopc-gui that disables the automatic startup (at bootup) of the server backend, since most people would probably use this package on desktop PCs and don't need the server running in background all the time. Like:

sudo update-rc.d -f samsungScannerServer remove

And of course the corresponding postrm code:

sudo update-rc.d samsungScannerServer defaults


I don't know really know how, but couldn't one ensure that suld-scantopc-gui always gets removed before suld-scantop, so no problems regarding these new routines arise?

angelnu

Welcome back total-king :-)

Sorry for breaking your extensions: apart from syntax errors there is few I can do...

About starting the service by default: I would expect that only people wanting this feature will install the package. The default settings should work after the installation so ideally people would just need to install the package and do nothing else.

bchemnet

Quote from: totally-king on July 27, 2013, 12:59:02
I did a few bugfixes (compatibility to modified sane method was broken), and made some changes to the GUI part, so that it works with angelnu's improvements of the server backend and doesn't print out fuzzy messages. (= (See binary files destined for /usr/bin in attachment.)

The package description of suldr-scantopc-gui still refers to samsungmfp-scantopc, this should be updated to suldr-scantopc.

I'll incorporate these into the package in a few days, I'm away from my main system at the moment.

Quote from: totally-king on July 27, 2013, 12:59:02
Also I would appreciate having the changelogs within the deb files as I originally implemented them (see attachment). When I created the deb packages I just renamed them to changelog and put them in the debian folder.

The changelogs are present.  I just moved them into /usr/share/doc/<package-name>/ according to the Debian standard.  I will merge the versions you included with the ones I was updating.  However, placing them in /debian/ is technically incorrect, because then they end up in the system control directory when the package is installed.  I also compressed them (again according to the standard), but I'm okay with leaving them uncompressed if you prefer.

Quote from: totally-king on July 27, 2013, 12:59:02
And maybe one could add a postinst routine to suld-scantopc-gui that disables the automatic startup (at bootup) of the server backend, since most people would probably use this package on desktop PCs and don't need the server running in background all the time. Like:

sudo update-rc.d -f samsungScannerServer remove

And of course the corresponding postrm code:

sudo update-rc.d samsungScannerServer defaults


I'll look at this, but my immediate response is similar to angelnu's - that people installing this package probably expect it to always be running (in the sense of not wanting to think about whether or not it is).  And I think defaulting to leaving it always running is probably correct, as it does not really interfere for those who don't need it while still allowing flexibility for those who do.  If a good argument could be made for either case, I can provide another package of the gui that disables running the server, or create a configuration prompt.  That would allow the user to choose.

Quote from: totally-king on July 27, 2013, 12:59:02
I don't know really know how, but couldn't one ensure that suld-scantopc-gui always gets removed before suld-scantop, so no problems regarding these new routines arise?

This is possible, I can implement it if necessary.

FYI, the scantopc package has been downloaded about 300 times in the last 2 months, and nearly all of those users also download the gui package.  However, since the forums are so quiet about these packages, I don't know how many are actively using it.  Or if it "just works" for most, or if it is failing regularly.  There definitely seems to be some interest, though.

totally-king

I agree with both of you, if the scantopc package is installed alone.

But when the GUI package is added I think it is better to refrain from automatic startup of the service. The GUI (ubuntu App Indicator) I wrote starts the server upon its application start (or restarts it if the server is already running) and stops it upon its exit. (To save resources on laptops/netbooks etc. ...) The option to chose what one wants (configure while installing) is good, but doesn't really work, because even if you chose to have the server started upon system boot, as soon as the GUI is closed the server is stopped as well and would then not be restarted until next start of the GUI or reboot.

So maybe one should work on the package description of the GUI package? Like:
Quote
An Ubuntu Application Indicator (a graphical user interface, GUI) for the server app used for the 'Scan to PC' function of Samsung multi function printers (MFPs) in suld-scantopc. It has some convenient buttons and issues informational notification bubbles about incoming scan files. Note: This is intended for notebook/desktop PC users that do not want the backend server to always run but rather started and stopped together with the GUI.

Sorry a/b the changelog issue. I do not know very much about debian packaging. As I clicked on 'Get changelog' in Synaptic it told me nothing was present - which obviously isn't true. I incorporated your changelogs into what I already wrote and attached the new ones. You can leave them compressed, btw - the most standard way is probably the best way. ;)

v0.4.3 (both scantopc and scantopc-gui, see bundled attachment): I improved a few other things (logging and error handling) and added an option to the conf file to disable the scanner object caching introduced by angelnu, since this does not work with multiple servers registered at the same scanner. Ideally the scanner connection should then be closed after each (multipage) scan, but this causes a seg fault (exiting SANE does as well). Problem is, that the scanner only has one port 9400 to listen to one computer running the server ... But for now the general option is there and at least leads to less problems with multiple servers even though the main problem remains. (My scanner usually freezes if two different servers try to reach it via SANE (port 9400) at the same time, and one of the servers gives me some SANE I/O Error ...)


bchemnet

Quote from: totally-king on July 28, 2013, 13:58:49
I agree with both of you, if the scantopc package is installed alone.

But when the GUI package is added I think it is better to refrain from automatic startup of the service. The GUI (ubuntu App Indicator) I wrote starts the server upon its application start (or restarts it if the server is already running) and stops it upon its exit. (To save resources on laptops/netbooks etc. ...) The option to chose what one wants (configure while installing) is good, but doesn't really work, because even if you chose to have the server started upon system boot, as soon as the GUI is closed the server is stopped as well and would then not be restarted until next start of the GUI or reboot.

So maybe one should work on the package description of the GUI package? Like:
Quote
An Ubuntu Application Indicator (a graphical user interface, GUI) for the server app used for the 'Scan to PC' function of Samsung multi function printers (MFPs) in suld-scantopc. It has some convenient buttons and issues informational notification bubbles about incoming scan files. Note: This is intended for notebook/desktop PC users that do not want the backend server to always run but rather started and stopped together with the GUI.

Good points.  As currently designed, you are probably correct about the server always running issue.  I was thinking about it from the point of view of someone who might not always want to run the GUI to be able to scan, but at times might want the notifications, etc.  But as designed, I think your description of the GUI use case is accurate, particularly with the updated description.  I will make the necessary changes.

Quote from: totally-king on July 28, 2013, 13:58:49
Sorry a/b the changelog issue. I do not know very much about debian packaging. As I clicked on 'Get changelog' in Synaptic it told me nothing was present - which obviously isn't true. I incorporated your changelogs into what I already wrote and attached the new ones. You can leave them compressed, btw - the most standard way is probably the best way. ;)

No problem.  I didn't learn about all the standards until I started putting together this repository, even though I had built several packages before then.

Quote from: totally-king on July 28, 2013, 13:58:49
v0.4.3 (both scantopc and scantopc-gui, see bundled attachment): I improved a few other things (logging and error handling) and added an option to the conf file to disable the scanner object caching introduced by angelnu, since this does not work with multiple servers registered at the same scanner. Ideally the scanner connection should then be closed after each (multipage) scan, but this causes a seg fault (exiting SANE does as well). Problem is, that the scanner only has one port 9400 to listen to one computer running the server ... But for now the general option is there and at least leads to less problems with multiple servers even though the main problem remains. (My scanner usually freezes if two different servers try to reach it via SANE (port 9400) at the same time, and one of the servers gives me some SANE I/O Error ...)

I will update with these changes.

bchemnet


totally-king

Thank you very much! The GUI package throws the following error during install (postinst gave back error code 1):

update-rc.d: /etc/init.d/samsungScannerServer exists during rc.d purge (use -f to force)


I think, you need to add the '-f' to the invocation of update-rc.d. Since the service samsungScannerServer exists it won't delete the startup links without forcing it to.

bchemnet

New version up, with the -f (and also re-ordering a couple of statements in postinst that were incorrect).

frankentux

Hi. I built a package for openSUSE (have'nt had a chance to test it yet until I get home). It is available here:
https://build.opensuse.org/package/show?project=home%3Ababelworx&package=python-samsungScannerServer

I still have to do some work with systemd.

What license is this software distributed under? Would it be possible to put a license file in the package?

frankentux

The package is now working (ish) with some manual fixes:
in force_multipart() I force host = '192.168.178.25' (the ip of the scanner)
in queryPrinterScanStatus() I force SCANNER_IP to '192.168.178.25

The reason for  the first one is that the script dies and complains about a non-numeric host (it accepts the ip address). scanimage -L returns something like snmp:net;192.168.178.25 and this chokes the h = http_client.HTTPConnection(host) - which expects an ip, not a string (I think).

The  reason for the second one is the same as the first except that it is now SCANNER_IP which gets the string returned from scanimage -L - that should also be an ip.

Once I manually force those two variables to ip addresses, I get to choose the options on the scanner itself. Those options are apparently successfully transported (and are displayed by the script). However, once initScan() is called, everything goes pear shaped. I get:

INFO:stderr:    imgs, s = initScan()
INFO:stderr:  File "samsungScannerServer.py", line 451, in initScan
INFO:stderr:    s.page_format = size #t-k: bugfix page_format is correct (not page-format)
INFO:stderr:  File "/usr/lib64/python2.7/site-packages/sane.py", line 183, in __setattr__
INFO:stderr:    self.last_opt = dev.set_option(opt.index, value)
INFO:stderr:_sane.error: Invalid argument

When I run scanimage -d 'smfp:net;192.168.178.25' > out.image, it works and I get an image in out.image - thus I don't think that this is related to the samsung uld backend but rather to how the script is calling the sane scanimage function. Here is the system information for sane:

sane-backends-autoconfig-1.0.23-5.1.1.x86_64
sane-backends-1.0.23-5.1.1.x86_64
python-imaging-sane-1.1.7-34.1.x86_64

I'm using the ULD version contained in ULD_Linux_V1.00.06.tar.gz

Any ideas?


totally-king

#47
Not really. Your scanner ID looks different from what I'm used to and what this application was made for. Mine for example is: smfp:SAMSUNG CLX-3300 Series on 192.168.178.29. Maybe the sane python module can't handle such a name?! You could try initiating a scan through ipython and look if this throws the same error:

import sane
sane.init()
dev = sane.get_devices()[0][0]
s = sane.open(dev)
## Edit: check if page_format option is available
if 'page_format' in s.optlist:
    s.page_format = 'A4 - 210x297 mm'
else:
    raise ValueError('page_format option not available')
pic = s.scan()
s.close()
sane.exit()


Edit: Now that I looked at the Traceback again, I think it's probably not the ID causing the sane error. (Still worth a try to check it out the manual way. Seems like there's a bug when trying to set the page format. If the error persists look what kinds of page format strings your scanner expects with scanimage --help -d 'smfp:net;192.168.178.25' and modify the SIZE2SANE dictionary in /etc/samsungScannerServer.conf if necessary.) But your problems with having to force the scanner IP are definitely because of your unusual scanner ID and could be overcome by an alternative IP extraction algorithm (maybe depending on the semicolon?). If you want that just tell me. ;)

totally-king

Here are the modified source and config files for version 0.4.4 of suld-scantopc and suld-scantopc-gui addressing the errors mentioned in http://www.bchemnet.com/suldr/forum/index.php?topic=157.0 and a bit more (updated changelogs included).

frankentux

This is the output of scanimage --help -d 'smfp:net;192.168.178.25'

Options specific to device `smfp:net;192.168.178.25':
    --preview[=(yes|no)] [no]
        Request a preview-quality scan
  Image Quality:
    --mode Color - 16 Million Colors|Grayscale - 256 Levels|Black and White - Halftone|Black and White - Line Art [Color - 16 Million Colors]
        Set the color composition mode of the scanned image
    --resolution 75|100|150|200|300|600|1200dpi [300]
        Set the resolution of the scanned image
  Scan Area:
    --doc-source Flatbed|ADF Simplex [Flatbed]
        Select source of the document to be scanned
    --page-format Statement|Statement (Rotated)|A5|A5 (Rotated)|B5 (JIS)|Executive|A4|Letter|Custom [A4]
        Set the paper format of the scanned page
    -l 0..216mm

  •         Set left position of the scan area
        -t 0..297mm

  •         Set top position of the scan area
        -x 0..216mm [210]
            Width of scan-area.
        -y 0..297mm [297]
            Height of scan-area.

    Trying the scan in python now (was there a reason you recommended ipython?)

totally-king

Well, I personally like the interactive approach with ipython to exactly see where something goes wrong. You still are in the environment to try another approch.

There it is I think:
Quote from: frankentux on October 01, 2013, 09:53:52
    --page-format Statement|Statement (Rotated)|A5|A5 (Rotated)|B5 (JIS)|Executive|A4|Letter|Custom [A4]
        Set the paper format of the scanned page

So as I said, you probably need to update the config file

SIZE2SANE={'SIZE_A4': 'A4', 'SIZE_A5': 'A5 (Rotated)',
           'SIZE_B5_JIS': 'B5 (JIS)', 'SIZE_EXECUTIVE': 'Executive',
           'SIZE_LETTER': 'Letter'}

For Statement and Executive (if you want/have that) you need to find out what your scanner's definitions for these formats are (as 'SIZE_A4' is for A4). To do that

wget 192.168.178.25/IDS/CAP.XML

and open the file to check for the definitions (if there are any).

frankentux

That fixed it! Here were the steps:

(1) def extractIPs(fileContent):
    pattern = r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)([ (\[]?(\.|dot)[ )\]]?(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})"
    ips = [each[0] for each in re.findall(pattern, fileContent)]   
    for item in ips:
        location = ips.index(item)
        ip = re.sub("[ ()\[\]]", "", item)
        ip = re.sub("dot", ".", ip)
        ips.remove(item)
        ips.insert(location, ip)
    return ips
#SCANNER_IP=SCANNER_SANE_NAME.split(' ')[-1]
try:
  SCANNER_IP = extractIPs(SCANNER_SANE_NAME)[0]
except IndexError: # regex failed?
  sys.exit(1)

(2) change the conf file like you said

Would it not make more sense to define SIZE2SANE in the python script rather than in the conf - depending on the sane scanner id, it could be set dynamically?

totally-king

#52
I added the IPv4 extraction method and also established an algorithm which tries to create the SIZE2SANE dictionary automatically. If one wants to override that, one simply has to define SIZE2SANE in the conf file.

See updated files and changelogs for suld-scantopc v0.4.5 and (reposted) suld-scantopc-gui v0.4.4 in the attachment.

Edit:
@frankentux: Please tell me, if these new versions work for you without any tweaking. If so: mission accomplished! ;) If not: bugfixing time ...

totally-king

Quote from: frankentux on September 26, 2013, 08:17:45
What license is this software distributed under? Would it be possible to put a license file in the package?

I decided to put the deb packages under 'GPL-3+' which means they may be distributed under GPLv3 or any later version of that license. I attached the license text taken from /usr/share/common-licenses/GPL-3 on my ubuntu system, if you need it.

totally-king

Sry for so many posts. But I found and fixed a bug in the GUI when started by a user that is not configured to own the scan files saved by the server app.

See updated files and changelogs for (reposted) suld-scantopc v0.4.5 and suld-scantopc-gui v0.4.5 in the attachment.

bchemnet

I expect to have time this weekend to push these out to the repository.

totally-king

@bchemnet Thanks for the updates. All is fine except (probably my fault, sry!) that the script of suld-scantopc isn't executable anymore (which leads to a lot of dpkg errors since configuration pre/post routines rely on (re)starting/stopping ...):

-rw-rw-r-- 1 root root 59K Okt  2 20:11 /usr/bin/samsungScannerServer.py

The correct mode is probably 755 (-rwxr-xr-x). Maybe you could also apply this to the suld-scantopc-gui script (samsungScannerServerAppIndicator.py), which currently has 775.


mradic

Hello people,

After long time I have visited bchemnet site, and was glad to see this thread and really nice feature included in repository, which I use a lot. Thanks angelnu and bchemnet!

For a while, I was using another script:
http://www.jon.demon.co.uk/dell1600n-net-scan/
(download link inside page)

It worked fine with my CLX-3160FN, I have never tried it on CLX-3185FN.

Here is my command line for invoking the script:
./dell1600n-net-scan.pl --listen 192.168.x.x --clx2160n --multi-session --scan-dir /home/guest

For making it "permanent": http://foo2zjs.rkkda.com/forum/read.php?28,1793,1793

But, since I do not need it all the time, I just added icon on menu bar to run application in terminal...

I just thought this might help you in further development...!

Regards,
Momir

bchemnet


Repository Information Legal Contact Alternative Drivers