## Printer Device Driver

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

### Presentation Manager Port-Driver Interface

A port driver is responsible for transmitting data to a printer and receiving data from a printer. The port driver does not need to know the format of the data-a protocol converter handles the command language for bidirectional printers.

The following API definitions are exported by bidirectional PM port drivers :

SplPdOpen
SplPdClose
SplPdAbortDoc
SplPdResetAbort
SplPdWrite
SplPdNewPage
SplPdQuery
SplPdSet
SplPdEnumPort
SplPdGetPortIcon
SplPdInstallPort
SplPdRemovePort
SplPdSetPort
as well as (optionally):

SplPdRemoteSetPort
SplPdSendCmd

If SplPdOpen is exported by a port driver, then the spooler no longer calls SplPdInitPort or SplPdTermPort for port initialization/termination.

If SplPdSendCmd is exported, the spooler may call the bidirectional- software protocol converter directly, instead of calling SplPdQuery/ SplPdSet first. The protocol converter then calls SplPdSendCmd to pass the command data to the printer.

The spooler handles all inter-process communication for the port driver. All calls for sending print jobs, querying, or setting printer configurations are done from the single spooler process.

All structures returned by PrtQuery or passed into PrtSet must use offsets from the beginning of the buffer instead of imbedded pointers. This is done to allow the spooler to perform more efficient inter-process communications .

The following is the flow when a port driver exports SplPdSendCmd:

                   |

                    PrtSet

              /---------\

              | Spooler |-----------\

              \---------/           |

                                     SplProtSendCmd

                               /---------------\

                               | Bidirectional |

                               |    Protocol   |

                               |   Converter   |

                               \---------------/

                      /-------------/

                      |

                       SplPdSendCmd

              /-------------\

              | Port Driver |

              \-------------/

The following is the flow when a port driver does not export SplPdSendCmd:

           |

            PrtSet

      /---------\

      | Spooler |            Send set command to port driver

      \---------/

           |

            SplPdSet

      /-------------\

      | Port Driver |        Gives port driver's SendCmd function address to converter

      \-------------/

           |

            SplProtSendCmd

      /---------\

      | Spooler |            Routes to correct bidirectional protocol converter

      \---------/

           |

            SplProtSendCmd

      /--------------------\

      | Protocol Converter | Generates command string, and sends it to port driver

      \--------------------/

           |

            SendCmd

      /-------------\

      | Port Driver |        Sends protocol-specific commands to printer

      \-------------/

           |

           /

           /

           |

       /---------\

       |         |

       | Printer |

       |         |

       \---------/

See the OS/2 Presentation Device Driver Reference for detailed information on these APIs, their syntax, and their parameters.

SplPdOpen Called by PrtOpen to open a device for output.

SplPdClose Called by PrtClose to close a device connection and free the handle.

SplPdAbortDoc Called by PrtAbort and PrtAbortDoc for document-abort processing.

SplPdResetAbort Called by PrtResetAbort to reset an aborted device handle to allow writes again.

SplPdWrite Called by PrtWrite and SplProtWrite to write data to the device.

SplPdNewPage Called by PrtNewPage to signal the beginning of a new output page.

SplPdQuery Called by PrtQuery to get information about the print device.

SplPdSet Called by PrtSet to set printer device information.

SplPdSendCmd Called by SplProtSendCmd to send protocol-specific commands to the printer.

SplPdEnumPort Called by the print object to enumerate ports supported by this port driver when the port driver does not export the default install- port extended attribute.

SplPdGetPortIcon Returns the resource ID of the icon that represents the ports supported by this port driver.

SplPdInstallPort Called by the print object when the user elects to install a new printer port.

SplPdRemovePort Called by the print object when the user elects to delete an existing printer port.

SplPdSetPort Called by the print object when the user elects to open the settings on a printer port.

SplPdRemoteSetPort Called by the network print object when an administrator elects to open the settings on a server's printer port from a client machine.