|Subject:||Re: Running octave script on interrupt|
|Date:||Fri, 3 Oct 2014 18:11:26 -0400|
|User-agent:||Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1|
On 10/03/2014 11:30 AM, Grzegorz Ficht wrote:
Looks like a cool project. You need to specify few things to get a meaningful help, though. What do you mean by 'timed execution'?
Octave sleep(n) function is accurate to seconds, so it won't work for you, but time() on my Linux is in miliseconds, so you could busy-loop, and that would be accurate to a combination of the OS latency and Octave interpreter execution jitter. If that's acceptable, then a code like this would work:
which on my system seems to run at 100Hz +- 1Hz judging from hist(diff(a),1000). You seem to need to run the loop forever, so just replace the outer loop with while(true).
How precisely do you need to control the frequency? If you need a better frequency accuracy and/or can't afford to run a busy loop, you probably would need to run the data acquisition in a realtime process (either RT_LINUX or Xenomai), and write the data to a pipe, and have Octave read that pipe.
Curiously to Octave developers, I noticed a problem with the above code. After running it in different configurations for a while, the time() function got stuck and started returning a constant value. I restarted Octave and it behaved fine, but I definitely saw it choke although I couldn't replicate this.
|[Prev in Thread]||Current Thread||[Next in Thread]|