Webusb для сканирования документов

Кто-нибудь успешно настроил webusb для сканирования документа? Я могу подключиться к USB-сканеру, но не смог найти документацию по командам для сканирования документов:

$lsusb -v

Bus 001 Device 007: ID 1083:163e Canon Electronics, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         1 
  bMaxPacketSize0        64
  idVendor           0x1083 Canon Electronics, Inc.
  idProduct          0x163e 
  bcdDevice            2.02
  iManufacturer           1 CANON   
  iProduct                2 CANON   DR-M160         
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass         0 (Defined at Interface level)
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               6
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         1 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

В приведенном ниже коде проверяется низкоуровневая передача, однако даже PromiseStatus помечен как разрешенный, статус остановлен, а статус device.transferIn остается ожидающим. Я не смог пойти дальше, так как не нашел документации ни на свой сканер, ни на любой другой сканер.

navigator.usb.requestDevice({ filters: [{ vendorId: 0x1083 }] })
.then(selectedDevice => {
   device = selectedDevice;
   return device.open(); // Begin a session.
 })
.then(() => device.selectConfiguration(1)) 
.then(() => device.claimInterface(0)) 
.then(() => device.controlTransferOut({
    requestType: 'vendor',
    recipient: 'device',
    request: 0x22,
    value: 0x01,
    index: 0x01})) 
.then(() => device.transferIn(1, 64)) // Waiting for 64 bytes of data from endpoint #1.
.then(result => {
  let decoder = new TextDecoder();
  console.log('Received: ' + decoder.decode(result.data));
})
.catch(error => { console.log(error); });

Благодарю вас !


person Hatem    schedule 07.01.2018    source источник
comment
Я использовал ядро ​​​​usbmon для мониторинга USB, и вот что происходит, когда команда xsane fire scan просто удаляет URBtag и временную метку из начала каждой строки. В целом после большого количества вводов прерываний (Ii) xsane fire Массовая команда вывода (Bo) C Ii:1:004:1 0:8 4 = 00000000 S Ii:1:004:1 -115:8 4 < S Bo:1:113:2 -115 24 = 00000014 00019000 00000000 31000000 00000000 00000000 C Bo:1:113:2 0 24 > S Bi:1:113:1 -115 8 < C Bi:1:113:1 0 8 = 00000000 00000000 S Bi:1:113:1 -115 8 < C Bi:1:113:1 0 8 = 00000000 00000000   -  person Hatem    schedule 09.01.2018
comment
еще не нашел решения, но любой, кто хочет сделать нечто подобное здесь, должен начать с для моего случая это canon dr-m160 ... и если вы знакомы с emscripten, это может спасти вам жизнь :)   -  person Hatem    schedule 11.01.2018


Ответы (4)


Сомневаюсь, что вам удалось соединиться с устройством. Прочитав спецификацию по безопасности, вы увидите, что устройство должно делать некоторые изменения будут доступны через webusb, а в вашем сканере ничего подобного нет.

Мои попытки использовать WebUSB привели меня к покупке микроконтроллера arduino для простого теста. Для получения дополнительной информации вы можете прочитать это статья о WebUSB на веб-сайте Google Developer. Назначение этого микроконтроллера — использовать его в качестве прокси/посредника между ПК и сканером, поскольку я полностью контролирую микроконтроллер и могу правильно настроить его для использования с WebUSB.

person Gramic    schedule 29.01.2018
comment
Если вы не можете сделать это с ПК, вы не можете сделать это с ардуино. Я могу правильно подключиться к своему устройству, однако, похоже, есть проблема с реализацией chrome webusb, которую я все еще исследую. - person Hatem; 30.01.2018
comment
Я подключился через WebUSB к ардуино и общался с ним без проблем. Я утверждаю, что вы не можете сделать то же самое со сканером, потому что у вас нет разрешений. Вы читали что-нибудь простое со своего подключенного сканера через webusb? Модель например. Это будет доказательством того, что вы правильно подключились и общались с ним. - person Gramic; 30.01.2018
comment
Да, я могу подключиться и получить конфигурацию и даже отправить некоторые команды (Co, Bo) и прочитать ответ сканера (Bi)... и т. д. Я не думаю, что это проблема с разрешением, поскольку Sane может сделать это без проблем, поэтому обычно это можно сделать с помощью webusb. - person Hatem; 31.01.2018
comment
Странно, что вам удалось правильно подключиться через WebUSB к вашему сканеру. Даже посылать какие-то команды! Даже этого у меня не получилось. - person Gramic; 02.02.2018

Я пытаюсь настроить сканирование через WebUSB на CanoScan LiDE 25. Он использует чип plustek.

// http://www.linux-usb.org/usb.ids
// 04a9 Canon, Inc.
// 2200  CanoScan LiDE 25
navigator.usb.requestDevice({ filters: [{ vendorId: 0x04a9 }] })
.then(device => {
    console.log(device.productName);      // "CanonScan"
    console.log(device.manufacturerName); // "Canon"
})
.catch(error => { console.log(error); });

