Repository navigation
printer.device: unit lock, Preferences encoding, PRD_SETJOBINFO - #1966
Open
terminills wants to merge 1 commit into
Open
terminills wants to merge 1 commit into
terminills wants to merge 1 commit into
Conversation
Three fixes found while writing a printer driver against the device.
pd_Close() indexed pb_UnitLock[] with the PDEV unit number from the
prefs file instead of the unit the device was opened on. A printer.prefs
without a PDEV chunk (as written before PDEV existed) left that number,
and the unit name, as uninitialised stack memory in Printer_Unit(), so
closing the device obtained and released a semaphore outside the array
("Semaphore in an illegal state" twice, every time a print finished).
Use pd_UnitNumber, set from the opened unit, and start the prefs from
zero so missing chunks read as empty.
Printer prefs keep pitch, quality, spacing, paper size and paper type as
small numbers (prefs/printertxt.h: PP_ELITE 1, PS_EURO_A4 9, ...), but
struct Preferences, which printer.device fills in for the driver, holds
them in their bit positions (intuition/preferences.h: ELITE 0x400,
EURO_A4 0x90, ...). The values were copied over unconverted, so every
paper size but US Letter reached the driver as something it does not
know, and the PostScript driver refused to open with PDERR_BADDIMENSION
from its PRS_PREINIT. Shift the five fields into place; PostScript and
the skeleton driver compare against the Preferences constants throughout,
as a driver gets them.
A print queue can only show job numbers: nothing tells the output device
which program is printing what. printer.device now takes the opener's
program name when the unit is opened (its CLI command name, else its
task name), and a new command, PRD_SETJOBINFO (CMD_NONSTD + 13), lets an
application name the document (PJIA_Application, PJIA_Document tags).
Both are passed on to the output device with the same command when the
unit opens and whenever they change; output devices that do not know it
ignore it.
The test developer/debug/test/printer/unitlock writes a preferences file
for unit 1 naming device unit 0 and the serial port, opens the unit,
closes it, has a second process open it again, and sends PRD_SETJOBINFO.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: printer.device: unit lock, Preferences encoding, PRD_SETJOBINFO
Three fixes found while writing a printer.device driver (the Gutenprint port):
Test: developer/debug/test/printer/unitlock writes ENV:SYS/printer1.prefs naming device unit 0, opens unit 1, closes it, has a second process open it again (10 s timeout) and sends PRD_SETJOBINFO; the unit uses the serial port so it runs on any machine. pc-x86_64 in QEMU on master 9802c8c:
PASS: opened printer.device unit 1,PASS: a second task could open unit 1 after it was closed,PASS: PRD_SETJOBINFO accepted,UNITLOCK PASS.