Author Topic: Handling RTS and DSR signal in usb device cdc class  (Read 17896 times)

pwk

  • Member
  • ***
  • Posts: 4
Handling RTS and DSR signal in usb device cdc class
« on: May 21, 2014, 06:02:21 am »
I accidentally deleted the original post; here it is:

I am implementing the usb device cdc class application, using external usb controller MAX3421E on FPGA platform.
In my application the usb device cdc class working properly and detecting the virtual com port.

Now i have to handle the DSR and RTS uart signal in my usb device cdc class application. These signal handled by request Serial state Notification, send by the host.

My problem is that...the host does not send the Serial state Notification request in my application.

I am attaching here the two  usblyzer data log in .html format, one is working i.e tower cdc and other is not working i.e FPGA cdc(my application data log).

In FPGA cdc usblyzer data log, i found that Query Pnp Device State ---> not supported......is that issue? i don't understand.
 
Please observe the both usblyzer data log and suggest me any solution....where i am getting stuck.

« Last Edit: May 21, 2014, 09:48:10 am by Jan Axelson »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #1 on: May 21, 2014, 09:48:33 am »
A CDC device may return the state of DSR in a SERIAL_STATE notification on the interrupt IN endpoint.

A host uses the SET_CONTROL_LINE_STATE control request to set or clear RTS.

In the device's abstract control model functional descriptor, bmCapabilities indicates whether the device supports  Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State. See 5.3.2 in PSTN120.pdf in the CDC specification.

pwk

  • Member
  • ***
  • Posts: 4
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #2 on: May 21, 2014, 01:16:41 pm »
Hi Jan,

Thanks for reply,
As you said, I have already configure abstract control model functional descriptor descriptor as follow....but till host not send Serial state Notification request.

const UINT8_T au8DeviceDescriptor[]=   // DEVICE Descriptor
{
  0x12,           // bLength = 18d
  0x01,           // bDescriptorType = Device (1)
  0x00,0x02,      // bcdUSB(L/H) USB spec rev (BCD)
  0x02,           // bDeviceClass,
  0x00,           // bDeviceSubClass,
  0x00,           // bDeviceProtocol
  0x40,           // bMaxPacketSize0 EP0 is 64 bytes
  0x04,0x25,      // idVendor(L/H)--Microsoft is 045E
  0x00,0x03,      // idProduct(L/H)--XBOX 360 Controller
  0x02,0x00,      // bcdDevice--1234
  0x01,           //iManufacturer
  0x02,           //iProduct,
  0x00,           // iSerialNumber
  0x01            //bNumConfigurations
};

//Configuration Descriptor

const UINT8_T au8ConfigurationDescriptor[]= // CONFIGURATION Descriptor
{
//Configuration Descriptor

    0x09, // bLength
    0x02, // bDescriptorType = Config
    0x43,0x00, // wTotalLength(L/H) = 67 bytes
    0x02, // bNumInterfaces
    0x01, // bConfigValue
    0x00, // iConfiguration
    0xC0, // bmAttributes. b7=1 b6=Bus-powered b5=RWU supported
    0x32, // MaxPower

    // INTERFACE Descriptor
    0x09, // length = 9
    0x04, // type = IF
    0x00, // IF #0
    0x00, // bAlternate Setting
    0x01, // bNum Endpoints
    0x02, // bInterfaceClass = CDC
    0x02, // bInterfaceSubClass,
    0x00, // bInterfaceProtocol
    0x00, // iInterface

    // CDC class specific Descriptor
    0x05, // bLength
    0x24, // bDescriptorType
    0x00, // CDC Header function descriptor
    0x10, 0x01, // Rev 1.1

    0x05, // bLength
    0x24, // bDescriptorType
    0x01, //Call Management function descriptor
    0x01,
    0x01,

    0x04, // bLength
    0x24, // bDescriptorType
    0x02, // Abstract control function descriptor
    0x06,

    0x05, // bLength
    0x24, // bDescriptorType
    0x06, // Union function descriptor
    0x00,
    0x01,


    //Endpoint Descriptor - Notification
    0x07, // Size of descriptor
    0x05, // Type of descriptor
    0x83, // Address of descriptor Bit- 7 1-IN/0-OUT Bit-0-3 endpoint no.
    0x03, // bmAtributts Bit- 0-1 indicate transfer type 11-interrupt
    0x10, // LSB Packet size
    0x00, // MSB Packet size
    0x0A, // Polling interval 10 ms


    // INTERFACE Descriptor
    0x09, // length = 9
    0x04, // type = IF
    0x01, // IF #1
    0x00, // bAlternate Setting
    0x02, // bNum Endpoints
    0x0A, // bInterfaceClass = DIC
    0x00, // bInterfaceSubClass,
    0x00, // bInterfaceProtocol
    0x00, // iInterface

    //Endpoint descriptor BULK OUT 1
    0x07, // Size of descriptor
    0x05, // Type of descriptor
    0x01, // Address of descriptor Bit- 7 1-IN/0-OUT Bit-0-3 endpoint no.
    0x02, // bmAtributts Bit- 0-1 indicate transfer type 10-bulk
    0x40, // LSB Packet size
    0x00, // MSB Packet size
    0x00, // Polling interval 0 ms

    //Endpoint descriptor BULK IN 2
    0x07, // Size of descriptor
    0x05, // Type of descriptor
    0x82, // Address of descriptor Bit- 7 1-IN/0-OUT Bit-0-3 endpoint no.
    0x02, // bmAtributts Bit- 0-1 indicate transfer type 10-bulk
    0x40, // LSB Packet size
    0x00, // MSB Packet size
    0x00 // Polling interval 0 ms


};

//Get line coding

const UINT8_T au8GetLineCode[] =
{
 /*e.g. 0x00,0x10,0x0E,0x00 : 0x000E1000 is 921600 bits per second */
    (115200>> 0) & 0x000000FF,
    (115200>> 8) & 0x000000FF,
    (115200>>16) & 0x000000FF,
    (115200>>24) & 0x000000FF,
     0x01,
     0x00,
     0x08
};

const UINT8_T au8GetAbstractState[]=
{
   0x0000,
   0x0000
};

const UINT8_T au8GetCountryCode[]=
{
   0x0000,
   0x0000
};

const UINT8_T au8GetSerialState[]=
{
   0xa1,
   0x20,
   0x00,
   0x00,
   0x00,
   0x00,
   0x02,
   0x00,
   0x00,
   0x00,
};

Please check these descriptors are correct or not ....

USBlyzer Report as follows.... I am not able to attache usblyzer data log doc. so that i am copy paste here.....

Capture List Type Seq Time Elapsed Duration Request Request Details Raw Data I/O C:I:E Device Object Device Name Driver Name IRP Status
START 0001 16:37:06.964             
PnP 0002 16:37:12.163 5.198332 s  Start Device     892BC0F0h USBSER000 usbser 85E91068h 
PnP 0003 16:37:12.163 5.198341 s  Start Device     861C7660h  ACPI 85E91068h 
PnP 0004 16:37:12.163 5.198365 s  Start Device     B0E5C4A0h USBPDO-6 usbhub 85E91068h 
PnP 0005-0004 16:37:12.163 5.198570 s 205 us Start Device     B0E5C4A0h USBPDO-6 usbhub 85E91068h Success
PnP 0006-0003 16:37:12.163 5.198576 s 235 us Start Device     861C7660h  ACPI 85E91068h Success
URB 0007 16:37:12.163 5.198593 s  Get Descriptor from Device Dvc  in  861C7660h  ACPI 8A82CE48h 
URB 0008 16:37:12.163 5.198599 s  Get Descriptor from Device Dvc  in  B0E5C4A0h USBPDO-6 usbhub 8A82CE48h 
URB 0009-0008 16:37:12.164 5.199694 s 1.094 ms Control Transfer Get Descriptor (Dvc) 12 01 00 02 02 00 00 40... in --:--:00 B0E5C4A0h USBPDO-6 usbhub 8A82CE48h Success (Success)
00000000  12 01 00 02 02 00 00 40 04 25 00 03 02 00 01 02  .......@.%......
00000010  00 01                                            ..             

 
URB 0010-0007 16:37:12.164 5.199700 s 1.107 ms Control Transfer Get Descriptor (Dvc) 12 01 00 02 02 00 00 40... in --:--:00 861C7660h  ACPI 8A82CE48h Success (Success)
00000000  12 01 00 02 02 00 00 40 04 25 00 03 02 00 01 02  .......@.%......
00000010  00 01                                            ..             

 
URB 0011 16:37:12.164 5.199712 s  Get Descriptor from Device Cfg ind:0  in  861C7660h  ACPI 8A82CE48h 
URB 0012 16:37:12.164 5.199718 s  Get Descriptor from Device Cfg ind:0  in  B0E5C4A0h USBPDO-6 usbhub 8A82CE48h 
URB 0013-0012 16:37:12.165 5.201195 s 1.477 ms Control Transfer Get Descriptor (Cfg ind:0) 09 02 43 00 02 01 00 C0... in --:--:00 B0E5C4A0h USBPDO-6 usbhub 8A82CE48h Success (Success)
00000000  09 02 43 00 02 01 00 C0 32 09 04 00 00 01 02 02  ..C.....2.......
00000010  00 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06  ...$....$....$..
00000020  05 24 06 00 01 07 05 83 03 0A 00 0A 09 04 01 00  .$..............
00000030  02 0A 00 00 00 07 05 01 02 40 00 00 07 05 82 02  .........@......
00000040  40 00 00                                         @..             

 
URB 0014-0011 16:37:12.165 5.201201 s 1.489 ms Control Transfer Get Descriptor (Cfg ind:0) 09 02 43 00 02 01 00 C0... in --:--:00 861C7660h  ACPI 8A82CE48h Success (Success)
00000000  09 02 43 00 02 01 00 C0 32 09 04 00 00 01 02 02  ..C.....2.......
00000010  00 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06  ...$....$....$..
00000020  05 24 06 00 01 07 05 83 03 0A 00 0A 09 04 01 00  .$..............
00000030  02 0A 00 00 00 07 05 01 02 40 00 00 07 05 82 02  .........@......
00000040  40 00 00                                         @..             

 
URB 0015 16:37:12.165 5.201212 s  Select Configuration 1    861C7660h  ACPI 8A82CE48h 
URB 0016 16:37:12.165 5.201218 s  Select Configuration 1    B0E5C4A0h USBPDO-6 usbhub 8A82CE48h 
URB 0017-0016 16:37:12.166 5.202150 s 932 us Select Configuration 1    B0E5C4A0h USBPDO-6 usbhub 8A82CE48h Success (Success)
URB 0018-0015 16:37:12.166 5.202158 s 945 us Select Configuration 1    861C7660h  ACPI 8A82CE48h Success (Success)
URB 0019 16:37:12.166 5.202203 s  Class Interface Get Line Coding (Ifc:0)  in  861C7660h  ACPI 8A82CE48h 
URB 0020 16:37:12.166 5.202208 s  Class Interface Get Line Coding (Ifc:0)  in  B0E5C4A0h USBPDO-6 usbhub 8A82CE48h 
URB 0021-0020 16:37:12.167 5.202945 s 737 us Control Transfer Get Line Coding (Ifc:0) 00 96 00 00 01 00 08 in --:--:00 B0E5C4A0h USBPDO-6 usbhub 8A82CE48h Success (Success)
00000000  00 96 00 00 01 00 08                             .......         

 
URB 0022-0019 16:37:12.167 5.202950 s 747 us Control Transfer Get Line Coding (Ifc:0) 00 96 00 00 01 00 08 in --:--:00 861C7660h  ACPI 8A82CE48h Success (Success)
00000000  00 96 00 00 01 00 08                             .......         

 
URB 0023 16:37:12.167 5.203025 s  Class Interface Set Control Line State (Ifc:0)  out  861C7660h  ACPI 8A82CE48h 
URB 0024 16:37:12.167 5.203030 s  Class Interface Set Control Line State (Ifc:0)  out  B0E5C4A0h USBPDO-6 usbhub 8A82CE48h 
URB 0025-0024 16:37:12.168 5.204052 s 1.022 ms Control Transfer Set Control Line State (Ifc:0)  out --:--:00 B0E5C4A0h USBPDO-6 usbhub 8A82CE48h Success (Success)
URB 0026-0023 16:37:12.168 5.204058 s 1.034 ms Control Transfer Set Control Line State (Ifc:0)  out --:--:00 861C7660h  ACPI 8A82CE48h Success (Success)
URB 0027 16:37:12.168 5.204080 s  Bulk or Interrupt Transfer 4096 bytes buffer  in 01:01:82 861C7660h  ACPI 8A82CE48h 
URB 0028 16:37:12.168 5.204087 s  Bulk or Interrupt Transfer 4096 bytes buffer  in 01:01:82 B0E5C4A0h USBPDO-6 usbhub 8A82CE48h 
URB 0029 16:37:12.168 5.204125 s  Bulk or Interrupt Transfer 10 bytes buffer  in 01:00:83 861C7660h  ACPI 8A2B8E48h 
URB 0030 16:37:12.168 5.204130 s  Bulk or Interrupt Transfer 10 bytes buffer  in 01:00:83 B0E5C4A0h USBPDO-6 usbhub 8A2B8E48h 
PnP 0031-0002 16:37:12.168 5.204155 s 5.823 ms Start Device     892BC0F0h USBSER000 usbser 85E91068h Success
PnP 0032 16:37:12.169 5.204316 s  Query Capabilities     892BC0F0h USBSER000 usbser 85E91068h 
PnP 0033 16:37:12.169 5.204322 s  Query Capabilities     861C7660h  ACPI 85E91068h 
PnP 0034 16:37:12.169 5.204331 s  Query Capabilities     B0E5C4A0h USBPDO-6 usbhub 85E91068h 
PnP 0035-0034 16:37:12.169 5.204340 s 9 us Query Capabilities     B0E5C4A0h USBPDO-6 usbhub 85E91068h Success
PnP 0036-0033 16:37:12.169 5.204390 s 69 us Query Capabilities     861C7660h  ACPI 85E91068h Success
PnP 0037-0032 16:37:12.169 5.204397 s 80 us Query Capabilities     892BC0F0h USBSER000 usbser 85E91068h Success
PnP 0038 16:37:12.169 5.204426 s  Query Pnp Device State     892BC0F0h USBSER000 usbser 85E91068h 
PnP 0039 16:37:12.169 5.204431 s  Query Pnp Device State     861C7660h  ACPI 85E91068h 
PnP 0040 16:37:12.169 5.204435 s  Query Pnp Device State     B0E5C4A0h USBPDO-6 usbhub 85E91068h 
PnP 0041-0040 16:37:12.169 5.204440 s 5 us Query Pnp Device State     B0E5C4A0h USBPDO-6 usbh ub 85E91068h NotSupported [/b]
PnP 0042-0039 16:37:12.169 5.204445 s 14 us Query Pnp Device State     861C7660h  ACPI 85E91068h Success
PnP 0043-0038 16:37:12.169 5.204450 s 24 us Query Pnp Device State     892BC0F0h USBSER000 usbser 85E91068h Success
PnP 0044 16:37:12.169 5.204459 s  Query Device Relations Bus Relations    892BC0F0h USBSER000 usbser 85E91068h 
PnP 0045 16:37:12.169 5.204464 s  Query Device Relations Bus Relations    861C7660h  ACPI 85E91068h 
PnP 0046 16:37:12.169 5.204472 s  Query Device Relations Bus Relations    B0E5C4A0h USBPDO-6 usbhub 85E91068h 
PnP 0047-0046 16:37:12.169 5.204477 s 4 us Query Device Relations Bus Relations    B0E5C4A0h USBPDO-6 usbhub 85E91068h Success
PnP 0048-0045 16:37:12.169 5.204483 s 20 us Query Device Relations Bus Relations    861C7660h  ACPI 85E91068h Success
PnP 0049-0044 16:37:12.169 5.204488 s 29 us Query Device Relations Bus Relations    892BC0F0h USBSER000 usbser 85E91068h Success


This report was generated by USBlyzer

Regards,
Pankaj

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #3 on: May 21, 2014, 02:46:14 pm »
The device sends SERIAL_STATE on the interrupt IN endpoint. The host doesn't request it explicitly, just sends IN token packets periodically.

I believe Query Pnp Device State is referring to something else:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff559618%28v=vs.85%29.aspx

pwk

  • Member
  • ***
  • Posts: 4
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #4 on: May 23, 2014, 01:52:20 am »
Hi Jan,

I have handled the SET CONTROL LINE STATE and SERIAL STATE request as follow, in my code...

//Get line coding
const UINT8_T au8GetLineCode[] =
{
 /*e.g. 0x00,0x10,0x0E,0x00 : 0x000E1000 is 921600 bits per second */
    (115200>> 0) & 0x000000FF,
    (115200>> 8) & 0x000000FF,
    (115200>>16) & 0x000000FF,
    (115200>>24) & 0x000000FF,
     0x01,
     0x00,
     0x08
};

const UINT8_T au8GetAbstractState[]=
{
   0x0000,
   0x0000
};

const UINT8_T au8GetCountryCode[]=
{
   0x0000,
   0x0000
};

const UINT8_T au8GetSerialState[]=
{
   0xa1,
   0x20,
   0x00,
   0x00,
   0x00,
   0x00,
   0x02,
   0x00,
   0x00,
   0x00,
};

//-------------------------------------------------------------------------------------
UINT8_T fnClassRequest(void)
{

  //Parse the SETUP Packet, for Request look at first byte
   switch(au8SetupPacketBuffer[bRequest])
   {
     
     case  CR_GET_LINE_CODING: // (0X21)
       {
           
            //Write the Descriptor at Endpoint 0 IN FIFO
            fnWriteBytes(rEP0FIFO, 7, &au8GetLineCode);--------> Sending on endpoint 0

            //Load EP0BC to arm the EP0-IN transfer & ACKSTAT
            fnWriteMax3421RegAS(rEP0BC,7);

         break;
       }

     case  CR_SET_CONTROL_LINE_STATE:   //(0X22)
       {
            //Dummy read to set the ACKSTAT bit
            fnReadMax3421RegAS(rFNADDR);  -------> here only send the ACK
         
         break;
       }
     case GET_ABSTRACT_STATE:    //(0X23)
       {
            //Write the Descriptor at Endpoint 0 IN FIFO
            fnWriteBytes(rEP0FIFO, 2, &au8GetAbstractState);

            //Load EP0BC to arm the EP0-IN transfer & ACKSTAT
            fnWriteMax3421RegAS(rEP0BC,2);

            break;
       }
     case GET_COUNTRY_SETTING :  // (0X24)
     {
           //Write the Descriptor at Endpoint 0 IN FIFO
           fnWriteBytes(rEP0FIFO, 2, &au8GetCountryCode);

          //Load EP0BC to arm the EP0-IN transfer & ACKSTAT
          fnWriteMax3421RegAS(rEP0BC,2);

          break;
     }
     case GET_SERIAL_STATE :   //(0X20)
     {
          //Write the Descriptor at Interrupt Endpoint 3 IN FIFO ---->sending at EP3 IN Interrupt Endpoint     
         fnWriteBytes(rEP3INFIFO, 10 , &au8GetSerialState);

         //Load rEP3INBC to arm the EP3-IN transfer & ACKSTAT
         fnWriteMax3421RegAS(rEP3INBC, 10);

         break;
     }
     //Unrecognized request type
     default:

       STALL_EP0
   }

I have received the only two class request from host side....
The first request is Get line Coding(0x21) and I am responding this request on Endpoint 0 as shown above.

The second request I have received is Set Control Line state(0x22) and I am responding this request by sending ACK only.

Then after that no one request send by the host side....

I have handle the Serial State request at case: GET_SERIAL_STATE(0x20) as shown in above code....but host dosen't send this request.

Please check above code is correct or  Is there any mistake in this code?



Regards,
Pankaj

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #5 on: May 23, 2014, 09:47:22 am »
Serial_State is a notification, not a request.

The host can do what it wants and might choose not to implement the handshaking.

pwk

  • Member
  • ***
  • Posts: 4
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #6 on: May 27, 2014, 03:00:52 am »
Hello Jan,

Thanks for your help,

I found the one mistake in my code, that is... forgot to arm the endpoint for next transfer....
as follow....

 //Load EP3BC to arm the EP3-IN transfer & ACKSTAT
  fnWriteMax3421RegAS(rEP3BC,2);

Now it is working fine....Serial State Notification send by the host.


Thanks&Regards,
Pankaj

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Handling RTS and DSR signal in usb device cdc class
« Reply #7 on: May 27, 2014, 10:01:11 am »
Glad you got it working! Thanks for reporting what you found.