打印机设备驱动程序通过模式
缺省情况下,打印机设备驱动程序本身 (例如 /dev/lp0) 以非传递方式运行。
用户可以通过发出 splp 命令来查询或修改 /dev/lp0 的操作规则。 例如,以下是在定义为 lp0的 IBM® 4029 LaserPrinter 的系统上发出 splp lp0 命令的结果。 结果被输出到由 TERM 环境变量指定的显示器组件。
device = /dev/lp0 (+ yes ! no)
CURRENT FORMATTING PARAMETERS (ignored by qprt, lpr, and lp commands)
Note: -p + causes the other formatting parameters to be ignored.
-p ! pass-through? -c + send carriage returns?
-l 64 page length (lines) -n + send line feeds?
-w 80 page width (columns) -r + carriage rtn after line fee?
-i 0 indentation (columns) -t + suppress tab expansion?
-W ! wrap long lines? -b + send backspaces?
-C ! convert to upper case? -f + send form feeds?
CURRENT ERROR PROCESSING PARAMETERS
-T 600 timeout value (seconds) -e ! return on error?
CURRENT SERIAL INTERFACE PARAMETERS
-B 19200baud rate -s 8 character size (bits)
-N ! enable parity? -S ! two stop bits?
-P ! odd parity? -p 参数确定打印机设备驱动程序 /dev/lp0 是否缺省设置为操作的通过模式; 操作模式可以被特定的数据流覆盖。 缺省情况下, -p 参数的值为 !。 或 不。 需要注意的是, -p 参数提出的问题是: "操作方式是否为传递方式?"
如果 -p 参数的值为 !,那么 然后,在数据流处理期间,设备驱动程序将使用列出的所有其他参数。 同样地,如果 -p 参数的值为 + 或 yes, 那么所有其他参数在数据流处理期间将被忽略。
使用 splp 命令更改打印机设备驱动程序的参数值不会影响假脱机程序的操作。 当 splp 命令用于直接访问设备驱动程序 (绕过假脱机程序) 时,它会影响诸如 cat 之类的命令。 例如,命令
cat /etc/motd > /dev/lp0打开 /dev/lp0 并将“每日提示”的内容直接写入打印机。 打印机的输出格式化类似于以下示例:
This is a test version of /etc/motd, used to demonstrate
what happens when a printer device driver, such as
/dev/lp0, is placed into or taken out of passthru mode.
Printers will print either exactly what they are sent,
if you set the job conditions up correctly, or, on the
most current printers, you may be able to direct the
printer to perform certain mappings for you. There are no carriage returns in
this file, and the only blank line occurs
immediate before this one.注意 -r 参数规定如果 -p 的值为 !,那么每个换行都映射为换行和回车。 这是必要的,因为大多数基于 UNIX 的操作系统都只使用换行; 与 DOS 或 OS/2 或其他操作系统不同,在基于 UNIX 的操作系统中,换行意味着回车符。 虽然这对文本编辑器起作用,但在其他类似的情况下,它不会对打印机起作用。 打印机仅打印发送给它们的数据。 例如,发出两个命令
splp -p+ lp0 cat /etc/motd > /dev/lp0在打印机上产生的输出类似于以下内容。
This is a test version of /etc/motd, used to demonstrate
what happens when a printer device driver, such as
/dev/lp0, is placed into or taken out of passthru mode.
Printers will print either exactly what they are sent,
if you set the job conditions up correctly, or, on the
most current printers, you may be able to direct the
printer to perform certain mappings for you. There are no carriage returns in
this file, and the only blank line occurs
immediately before this one.在第一个示例中,响应了所有设备驱动程序的设置。 尤其是启用了将换行映射为换行和回车。 当设备驱动程序向物理打印机写入字符时,它在每个换行后面发送一个回车。 它也响应页面宽度的设置。
在第二个示例中,设备驱动程序仅限于简单地将 /etc/motd 的每个单字节字符写入物理打印机, 而不对数据流发生任何映射或其他修改。 当 /etc/motd 的第一个句子结束时,换行使打印头直接向下一行; 没有回车符将打印头移回左侧页边距。 打印了单词“printer”的前四个字母 prin。 这时,打印机本身而不是设备驱动程序确定已到达右侧页边距,因此打印了一个回车符,将打印头返回到左侧页边距。 继续打印数据流中的下一个字符。
在第二个示例中,作业甚至没有打印,直到按下打印机上的复位按钮。 这是因为打印机未收到足够的数据(字符)以自动弹出页面,并且没有换页发送到打印机使它弹出页面; 设备驱动程序上的 -f 参数被忽略。