To communicate with a serial device from your Mac OS X application, use I/O Kit functions to obtain a path to the device file for that device. Then, implement traditional UNIX serial port access using the POSIX termios API. Your application can read and write data using the device file.
Specifically, the sample code in this chapter demonstrates how to:
Find all serial devices that claim to be modems
Obtain the path to the device file of the first modem found
Use the POSIX API to initialize the modem and communicate with it through the device file
The sample code shown in this chapter is from an Xcode “CoreFoundation Tool” project. The project builds a tool that has no user interface and sends its output to the console. You can view the output either by running the tool within Xcode or by running the Console utility, which you can find at /Applications/Utilities/Console. You can, of course, write similar code without these restrictions. For detailed documentation on using Xcode, see http://developer.apple.com/referencelibrary/DeveloperTools/index.html.
Many functions, data types, and constants used in the sample code in this chapter are defined in header files in Kernel.framework, System.framework, or in the directory /usr/include (whose contents you can examine using the Terminal application, located in /Applications/Utilities/Terminal). Specific header files are noted where appropriate. Some functions and data types, such as those for working with the CFStringRef type, are defined in header files in CoreFoundation.framework.
Some functions and data types used in this chapter are described in UNIX man pages. To view the reference documentation for these, see Mac OS X Man Pages. Alternatively, you can view the documentation by typing manfunction_name (for example, man tcsetattr) in a Terminal window. Many of the code snippets in this chapter refer to specific man pages in the code comments.
Last updated: 2005-12-06