home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!waikato.ac.nz!aukuni.ac.nz!cs18.cs.aukuni.ac.nz!awil2
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Puzzled: Serial PowerBook I/O
- Message-ID: <1992Dec17.222300.16232@cs.aukuni.ac.nz>
- From: awil2@cs.aukuni.ac.nz (Andrew James Willmott )
- Date: Thu, 17 Dec 1992 22:23:00 GMT
- References: <zzT=-a#@engin.umich.edu>
- Organization: Computer Science Dept. University of Auckland
- Lines: 70
-
- In <zzT=-a#@engin.umich.edu> Gavin@UMich.EDU (Gavin Eadie) writes:
-
- >Friends ... I'm puzzled. The following complete ThinkC program runs to
- >completion on several Macs I've tried (II, IIci, Q-700 and Q-900) but
- >fails to complete on PowerBooks (170 and 145). It's got to be something
- >simple (or maybe not) -- can you help?
-
-
- >#include <Devices.h>
- >#include <Events.h>
- >#include <Serial.h>
-
- >#include <stdIO.h>
-
- >short refNum_in, refNum_out;
- >long outcount;
- >char outBuffer[128];
- >OSErr oserr;
-
- >main () {
- > printf("Here we go ... Mouse-Klik to stop\n",oserr);
-
- > oserr = OpenDriver("\p.AOut", &refNum_out);
- > if(oserr != noErr) {
- > printf("OpenDriver(out): %d\n",oserr);
- > goto exit;
- > }
-
- > oserr = OpenDriver("\p.AIn", &refNum_in);
- > if(oserr != noErr) {
- > printf("OpenDriver(in): %d\n",oserr);
- > goto exit;
- > }
-
- > outcount = 1;
- > outBuffer[0] = ' ';
- > oserr = FSWrite(refNum_out, &outcount, (Ptr)outBuffer);
- > if(oserr != noErr) {
- > printf("FSWrite(out): %d\n",oserr);
- > }
- >
- >exit:
- > do {
- > } while (!Button());
- >}
-
- This could be because the powerbooks (or any Mac with a power manager)
- require you to turn the serial port on before you use it, with a call called
- (I think!) Aon. (There's also Aoff, Bon and Boff.) I had this problem with
- a MIDI program of mine that I tried to run on my PB100. I couldn't figure out
- why nothing was coming out or going in when it worked fine on other machines.
- It would work properly when another serial program was running in the
- background, however! It turned out that this was because the serial program
- *did* turn on the port, so my application could then run.
-
- On the other hand, this might not be your problem, because I was writing
- directly to the VIA rather than using OpenDriver, due to the non-standard
- MIDI clock rate. (Non-standard for the Mac, that is!) I would imagine that
- OpenDriver("Ain"...) should turn the port for you. Then again, it wouldn't
- do any harm to check :)
-
- Cheers,
-
- Andrew
-
- --
- +--- Andrew Willmott ------------- awil2@cs7.cs.aukuni.ac.nz ---+
- | Diplomacy: The art of saying "nice doggie" until you find a |
- | rock. -Wynn Catlin |
- +------------------------- Auckland, NZ ------------------------+
-