2013-06-03 56 views
1

我目前正试图让iPad 4与Arbotix RoboController(带有大量引脚的Arduino控制器)通话。我正在使用连接到RedPark C2-TTL电缆的Lightning to 30-pin Adapter的iPad 4。该电缆在Redpark串行电缆无法接收iPad上的数据4

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

下正确识别。

但是我没有从RedPark SDK的Serial Cable SDK /用户指南中获益。 Arbotix设置为每隔300毫秒写出'Hello World',但方法为

- (void) readBytesAvailable:(UInt32)numBytes { 
    ... 
} 

根本不被调用。另外cableConnected从未被称为。

我确定我已经设置波特率为双方9600,作为this question建议的答案。

有可能谎言与适配器的用法,虽然我有我的怀疑。 有什么建议吗?

EDIT

的解决方案是如下:我重新测试了它在iPad 4 +适配器和发现它与没有问题。优秀!

+0

我已经获得了iPad 1代,并重复了测试。我仍然没有运气:RedPark SDK调用'cableDisconnected',但不调用'cableConnected'。我知道这一点,因为我设置了调试消息以在屏幕上显示任何这些方法时被调用。 – fatuhoku

回答

1

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

我之所以被卡住的原因是因为在书籍'iOS Sensor Apps with 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. 
1

在info.plist中,你使用 “com.redpark.hobdb9” 申报电缆?我一直想知道是否需要将C2-TTL电缆声明为其他内容,但在网上没有发现任何资源这样说。

+0

是的,没错。 '支持的外部附件协议'应该设置为'com.redpark.hobdb9'。尽管许多消息来源表示这是可选的,但实际上它是必要的。我正在使用TTL电缆。 – fatuhoku

+0

面对同样的问题,像readBytesAvailable这样的一些委托方法不会调用。我正在使用RedPark L2-DB9V。 \t com.redpark.hobdb9v \t com.redpark。ser45v \t com.redpark.ser45 \t com.redpark.nmeax \t com.redpark.appgps \t com.redpark.serdb9 \t com.redpark.serEval \t com.redpark.hobdb9 \t com.redpark.L2-DB9V \t com.redpark.DB9V 但在接收日期没有运气。 任何帮助将非常感激。 –