私はarduinoとopenframeworksの間でシリアルプログラムを作っています。しかし、arduino は奇妙なデータを openframeworks プログラムに送信しました。解決できませんでした、助けてください。
(Arduinoコード)
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.write('a');
delay(100);
}
(Mac の opneframeworks コード)
#include "testApp.h"
ofSerial mySerial;
//--------------------------------------------------------------
void testApp::setup(){
mySerial.setup(0, 9600);
}
//--------------------------------------------------------------
void testApp::update(){
unsigned char myByte = 0;
myByte = mySerial.readByte();
if(myByte == OF_SERIAL_NO_DATA){
cout << "no data was read";
}else if(myByte == OF_SERIAL_ERROR){
cout << "an error occurred";
}else{
cout << "myByte is " << myByte << "\n";
}
}
(Xcode のコンソール)
...
myByte is \376
myByte is \376
myByte is a
myByte is \376
myByte is \376
myByte is \376
myByte is \376
...
Arduino がデータを送信しなかったときに、Mac 上の OpenFrameworks が "\376" を取得したようです。
私の環境は、
- Mac OS ライオン
- Xcode v4.3.3 SDK10.6
- Mac 用 OpenFrameworks v0.7.4
- Arduino IDE v1.0.4
- Arduino uno(atmega328p)
- Arduinoと私のPCはUSBケーブルで接続されています