Stream Drivers (Compact 7)
3/12/2014
Windows Embedded Compact includes the stream interface API, which makes it possible for software modules to interact with peripherals as if they were files. A stream driver (sometimes referred to as a stream interface driver) is any driver that exposes the stream interface, regardless of the type of the device that the driver controls. The stream interface is appropriate for any I/O device that can be considered a data source or a data sink.
Stream Interface API
The stream interface functions are designed to closely match the semantics of file system APIs such as ReadFile, WriteFile, and IOControl. Device functionality presented through the stream interface is exposed to applications through the file system; that is, applications interact with the driver by opening specially named files in the file system.
The stream interface consists of thirteen functions as shown in the following table.
Stream interface function name | Description |
---|---|
Initializes the device. |
|
Opens the device. |
|
Closes the device. |
|
Reads data from the device |
|
Writes data to the device. |
|
Moves the data pointer in the device. |
|
Sends a command to the device. |
|
Cancels all pending asynchronous I/O requests. |
|
De-initializes the device |
|
Prepares the device driver for de-initialization. |
|
Prepares the device driver for a close operation. |
|
Ends power to the device |
|
Restores power to the device. |
The XXX prefix is a placeholder: replace XXX with the prefix for a specific device driver implementation. Alternately, some drivers may use undecorated entry point names that do not have the XXX prefix. For more about stream interface functions, see Stream Interface Driver Reference.
When to Create a Stream Driver
Consider using a stream driver design for a new device driver implementation if any one of the following is true:
- Your device driver manages a peripheral that produces or consumes streams of data as its primary function. For example, applications typically access storage, serial port, and audio devices through stream drivers. An example of a device that is not a good candidate for a stream driver is a display device, because it does not produce or consume data by using traditional stream-oriented file system methods.
- Applications that use your device driver are currently implemented to access device functionality through a file system interface.
- You are starting your device driver development with an existing Windows Embedded Compact 7 sample driver that is a stream driver.
- You are porting your device driver from another operating system. Because the stream interface approach is common to many operating systems, you may find it easiest to port an existing device driver to Windows Embedded Compact 7 by adapting it to the stream interface.
Sample Stream Driver
Microsoft provides source code for a sample stream driver at %_WINCEROOT%\Platform\BSPTemplate\Src\Drivers\Streamdriver. For more information about using this sample driver to develop a new device driver, see Implement Your Device Driver.
For More Information About Stream Drivers
Windows Embedded Compact 7 documentation includes detailed reference material for the design and implementation of stream interface drivers. If you are creating a stream driver, make sure that you read the topics described in the following table.
Topic | Description |
---|---|
Explains each of the stream interface driver functions, describing syntax, parameters, and return values. |
|
Device Manager functions for loading stream drivers, issuing I/O controls to devices, and handling asynchronous read, write, and I/O control operations. |
|
File system functions that applications use to access stream devices, including CreateFile, ReadFile, and WriteFile. |