• Serial port query

    From Darin McBride@1:250/102 to all on Thursday, August 03, 2000 17:37:56
    Hello !

    I've been asked how to do something I'm at a loss as to where to start - if it's possible at all. To quote the person asking me:

    Is there a way 1. to check the state of a port, 2. determine the application using it?

    By #1, I believe he means "determine if a comm port was in use".

    Any ideas whatsoever would be appreciated. I believe #1 can be done by an attempt to open the port as a file in "DENY_ALL" mode - if it fails, someone is
    using it. I don't believe #2 is possible. If I could be corrected, that would
    be great. :-)

    Thanks,

    Darin

    ---
    * Origin: Tanktalus' Tower BBS (1:250/102)
  • From Vitus Jensen@2:2474/424.1 to Darin McBride on Sunday, August 06, 2000 17:55:48
    Moin Darin!

    04.08.2000, Darin McBride wrote a message to all:

    I've been asked how to do something I'm at a loss as to where to start
    - if it's possible at all. To quote the person asking me:

    Is there a way 1. to check the state of a port, 2. determine the application using it?

    By #1, I believe he means "determine if a comm port was in use".

    Any ideas whatsoever would be appreciated. I believe #1 can be done
    by an attempt to open the port as a file in "DENY_ALL" mode - if it
    fails, someone is using it. I don't believe #2 is possible. If I
    could be corrected, that would be great. :-)

    Get OS2UNDOC from hobbes and have a look at the DosQuerySysState API. It will return infos about all open files of a single or all processes. There are problems when using it at certain fixpak levels (older Warp 3 fixpaks).

    And Scott Garfinkle posted in C.O.O.P.Misc that it is now possible getting infos about all open semaphore handles as well. Starting with FP 13 AFAIR (got
    the msg stored somewhere).

    Bye,
    Vitus

    ---
    * Origin: PATH=C:\DOS;C:\DOS\RUN;C:\WIN\CRASH\DOS;C:\ME\DEL\WIN (2:2474/424.1)
  • From Darin McBride@1:250/102 to Vitus Jensen on Sunday, August 06, 2000 16:12:28
    Hello Vitus!

    Replying to a message of Vitus Jensen to Darin McBride:

    I've been asked how to do something I'm at a loss as to where to
    start - if it's possible at all. To quote the person asking me:

    Is there a way 1. to check the state of a port, 2. determine the
    application using it?

    By #1, I believe he means "determine if a comm port was in use".

    Any ideas whatsoever would be appreciated. I believe #1 can be done
    by an attempt to open the port as a file in "DENY_ALL" mode - if it
    fails, someone is using it. I don't believe #2 is possible. If I
    could be corrected, that would be great. :-)

    Get OS2UNDOC from hobbes and have a look at the DosQuerySysState API.
    It will return infos about all open files of a single or all
    processes. There are problems when using it at certain fixpak levels (older Warp 3 fixpaks).

    Of course! I forgot all about that. I already use that call for a number of things, so one more is no biggie. :-) Unfortunately, I can't figure out how to trace back from the file to the process(es). I've done some slight modifications to the sample programs given in the undoc INF file, and I get:

    name: D:\BBS\MAIL\ECHO\FIDONET\BACKBONE\OS2PROG.SQD
    opencnt: 1
    sfn: e0
    refcnt: 1
    flags: 0
    accmode: c2
    filesize: 62315
    volhnd: 264
    attrib: 20 [A-----]

    Now, *I* know which process this is:

    PID: 1736
    PPID: 30
    type: 3
    state: 10
    session id: 36
    mod handle: 1be8 (D:\BBS\FLEET\FLTSTRT.EXE)
    # of threads: 4
    [...]

    I just can't tell how to get from one to the other.

    And Scott Garfinkle posted in C.O.O.P.Misc that it is now possible
    getting infos about all open semaphore handles as well. Starting
    with FP 13 AFAIR (got the msg stored somewhere).

    DQSS doesn't seem to get 32-bit sem handles yet... :-( 16-bit doesn't seem to be a problem. (I recently installed FP14.)

    Darin

    ---
    * Origin: Tanktalus' Tower BBS (1:250/102)
  • From Vitus Jensen@2:2474/424.1 to Darin McBride on Wednesday, August 09, 2000 20:23:58
    Moin Darin!

    06.08.2000, Darin McBride wrote a message to Vitus Jensen:

    ...
    Is there a way 1. to check the state of a port, 2. determine the
    application using it?

    By #1, I believe he means "determine if a comm port was in use".

    Any ideas whatsoever would be appreciated. I believe #1 can be done
    by an attempt to open the port as a file in "DENY_ALL" mode - if it
    fails, someone is using it. I don't believe #2 is possible. If I
    could be corrected, that would be great. :-)

    Get OS2UNDOC from hobbes and have a look at the DosQuerySysState API.
    It will return infos about all open files of a single or all
    processes. There are problems when using it at certain fixpak
    levels (older Warp 3 fixpaks).

    Of course! I forgot all about that. I already use that call for a
    number of things, so one more is no biggie. :-) Unfortunately, I
    can't figure out how to trace back from the file to the process(es).

    Use the brute force method? See below.


    I've done some slight modifications to the sample programs given in
    the undoc INF file, and I get:

    name: D:\BBS\MAIL\ECHO\FIDONET\BACKBONE\OS2PROG.SQD
    opencnt: 1
    sfn: e0
    refcnt: 1
    flags: 0
    accmode: c2
    filesize: 62315
    volhnd: 264
    attrib: 20 [A-----]

    Now, *I* know which process this is:

    PID: 1736
    PPID: 30
    type: 3
    state: 10
    session id: 36
    mod handle: 1be8 (D:\BBS\FLEET\FLTSTRT.EXE)
    # of threads: 4
    [...]

    I just can't tell how to get from one to the other.
    ...

    There is this lees-than-optimal solution but why not use it:

    get a list of all running processes via DosQuerySysState
    for every process ID
    get a list of all open files via DosQuerySysState
    for every open file
    check whether filename = COMx
    if identical
    dump process info (DosQuerySysState)

    I don't think it would be too slow to be usable.

    Bye,
    Vitus

    ---
    * Origin: Of all the things I've lost, I miss my mind the most. (2:2474/424.1)
  • From Darin McBride@1:250/102 to Vitus Jensen on Friday, August 11, 2000 13:29:40
    Hello Vitus!

    Replying to a message of Vitus Jensen to Darin McBride:

    Get OS2UNDOC from hobbes and have a look at the DosQuerySysState
    API. It will return infos about all open files of a single or all
    processes. There are problems when using it at certain fixpak
    levels (older Warp 3 fixpaks).

    Of course! I forgot all about that. I already use that call for a
    number of things, so one more is no biggie. :-) Unfortunately, I
    can't figure out how to trace back from the file to the process(es).

    Use the brute force method? See below.

    [...]

    There is this lees-than-optimal solution but why not use it:

    get a list of all running processes via DosQuerySysState
    for every process ID
    get a list of all open files via DosQuerySysState
    for every open file
    check whether filename = COMx
    if identical
    dump process info (DosQuerySysState)

    I don't think it would be too slow to be usable.

    Of course - didn't think of that. However, I've found what may work a bit better, if I can decipher everything. The Warp4.5 toolkit *has* DosQuerySysState somewhat documented, and some of its structures are a bit bigger than what OS2UNDOC has. Unfortunately, I don't have that toolkit at home... :-/

    Darin

    ---
    * Origin: Tanktalus' Tower BBS (1:250/102)
  • From Vitus Jensen@2:2474/424.1 to Darin McBride on Saturday, August 12, 2000 16:11:52
    Hi Darin!

    11.08.2000, Darin McBride wrote a message to Vitus Jensen:

    ...
    Of course - didn't think of that. However, I've found what may work a
    bit better, if I can decipher everything. The Warp4.5 toolkit *has* DosQuerySysState somewhat documented, and some of its structures are
    a bit bigger than what OS2UNDOC has. Unfortunately, I don't have
    that toolkit at home... :-/

    I've forwarded the post from Scott Garfinkel to you. Perhaps this might shed even more light about DosQuerySysState.

    Bye,
    Vitus

    ---
    * Origin: OS/2: Your brain. Windows: Your brain on drugs. (2:2474/424.1)