I have a server on which I have several serial printers set up as raw queues in cups. On each of these, I have installed interfaces scripts to perform some simple output manipulation and to handle IPC with an application that runs on the server and likes to attach directly to printers and write to them, which doesn't jive well with cups thinking that he is exclusively in control of the printer devices. Everything there appears to be working.
Enter another application on the server that, while it does go through cups (after spooling through its own print spooler), appears to be injecting printer-specific escape codes into the files it prints out. In other words, the print produced by this application is not simply a stream of plain text characters, but it contains binary control codes that the printer is meant to interpret.
The problem that I am encountering is that cups appears to be bypassing my interfaces when it receives such files from this second application. I tested this by setting up two nearly identical print files. The first contained the plain text "Hello, world!" followed by a newline character; the second contained some escape codes for one of the printers followed by the "Hello, world!" and newline. I then added a "sleep 5" line to my printer's interface so that there would be a noticeable delay when printing.
When I printed the first file using lp, nothing happened for five seconds, after which the printer came to life and wrote out "Hello, world!" However, when I printed the second file using the exact same lp
command, it immediately printed "Hello, world!" without sleeping. I have also noted that I can use the "-o raw
" option in lp
to force the same behavior with the first file (immediately printing it out without the five-second delay).
My guess is that cups is looking at the actual data being printed and trying to determine its type and, when it sees printer escape codes in the data, it decides that this is "raw" print and bypasses the interface. This is not the behavior that I expected since I set the printer up as a "raw" queue in the first place and assumed this meant that cups would just pass anything sent to it through the interface; nevertheless, this is the behavior that I am seeing.
My question is: Is there a way to send an option to cups (other than -o raw
, which appears to bypass the interface as well) telling him not to detect the type of the print data received and to go ahead and send it to the interface script? Alternatively, is there a way to specify the format of the incoming data (e.g., tell cups that what it is receiving is "plain text" even though it contains escape codes) such that cups will not look at it and simply pass it to the interface?