iPad 与 Mac 或 PC 之间的 USB 通信
我想编写一个 iPhone/iPad 应用程序,可以通过 USB 连接与 Mac 或 PC 程序(我也会编写)进行通信。有谁知道我该怎么做? (我意识到我可能需要越狱我的iPad)
I would like to write an iPhone/iPad app that can communicate through a USB connection with a Mac or PC program (that I would also write). Does anyone know how I could go about doing this? (I realize that I may have to jailbreak my iPad)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过 USB (USBMux) 进行的套接字通信可能会满足您的需求。当iPad或iPhone插入Mac时,会有一个设备描述/var/run/usbmuxd。您可以创建一个套接字并将其连接到 /var/run/usbmuxd 并向 iOS 设备发送/接收打包数据。数据应该被包装。
这是来自 theiphonewiki http://theiphonewiki.com/wiki/index.php?title=Usbmux。我可以提供的是连接 usbmuxd 的示例代码。
之后,您必须“连接”到您的应用程序在 iPad 上监听的端口。上面的 wiki 页面列表中事件序列部分讨论的“连接”过程。准备工作完成后,就可以使用socket来发送和读取数据了。
Socket communication via USB (USBMux) might meet your needs. When an iPad or iPhone plug in to a Mac, there will be a device description /var/run/usbmuxd. You can create a socket and connect it to /var/run/usbmuxd and send/receive packaged data to/or from iOS device. The data should be wrapped.
Here is a brief reference from theiphonewiki http://theiphonewiki.com/wiki/index.php?title=Usbmux. What I can provide is the sample code for connect to usbmuxd.
After that you have to "connect" to the port your App listen on iPad. The "connect" process discussed in the wiki page list above in section Sequence of Events. After the preparing work done, you can use the socket to send and read data.
必须是 USB 连接吗?
如果没有,那么 Robbie Hanson 的 GCDAsyncSocket 非常适合连接各种 Apple 设备。去年我用它把一堆 iPad 连接到 Mac mini 上运行的一个应用程序。
Does it have to be a USB connection?
If not, then Robbie Hanson's GCDAsyncSocket is great for connecting all kinds of Apple devices. I used it last year to connect a bunch of iPads to a single app running on a Mac mini.