home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!swrinde!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!network.ucsd.edu!qualcom.qualcomm.com!NewsWatcher!user
- From: jpurlia@qualcomm.com (John Purlia)
- Newsgroups: comp.sys.mac.programmer
- Subject: Asynch Serial IO
- Message-ID: <jpurlia-110992084343@129.46.5.45>
- Date: 11 Sep 92 15:46:30 GMT
- Sender: news@qualcomm.com
- Followup-To: comp.sys.mac.programmer
- Organization: Qualcomm, Inc.
- Lines: 64
- Nntp-Posting-Host: 129.46.5.45
-
- Has anyone had any luck passing data out the serial ports asynchronously?
- I'm passing buffers of data with asynch calls to PBWrite, which seems to
- work fine (though, how would I know; I'm not connected to anything yet!),
- but my program freezes when I quit and call KillIO. A press of the
- programmer's switch shows the toolbox wandering around inside of
- FluhEvents. In a nutshell, here's what I'm doing (lots of stuff excluded,
- of course):
-
- /* Open the drivers and set the baud rate */
- void serialInit (void)
- {
- OpenDriver ("\p.AOut", &AoutRef);;
- OpenDriver ("\p.AIn", &AinRef);
- SerReset (AoutRef, baud1200 + stop10 + noParity + data8);
- SerSetBuf (AinRef, &BigBuf, BIGBUFSIZ);
- }
-
- /* The spot where I transfer a buffer out the serial port */
- void serialTx (void)
- {
- memset ((char *) &gTransmitPB, 0, sizeof (HParamBlockRec));
- gTransmitPB.ioParam.ioRefNum = AoutRef;
- gTransmitPB.ioParam.ioBuffer = txbuf;
- gTransmitPB.ioParam.ioReqCount = i;
- if (errcode = PBWrite (&gTransmitPB, true))
- transmitError (errcode);
- }
-
- /* Called everytime through my main event loop. I poll for completion
- of the asynchronous PBWrite call */
- void idleLoop (void)
- {
- /* If we're still trying to transmit... bail! */
- if (gTransmitPB.ioParam.ioResult == 1)
- return;
- else
- if (gTransmitPB.ioParam.ioResult) {
- transmitError (gTransmitPB.ioParam.ioResult);
- gTransmitPB.ioParam.ioResult = 0;
- }
- }
-
- /* This is called when I quit the program */
- void closeSerial (void) {
- KillIO (AoutRef);
- KillIO (AinRef);
- CloseDriver (AinRef);
- CloseDriver (AoutRef);
- }
-
-
- The app freezes as soon as it hits the first KillIO call. When I make the
- call to PBWrite synchronous, or otherwise use a call to FSWrite, everything
- works fine, but of course I have to wait unacceptable periods of time for
- the IO to complete. Now, I know that the file manager does not *really*
- work asynchronously (at least not to the hard disk), but the serial ports
- certainly should!
-
- Any ideas?
-
- ...........................................................................
- John Purlia : My brain; not my company's brain. My brain says...
- jpurlia@qualcomm.com : "The Toolbox giveth, and the Tech Notes taketh away"
- ...........................................................................
-