Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!mips!apple!portal!sv!leonardr From: leonardr@svc.portal.com Newsgroups: comp.sys.mac.programmer Subject: Re: RAM serial driver and event handling Message-ID: <1990Sep24.000818.29952@svc.portal.com> Date: 24 Sep 90 00:08:18 GMT References: <1990Sep20.143626.23475@midway.uchicago.edu> <10326@goofy.Apple.COM> Organization: Software Venture Lines: 42 In article <10326@goofy.Apple.COM> han@Apple.COM (Byron Han, scapegoat) writes: >In article <1990Sep20.143626.23475@midway.uchicago.edu> rfl@oddjob.UChicago.EDU () writes: >> >>How do you mean "steal"? > >Application A opens the serial driver. User switches to Finder and opens >Application B which also opens the serial driver. Data is not shared in a >totally nondeterministic manner between the two applications. > Boy is that an understatement if I ever heard one ;-) >Appications B (a A for that matter) should check to see if the serial driver >to be opened is already opened or not. If it is already open, it should >put up an alert saying that the serial port is already in use. If the driver >is not open, _PBOpen should then be called. If _PBOpen returns portInUse, >the application should also post an alert. This is what the Serial Connection >Tool does. > How would you recommed that you check for 'already open'? I can't speak for PBOpen, but FSOpen DOES NOT (at least under 6.x) return portInUse it just goes ahead and opens up the driver AGAIN. Caused big problems when I updated my old code from the Ram driver since I no longer got portInUse errors... >Oh also, do not assume that the only drivers available are .Ain, .Aout, .BIn, >and .Bout. If the CommToolbox is installed, perform a lookup of the serial >devices that are installed to get the names of all of the ports and the >names of the associated input and output drivers (which should all support the >same control calls that the existing .A/B In/Out drivers do. > Correct! Even if you do not use any of the other CTB managers, you should AT LEAST do a lookup for all serial devices so that the user can use any serial device. There is even example code in the CTB docs for doing this and it is REAL simple to add to an already properly written application. >Byron Han >Occasional Wizard Only occasional!?!? Ah, being modest...I get it. Leonard Rosenthol Software Ventures