Created
March 28, 2015 08:19
-
-
Save phoenixperry/a75599c78fb6778d974b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This code will give you the bug: | |
ofSerial serial | |
void ofApp::setup(){ | |
//this is the strange line. If I don't explicity call the ofSerial construtor all hell breaks loose. The error is Thread 1: EXC_BAD_ACCESS//(code=1, address 0xffffff4). | |
serial.listDevices(); | |
serial. setup(0, 9600); | |
} | |
void ofApp::update(){ | |
//This gets sent to arduino, calling for a new set of readings | |
serial.writeByte('a'); | |
if(serial.available()){ | |
unsigned char bytesReturned[6]; //000 new line + null terminator | |
memset(bytesReturned, 0, sizeof(bytesReturned)); | |
// This reads the data now that arduino is sending a response, | |
serial.readBytes(bytesReturned, 5); | |
//check the data to make sure the new line isn't doing weird stuff | |
string serialData = (char*) bytesReturned; | |
sensorPadValue = ofToInt(serialData); | |
cout << sensorPadValue << endl; | |
serial.flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment