I'm driving a pump with electronic pulses. Writing a "1" to a file generates a pulse. The write itself takes several tens of milliseconds. The delay isn't the same each time. I want to start one write exactly every 500 milliseconds.
My idea using threads:
1. A "pulse writing" thread writes a pulse to the file when it receives a semaphore signal. 2. Time::HiRes clock_nanosleep (or similar) runs in the main thread sending a signal precisely every 500msec to the "pulse writing" thread.
Does this seem like a good way to go? Anyone done anything like this before? The tricky thing is that the writing time is somewhat variable and blocks until done, so I can't just do it all in one thread I don't think. Or maybe I'm a little thread-happy since I just learned them?
Thanks much!
In reply to Any ideas for using perl as a simple pulse generator? by bfreemer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |