none
USB Serial Port Hub RRS feed

  • Question

  • I need to create a Windows Driver for a serial port hub.  I unfortunately cannot use the built-in CDC driver as I need to support 6 UART ports and do not have enough endpoints available.  So I need to create a serial port driver.  I am aware of the serial port example which is part of the WDK.  Are there any examples showing that being combined with USB?  Do I need to create two drivers?
    Wednesday, August 1, 2018 1:59 PM

Answers

  • in option two, your second INF for the raw child PDO is in the ports class.  it installs the null driver, Essentially AddService with no service name at all.  

    PDOs do not get a device add event, you create the WDFDEVICE PDO explicitly and you can initialize it when it is created


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

    • Marked as answer by iDeadlock Friday, August 10, 2018 7:52 PM
    Friday, August 10, 2018 2:00 PM
  • You should start with the serial sample. No, there isn’t a serial sample that has usb in it. You basically need to rip out all hw access code and replace it with usb commands. The sample is pretty well setup for this. You only need one driver, not two. The bigger decision is if you have your driver enumerate six com port children or expose all six in the fdo. If you want the OS to automatically assign all six com port names you should 1 install the fdo with an inf NOT in the ports class. System class is good. 2 expose each as a raw child device 3 install the child pdo with an inf in the ports class so that the ports class installer assigns a com name to each

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

    Thursday, August 2, 2018 12:26 AM

All replies

  • You should start with the serial sample. No, there isn’t a serial sample that has usb in it. You basically need to rip out all hw access code and replace it with usb commands. The sample is pretty well setup for this. You only need one driver, not two. The bigger decision is if you have your driver enumerate six com port children or expose all six in the fdo. If you want the OS to automatically assign all six com port names you should 1 install the fdo with an inf NOT in the ports class. System class is good. 2 expose each as a raw child device 3 install the child pdo with an inf in the ports class so that the ports class installer assigns a com name to each

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

    Thursday, August 2, 2018 12:26 AM
  • Thank you Doron.  Are there any examples of how to expose a child device?
    Thursday, August 2, 2018 1:04 PM
  • the toaster sample has two bus driver examples, statbus and dynambus, which show the two ways KMDF exposes bus enumeration.  I would suggest the static method as you know ahead of time how many children you will need and they won't come and go

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

    Thursday, August 2, 2018 11:49 PM
  • Thank you!
    Friday, August 3, 2018 2:58 PM
  • So, regarding number 3, what would the function driver be for the child PDO?  Using the toaster example, it sure seems like I need a second driver.
    Tuesday, August 7, 2018 8:22 PM
  • you can

    1) implement the port processing functionality in a child raw PDO without an FDO, where the raw PDO understands everything

    2) implement the com port processing functionlaity in a child raw PDO without an FDO, where the raw PDO just forwards IO to the parent (the raw PDO is pure pass through)

    3) implement the port processing functionality in a second FDO that loads on the child PDO (which is not raw in this case)


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

    Wednesday, August 8, 2018 6:52 PM
  • Ok, I understand each of those options.  The INF file which is required for the exposed child PDO, what driver would that point to? serial.sys and serenum.sys?
    Thursday, August 9, 2018 5:14 PM
  • Ok, I understand each of those options.  

    Do you? really?

    serial.sys and serenum.sys?

    Please review what Doron wrote. Serial.sys does not work with USB. Usbser.sys does, but you said the device does not have enough endpoints. So roll your own.

    -- pa

    Thursday, August 9, 2018 9:09 PM
  • Thank you for your candor, I suppose.  Once I have the child PDO exposed, I must then provide an INF file which maps the child PDO to a function driver.  I would prefer to not create a 2nd driver, so I would like to point to an existing function driver.  I am mainly asking what would be provided in the 2nd INF.  It is of course entirely possible I am missing the point.
    Thursday, August 9, 2018 9:23 PM
  •  I would prefer to not create a 2nd driver, so I would like to point to an existing function driver. 

    It looks like no in-box function driver provides what you need. You will need two INFs as Doron pointed out, because one of the INFs should be of class "Ports". Also, as Doron wrote, the driver (binary) can be only one. So it will be one driver and 2 INFs.  To reuse the same binary, two INFs should specify exactly same service section (which describes the .sys file).

    I am mainly asking what would be provided in the 2nd INF

    It's purpose is to associate the "serial port" devices with device IDs exported by the 1st driver, and with the system provided Ports class installer. The details depend which of the 3 options you choose. Basically it should be similar to other INFs of the Ports class (search in-box INFs for examples) but with your own hardware ID.

    Hope the reputable experts would correct if I've missed something.

    Regards,

    -- pa


    • Edited by Pavel A Friday, August 10, 2018 1:10 PM
    Friday, August 10, 2018 1:05 PM
  • Okay.  Thank you for your response.  I haven't thought about going down that path.  I am attempting to implement option 2.  How do I distinguish between entering the bus and the PDO entering the device add event?
    Friday, August 10, 2018 1:48 PM
  • in option two, your second INF for the raw child PDO is in the ports class.  it installs the null driver, Essentially AddService with no service name at all.  

    PDOs do not get a device add event, you create the WDFDEVICE PDO explicitly and you can initialize it when it is created


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

    • Marked as answer by iDeadlock Friday, August 10, 2018 7:52 PM
    Friday, August 10, 2018 2:00 PM
  • That makes more sense.  Thank you!
    Friday, August 10, 2018 7:52 PM
  • I am slowly making progress on the driver with the very generous help that has been provided.  The next issue I am having is the raw PDO is started in the D3 state which I believe is causing issues.  How do I wake the raw PDO device?  The bus device is in the D0 state.
    Friday, August 10, 2018 9:28 PM
  • Ok, I figured that problem out.  I did not call WdfPdoInitAssignRawDevice which was preventing the PDO form starting.
    • Edited by iDeadlock Thursday, August 16, 2018 1:10 PM
    Monday, August 13, 2018 10:37 PM