这个问题在这里已有答案:
系统细节:
OS X 10.9.1 (13B42)
USB红外触摸屏详情:
Low Speed device @ 3 (0x14400000): ............................................. Composite device from unknown vendor
Port Information: 0x101a
Not Captive
Attached to Root Hub
External Device
Connected
Enabled
Connected to External Port
Number Of Endpoints (includes EP0):
Total Endpoints for Configuration 1 (current): 2
Device Descriptor
Descriptor Version Number: 0x0100
Device Class: 0 (Composite)
Device Subclass: 0
Device Protocol: 0
Device MaxPacketSize: 8
Device VendorID/ProductID: 0x255E/0x0001 (unknown vendor)
Device Version Number: 0x0100
Number of Configurations: 1
Manufacturer String: 0 (none)
Product String: 0 (none)
Serial Number String: 0 (none)
Configuration Descriptor (current config)
Length (and contents): 25
Raw Descriptor (hex) 0000: 09 02 19 00 01 01 00 A0 FA 09 04 00 00 01 FF 00
Raw Descriptor (hex) 0010: 00 00 07 05 81 03 08 00 0A
Number of Interfaces: 1
Configuration Value: 1
Attributes: 0xA0 (bus-powered, remote wakeup)
MaxPower: 500 mA
Interface #0 - Vendor-specific
Alternate Setting 0
Number of Endpoints 1
Interface Class: 255 (Vendor-specific)
Interface Subclass; 0 (Vendor-specific)
Interface Protocol: 0
Endpoint 0x81 - Interrupt Input
Address: 0x81 (IN)
Attributes: 0x03 (Interrupt)
Max Packet Size: 8
Polling Interval: 10 ms
我的测试代码源(https://github.com/maqinjun/MyDriver/blob/master/MyDriver/MyDriver/MyDriver.cpp) .
作为细节,我的红外触摸屏不是HID USB设备,并报告中断输入事件 . 所以,我需要为它编写一个自定义USB驱动程序 . 然后,我决定写一个USB驱动程序kext .
根据Mac开发人员库(I/O Kit Fundamentals),我看到了 Handling Events . 为了将工作循环的角色放在透视中,首先要考虑它所针对的事件源 . 在I / O Kit中,有五大类异步事件:
1.中断事件 - 源自设备的间接(辅助)中断
2.定时器事件 - 定时器定期发送的事件,例如超时
- I / O命令 - 驱动程序客户端向其提供者发出的I / O请求
4.电源事件 - 通常通过调用驱动程序堆栈生成
5.结构事件 - 通常涉及I / O注册表的事件
我在他们的 start function 中设置了他们的工作循环,事件源和事件处理程序 . 但是没有工作 . 所以,我无法从USB触摸屏设备获取数据 .
我的问题:
1.是否有其他方法可以从os x USB kext中的USB设备接收报告数据?
2.获取报表数据时如何将坐标调度到系统?
谁来帮帮我?
1 回答
这不是USB的工作原理 . USB设备永远不会自己生成事件 - 您需要在设备的界面上找到相关的管道 . 然后,您需要向设备发送请求,当事件发生时,设备将响应 .
我建议阅读USB的工作原理 . 此外,如果此设备已存在其他操作系统的驱动程序,那么开发人员是否可以引导您完成此操作?您还会发现this book的所有故障,在编写USB驱动程序方面都有不错的章节,并解释了USB设备,接口, endpoints 等如何组合在一起 .
您可能希望考虑在用户空间中编写驱动程序 . 编写kexts并不是我向新手推荐的东西,如果可以在用户空间中做同样的事情,我也不会推荐 .
最后,请不要指望本网站的用户指导您完成为设备编写驱动程序的整个学习过程 . 您可以从中学到很多材料 - 书籍,Apple的文档,博客文章,Apple的源代码,第三方源代码等等 . 是的,这可能需要几个月的时间 . 没有办法解决这个问题(除了雇用别人这样做) .