pyftdi问题与多处理

发布于 2025-02-05 21:12:59 字数 673 浏览 1 评论 0原文

我目前正在使用Adafruit的FT232H突破板(USB GPIO)使用Windows中的Pyftdi控制,使用Zadig安装的Libusbk 3.0.7驱动程序。它在各个方面都可以正常工作,但是对于这个特定的项目,我需要使用多处理模块。 但是,我无法让Pyftdi使用它。要复制我的问题,您只需运行这一点代码即可。

import multiprocessing as mp

import board

def func():
    print('This will crash')

p1 =  mp.Process(target=func)

p1.start()
p1.join()
p1.terminate

从我可以收集到的问题上,问题是,在实施新过程时,Python将再次导入板模块,要求运行FT232H,并试图声称它已经声称是USB界面,并提出此错误:

pyftdi.ftdi.ftdierror:usberror:[errno none] b'libusb0-dll:err [supert_inlefface]无法主张接口0,win Orror:当该文件已经存在时无法创建文件。

但是,如果我围绕此书进行编写,以便第二次未在新过程中导入董事会模块,则任何FT232H命令在新过程中运行都将不起作用。

有人对我如何以某种方式解决这个问题有任何想法吗?

I'm currently using a FT232H Breakout board (USB GPIO) from Adafruit that I am controlling with Pyftdi in Windows, using the libusbK 3.0.7 driver installed through ZADIG. It's working just fine in every aspect, but for this particular project I need to use the multiprocessing module.
However, I can't get Pyftdi to work with it. To replicate my issue, you can just run this bit of code.

import multiprocessing as mp

import board

def func():
    print('This will crash')

p1 =  mp.Process(target=func)

p1.start()
p1.join()
p1.terminate

From what I can gather, the problem is that when instanciating a new process, Python will once again import the board module, required to run the FT232H, and will attempt to claim it's USB interface which is already claimed, throwing this error:

pyftdi.ftdi.FtdiError: UsbError: [Errno None] b'libusb0-dll:err [claim_interface] could not claim interface 0, win error: Cannot create a file when that file already exists.

However, if I write around this so that the board module is not imported a second time for the new process, any FT232H commands ran in the new process will not work.

Anyone has any ideas on how I can tackle this somehow?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文