Best way to Communicate between cogs?
SpinHead
Posts: 28
Ok, I think I understand exactly how to do this ( I am more of a hardware guy than software so bear with me.) from the main Cog I am going to define an object, Input, inside of Input is a start method that starts a method in a new cog loop that watches a variable defined in the dat area, I also have a Read method in Input that responds with the first byte of the variable Is this the best way to do this? This is my first time writing a new cog object instead of just logic inside the main cog.
Also, how would I return the first byte in an array and shift everything else over, i.e. nibble the data
Thanks!
·
Also, how would I return the first byte in an array and shift everything else over, i.e. nibble the data
Thanks!
·
Comments
Declare the object in 2 objects in are running in different cogs that want to communicate. 1 object calls read and the other calls write.
Since the array is in DAT, there is 1 array shared between the 2 instances of the object. The read waits until a write is called and a write waits until any data in the array is read before writing.
Edit: the attachment is a quick hack to show what I mean. It is hacked from existing code but probably has bugs sinces its untested in this form. You can extend it to double buffer, pass different size buffers, etc.
Post Edited (Timmoore) : 6/10/2008 3:35:02 AM GMT