home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / amiga / programm / 18060 < prev    next >
Encoding:
Internet Message Format  |  1993-01-02  |  3.7 KB

  1. Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!terapin!robertm
  2. From: robertm@terapin.com (Robert Michaels)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Programming Help Needed
  5. References: <kkPLwB3w165w@coyote.datalog.com>
  6. Message-ID: <robertm.323s@terapin.com>
  7. Date: 2 Jan 93 17:32:32 PST
  8. Organization: BBS
  9. Lines: 94
  10.  
  11. In article <kkPLwB3w165w@coyote.datalog.com>, cobra@coyote.datalog.com (Ken
  12. Thompson) writes:
  13. >  Greetings:
  14. > The following message is from a friend of mine...I know *very* little
  15. >about C programming, and stretched my brain for a few milli-seconds &
  16. >couldn't figure it out, so I'll forward it here...
  17. > If you would be as kind ast to E-Mail your responses, I will collect
  18. >them and forward them to my friend.  Thanks!         -Ken
  19. > - - - - - - - - - - - (generic cutting line) - - - - - - - - - - - - - -
  20. >Those who have done experimentation with the Serial port routines in C 
  21. >or otherwise, please step forward
  22. >My problem:
  23. >I set up the typical things to do a serial port read such as open 
  24. >up a MsgPort structure and then create a 'request block' with a 
  25. >CreateExtIO() function.  I set up the baud rates and know that every-
  26. >thing is working properly.
  27. >Now, I would like to receive one byte at a time from the serial port
  28. >in real time.  No 2400 bytes per second or anything.  And, for every 
  29. >one of those bytes from the serial port, I wish to get a MsgPort mes-
  30. >sage sent to me for each one of those bits and then check for that mes-
  31. >sage with a:
  32. >SerialPortSignal = 1 << ReadPortPtr->IOSer.io_Message.mn_ReplyPort->mp_Sig
  33. >Bit
  34. >I wish to check two other message ports at the same time in the same
  35. >manner.  One is from a window and the other from a timer.
  36. >Therefore, I wish to have three MessagePorts that all send me slow
  37. >changing information, and I wish one of them to be from the serial
  38. >port.
  39. >I can't use a 'Wait(Signals=SerialPortSignal (or) WindowPortSignal 
  40. >(or) TimerPortSignal) because it locks up and I don't get any signals
  41. >from either the timer or serial port if I do that.
  42. >Anybody got any code which may shed some light on this?
  43. >I don't wish to do continuous cycling and rechecking using the 
  44. >CheckIO() function, I just want it to sit there until things are 
  45. >done, or ready, then have it proceed.
  46. > - - - - - - - - - - - (generic cutting line) - - - - - - - - - - - - - -
  47. > Again, if responses could be E-mailed, it'd be appreciated...thanks!
  48. >
  49. >
  50. >           _____         ______________________   _____                
  51. >       |/    |          | cobra@datalog.com   |     |        /\        
  52. >       |\ en |hompson   | cobra@jab.tus.az.us |     |ucson, /--\rizona 
  53. >     ------------------------------------------------------------------
  54. First request that the serial device read exactly one byte as follows:
  55.  
  56. /*Issue read command for serial port, don't wait for IO to be completed*/
  57.  
  58. VOID readser(void)
  59.  
  60. {
  61.    SerialRdIO->IOSer.io_Command=CMD_READ;
  62.    SerialRdIO->IOSer.io_Length=1;
  63.    SendIO((struct IORequest *)SerialRdIO);
  64. }
  65.  
  66.  
  67. Then use the following to wait for the read to take place...note that you can
  68. add in as many other masks for events to wait for in addition to 'WINDMASK':
  69.  
  70.  
  71. VOID WaitActivity(VOID)
  72.  
  73. {
  74.    (VOID) Wait(windmask|sermask);
  75.    if (CheckIO((struct IORequest *)SerialRdIO)) {
  76.    WaitIO((struct IORequest *)SerialRdIO);  /*Serial read complete-celanup*/
  77.    ...do whatever you want when byte is read...
  78.    } else {
  79.    ...check for other reason Wait returned...
  80. }
  81.  
  82.  
  83. Note that you can save the value returned by wait and test it against windmask,
  84. sermask or other masks to see which event occurred.
  85.  
  86. Also, sermask=1L<<SerialMP.mp_SigBit.
  87. Simularily to windmask would be 1L<<Window.UserPort.mp_SigBit.
  88.  
  89. Let me know if this is unclear or you have further questions.
  90.