I'm trying to build an interface in Max for a game involving multiple players. The game mechanics are all working and ready to go. Right now, though, the only way to reset the game is to manually press the reset button the Arduino. Currently when the game ends, the Arduino enters a while loop that will only exit when it receives a particular number over Serial (sent from Max).
The project is using XBees, and the XBee code doesn't work over SoftwareSerial, so the XBees have to use the hardware Serial port, which means I can't use the Serial monitor to debug. I currently have a second Arduino (the "Debugger") set up to debug the first one (the "Console"). There is a SoftwareSerial object in the Console, and I'm printing debugging messages to it as I would to the Serial monitor, like so:
SoftwareSerial debugSerial (3, 2); // rx, tx
debugSerial.println("Debugging message");
The two Arduinos have wires between them, with the Console's Tx pin plugged into the Debugger's Rx pin, and the Debugger's Tx pin plugged into the Console's Rx pin. Finally, there is a wire connecting a ground pin on the Console to a ground pin on the Debugger. *
The Debugger is listening for messages and printing them out via its hardware Serial port, like this:
SoftwareSerial consoleDebug (3, 2) // rx, tx
Serial.println(consoleDebug.readString());
Since the communication is happening over SoftwareSerial on both ends (Console and Debugger), I can also use the Debugger's hardware Serial to send and receive information through the interface in Max. I don't need to debug the game logic anymore because the game is working.
I want to be able to send "packets" of information into Max, such as {79, 5, 83} and have Max say "I see a 79, so the next number is the suit, and the following number is that suit's new value.
I also want to have a button in the Max interface that will send a 98 back through the Debugger and into the Console, and the Console will see the message and say "I see a 98, so I'm restarting the game."
I can't get a test number (like a "75") to go: Console > Debugger > Interface. Right now, I can get a test message to go: Console > Debugger (> Serial monitor), and I can get a test message to go from Debugger > Interface. When I send a test message from the Console to the Debugger, the Debugger is using readString() to read it, but everything I've tried so far in terms of converting the String into an integer to send it into the Max interface hasn't worked.
When I send a test message (integer) directly from the Debugger into the Max interface, it works fine. So the problem lies right… Console > Debugger (…here) > Interface.
Here is a zip folder of a couple slimmed down files (Console, Debugger, Interface). https://drive.google.com/file/d/0B0LuO5zb3-YvTkN3TkthVUgyZ0k/view?usp=sharing
I found this thread), which seems to be what I'm looking for in terms of splitting the "packet" in Max, but unfortunately they didn't include the Arduino code in their post, so I'm not sure how the numbers are being sent.
I know logic isn't Max's strong suit, so I'm not even sure if this is doable in Max. I'm also looking at TouchDesigner for the interface, but I don't have any experience with TouchDesigner, and I have a good amount of experience with Max.
If I didn't clarify something that I should have, please don't hesitate to ask!
- [This method works fine for debugging, aside from a few caveats. The messages seem to take a second or two to print out, and I can't figure out why. If too many messages are sent, they get "bunched up" and don't print until the Console stops sending print statements to the debugSerial SoftwareSerial object.
Sometimes, the Debugger actually stops printing messages at all until the Console is reset. I suspect this all has something to do with not flushing the SoftwareSerial object, but I have no idea where to start. It's not a huge problem, and I don't mind leaving it as is for now.]