Akua Sweets--Pause for
Akua Sweets--Pause for
- Subject: Akua Sweets--Pause for
- From: "TRELEAVEN, CRAIG" <email@hidden>
- Date: Tue, 03 Apr 2001 09:12:23 -0500
- Organization: Clearview Consulting on assignment at Bell Nexxia
Hello all:
I'm trying to develop an AppleScript applet that will check the serial
port at least 5 times per second
or so.* I want to use 'Pause for' from Akua Sweets to allow other
applications to continue to run. Trouble is, my applet seems to want to
suck up most of the cycles on my machine. The following illustrates the
problem:
-----------begin script---------------
--on run
copy (pause for 0) to ticks_start--the starting tick counter in 60ths of
a second
repeat 100 times
pause for 6 --should run for 6 seconds, virtually all of it given
to other apps
end repeat
return (pause for 0) - ticks_start--just to check how long we really ran
--end run
-----------end script---------------
When I run this script, either as an applet or in Script Editor, other
running processes basically starve for processor time. For instance,
the Seti@home client pretty much stops. SoundJam will still play MP3s
but ripping slows to a crawl. Peak-a-boo seems to confirm this.
From some timing tests, I think my applet should only be taking about
3-5% of the CPU. My main loop checks for a byte available on the serial
port. Finding none, it checks for a key press (ie Quit). These take
about .4 ticks, on average. If I then pause for 12 ticks, for instance,
I should only be consuming 3% of the available time, no?
Note that I'm not using an on idle handler since the timing granularity
on these is too coarse--full seconds rather than ticks.
I'm running MacOS 8.1 with AppleScript version 1.1.2 on a beige G3 266
DT.
Any suggestions?
Craig Treleaven
* Why? I want to play MP3's from my upstairs Mac on my downstairs home
stereo and be able to control playback from downstairs (play, stop,
mute, skip forward, back, etc). Found a package (the Entertainment
Anywhere 2000 from X10.com, only $69) that does this but comes with PC
software only. It uses 2.4 GHz to transmit from the computer to
stereo. The included remote uses RF to talk to a device attached to a
serial port. So I need something to listen to the serial port and do
the right things to SoundJam when a button is pressed on the remote.
And, of course, I want sub-second response time. Now, don't you wish
you hadn't asked! OTOH, if you're interested, I plan to release this as
freeware if/when I get it working better.