home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19992 < prev    next >
Encoding:
Internet Message Format  |  1992-12-18  |  2.6 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!waikato.ac.nz!aukuni.ac.nz!cs18.cs.aukuni.ac.nz!awil2
  2. Newsgroups: comp.sys.mac.programmer
  3. Subject: Re: Puzzled: Serial PowerBook I/O
  4. Message-ID: <1992Dec17.222300.16232@cs.aukuni.ac.nz>
  5. From: awil2@cs.aukuni.ac.nz (Andrew James        Willmott       )
  6. Date: Thu, 17 Dec 1992 22:23:00 GMT
  7. References: <zzT=-a#@engin.umich.edu>
  8. Organization: Computer Science Dept. University of Auckland
  9. Lines: 70
  10.  
  11. In <zzT=-a#@engin.umich.edu> Gavin@UMich.EDU (Gavin Eadie) writes:
  12.  
  13. >Friends ... I'm puzzled.  The following complete ThinkC program runs to
  14. >completion on several Macs I've tried (II, IIci, Q-700 and Q-900) but
  15. >fails to complete on PowerBooks (170 and 145).  It's got to be something
  16. >simple (or maybe not) -- can you help?
  17.  
  18.  
  19. >#include <Devices.h>
  20. >#include <Events.h>
  21. >#include <Serial.h>
  22.  
  23. >#include <stdIO.h>
  24.  
  25. >short     refNum_in, refNum_out;
  26. >long    outcount;
  27. >char    outBuffer[128];
  28. >OSErr    oserr;
  29.  
  30. >main () {
  31. >    printf("Here we go ... Mouse-Klik to stop\n",oserr);
  32.  
  33. >    oserr = OpenDriver("\p.AOut", &refNum_out);
  34. >    if(oserr != noErr) {
  35. >        printf("OpenDriver(out): %d\n",oserr);
  36. >        goto exit;
  37. >    }
  38.  
  39. >    oserr = OpenDriver("\p.AIn", &refNum_in);
  40. >    if(oserr != noErr) {
  41. >        printf("OpenDriver(in): %d\n",oserr);
  42. >        goto exit;
  43. >    }
  44.  
  45. >    outcount = 1;
  46. >    outBuffer[0] = ' ';
  47. >    oserr = FSWrite(refNum_out, &outcount, (Ptr)outBuffer);
  48. >    if(oserr != noErr) {
  49. >        printf("FSWrite(out): %d\n",oserr);
  50. >    }
  51. >    
  52. >exit:
  53. >    do {
  54. >    } while (!Button());
  55. >}
  56.  
  57. This could be because the powerbooks (or any Mac with a power manager)
  58. require you to turn the serial port on before you use it, with a call called
  59. (I think!) Aon. (There's also Aoff, Bon and Boff.) I had this problem with
  60. a MIDI program of mine that I tried to run on my PB100. I couldn't figure out
  61. why nothing was coming out or going in when it worked fine on other machines.
  62. It would work properly when another serial program was running in the
  63. background, however! It turned out that this was because the serial program
  64. *did* turn on the port, so my application could then run.
  65.  
  66. On the other hand, this might not be your problem, because I was writing
  67. directly to the VIA rather than using OpenDriver, due to the non-standard
  68. MIDI clock rate. (Non-standard for the Mac, that is!) I would imagine that
  69. OpenDriver("Ain"...) should turn the port for you. Then again, it wouldn't
  70. do any harm to check :)
  71.  
  72. Cheers,
  73.  
  74. Andrew
  75.  
  76. -- 
  77. +--- Andrew Willmott ------------- awil2@cs7.cs.aukuni.ac.nz ---+
  78. | Diplomacy: The art of saying "nice doggie" until you find a   |
  79. | rock.                                          -Wynn Catlin   |
  80. +------------------------- Auckland, NZ ------------------------+
  81.