Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanning initiated by scanner buttons starts with a great delay #31

Open
archont00 opened this issue Sep 17, 2024 · 5 comments
Open

Scanning initiated by scanner buttons starts with a great delay #31

archont00 opened this issue Sep 17, 2024 · 5 comments
Labels
question Further information is requested

Comments

@archont00
Copy link

archont00 commented Sep 17, 2024

Hi,

The scanner is connected via ethernet cable.

device `brother4:net1;dev0' is a Brother *DCP-B7520W Brother_DCP-B7520DW_series

When I use in scripts/scantofile.sh:

scan_cmd="scanimage -l 0 -t 0 -x 215 -y 297 --device-name=$device --resolution=$resolution --batch=$output_file"
echo "Command: $scan_cmd"

the initiation of the scanning has a great delay of cca 30 seconds ("Connecting to PC" is displayed on the scanner LCD after pressing the scan button on the scanner):

2024-09-17T**19:32:54**.578402000Z /opt/brother/scanner/brscan-skey/script/scantofile.sh: line 14: UID: readonly variable
2024-09-17T19:32:54.579085000Z filename: /scans/2024-09-17--21-32-54/2024-09-17--21-32-54-front-page%04d.pnm
2024-09-17T19:32:54.579236000Z Command: scanimage -l 0 -t 0 -x 215 -y 297 --device-name=brother4:net1;dev0 --resolution=150 --batch=/scans/2024-09-17--21-32-54/2024-09-17--21-32-54-front-page%04d.pnm
2024-09-17T19:32:54.579382000Z Output format is not set, using pnm as a default.
2024-09-17T**19:33:03**.579674000Z scanimage: rounded value of br-x from 215 to 211.881
2024-09-17T19:33:03.580342000Z scanimage: rounded value of br-y from 297 to 296.973
2024-09-17T19:33:03.580492000Z Scanning infinity pages, incrementing by 1, numbering from 1
2024-09-17T19:33:03.580631000Z Scanning page 1
2024-09-17T**19:34:23**.590222000Z Scanned page 1. (scanner status = 5)

Scanning of subsequent pages within the batch starts promptly after button press (Next = up arrow key on the scanner).

When I run the above scanimage command from terminal inside the docker container (i.e. direct scanning initiated from computer), it takes 9 seconds to actually start the scanning. The scanning itself takes just a few seconds as it is 150 dpi only.

As per above log, the delay between the scanner button press (19:32:54) and the scanning (cca 19:33:34 less few seconds spent on actual scanning) looks like 3 times the 9 seconds delay. (Could it be that SANE commands are triggered three times for any reason.)

Any ideas what might be wrong with brother4 driver or brscan-skey and if it can be setup to run with shorter initial delay? It makes it impractical to use the scanner buttons now...

BTW, I tried to run scanimage in terminal inside the container with --device-name=escl:http://10.11.13.11:80 instead and the scanning started immediately without any delay.

Unfortunately, when I tried to use this device name in the script, the delay of cca 10 seconds is still there and the command fails eventually (driver is probably not supported by brscan-skey?):

2024-09-17T**19:35:35**.600366000Z /opt/brother/scanner/brscan-skey/script/scantofile.sh: line 14: UID: readonly variable
2024-09-17T19:35:35.601023000Z filename: /scans/2024-09-17--21-35-34/2024-09-17--21-35-34-front-page%04d.pnm
2024-09-17T19:35:35.601164000Z Command: scanimage -l 0 -t 0 -x 215 -y 297 --device-name=escl:http://10.11.13.11:80 --resolution=100 -v -v -v --batch=/scans/2024-09-17--21-35-34/2024-09-17--21-35-34-front-page%04d.pnm
... cut on purpose ...
2024-09-17T19:35:35.602824000Z Scanning page 1
2024-09-17T**19:35:45**.601742000Z scanimage: sane_start: Invalid argument
2024-09-17T19:35:45.602384000Z Batch terminated, 0 pages scanned
2024-09-17T19:35:45.602531000Z Closing device
2024-09-17T19:35:45.602666000Z Calling sane_exit

EDIT: Clarifying that the delay 30 secs is when using the physical scan button on the scanner.

@vgarcia007
Copy link
Collaborator

Sorry if I misunderstood. But you mean that when you trigger the scan directly on the device, the delay occurs?

@archont00
Copy link
Author

Exactly: The delay of cca 30 seconds occurs when I press the scan button directly on the printer.

@PhilippMundhenk
Copy link
Owner

My apologies for the late reply, I had a bit of a busy week.

tl;dr: No obvious solution, sorry.

Interesting...I do observer rather long delays as well, when using the button, especially when using the flatbed, rather than the auto feeder. In my case, this is 8s though, which is much more bearable. With ADF, it is closer to 2s. Thus, 30s is really an extremely long time.

I do call the scan commands twice, with some sleep padding, as we otherwise observed issues on some printers, but once scanimage is triggered, timing is outside of my sphere of influence. I have not reverse engineered the scanner driver, it is very much possible, there are issues there. I also don't want to exclude the possibility that the current configuration in this repo is not ideal for every scanner. It is posible that one could reach faster scanning times with better settings, as you did above. A few things I noticed:

  • Calling with --device-name=$device, as you describe above, currently might not work. Thus the default does not use the device name, yet. Once Fix temp directories left behind #33 is in, this should be fixed.
  • The device name (and thus driver) is currently not configurable, but this would be a fairly easy addition. However, seeing that this does not help with triggering through the buttons, lets not use this as the first step.
  • It is posible there are some implicit dependencies between brscan-skey and brscan4. I assume that the scanner, once triggering is performed via buttons, is in a state that does not allow it to be triggered via other means. One would need to terminate/abort the SNMP sequence manually in the script to enable scanning in this case. We had reverse engineered some of the protocol in Scripts work, but can't initiate scan from printer #10, but I would need some time to read into this again. The fastest would be to just move scanning to detached process, but this would disable all further control, such as scanning additional pages.
  • It might be possible to also try some of the other SANE commands, like scanadf, but I have very little experience with this. I had more failures than success with these.

Let me think about this a little more, but ad the moment, I don't quite see an easy solution to this, unfortunately...

@PhilippMundhenk
Copy link
Owner

out of curiosity: Which scanner are you using? Workflows and buttons seem very different from mine.

@PhilippMundhenk PhilippMundhenk added the question Further information is requested label Sep 22, 2024
@archont00
Copy link
Author

archont00 commented Sep 23, 2024

Hi,
I use DCP-B7520DW, which has only the flatbed scanner (no ADF).
Thanks for the comments - I will try to test with other commands from SANE. Also, there is a binary program for scanning provided by Brother within the scanner driver package and its original scanning scripts.
I will get back if I find anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants