Go Down

Topic: synchronizing multiple sensors to MaxMSP; millis? interrupt? (Read 912 times) previous topic - next topic

brendan mccloskey

I just thought that, sending some pseudo-code might help clarify:

What I want Arduino to say to Max is
"here's a signifier for the first sensor value; and here's the end of the packet"

and Max will hear
"oh, this MUST be the first sensor value cos there's the signifier"

and n00meister will say
"Dear Cycling74 forum, what do I do with this signifier?"

thanks
n00bmeister

PaulS

What I would do is add a start of packet marker, each value followed by a separator, in a loop, then an end of packet marker:
<v1, v2, v3, v4, v5, v6, v7, v8>
When reading data, read a character. If it isn't a start of packet marker (<), throw it away. If it is, throw it away, and start another loop.

In that loop, read data. If the character is an end of packet marker, process the string received. If it is not and end of packet marker, add it to the string, unless it is another start of packet marker.

Processing the string involves parsing the tokens, nicely separated by delimiters.

Since you are sending the values as binary data, parsing is not really required, nor is the delimiter. The start and end of packet markers are, though.

Go Up