简体   繁体   English

OSX:我可以在不使用USB到串行驱动程序的情况下与USB到串行设备通信吗?

[英]OSX: Can I talk to a USB-to-serial device without using a USB-to-serial driver?

I have a chunk of code using POSIX APIs to talk to a device which is essentially a cp210x USB-to-serial device. 我有大量代码使用POSIX API与设备通讯,该设备本质上是cp210x USB到串行设备。

The code does work, but I had to install a kernel extension to make it happen. 该代码确实有效,但是我必须安装内核扩展才能实现。 Now, I don't want to install a kext. 现在,我不想安装kext。 This device's engineers have used a non-standard vendor ID and product ID for their device, so the proper driver for it doesn't notice that it will work. 该设备的工程师为他们的设备使用了非标准的供应商ID和产品ID,因此适合其的驱动程序不会注意到它会起作用。 Therefore, I have to edit the Info.plist for the kext, or make my own "codeless" kext, but either way I will have to get a kernel extension signed, which seems like a pain in the butt (I remember it was a huge ordeal just to get the right certificate to sign an app!) 因此,我必须编辑kext的Info.plist,或制作自己的“无代码” kext,但是无论哪种方式,我都必须对内核扩展进行签名,这似乎给屁股带来了痛苦(我记得那是一个麻烦。巨大的磨难只是为了获得正确的证书来签署应用程序!)

So basically, I was able to get it to work, but only after turning off kext signature checks globally, which is not something I want to do. 因此,基本上,我能够使它工作,但是只有在全局关闭kext签名检查之后,我才不想这样做。

Now, I have another chunk of code which uses IOKit to query the USB devices for a device which matches a given vendor ID and product ID and can show a bunch of properties about it. 现在,我还有另一段代码,该代码使用IOKit来查询USB设备中与给定供应商ID和产品ID相匹配的设备,并可以显示有关其的一系列属性。

Is there some way I can use IOKit, then, to open a serial connection to a USB-to-serial device, without having to install a kext? 有什么方法可以使用IOKit,而无需安装kext来打开与USB到串行设备的串行连接? (Maybe this chip is sufficiently generic that there is a proper way to do it already in OSX? USB-to-serial isn't exactly new technology.) (也许该芯片足够通用,以至于在OSX中已经有适当的方法可以做到这一点?USB到串行并不是完全新的技术。)

So if I understand correctly, you'd like to add an IOKit kext personality to the Serial-over-USB kernel driver from userspace? 因此,如果我理解正确,您想从用户空间向USB串行内核驱动程序添加IOKit kext个性吗? I'm not aware of a way of doing that. 我不知道这样做的方法。

Your options, as far as I'm aware, are: 据我所知,您的选择是:

  • The codeless kext you've been using. 您一直在使用的无代码kext。 For Mavericks and Yosemite you will indeed need to sign the kext. 对于小牛和优胜美地,您确实需要签名。 The actual signing is straightforward (trivial using Xcode), but you'll need to get the correct signing certificate from Apple. 实际的签名很简单(使用Xcode很简单),但是您需要从Apple获得正确的签名证书。 This is the form for it - you'll need to be a paid-up Mac Developer Program, and be prepared to wait up to 6 weeks. 这是它的表格 -您需要成为付费的Mac Developer Program,并准备等待长达6周的时间。

  • Accessing the device entirely from userspace. 完全从用户空间访问设备。 You can do this via IOKit directly , or you can use an open source wrapper library such as libusb . 您可以直接通过IOKit进行此操作 ,也可以使用开源包装程序库(例如libusb) Then you need to actually drive the serial-to-USB device via its USB protocol. 然后,您实际上需要通过其USB协议驱动串行转USB设备。 Maybe you can find an existing userspace driver for it; 也许您可以找到一个现有的用户空间驱动程序。 I haven't looked for one. 我没有找一个。 But in any case, you won't be able to access the device via the POSIX interfaces, as everything will live inside your userspace process. 但是无论如何,您将无法通过POSIX接口访问设备,因为所有内容都将存在于用户空间进程中。

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

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