+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Junior Member level 3
    Points: 892, Level: 6

    Join Date
    Jun 2009
    Posts
    28
    Helped
    1 / 1
    Points
    892
    Level
    6

    how to check if a serial port is being used by any other process or a program

    how to check if serial port(typically COM1) being used by any other program??

    is there any application to check so??

    •   Alt25th January 2011, 12:32

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 35,219, Level: 45
    Awards:
    Helpful bronze
    ckshivaram's Avatar
    Join Date
    Apr 2008
    Location
    villingen (Germany) / Bangalore
    Posts
    5,070
    Helped
    2125 / 2125
    Points
    35,219
    Level
    45
    Blog Entries
    1

    Re: how to check if a serial port is being used by any other process or a program

    If you use same com port once and t open the same port the OS will throw error that the port is already open...

    some times there will be problem that we do multiple mouse click when the application do not open and we find or see only 1 application in the task bar, but in the background there will be other instances of the same port so we get error that port is already open....

    you can find out multiple port opening with task manager , or go to device manager and hardware devices list and get the port details and see if any ports have the same COM port setting and name....
    " It is so simple to be happy,
    but it is so difficult to be simple"



  3. #3
    Junior Member level 3
    Points: 892, Level: 6

    Join Date
    Jun 2009
    Posts
    28
    Helped
    1 / 1
    Points
    892
    Level
    6

    Re: how to check if a serial port is being used by any other process or a program

    i hav only a single port, i.e, COM1 which i want to use isp..
    plz explain in detail what are d steps to be followed for checking if the port is being used?
    also tell me what do u mean by port 'open' ?



    •   Alt25th January 2011, 13:27

      advertising

        
       

  4. #4
    Full Member level 1
    Points: 3,068, Level: 13
    srhoar's Avatar
    Join Date
    Jul 2002
    Location
    The center of the World - Dallas
    Posts
    119
    Helped
    21 / 21
    Points
    3,068
    Level
    13

    Re: how to check if a serial port is being used by any other process or a program

    Quick question. What language are you developing in?

    in C

    Code:
    //com.c
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      char c;
      FILE *fp;
      if ((fp=fopen("/dev/com1","r"))!=NULL) {
        while ((c=(char)getc(fp))!=EOF)
          putc(c,stdout);
        fclose(fp);
      } else
      printf("com1 already in use\n");
      return 0;
    }
    basically,
    try to open the com port.
    for fopen()
    If the file has been succesfully opened the function will return a pointer to a FILE object that is used to identify the stream on all further operations involving it. Otherwise, a null pointer is returned.
    ie, if you get nothing back, it didn't open the port and something else is using it.

    the above code runs in cygwin. if you execute:
    >gcc com.c
    >a
    it will open com1
    you can test this by opening hyperterminal and trying to open com1. Hyperterminal will return that the port is already in use.
    do a CTRL-c to exit the cygwin program and retry hyperterminal. You should find that you can now open it.
    Now run a.exe in cygwin. It will respond com1 already in use.

    That should get you going.

    Red
    Last edited by srhoar; 25th January 2011 at 14:14. Reason: additional info



  5. #5
    Junior Member level 3
    Points: 892, Level: 6

    Join Date
    Jun 2009
    Posts
    28
    Helped
    1 / 1
    Points
    892
    Level
    6

    Re: how to check if a serial port is being used by any other process or a program

    @srhoar: u didn't get it...
    my problem is that i am facing problems with any serial interface...it seems to me (may be i cud be wrong) that my only serial port(COM1) is being used by any other process..i have a 8051 kit which on 1 out of 20 occasions shows that interface is ready(although still problems in it as it is not able to burn the program into the uc) ....rest of the times it shows an error that burner kit is not connected. No problem in the burner...
    My question is: "Do u have any way/technique of finding out whether any process is using the serial port right now?"...I am using windows xp version 2002 sp2...Just give me a step by step procedure...:)



  6. #6
    Advanced Member level 5
    Points: 35,219, Level: 45
    Awards:
    Helpful bronze
    ckshivaram's Avatar
    Join Date
    Apr 2008
    Location
    villingen (Germany) / Bangalore
    Posts
    5,070
    Helped
    2125 / 2125
    Points
    35,219
    Level
    45
    Blog Entries
    1

    Re: how to check if a serial port is being used by any other process or a program

    as i told you whenever you get this error go to task manager of your computer by (ctrl+ alt + del), and chech in the process if any com port application is opened. close all application of com port if multiple application are open...

    Are you using any bluetooth dongle or device connected to PC when this error happens.??????

    next step will be to go to system mamanger and check for possible faults
    " It is so simple to be happy,
    but it is so difficult to be simple"



  7. #7
    Banned
    Points: 340, Level: 3

    Join Date
    Dec 2010
    Posts
    66
    Helped
    10 / 10
    Points
    340
    Level
    3

    Re: how to check if a serial port is being used by any other process or a program

    do you by any chance open 2 applications using same port such as programmer and hyperterminal.. where you just disable hyperterminal instead of closing application.. you get these errors



+ Post New Thread
Please login