robotics_mait
Junior Member level 3
how to check if serial port(typically COM1) being used by any other program??
is there any application to check so??:roll::roll::roll:
is there any application to check so??:roll::roll::roll:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
//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;
}
ie, if you get nothing back, it didn't open the port and something else is using it.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.