## Printer Device Driver

[prev][next][parent][TOC]

### Sample Bidirectional Infrared Port Driver

A port driver is only responsible for transmitting data to and from the printer; it is not responsible for interpreting the information being sent to or returned by the printer. A PM port driver is a DLL that is used to communicate with a printer. The PM port-driver interface now passes all print job data to the port driver and allows the port driver to return information sent by the printer. Example port drivers are the:

/OS2/DLL/PARALLEL.PDR for parallel attached printers
/OS2/DLL/SERIAL.PDR for COM devices

While different manufacturers may use unique protocols to connect to their printers, developers can write a port driver for a set of printers that use a unique communications mechanism. For example, a port driver can be written for network-wire attached printers.

Our sample infrared port driver, when compiled with the target BIDIDBG, logs informational messages into a file called "C:\ALERT.INF". This is to help with debugging only. To disable logging to this file, change the makefile so that it no longer defines compile-flag DEBUG_ALERT.

The sample infrared port driver can be changed to support a different communications media. Make copies of our port-driver makefile and source; then, change the string "INFRARED" in the names of these files to a string that matches the new port driver being developed-e.g., "MYDRIVER".

Here is a code roadmap:

help.c Initializes and calls help functions. To enable easier loading, this dynamically loads HELPMGR.DLL instead of linking to the help manager.

infrared.c Handles all communication with the infrared device. This code uses some callback functions to interface with the LMDLL.DLL infrared helper DLL. This should be replaced with code specific to the communications media used by your new port driver.

init.c Contains DLL initialization and port-driver initialization routines. This code loads LMDLL.DLL when needed by the port driver.

pdrapi.c Public-entry points for port driver. This contains all the public SplPd APIs for the port driver.

util.c Utility functions for the port driver, including memory-allocation and global semaphore-access routines.