none
DeviceIOControl function (for IOCTL_SCSI_PASS_THROUGH) returns error '1117' - ERROR_IO_DEVICE RRS feed

  • Question

  • Question

    Hi,

    I am doing read-write operation on my device via SCSI communication(using SCSI card to communicate).

    Suddenly, in between reading\writing operation I get error 1117 from DeviceIOControl() function. This is while reading data from device. I am using the code as mentioned below:

    Can anyone suggest what could be the cause of this error.

    I am using Windows 7 64 bit machine.

    Declarations:

    SCSI_DATA_TRANSFER_LENGTH = 0x05EC
    PSCSI_PASS_THROUGH_WITH_BUFFERS m_sptWithBuffer;

    // SCSI_PASS_THROUGH_WITH_BUFFERS and SCSI_PASS_THROUGH are structures as defined below:

    typedef struct {
    SCSI_PASS_THROUGH spt;
    ULONG Filler;
    UCHAR ucSenseBuf[32];
    UCHAR ucDataBuf[1516]; // 1516=0x05EC
    } SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS;

    typedef struct {
    USHORT Length;
    UCHAR  ScsiStatus;
    UCHAR  PathId;
    UCHAR  TargetId;
    UCHAR  Lun;
    UCHAR  CdbLength;
    UCHAR  SenseInfoLength;
    UCHAR  DataIn;
    ULONG  DataTransferLength;
    ULONG  TimeOutValue;
    ULONG  DataBufferOffset;
    ULONG  SenseInfoOffset;
    UCHAR  Cdb[16];
    } SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;

    Defination:

        HANDLE hPort =m_hPortHandle;
        DWORD returned =0;
        DWORD length = 0;
        BOOL status;

        m_sptWithBuffer->spt.Cdb[0] = 0x08; // 0x08 - Cdb[0]: Receive command code
        m_sptWithBuffer->spt.Cdb[1] = 0x0;
        m_sptWithBuffer->spt.Cdb[2] = 0x0;
        m_sptWithBuffer->spt.Cdb[3] = 0x05; // These two bytes are copied from OPC90.
                                                                   // This is the amount of returned bytes
        m_sptWithBuffer->spt.Cdb[4] = 0xEC; //These two bytes are copied from OPC90.
        m_sptWithBuffer->spt.Cdb[5] = 0x0;

        m_sptWithBuffer->spt.CdbLength = 6; //sizeof(m_sptWithBuffer->spt.Cdb);

       memset((void*)m_sptWithBuffer->ucDataBuf, 0, SCSI_DATA_TRANSFER_LENGTH);
        m_sptWithBuffer->spt.DataIn = SCSI_IOCTL_DATA_IN; // SCSI_IOCTL_DATA_IN = 1

        m_sptWithBuffer->spt.DataTransferLength = SCSI_DATA_TRANSFER_LENGTH;
        length = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,ucDataBuf)
            + m_sptWithBuffer->spt.DataTransferLength;

        status = DeviceIoControl(hPort,
                                    IOCTL_SCSI_PASS_THROUGH,
                                    m_sptWithBuffer, //(LPVOID)
                                    sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS),
                                    m_sptWithBuffer, //(LPVOID)
                                    length,
                                    &dwReturned,
                                    NULL);

    I am getting status as '1117' (ERROR_IO_DEVICE).

    ERROR_IO_DEVICE
    1117 (0x45D)

    The request could not be performed because of an I/O device error.


    Shubhi Gogna

    Wednesday, August 6, 2014 11:00 AM

Answers

  • Did you set up the rest of spt fields like Length, DataBufferOffset, SenseInfoOffset? Also in the DeviceIoControl call the input / output buffer length is incorrect. Check http://msdn.microsoft.com/en-us/library/windows/hardware/ff560519%28v=vs.85%29.aspx for details.

    Wednesday, August 6, 2014 6:09 PM