访问USB扫描

2024-04-18 20:43:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要能够与USB扫描仪接口(特别是爱普生完美V550)。我尝试过ImageScanner,但它似乎找不到我的设备(我也尝试过安装twain,但它有问题说

Could not find any downloads that satisfy the requirement twain.)

所以我转而转向PyUSB,它可以看到设备就在那里。我现在的问题是,我不知道我需要发送什么设备,它扫描和发送回我的图片。在

下面是我运行的代码:

^{pr2}$

结果是:

CONFIGURATION 1: 2 mA ====================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x20 (32 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x1
   iConfiguration       :    0x0
   bmAttributes         :   0xc0 Self Powered
   bMaxPower            :    0x1 (2 mA)
    INTERFACE 0: Vendor Specific ===========================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :   0xff Vendor Specific
     bInterfaceSubClass :   0xff
     bInterfaceProtocol :   0xff
     iInterface         :    0x0
      ENDPOINT 0x81: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x81 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :  0x200 (512 bytes)
       bInterval        :   0xff
      ENDPOINT 0x2: Bulk OUT ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x2 OUT
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :  0x200 (512 bytes)
       bInterval        :   0xff

Tags: inbytesbulkendpointvendorspecificmatwain
1条回答
网友
1楼 · 发布于 2024-04-18 20:43:09

如果你能让你的扫描仪在Windows下工作,你能做的就是在linux主机上设置一个Windows虚拟机。我推荐gnome-box/KVM。您将需要一台带有CPU虚拟化扩展的主机(大多数现代CPU都有这种功能)。在

然后在主机上安装Wireshark。usnigwireshark,你可以监视Windows扫描仪驱动程序和设备之间的USB通信。基于此,你可以对USB协议进行逆向工程。一旦您理解了协议,使用PyUSB实现它就相对容易了。在

相关问题 更多 >