home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15350 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  2.8 KB

  1. 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
  2. From: jpurlia@qualcomm.com (John Purlia)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Asynch Serial IO
  5. Message-ID: <jpurlia-110992084343@129.46.5.45>
  6. Date: 11 Sep 92 15:46:30 GMT
  7. Sender: news@qualcomm.com
  8. Followup-To: comp.sys.mac.programmer
  9. Organization: Qualcomm, Inc.
  10. Lines: 64
  11. Nntp-Posting-Host: 129.46.5.45
  12.  
  13. Has anyone had any luck passing data out the serial ports asynchronously? 
  14. I'm passing buffers of data with asynch calls to PBWrite, which seems to
  15. work fine (though, how would I know; I'm not connected to anything yet!),
  16. but my program freezes when I quit and call KillIO.  A press of the
  17. programmer's switch shows the toolbox wandering around inside of
  18. FluhEvents.  In a nutshell, here's what I'm doing (lots of stuff excluded,
  19. of course):
  20.  
  21. /* Open the drivers and set the baud rate */
  22. void serialInit (void)
  23. {
  24.     OpenDriver ("\p.AOut", &AoutRef);;
  25.     OpenDriver ("\p.AIn", &AinRef);
  26.     SerReset (AoutRef, baud1200 + stop10 + noParity + data8);
  27.     SerSetBuf (AinRef, &BigBuf, BIGBUFSIZ);
  28. }
  29.  
  30. /* The spot where I transfer a buffer out the serial port */
  31. void serialTx (void)
  32. {
  33.     memset ((char *) &gTransmitPB, 0, sizeof (HParamBlockRec));
  34.     gTransmitPB.ioParam.ioRefNum    = AoutRef;
  35.     gTransmitPB.ioParam.ioBuffer    = txbuf;
  36.     gTransmitPB.ioParam.ioReqCount = i;
  37.     if (errcode = PBWrite (&gTransmitPB, true))
  38.         transmitError (errcode);
  39. }
  40.  
  41. /* Called everytime through my main event loop.  I poll for completion
  42.    of the asynchronous PBWrite call */
  43. void idleLoop (void)
  44. {
  45.     /* If we're still trying to transmit... bail! */
  46.     if (gTransmitPB.ioParam.ioResult == 1)
  47.         return;
  48.     else
  49.         if (gTransmitPB.ioParam.ioResult) {
  50.             transmitError (gTransmitPB.ioParam.ioResult);
  51.             gTransmitPB.ioParam.ioResult = 0;
  52.         }
  53. }
  54.  
  55. /* This is called when I quit the program */
  56. void closeSerial (void) {
  57.     KillIO (AoutRef);
  58.     KillIO (AinRef);
  59.     CloseDriver (AinRef);
  60.     CloseDriver (AoutRef);
  61. }
  62.  
  63.  
  64. The app freezes as soon as it hits the first KillIO call.  When I make the
  65. call to PBWrite synchronous, or otherwise use a call to FSWrite, everything
  66. works fine, but of course I have to wait unacceptable periods of time for
  67. the IO to complete.  Now, I know that the file manager does not *really*
  68. work asynchronously (at least not to the hard disk), but the serial ports
  69. certainly should!
  70.  
  71. Any ideas?
  72.  
  73. ...........................................................................
  74. John Purlia          : My brain; not my company's brain.  My brain says...
  75. jpurlia@qualcomm.com : "The Toolbox giveth, and the Tech Notes taketh away"
  76. ...........................................................................
  77.