Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

konashi1がUartWriteできないバグ #82

Open
sagiii opened this issue Sep 8, 2015 · 2 comments
Open

konashi1がUartWriteできないバグ #82

sagiii opened this issue Sep 8, 2015 · 2 comments
Assignees
Milestone

Comments

@sagiii
Copy link
Contributor

sagiii commented Sep 8, 2015

UartSampleでTXできない。

@0x0c
Copy link
Member

0x0c commented Sep 25, 2015

再現手順を教えていただけますか

@norioike
Copy link

iOS 9.0.1 iphone6plus
konashi-ios-sdk : branch-feature/refuctuoring_ios9
にて再現しました。

[手順]
UartSampleを使用。また、UARTの相手としてArduino unoを使用しました。
KonashiからTXしたデータをArduinoで受け取り、Arduinoから別の数値をTXするという方法で確認しました。

Xcodeのソースは以下になります。
//
// ViewController.m
// UartSample
//
// Copyright (c) 2013 Yukai Engineering. All rights reserved.
//

#import "ViewController.h"
#import "Konashi.h"

@interface ViewController ()

@EnD
unsigned char TX = 10;//TXでArdinoに送信するデータ
@implementation ViewController

  • (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [[Konashi shared] setConnectedHandler:^{
    NSLog(@"CONNECTED");
    }];
    [[Konashi shared] setReadyHandler:^{
    NSLog(@"READY");

    self.statusMessage.hidden = NO;
    
    //Konashiで使用するピンの設定をする。
    [Konashi uartMode:KonashiUartModeEnable baudrate:KonashiUartBaudrateRate9K6];//9600bpsでやりとりする
    

    }];
    [[Konashi shared] setUartRxCompleteHandler:^(NSData *getuartdata) {

    unsigned char rxdata;
    [getuartdata getBytes:&rxdata length:1];
    
    NSLog(@"UartRx %d", rxdata);
    

    }];
    }

  • (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

  • (IBAction)find:(id)sender {
    [Konashi find];
    }

  • (IBAction)send:(id)sender {
    // [Konashi uartWriteData:[NSData dataWithBytes:"A" length:1]];

    NSData *tx_data;
    tx_data = [NSData dataWithBytes:&TX length:sizeof(TX)]; //"10"という数値を送る

    [Konashi uartWriteData:tx_data];
    NSLog(@"Send TX");
    }
    @EnD

またArduinoはソフトウェアシリアルを使用しました。(ハードウェアシリアルでモニターしたかったため。)ソースは以下。

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);//RX,TX

int rxdata;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(9600);
pinMode(13,OUTPUT);//LED点灯
}

void loop() {
// put your main code here, to run repeatedly:

if(mySerial.available()){
rxdata = mySerial.read();
Serial.println(rxdata);
mySerial.write(byte(20));
digitalWrite(13,HIGH);
Serial.println("Get and Send the data!");
delay(300);
digitalWrite(13,LOW);
}

}

@0x0c 0x0c added this to the 4.2.0 milestone Nov 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants