Using IOCtl Functions to Access Devices

Many OS/2 functions communicate with devices. Usually, this communication is transparent to the application (the application has no knowledge of how the communication actually occurs). At times, however, an application requires more direct access to a device. To accommodate this need, OS/2 furnishes DosDevIOCtl. Applications can use DosDevIOCtl to send commands and data to a device driver; the device driver interprets these commands and sends the appropriate instructions to the physical device.

As an example, some devices have several operating modes. A communications port can operate at one of a number of bit rates and have several data-word formats. The actual commands to set these parameters might vary, depending on the communications hardware.

Named constants have been defined for the categories, functions, and commands that are passed to a device driver, to make it easier for application programmers to use DosDevIOCtl. These named constants are defined in the file BSEDEV.H. This file must be included in your application when you use the constants. This file also contains data structure definitions for the parameter and data packets commonly used with DosDevIOCtl. The following examples use the communications port to demonstrate how DosDevIOCtl works.


[Back: Using the File System to Access Devices]
[Next: Setting Communications-Port Parameters]