<div dir="ltr">Thanks Allan,<div><br></div><div>That makes sense, I hooked up Wireshark and started comparing Windows and Linux</div><div><br></div><div>Looking at Wireshark traces:<br></div><div><div>Successful Windows power on of Scanner yields hundreds of URB_CONTROL in/out messages over the USB bus. During this communication the Red LED on the scanner turns Green</div><div>On Linux Power On only yields 20 calls counting Request and Response as two messages.</div><div>The Red LED on the scanner stays Red.</div><div>( I have not attached any traces as large emails with attachments seem to get stuck in some filter until they are manually released, but can put them using dropbox if it helps )</div><div><br></div><div><div>In order to be able to interpret the traces easier, It was suggested that most Avision Scanners are SCSI over USB which is pretty standard, so I tried to google a specification document, but could find nothing, anyone know where to find such a specification?</div><div><br></div><div>If it adheres to a standard SCSI protocol, then perhaps compiling a backend where I clone and modify the product number for any other Avision Sheet Feed scanner and test using that may bring us closer.</div></div><div><br></div><div>the scanner is added to /lib/udev/hwdb.d/20-sane.hwdb and VM rebooted</div><div>usb:v0638p2b6a*<br> libsane_matched=yes</div><div><br></div><div>Are there any more configurations I can do to make the backend treat the AV50F scanner the same as another Avision Sheet-feed Scanner which IS supported? Or do I need to clone, modify and recompile the backend to do that?</div></div><div><br></div><div>cheers, Ove.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 9 Sept 2024 at 12:17, m. allan noah <<a href="mailto:kitno455@gmail.com">kitno455@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"><div>You cannot compare the traces from two different backends. There is no expectation that their scanners need the same type of communication, or that the backends are coded in the same way.</div><div>Instead, you must get a wireshark trace of the scanner working under windows, and reverse engineer the protocol.</div><div><br></div><div>allan<br></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 9, 2024 at 7:09 AM Ove Laurum <<a href="mailto:laurum.tech@gmail.com" target="_blank">laurum.tech@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"><div dir="ltr">OK some more information gleaned, as per email below, after updating 20-sane.hwdb, there is no difference as far as I can tell, even in the trace using</div><div dir="ltr"><span style="color:rgb(80,0,80)">SANE_DEBUG_AVISION=100 scanimage -L</span></div><div dir="ltr"><font color="#500050">the trace showed the same events.</font></div><div><font color="#500050">Did I miss something??</font></div><div dir="ltr"><font color="#500050"><br></font></div><div dir="ltr"><font color="#500050">I then looked at the USB wireshark capture and I compared my working Canon LiDE 220 against the non-working Avision AV50F.</font></div><div dir="ltr"><font color="#500050">What I can see is that when I power on the scanners in Linux, I get the same traces in wireshark, and when I run </font>sane-find-scanner I also get the same trace for each device.</div><div><font color="#500050">but when I run </font><span style="color:rgb(80,0,80)">scanimage -L I get differences, so far so good, but a bit strange because with the failing scanner, I get:</span></div><div><span style="color:rgb(80,0,80)">host => URB_CONTROL out</span></div><div><span style="color:rgb(80,0,80)">scan => URB_CONTROL out</span><span style="color:rgb(80,0,80)"><br></span></div><div><div><span style="color:rgb(80,0,80)">host => URB_CONTROL out</span></div><div><span style="color:rgb(80,0,80)">scan => URB_CONTROL out</span></div><div><div><span style="color:rgb(80,0,80)">host => URB_CONTROL in</span></div><div><span style="color:rgb(80,0,80)">scan => URB_CONTROL in</span></div></div><div><span style="color:rgb(80,0,80)">followed by ~30 seconds timeout</span></div><div><span style="color:rgb(80,0,80)"><br></span></div><div><span style="color:rgb(80,0,80)">but on the working scanner I don't get any communication at all when I do </span>scanimage -L</div><div>( I do see traffic for the working scanner, but not for <span style="color:rgb(80,0,80)">scanimage -L)</span></div><div><span style="color:rgb(80,0,80)"><br></span></div><div><span style="color:rgb(80,0,80)">This leads me to believe that there is something before </span><span style="color:rgb(80,0,80)">scanimage -L that goes wrong.</span></div><div><span style="color:rgb(80,0,80)">Trace tells me that the backend is asking </span><span style="color:rgb(80,0,80)">sanei_usb.c to communicate with the scanner on the correct device ID, but it is getting a write error back.</span></div></div><div dir="ltr"><div>Could it be another configuration that is required?</div><div><br></div><div>when I do </div><div>SANE_DEBUG_SANEI_USB=5 scanimage -L<br></div><div>I got some interesting information.</div><div>I attached the logfile as sanei_usb.ods file (openoffice) to this email</div><div>Green lines (in the file) are for the working Canon Scanner</div><div>Yellow Lines for the not working Avision scanner.</div><div><br></div><div>Successful scanner</div><div>[16:01:00.053164] [sanei_usb] sanei_usb_open: opened usb device `libusb:001:010' (*dn=0)<br>[16:01:00.053210] [sanei_usb] sanei_usb_close: evaluating environment variable SANE_USB_WORKAROUND<br>[16:01:00.053229] [sanei_usb] sanei_usb_close: closing device 0<br></div><div>[16:01:00.053793] [sanei_usb] sanei_usb_scan_devices: marking existing devices<br></div><div><br></div><div>failing scanner<br></div><div>[16:01:03.786750] [sanei_usb] sanei_usb_open: opened usb device `libusb:001:012' (*dn=1)<br>[16:01:03.786766] [sanei_usb] sanei_usb_write_bulk: trying to write 10 bytes<br>[16:01:03.787163] [sanei_usb] sanei_usb_write_bulk: wanted 10 bytes, wrote 10 bytes<br>[16:01:03.787188] [sanei_usb] sanei_usb_read_bulk: trying to read 96 bytes<br>[16:01:04.787997] [sanei_usb] sanei_usb_read_bulk: read failed (still got 0 bytes): Operation timed out<br>[16:01:04.790478] [sanei_usb] sanei_usb_write_bulk: trying to write 10 bytes<br>[16:01:04.790834] [sanei_usb] sanei_usb_write_bulk: wanted 10 bytes, wrote 10 bytes<br>[16:01:04.790853] [sanei_usb] sanei_usb_read_bulk: trying to read 96 bytes<br>[16:01:05.792574] [sanei_usb] sanei_usb_read_bulk: read failed (still got 0 bytes): Operation timed out<br>[16:01:05.793384] [sanei_usb] sanei_usb_write_bulk: trying to write 10 bytes<br>[16:01:35.794146] [sanei_usb] sanei_usb_write_bulk: write failed: Operation timed out<br>[16:01:35.794795] [sanei_usb] sanei_usb_read_bulk: trying to read 1 bytes<br>[16:01:36.295389] [sanei_usb] sanei_usb_read_bulk: read failed (still got 0 bytes): Operation timed out<br>[16:01:36.296025] [sanei_usb] sanei_usb_read_int: trying to read 1 bytes<br>[16:01:36.797312] [sanei_usb] sanei_usb_write_bulk: trying to write 10 bytes<br>[16:02:06.799887] [sanei_usb] sanei_usb_write_bulk: write failed: Operation timed out<br>[16:02:06.800591] [sanei_usb] sanei_usb_read_bulk: trying to read 1 bytes<br>[16:02:07.301149] [sanei_usb] sanei_usb_read_bulk: read failed (still got 0 bytes): Operation timed out<br>[16:02:07.301919] [sanei_usb] sanei_usb_read_int: trying to read 1 bytes<br>[16:02:07.819371] [sanei_usb] sanei_usb_scan_devices: marking existing devices<br></div><div><br></div><div>This looks like the same flow as we saw in the backend log, but we also see that for the successful scanner the backend is not attempting to communicate with the scanner.</div><div>And for the failing scanner it claims to write 10 bits, but fails in reading. Operation timed out on a 1 second timer.</div><div>Is this because the backend already knows how to communicate with the canon scanner and it is only when such information is missing that it tries (and fails) to talk to the Avision scanner?</div><div><br></div><div>Is there any documentation that it would be good to read to better understand what the backend and sanei_usb is trying to do?</div><div><br></div><div><br></div><div>Thanks in advance for any helpful pointers</div><div><br></div><div>Ove/</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 8 Sept 2024 at 14:04, Ove Laurum <<a href="mailto:laurum.tech@gmail.com" target="_blank">laurum.tech@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"><div>Thanks Ralph, I am not familiar with udev, but I added my scanner to the bottom of the file /lib/udev/hwdb.d/20-sane.hwdb on the VM I have the Scanner connected to as you suggested</div><div>I did: $ <b>udevadm control --reload-rules</b></div><div>No luck</div><div>I rebooted the VM but I still can not see the scanner with scanimage -L</div><div><br></div><div>Is the scanner supposed to show up using scanimage -L?</div><div><br></div><div>I also tried the GUI xsane, but it also can not see the scanner.</div><div><br></div><div><br></div><div>Last 7 lines of 20-sane.hwdb:<br># Dell Dell 1235cn<br>usb:v413Cp5310*<br> libsane_matched=yes<br><br># OVE<br>usb:v0638p2b6a*<br> libsane_matched=yes<br></div><div><br></div><div>output from lsusb & sane-find-scanner & scanimage -L</div><div>root# lsusb<br>Bus 001 Device 003: ID 0638:2b6a Avision, Inc. AV50F Plus<br></div><div><br></div><div>root# sane-find-scanner<br><br> # sane-find-scanner will now attempt to detect your scanner. If the<br> # result is different from what you expected, first make sure your<br> # scanner is powered up and properly connected to your computer.<br><br> # No SCSI scanners found. If you expected something different, make sure that<br> # you have loaded a kernel SCSI driver for your SCSI adapter.<br><br>found possible USB scanner (vendor=0x0638 [AVISION], product=0x2b6a [AV50F Plus]) at libusb:001:003<br> # Your USB scanner was (probably) detected. It may or may not be supported by<br> # SANE. Try scanimage -L and read the backend's manpage.<br><br> # Not checking for parallel port scanners.<br><br> # Most Scanners connected to the parallel port or other proprietary ports<br> # can't be detected by this program.<br>root# scanimage -L<br><br>No scanners were identified. If you were expecting something different,<br>check that the scanner is plugged in, turned on and detected by the<br>sane-find-scanner tool (if appropriate). Please read the documentation<br>which came with this software (README, FAQ, manpages).<br></div><div><br></div><div><br></div><div>Regards Ove.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 4 Sept 2024 at 19:20, Ralph Little <<a href="mailto:skelband@gmail.com" target="_blank">skelband@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"><div dir="ltr"><div>Hi,</div><div><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 4, 2024 at 10:11 AM Ove Laurum <<a href="mailto:laurum.tech@gmail.com" target="_blank">laurum.tech@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 Ralph,<div><br></div><div>I found the code on GitLab. Very useful.<br><div><br></div><div>I also managed to add my scanner to the config file /etc/sane.d/avision.conf</div><div>usb 0x0638 0x2b6a<br></div></div></div></blockquote><div><br></div><div>Great.</div><div> <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"><div><div></div><div><br></div><div>I didn't get much of a trace out until I ran it as root, see abbreviated output below</div><div>SANE_DEBUG_AVISION=100 scanimage -L<br></div><div>(I don't think I can use the -d option unless the device is listed with "scanimage -L")</div><div><br></div><div>When I do:</div><div>SANE_DEBUG_AVISION=50 sane-find-scanner</div><div>I get no trace, is that because the backend is not involved at this stage?</div></div></div></blockquote><div><br></div><div>Yeah, that won't work. sane-find-scanner is not using the SANE API at all. It merely looks for devices that might be scanners.</div><div>You should use scanimage or another SANE frontend instead. This *should* work once the avision backend knows about your scanner.</div><div>I *think* that you can use -d avision to pick the first avision device.<br></div><div> </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"><div><div><br></div><div>In the trace that I did get, it looks like the backend is opening the correct device "libusb:001:003" and tries a first command which is "Inquiry".</div><div>It builds the query and tries to write it but fails with error code 9.</div><div><br></div><div>I am running the command as root (not as sudo) so it should not be a permissions issue unless the backend is run by a different user.</div><div>If I run as an unprivileged user then I do not even get this far. In that case it tries to access the scanner but fails and is not even getting to the stage of Attaching to the scanner.</div><div>Also worth noting is that my Canon LiDE220 works fine with sane, which is another indicator that it is unlikely a permissions issue.<br></div></div></div></blockquote><div><br></div><div>Permissions are generally handled by udev which has rules based on USB ids to give permissions to non-root users.</div><div>Just adding the USB ids to the backend will not be sufficient. You *could* add the USB ids to a udev file such as /lib/udev/hwdb.d/20-sane.hwdb followed by running something like <br></div><div><span lang="en"><span><b><br></b></span></span></div><div><span lang="en"><span><b>udevadm control --reload-rules</b></span></span></div><div><span lang="en"><span><b><br></b></span></span></div><div><span lang="en"><span>...as root. This should allow you to connect to the device<b> </b>as a regular scanning user.<b><br></b></span></span></div><div> </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"><div><div></div><div><br></div><div>So based on the trace and on the source code it looks like it is: </div><div><ul><li>Attaching to the scanner.</li><li><code>SANE_Status</code> = <code>SANE_STATUS_GOOD</code> in reply to <code>sanei_usb_open</code></li><li>starts building an inquiry</li><li>tries to send the inquiry</li><li>fails to do <code>sanei_usb_write_bulk</code></li><li>sanei_usb.c responds with error</li></ul></div><div>How can I see log entries from sanei_usb.c code?</div><div><br></div></div></div></blockquote><div><br></div><div>I believe SANE_DEBUG_SANEI_USB=5 will give you some info about sanei USB operations. Greater value gives you more info.</div><div><br></div></div><div class="gmail_quote">Cheers,</div><div class="gmail_quote">Ralph<br></div></div>
</blockquote></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">"well, I stand up next to a mountain- and I chop it down with the edge of my hand"</div>
</blockquote></div>