SPTI Get Event Status Notification returning bad info!

vbimport

#1

Hi! I’ve been banging my head against a wall for a several hours and would appreciate any help/advice!!

I wrote a simple piece of XP ASPI code that sends a Get Event Status Notification command to a drive to get the media status. I’m sending “4a 1 0 0 10 0 0 0 8 0” and getting back correct information, “00 06 04 56 00 02 00 00” (meaning the tray is open!). So far so good…

Now, I want to change this to use SPTI, I’m sending the same command but instead get back “00 06 04 56 00 00 00 00”, meaning tray is closed and no media is present.

Whatever I do with the tray, whether it be closed/opened/empty/full, the SPTI function gets back the same four 0s. I’m sure the code is good and is receiving responses since the received Get Event Status Notification header is correctly constructed.

At this point, ASPI is still returning good info! I’ve removed the ASPI drivers in case they were interfering but still the same…

Is something (OS or drive) caching information? Is SPTI flawed? Am I being daft!?

Any help would be greatly appreciated!!!

C


#2

From what I am reading in the MMC 5r03C spec, an event code of 02 does not indicate tray open. This byte indicates if new media has been put in the drive and is ready for access. Have you tried changing the disc and closing the tray?

Hope this might help.

RM


#3

I confirm SPTI works properly with Get Event Status Notification on XP. Btw, 01 means tray is open if I remember correctly.

I have a source code that send this same command and have tried it on a Plextor 755A, which works perfectly on XP and Vista. :slight_smile:

Perhaps you’re setting up the SPTI or CDB structure transfer len too short, or the drive doesn’t actually support the command, and ASPI is just giving dirty bytes after the header.

Would help if you can post a snippet of that code here (the SPTI structure part).

Here’s my snippet:

//SCSI-3 send event status notification command.
BOOL send_event_status_notif(HANDLE hVolume)
{
    DWORD dwBytesReturned;

    sptd_sb.sptd.Length=sizeof(SCSI_PASS_THROUGH_DIRECT);
    sptd_sb.sptd.PathId=0;    //SCSI card ID will be filled in automatically.
    sptd_sb.sptd.TargetId=0;  //SCSI target ID will also be filled in.
    sptd_sb.sptd.Lun=0;       //SCSI lun ID will also be filled in.
    sptd_sb.sptd.CdbLength=10;  //CDB size is 10 for GET EVENT/STATUS NOTIFICATION MMC2 command.
    sptd_sb.sptd.SenseInfoLength=MAX_SENSE_LEN;  //Return sense buffer length.
    sptd_sb.sptd.DataIn=SCSI_IOCTL_DATA_IN;  //There will be data from drive.
    sptd_sb.sptd.DataTransferLength=8;  //Size of output data from drive.
    sptd_sb.sptd.TimeOutValue=108000;  //SCSI timeout value (max 108000 sec = time 30 min).
    sptd_sb.sptd.DataBuffer=(PVOID)&(DataBuf);
    sptd_sb.sptd.SenseInfoOffset=sizeof(SCSI_PASS_THROUGH_DIRECT);

    //CDB with values for GET EVENT/STATUS NOTIFICATION CDB10 command.
    //The values were taken from MMC2 draft paper.
    sptd_sb.sptd.Cdb[0]=0x4A;  //Code for GET EVENT/STATUS NOTIFICATION command.
    sptd_sb.sptd.Cdb[1]=1;  //Immediate.
    sptd_sb.sptd.Cdb[2]=0;
    sptd_sb.sptd.Cdb[3]=0;
    sptd_sb.sptd.Cdb[4]=0x10;  //Media Status Class Events.
    sptd_sb.sptd.Cdb[5]=0;
    sptd_sb.sptd.Cdb[6]=0;
    sptd_sb.sptd.Cdb[7]=0;
    sptd_sb.sptd.Cdb[8]=8;  //LSB of max length of bytes to receive.
    sptd_sb.sptd.Cdb[9]=0;
    sptd_sb.sptd.Cdb[10]=0;
    sptd_sb.sptd.Cdb[11]=0;
    sptd_sb.sptd.Cdb[12]=0;
    sptd_sb.sptd.Cdb[13]=0;
    sptd_sb.sptd.Cdb[14]=0;
    sptd_sb.sptd.Cdb[15]=0;

    ZeroMemory(DataBuf, 8);
    ZeroMemory(sptd_sb.SenseBuf, MAX_SENSE_LEN);

    //Send the command to drive.
    return DeviceIoControl(hVolume,
                           IOCTL_SCSI_PASS_THROUGH_DIRECT,
                           (PVOID)&sptd_sb, (DWORD)sizeof(sptd_sb),
                           (PVOID)&sptd_sb, (DWORD)sizeof(sptd_sb),
                           &dwBytesReturned,
                           NULL);
}

#4

Thank you both for your replies! I tried Truman’s code (many thanks for that) and it worked a treat… Which then annoyed me as it looked the same as mine!!!

So becoming curious as to why mine didn’t work so a bit of poking around and I’ve just realised that Truman was right, I was setting the data length too short, only for the header - which is why that was always filled correctly out but the status info wasn’t!!

Mmmm so I’m now standing in the corner with my hands on head!

Thanks for your help - excellent forum as always!! :slight_smile: