/************************************************************************************************** * * StringSerialProtocol * * Version: 1.1.2 - April 2009 * Author: Christoph Wartmann / chair for caad - ETH Zürich / wartmann[at]arch.ethz.ch * Etienne Ribeiro / tutorial assistant caad / eribeiro[at]ethz.ch * * Desc: A Protocoll to communicate through the Serial Interface. * ***************************************************************************************************/ // var String comPort = "COM8"; SerialProtocolLibrary messanger; // Setup void setup () { // size size(400,400); // Initialize COM Port messanger = new SerialProtocolLibrary (this, comPort); messanger.setID (0); // 0 = sending an receiving to/from all Nodes } // Draw void draw () { } // Key pressed void keyPressed() { switch (key) { case 'p': case 'P': // Ping messanger.send('p', "Ping Pong"); break; case 'a': case 'A': // messanger.send('a', 2563); break; case 'b': case 'B': messanger.send('b', ""); break; } } // SerialEvenet void SerialEvent (String cmd, String message) { if (cmd.charAt(0) == 'a') { int x = messanger.parseInteger(message); print ("Parsed int: "); println (x); } else if (cmd.charAt(0) == 'b') { println ("Command b"); } else { println(message); } }