Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Working With a Serial Device

This chapter provides sample code that demonstrates how to use the device-file mechanism to find and communicate with a serial device that explicitly claims to be a modem, such as a built-in or USB modem. Because there is no safe, programmatic way to determine if a device attached to a serial port is indeed a modem, the sample code in this chapter does not find modems on the other side of a serial port.

The code snippets in this chapter are from the sample application SerialPortSample, available in its entirety at http://developer.apple.com/samplecode/SerialPortSample.

Note: If you choose to develop a Cocoa application that accesses a serial modem, be aware that Objective-C does not provide interfaces for I/O Kit or POSIX functions. However, because the I/O Kit and POSIX APIs are C APIs, you can call them from a Cocoa application.

Although the sample code in this chapter has been compiled and tested to some degree, Apple does not recommend that you directly incorporate this code into a commercial application. For example, only limited error handling is shown—you should develop your own techniques for detecting and handling errors.

Important: The sample code in this chapter is written to run in Mac OS X v10.0 or later.

Contents:

Serial Device Access in an Intel-Based Macintosh
Accessing a Serial Device
Including Header Files and Defining Macros and Constants
Setting Up a Main Function
Finding All Modems
Getting the Path to the Device File for a Modem
Opening the Serial Port
Communicating With the Modem
Closing the Serial Port




< Previous PageNext Page > Hide TOC


Last updated: 2005-12-06




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.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice