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....
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' ?
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.
@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...
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
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