Serial Sample

DESCRIPTION

The Serial (16550-based RS-232) sample driver is a WDF version of the inbox Serial.sys driver in %WINDIR%\system32\drivers. This sample driver is functionally equivalent to the inbox driver, with these two exceptions:

  1. This sample does not support multi-function serial devices.
  2. This sample does not support legacy serial ports. Legacy ports are not detected by the BIOS, and are, therefore, not enumerated by the operating system.

The code in this sample works on Microsoft Windows 2000 and later versions of Windows.

The Serial sample driver runs in kernel mode.

This sample driver supports power management. When a serial port is not in use, the driver places the port hardware in a low-power state. When the port is opened, it receives power and wakes up. The driver supports wake-on-ring for platforms that support this function. The driver can be compiled to run on both 32-bit and 64-bit versions of Windows.

BUILDING THE SAMPLE

Click Start, click All Programs, find your installed WDK in the list of programs, and select an appropriate build environment. The resulting Command Window defines the environment variables to use for the build process.

In this Command Window, change to the directory (src\serial\serial in your installed WDK files) that contains the source code for the Serial sample driver.

Enter the command build -ceZ (or, equivalently, run the BLD macro). This command invokes the make routines in the WDK, which build the sample driver components. If the build succeeds, you will find the Wdfserial.sys driver binary file and the Serial.inf information file in the build output directory. You can infer the name of this output directory from the name of the Buildxxx.log file (for example, Buildfre_win7_x86.log). If the build fails, you can find errors and warnings in the Buildxxx.err and Buildxxx.wrn files, respectively.

INSTALLATION

On your test computer, create an installation directory (for example, C:\Serialsample). Into this directory, copy the Wdfserial.sys and Serial.inf files from the build output directory. In addition, copy the KMDF co-installer file (for example, WdfCoInstaller01009.dll from the redist\wdf directory in your installed WDK files) to this installation directory.

Open Device Manager, find Ports (COM & LPT) in the device list, and open the list of ports. Right click on Communication Port (COM1) and select Update Driver Software. In the Update Driver Software dialog, click Browse my computer for driver software. Next, click Let me pick from a list of device drivers on my computer, and click Have Disk. In the Install From Disk dialog, browse to the installation directory (for example, C:\Serialsample), and complete the installation.

Run Hypertrm.exe or a similar test application to verify that the serial port can be opened, and that it can send and receive data.

RESOURCES

See the description of the Kernel-Mode Driver Framework in the WDK documentation.

CODE TOUR

File Manifest

FileDescription

Serial.htm

The documentation for this sample (this file)

Sources

The generic file for building this code sample

Error.c

Error operations

Flush.c

Flush operations

Immediat.c

Handles the sending of immediate data

Initunlo.c

Performs driver initialization and unload

Ioctl.c

IOCTL requests

Isr.c

Interrupt service routine functionality

Log.c

Debugging log support

Log.h

Debugging macro definitions

Modmflow.c

Flow control functionality

Openclos.c

CreateFile and Close functionality

Pnp.c

Plug and Play (PnP) support

Power.c

Power support

Precomp.h

Pre-compiled header file

Purge.c

Purge operations

Qsfile.c

Query/set file operations

Read.c

Read operations

Registry.c

Miscellaneous registry access functions

Serial.h

Type definitions and data for serial driver

Serial.rc

Resource data

Serlog.mc

Log messages

Utils.c

Generic helper functionality

Waitmask.c

Wait-mask functionality

Wmi.c

WMI support

Write.c

Write operations

 

 

 

Send comments about this topic to Microsoft

Build date: 6/11/2012

Show:
© 2015 Microsoft