From: Garet Cammer on
Hi everyone,
We are trying to send vendor-specific data to an ATAPI device we have
designed, using the WRITE BUFFER command (SCSI op code 0x3B) through an
application running under WIN 2000. The function uses the
IOCTL_SCSI_PASS_THROUGH_DIRECT, just like the spti.c example in the MSDN
library.
The protocol is working but the only data we get is the CDB[] array repeated
over and over, not the data buffer specified in sptdwb.sptd.DataBuffer.
Can anyone suggest what is wrong, or where to look for a solution?

Thanks in advance,

Garet


From: Gary G. Little on
Given that you are on 2000 and using an off the shelf HBA and driver, does
the driver support the command in SPTI? Since it's an ATAPI device it does
seem to me you should be using the ATA command defined by the T13 committee
and not the SCSI command defined by the T10 committee. The question then
come up as to how you are mapping the CDB to the TFR.

--
The personal opinion of
Gary G. Little

"Garet Cammer" <gcammer(a)arcoide.com> wrote in message
news:u2Q2OrMWGHA.1352(a)TK2MSFTNGP05.phx.gbl...
> Hi everyone,
> We are trying to send vendor-specific data to an ATAPI device we have
> designed, using the WRITE BUFFER command (SCSI op code 0x3B) through an
> application running under WIN 2000. The function uses the
> IOCTL_SCSI_PASS_THROUGH_DIRECT, just like the spti.c example in the MSDN
> library.
> The protocol is working but the only data we get is the CDB[] array
> repeated over and over, not the data buffer specified in
> sptdwb.sptd.DataBuffer.
> Can anyone suggest what is wrong, or where to look for a solution?
>
> Thanks in advance,
>
> Garet
>


From: Garet Cammer on
Thanks for the ideas, Gary.
Our product is identified as a removable media storage device, similar to a
CDROM, and does support the "Packet" commands, which are generated through
the SCSI_PASS_THROUGH_DIRECT ioctl. This works fine with other commands,
including the "READ BUFFER" (op code 0x3C), so it seems to me that either we
are not mapping the CDB array correctly, or one of the Windows drivers is
not performing as expected...
Regards,
Garet

"Gary G. Little" <gary.g.little(a)seagate.com> wrote in message
news:44342058$0$15443$6d36acad(a)taz.nntpserver.com...
> Given that you are on 2000 and using an off the shelf HBA and driver, does
> the driver support the command in SPTI? Since it's an ATAPI device it does
> seem to me you should be using the ATA command defined by the T13
> committee and not the SCSI command defined by the T10 committee. The
> question then come up as to how you are mapping the CDB to the TFR.
>
> --
> The personal opinion of
> Gary G. Little
>
> "Garet Cammer" <gcammer(a)arcoide.com> wrote in message
> news:u2Q2OrMWGHA.1352(a)TK2MSFTNGP05.phx.gbl...
>> Hi everyone,
>> We are trying to send vendor-specific data to an ATAPI device we have
>> designed, using the WRITE BUFFER command (SCSI op code 0x3B) through an
>> application running under WIN 2000. The function uses the
>> IOCTL_SCSI_PASS_THROUGH_DIRECT, just like the spti.c example in the MSDN
>> library.
>> The protocol is working but the only data we get is the CDB[] array
>> repeated over and over, not the data buffer specified in
>> sptdwb.sptd.DataBuffer.
>> Can anyone suggest what is wrong, or where to look for a solution?
>>
>> Thanks in advance,
>>
>> Garet
>>
>
>


From: Valeriy Glushkov on
Garet,

There is a chance that some CD-ROM filter driver does not support forwarding
of this particular SCSI opcode.
Have you tried use some other kind of SCSI write command (like WRITE 0x2A,
etc) ?

--
Best regards,
Valeriy Glushkov

