Backchannel usage

Josh Mathis josh.m at swecoinus.com
Mon May 22 11:27:32 PDT 2006


One quick update - I tried this with a USB printer, and the result was 
different. I wrote the same status request and read the same way. The 
read returned -1. However, watching a tail of the error_log, AFTER my 
filter was done, and the read returned -1, I get a debug message from 
the USB backend saying that it received 2 bytes of backchannel data. I 
changed my filter to timeout after 10 seconds on the read, then issue 
another read. The second one comes back correctly, with the right data 
from the printer. I have also tried excessive timeouts like 2 minutes, 
but get the same result - the first read always fails.

So this raises two questions - why does the parallel backend not get 
anything at all back, and why does the USB get the return data too late?

Code as it stands now:
char backbuffer[1024]; //buffer for returned data
printf("\x1b\x05\x06"); //send status request
fflush(stdout);
count = cupsBackChannelRead(backbuffer, 2, 10); //read 2 bytes
fprintf(stderr, "***** Read %i backchannel bytes*****\n", count); //this 
times out and the debug shows -1!

count = cupsBackChannelRead(backbuffer, 2, 10); //read 2 bytes
fprintf(stderr, "***** Read %i backchannel bytes*****\n", count); //the 
debug shows 2!



Josh Mathis wrote:
> Thanks for the reminder. I added that. Unfortunately, I still get the 
> same result. I tried my printer's debug mode where it prints (in hex) 
> all the data sent to it and it seems that the printf is getting to the 
> printer. A separate command line utility shows that the printer is 
> responding to status inquiries correctly, but my backchannel read still 
> returns -1.
> 
> Thanks again.
> -Josh
> 
> Michael Sweet wrote:
>> Josh Mathis wrote:
>>> I am trying to add some simple status support into my filter. Before the
>>> print data of a job is sent, I attempt to send a status request (escape
>>> command) and then read a two-byte response. However, the function
>>> always fails (return -1).
>>>
>>> To do a basic test, I changed the filter to only send a 3-byte status 
>>> request with printf, just like normal print data, then read the 
>>> 2-byte response with cupsBackChannelRead, then exit the job. However, 
>>> the read always times out and returns -1. I have confirmed that the 
>>> printer is receiving the status request, but it seems that the 
>>> backend is not picking up the response.
>>>
>>> Here is what I am doing:
>>>
>>> char backbuffer[1024]; //buffer for returned data
>>> printf("\x1b\x05\x06"); //send status request
>>
>> Add a fflush(stdout) call here, otherwise your printf output will
>> not actually get sent to the printer... :)
>>




More information about the cups-devel mailing list