ADC Home > Reference Library > Technical Notes > Legacy Documents > Hardware & Drivers >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Opening the Serial Driver

CONTENTS

This Technical Note describes the recommended, safe, and compatible way to open the Macintosh serial driver, and it explains why you should no longer check for port availability.

Updated: [October 01 1989]






OpenDriver

Starting with the 128K ROM, we recommend that applications do not check the low-memory globals SPConfig, PortAUse, and PortBUse before opening the serial driver. It is no longer the application's responsibility to test for the availability of the serial ports. When running AppleTalk Phase 2, it is now possible to use the printer port for asynchronous serial communication while AppleTalk is active and using an alternate connection, such as EtherTalk or TokenTalk.

The serial driver automatically verifies that the serial port is correctly configured and free for an asynchronous driver; if it is not correctly configured or free, the serial driver returns either the result code portNotCf or portInUse. The serial driver already has all the code built into it for testing the availability of the serial ports before trying to complete the _Open call. Therefore, since all of the required checks are made inside the driver itself, we recommend that a simple OpenDriver call be made when you need to use a serial port.

By using just the OpenDriver call to the serial driver, you ensure that your code is both user-friendly and compatible with future versions of the System Software.

Pascal

result := OpenDriver('.AOut',AoutRefNumber);
       {Check result codes in a real application. }

result := OpenDriver('.AIn',AinRefNumber);
       {See failure mechanism in Sample Code. }

C

result = OpenDriver("\p.AOut",&AoutRefNumber);
       /*Check result codes in a real app.*/

result = OpenDriver("\p.AIn",&AinRefNumber);
       /* See failure mechanism in Sample Code.*/

If you must maintain compatibility with the 64K ROMs, call _SysEnvirons, then either call RAMSDOpen for the 64K ROM machines or OpenDriver for the others.

Back to top

References

Inside Macintosh, Volume II-249, The Serial Driver

Inside Macintosh, Volume IV-225, The Serial Driver

Technical Note M.OV.GestaltSysenvirons -- Gestalt and Sysenvirons : a Never Ending Story

DTS Q & A Stack

Back to top

Change History

01-August-1989

Originally written.

01-October-1989

Corrected syntax errors in the sample code.

Back to top

Downloadables

Acrobat gif

Acrobat version of this Note (48K)

Download


Back to top


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.