"Garet Cammer" <gcammer(a)arcoide.com> wrote in message
news:%23ZmHjQPWGHA.2376(a)TK2MSFTNGP03.phx.gbl...
> Thanks for the ideas, Gary.
> Our product is identified as a removable media storage device, similar to
> a CDROM, and does support the "Packet" commands, which are generated
> through the SCSI_PASS_THROUGH_DIRECT ioctl. This works fine with other
> commands, including the "READ BUFFER" (op code 0x3C), so it seems to me
> that either we are not mapping the CDB array correctly, or one of the
> Windows drivers is not performing as expected...
> Regards,
> Garet
>
> "Gary G. Little" <gary.g.little(a)seagate.com> wrote in message
> news:44342058$0$15443$6d36acad(a)taz.nntpserver.com...
>> Given that you are on 2000 and using an off the shelf HBA and driver,
>> does the driver support the command in SPTI? Since it's an ATAPI device
>> it does seem to me you should be using the ATA command defined by the T13
>> committee and not the SCSI command defined by the T10 committee. The
>> question then come up as to how you are mapping the CDB to the TFR.
>>
>> --
>> The personal opinion of
>> Gary G. Little
>>
>> "Garet Cammer" <gcammer(a)arcoide.com> wrote in message
>> news:u2Q2OrMWGHA.1352(a)TK2MSFTNGP05.phx.gbl...
>>> Hi everyone,
>>> We are trying to send vendor-specific data to an ATAPI device we have
>>> designed, using the WRITE BUFFER command (SCSI op code 0x3B) through an
>>> application running under WIN 2000. The function uses the
>>> IOCTL_SCSI_PASS_THROUGH_DIRECT, just like the spti.c example in the MSDN
>>> library.
>>> The protocol is working but the only data we get is the CDB[] array
>>> repeated over and over, not the data buffer specified in
>>> sptdwb.sptd.DataBuffer.
>>> Can anyone suggest what is wrong, or where to look for a solution?
>>>
>>> Thanks in advance,
>>>
>>> Garet
>>>
>>
>>
>
>


From: Garet Cammer on
Hello Valeriy,
I tried using WRITE (op code 0x2A) as you suggested, and it works fine. I
used the same code, except for the command specific CDBs.
here is the code:

This is the Write Buffer command that does not work (repetes the CDB array
over and over):
---------------------------------------------------------------------------------------------

DUPLIWIN_API int VBDEF WriteBuffetTest(char DrvLtr)
{
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
BOOL status;
ULONG length, returned;
int i;
HANDLE hDevice = INVALID_HANDLE_VALUE;
UCHAR dataBuffer[1024];

hDevice = GetHandleFromVolume(DrvLtr);
if (hDevice == INVALID_HANDLE_VALUE)
{
return 2;//error
}
ZeroMemory(&sptdwb, sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
ZeroMemory(dataBuffer, 1024);

//create buffer file
for (i=0;i<1024;i++)
dataBuffer[i] = i % 256;

sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_OUT; // writing to drive
sptdwb.sptd.PathId = 0;
sptdwb.sptd.TargetId = 1;
sptdwb.sptd.Lun = 0;
sptdwb.sptd.CdbLength = CDB10GENERIC_LENGTH;
sptdwb.sptd.DataTransferLength = 1024;
sptdwb.sptd.TimeOutValue = 5000; // in milliseconds
sptdwb.sptd.DataBuffer = dataBuffer;

sptdwb.sptd.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,ucSenseBuf);
sptdwb.sptd.SenseInfoLength = sizeof(sptdwb.ucSenseBuf);

sptdwb.sptd.Cdb[0] = SCSIOP_WRITE_DATA_BUFF; //op code 0x3B
sptdwb.sptd.Cdb[1] = 0x02; //
sptdwb.sptd.Cdb[2] = 0x00;
sptdwb.sptd.Cdb[3] = 0x00;
sptdwb.sptd.Cdb[4] = 0x00;
sptdwb.sptd.Cdb[5] = 0x00;
sptdwb.sptd.Cdb[6] = 0x00;
sptdwb.sptd.Cdb[7] = 0x04; //0x400 bytes
sptdwb.sptd.Cdb[8] = 0x00;

length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
status = DeviceIoControl(hDevice, // device handle
IOCTL_SCSI_PASS_THROUGH_DIRECT, // control code
&sptdwb, // input query
length, // size of input
&sptdwb, // output
length, // size of output
&returned, // num bytes urned
NULL); // overlapped (async) IO struct

if (status == FALSE)
{
printf("WRITE bUFFER - failed with error %d\n", GetLastError());
return FAILURE;
}
else
for (i=0;i<1024;i++)
GDataBuffer[i] = dataBuffer[i]; //copy to global
return SUCCESS;
}


This is the Write (Data) command that works fine:
--------------------------------------------------

