Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not understanding OF to arduino communication #71

Open
onurkalaycioglu opened this issue Oct 1, 2013 · 8 comments
Open

Not understanding OF to arduino communication #71

onurkalaycioglu opened this issue Oct 1, 2013 · 8 comments

Comments

@onurkalaycioglu
Copy link
Contributor

ive looked at the stackoverflow parsing string delimiter thing and im a bit confused. what would a basic arduino sketch for serial.read look like. i found a youtube video that makes more sense, but not enough.
http://www.youtube.com/watch?v=ts81ZTdY_DQ

also im getting errors in my OF code, it wants to change mySerial to eSerial and im getting an error of "member reference base type '<anonymous enum at /Applications/Xcode.app..... "

int numBytesWritten = mySerial.writeBytes(outputBuffer.getBinaryBuffer(),

@bakercp
Copy link
Member

bakercp commented Oct 1, 2013

Could you clarify this question with some code ... screenshots or other information? I'm assuming you have seen all of the examples in this repo?

Using ASCII encoded strings:
https://github.com/bakercp/ExperimentalMedia/tree/master/Week4

Using bytes rather than strings:
https://github.com/bakercp/ExperimentalMedia/tree/master/Week6

@bakercp
Copy link
Member

bakercp commented Oct 1, 2013

Also, the video you found does things a slightly different way, so just keep that in mind when comparing.

@onurkalaycioglu
Copy link
Contributor Author

o i think i completely missed the week 6 simpleserialprotcol sketches. i was going off of this from the assignments page should i not use this code?

// in void setup()
ofSerial mySerial;
mySerial.setup(); // fill in your data

// ...

// in void update()

ofBuffer outputBuffer;

outputBuffer.append(ofToString(VALUE_0));
outputBuffer.append(",");
outputBuffer.append(ofToString(VALUE_1));
outputBuffer.append(",");
outputBuffer.append(ofToString(VALUE_2));
outputBuffer.append("\r\n");

int numBytesWritten = mySerial.writeBytes(outputBuffer.getBinaryBuffer(), outputBuffer.size());

if(numBytesWritten != outputBuffer.size())
{
    // warning ... something probably went wrong ...
}

@bakercp
Copy link
Member

bakercp commented Oct 1, 2013

You can use either one. It depends on what kind of data you want. You can read the code / comments for a clear description of when you would want to use one vs. the other. The week six example just demonstrates another way of doing it (without ASCII encoding).

@onurkalaycioglu
Copy link
Contributor Author

cool thanks, it works. the week 6 sketches were more of what i was going for. the arduino is ok sending and receiving data simultaneously?

@onurkalaycioglu
Copy link
Contributor Author

*at receiving

@bakercp
Copy link
Member

bakercp commented Oct 1, 2013

Yeah, the Arduino can do both at the "same" time. Of course it's not actually happening at the same time, because a Serial.write() will either happen before or after a Serial.read() (and vice versa) in sequence, but it all happens so quickly that it effectively does both at the same time.

@onurkalaycioglu
Copy link
Contributor Author

ok just making sure its not a damaging process because my "arduino" is a "little" more expensive than a standard board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants