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?

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.

1 Like

@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!

… 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 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!