[cups.development] How are the command filters supposed to return data?

Reinhold Kainhofer reinhold at kainhofer.com
Fri Aug 20 08:33:26 PDT 2010


Am Freitag, 20. August 2010, um 14:45:52 schrieben Sie:
> On Wed, 2010-07-14 at 01:43 +0200, Reinhold Kainhofer wrote:
> > To get the response of the printer, I have to call cupsBackChannelRead,
> > right? Is the data written by the command filter sent to the printer
> > immediately by the backend, or do I need to select some non-zero
> > timeout?
> 
> I would have thought it would be sent directly to the printer if
> possible, although I don't see anything in the documentation requiring
> this explicitly. (IMHO it ought to be required...)

Actually, no. You have to do a cupsSideChannelDoRequest to send the data to 
the printer. After that, one can do a cupsBackChannelRead...
In particular, I have now finished the ReportLevels target for my magicolor 
1690MF. The core commands are:

    pwrite("\033%-12345X at PJL INFO DSTATUS\015\012", 28);
    pwrite("\033%-12345X", 9);
    fflush(stdout);

    // RER: 07/20/10 - Sleep for a bit!
    sleep(5);

    // Ask the backend to send all data NOW:
    datalen = 0;
    cupsSideChannelDoRequest(CUPS_SC_CMD_DRAIN_OUTPUT, buffer, &datalen, 5.0);

    // Read back the data from the printer
    bytes = cupsBackChannelRead(buffer, sizeof(buffer) - 1, 5.0);
    buffer[bytes] = '\0';

Now, bytes contains the response by the printer, which must then be propertly 
parsed by the filter... 
See the file command2foo2lava-pjl.c in the latest foo2zjs driver package...

> Even so, you may still need a non-zero timeout -- the printer may be
> busy and unable to respond at the time

Yes, I decided to use 5.0, which is used by some other filters, too.

Cheers,
Reinhold


-- 
------------------------------------------------------------------
Reinhold Kainhofer, reinhold at kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org





More information about the cups-devel mailing list