В настоящее время я пытаюсь реконструировать протокол с помощью wireshark и USBMon. Ребята из sane это уже сделали (https://gitlab.com/sane-project/backends/blob/master/backend/plustek.c)

Сеанс трассировки Wireshark USBMon

На картинке выше вы можете увидеть трассировку с помощью Wireshark и команды:

export SANE_DEBUG_DLL=255 # enabled debug logging for sane
scanimage -p --resolution 150 --mode Gray -x 210 -y 297 > image.pnm

Это не ответ на ваш вопрос. Тем не менее он показывает путь.

Я ожидаю, что самым инновационным будет скомпилировать sane с помощью emscripten (https://github.com/kripken/emscripten) в javascript, а затем использовать его напрямую.

Вот еще несколько результатов отладки при включении журнала отладки драйвера plustek:

$ export SANE_DEBUG_PLUSTEK=12
$ scanimage -L
[sanei_debug] Setting debug level of dll to 0.
[sanei_debug] Setting debug level of plustek to 12.
[plustek] Plustek backend V0.52-12, part of sane-backends 1.0.25git
[plustek] Retrieving all supported and conntected devices
[plustek] Available and supported devices:
[plustek] Device: >libusb:001:008< - 0x04a9x0x2220
[plustek] ># Plustek-SANE Backend configuration file<
[plustek] ># For use with LM9831/2/3 based USB scanners<
[plustek] >#<
[plustek] ><
[plustek] ># each device needs at least two lines:<
[plustek] ># - [usb] vendor-ID and product-ID<
[plustek] ># - device devicename<
[plustek] ># i.e. for Plustek (0x07B3) UT12/16/24 (0x0017)<
[plustek] ># [usb] 0x07B3 0x0017<
[plustek] ># device /dev/usbscanner<
[plustek] ># or<
[plustek] ># device libusb:bbb:ddd<
[plustek] ># where bbb is the busnumber and ddd the device number<
[plustek] ># make sure that your user has access to /proc/bus/usb/bbb/ddd<
[plustek] >#<
[plustek] ># additionally you can specify some options<
[plustek] ># warmup, lOffOnEnd, lampOff<
[plustek] >#<
[plustek] ># For autodetection use<
[plustek] ># [usb]<
[plustek] ># device /dev/usbscanner<
[plustek] >#<
[plustek] ># or simply<
[plustek] ># [usb]<
[plustek] >#<
[plustek] ># or if you want a specific device but you have no idea about the<
[plustek] ># device node or you use libusb, simply set vendor- and product-ID<
[plustek] ># [usb] 0x07B3 0x0017<
[plustek] ># device auto<
[plustek] >#<
[plustek] ># NOTE: autodetection is safe, as it uses the info it got<
[plustek] >#       from the USB subsystem. If you're not using the<
[plustek] >#       autodetection, you MUST have attached that device<
[plustek] >#       at your USB-port, that you have specified...<
[plustek] >#<
[plustek] ><
[plustek] >[usb]<
[plustek] next device uses autodetection
[plustek] ... next device
[plustek] ><
[plustek] >#<
[plustek] ># options for the previous USB entry<
[plustek] >#<
[plustek] ># switch lamp off after xxx secs, 0 disables the feature<
[plustek] ># (can also be set via frontend)<
[plustek] >option lampOff 300<
[plustek] Decoding option >lampOff<
[plustek] ><
[plustek] ># warmup period in seconds, 0 means no warmup, -1 means auto-warmup<
[plustek] ># (can also be set via frontend)<
[plustek] >option warmup -1<
[plustek] Decoding option >warmup<
[plustek] ><
[plustek] ># 0 means leave lamp-status untouched, not 0 means switch off<
[plustek] ># on sane_close<
[plustek] ># (can also be set via frontend)<
[plustek] >option lOffOnEnd 1<
[plustek] Decoding option >lOffOnEnd<
[plustek] ><
[plustek] >#<
[plustek] ># options to tweak the image start-position<
[plustek] ># (WARNING: there's no internal range check!!!)<
[plustek] >#<
[plustek] ># for the normal scan area<
[plustek] >#<
[plustek] >option posOffX 0<
[plustek] Decoding option >posOffX<
[plustek] >option posOffY 0<
[plustek] Decoding option >posOffY<
[plustek] ><
[plustek] ># for transparencies<
[plustek] >option tpaOffX 0<
[plustek] Decoding option >tpaOffX<
[plustek] >option tpaOffY 0<
[plustek] Decoding option >tpaOffY<
[plustek] ><
[plustek] ># for negatives<
[plustek] >option negOffX 0<
[plustek] Decoding option >negOffX<
[plustek] >option negOffY 0<
[plustek] Decoding option >negOffY<
[plustek] ><
[plustek] >#<
[plustek] ># for setting the calibration strip position<
[plustek] ># (WARNING: there's no internal range check!!!)<
[plustek] ># -1 means use built in<
[plustek] ># (can also be set via frontend)<
[plustek] >option posShadingY -1<
[plustek] Decoding option >posShadingY<
[plustek] >option tpaShadingY -1<
[plustek] Decoding option >tpaShadingY<
[plustek] >option negShadingY -1<
[plustek] Decoding option >negShadingY<
[plustek] ><
[plustek] >#<
[plustek] ># to invert the negatives, 0 disables the feature<
[plustek] >#<
[plustek] >option invertNegatives 0<
[plustek] Decoding option >invertNegatives<
[plustek] ><
[plustek] >#<
[plustek] ># to disable the internal sensor speedup function,<
[plustek] ># 1 disables the feature<
[plustek] >#<
[plustek] >option disableSpeedup 0<
[plustek] Decoding option >disableSpeedup<
[plustek] ><
[plustek] >#<
[plustek] ># to save/restore coarse calibration data<
[plustek] ># (can also be set via frontend)<
[plustek] >option cacheCalData 0<
[plustek] Decoding option >cacheCalData<
[plustek] ><
[plustek] >#<
[plustek] ># use alternate calibration routines<
[plustek] >#<
[plustek] >option altCalibration 0<
[plustek] Decoding option >altCalibration<
[plustek] ><
[plustek] >#<
[plustek] ># for skipping whole calibration step<
[plustek] >#<
[plustek] >option skipCalibration 0<
[plustek] Decoding option >skipCalibration<
[plustek] ><
[plustek] >#<
[plustek] ># for skipping entire fine calibration step<
[plustek] ># coarse calibration is done<
[plustek] >#<
[plustek] >option skipFine 0<
[plustek] Decoding option >skipFine<
[plustek] ><
[plustek] >#<
[plustek] ># discard the result of the fine white calibration<
[plustek] >#<
[plustek] >option skipFineWhite 0<
[plustek] Decoding option >skipFineWhite<
[plustek] ><
[plustek] >#<
[plustek] ># some scanners have a dark calibration strip, in<
[plustek] ># general this one should be used for calibration.<
[plustek] ># As this could cause some trouble, this option<
[plustek] ># overrides that and the dark calibration will be<
[plustek] ># done by switching the lamp off<
[plustek] >#<
[plustek] >option skipDarkStrip 0<
[plustek] Decoding option >skipDarkStrip<
[plustek] ><
[plustek] ># for replacing the gain values found during coarse<
[plustek] ># calibration<
[plustek] ># (can also be set via frontend)<
[plustek] >option red_gain   -1<
[plustek] Decoding option >red_gain<
[plustek] >option green_gain -1<
[plustek] Decoding option >green_gain<
[plustek] >option blue_gain  -1<
[plustek] Decoding option >blue_gain<
[plustek] ><
[plustek] ># for replacing the offset values found during coarse<
[plustek] ># calibration<
[plustek] ># (can also be set via frontend)<
[plustek] >option red_offset   -1<
[plustek] Decoding option >red_offset<
[plustek] >option green_offset -1<
[plustek] Decoding option >green_offset<
[plustek] >option blue_offset  -1<
[plustek] Decoding option >blue_offset<
[plustek] ><
[plustek] >#<
[plustek] ># for replacing the default lampoff settings, this<
[plustek] ># works only for CIS devices like CanoScan LiDE20<
[plustek] ># (can also be set via frontend)<
[plustek] >option red_lampoff   -1<
[plustek] Decoding option >red_lampoff<
[plustek] >option green_lampoff -1<
[plustek] Decoding option >green_lampoff<
[plustek] >option blue_lampoff  -1<
[plustek] Decoding option >blue_lampoff<
[plustek] ><
[plustek] >#<
[plustek] ># for adjusting the default gamma values<
[plustek] ># (can also be set via frontend)<
[plustek] >option redGamma         1.0<
[plustek] Decoding option >redGamma<
[plustek] >option greenGamma       1.0<
[plustek] Decoding option >greenGamma<
[plustek] >option blueGamma        1.0<
[plustek] Decoding option >blueGamma<
[plustek] >option grayGamma        1.0<
[plustek] Decoding option >grayGamma<
[plustek] ><
[plustek] >#<
[plustek] ># to enable TPA (EPSON or UMAX, if autodetection fails)<
[plustek] ># 0 means default behaviour as specified in the internal tables<
[plustek] ># 1 means enable (needed for UMAX 3450)<
[plustek] >option enableTPA 0<
[plustek] Decoding option >enableTPA<
[plustek] ><
[plustek] >#<
[plustek] ># model override functionality, currently only available for<
[plustek] ># Mustek devices, using NSCs' vendor ID: 0x0400 and<
[plustek] ># also their product ID: 0x1000 (LM9831) 0x1001 (LM9832)<
[plustek] >#<
[plustek] ># mov/PID    |    0x1000   |   0x1001<
[plustek] ># ---------------------------------------<
[plustek] ># 0 (default)| BearPaw1200 | BearPaw 2400<
[plustek] ># 1          |   ignored   | BearPaw 1200<
[plustek] >#<
[plustek] >option mov 0<
[plustek] Decoding option >mov<
[plustek] ><
[plustek] >#<
[plustek] ># and of course the device-name<
[plustek] >#<
[plustek] ># device /dev/usbscanner<
[plustek] >device auto<
[plustek] Decoding device name >auto<
[plustek] ><
[plustek] >#<
[plustek] ># to define a new device, start with a new section:<
[plustek] ># [usb]<
[plustek] >#<
[plustek] attach (auto, 0x7ffdc9adc760, (nil))
[plustek] Device configuration:
[plustek] device name  : >auto<
[plustek] USB-ID       : ><
[plustek] model ovr.   : 0
[plustek] warmup       : -1s
[plustek] lampOff      : 300
[plustek] lampOffOnEnd : yes
[plustek] cacheCalData : no
[plustek] altCalibrate : no
[plustek] skipCalibr.  : no
[plustek] skipFine     : no
[plustek] skipFineWhite: no
[plustek] skipDarkStrip: no
[plustek] incDarkTarget: yes
[plustek] invertNegs.  : no
[plustek] dis.Speedup  : no
[plustek] pos_x        : 0
[plustek] pos_y        : 0
[plustek] pos_shading_y: -1
[plustek] neg_x        : 0
[plustek] neg_y        : 0
[plustek] neg_shading_y: -1
[plustek] tpa_x        : 0
[plustek] tpa_y        : 0
[plustek] tpa_shading_y: -1
[plustek] red gain     : -1
[plustek] green gain   : -1
[plustek] blue gain    : -1
[plustek] red offset   : -1
[plustek] green offset : -1
[plustek] blue offset  : -1
[plustek] red lampoff  : -1
[plustek] green lampoff: -1
[plustek] blue lampoff : -1
[plustek] red Gamma    : 1.00
[plustek] green Gamma  : 1.00
[plustek] blue Gamma   : 1.00
[plustek] gray Gamma   : 1.00
[plustek] ---------------------
[plustek] usbDev_open(auto,) - 0x5555ca4dbe90
[plustek] Vendor ID=0x04A9, Product ID=0x2220
[plustek] usbio_DetectLM983x
[plustek] usbio_DetectLM983x: found LM9832/3
[plustek]  * setting device to idle state!
[plustek] Detected vendor & product ID: 0x04A9-0x2220
[plustek] Device description for >0x04A9-0x2220< found.
[plustek] usb_initDev(43,0x04a9,-1)
[plustek] Device WAF  : 0x00004002
[plustek] Transferrate: 1000000 Bytes/s
[plustek] Device Flags: 0x00000000
[plustek] Vendor adjusted to: >Canon<
[plustek] LAMP-STATUS: 0x00000000 (off)
[plustek] RESETTING REGISTERS(-1) - 0x80
[plustek] MISC I/O after RESET: 0x66, 0x16, 0x91
[plustek] Calibration file-names set to:
[plustek] >/home/manuel/.sane/Canon_CanoScan_LiDE25-coarse.cal<
[plustek] >/home/manuel/.sane/Canon_CanoScan_LiDE25-fine.cal<
[plustek] usb_SetScanParameters()
[plustek] usb_GetMCLKDivider()
[plustek] usb_GetMCLKDiv()
[plustek] * PhyBytes   = 6
[plustek] * PhyLines   = 4
[plustek] * TotalBytes = 24
[plustek] * Scansteps=72 (9*1200/150)
[plustek] usb_SetScanParameters() done.
[plustek] usbDev_getCaps()
[plustek] Scanner information:
[plustek] Vendor : Canon
[plustek] Model  : CanoScan LiDE25
[plustek] Flags  : 0x00000000
[plustek] drvclose()
[plustek] usbDev_stopScan()
[plustek] usbDev_ScanEnd(), start=0, park=0
[plustek] usbDev_close()
[plustek] attach: model = >CanoScan LiDE25<
[plustek] sane_get_devices (0x7ffdc9ade8e0, 0)
device `plustek:libusb:001:008' is a Canon CanoScan LiDE25 flatbed scanner
[plustek] sane_exit
[plustek] Shutdown called (dev->fd=-1, libusb:001:008)
[plustek] Waiting for scanner-ready...
[plustek] Switching lamp off...
[plustek] LAMP-STATUS: 0x00000000 (off)
[plustek] LAMP-STATUS: 0x00000000 (off)
[plustek] Lamp-Timer stopped

Вот что выдает при сканировании

scanimage -p --resolution 150 --mode Gray -x 210 -y 297 > image.pnm
[sanei_debug] Setting debug level of dll to 0.
[sanei_debug] Setting debug level of plustek to 12.
[plustek] Plustek backend V0.52-12, part of sane-backends 1.0.25git
[plustek] Retrieving all supported and conntected devices
[plustek] Available and supported devices:
[plustek] Device: >libusb:001:008< - 0x04a9x0x2220
[plustek] ># Plustek-SANE Backend configuration file<
[plustek] ># For use with LM9831/2/3 based USB scanners<
[plustek] >#<
[plustek] ><
[plustek] ># each device needs at least two lines:<
[plustek] ># - [usb] vendor-ID and product-ID<
[plustek] ># - device devicename<
[plustek] ># i.e. for Plustek (0x07B3) UT12/16/24 (0x0017)<
[plustek] ># [usb] 0x07B3 0x0017<
[plustek] ># device /dev/usbscanner<
[plustek] ># or<
[plustek] ># device libusb:bbb:ddd<
[plustek] ># where bbb is the busnumber and ddd the device number<
[plustek] ># make sure that your user has access to /proc/bus/usb/bbb/ddd<
[plustek] >#<
[plustek] ># additionally you can specify some options<
[plustek] ># warmup, lOffOnEnd, lampOff<
[plustek] >#<
[plustek] ># For autodetection use<
[plustek] ># [usb]<
[plustek] ># device /dev/usbscanner<
[plustek] >#<
[plustek] ># or simply<
[plustek] ># [usb]<
[plustek] >#<
[plustek] ># or if you want a specific device but you have no idea about the<
[plustek] ># device node or you use libusb, simply set vendor- and product-ID<
[plustek] ># [usb] 0x07B3 0x0017<
[plustek] ># device auto<
[plustek] >#<
[plustek] ># NOTE: autodetection is safe, as it uses the info it got<
[plustek] >#       from the USB subsystem. If you're not using the<
[plustek] >#       autodetection, you MUST have attached that device<
[plustek] >#       at your USB-port, that you have specified...<
[plustek] >#<
[plustek] ><
[plustek] >[usb]<
[plustek] next device uses autodetection
[plustek] ... next device
[plustek] ><
[plustek] >#<
[plustek] ># options for the previous USB entry<
[plustek] >#<
[plustek] ># switch lamp off after xxx secs, 0 disables the feature<
[plustek] ># (can also be set via frontend)<
[plustek] >option lampOff 300<
[plustek] Decoding option >lampOff<
[plustek] ><
[plustek] ># warmup period in seconds, 0 means no warmup, -1 means auto-warmup<
[plustek] ># (can also be set via frontend)<
[plustek] >option warmup -1<
[plustek] Decoding option >warmup<
[plustek] ><
[plustek] ># 0 means leave lamp-status untouched, not 0 means switch off<
[plustek] ># on sane_close<
[plustek] ># (can also be set via frontend)<
[plustek] >option lOffOnEnd 1<
[plustek] Decoding option >lOffOnEnd<
[plustek] ><
[plustek] >#<
[plustek] ># options to tweak the image start-position<
[plustek] ># (WARNING: there's no internal range check!!!)<
[plustek] >#<
[plustek] ># for the normal scan area<
[plustek] >#<
[plustek] >option posOffX 0<
[plustek] Decoding option >posOffX<
[plustek] >option posOffY 0<
[plustek] Decoding option >posOffY<
[plustek] ><
[plustek] ># for transparencies<
[plustek] >option tpaOffX 0<
[plustek] Decoding option >tpaOffX<
[plustek] >option tpaOffY 0<
[plustek] Decoding option >tpaOffY<
[plustek] ><
[plustek] ># for negatives<
[plustek] >option negOffX 0<
[plustek] Decoding option >negOffX<
[plustek] >option negOffY 0<
[plustek] Decoding option >negOffY<
[plustek] ><
[plustek] >#<
[plustek] ># for setting the calibration strip position<
[plustek] ># (WARNING: there's no internal range check!!!)<
[plustek] ># -1 means use built in<
[plustek] ># (can also be set via frontend)<
[plustek] >option posShadingY -1<
[plustek] Decoding option >posShadingY<
[plustek] >option tpaShadingY -1<
[plustek] Decoding option >tpaShadingY<
[plustek] >option negShadingY -1<
[plustek] Decoding option >negShadingY<
[plustek] ><
[plustek] >#<
[plustek] ># to invert the negatives, 0 disables the feature<
[plustek] >#<
[plustek] >option invertNegatives 0<
[plustek] Decoding option >invertNegatives<
[plustek] ><
[plustek] >#<
[plustek] ># to disable the internal sensor speedup function,<
[plustek] ># 1 disables the feature<
[plustek] >#<
[plustek] >option disableSpeedup 0<
[plustek] Decoding option >disableSpeedup<
[plustek] ><
[plustek] >#<
[plustek] ># to save/restore coarse calibration data<
[plustek] ># (can also be set via frontend)<
[plustek] >option cacheCalData 0<
[plustek] Decoding option >cacheCalData<
[plustek] ><
[plustek] >#<
[plustek] ># use alternate calibration routines<
[plustek] >#<
[plustek] >option altCalibration 0<
[plustek] Decoding option >altCalibration<
[plustek] ><
[plustek] >#<
[plustek] ># for skipping whole calibration step<
[plustek] >#<
[plustek] >option skipCalibration 0<
[plustek] Decoding option >skipCalibration<
[plustek] ><
[plustek] >#<
[plustek] ># for skipping entire fine calibration step<
[plustek] ># coarse calibration is done<
[plustek] >#<
[plustek] >option skipFine 0<
[plustek] Decoding option >skipFine<
[plustek] ><
[plustek] >#<
[plustek] ># discard the result of the fine white calibration<
[plustek] >#<
[plustek] >option skipFineWhite 0<
[plustek] Decoding option >skipFineWhite<
[plustek] ><
[plustek] >#<
[plustek] ># some scanners have a dark calibration strip, in<
[plustek] ># general this one should be used for calibration.<
[plustek] ># As this could cause some trouble, this option<
[plustek] ># overrides that and the dark calibration will be<
[plustek] ># done by switching the lamp off<
[plustek] >#<
[plustek] >option skipDarkStrip 0<
[plustek] Decoding option >skipDarkStrip<
[plustek] ><
[plustek] ># for replacing the gain values found during coarse<
[plustek] ># calibration<
[plustek] ># (can also be set via frontend)<
[plustek] >option red_gain   -1<
[plustek] Decoding option >red_gain<
[plustek] >option green_gain -1<
[plustek] Decoding option >green_gain<
[plustek] >option blue_gain  -1<
[plustek] Decoding option >blue_gain<
[plustek] ><
[plustek] ># for replacing the offset values found during coarse<
[plustek] ># calibration<
[plustek] ># (can also be set via frontend)<
[plustek] >option red_offset   -1<
[plustek] Decoding option >red_offset<
[plustek] >option green_offset -1<
[plustek] Decoding option >green_offset<
[plustek] >option blue_offset  -1<
[plustek] Decoding option >blue_offset<
[plustek] ><
[plustek] >#<
[plustek] ># for replacing the default lampoff settings, this<
[plustek] ># works only for CIS devices like CanoScan LiDE20<
[plustek] ># (can also be set via frontend)<
[plustek] >option red_lampoff   -1<
[plustek] Decoding option >red_lampoff<
[plustek] >option green_lampoff -1<
[plustek] Decoding option >green_lampoff<
[plustek] >option blue_lampoff  -1<
[plustek] Decoding option >blue_lampoff<
[plustek] ><
[plustek] >#<
[plustek] ># for adjusting the default gamma values<
[plustek] ># (can also be set via frontend)<
[plustek] >option redGamma         1.0<
[plustek] Decoding option >redGamma<
[plustek] >option greenGamma       1.0<
[plustek] Decoding option >greenGamma<
[plustek] >option blueGamma        1.0<
[plustek] Decoding option >blueGamma<
[plustek] >option grayGamma        1.0<
[plustek] Decoding option >grayGamma<
[plustek] ><
[plustek] >#<
[plustek] ># to enable TPA (EPSON or UMAX, if autodetection fails)<
[plustek] ># 0 means default behaviour as specified in the internal tables<
[plustek] ># 1 means enable (needed for UMAX 3450)<
[plustek] >option enableTPA 0<
[plustek] Decoding option >enableTPA<
[plustek] ><
[plustek] >#<
[plustek] ># model override functionality, currently only available for<
[plustek] ># Mustek devices, using NSCs' vendor ID: 0x0400 and<
[plustek] ># also their product ID: 0x1000 (LM9831) 0x1001 (LM9832)<
[plustek] >#<
[plustek] ># mov/PID    |    0x1000   |   0x1001<
[plustek] ># ---------------------------------------<
[plustek] ># 0 (default)| BearPaw1200 | BearPaw 2400<
[plustek] ># 1          |   ignored   | BearPaw 1200<
[plustek] >#<
[plustek] >option mov 0<
[plustek] Decoding option >mov<
[plustek] ><
[plustek] >#<
[plustek] ># and of course the device-name<
[plustek] >#<
[plustek] ># device /dev/usbscanner<
[plustek] >device auto<
[plustek] Decoding device name >auto<
[plustek] ><
[plustek] >#<
[plustek] ># to define a new device, start with a new section:<
[plustek] ># [usb]<
[plustek] >#<
[plustek] attach (auto, 0x7ffeffed9fa0, (nil))
[plustek] Device configuration:
[plustek] device name  : >auto<
[plustek] USB-ID       : ><
[plustek] model ovr.   : 0
[plustek] warmup       : -1s
[plustek] lampOff      : 300
[plustek] lampOffOnEnd : yes
[plustek] cacheCalData : no
[plustek] altCalibrate : no
[plustek] skipCalibr.  : no
[plustek] skipFine     : no
[plustek] skipFineWhite: no
[plustek] skipDarkStrip: no
[plustek] incDarkTarget: yes
[plustek] invertNegs.  : no
[plustek] dis.Speedup  : no
[plustek] pos_x        : 0
[plustek] pos_y        : 0
[plustek] pos_shading_y: -1
[plustek] neg_x        : 0
[plustek] neg_y        : 0
[plustek] neg_shading_y: -1
[plustek] tpa_x        : 0
[plustek] tpa_y        : 0
[plustek] tpa_shading_y: -1
[plustek] red gain     : -1
[plustek] green gain   : -1
[plustek] blue gain    : -1
[plustek] red offset   : -1
[plustek] green offset : -1
[plustek] blue offset  : -1
[plustek] red lampoff  : -1
[plustek] green lampoff: -1
[plustek] blue lampoff : -1
[plustek] red Gamma    : 1.00
[plustek] green Gamma  : 1.00
[plustek] blue Gamma   : 1.00
[plustek] gray Gamma   : 1.00
[plustek] ---------------------
[plustek] usbDev_open(auto,) - 0x55e6fbc6e5a0
[plustek] Vendor ID=0x04A9, Product ID=0x2220
[plustek] usbio_DetectLM983x
[plustek] usbio_DetectLM983x: found LM9832/3
[plustek]  * setting device to idle state!
[plustek] Detected vendor & product ID: 0x04A9-0x2220
[plustek] Device description for >0x04A9-0x2220< found.
[plustek] usb_initDev(43,0x04a9,-1)
[plustek] Device WAF  : 0x00004002
[plustek] Transferrate: 1000000 Bytes/s
[plustek] Device Flags: 0x00000000
[plustek] Vendor adjusted to: >Canon<
[plustek] LAMP-STATUS: 0x00000000 (off)
[plustek] RESETTING REGISTERS(-1) - 0x80
[plustek] MISC I/O after RESET: 0x66, 0x16, 0x91
[plustek] Calibration file-names set to:
[plustek] >/home/manuel/.sane/Canon_CanoScan_LiDE25-coarse.cal<
[plustek] >/home/manuel/.sane/Canon_CanoScan_LiDE25-fine.cal<
[plustek] usb_SetScanParameters()
[plustek] usb_GetMCLKDivider()
[plustek] usb_GetMCLKDiv()
[plustek] * PhyBytes   = 6
[plustek] * PhyLines   = 4
[plustek] * TotalBytes = 24
[plustek] * Scansteps=72 (9*1200/150)
[plustek] usb_SetScanParameters() done.
[plustek] usbDev_getCaps()
[plustek] Scanner information:
[plustek] Vendor : Canon
[plustek] Model  : CanoScan LiDE25
[plustek] Flags  : 0x00000000
[plustek] drvclose()
[plustek] usbDev_stopScan()
[plustek] usbDev_ScanEnd(), start=0, park=0
[plustek] usbDev_close()
[plustek] attach: model = >CanoScan LiDE25<
[plustek] sane_get_devices (0x7ffeffedc120, 0)
[plustek] sane_open - libusb:001:008
[plustek] Presetting Gamma tables (len=4096)
[plustek] * Channel[0], gamma 2.000
[plustek] * Channel[1], gamma 2.000
[plustek] * Channel[2], gamma 2.000
[plustek] * Channel[3], gamma 2.000
[plustek] ----------------------------------
[plustek] sane_start
[plustek] usbDev_open(libusb:001:008,) - (nil)
[plustek] Vendor ID=0x04A9, Product ID=0x2220
[plustek] usbio_DetectLM983x
[plustek] usbio_DetectLM983x: found LM9832/3
[plustek] Detected vendor & product ID: 0x04A9-0x2220
[plustek] Device description for >0x04A9-0x2220< found.
[plustek] usb_initDev(43,0x04a9,43)
[plustek] Device WAF  : 0x00004002
[plustek] Transferrate: 1000000 Bytes/s
[plustek] Device Flags: 0x00000006
[plustek] Vendor adjusted to: >Canon<
[plustek] LAMP-STATUS: 0x00000000 (off)
[plustek] RESETTING REGISTERS(43) - 0x80
[plustek] MISC I/O after RESET: 0x66, 0x16, 0x91
[plustek] usbDev_getCaps()
[plustek] scanmode = 1
[plustek] usbDev_getCropInfo()
[plustek] usb_GetImageInfo()
[plustek] PPL = 1240
[plustek] LPA = 1753
[plustek] BPL = 1240
[plustek] brightness 0, contrast 0
[plustek] usbDev_setScanEnv()
[plustek] usb_SaveImageInfo()
[plustek] * dwFlag = 0x00000400
[plustek] usb_GetImageInfo()
[plustek] * Preview Mode NOT set!
[plustek] Setting map[3] at 0x55e6fbcf7254
[plustek] usbDev_startScan()
[plustek] LAMP-STATUS: 0x00000000 (off)
[plustek] Switching Lamp on
[plustek] Warmup-Timer started
[plustek] LAMP-STATUS: 0x00000001 (on)
[plustek] Lamp-Timer stopped
[plustek] dwflag = 0x40000400 dwBytesLine = 1240
[plustek] Lines          = 1753
[plustek] Bytes per Line = 1240
[plustek] Bitdepth       = 8
[plustek] TIME START
[plustek] local_sane_start done
[plustek] reader_process started (as thread)
[plustek] reader_process:starting to READ data (2173720 bytes)
[plustek] buf = 0x7f1864447010
[plustek] usbDev_PrepareScan()
[plustek] sane_start done
[plustek] cano_DoCalibration()
[plustek] #########################
[plustek] usb_SpeedTest(43,1000000)
[plustek] GETMCLK[10/1], using entry 8: 12.000, 1200
[plustek] SETMCLK[10/1]: 12.000
[plustek] usb_SetScanParameters()
[plustek] usb_GetMCLKDivider()
[plustek] usb_GetMCLKDiv()
[plustek] * PhyBytes   = 30606
[plustek] * PhyLines   = 1
[plustek] * TotalBytes = 30606
[plustek] usb_SetScanParameters() done.
[plustek] usb_ScanBegin()
[plustek] usb_DownloadShadingData(1)
[plustek] usb_ScanBegin() done.
[plustek] usb_IsDataAvailableInDRAM()
[plustek] Data is available
[plustek] usbDev_ScanEnd(), start=1, park=0
[plustek] usb_SetScanParameters()
[plustek] usb_GetMCLKDivider()
[plustek] usb_GetMCLKDiv()
[plustek] * PhyBytes   = 30606
[plustek] * PhyLines   = 1
[plustek] * TotalBytes = 30606
[plustek] usb_SetScanParameters() done.
[plustek] usb_ScanBegin()
[plustek] usb_DownloadShadingData(1)
[plustek] usb_ScanBegin() done.
[plustek] usb_IsDataAvailableInDRAM()
[plustek] Data is available
[plustek] usbDev_ScanEnd(), start=1, park=0
[plustek] usb_SetScanParameters()
[plustek] usb_GetMCLKDivider()
[plustek] usb_GetMCLKDiv()...

Надеюсь, это немного поможет Мануэлю

person Manuel_B    schedule 10.02.2018
comment
Все это уже сделано, и я скоро опубликую на github свой генератор обратного инжиниринга, даже пытался скомпилировать Sane с помощью emscripten, и это сложная часть, так как я столкнулся с ограничениями emscripten. Так что на самом деле проблема, похоже, связана с самой реализацией webusb chrome, поэтому все еще ищет. - person Hatem; 12.02.2018
comment
@Hatem Я также пробовал компиляцию с emscripten с теми же результатами: github.com/ManuelB/sane- backend-emscripten не работал должным образом :-( - person Manuel_B; 14.02.2018

Прошу прощения, что не увидел этот вопрос раньше. Я построил сканер (фактически двойной сканер), и он работает через веб-интерфейс: https://www.codemacs.com/other/anything/sane-on-freebsd-connecting-two-scanners-control-via-html.2314971.htm Один сканер еще проще.

person Chris Stainton    schedule 13.02.2021
comment
Спасибо, Крис, как вы упомянули, ваше решение требует, чтобы Sane был установлен на стороне клиента, а это не то, что мы ищем здесь. - person Hatem; 14.02.2021
comment
Нет, здравомыслящий находится на стороне сервера. Клиентом может быть любой пользователь с включенным браузером и JS (что составляет почти 100% клиентов). - person Chris Stainton; 15.02.2021
comment
У меня есть случай, когда несколько клиентов имеют сканер на стороне клиента, поэтому решение на стороне сервера не может помочь. - person Hatem; 17.02.2021

Я надеюсь, что это будет полезно, хотя это не прямой ответ на вопрос.

Потратив много времени на то, чтобы заставить WebUSB работать, попробуйте изучить другие варианты, и я нашел решение, которое хорошо работает для моего веб-приложения. Просто используйте scanimage для сканирования на сервер. Клиент отправляет запрос AJAX, сервер создает командную строку для запуска с shell_exec в PHP, затем использует file_get_contents или что-то еще с отсканированным изображением. В моей ситуации у сканера нет причин разговаривать с клиентом, так как изображение все равно попадет в базу данных на сервере.

См. также: сканирование документов на основе браузера

person aswine    schedule 31.07.2020
comment
Извините, это может быть вариант, только если сканер подключен к серверу, что не всегда так. Обычно сканер подключается к клиенту, поэтому я пробовал WebUSB... - person Hatem; 02.08.2020
comment
Хорошо. Это все еще иногда имеет место. Особенно, если у вас есть сетевой сканер, вы можете разместить сканер на столе клиента, но при этом подключить к нему сервер. - person aswine; 03.08.2020