Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: For GURU'S Only Message-ID: <34253@ucbvax.BERKELEY.EDU> Date: 12 Feb 90 15:22:53 GMT References: <4073@ccncsu.ColoState.EDU> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 49 >1) Can the Mac 2x 16mhz. keep up with this data rate? Yes. For example, LocalTalk Appletalk uses the serial port at 250K baud and even a MacPlus can keep up with it. >2) Could it keep up while dumping to disk? (8 meg RAM is available) Probably, if you use the Port A, (the port with a picture of a Modem.) It would be safer to buffer the whole image in RAM, then write it. >3) Can this be done in the background without going to an assembly level? I don't have to much time. Yes. >4) Would anyone have any small example of direct control of the > serial port? (in C preferably) Do not do this. Just use the Serial Driver asynchronously. Write a simple application as follows. Set its "can Background" bit in its SIZE resource so multifinder will give it null events in background. Here is what it does: OpenDriver("\p.Ain") and OpenDriver("\p.Aout"). Set the speed of the port to 56k. Set the serial buffer size to something decently large. The serial driver will automatically buffer unread characters into its buffer, in preparation for a read call sometime later. Now, enter the event loop of your application. Use WaitNextEvent() and set your application to wake up every second. at nullEvent time, check, using TickCount() to see if one second has elapsed. If it has not, do nothing, just loop around back to WaitNextEvent(). If the time has elapsed, check the number of unread characters in the serial driver's buffer. If it is large and hasn't changed in the last two seconds, you've got a complete image. FSWrite it to a disk file. FSRead the serial buffer into itself, or do a KillIO on the serial port to reset the driver. Add a menu bar, so the user can Quit the application, and it can reset the serial buffer, close the port and clean up after itself. Trivial. No funky calls, no assembly language. > The mac is a detour in the inevitable march of mediocre computers. > drs@bnlux0.bnl.gov (David R. Stampf) --- David Phillip Oster -master of the ad hoc odd hack. Arpa: oster@dewey.soe.berkeley.edu Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu