[cups.development] Filter - backend communication example?

Michael Sweet msweet at apple.com
Wed Feb 3 09:05:06 PST 2010


On Feb 2, 2010, at 11:22 PM, Paul Newall wrote:
>> I am working on a filter for the Kodak EPS 5250.
>> I can make the correct data, but printing is unreliable. I suspect that I need to add some bidirectional comms between filter and printer because the windows driver sends  a command several times to the printer before sending the data as if it is waiting for a particular response.
>> 
>> Can anyone point me at an existing filter that uses cupsBackChannelRead() so I can look at the source code?
> 
> 3rd Feb
> I am using the socket backend. I think I need some way to force the backend to send a packet containing a command to the printer before it sends the print data.
> At the moment the command is not sent until a large quantity of print data is ready to send. Then a large packet gets sent.
> Is there a mechanism for telling the backend to send a packet now?

Yes, there are two things you need to do.

First, if you are using the C stdio stuff, do:

    fflush(stdout);

Second, you can use the cupsSideChannel APIs to tell the backend to drain all pending data:

    cups_sc_status_t status;

    status = cupsSideChannelDoRequest(CUPS_SC_CMD_DRAIN_OUTPUT, NULL, NULL, 30.0);

"status" will be CUPS_SC_STATUS_OK if everything worked, CUPS_SC_STATUS_TIMEOUT if the backend did't complete within the time allowed (30 seconds in the code above), CUPS_SC_STATUS_IO_ERROR if the backend couldn't send data to the printer, or CUPS_SC_STATUS_NOT_IMPLEMENTED if the backend does not support the command (all of the standard CUPS backends do...)

You should also read the Filter and Backend Programming Guide, available on your system and on cups.org:

    http://localhost:631/help/api-filter.html
    http://www.cups.org/documentation.php/doc-1.4/api-filter.html

although looking at it we seem to have omitted what I provided above...  Filed CUPS STR #3491 to add it:

    http://www.cups.org/str.php?L3491

Feel free to add your own comments/feedback.

___________________________________________________
Michael Sweet, Senior Printing System Engineer







More information about the cups mailing list