[cups.general] How to send jobs to a SCSI printer with cups?
Mike Fedyk
mfedyk at matchmail.com
Fri Sep 10 20:03:23 PDT 2004
Mike Fedyk wrote:
> Mike Fedyk wrote:
>
>> Mike Fedyk wrote:
>>
>>> Is this right?
>>>
>>> In scsi-linux.c at line 185:
>>>
>>> scsi_cmd[0] = 0x0a; /* Group 0 print command */
>>> scsi_cmd[1] = 0x00;
>>> scsi_cmd[2] = bytes / 65536;
>>> scsi_cmd[3] = bytes / 256;
>>> scsi_cmd[4] = bytes;
>>> scsi_cmd[5] = 0x00;
>>>
>>> According to [1], the format should be
>>>
>>> Operation code (0Ah)
>>> LUN
>>> MSB
>>> Transfer Length
>>> LSB
>>> Control
>>>
>>> I don't know if the linux scsi stack changes the orders of the
>>> fields though...
>>>
>>> [1]
>>> http://www.danbbs.dk/~dino/SCSI/SCSI2-11.html
>>>
>> Here's a patch:
>> --- scsi-linux.c.orig 2004-09-10 16:14:08.000000000 -0700
>> +++ scsi-linux.c 2004-09-10 16:17:20.000000000 -0700
>> @@ -185,8 +185,8 @@
>> scsi_cmd[0] = 0x0a; /* Group 0 print command */
>> scsi_cmd[1] = 0x00;
>> scsi_cmd[2] = bytes / 65536;
>> - scsi_cmd[3] = bytes / 256;
>> - scsi_cmd[4] = bytes;
>> + scsi_cmd[3] = bytes;
>> + scsi_cmd[4] = bytes / 256;
>> scsi_cmd[5] = 0x00;
>>
>> for (try = 0; try < 10; try ++)
>>
>> ------------------------------------------------------------------------
>>
>> --- scsi-linux.c.orig 2004-09-10 16:14:08.000000000 -0700
>> +++ scsi-linux.c 2004-09-10 16:17:20.000000000 -0700
>> @@ -185,8 +185,8 @@
>> scsi_cmd[0] = 0x0a; /* Group 0 print command */
>> scsi_cmd[1] = 0x00;
>> scsi_cmd[2] = bytes / 65536;
>> - scsi_cmd[3] = bytes / 256;
>> - scsi_cmd[4] = bytes;
>> + scsi_cmd[3] = bytes;
>> + scsi_cmd[4] = bytes / 256;
>> scsi_cmd[5] = 0x00;
>>
>> for (try = 0; try < 10; try ++)
>>
>>
> Well, if I did find a bug, it looks like this is the proper fix even
> though the buffer size is only 8k bytes...
>
> --- scsi-linux.c.orig 2004-09-10 16:14:08.000000000 -0700
> +++ scsi-linux.c 2004-09-10 19:02:47.000000000 -0700
> @@ -184,9 +184,9 @@
>
> scsi_cmd[0] = 0x0a; /* Group 0 print command */
> scsi_cmd[1] = 0x00;
> - scsi_cmd[2] = bytes / 65536;
> - scsi_cmd[3] = bytes / 256;
> - scsi_cmd[4] = bytes;
> + scsi_cmd[3] = bytes / 16777216; /* High 8 bit value of
> Transfer Lenght */
> + scsi_cmd[2] = bytes / 65536; /* Middle 8 bit value of
> Transfer Lenght */
> + scsi_cmd[4] = bytes / 256; /* Low 8 bit value of Transfer
> Lenght */
> scsi_cmd[5] = 0x00;
>
> for (try = 0; try < 10; try ++)
>
>------------------------------------------------------------------------
>
>--- scsi-linux.c.orig 2004-09-10 16:14:08.000000000 -0700
>+++ scsi-linux.c 2004-09-10 19:02:47.000000000 -0700
>@@ -184,9 +184,9 @@
>
> scsi_cmd[0] = 0x0a; /* Group 0 print command */
> scsi_cmd[1] = 0x00;
>- scsi_cmd[2] = bytes / 65536;
>- scsi_cmd[3] = bytes / 256;
>- scsi_cmd[4] = bytes;
>+ scsi_cmd[3] = bytes / 16777216; /* High 8 bit value of Transfer Lenght */
>+ scsi_cmd[2] = bytes / 65536; /* Middle 8 bit value of Transfer Lenght */
>+ scsi_cmd[4] = bytes / 256; /* Low 8 bit value of Transfer Lenght */
> scsi_cmd[5] = 0x00;
>
> for (try = 0; try < 10; try ++)
>
>
I knew something didn't feel right about that patch.
--- scsi-linux.c.orig 2004-09-10 16:14:08.000000000 -0700
+++ scsi-linux.c 2004-09-10 19:48:16.000000000 -0700
@@ -184,9 +184,9 @@
scsi_cmd[0] = 0x0a; /* Group 0 print command */
scsi_cmd[1] = 0x00;
- scsi_cmd[2] = bytes / 65536;
- scsi_cmd[3] = bytes / 256;
- scsi_cmd[4] = bytes;
+ scsi_cmd[3] = min(bytes / 65536, 256); /* High 8 bit value of
Transfer Lenght */
+ scsi_cmd[2] = min(bytes / 256, 256); /* Middle 8 bit value of
Transfer Lenght */
+ scsi_cmd[4] = min(bytes, 256); /* Low 8 bit value of
Transfer Lenght */
scsi_cmd[5] = 0x00;
for (try = 0; try < 10; try ++)
Since scsi_cmd is of type char, do I need the min() calls there, or will
the values just be truncated to one char when you call a char as an array?
If you write an int to scsi_cmd[4] won't that write 4 or 8 bytes and
thus overflow your char variable?
Will min() write only 1 byte to a char if the value of an int is <= 256?
What file do I need to include for the min() function?
Yes, I'm new to C. Can you tell? ;)
Mike
More information about the cups
mailing list