Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!ucsd!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Opening the serial driver. Message-ID: <4546@helios.ee.lbl.gov> Date: 2 Jan 90 23:24:18 GMT References: <3903@atr-la.atr.co.jp> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 45 X-Local-Date: 2 Jan 90 15:24:18 PST In article <3903@atr-la.atr.co.jp> alain@atr-la.atr.co.jp (Alain de Cheveigne) writes: > > >I'm updating some code according to TN 249 to use OpenDriver() instead >of RamSDOpen(). I hope in this way to detect when some other terminal >program has opened the line, to avoid opening twice. The code I use is: > /* MPW C 3.0 */ > /* test to see if another program owns the serial port */ > short refnum = aoutRefNum; > result = opendriver("AOut",&refnum); >The result of opendriver() is always -43, which corresponds to fnfErr >in Errors.h of CInterfaces. >1) What am I doing wrong? > MPW C has lower case equivalents that accept C strings everybody. Therefore, the call opendriver(char*,short*) takes a C (i.e. null terminated) string. The reason you are getting a fnfErr return code is that the names for the serial drivers are ".AIn" & ".AOut". They have "." characters to avoid conflicts with file names (hopefully). Therefore, the call result = opendriver(".AOut", &refnum); should work. The equivalent call using pascal strings is result = OpenDriver("\p.AOut", &refnum); which is more "portable" (between Think and MPW C). I, for one, will never use the lower case calls because no other development system offers them, and I try to keep my strings in pascal form as much as possible to avoid having to conversions. On a similar note, does anybody have a library of pascal string manipulation code lying around? I guess it would be nice to have all of the regular C string functions cast in a form to manipulate pascal strings. I've always wondered, what do Pascal programmers use to do things like sprintf? ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------