milne@ics.uci.edu (Alastair Milne) (05/11/91)
Some of you may have seen my previous postings here, and may remember
that I am writing a Turbo Pascal 5.0 / 6.0 unit to run IBM's M-Motion Video
adapter/A through their M-Control program.
In general it has been going very well, but some time ago, I was looking
for help in correctly disabling the WakeUp routine when closing down.
My problem was that, although the WakeUp routine itself was correctly
used while activated, I was finding that the next application to use
M-Control was crashing when M-Control tried to use what it thought
was a WakeUp routine at the old address. i.e. deactivation of the WakeUp
routine was not being successfully completed.
It seems I have solved that.
There is a table in the manual which states which commands will cause
an available WakeUp routine to be used for their replies, and which will
not. Naturally, commands that deactivate the WakeUp routine do not attempt
to use it to return their replies. However, I misread it to mean that
those commands don't return *any* replies. (I believe there are indeed
a couple of M-Control commands which don't cause replies to return.)
In my own defense, this was rather an easy misreading to make.
Once I eliminated the exceptional way I was handling the command that
removed the WakeUp routine, and did it the way all other commands
are handled (a single routine that sends the command and waits for the
reply) it started working properly.
Though I didn't think of it clearly at the time, the manual does indicate
that until M-Control knows the reply to a command has been read, it does
not complete any state change that command may cause. It is emphatic
about this in the case of STOP, which perhaps led me to forget about it
in other cases.
For anybody else exploring Turbo Pascal implementations of M-Control
applications, I have this advice:
- FIRST, make sure you have routines working which poll the destination
status variable (for *all* destinations) and grab every incoming reply
as it appears. I call mine in the process of waiting for a particular
reply, and queue any others that come in;
- SECOND, build your WakeUp routine.
Why this order? Because as soon as you deactivate the WakeUp routine,
you'll be *very* glad when your reading routine can use polling to
receive all further replies. This may be self evident to many, but
since I had to find it out by experience, I expect there may be others
who do too.
(This probably also applies to languages other than Pascal, but since
Pascal is the one I'm working in, I won't presume to say what others need.)
Finally: though we Pascal people seem to be rare beasts in the M-Media
world, I have had a few replies that show I am not at all unique.
So I want to encourage those people who are using Turbo Pascal:
I have already written 2 or 3 applications -- small utilities mostly --
on top of my multimedia unit, and it is working great. Especially so
now that the WakeUp routine is working -- a number of responses that
used to get missed and leave a display incomplete are now unfailingly
grabbed.
Alastair Milne