简体   繁体   English

如何在Mac环境下使用带有objective-c的USB / HID端口?

[英]How to use the USB/HID port with objective-c under a Mac environment?

I am having big trouble to communicate through USB, from a Mac to an external HID device. 我很难通过USB进行通信,从Mac到外部HID设备。 The hardware has been proven fine when running under the Windows XP platform, but I can't find a GOOD exemple of programming the HID with Cocoa / objective-C. 在Windows XP平台下运行时,硬件已被证明是好的,但我找不到用Cocoa / objective-C编程HID的好例子。 Several exemples are available in the Apple center, but they are either poorly documented, or too much complex ( in term of software with mixed objective-C and C, making the file difficult to understand), or not up to date. Apple中心提供了几个例子,但它们要么记录不清,要么太复杂(对于具有混合目标C和C的软件,使文件难以理解),或者不是最新的。 Well, I must say that I am more an hardware electronic engineer than a software specialist ! 好吧,我必须说我不是软件专家而是硬件电子工程师! So far, I can enumerate the USB port, identify my device using the HID Apple's tools ( I read PID and VID ), but I miserably fail to send a report and/or to read a report back from the external device. 到目前为止,我可以枚举USB端口,使用HID Apple的工具识别我的设备(我读取PID和VID),但我很难发送报告和/或从外部设备读回报告。 I would certainelly appreciate if one of you has used the new Apple's HID API and can share some know how. 如果你们中的一个人使用了新的Apple的HID API并且可以分享一些知识,我将非常感谢。 On the other hand, is there any "USB spy" tool operating with the Apple's OSX ? 另一方面,是否有任何“USB间谍”工具与Apple的OSX一起运行? Thank you so much for your help 非常感谢你的帮助

Michael 迈克尔

You are not going to find an Objective-c interface for the HID. 您不会为HID找到Objective-c接口。 At least, not anything more than a wrapper. 至少,不仅仅是一个包装器。 Because of dynamic binding and delayed messaging, Objective-c is poorly suited to programming time dependent task like device drivers or for communicating with same. 由于动态绑定和延迟消息传递,Objective-c不太适合编写与时间相关的任务,如设备驱动程序或与之通信。 You're going to have to work in C. 你将不得不在C工作。

The Apple resources: Accessing Hardware From Applications ,the HID Class Device Interface Guide are going to be your best resources. Apple资源: 从应用程序访问硬件HID类设备接口指南将是您最好的资源。 This tech note offers a good overview as well. 此技术说明也提供了很好的概述。

The Apple System profiler will scan you USB chain to see what devices are visible to the hardware itself. Apple系统分析器将扫描您的USB链,以查看硬件本身可见的设备。

Edit01: Edit01:

Can't believe I forgot about /Developer/Applications/Utilities/IORegistryExplorer. 不敢相信我忘了/Developer/Applications/Utilities/IORegistryExplorer. It gives you a detailed breakdown of the entire hardware tree. 它为您提供了整个硬件树的详细分类。

So yes, you're going to have to dive down and write C, not Objective-C, to do your thing. 所以,是的,你将不得不潜入并编写C而不是Objective-C来做你的事情。

Luckily, there's an additional Apple resource to make the USB/HID Manager MUCH easier. 幸运的是,还有一个额外的Apple资源可以让USB / HID Manager变得更容易。

See the HID Utilities Sample/Library from Apple 请参阅Apple的HID Utilities示例/库

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

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