Results 1 to 8 of 8

Thread: Control serial port pin with API

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    96

    Control serial port pin with API

    Hi.

    Does anybody have an example on have to control the pins on the serial port thru API (not using MScomm) in VB 6.

    I realy need this, since I need to be able to have TOTAL control of ALL the pin on the com port.
    Best Regards from.

    Chris101

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    What are you mean by "control the pins"? I'm curious as to what you want to do.

    If you're talking about individually managing what's going on with the pins, I _think_ that's even below API stuff, it's hardware. Not to mention is might be RJ45's, 11's DB9's or 25's or whatever, and that usually at least one wire is a ground.

    For a very simple application, you can even just have one wire - transmit on one end and receive on the other.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    96
    HI.

    I need to be able to control TXD, DTR, DSR, RTS and CTS separetly, without them turning one or the other on or off, I know this can be done in Delphi and C++ (dont know how) but should it not be possible in VB6, there must be another way than using the MSComm ??
    Best Regards from.

    Chris101

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    That makes sesnse. When I first read "pins" I was thinking pin 2, 3 etc.

    I'm sure the communications control is way too high level for that, wish I knew if there were Windows API calls or if you have to communicate with the driver. I have a book, Serial Communications that talks about that type of stuff, it's using C++. Unfortunately, I'm on the road and won't be home until next week.

    If this thread is still at this point then, I'll see what I can find.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    96
    Hi Mike.

    I would REALY like your help, since I'm stuck here at the moment, so I won't close this thread unless someone has another GOOD answer for me.
    Best Regards from.

    Chris101

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    I'll try my best, but can't promise anything

    It's just plain interesting to me, so I want to figure it out. For some reason, I'm fascinated by com ports. Still trying to get the guts up to put my tounge against one to see if I get shocked when data is sent.

    I won't be home (have access to my book) until at least Saturday. But in case you're near a book store, it's called "Serial Communications", can't remember the author.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    96
    Hi

    I found some more info, it's some of these API's we need:
    CreateFile -> To open the COM port

    SetCommState (to set the state of some signals)

    GetCommState (to get the state of some signals)

    CloseHandle -> to close the serial port

    But we need more, we need something to configure the port DCB
    Best Regards from.

    Chris101

  8. #8
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Finally got my book. Now, I'm just reading some stuff, don't know enough about it to explain. I _think_ a reference like this is what you need. The book is called "Serial Communications Developer's Guide" second edition by Mark Nelson. ISBN 0-7645-4570-1. It cost me about $50. This was published in 2000, might be a later edition.

    Anyway, when you say you need to "configure the port DCB", this book explains all that, has example source code etc. Apparently, once the DCB structure is filled out, you pass it to some of the functions in the win 32 API, like SetCommState().

    The DBC structure is quite a beast, with about 24 members. This particular book has some wrapper classes that claim to make it easier on the programmer.

    MSDC has a lot of info also, starting around http://msdn.microsoft.com/library/de..._resources.asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width