none
Conditions for STATUS_INVALID_DEVICE_REQUEST with WdfIoTargetSendWriteSynchronously() RRS feed

  • Question

  • Hello!

    I'm writing some drivers for a new USB device that is supposed to operate like a standard COM port with our additional functionality. In a previous USB driver, I had been using WdfRequestSend in an asynchronous manner, but in this iteration I'd like to use WdfIoTargetSendWriteSynchronously() instead. However I find that no matter what I do, WdfIoTargetSendWriteSynchronously() is always returning STATUS_INVALID_DEVICE_REQUEST, and I'm not sure why - I've read and re-read the doc and my example but I must be overlooking something. The goal is to write the 'write command' to the register writing endpoint. It always fails, at no time does the this function finish correctly.

    NTSTATUS synccom_port_set_register_uint32(struct asynccom_port *port, unsigned char offset, unsigned char address, UINT32 value)
    {
    WDF_MEMORY_DESCRIPTOR write_descriptor;
    unsigned char write_buffer[7];
    NTSTATUS status;
    WDFUSBPIPE write_pipe;
    PULONG_PTR bytes_written = 0;
    WDF_REQUEST_SEND_OPTIONS write_options;
    
    write_pipe = port->register_write_pipe;
    
    WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&write_descriptor, (PVOID)&write_buffer, sizeof(write_buffer));
    WDF_REQUEST_SEND_OPTIONS_INIT(&write_options, WDF_REQUEST_SEND_OPTION_SYNCHRONOUS);
    
    write_buffer[0] = ASYNCCOM_WRITE_REGISTER;
    write_buffer[1] = offset;
    write_buffer[2] = address << 1;
    // There may be a better way to do this - this seems dangerous.
    memcpy(&write_buffer[3], &value, sizeof(UINT32));
    
    // This is returning 0xC0000010 for some reason.
    status = WdfIoTargetSendWriteSynchronously(WdfUsbTargetPipeGetIoTarget(write_pipe), WDF_NO_HANDLE, &write_descriptor, NULL, &write_options, bytes_written);
    if(!NT_SUCCESS(status)) TraceEvents(TRACE_LEVEL_WARNING, DBG_IOCTL, "%s: Error status: 0x%x.", __FUNCTION__, status);
    
    return status;
    }

    Thanks in advance!


    Thursday, July 14, 2016 2:43 PM

Answers

  • Did the previous driver send IRP_MJ_WRITEs on the USB pip io target? or were your previous iteration WdfRequestSend calls sending requests formatted with WdfUsbTargetPipeFormatRequestForWrite? I would assume it is the latter (FormatForWrite). If that is correct, the synchronous version is WdfUsbTargetPipeWriteSynchronously NOT WdfIoTargetSendWriteSynchronously


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, July 14, 2016 4:33 PM

All replies

  • Did the previous driver send IRP_MJ_WRITEs on the USB pip io target? or were your previous iteration WdfRequestSend calls sending requests formatted with WdfUsbTargetPipeFormatRequestForWrite? I would assume it is the latter (FormatForWrite). If that is correct, the synchronous version is WdfUsbTargetPipeWriteSynchronously NOT WdfIoTargetSendWriteSynchronously


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, July 14, 2016 4:33 PM
  • For future debugging, after the call returns error, set a break point and run

    !wdfkd.wdflogdump <your driver name>

    and make sure you have correct symbols for wdf and your driver. the log dump will tell if you WDF is returning this value or the underlying bus driver.


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, July 14, 2016 4:33 PM
  • Yep. I was using the wrong function. I got so focused on figuring out why WdfIoTargetSendWriteSynchronously() didn't work I didn't realize that I was using the wrong one.

    Thanks. I am filled with a mixture of joy and frustration.

    Thursday, July 14, 2016 4:55 PM