hello!
I’m kind of newbie with oF. basically, I used to processing. but recently trying to move to oF.
in this thread, I wanna ask linking error message, below
Undefined symbols for architecture i386:
“testApp::ofxGetSerialString(ofSerial&, char)”, referenced from:
testApp::update() in testApp.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I’m trying to communicate with arduino. not with Firmata, instead ofSerial.
cause not quite experience with OF, I googled and find this page, and follow this one. (below)
https://sites.google.com/site/ofauckland/examples/serial-read-string-from-arduino
there’s no problem just before add ofxGetSerialString(),
but finally it’s not executed. instead Linking Error.
I cannot find any syntax error on it.
I tried with xCode 5.0.2, oF 0.8.0, OSX 10.9.1 mavericks.
anyone help me? whole code is below.
#include "testApp.h"
/*
// trim trailing spaces
string ofxTrimStringRight(string str) {
size_t endpos = str.find_last_not_of(" \t\r\n");
return (string::npos != endpos) ? str.substr( 0, endpos+1) : str;
}
// trim trailing spaces
string ofxTrimStringLeft(string str) {
size_t startpos = str.find_first_not_of(" \t\r\n");
return (string::npos != startpos) ? str.substr(startpos) : str;
}
string ofxTrimString(string str) {
return ofxTrimStringLeft(ofxTrimStringRight(str));;
}
*/
string ofxGetSerialString(ofSerial &arduino, char until) {
static string str;
stringstream ss;
char ch;
int ttl=1000;
while ((ch=arduino.readByte())>0 && ttl-->0 && ch!=until) {
ss << ch;
}
str+=ss.str();
if (ch==until) {
string tmp=str;
str="";
return tmp;
} else {
return "";
}
}
//--------------------------------------------------------------
void testApp::setup(){
// vector <ofSerialDeviceInfo> deviceList = arduino.getDeviceList();
// for(int i=0; i<deviceList.size(); i++){
// cout << &deviceList[i] << endl;
// }
arduino.listDevices();
arduino.setup(0, 9600);
bOn = false;
ofBackground(255,255,255);
}
//--------------------------------------------------------------
void testApp::update(){
string result = ofxGetSerialString(arduino, '\n');
if(result !=""){
if(ofToInt(result) > 500){
bOn = true;
int value = ofToInt(result);
cout << value << endl;
}
}
}
//--------------------------------------------------------------
void testApp::draw(){
// str = arduino.getString();
//ofDrawBitmapString(data, 100, 100);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}