使用python关闭windows中的特定USB端口

2024-09-30 20:25:33 发布

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


这是我的第一篇文章,我已经看到了越具体越好,所以我会尽量说得非常清楚,并提前感谢!在

我想要的:
我需要同时扫描2台或更多扫描仪的图像,这些扫描仪来自同一品牌和型号,在这种情况下爱普生完美V600,我需要不同的时间间隔,在20小时内至少捕获40次。

我的方法 我决定使用Windows,我已经有了一个Python程序,它只需要一个扫描仪,或者两个来自不同型号的扫描仪。但你们来的地方是:

问题
Windows总是用同一个扫描仪打印,因为它们来自同一品牌和型号,所以它总是使用同一个,我不能使用两个不同的扫描仪,因为这样会导致图像不可比较。不过,当我使用两个不同的扫描仪时,我没有这个问题。我需要找到一种方法来打印每台扫描仪。我想买一个USB集线器并用python控制它,但显然,如果在windows中实现libsub,我就无法控制它了。因此,我目前正在寻找一种方法来禁用特定的USB端口,这样程序将只识别一个设备,用它扫描,禁用该设备,重新启用另一个设备,依此类推。


我可以访问的内容:

  • 现在我在Conda环境中的python3.5版本中使用windows164位python内核3,Conda版本(4.5.11)。在
  • Ubuntu16.04,64位,Pynase在conda内部的Python3.5环境中工作(手头没有conda版本)。在
  • 一款爱普生完美V600。在
  • 两个Canon Lide200,只能在windows下运行,因为Ubuntu中没有驱动程序。

我也尝试过

  • 使用Ubuntu
    我认为这是个好主意,但是Epson drivers webpage无法连接到包含其余Epson文件的存储库,仅允许我部分下载这些文件,我已经尝试与Docky存储库的所有者联系,但他未能与我联系。
    错误:

W: The repository 'http://ppa.launchpad.net/docky-core/ppa/ubuntu Xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://ppa.launchpad.net/docky-core/ppa/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

  • 当我手动输入site's repository时,我发现 所有与XENIAL驱动程序的链接都断开了,实际上整个XENIAL 文件夹丢失。

  • 我也觉得忽略这条信息是个好主意,但是我 需要Epwoka驱动程序在Ubuntu中运行Epson扫描仪 一个完整的问题。除此之外,不知道爱普生是否 完美V600将有可能由 pyinsan lib,因为被标记为未测试。

使用Windows

  • 我想买一个USB集线器并按图示控制in this thread,但显然在windows中是不可能的。

  • 我已经安装了libsub,usb.util,libusb1,USB(用于核心功能)和usb1,但我不知道(我认为不可能)用它们来禁用和重新启用特定的USB端口。

  • 无法禁用驱动程序,因为这意味着所有USB都将关闭以连接扫描仪。

  • 设备管理器没有帮助,因为无法分辨哪个设备是哪个。

  • 无法更改扫描仪的名称(可以,打印机可以有特定的名称),但扫描仪不能。

  • 我不能再买扫描仪了,我和爱普生在一起。



我的扫描代码

import pyinsane2
def Scan(Device, dpi):
pyinsane2.init()
try:
    pyinsane2.set_scanner_opt(Device, 'resolution', [dpi])
    pyinsane2.set_scanner_opt(Device, 'mode', ['Color'])
    pyinsane2.maximize_scan_area(Device)
    scan_session = Device.scan(multiple=False)
    try:
        while True:
            scan_session.scan.read()
    except EOFError:
        pass
    Image = scan_session.images[-1]
finally:
    pyinsane2.exit()
return(Image)

devices = pyinsane2.get_devices()
image_a = Scan(devices[0], 75)
image_b = Scan(devices[1], 75)
a = devices[1]
b = devices[0]
a == b                                  #Different
a.dev_type == b.dev_type
a.model == b.model
a.name == b.name                        #Different
a.nice_name == b.nice_name
a.options == b.options
a.reload_options == b.reload_options    #Different
a.scan == b.scan                        #Different
a.srcs == b.srcs                        #Different
a.vendor == b.vendor

我在每个扫描仪里都放了一张便签,一张上面写着“a”,另一张上面写着“b”,它总是用我先插上的扫描仪进行扫描

这就是我想做的(妈妈手工操作):**This is what I'm trying to do**





这是我在python中尝试时得到的结果:

This is what I get

任何解决方案都会帮助我,发挥创造力!我在考虑使用一个.bat文件来禁用一个特定的端口,然后用Python调用它。但我找不到方法好了。留着请记住,手动操作不是20到40小时连续图像采集的选项。
谢谢!

~迭戈


Tags: 方法name图像scanrepositorydevice驱动程序usb