Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!cs.utexas.edu!sun-barr!ccut!titcca!kddlab!atrpost!atr-la!alain From: alain@atr-la.atr.co.jp (Alain de Cheveigne) Newsgroups: comp.sys.mac.programmer Subject: Opening the serial driver. Message-ID: <3903@atr-la.atr.co.jp> Date: 31 Dec 89 07:06:27 GMT Organization: ATR International,Japan Lines: 63 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); if (result == portInUse) { /* port already open */ dont_close_serial = true; /* no need to close on exit */ return; } [test for portNotCf] if (result != noErr) { errMsg("result: %d", result); /* say what's wrong */ error = true; return; } [code to open "AIn"] The result of opendriver() is always -43, which corresponds to fnfErr in Errors.h of CInterfaces. I don't know what that means. I tried installing the SERD resources in the program file, with no success. Questions: 1) What am I doing wrong? 2) If I get OpenDriver() to work, should I still use SerSetBuf(), SerHShake(), SerReset(), etc., or are they also superseded? 3) If I don't get it to work, is there any objection to keeping with RamSDOpen()? I think Tim Maroney suggested some time back that one can test whether the port is open with a status call, and open only if that call fails. 4) If the port is already open, I don't need to open, and I don't close on exit. I expect other programs to act the same. What happens if I opened first, then the other program starts, then I quit. Is there anyway of knowing if the other program still needs the port? 5) My program works fine over serial lines. I'd like it to work over ethernet, and maybe AppleTalk. Is there any chance that someone will come out with a piece of software that will emulate a serial port over ethernet or AppleTalk? It would open a window, establish a connection to a host and let me log in, and from then on the serial port (A or B) would be redirected through this channel. I wouldn't need to modify my code. Is this in the CTB? If so, is there something I should do to be compatible? Or shall I really have to modify my code? Thanks for any help. If I get good e-mail, I'll summarize. Alain de Cheveigne, alain@atr-la.atr.co.jp