Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!goofy.apple.com!chesley From: chesley@goofy.apple.com (Harry Chesley) Newsgroups: comp.sys.mac.programmer Subject: Re: FSRead hangs on the serial driver Message-ID: <6113@internal.Apple.COM> Date: 11 Jan 90 01:26:52 GMT Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 37 References:<7770@unix.SRI.COM> <4713@hydra.gatech.EDU> In article <4713@hydra.gatech.EDU> cc100aa@prism.gatech.EDU (Ray Spalding) writes: > >1) Why does the second FSRead hang? > > Because it will not return until it gets the exact number of characters > you asked it to read. More exactly: it will read until it gets at least as many characters as you ask for (more is OK). It sounds like you're experiencing either buffer overflow or baud rate mismatch. The default input buffer for the serial port is only 64 bytes. So 80 characters can easily overflow the buffer if you don't read it out fast. You can increase the buffer size by calling SerSetBuf (but be sure and unset the buffer by calling SerSetBuf with a length of zero before exiting the application or you'll get horrible crashes). Alternatively, the baud rates may not be set right. Therefore, you send enough characters at one speed, but they come through as fewer gibberish characters at the other speed. In article <4713@hydra.gatech.EDU> cc100aa@prism.gatech.EDU (Ray Spalding) writes: > >3) Is there a way to get the serial driver and/or FSRead to time out? > > The way to accomplish this is to use asynchronous I/O (in the > sense of IM vol IV, not in the sense of async data communications). > You start an asynchronous read request, then go about your business processing > events and so on. Periodically, you check the request block for completion: > 0 == normal completion; 1 == still in progress; anything else == error. > If you want to time it out, you have to watch the time yourself (using > TickCount). Even simpler, use SerGetBuf to find out how many input characters are available, and do a synchronous call but only when there are enough characters available.