DUPLIWIN_API int VBDEF ModeSelect(char DrvLtr)//really WRITE BUFFER
{
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
BOOL status;
ULONG length, returned;
int i;
HANDLE hDevice = INVALID_HANDLE_VALUE;
UCHAR dataBuffer[1024];
ULONGLONG start_lba;
ULONG num_sectors;

start_lba = 195312500; //just free space on disk
num_sectors = 2; //1kb
hDevice = GetHandleFromVolume(DrvLtr);
if (hDevice == INVALID_HANDLE_VALUE)
{
return 2;//error
}
ZeroMemory(&sptdwb, sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
ZeroMemory(dataBuffer, 1024);

for (i=0;i<1024;i++)
dataBuffer[i] = i % 256;

sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_OUT; // writing to drive
sptdwb.sptd.PathId = 0;
sptdwb.sptd.TargetId = 1;
sptdwb.sptd.Lun = 0;
sptdwb.sptd.CdbLength = CDB10GENERIC_LENGTH;
sptdwb.sptd.DataTransferLength = 1024;
sptdwb.sptd.TimeOutValue = 5000; // in milliseconds
sptdwb.sptd.DataBuffer = dataBuffer;

sptdwb.sptd.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,ucSenseBuf);
sptdwb.sptd.SenseInfoLength = sizeof(sptdwb.ucSenseBuf); // 24?

sptdwb.sptd.Cdb[0] = SCSIOP_WRITE; //opcode 0x2A
sptdwb.sptd.Cdb[1] = 0x00; sptdwb.sptd.Cdb[2] =
(UCHAR)(start_lba >> 24) & 0xFF; // MSB of lba
sptdwb.sptd.Cdb[3] = (UCHAR)(start_lba >> 16) & 0xFF;
sptdwb.sptd.Cdb[4] = (UCHAR)(start_lba >> 8) & 0xFF;
sptdwb.sptd.Cdb[5] = (UCHAR)(start_lba) & 0xFF; // LSB of lba
sptdwb.sptd.Cdb[6] = 0x00; sptdwb.sptd.Cdb[7] =
(UCHAR)(num_sectors >> 8) & 0xFF; // MSB of num blocks
sptdwb.sptd.Cdb[8] = (UCHAR)(num_sectors) & 0xFF; // LSB of num blocks
sptdwb.sptd.Cdb[9] = 0x00;

length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
status = DeviceIoControl(hDevice, // device handle
IOCTL_SCSI_PASS_THROUGH_DIRECT, // control code
&sptdwb, // input query
length, // size of input
&sptdwb, // output
length, // size of output
&returned, // num bytes returned
NULL); // overlapped (async) IO struct

if (status == FALSE)
{
printf("Write Data - failed with error %d\n", GetLastError());
return FAILURE;
}
else
for (i=0;i<1024;i++)
GDataBuffer[i] = dataBuffer[i];//copy to global
return SUCCESS;
}

"Valeriy Glushkov" <gvvua(a)NO-SPAMua.fm> wrote in message
news:uOx2gvPWGHA.4212(a)TK2MSFTNGP03.phx.gbl...
> Garet,
>
> There is a chance that some CD-ROM filter driver does not support
> forwarding of this particular SCSI opcode.
> Have you tried use some other kind of SCSI write command (like WRITE
> 0x2A, etc) ?
>
> --
> Best regards,
> Valeriy Glushkov
>
> "Garet Cammer" <gcammer(a)arcoide.com> wrote in message
> news:%23ZmHjQPWGHA.2376(a)TK2MSFTNGP03.phx.gbl...
>> Thanks for the ideas, Gary.
>> Our product is identified as a removable media storage device, similar to
>> a CDROM, and does support the "Packet" commands, which are generated
>> through the SCSI_PASS_THROUGH_DIRECT ioctl. This works fine with other
>> commands, including the "READ BUFFER" (op code 0x3C), so it seems to me
>> that either we are not mapping the CDB array correctly, or one of the
>> Windows drivers is not performing as expected...
>> Regards,
>> Garet
>>
>> "Gary G. Little" <gary.g.little(a)seagate.com> wrote in message
>> news:44342058$0$15443$6d36acad(a)taz.nntpserver.com...
>>> Given that you are on 2000 and using an off the shelf HBA and driver,
>>> does the driver support the command in SPTI? Since it's an ATAPI device
>>> it does seem to me you should be using the ATA command defined by the
>>> T13 committee and not the SCSI command defined by the T10 committee. The
>>> question then come up as to how you are mapping the CDB to the TFR.
>>>
>>> --
>>> The personal opinion of
>>> Gary G. Little
>>>
>>> "Garet Cammer" <gcammer(a)arcoide.com> wrote in message
>>> news:u2Q2OrMWGHA.1352(a)TK2MSFTNGP05.phx.gbl...
>>>> Hi everyone,
>>>> We are trying to send vendor-specific data to an ATAPI device we have
>>>> designed, using the WRITE BUFFER command (SCSI op code 0x3B) through an
>>>> application running under WIN 2000. The function uses the
>>>> IOCTL_SCSI_PASS_THROUGH_DIRECT, just like the spti.c example in the
>>>> MSDN library.
>>>> The protocol is working but the only data we get is the CDB[] array
>>>> repeated over and over, not the data buffer specified in
>>>> sptdwb.sptd.DataBuffer.
>>>> Can anyone suggest what is wrong, or where to look for a solution?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Garet
>>>>
>>>
>>>
>>
>>
>
>