我目前正在尝试让 iPad 4 与 Arbotix RoboController 对话(具有大量引脚的类似 Arduino 的 Controller )。我正在使用带有 Lightning to 30-pin Adapter 的 iPad 4连接到 RedPark C2-TTL电缆。在
下正确识别电缆Settings -> General -> About -> Serial TTL Cable
.
但是我没有按照 RedPark SDK 中的串行电缆 SDK/用户指南走运。 Arbotix 被设置为每 300 毫秒将“Hello World”写入串行,但方法
- (void) readBytesAvailable:(UInt32)numBytes {
...
}
根本没有被调用。此外,从未调用过 cableConnected
。
我确定我已经将双方的波特率设置为 9600,作为 this question 的答案。建议。
尽管我对此表示怀疑,但可能与适配器的使用有关。
有什么想法吗?
编辑:
解决方法如下:我在iPad 4+ Adapter上重新测试,发现没有问题。太棒了!
最佳答案
我解决了!我没有在 .plist
文件中声明电缆。按照 this page 的说明添加 Supported external accessory protocols
后在第 11 步,我能够按预期收到所有事件。
我陷入困境的原因是因为上面的链接和“带有 Arduino 的 iOS 传感器应用程序”一书中都声明该属性在某种程度上是合格的可选步骤,我选择省略。我认为一定是时间或线程问题导致的,因为需要显示一个额外的对话框,要求用户访问 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/