iphone - 串行写入不起作用

标签 iphone ios objective-c serial-port

我正在尝试使用 this tutorial 提供的代码示例将字符“b”写入 iPhone 的串行端口,但我没有得到想要的结果。当我使用 this link 提供的串行控制台应用程序时它似乎正在向 Arduino 发送字母/字符“b”,因为我的灯开始闪烁。

我为尝试发送“b”字符的应用构建的方法如下所示,

- (IBAction)blinkFlow_A_LED:(id)sender {

    // method to blink the Flow_A LED on the kegboard-mini Arduino sheild.

    NSLog(@"blink Flow_A btn pressed");

    NSLog(@"hello kyle");

    // open serial port / interface

    [serial open:B2400];
    if(serial.isOpened)
    {
        NSLog(@"Serial Port Opened");
    }
    else NSLog(@"Serial Port Closed");

    // print serial debugging messages
    serial.debug = true;


    // send serial data (tx)

    [serial write:text];

    // print message sent
    NSLog(@"the command sent was:%@",text);
}

最佳答案

您在哪里定义“文本”?文本应该是 NSString。

例如:

[serial write:@"hello world"];

关于iphone - 串行写入不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16290848/

相关文章:

iphone - 如何从 XML 模式生成 Objective C 类文件?

ios - UIWebview 键盘返回键按下 ios 7

iphone - 在 ios 键盘上方显示建议工具栏

iphone - [indexPath 行] 中的 EXC_BAD_ACCESS

ios - 与 Storyboard建立连接时遇到问题

iphone - 如何在iphone sdk中使用命名空间

ios - 无法将类型 'Option' 的值转换为预期的参数类型 '@noescape (Option) throws -> Bool'

ios - 我应该指定任何路径来访问 Xcode 中的头文件吗?

iphone - 如何在我的应用程序本地文档目录中将 NSString 另存为 .txt 文件?

ios - TableView - 在部分中自定义标题