Announcement

Collapse
No announcement yet.

ComPort built in or virtual (USB)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ComPort built in or virtual (USB)

    Hello PB - community,
    after the function CreateFile(...) has successfully retrieved a valid handle to a serial-port, I want to find out, if that port is an existing physical device or
    maybe an USB-Serial-converter.
    Is there any way to find out?

    Thanks and greetings
    Heinz Grandjean

    P.S. Thanks again for the help concerning my speed-question from last week.
    Heinz Grandjean
    http://www.estwgj.com/

  • #2
    Hi Heinz,
    Before anyone says "No", let me be the first to say "YES"

    Although I am still working on it, so I can not post a simple snippet just yet, but it can be done. But to give you a jump-start on how its done, look in the Source Code Forum for my USB postings....One that comes to mind is "USB In-Complete"

    Also, tonight I hope to be posting a question on where I am stuck, that may be of some help to you as to the real name of "COM1" vs the name of Usb adapter with the same name of "COM1"

    Sorry I couldn't give you a short-simple answer, but like I said, I am working on it.
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

    Comment


    • #3
      Hello Cliff,
      many thanks for a first advice.
      Maybe the setupapi.dll could be an answer.
      I found in the Poffs an example made by Pierre Bellisle.
      Heinz Grandjean
      http://www.estwgj.com/

      Comment


      • #4
        Hi Heinz,
        A while back both myself and Pierre did basically the same thing using SetupApi, so you are on the right track

        Now that I was able to find the paths I was looking for, basically the difference for a "Real" Comport are:
        Code:
        '     ErrFunc = CreateFile("COM1", %GENERIC_READ OR %GENERIC_WRITE, 0, BYVAL 0, %OPEN_EXISTING, %FILE_FLAG_OVERLAPPED, %NULL)        'Windows Friendly Name
             DevHndl = CreateFile("\\?\acpi#pnp0501#1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}", %GENERIC_READ OR %GENERIC_WRITE, 0, BYVAL 0, %OPEN_EXISTING, %FILE_FLAG_OVERLAPPED, %NULL)        'Windows REAL Name
        Where to my knowledge, if the path includes "acpi" then it is a real ComPort, but if it has a "VID" and "PID" then it is a Virtual Com
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          Hi Heinz and Cliff,

          Note that this demo have been updated, look at Hardware enumeration using SetupApi.dll

          Comment


          • #6
            WOW Pierre

            WOWSERS!!! Nice Job!!! :rockwoot:

            I never realized you optimized so well, now I am going to have to go back to my initial code and see if your route is faster (and probably better) than mine, since its been so long of my endless nights and weekends :coffee2:

            Since then, I am close (or I hope I am close, but you know the walls that keep cropping up every time I think I am close) to actually communicating with the device.

            Last best hurdle I got over is Enumerate everything, find the info, check if the device is available or in use or if the device is known to windows but can not be used because of some problem.

            So far, so good...If I can only get the rest of the pieces in place then I can post what started small but may be "The Holy Grail" as far as USB and other devices

            ("No....No...Tis nothing but a scratch" ....Monty Python)

            Thanx again for all the help that you and the guys in the forums have given me
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment

            Working...
            X