Data communication between sketches

edited August 2014 in How To...

Hey guys, I'm developing a personal project that works like this, I have two processing sketches, one of them is a canvas in which I'll be drawing and the other is a control panel for the canvas, I want to control the canvas variables from the control panel, lets say for example, the radius of a circle. I know it's possible to communicate between the two, but my question is: What is the best way to do this?

I did it via UDP, sending a JSONObject as string and parsing it on the other end, but I'm not sure if this is the best way to do it. I'm open for suggestions! Thanks!

Tagged:

Answers

  • UDP is slow with big data but in your case fine. If this works for you, i say go for it.

    At the moment I work on a library to transfer files between programs with highspeed since OSC is to limited for me.

  • I am trying to decide the best way to communicate between Processing sketches running on the same machine... Was thinking UDP would be good between machines but is there a better way to have two sketches talk when both are running within a single PC?

  • Define "better"? What are your needs? Speed? Volume of data? Ease of use?

    You can even make two sketches to communicate by writing to files on disk... (and reading them!)

  • Hello, i am interested in making a communication between 3 sketches in the same pc. @philho your idea of communicate by writing and reading from files sounds good to me. Is there any code explample that would help me understand how can i get this done?

    Cheers.

  • While Philho is not here, I can suggest this tutorial for general understanding of concept.

  • See saveStrings() and loadStrings(), for example.

  • Good point @PhiLho. I am looking for pretty simple programming code and reliable transfers... Low volume, relatively low performance is fine. I am new to Processing but have some coding experience so not expecting it to be too hard. Just not used to the libraries and various functions so still feeling my way around.

    In addition to writing to files, another potential concept that I found is to use Named Pipes. I need to explore how to send a relatively complex data structure through them. I also need to make sure the differences of using them in Win7 and Linux are not too drastic so I can port the apps as needed. But the idea of writing essentially to a virtual file is intriguing - no need to exercise the hard disk if persistence is not needed.

    Thanks for your thoughts...

    Jay

Sign In or Register to comment.