Trying to get status via cupsBackChannelRead does not work with this code.
Johan Henselmans
johan at netsense.nl
Mon Feb 6 12:53:25 PST 2012
I am having problems trying to get the status from the printer I am writing a filter for.
The code I am using is:
status = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_BIDI, &data, &datalen, 5.0);
// Read the response if the output was sent
if (status == CUPS_SC_STATUS_OK & datalen==1){
bidi=(cups_sc_bidi_t)data;
// drain the pending output
status = cupsSideChannelDoRequest(CUPS_SC_CMD_DRAIN_OUTPUT, &data, &datalen, 5.0);
fprintf(stdout, " <S2>"); //send status request, returns seven digit ticket count and prom version
fflush(stdout);
count = cupsBackChannelRead(backbuffer, sizeof(backbuffer), 0.0);
fprintf(stderr, "DEBUG: ***** backbuf Read %i backchannel bytes in Setup*****\n", count);
if (count > 0){
fprintf(stderr, "DEBUG: ***** backbuffer: [");
int i = 0;
while (i < count){
fprintf(stderr, "%c", backbuffer[i]);
i++;
}
fprintf(stderr, "] *****\n");
}
fflush(stderr);
}
This should return 23 bytes of data. The result is that I do not get 23 bytes of data, but -1, and after that I get a
bunch of messages that some data is received. It seems that the cupsBackChannelRead is not waiting long enough for the
answer. I varied with different settings for the time-out, from 20.0 to 0.0 to -1.0 as per
http://www.cups.org/documentation.php/api-filter.html#cupsBackChannelRead
But the results are not what I would expect, sometimes I get 1 bytes, sometimes -1 bytes, sometime I get the full 23
bytes. Is there something that I am missing here?
D [06/Feb/2012:20:59:09 +0100] [Job 1786] ***** backbuf Read -1 backchannel bytes in Setup*****
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 2 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
D [06/Feb/2012:20:59:09 +0100] [Job 1786] Read 1 bytes of back-channel data...
--
Kind Regards,
Johan Henselmans
More information about the cups
mailing list