Hi.
I'm developing an external that starts a separate pthread to poll some hardware inputs. When the outputs change, I need to send a message like [34 56( to one of two outlets in the external from my thread.
Do I need to use my own mutex? or the sys_lock(), sys_unlock() calls around the outlet_whatever() calls? or nothing at all, just call outlet_whatever()?
Anyone cares to give a two line explanation of the logic around this?
Thanks!
typo: "when the inputs change'', not "outputs".
On Wed, May 21, 2014 at 11:01 AM, Rafael Vega email.rafa@gmail.com wrote:
Hi.
I'm developing an external that starts a separate pthread to poll some hardware inputs. When the outputs change, I need to send a message like [34 56( to one of two outlets in the external from my thread.
Do I need to use my own mutex? or the sys_lock(), sys_unlock() calls around the outlet_whatever() calls? or nothing at all, just call outlet_whatever()?
Anyone cares to give a two line explanation of the logic around this?
Thanks!
-- Rafael Vega email.rafa@gmail.com
Hi Rafael -
YOu can indeed pass messages to outlets or objects bound to symbols from an arbitrary thread, protecting them between a sys_lock() and sys_unlock() call. You can also maintain your own queue of messages between the new thread and the Pd thread - this will be more work but can be made absolutely robust (i.e., not depending on the safety of the sys_lock() mechanism which I _think_ is safe but one can never be certain.
cheers Miller
On Wed, May 21, 2014 at 11:01:33AM -0500, Rafael Vega wrote:
Hi.
I'm developing an external that starts a separate pthread to poll some hardware inputs. When the outputs change, I need to send a message like [34 56( to one of two outlets in the external from my thread.
Do I need to use my own mutex? or the sys_lock(), sys_unlock() calls around the outlet_whatever() calls? or nothing at all, just call outlet_whatever()?
Anyone cares to give a two line explanation of the logic around this?
Thanks!
-- Rafael Vega email.rafa@gmail.com
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On 22/05/14 02:01, Rafael Vega wrote:
Hi.
I'm developing an external that starts a separate pthread to poll some hardware inputs. When the outputs change, I need to send a message like [34 56( to one of two outlets in the external from my thread.
from your previous emails I'd guess you are using a beagle board, I'm not sure what they provide as far as hardware interface goes, but on the Raspberries there is a library, and several usable APIs, that give access to the hardware interrupts from the GPIOs, either in many languages including C, python, bash etc so no need for polling, you can just use a call-back in C or even simpler start a call-back program in bash and pipe its (filtered) output to pd via pdsend.
I can send some useful references to the Pi stuff if you are interested.
It really is much better to avoid having polling loops and such in the CPU, hardware does this much better ... the GPIO drivers in the Pis offer callbacks, DMA and such to avoid this ... probably something similar is available on the beagleboard, otherwise that's the advantage of using something like an arduino ... the polling is then done in the arduino and only the relevant details are passed on to the main computer.
A big operating system really isn't the right environment for the kind of timing required for low-level hardware interfaces.
Simon
Hi Simon, I'm using an interrupt interface for reading the digital inputs but polling for reading the analog ones. Probably not the best thing to do as you say. I'd be hapy to look at the references you mention. Thanks!
On Thu, May 22, 2014 at 1:44 AM, Simon Wise simonzwise@gmail.com wrote:
On 22/05/14 02:01, Rafael Vega wrote:
Hi.
I'm developing an external that starts a separate pthread to poll some hardware inputs. When the outputs change, I need to send a message like [34 56( to one of two outlets in the external from my thread.
from your previous emails I'd guess you are using a beagle board, I'm not sure what they provide as far as hardware interface goes, but on the Raspberries there is a library, and several usable APIs, that give access to the hardware interrupts from the GPIOs, either in many languages including C, python, bash etc so no need for polling, you can just use a call-back in C or even simpler start a call-back program in bash and pipe its (filtered) output to pd via pdsend.
I can send some useful references to the Pi stuff if you are interested.
It really is much better to avoid having polling loops and such in the CPU, hardware does this much better ... the GPIO drivers in the Pis offer callbacks, DMA and such to avoid this ... probably something similar is available on the beagleboard, otherwise that's the advantage of using something like an arduino ... the polling is then done in the arduino and only the relevant details are passed on to the main computer.
A big operating system really isn't the right environment for the kind of timing required for low-level hardware interfaces.
Simon
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list