我正在尝试让iPad 4与Arbotix RoboController(具有大量针脚的Arduino控制器)对话。我正在使用iPad 4,Lightning to 30-pin Adapter连接到RedPark C2-TTL电缆。
下正确识别电缆Settings -> General -> About -> Serial TTL Cable
但是,按照RedPark SDK中的Serial Cable SDK / Users Guide,我没有运气。建立了Arbotix,每隔300ms将“Hello World”写入序列,但方法
- (void) readBytesAvailable:(UInt32)numBytes {
...
}
根本就没有被召唤。此外,cableConnected
从未被调用过。
我确信我已经将双方的波特率设置为9600,正如this question建议的答案所示。
虽然我有疑虑,但有可能存在使用适配器的谎言。
有什么想法吗?
修改:
解决方案如下:我在iPad 4 +适配器上重新测试它,发现它没有问题。优良!
答案 0 :(得分:1)
我解决了!我没有在.plist
文件中声明电缆。按照this page第11步的指示添加Supported external accessory protocols
后,我能够按预期收到所有活动。
我之所以如此困难的原因是因为“使用Arduino的iOS传感器应用程序”一书中的AND上面的链接,声明该属性是一个合格的可选步骤,我选择省略。我认为一定是时间或线程问题是由于需要显示一个额外的对话框,要求用户访问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.
答案 1 :(得分:1)
在info.plist中你使用“com.redpark.hobdb9”来声明电缆吗?我一直想知道是否需要将C2-TTL电缆声明为其他东西,但是没有在网上发现任何资源这样说。