SerialMQ, connection between openFrameworks, Max/MSP <----> Arduino
- In
/Of
folder is a openFramewors wrapper for serial communication with Arduino - In the
Arduino
andMaxPatch
folder, there are wrappers for Arduino and Max/MSP correspondingly. Each has it own README that explain how to use the code.
The ofYJArduinoSerial
object will maintain a std::map
which store the received command and message as key and value respectively.
Assuming the data sent from Arduino is something like
cmd0 message1
cmd1 message2
commands are separated by newline character (\n) command and message are seperated by space (currently not changeable, will add the feature in next update)
- Use
setConnectId()
to set serial port (Default: 0) - Use
setBaudRate()
to set baud rate (Default: 9600) - Use
setReceivedMsgSep()
to set delimiter for received message (Default: '\n'); - Use
setSendMsgSep()
to set delimiter for sending message (Default: '\n') connect()
will create separate thread (ofThread) to listening the serial port- Use
getValue(std::string key)
to get message. key is the command (cmd0, cmd1) and return string is the message (message1, message2) - Use
getCounter(std::string key)
to get counter for each command. The counter will automatically plus 1 once received new message for corresponding command. It is use to make sure the data is updated by Arduino or not. - Use
sendMsg(std::string msg)
to send message to Arduino
The example code is locate in /src
#TODO
- Add features for changing delimiter to separate command and message
- Add protection to prevent counter from overflow.