我目前正在尝试使iPad 4与Arbotix RoboController(带有很多引脚的类似Arduino的控制器)进行通讯。我正在使用连接到RedPark Lightning to 30-pin Adapter电缆的C2-TTL的iPad 4。在下面正确识别电缆

Settings -> General -> About -> Serial TTL Cable



但是我没有遵循RedPark SDK的《串行电缆SDK /用户指南》。 Arbotix的设置是每300毫秒写出“Hello World”序列,但是方法
- (void) readBytesAvailable:(UInt32)numBytes {
    ...
}

根本不被调用。也从未调用过cableConnected

我相信我已经将双方的波特率都设置为9600,这是对this question的建议。

尽管我对此表示怀疑,但使用适配器还是有可能的。
有任何想法吗?

编辑:

解决方法如下:我在iPad 4 +适配器上对其进行了重新测试,发现它可以正常工作。优秀的!

最佳答案

我解决了!我没有在.plist文件中声明电缆。按照this page的步骤11的指示添加了Supported external accessory protocols后,我能够按预期接收所有事件。

我之所以陷入困境,是因为上面的链接以及《 iOS传感器应用程序与Arduino》一书中的链接都声明该属性已被列为可选步骤,因此我选择省略。我认为肯定是由于需要显示一个额外的对话框,要求用户访问App Store来拧紧这些事件的正确委派而导致的计时或线程问题。

在网页上:

This step is optional, but it will avoid the problem of you seeing an error message ("This accessory requires an application...") each time you plug in the cable.

在书上:
Finally, we need to declare support for the cable in our application’s Info.plist file. If we don’t do this, we’ll get something that looks like Figure 2-13 every time we plug the cable into the device.

关于ios - Redpark串行电缆未在iPad 4上接收数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16892522/

10-10 17:35