<div dir="ltr"><div dir="ltr"><font face="monospace">I think I'm close to making it work, although I had to write some code rather than use sane for polling the buttons.</font><div><font face="monospace"><br></font></div><div><font face="monospace">Few observations:</font></div><div><font face="monospace">1. In the MFNP scanner command 50 (0x32), subcommands 2 and 3, sane sends the hostname UTF-16 (or USC-2) encoded.</font></div><div><font face="monospace">MF4780w expects it in ASCII (or UTF-8?). Which means that if I poll my device with SANE, it's displayed as an empty line.</font></div><div><font face="monospace">Possibly that's a difference between MFNP and BJNP protocols, or maybe printer/scanner tells the codepage to use in earlier packets.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">2. When I select "Scanner" -> "Computer" -> "<hostname>" -> {"B/W" / "Color" / "Custom 1" / "Custom 2"} on my device, the response to my MFNP command 50 subcommand 2 looks like this:</font></div><div><font face="monospace">Payload: 00 00 80 00 00 50 85 f4 00 00 00 05 00 00 00 04 01 00 00 00 00<br></font></div><div><font face="monospace">                                                      ^^ ^^</font></div><div><font face="monospace">                                                      |   \ This "01" is either 01 or 02 or 03 or 04 depending whether it's "B/W" or "Color" and so on</font></div><div><font face="monospace">                                                       \ Instead of this "04", "00" is returned when the scanner is in stand by mode</font></div><div><font face="monospace">`scanimage -A` doesn't return values of the buttons for some reason. I'm not sure why exactly (e.g. maybe printer is confused with UTF-16 hostname, maybe the button location in the response is not where SANE looks for it, maybe dialog_id is lost somewhere).</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">3. Before scanning, the Windows driver also sends MFNP command 64 (0x40), with this payload:</font></div><div><font face="monospace">Payload: f3 20 00 00 00 00 00 00 0c 00<br></font></div><div><font face="monospace">Return payload is something like:</font></div><div><font face="monospace">Payload: 06 06 03 01 00 41 03 00 41 00 01 00 00 76<br></font></div><div><font face="monospace">It seems to return printer/scanner's settings (I tried to change paper size etc in settings and the line changed), but I think the only useful piece of information for scanning is the last bit: that 0x76 becomes 0x77 when there is something in the scanner feeder.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">4. After sending the response, the scanner goes into the listening mode, and you can scan from any program using SANE (I suspect you can even do that from a different host).</font></div><div><font face="monospace">That means that after handing the initial handshake by sending those UDP packets manually, the rest looks promising with scanning through SANE.</font></div><div><font face="monospace">The main worry that I have is whether SANE will be able to handle scanning multiple pages in a flatbed while being controlled from the scanner side.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">I'll keep you posted for any progress that I'll have. Any further advice would be appreciated.</font></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 15, 2021 at 8:54 PM Alexander Lyashuk <<a href="mailto:mooskagh@gmail.com">mooskagh@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for the suggestion, but I actually don't have any windows machine that I can use for that.<div><br></div><div>I only started windows in a virtualbox to observe the network traffic between it and the scanner.</div><div>(and also I reboot my laptop to windows sometimes, mentioning that just to explain why I used "windows machines" in plural in my previous message)</div><div><br></div><div>If you suggest that the scanner itself would upload documents via SMB, unfortunately MF4780w is quite old and doesn't support that, as well as other convenient options like scanning to email, so unless I'm missing something I'm stuck with using either MFNP or WSD.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 15, 2021 at 7:36 PM Jörn-Ingo Weigert <<a href="mailto:jiweigert@gmail.com" target="_blank">jiweigert@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Just a guess without having that scanner model:<div dir="auto"><br></div><div dir="auto">You should be able to use your desired mode, when you share a folder on windows and set  both access and security to "everyone" in the properties of the shared folder.</div><div dir="auto"><br></div><div dir="auto">In the settings of your scanner you should enable "SMB" protocol too. </div><div dir="auto"><br></div><div dir="auto">Hope that help you</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Alexander Lyashuk <<a href="mailto:mooskagh@gmail.com" target="_blank">mooskagh@gmail.com</a>> schrieb am So., 15. Aug. 2021, 12:31:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">One more thing to add, maybe WSD will be an easier option.<div><br></div><div>It's possible to enable WSD support for this scanner.</div><div><br></div><div>In that case, I also can scan in "Remote scanner" mode through the sane-airscan backend.</div><div>I can also start scanning to the windows machines from the scanner through WSD (when I select "Scan" -> "Computer", all windows machines in my local network appear, even ones without Canon drivers, unlike it was with MFNP-only mode).</div><div><br></div><div>However, when I do `scanimage --device-name=airscan:w0:mf4780w -A` similarly to what I attempted with MFNP mode, no new lines appear in the list of destinations.</div><div>Also `scanimage -A` doesn't show the state of buttons in this case.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 15, 2021 at 11:43 AM Alexander Lyashuk <<a href="mailto:mooskagh@gmail.com" rel="noreferrer" target="_blank">mooskagh@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi sane-devel,<br><br>I have a Canon i-Sensys MF4780w network scanner/printer.<br><br>It has two ways to start scanning:<br>- "Remote scanner" / "pull mode", when you enable that mode on the device and then continue on the computer.<br>- "Computer" / "push mode", where you select the destination and initiate scanning from the scanner itself.<br><br>My scanner works well in "Remote scanner" mode (through the pixma backend, I've added "mfnp://<a href="http://10.162.0.7/" rel="noreferrer" target="_blank">10.162.0.7</a>" to pixma.conf).<br>I'd like to be able to initiate the scans from the scanner (in "Computer"/push mode) though, so that I can set up a headless server which will upload documents to Google Drive.<br><br>So far I failed to set it up that way, and I wonder whether there is any hope.<br><br>When I select "Scan" -> "Computer" on my scanner,<br>- First I have to select the destination.<br>- Then I select the mode (Color/BnW/Custom1/Custom2).<br><br>I checked what Windows does to appear in the list of destinations, and it seems that it sends an MFNP message to the scanner every 5 seconds and so.<br><br>I tried to do the same from Linux by calling `scanimage -A` in the loop. When I did that, a selectable extra empty line indeed appeared in the list of destinations on the scanner. I checked the messages from Windows and Linux in network sniffer and it appears that Windows sends the hostname in ASCII format, while on Linux it's UTF-16, that's the likely reason why the scanner cannot display the destination name properly.<br>I wouldn't mind having an empty line as a hostname though as long as it would work.<br><br>When I select "Scan" -> "Computer" -> "empty line" -> "Custom 1" (or BnW/Custom2/Color), both --button-1 and --button-2 still show value [0] in `scanimage -A`, so I cannot find any way to know I should start scanning.<br><br>I also tried to use scanbd, but it appears not to be able to find the scanner at all:<br><br>[root]# SANE_CONFIG_DIR=/usr/local/etc/scanbd/ ./scanbd -f -d7<br>./scanbd: reading config file /usr/local/etc/scanbd/scanbd.conf<br>./scanbd: debug on: level: 7<br>./scanbd: dropping privs to uid root<br>./scanbd: dropping privs to gid scanner<br>./scanbd: drop privileges to gid: 96<br>./scanbd: Running as effective gid 96<br>./scanbd: drop privileges to uid: 0<br>./scanbd: Running as effective uid 0<br>./scanbd: dbus_init<br>./scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'<br>./scanbd: SANE_CONFIG_DIR=/usr/local/etc/scanbd/<br>./scanbd: sane version 1.0<br>./scanbd: Scanning for local-only devices<br>./scanbd: start_sane_threads<br>./scanbd: no devices, not starting any polling thread<br>./scanbd: start dbus thread<br>./scanbd: Not Primary Owner (-1)<br>./scanbd: Name Error (Connection ":1.219" is not allowed to own the service "de.kmux.scanbd.server" due to security policies in the configuration file)<br>./scanbd: udev init<br>./scanbd: get udev monitor<br>./scanbd: udev fd is non-blocking, now setting to blocking mode<br>./scanbd: start udev thread<br>./scanbd: udev thread started<br><br>Note the string "Scanning for local-only devices", does it mean it doesn't attempt to scan network devices?<br><br>Any suggestions on what to try next would be very appreciated.<br><br>Thanks!<div></div><div><br></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>