简体   繁体   English

在Java GUI中检测USB的Python脚本

[英]Python script to detect USBs in java GUI

I'm making a java GUI application (javafx) that calls a python script (python2.7) which detects connected devices. 我正在制作一个Java GUI应用程序(javafx),该应用程序调用检测连接设备的python脚本(python2.7)。 The reason for this is so I can automate my connections with multiple devices. 这样做的原因是我可以自动与多个设备建立连接。

In my python script, I use pyusb. 在我的python脚本中,我使用pyusb。 However to detect a device, I have to use inf_wizard.exe from libusb-win32 to communicate with the device. 但是,要检测设备,我必须使用libusb-win32中的inf_wizard.exe与该设备进行通信。 This is fine for my own development and debugging, but what happens if I wish to deploy this app and have other users use this? 这对于我自己的开发和调试来说很好,但是如果我希望部署该应用程序并让其他用户使用该应用程序会怎样?

Would this app, on another computer, be able to detect a device? 此应用程序在另一台计算机上是否能够检测到设备?

Thanks 谢谢

Please let me know if there is a better way to doing this. 如果有更好的方法,请告诉我。

No, in most (Windows) scenarios this will not work. 不可以,在大多数情况下(Windows),这是行不通的。 The problem is that libusb on Windows uses a special backend (libusb0.sys, libusbK.sys or winusb.sys). 问题是Windows上的libusb使用特殊的后端(libusb0.sys,libusbK.sys或winusb.sys)。 You have to install one of those backends (libusb-win32 is libusb0.sys) on every machine you want your software to run on. 您必须在要运行软件的每台计算机上安装这些后端之一(libusb-win32为libusb0.sys)。 Under Linux this should work fine out of the box. 在Linux下,这应该可以立即使用。

Essentially you have to ship the files you generate with inf_wizard.exe with your software and install the inf (needs elevated privileges) before you can use the device with your software. 本质上,您必须将使用inf_wizard.exe生成的文件与软件一起运输,并安装inf(需要提升的特权),然后才能将设备与软件一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM