Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


UMDF2 serial port driver

Hellow everyone! I'm new to develop UART driver with UMDF2. And i met a problem.
While I get the IOCTL_SERIAL_SET_BAUD_RATE message , i can't find any way to deal with it.

As shown below,it always return STATUS_WAIT_1

WDF_USB_CONTROL_SETUP_PACKET_INIT_CLASS(
&setupPacket,
BMREQUEST_HOST_TO_DEVICE,
BMREQUEST_TO_INTERFACE,
0x21,
1,
0);

//Init memory
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memoryDescriptor, (PVOID)&modemInfo, sizeof(MODEM_INFO));

// setup the send option
WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT);
WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&sendOptions, DEFAULT_CONTROL_TRANSFER_TIMEOUT);

status = WdfUsbTargetDeviceSendControlTransferSynchronously(
    pDeviceContext->UsbDevice,
    WDF_NO_HANDLE,
    &sendOptions,
    &setupPacket,
    &memoryDescriptor,
    NULL);

In which way i can pass the message to the usb stack?

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,698

    0x21 is GET_LINE_CODING. Were you actually trying to fetch the parameters or set them? SET_LINE_CODING is 0x20.

    You're setting wValue to 1. wValue must be 0 for these requests. Is your CDC interface #0? That's what goes in wIndex.

    What does MODEM_INFO look like? It needs to be 7 bytes.

    GET_LINE_CODING and SET_LINE_CODING are optional in a CDC device. Are you quite sure your device supports them? The Abstract Control Management descriptor has capability bits that tell you whether they are supported.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • @Tim_Roberts said:
    0x21 is GET_LINE_CODING. Were you actually trying to fetch the parameters or set them? SET_LINE_CODING is 0x20.

    You're setting wValue to 1. wValue must be 0 for these requests. Is your CDC interface #0? That's what goes in wIndex.

    What does MODEM_INFO look like? It needs to be 7 bytes.

    GET_LINE_CODING and SET_LINE_CODING are optional in a CDC device. Are you quite sure your device supports them? The Abstract Control Management descriptor has capability bits that tell you whether they are supported.

    Thank you very much for your answer!
    First, I am going to get the line coding before setting it.

    And the "MODEM_INFO" shown as below.

    pragma pack(push, 1)

    typedef struct _MODEM_INFO
    {
    ULONG ulDteRate;
    UCHAR ucStopBit;
    UCHAR ucParityType;
    UCHAR ucDataBits;
    } MODEM_INFO, *PMODEM_INFO;

    pragma pack(pop)

    GET_LINE_CODING and SET_LINE_CODING are all supported and I have implemented them in my driver with WDM.
    I have set the "wValue " to 0, and request to "SET_LINE_CODING ".
    But with WDF(UMDF/KMDF), the request always returns STATUS_UNSUCCESSFUL.
    I am finding the reason...

    Any way,it is my pleasure to get your help!

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,698

    ... the request always returns STATUS_UNSUCCESSFUL.

    You said it returned STATUS_WAIT_1.

    Did you pattern your driver after a sample, or start from scratch?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • @Tim_Roberts said:

    ... the request always returns STATUS_UNSUCCESSFUL.

    You said it returned STATUS_WAIT_1.

    Did you pattern your driver after a sample, or start from scratch?

    According to your suggestion, I modified the "wValue" and "RequestType" and the result changed to STATUS_UNSUCCESSFUL.
    Maybe my device doesn't support SET_LINE_CODING function, I think you are right. I need to learn more basic technical knowledge^.^
    Thanks a lot!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE